Sken IP adres na UBNT: Porovnání verzí
Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
(Založena nová stránka: Přes SSH v konzoli (pokud je rozsah jiný než 192.168.1.0/24, upravte proměnnou address): address="192.168.1."; for i in `seq 1 254`; do up=`ping -c1 -W1 $address$i ...) |
|||
(Není zobrazeno 12 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 | |||
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" |
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"