A Bash script to extract and format open ports from greppable Nmap scan results.
- Parses Nmap greppable (
-oG) output. - Extracts IP addresses and their open ports.
- Formats the output as:
<IP_ADDRESS> <PORT1>,<PORT2>,<PORT3> - Efficient processing using
grepandawk.
./parse.sh <nmap_results_file>Host: 192.168.1.1 () Ports: 22/open/tcp//ssh///, 80/open/tcp//http///, 443/open/tcp//https///
Host: 192.168.1.2 () Ports: 3306/open/tcp//mysql///
192.168.1.1 22,80,443
192.168.1.2 3306
- Clone this repository:
git clone https://github.com/yourusername/nmap-parser.git cd nmap-parser - Make the script executable:
chmod +x parse.sh
To use this script, ensure you scan with the -oG option:
nmap -p- -oG nmap_results.txt 192.168.1.0/24- Extracts lines containing
"Ports"usinggrep. - Uses
awkto:- Print the IP address (second field).
- Extract and format open ports in a comma-separated list.
Feel free to submit issues or pull requests to improve this script.
π‘ Happy scanning! Stay ethical! π