Working State with Basic Reporting to Markdown file.

This commit is contained in:
2025-01-13 16:33:00 -05:00
parent f68657e4e4
commit b38b806a78
15 changed files with 50 additions and 1248 deletions

View File

@@ -1,8 +1,15 @@
#!/bin/bash
# --- Sudo Check ---
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mERROR: This script must be run as root (sudo).\e[0m"
exit 1
fi
# --- Dependency Check ---
dependencies=("nmap" "python3" "awk" "amap")
dependencies=("nmap" "python3" "awk")
for dependency in "${dependencies[@]}"; do
if ! command -v "$dependency" &> /dev/null; then
@@ -47,6 +54,7 @@ mkdir raw_files
#Variable storage
f1='raw_files'
total_ips=$(wc -l < "$1")
## Pingable IP Check ##
@@ -174,11 +182,9 @@ cat << EOF > "$report_file"
## Target Information
**Input File:** $1
**Input File:** $1 containing $total_ips ip addresses
## Ping Sweep Results
**(Host IPs from ping sweep will be inserted here)**
**Total Ports Scanned:** $topports
## Open Ports Summary
@@ -186,6 +192,10 @@ cat << EOF > "$report_file"
## Suspicious Open Ports
## Ping Sweep Results
**(Host IPs from ping sweep will be inserted here)**
EOF
echo -e "\e[33mPopulating Open Ports Summary...\e[0m"
@@ -230,10 +240,42 @@ awk -v warning_ports="$warning_ports_list" '
}
1' "$report_file" > temp_report.md && mv temp_report.md "$report_file"
echo ""
echo -e "\e[1;34m Finished Running Script \e[0m"
echo ""
echo -e "\e[33mPopulating Ping Sweep Results...\e[0m"
# Count the number of pingable hosts
host_count=$(wc -l < "$results_dir/raw_files/pingable_hosts.txt")
# Determine the number of columns (adjust as needed)
columns=4
# Calculate the number of rows needed
rows=$(( (host_count + columns - 1) / columns ))
# Initialize the table
ping_table=""
ping_table+="| | | | |\n" # Adjust header based on 'columns'
ping_table+="|---|---|---|---|\n" # Adjust separator based on 'columns'
# Read the pingable hosts into an array
mapfile -t pingable_hosts < "$results_dir/raw_files/pingable_hosts.txt"
# Populate the table
i=0
for row in $(seq 1 $rows); do
for col in $(seq 1 $columns); do
if [[ $i -lt $host_count ]]; then
ping_table+="| ${pingable_hosts[$i]} "
else
ping_table+="| " # Empty cell if no more hosts
fi
((i++))
done
ping_table+="|\n"
done
# Insert the ping table into the Markdown report
sed -i "/(Host IPs from ping sweep will be inserted here)/c\\
$ping_table" "$report_file"
echo ""
echo -e "\e[1;34m Finished Running Script \e[0m"