[RndTbl] interesting unix pipe problem (stop whole pipe chain on first match)

Adam Thompson athompso at athompso.net
Sun May 31 08:53:50 CDT 2020


AFAIK, the solution is to not use nmap.
I suspect arping would be just as useful for your case, and it runs 
nearly instantaneously.  Couple with the Linux version's "-f" flag, put 
it in the background, collect all the return codes somehow[*] and you're 
done in under 0.5sec.  I prefer arping because it eliminates stupid 
firewall problems.
Or fping, which can scan an entire subnet in a second or so using ICMP 
in a single process in a couple of seconds.
-Adam

On 2020-05-31 01:35, Trevor Cordes wrote:
> Argh, sorry... for testing I was using a slightly bogus ip range...
> please change the 254-254 to 100-254.  The corrected command line is
> below:
> 
> echo 192.168.101 | \
> timeout 30 bash -c \
>  " \
>   sint=\$(cat); \
>   (nmap -ddd -vvv --send-ip \
>   --host-timeout 5s --max-rtt-timeout 1s --initial-rtt-timeout 500ms \
>   --max-retries 1 -S \$sint.1 -sn -PE \$sint.2 \$sint.100-254 2>&1 & \
>   echo \$! >&3) \
>   3>pidnmap \
>   | grep --line-buffered -P 'RCVD.{0,30}?ICMP.{0,60}?Echo reply' \
>   | (head -1 && kill \$(<pidnmap) 2>&1) \
> " \
> |grep RCVD || echo "no hosts found"
> 
> 
> And for some reason when I paste this from a my gui mail client it has
> syntax errors, but when I paste it from a tui mail client it works
> fine... YMMV.  I guess I could post the one-line version:
> 
> echo 192.168.101 | timeout 30 bash -c "sint=\$(cat); (nmap -ddd -vvv
> --send-ip --host-timeout 5s --max-rtt-timeout 1s --initial-rtt-timeout
> 500ms --max-retries 1 -S \$sint.1 -sn -PE \$sint.2 \$sint.100-254 2>&1
> & echo \$! >&3) 3>pidnmap | grep --line-buffered -P
> 'RCVD.{0,30}?ICMP.{0,60}?Echo reply' | (head -1 && kill \$(<pidnmap)
> 2>&1)" |grep RCVD || echo "no hosts found"
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.ca
> https://muug.ca/mailman/listinfo/roundtable


More information about the Roundtable mailing list