Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mulit-site functionality #14

Open
BustedSec opened this issue May 23, 2023 · 0 comments
Open

mulit-site functionality #14

BustedSec opened this issue May 23, 2023 · 0 comments

Comments

@BustedSec
Copy link

BustedSec commented May 23, 2023

I created the following bash script so your program can process multiple sites and output them all as text files and compress them.

#!/bin/bash

# Ask the user for the filename
echo "Please enter the filename:"
read filename

# Check if the file exists
if [ ! -f "$filename" ]; then
    echo "File not found!"
    exit 1
fi

# Create a results directory
mkdir -p results

# Read each line from the file
while IFS= read -r line
do
    # Split the line by ':' and get the first part
    host=${line%%:*}

    # Inform the user of the current progress
    echo "Processing $host"

    # Run the program with the host, remove ANSI colors and redirect output to a temporary file
    # The timeout command will terminate the python command if it runs for more than 30 seconds
    timeout 30 python3 ./securityheaders.py "$host" | sed 's/\x1b\[[0-9;]*m//g' > "${host}.tmp" 2>>errors.log

    # If the python command was terminated by the timeout command, print an error message
    if [ $? -eq 124 ]; then
        echo "Command timed out for host: $host" | tee -a errors.log
    fi

    # Check if the output file is zero size
    if [ ! -s "${host}.tmp" ]; then
        echo "$host file is zero size" >> logs.txt
        rm "${host}.tmp"
    else
        mv "${host}.tmp" "results/${host}.txt"
    fi
done < "$filename"

# Wait for all background processes to finish
wait

# Compress the results directory
zip -r results.zip results/

# Print a completion message
echo "Script completed successfully!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant