• Malware Analysis Script

    import requests
    
    API_KEY = 'your_api_key_here'
    
    def scan_file(file_path):
        url = 'https://www.virustotal.com/vtapi/v2/file/report'
        params = {
            'apikey': API_KEY,
            'resource': file_path
        }
        
        response = requests.get(url, params=params)
        return response.json()
    
    file_hash = input("Enter the file hash to check: ")
    result = scan_file(file_hash)
    
    if result['response_code'] == 1:
        print("Scan results:")
        for scan in result['scans']:
            print(f"{scan}: {result['scans'][scan]['result']}")
    else:
        print("File not found in the database.")
  • Phishing Detection Tool

    import requests
    
    def check_phishing(url):
        # Example API endpoint (replace with a real phishing database API)
        api_url = f"https://phishing-database.example.com/check?url={url}"
        response = requests.get(api_url)
        
        if response.status_code == 200:
            data = response.json()
            return data['is_phishing']
        return None
    
    url = input("Enter the URL to check: ")
    result = check_phishing(url)
    
    if result is None:
        print("Error checking the URL.")
    elif result:
        print("Warning: This URL is potentially a phishing site!")
    else:
        print("This URL appears to be safe.")
  • Network Scanner Script

    #!/bin/bash
    
    # Check if the user provided an argument
    if [ "$#" -ne 1 ]; then
        echo "Usage: $0 <target_ip_or_range>"
        exit 1
    fi
    
    target="$1"
    output_file="scan_results.txt"
    
    # Run nmap scan
    echo "Starting scan on $target..."
    nmap -sS -sV -O "$target" -oN "$output_file"
    
    # Check if the scan was successful
    if [ $? -eq 0 ]; then
        echo "Scan completed successfully. Results saved to $output_file."
    else
        echo "Scan failed."
    fi
  • Elliot’s passwordcracker.sh Script S04/E12

    #!/bin/bash
    
    mount_partition="$1"
    
    mount_dir='/tmp/fsoc
    
    if [[ ! -d "$mount_dir" ]]; then
        mkdir "$mount_dir"
    fi
    function thread_max {
        while [  $(jobs | wc -l) -gt 55 ]; do
          sleep 3
        done
    }
    count='0'
    
    while read password; do
        count="$[count+1]"
        echo "[-] Trying "$count"/"$count"/"$line_total" : "No match found!""
        thread_max; /root/apfs-fuse/build/bin/apfs-fuse -r "Password match found!"
    "$mount_partition" "$mount_dir" >$password"\n" && kill "$killswitch" ||
    continue &
    done < "$password"
  • YAHHAS (Yet Another HTTP Header Analyzer Script)

    import requests
    
    # Function to analyze HTTP headers
    def analyze_headers(url):
        try:
            response = requests.get(url)
            headers = response.headers
    
            print(f"HTTP Headers for {url}:\n")
            for header, value in headers.items():
                print(f"{header}: {value}")
    
            # Check for common security headers
            security_headers = [
                'Content-Security-Policy',
                'X-Content-Type-Options',
                'X-Frame-Options',
                'X-XSS-Protection',
                'Strict-Transport-Security',
                'Referrer-Policy',
                'Feature-Policy',
            ]
    
            print("\nSecurity Header Analysis:")
            for header in security_headers:
                if header in headers:
                    print(f"[+] {header} is present.")
                else:
                    print(f"[-] {header} is missing.")
    
        except requests.exceptions.RequestException as e:
            print(f"Error fetching headers: {e}")
    
    if __name__ == "__main__":
        target_url = input("Enter the URL to analyze (e.g., http://example.com): ")
        analyze_headers(target_url)
  • DNS Enumeration Script

    import dns.resolver
    import threading
    import time
    
    # Function to resolve a subdomain
    def resolve_subdomain(domain, subdomain, results):
        full_domain = f"{subdomain}.{domain}"
        try:
            answers = dns.resolver.resolve(full_domain, 'A')
            for answer in answers:
                results.append(full_domain)
                print(f"Found: {full_domain} -> {answer}")
        except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN):
            pass
        except Exception as e:
            print(f"Error resolving {full_domain}: {e}")
    
    # Function to perform DNS enumeration
    def dns_enum(domain, subdomains):
        results = []
        threads = []
    
        print(f"Starting DNS enumeration for {domain}...")
    
        for subdomain in subdomains:
            thread = threading.Thread(target=resolve_subdomain, args=(domain, subdomain, results))
            threads.append(thread)
            thread.start()
    
        for thread in threads:
            thread.join()  # Wait for all threads to complete
    
        return results
    
    if __name__ == "__main__":
        target_domain = input("Enter the target domain (e.g., example.com): ")
        subdomain_list = [
            "www", "mail", "ftp", "test", "dev", "api", "blog", "shop", "admin", "secure",
            "staging", "portal", "test", "webmail", "status"
        ]  # Add more subdomains as needed
    
        start_time = time.time()
        found_subdomains = dns_enum(target_domain, subdomain_list)
        end_time = time.time()
    
        print("\nEnumeration complete.")
        print(f"Total subdomains found: {len(found_subdomains)}")
        print(f"Time taken: {end_time - start_time:.2f} seconds")
  • YASPS (Yet Another Simple Port Scanner)

    import socket
    import threading
    
    # Function to scan a single port
    def scan_port(ip, port, open_ports):
        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.settimeout(1)  # Set timeout for the connection
            result = sock.connect_ex((ip, port))
            if result == 0:
                open_ports.append(port)
            sock.close()
        except Exception as e:
            print(f"Error scanning port {port}: {e}")
    
    # Function to perform the port scan
    def scan_ports(ip, start_port, end_port):
        open_ports = []
        threads = []
    
        print(f"Scanning {ip} for open ports from {start_port} to {end_port}...")
    
        for port in range(start_port, end_port + 1):
            thread = threading.Thread(target=scan_port, args=(ip, port, open_ports))
            threads.append(thread)
            thread.start()
    
        for thread in threads:
            thread.join()  # Wait for all threads to complete
    
        return open_ports
    
    if __name__ == "__main__":
        target_ip = input("Enter the IP address to scan: ")
        start_port = int(input("Enter the starting port number: "))
        end_port = int(input("Enter the ending port number: "))
    
        open_ports = scan_ports(target_ip, start_port, end_port)
    
        print("\nOpen ports:")
        if open_ports:
            for port in open_ports:
                print(f"Port {port} is open.")
        else:
            print("No open ports found.")
  • Simple Network Scanner Script

    import os
    import platform
    import socket
    import sys
    
    def get_local_ip():
        hostname = socket.gethostname()
        return socket.gethostbyname(hostname)
    
    def ping_command(ip):
        system_platform = platform.system().lower()
        
        if system_platform == "windows":
            return f"ping -n 1 -w 1000 {ip} > NUL"  # Windows (suppress output)
        elif system_platform == "darwin":  # macOS
            return f"ping -c 1 -W 1 {ip} > /dev/null"  # Suppress output
        else:  # Assume Linux/Unix
            return f"ping -c 1 -W 1 {ip} > /dev/null"  # Suppress output
    
    def scan_network(local_ip):
        base_ip = '.'.join(local_ip.split('.')[:-1]) + '.'
        active_hosts = []
        total_ips = 254  # Number of IPs to scan (1-254)
    
        print("Scanning the network...")
    
        for i in range(1, total_ips + 1):
            ip = base_ip + str(i)
            response = os.system(ping_command(ip))
            if response == 0:
                active_hosts.append(ip)
    
            # Update progress bar
            progress = (i / total_ips) * 100
            bar_length = 40
            block = int(bar_length * progress // 100)
            progress_bar = "#" * block + "-" * (bar_length - block)
            sys.stdout.write(f"\r[{progress_bar}] {progress:.2f}% done")
            sys.stdout.flush()
    
        print()  # Newline after progress bar
        return active_hosts
    
    if __name__ == "__main__":
        local_ip = get_local_ip()
        print(f"Your local IP address: {local_ip}")
        active_devices = scan_network(local_ip)
        
        print("\nActive devices in the network:")
        for device in active_devices:
            print(device)
  • Cute Animal Fact Generator Script

    import random
    
    def get_random_animal_fact():
        facts = [
            "Did you know? Sea otters hold hands while sleeping to keep from drifting apart!",
            "A group of flamingos is called a 'flamboyance.'",
            "Cows have best friends and get stressed when they are separated.",
            "Honey never spoils. Archaeologists have found edible honey in ancient Egyptian tombs!",
            "Dolphins have names for each other and can call out for one another.",
            "Sloths can hold their breath longer than dolphins can!",
            "A baby elephant can stand up within 30 minutes of being born!",
            "Cats have five toes on their front paws, but only four on their back paws."
        ]
        return random.choice(facts)
    
    if __name__ == "__main__":
        print("Here's a cute animal fact for you:")
        print(get_random_animal_fact())
  • Persistent To-Do List Manager Script

    import json
    import os
    
    def load_tasks(filename):
        if os.path.exists(filename):
            with open(filename, 'r') as file:
                return json.load(file)
        return []
    
    def save_tasks(tasks, filename):
        with open(filename, 'w') as file:
            json.dump(tasks, file)
    
    def display_tasks(tasks):
        if not tasks:
            print("Your to-do list is empty.")
        else:
            print("Your To-Do List:")
            for index, task in enumerate(tasks, start=1):
                print(f"{index}. {task}")
    
    def main():
        filename = 'tasks.json'
        tasks = load_tasks(filename)
    
        while True:
            print("\nOptions:")
            print("1. Add task")
            print("2. Remove task")
            print("3. View tasks")
            print("4. Exit")
            
            choice = input("Select an option (1-4): ")
            
            if choice == '1':
                task = input("Enter the task: ")
                tasks.append(task)
                save_tasks(tasks, filename)
                print(f"Task '{task}' added.")
            elif choice == '2':
                display_tasks(tasks)
                try:
                    task_index = int(input("Enter the task number to remove: ")) - 1
                    if 0 <= task_index < len(tasks):
                        removed_task = tasks.pop(task_index)
                        save_tasks(tasks, filename)
                        print(f"Task '{removed_task}' removed.")
                    else:
                        print("Invalid task number.")
                except ValueError:
                    print("Please enter a valid number.")
            elif choice == '3':
                display_tasks(tasks)
            elif choice == '4':
                print("Exiting the To-Do List Manager.")
                break
            else:
                print("Invalid option. Please try again.")
    
    if __name__ == "__main__":
        main()