如果與netcat的連接成功,如何停止腳本? 例如,如果Connection to 192.168.2.4 21 port [tcp/ftp] succeeded!
我不知道什麼持有該字符串的文本。如果nc連接在bash中成功,則停止腳本
#!/bin/bash
#Find first 3 octets of the gateway and set it to a variable.
GW=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | cut -c1-10)
#loop through 1 to 255 on the 4th octect
for octet4 in {1..255}
do
sleep .2
nc -w1 $GW$octet4 21
done