1
0
Fork 0

further improved nmap helper functions; default params, tun, generic function

This commit is contained in:
Massaki Archambault 2018-03-26 09:06:05 -04:00
parent 1a78780561
commit 54bb0393e2
1 changed files with 17 additions and 12 deletions

View File

@ -9,23 +9,28 @@ vifunction() {
} }
nmap-libvirt() { nmap-libvirt() {
local addr_list="" __nmap_iface 'virbr[0-9]+' $@
for link in $(ip link show up | grep -Eo 'virbr[0-9]+'); do }
for addr in $(ip addr show $link | grep -oP '(?<=inet )([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}'); do
addr_list="$addr_list $addr" nmap-tun() {
done __nmap_iface 'tun[0-9]+' $@
done
echo "Scanning $addr_list"
nmap $@ $addr_list
} }
nmap-local() { nmap-local() {
local addr_list="" __nmap_iface '(eth|wlan)[0-9]+' $@
for link in $(ip link show up | grep -Eo '(eth|wlan)[0-9]+'); do }
__nmap_iface() {
local iface="$1"
shift
local opt=${@:--T5}
for link in $(ip link show up | grep -Eo "$iface"); do
for addr in $(ip addr show $link | grep -oP '(?<=inet )([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}'); do for addr in $(ip addr show $link | grep -oP '(?<=inet )([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}'); do
addr_list="$addr_list $addr" addr_list="$addr_list $addr"
done done
done done
echo "Scanning $addr_list"
nmap $@ $addr_list printf "Scanning %s\n" "$addr"
nmap $opt $addr_list
} }