Network scan with shell script and www-data
user
PING IPs
for i in $(seq 1 10);
do ping -c1 -t 1 192.168.0.$i | grep -v '100% packet loss' | grep PING | awk '{print $2}' >> /var/www/html/ips.txt;
done;
Probe TCP Ports
Lines=$(cat /var/www/html/ips.txt);
for IP in $IPS;
do for PORT in {1..1000};
do echo >/dev/tcp/"$IP"/"$PORT" && echo "$IP:$PORT is open" >> /var/www/html/ports.txt || "$IP:$PORT is closed";
done;
done
Embeded into .php
file
<?php
set_time_limit(0);
exec('for i in $(seq 1 10); do ping -c1 -t 1 192.168.0.$i | grep -v \'100% packet loss\' | grep PING | awk '{print $2}' >> ips.txt; done;');
?>