Want to take a list of open ports from a prior nmap scan, for use in future ones? egrep -o '[0-9]*/open/tcp/' your-prior-gnmap-output.gnmap | cut -d/ -f1 | sort -un | tr '\n' ',' Output will look something like this: 22,80,631,902,2200,2222,3389,5432,60443, [1/2]
2
24
1
89
Take the list (minus the final comma), and add it as the argument to a new nmap -p command: nmap 10.10.10.0/24 -p 22,80,631,902,2200,2222,3389,5432,60443 Hack the planet! * * Following scope, RoE, and signed authorization letters. [2/2]
1
2
14
Replying to @jeffmcjunkin
Add ... | sed ‘s/,$//‘ to your pipeline to remove the final comma, then you can use $(...) to substitute directly into your second command line. Also consider awk to replace egrep ... | cut

Feb 12, 2019 · 5:35 PM UTC

1
3
Replying to @hal_pomeranz
Nice! Thanks Hal!
1
1
I do like grep | cut for simplicity sometimes. I'm still amused at @egyp7 's nickname for cut of "baby awk"
1
4