Advertisement
efxtv

How to sign an APK on Android (command line) and deal with zip

Dec 15th, 2023 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | Cybersecurity | 0 0
  1. How to sign an APK on Android (command line) and deal with zip
  2. _____________________________________________________________
  3. # Get details about APK
  4. aapt dump badging SpareParts.apk
  5. unzip -l app.apk
  6. aapt dump permissions app/demo_input.apk
  7.  
  8. ---------------------------------------------Dealing-archive----------------
  9. -Check detailed view zip
  10. unzip -v demo_input.apk
  11.  
  12. - copy files recursively in zip (./ present working directory)
  13. zip -r demo_input.apk ./
  14.  
  15. -delete all the sign files (demo at the end)
  16. zip -d my_application.apk META-INF/\*
  17. or
  18. zip -d demo_input.apk "META-INF/*"
  19.  
  20. # Extract specific file from apk
  21. unzip -l
  22. unzip -j "demo_input.apk" "res/mipmap-xxxhdpi/ic_launcher.png" -d $PWD/saved-dir
  23.  
  24. - Extract to a relative dir
  25. unzip -j -d relativedir archive.zip path/in/archive/file.ext
  26.  
  27. - Extract to the current dir
  28. unzip -j -d . archive.zip path/in/archive/file.ext
  29.  
  30. - Extract to absolute dir
  31. unzip -j -d /absolutedir archive.zip path/in/archive/file.ext
  32.  
  33. - update file to zip file
  34. zip -u demo_input.apk file.txt
  35.  
  36. - update file into an existing directory of zip
  37. zip -u demo_input.apk res/fine.txt
  38.  
  39. -Move file to zlip file
  40. zip -m demo_input.apk file.txt
  41.  
  42. -Add directory to a zip file
  43. zip -r demo_input.apk directory_path
  44.  
  45. - Create encrypted file with password
  46. zip -e demo_input.apk .*txt
  47.  
  48. ---------------------------------------------Dealing-archive----------------
  49.  
  50. # Create key tool
  51. keytool -genkey -v -keystore release.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000
  52.  
  53. -Sign apk JARSIGNER
  54. jarsigner -verbose -sigalg SHA1withRSA -digestalg ShA1 -keystore release.keystore L3MON.apk example
  55.  
  56. - zip align apk
  57. wget http://security.ubuntu.com/ubuntu/pool/universe/a/android-platform-build/zipalign_8.1.0+r23-3ubuntu2_amd64.deb
  58. zipalign -v 4 new.apk aligned.apk
  59.  
  60.  
  61. # Create cert using openssl
  62. openssl req -x509 -days 9125 -newkey rsa:1024 -nodes -keyout key.pem -out certificate_x509.pem
  63. openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
  64. apksigner sign --key key.pk8 --cert certificate_x509.pem app/demo_input.apk
  65.  
  66.  
  67. # Sign using apksigner
  68. keytool -genkey -v -keystore release.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000
  69. apksigner sign --ks-key-alias example --ks release.keystore app/demo_input.apk
  70. apksigner verify app/demo_input.apk
  71. jarsigner -verify -verbose my_application.apk
  72.  
  73. # Sign using uber signer
  74. openssl req -x509 -days 9125 -newkey rsa:1024 -nodes -keyout key.pem -out certificate_x509.pem
  75. openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
  76. java -jar uber.jar certificate.pem key.pk8 app/demo_input.apk path-of-the-new-signed-apk.apk
  77.  
  78. We will update this file soon...
  79.  
  80. Join our private classes on telegram t.me/efxtv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement