Last active
March 28, 2024 16:26
-
-
Save scmanjarrez/9d6c2995c0ec4bcbd7dbaa5b3d369611 to your computer and use it in GitHub Desktop.
Small script to generate a list of ports to be scanned from the port detected by nmap
This file contains hidden or 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
#!/bin/bash | |
declare -a tcp=() | |
declare -a udp=() | |
while IFS= read -r line; do | |
port=$(echo $line | awk '{print $4}') | |
[[ "$port" =~ "tcp" ]] && tcp+=("${port%%/*}") || udp+=("${port%%/*}") | |
done < "${1:-/dev/stdin}" | |
IFS=, | |
echo -n "-sS -p " | |
echo "${tcp[*]}" | |
echo -n "-sU -p " | |
echo "${udp[*]}" | |
# Usage: | |
# ❯ bash nmapparser.sh | |
# Discovered open port 445/tcp on 10.129.202.41 | |
# Discovered open port 135/udp on 10.129.202.41 | |
# Discovered open port 3389/tcp on 10.129.202.41 | |
# Discovered open port 139/udp on 10.129.202.41 | |
# Discovered open port 111/tcp on 10.129.202.41 | |
# <Ctrl+D> | |
# -sS -p 445,3389,111 | |
# -sU -p 135,139 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment