How to find the core code in the first lesson of app anti-compilation

Source: Internet
Author: User

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:

    1. Meta-inf: Signature file (How this is generated later will be mentioned)
    2. Res: A resource file in which XML format files are converted from text format to binary AXML file format during compilation
    3. AndroidManifest.xml:android configuration file, the compilation process is still converted to AXML format
    4. Classes.dex:Java code-like file (Dalvik byte code) generated after compilation
    5. RESOURCES.ARSC: Index table with ID value resource (the resource in the asserts folder does not generate an index)
    6. 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.

    1. E:\ anti-compilation \apktool>java-jar Apktool.jar d-f 123.apk 123
Copy Code

The Execute command prompts you:

  1. E:\ anti-compilation \apktool>java-jar Apktool.jar d-f 123.apk 123
  2. I:baksmaling ...
  3. I:loading Resource Table ...
  4. Exception in thread "main" Brut.androlib.AndrolibException:Could not decode ARS
  5. C file
  6. At Brut.androlib.res.decoder.ARSCDecoder.decode (arscdecoder.java:55)
  7. At BRUT.ANDROLIB.RES.ANDROLIBRESOURCES.GETRESPACKAGESFROMAPK (androlibres
  8. ources.java:315)
  9. At brut.androlib.res.AndrolibResources.loadMainPkg (androlibresources.jav
  10. A:50)
  11. At Brut.androlib.res.AndrolibResources.getResTable (androlibresources.jav
  12. A:43)
  13. At Brut.androlib.Androlib.getResTable (androlib.java:44)
  14. At Brut.androlib.ApkDecoder.getResTable (apkdecoder.java:148)
  15. At Brut.androlib.ApkDecoder.decode (apkdecoder.java:98)
  16. At Brut.apktool.Main.cmdDecode (main.java:120)
  17. At Brut.apktool.Main.main (main.java:57)
  18. caused by:java.io.ioexception:expected:0x001c0001, got:0x00000000
  19. At Brut.util.ExtDataInput.skipCheckInt (extdatainput.java:48)
  20. At Brut.androlib.res.decoder.StringBlock.read (stringblock.java:45)
  21. At Brut.androlib.res.decoder.ARSCDecoder.readPackage (arscdecoder.java:97
  22. )
  23. At Brut.androlib.res.decoder.ARSCDecoder.readTable (arscdecoder.java:82)
  24. At Brut.androlib.res.decoder.ARSCDecoder.decode (arscdecoder.java:48)
  25. ... 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?

    1. Smali is an intermediate language in the DEX format used by Android Dalvik virtual machines
    2. 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

    1. 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.

    1. E:\ anti-compilation \apktool\123\smali\com\b\a\k.smali:
    2. 7. Method public static A (ljava/lang/string; ljava/lang/string;) ljava/lang/string;
    3. 8. Locals 6
    4. 9:. Parameter "UserName"
    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.