Sken IP adres na UBNT: Porovnání verzí
Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
(→Arping) |
|||
(Není zobrazeno 9 mezilehlých verzí od stejného uživatele.) | |||
Řádek 1: | Řádek 1: | ||
Přes SSH v konzoli | Přes SSH v konzoli, vždy upravte proměnné: | ||
= | '''address''' = rozsah lokálních IP adres | ||
'''start''' = číslo počáteční IP adresy | |||
'''end''' = číslo koncové IP adresy | |||
'''port''' = port, na kterém běží webové rozhraní (pouze HTTP) | |||
= ping = | |||
address="192.168.1."; | address="192.168.1."; | ||
for i in `seq | start=1; | ||
end=254; | |||
for i in `seq $start $end`; | |||
do | do | ||
up=`ping -c1 -W1 $address$i | grep "1 packets received" | wc -l`; | up=`ping -c1 -W1 $address$i | grep "1 packets received" | wc -l`; | ||
Řádek 16: | Řádek 26: | ||
address="192.168.1."; | address="192.168.1."; | ||
iface= | start=1; | ||
for i in `seq | end=254; | ||
iface=`ip addr | grep $address | awk '{print $NF}'`; | |||
for i in `seq $start $end`; | |||
do | do | ||
up=`arping -c1 -I $iface $address$i | grep "Received 1 replies" | wc -l`; | up=`arping -c1 -w1 -I $iface $address$i | grep "Received 1 replies" | wc -l`; | ||
if [ "$up" -eq 1 ]; | if [ "$up" -eq 1 ]; | ||
then | then | ||
Řádek 25: | Řádek 37: | ||
fi; | fi; | ||
done | done | ||
= wget = | |||
address="192.168.1."; | |||
start=1; | |||
end=254; | |||
port=80; | |||
for i in `seq $start $end`; | |||
do | |||
wget -qO- http://$address$i:$port >/dev/null 2>&1 && echo $address$i; | |||
done | |||
= Skript vše v jednom = | |||
#!/bin/bash | |||
# rozsah lokalnich IP adres | |||
address="192.168.1." | |||
# cislo prvni IP adresy | |||
start=1 | |||
# cislo posledni IP adresy | |||
end=254 | |||
# pocet skenu najednou | |||
count=20 | |||
# interval mezi skeny | |||
sleep=5 | |||
# porty HTTP ke skenovani | |||
ports="80 8080" | |||
iface=`ip addr | grep $address | awk '{print $NF}'`; | |||
log="/tmp/scan.log" | |||
test_host () | |||
{ | |||
output="" | |||
ping -q -c1 -W1 $1 >/dev/null && output="ping" | |||
arping -q -c1 -w1 -I $iface $1 >/dev/null && output="$output arping" | |||
for port in $ports; | |||
do | |||
wget -qO- http://$1:$port >/dev/null 2>&1 && output="$output port $port " | |||
done | |||
if [ -n "$output" ]; | |||
then | |||
echo "$1: $output" | |||
fi | |||
} | |||
greater () | |||
{ | |||
if [ $1 -le $2 ]; | |||
then | |||
echo $1 | |||
else | |||
echo $2 | |||
fi | |||
} | |||
rm "$log" | |||
for i in `seq $start $count $end`; | |||
do | |||
from=$address$i | |||
to=`greater $((i+count)) $end` | |||
echo "$address$i - $address$to" | |||
for j in $(seq $i $to); | |||
do | |||
ip=$address$j | |||
test_host $ip >> "$log" & | |||
done | |||
sleep $sleep | |||
done | |||
cat "$log" |
Aktuální verze z 10. 10. 2023, 06:19
Přes SSH v konzoli, vždy upravte proměnné:
address = rozsah lokálních IP adres
start = číslo počáteční IP adresy
end = číslo koncové IP adresy
port = port, na kterém běží webové rozhraní (pouze HTTP)
ping
address="192.168.1."; start=1; end=254; for i in `seq $start $end`; do up=`ping -c1 -W1 $address$i | grep "1 packets received" | wc -l`; if [ "$up" -eq 1 ]; then echo $address$i; fi; done
arping
address="192.168.1."; start=1; end=254; iface=`ip addr | grep $address | awk '{print $NF}'`; for i in `seq $start $end`; do up=`arping -c1 -w1 -I $iface $address$i | grep "Received 1 replies" | wc -l`; if [ "$up" -eq 1 ]; then echo $address$i; fi; done
wget
address="192.168.1."; start=1; end=254; port=80; for i in `seq $start $end`; do wget -qO- http://$address$i:$port >/dev/null 2>&1 && echo $address$i; done
Skript vše v jednom
#!/bin/bash # rozsah lokalnich IP adres address="192.168.1." # cislo prvni IP adresy start=1 # cislo posledni IP adresy end=254 # pocet skenu najednou count=20 # interval mezi skeny sleep=5 # porty HTTP ke skenovani ports="80 8080" iface=`ip addr | grep $address | awk '{print $NF}'`; log="/tmp/scan.log" test_host () { output="" ping -q -c1 -W1 $1 >/dev/null && output="ping" arping -q -c1 -w1 -I $iface $1 >/dev/null && output="$output arping" for port in $ports; do wget -qO- http://$1:$port >/dev/null 2>&1 && output="$output port $port " done if [ -n "$output" ]; then echo "$1: $output" fi } greater () { if [ $1 -le $2 ]; then echo $1 else echo $2 fi } rm "$log" for i in `seq $start $count $end`; do from=$address$i to=`greater $((i+count)) $end` echo "$address$i - $address$to" for j in $(seq $i $to); do ip=$address$j test_host $ip >> "$log" & done sleep $sleep done cat "$log"