Skip to content

Instantly share code, notes, and snippets.

@Aptimex
Last active April 1, 2025 22:01
Show Gist options
  • Save Aptimex/499d1fd76c78e26eb49bc43a78fddd37 to your computer and use it in GitHub Desktop.
Save Aptimex/499d1fd76c78e26eb49bc43a78fddd37 to your computer and use it in GitHub Desktop.
Masscan ports to NMAP
# This goes in ~/.bashrc or similar
function ms2nmap() {
cat $1 | grep open | cut -d " " -f 4 | cut -d "/" -f 1 | tr "\n" "," | head -c -1
}
# Redirect or tee masscan output to a file. Then use 'ms2nmap ./filename' to convert it into a port list that nmap will take with -p
# You can directly pass it to nmap like this: nmap 1.2.3.4 -p$(ms2nmap file.txt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment