Believe that a lot of people should be able to contact the app anti-compilation, this small seven to everyone to bring the entry level routines, they are slowly groping to learn, grow together.
first step, decompile
required tools are:
A. Java environment, in fact, here you just install the burp do not care about this
two. Apktool tools
three. Dex2jar tools
four. Sublime tool: sublime text is a popular code editor software and also an advanced text editor for HTML and prose that can run on Linux,windows and Mac OS X.
five. Jd-gui.exe tool
First let's look at the structure of the APK file:
- Meta-inf: Signature file (How this is generated later will be mentioned)
- Res: A resource file in which XML format files are converted from text format to binary AXML file format during compilation
- AndroidManifest.xml:android configuration file, the compilation process is still converted to AXML format
- Classes.dex:Java code-like file (Dalvik byte code) generated after compilation
- RESOURCES.ARSC: Index table with ID value resource (the resource in the asserts folder does not generate an index)
- Other files: Directories that can be added by developers themselves, such as assets, or LIB (native so code)
Copy Code
After we download a website app package, here does not need to elaborate, everybody casually find an app to download to the computer.
Now start the anti-compilation:
Open cmd, navigate to Apktool, and execute the command below, 123.APK is the name of the app you just downloaded, and 123 is the reverse-compiled file name.
- E:\ anti-compilation \apktool>java-jar Apktool.jar d-f 123.apk 123
Copy Code
The Execute command prompts you:
- E:\ anti-compilation \apktool>java-jar Apktool.jar d-f 123.apk 123
- I:baksmaling ...
- I:loading Resource Table ...
- Exception in thread "main" Brut.androlib.AndrolibException:Could not decode ARS
- C file
- At Brut.androlib.res.decoder.ARSCDecoder.decode (arscdecoder.java:55)
- At BRUT.ANDROLIB.RES.ANDROLIBRESOURCES.GETRESPACKAGESFROMAPK (androlibres
- ources.java:315)
- At brut.androlib.res.AndrolibResources.loadMainPkg (androlibresources.jav
- A:50)
- At Brut.androlib.res.AndrolibResources.getResTable (androlibresources.jav
- A:43)
- At Brut.androlib.Androlib.getResTable (androlib.java:44)
- At Brut.androlib.ApkDecoder.getResTable (apkdecoder.java:148)
- At Brut.androlib.ApkDecoder.decode (apkdecoder.java:98)
- At Brut.apktool.Main.cmdDecode (main.java:120)
- At Brut.apktool.Main.main (main.java:57)
- caused by:java.io.ioexception:expected:0x001c0001, got:0x00000000
- At Brut.util.ExtDataInput.skipCheckInt (extdatainput.java:48)
- At Brut.androlib.res.decoder.StringBlock.read (stringblock.java:45)
- At Brut.androlib.res.decoder.ARSCDecoder.readPackage (arscdecoder.java:97
- )
- At Brut.androlib.res.decoder.ARSCDecoder.readTable (arscdecoder.java:82)
- At Brut.androlib.res.decoder.ARSCDecoder.decode (arscdecoder.java:48)
- ... 8 more
Copy Code
This explains the app's anti-compilation measures. But it's okay, let's go. You'll find that there is a 123 file that opens this file and displays the Smail file. So what is a Smali file?
- Smali is an intermediate language in the DEX format used by Android Dalvik virtual machines
- Can be understood as, C and assembly language compilation and anti-compilation, the Smali is understood as an assembly language
Copy Code
The second step is to drag the 123 file toSublime tool, you can see the app code is confusing, we need to find the core code. So how do I find the core code?
The main use of two methods, one is to use burp orWiresharkgrab the key string of the package, combined with the sublime Text tool in the Smali folder to find the location of the key string with the "Find in Folders" function, and then go to the bottom.
The second is to view its code directly through Jd-gui and locate the login interface's Click event and navigate to its key code.
I use here or recommend the first, the second is more tired.
when logging in to the app, open the Burp intercept packet or use the Wireshark tool, the key parameter is username
- https://www.xx.com/app/checkRegister.do?userName=18888888888&channelCode=af9rU2Tq&platForm=5&uKey= 2f9d65cf-94c9-457b-9e6c-593ecbe6c169&userid=-1
Copy Code
Next, we use the keywords found, using the sublime Text Tool "View in file" function in the Smali folder to find the place where the keyword appears.
- E:\ anti-compilation \apktool\123\smali\com\b\a\k.smali:
- 7. Method public static A (ljava/lang/string; ljava/lang/string;) ljava/lang/string;
- 8. Locals 6
- 9:. Parameter "UserName"
- Parameter "password"
Copy Code
Here, we can basically locate the key code location. Let's talk about it first, haha, not until the end.
This article goes to farmer safety
Original address: http://www.farmsec.org/forum.php?mod=viewthread&tid=343
How to find the core code in the first lesson of app anti-compilation