-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscanner.sh
executable file
·46 lines (30 loc) · 1.07 KB
/
scanner.sh
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
#!/bin/bash
# Check if IP Address is passed
if [ $# -eq 0 ]; then
echo "Invalid Syntax"
echo "./scanner.sh [target_ip]"
exit 1
fi
# Colors
GREEN="\033[0;32m"
BLUE="\033[0;34m"
YELLOW="\033[1;33m"
NO_COLOR="\033[0m"
# Target IP
target_ip=$1
echo -e "${BLUE}[!] Running rustscan to get open ports${NO_COLOR}"
rustscan_results=$(rustscan -a $target_ip -r 1-65535)
# Extracting Open Ports from Rustscan Results
open_ports_lines=$(echo "$rustscan_results" | grep "Discovered open port")
ports=$(echo "$open_ports_lines" | cut -d " " -f4- | rev | cut -d " " -f3- | rev)
open_ports=($ports)
# Display Open Ports
echo -e "${YELLOW}[+] Open Ports Identified:${NO_COLOR}"
printf "${GREEN}%s\n${NO_COLOR}" "${open_ports[@]}"
# Convert Open Ports into a String for Nmap
ports_for_nmap=$(echo "$ports" | rev | cut -c5- | rev)
ports_for_nmap=($ports_for_nmap)
ports_for_nmap=$(printf "%s," "${ports_for_nmap[@]}")
echo -e "${BLUE}[!] Running Nmap for open ports${NO_COLOR}"
# Run Nmap on open ports identified by rustscan
sudo nmap -A -T4 -sS -p$ports_for_nmap $target_ip $2