Last active
September 13, 2025 05:12
-
-
Save binarweb/7947d5a5ab58b0368d27b7ad177ceae5 to your computer and use it in GitHub Desktop.
Parallel Bash Network and Port Scanner
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
| #!/usr/bin/env bash | |
| network="10.10.10" # Your target network should be in the form of "X.X.X", while it will scan X.X.X.1 to X.X.X.254 | |
| threads=100 # Number of parallel threads | |
| ping_count=1 # Number of ping attempts | |
| ping_timeout=1 # In seconds | |
| nc_timeout=1 # In seconds | |
| ports=(22 80 443 8080 8384) # The ports to check | |
| # Colors | |
| GREEN='\033[0;32m' | |
| RED='\033[0;31m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No Color | |
| export network ping_count ping_timeout nc_timeout ports GREEN RED YELLOW NC | |
| seq 1 255 \ | |
| | xargs -P"$threads" -I{} bash -c ' | |
| ip="$network.{}" | |
| # 1) Ping check | |
| if ping -c "$ping_count" -W "$ping_timeout" "$ip" &>/dev/null; then | |
| open_list="" | |
| # 2) Port checks using nc (netcat) | |
| for p in "$@"; do | |
| if nc -zv -w "$nc_timeout" "$ip" "$p" &>/dev/null; then | |
| open_list+="$p " | |
| fi | |
| done | |
| # 3) Print the result in one go | |
| if [ -n "$open_list" ]; then | |
| echo -e "${GREEN}$ip${NC} ... ${YELLOW}${open_list% }${NC}" | |
| else | |
| echo -e "${GREEN}$ip${NC} ... ${RED}none${NC}" | |
| fi | |
| fi | |
| ' _ {} "${ports[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment