-
Error- Nmap shell script goes in infinite loop
This post is deleted! -
@sonal said in Error- Nmap shell script goes in infinite loop:
Any suggestions to fix this?
I have tested your script and it does not run in an infinite loop for me, however, it runs for a long time as it scans each host multiple times. I think the problem is the following statement where you instruct nmap to read the list of hosts from file (btw I think $line1 is undefined in this context).
nmap -oG output.txt -T4 -f -iL iplist.txt $line1
See excerpt from man page:
Usage: nmap [Scan Type(s)] [Options] {target specification} TARGET SPECIFICATION: Can pass hostnames, IP addresses, networks, etc. Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 -iL <inputfilename>: Input from list of hosts/networks -iR <num hosts>: Choose random targets --exclude <host1[,host2][,host3],...>: Exclude hosts/networks --excludefile <exclude_file>: Exclude list from file
So, either you read the targets from file and remove while loop, or you remove the part
-iL iplist.txt
from the statement and change the target spec as follows:nmap -oG output.txt -T4 -f $line
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law