Decompile APK built with Xamarin - c#

Good day all.
I need get C# source code from an apk, I tried a few days ways, but they give me java code.
I built a little game in c# xamarin. I stopped working on it for a while, and now I want continue building it, but I've lost the source code. I have an apk file but cannot get the source code. If there is any way get the source code? Please help me.

first, extract apk using 7zip or winrar. you can also use APKTool
then go to the assemblies folder and open {appname}.dll with dnSpy or dotPeek. if you're not using Microsoft Windows, there's a cross-platform tool called AvaloniaILSpy.
if you don't see the dll file (only .so files) you need to unpack it with this tool.
I opened with dnSpy

First use apktools to unpack apk
then use "https://github.com/tjg1/mono_unbundle" to unpack "libmonodroid_bundle_app.so"
then you will get <your_app_name>.dll
open it by dnSpy

Related

"Invalid Swift Support" Using Native Swift Library in Xamarin.iOS

I just implemented a native library, Charts (original native library), and its working on my phone and simulator. Unfortunately, when I submit it to iTunes connect, it kicks it back after processing and says:
Invalid Swift Support - The SwiftSupport folder is missing. Rebuild
your app using the current public (GM) version of Xcode and resubmit
it.
I'm using XCode to publish the archive to iTunes connect, but don't know how to do what this StackOverflow solution is saying. Since I don't use XCode to start the build process, I'm using Xamarin Studio 6, not sure how to set that setting.
So ideally, I need to "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings".
Anybody have any ideas on how to do this? At a roadblock on releasing the beta until I can get this uploaded.
Thanks for your help!
What's your Xcode version? Make sure to be using the latest and GM one, I believe it to be 7.3. The script described on the Readme copy the files from Xcode folder.
If you unpack the IPA created after the script ran you can check for the folder's existence.
When rebuilding and binding the library the option "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings" Didn't work for me as well.
Apple stated when trying to publish: "Invalid Frameworks folder". Xcode will embed files as in: 'Payload/YOURAPP.app/Frameworks/Charts.framework/Frameworks/libswiftCore.dylib', but in the final App it should be as in: 'Payload/YOURAPP.app/Frameworks/libswiftCore.dylib' and 'SwiftSupport/libswiftCore.dylib'.
To solve the problem the library does it in the build process. And you need the script to fix the 'SwiftSupport' folder. I didn't found a way to tamper with Xamarin Studio 'Archive for Publish' function.
Update: You can just use this script I threw together to fix your IPA so it's properly formatted, download the Auto IPA Packager on Github. It's a simplification of the IPA Packager I reference below, and handles all of the steps below too.
So, I've finally made it submit properly to the App Store, just had to hop through a few more steps than I expected. A lot of my confusion was because I didn't want to leave out other artifacts. I've decided to list the process here so it's very clear for anybody deploying an iOS app in the future that needs to use this tool.
Download the IPA Packager from GitHub.
Then go to Xamarin Studio, and Build > Archive for Publishing.
I've been using XCode to export my archives. Open XCode, Window > Organizer. Find your app archive, and click "Export" and follow the appropriate steps, then save it.
Locate the .ipa file and change it to .zip, and extract it.
Next, in the extracted files, locate the "AppNameFolder > Payload > AppName.app".
Load terminal and execute the following:
sh package_ipa.sh /AppNameFolder/Payload/AppName.app /AppNameFolder/AppName.ipa
AppName.ipa should now be created. This file should be ready to upload to the App Store. However, if your AppNameFolder has a "Symbols" directory you should follow the additional steps below...
Optional: If you have symbol files, you should change the AppName.ipa to AppName.zip and extract the files.
Drag the "AppNameFolder > Symbols" directory into the extracted AppName folder, then zip the contents of the folder and change the extension back to .ipa.
I had some issue getting #jamesbar2 solution to work. Here are my manual steps for uploading Xamarin builds with Swift packages.
Archive your app for Publishing.
When the Archives window pops up, go to it in Finder (right click on it and select "Reveal in Finder").
When Finder appears, we need to access the archive's content (right click and select "Show Package Contents").
Inside of the archive package, create a folder called "SwiftSupport".
Inside of the package navigate to "Product/Applications/YourAppName.app/Frameworks" (You will need to right click on the .app and select "Show Package Contents").
Copy all the swift ".dylib" files inside of the Frameworks directory.
Navigate back to "SwiftSupport" and paste those copied libraries.
Now Launch Xcode and load Organizer (Window -> Organizer).
Find your app in the Archives and "Upload to App Store...".
I was only able to get this to work using Xcode Organizer, using Xamarin always failed.
Note: I am using Visual Studio for Mac Community 7.3.2 (build 12).
Update:
I recently had issues with uploading, with TestFlight rejection email saying something like:
The file libswiftCore.dylib doesn’t have the correct code signature. blah, blah, blah.
To fix this problem instead of copying the Frameworks from your app Framework folder, grab them from Xcode. You can find them at:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Note TestFlight would reject my build if I added all the Frameworks to SwiftSupport folder. Only include the Frameworks that your app is using.

Lost my code visual studio but still got the publish folder, is it possible to get my code back?

I lost my code but I published the code a few days ago in visual studio. Is it possible to reverse the .manifest files and .deploy files back to c# code?
Edit: its a console application
This is all i have: http://imgur.com/nUgKgWz
see here
Reflector and its add-in FileDisassembler.
Reflector will allow to see the source code. FileDisassembler will allow you to convert it into a VS solution.
If you're not using any Source-Control-System your code is lost.
You can try to get back your code by decompiling your published version. Therfor you can use something like ILSpy.

MS VS 2012. my code is not showing up (C#)

I am working on a project and while compiling, my laptop handed up and I have to turn it off manually.
After the restart I found that my code is not showing up. There is no line of code in program.cs file.
I am working on that code since a month. And all of it vanished.
Need help. I have the executable file working properly. But i need the code. Is there any way to find that code ?
Use ILSpy to decompile your executable. You will get the source code back, minus the comments. This is possible because assemblies (like your exe) actually contain "Intermediate Language" (IL), and not native machine code/assembler. From the IL it is possible to get a reasonable representation of the original source code. You may need to recreate the csproj file manually, if you do not have it.
If you have the .exe you must have compiled it, if you compiled it you must have saved it.
Where it is depends on where you saved it. Easiest thing would be to use the search function in Windows – search for whatever you called your program, or failing that, *.csproj. Then you can open the csproj file with Visual Studio and you should get most of it back.

C# solution and source file corrupted due to windows system crash

I am using Windows 7 and Visual Studio 2010.
My system crashed. Now, I am not able to open my C# project solution file.
The source file also corrupted. In Notepad++, its showing NULL characters. However, size of the file is correct.
How can I solve this problem? I really need the project, as it is very important to me.
EDIT:
I find the solution. I used this program (http://ilspy.net/) and able to find the source code from its binary file. Thanks to everyone.
I found solution. I used this program (http://ilspy.net/) and able to find the source code from its binary file.
If the project is corrupted it's likely gone and you'll need to look to your backups.
I've used a few different text editors. I find TextPad to be the best at opening files. I'm even able to open locked files with TextPad. I've been using it for years and I Love It.
Good Luck

Best solution for making an Autorun application?

For my work I need to create a Autorun application for a CD for our client. The problem is all I'm a C# programmer by trade and .NET does not make for the best autoruns since not all computers will have .NET installed on them.
What is a good solution that will work on Win98-Vista computers?
The answer to this question is really one of preference. Technically, anything can be instructed to open as an autorun. The autorun.inf file is simply an instruction file that Windows knows how to read in order to determine what it should do when a CD is inserted. That could be an application (written in any language you choose), a powerpoint presentation, opening a link to a website, etc. As long as you follow the rules of the autorun.inf file:
http://autorun.moonvalley.com/autoruninf.htm
There are many small autorun-utils (some free) that are configurable. I would go for one of those.
http://www.ezau.com/latest/articles/083.shtml
You need two things:
Follow this steps (http://support.microsoft.com/kb/324733 OR http://support.microsoft.com/kb/888469)
When your application is ready (with bootstrapper), you'll have to create a autorun.inf file on CD root path. Search 'autorun.inf create' on your favorite Search Engine.
It is possible using Mono's bundling feature:
"The resulting executable is self contained and does not need the Mono runtime installed to run."
Mono is an Open Source .Net clone and should be able to run most .Net applications. See "Bundles" section here: http://www.mono-project.com/Guide:Running_Mono_Applications
You could use .hta file on CD to launch as splash page, and from there detect if .NET is installed (using COM from HTA file) and then run your custom executable.
.hta files are what Microsoft SQL Server (and most of their others) installation cd uses from memory, easy to make them look very professional (its just html in the background basically)
You can include the runtime with the CD, but you'll have to install it before running your app. You might look into just popping open an html file from the CD.
Otherwise, you can look at writing a small native program that can prompt to install the runtime if it's not there, or run your .NET app if it is.
Try Delphi; it's by far the best way to create native win32 application nowadays.
It creates slick stand-alone .exe files with rich GUI's that don't need any runtime libraries or other annoying dependencies. Works on any windows machine.
There was a program from Macrovision called "Demoshield" that worked well back in the day. I'm not sure if its available anymore, but it was an alright program for creating the auto-run programs.

Categories