Search K
Appearance
Appearance
Other ways to support HackTricks:
This section of the post is a summary from the post https://medium.com/@shubhamsonani/hacking-with-precision-bypass-techniques-via-debugger-in-android-apps-27fd562b2cc0
Content based on https://medium.com/@shubhamsonani/hacking-with-precision-bypass-techniques-via-debugger-in-android-apps-27fd562b2cc0
Decompile the APK:
android:debuggable=true
to enable debugging mode.Install the Modified Application:
adb install <application_name>
.Retrieve the Package Name:
adb shell pm list packages โ3
to list third-party applications and find the package name.Set the App to Await Debugger Connection:
adb shell am setup-debug-app โw <package_name>
.adb shell am setup-debug-app โw -โpersistent <package_name>
.adb shell am clear-debug-app <package_name>
.Prepare for Debugging in Android Studio:
Set Breakpoints in Key Java Files:
MainActivity.java
(specifically in the onCreate
method), b.java
, and ContextWrapper.java
.The application, at certain points, will verify if it is debuggable and will also check for binaries indicating a rooted device. The debugger can be used to modify app info, unset the debuggable bit, and alter the names of searched binaries to bypass these checks.
For the debuggable check:
this mLoadedAPK -> mApplicationInfo -> flags = 814267974
.flags = 814267974
is 11000011100111011110
, indicating that the "Flag_debuggable" is active.These steps collectively ensure that the application can be debugged and that certain security checks can be bypassed using the debugger, facilitating a more in-depth analysis or modification of the application's behavior.
Step 2 involves changing a flag value to 814267972, which is represented in binary as 110000101101000000100010100.
A demonstration was provided using a vulnerable application containing a button and a textview. Initially, the application displays "Crack Me". The aim is to alter the message from "Try Again" to "Hacked" at runtime, without modifying the source code.
apktool
to access the AndroidManifest.xml
file.android_debuggable="true"
in the AndroidManifest.xml indicates the application is debuggable and susceptible to exploitation.apktool
is employed solely to check the debuggable status without altering any code.adb jdwp
to identify Dalvik VM ports that are listening.classes
and methods <class_name>
were used to uncover the applicationโs structure.onClick
method, and its execution was controlled.locals
, next
, and set
commands were utilized to inspect and modify local variables, particularly changing the "Try Again" message to "Hacked".run
command, successfully altering the applicationโs output in real-time.This example demonstrated how the behavior of a debuggable application can be manipulated, highlighting the potential for more complex exploits like gaining shell access on the device in the application's context.
Other ways to support HackTricks: