File size: 1,717 Bytes
5f491f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

# Enhanced script for running search queries on multiple APIs (Censys, Zoomeye, and Shodan)
# This script reads search keywords from a provided file, processes them using the autosploit.py script,
# and saves the results to hosts.txt. It includes advanced error handling, logging, and modular design.

# Function to run queries on multiple APIs and save results
run_queries() {
    local input_file=$1
    local query_log="query.log"
    local result_file="hosts.txt"
    
    # Clear previous log and result files
    > "$query_log"
    > "$result_file"
    
    while IFS= read -r keyword; do
        echo "Processing keyword: $keyword" | tee -a "$query_log"
        if python3 autosploit.py -A -a -f etc/json/default_modules.json -q "$keyword" >> "$result_file"; then
            echo "Successfully processed: $keyword" | tee -a "$query_log"
        else
            echo "Failed to process: $keyword" | tee -a "$query_log"
        fi
    done < "$input_file"
}

# Function to display usage information
display_help() {
    echo "Usage: $0 [FILENAME]"
    echo "FILENAME: Path to the file containing search keywords."
    exit 1
}

# Main function to handle script execution
main() {
    local input_file=$1
    
    # Ensure script is run as root
    if [ "$EUID" -ne 0 ]; then
        echo "[!] This script must be run as root!"
        exit 1
    fi

    # Verify input file
    if [ -z "$input_file" ] || [ ! -f "$input_file" ]; then
        display_help
    fi

    echo "[+] Starting quicksploit searching..."
    run_queries "$input_file"
    echo "[+] Results saved to hosts.txt"
}

# Execute main function with provided arguments
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    main "$@"
fi