Lab 2.1 Port Scanning 1 - JimKnee-Champ/Ethical-Hacking-Journal GitHub Wiki

Note: chmod + x a file in order to allow it to be run from the command line (give it execute privileges) Code: Runs a port scan against the IP addresses in the host file, scanning the ports in the port file to see if theyre open. Only returns the IP address and the port number(s). #!/bin/bash

hostfile=$1

portfile=$2

echo "host,port" for host in $(cat $hostfile); do for port in $(cat $portfile); do timeout .1 bash -c "echo >/dev/tcp/$host/$port" 2>/dev/null && echo $host,$port done done