Last active
March 23, 2020 13:41
-
-
Save DanijelMi/d019b5aff111908e5f3177c10857228b to your computer and use it in GitHub Desktop.
Pipe in nmap stdout, output CSV format of ports suitable for Nessus. Install for bash: curl https://gist.githubusercontent.com/DanijelMi/d019b5aff111908e5f3177c10857228b/raw/347f5e41b7ce03567ac6245e1dee92214ab86dff/nmap2csv >> ~/.bashrc && source ~/.bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: nmap {OPTIONS} {TARGET_IP} | nmap2csv | |
nmap2csv (){ | |
# License: GPLv2 | |
# Author: Danijel M. | |
# Brief help prompt | |
if [[ $1 == "-h" || $1 == "--help" ]]; then | |
printf "\e[32;1m Usage: nmap {OPTIONS} {TARGET_IP} | nmap2csv\e[0m \n" | |
return 0 | |
fi | |
# Check for dependencies | |
DEPENDENCIES=(nmap grep sed printf cat) | |
for i in "${DEPENDENCIES[@]}"; do | |
which $i &> /dev/null && continue | |
printf "$i was not found on your system. Aborting.\n" | |
return 1 | |
done | |
# 0:Get STDIN 1:Greedy find numbers 2: Newline into Comma+Space 3: remove tail Comma+Space | |
cat /dev/stdin | \ | |
grep -oE '^[0-9]*' | \ | |
sed -z 's/\n/, /g' | \ | |
sed 's/..$/\n/' | |
return 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment