-
-
Save baseboxorg/0c176012bf0bbefab7b0b7d9fc89532f to your computer and use it in GitHub Desktop.
Mac OSX: Port Scan Your Own Network with Netcat from Homebrew
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
#!/bin/bash | |
# Turn on job control to do more than one at a time | |
set -m | |
# Check to see if Homebrew is installed, and install it if it is not | |
command -v brew >/dev/null 2>&1 || { echo >&2 "You will need Homebrew to use this tool, installing now"; /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; } | |
# Check to see if `netcat` is installed, install it if it is not | |
command -v netcat >/dev/null 2>&1 || { echo >&2 "You will also need netcat in order to use this tool, installing it now"; brew install netcat; } | |
# Prompt the user for the port which we will scan | |
read -p "Which port would you like to scan? The default is [80]:" PORT | |
PORT=${PORT:-80} | |
# Prompt the user for the C-class range we will scan | |
read -p "For which range? The default is [10.0.1.]:" RANGE | |
RANGE=${RANGE:-10.0.1.} | |
# Removed the start and end IP blocks and scan 255 by default | |
#echo "From what starting IP? The default is 1" | |
#read -p "From what starting IP? The default is [1]:" STARTIP | |
#STARTIP=${STARTIP:-1} | |
for i in {1..254}; do netcat -vnz -w 1 $RANGE$i $PORT; done | |
# Turn off job control once more | |
set +m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment