-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickmap.sh
27 lines (22 loc) · 883 Bytes
/
quickmap.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
#!/bin/bash
# This script takes an IP address as an argument and runs two nmap commands on it
# The first command scans all ports and saves the open ports to a variable
# The second command scans the open ports and saves the output to a file
# Check if an IP address is provided
if [ -z "$1" ]; then
echo "Please provide an IP address as an argument."
exit 1
fi
# Run the first nmap command and extract the open ports
echo "Running nmap -p- -T4 -Pn -vvv $1"
ports=$(nmap -p- -T4 -Pn -vvv $1 -oN nmap | grep "syn-ack" | cut -d "/" -f 1 | tr "\n" "," | sed "s/,$//")
# Check if any ports are found
if [ -z "$ports" ]; then
echo "No open ports found."
exit 2
fi
directory=$(pwd)
# Run the second nmap command and save the output to a file
echo "Running nmap -p $ports -sCV $1 -o $directory/nmap"
nmap -p $ports -sV $1 -o nmap
echo "Done. The output is saved in nmap file."