This tutorial on Reverse Engineering Flutter App File is a short one, even though it sounds difficult.
I have found it useful at times when I deleted the code
but had the debug app with me.
It would be better for you to bookmark
the page and keep it as a reference, you might need in future.
How Does Flutter Debug Apk Work?
Well, this tutorial requires
the debug-apk of the app. The release version might not work.
In the debug mode, flutter
keeps all the source code along with some comments in a file named
kernel blob.bin
So we will use this file to get
back your codes.
Here is some of the tool and
requirement that I used:
- This method is only applicable to the Debug Mode apps.
- Ubuntu or any Linux OS. This is the OS
I opted for due to some command I used and could not find it in Windows
machine. If you found one, let me know in the comment section.
Please note: There is other
information on the internet with a different method. You can try it out and let
me know in the comment section. I personally tried and found
this method to be the easiest way out.
Step One : Extract Flutter Apk
We will start by extracting the
apk file. Once you extract it, open the terminal in the extracted folder.
Step Two : Renaming The File
Once we are inside the
extracted folder. You need to type the following command:
$ strings
apk-extracted-name/assets/flutter_assets/kernel_blob.bin > code.dart
Well if you are a Linux user,
you know what you are doing here.
The strings command in Linux will read only the text portion of the binary file. So in our case, it will open the kernel_blob.bin file and extract all the text in that file.
We can do this ourself, but it will be a complex
task. You can open the file in the code editor and see for yourself.
At the end of command, you can see ” >
code.dart“. This portion of the command will get that strings and make a
new file (code.dart) and write all the content there.
Step Three : Read The Code File
Well, that is all. Now you can
just open the code.dart file. Don’t get overwhelmed by the size and unwanted
text that the file contains.
The code will not be in the way you have initially written down. It will be all messed up.
You can search the file for some keywords like “import“, “Scaffold” or
any other words related to your project and see the code.
Conclusion
I hope this tutorial has helped you in reverse engineering your
flutter app. You can check my other tutorials
on Flutter.
Have you found a better and easier way to
reverse engineer your Flutter App? Let me know in the comment
section. It would be of great help.