Skip to content

Instantly share code, notes, and snippets.

@rosivaldo
Created April 13, 2017 12:49
Show Gist options
  • Save rosivaldo/b72f7344fca1dc486552c1ac3c4fc451 to your computer and use it in GitHub Desktop.
Save rosivaldo/b72f7344fca1dc486552c1ac3c4fc451 to your computer and use it in GitHub Desktop.
Small utility to check hosts on your network with nmap. Very simple and handful for me.
#!/bin/bash
if [ -z $1 ]
then
echo "type livehosts network [port]"
exit -1
fi;
if [ -z $2 ]
then
echo "hosts found on network: "$1
nmap -n -sP $1 | grep report | awk '{print $5}'
exit 0
fi;
echo "hosts found on network: "$1
echo "with port: "$2
nmap -oG /tmp/outputfile.txt -T4 -F $1 > /dev/null
grep $2'/open' /tmp/outputfile.txt | awk '{print $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment