Bash Scripting: 4 3 24 - ConnorEast/Tech-Journal GitHub Wiki

Coding a nmap scan of all Servers on my network:

Line 1: ---> ip addr | grep "scope global" | cut -d " " -f 8 | cut -d "." -f 1,2,3 > octets.txt
Line 2: ---> OCTETS=$(cat octets.txt)
Line 3: ---> echo "" > $OCTETS.txt
Line 4: ---> for ip in {1..254}
line 5: ---> do
line 6: ---> ping -c 1 $OCTETS.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" >> $OCTETS.txt $ Done
Line 7: ---> cat $OCTETS.txt | sort > sorted_$OCTETS.txt
Line 8: ---> nmap -sS -iL sorted_$OCTETS.txt
Line 9: ---> Exit

Line 1: Takes your IP address. In my case 192.168.201.64 and cuts off the final 3 digits leaving the variable 192.168.201 to be saved to octet.txt
Line 2: Saves the content of octet.txt to a variable called OCTETS.
Line 3: Confirms that the file 192.168.201.txt is empty.
Line 4/5: For each number between 1 and 254 save the variable to IP and do the following:
Line 6: ping the address of the $OCTETS.$IP variables and save the ones that returned bytes to the file called $OCTETS.txt
Line 8: Next create a nmap ping searching for all of the open ports for the IPS on your network

image
image https://www.google.com/search?q=sleep+mode+delayed+response&rlz=1C1GCEA_enUS1093US1093&oq=sleep+mode+delayed+response&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORigATIHCAEQIRigATIHCAIQIRigATIHCAMQIRigAdIBCDQ2MDdqMGo3qAIAsAIA&sourceid=chrome&ie=UTF-8
https://www.stationx.net/nmap-cheat-sheet/