Browse Source
-w (timeout) option doesn't do anything in nmap-ncat (default netcat in CentOS/RHEL) for UDP datagrams, and nmap-ncat has a default idle timeout set to 2 seconds. We can get the same behavior as netcap-openbsd (Debian/Ubuntu) by setting that idle timeout (-i) option to 1 second. This commit detects the flavor of the netcat binary (nmap vs other) and uses it to adapt the parameters. Story: 2007688 Task: 39800 Change-Id: I0100aaa428477f011bd39a90dd4ec98199b4bebcchanges/30/729230/1
1 changed files with 13 additions and 1 deletions
@ -1,4 +1,16 @@
|
||||
#!/bin/bash |
||||
|
||||
nc_cmd=`which nc` |
||||
$nc_cmd -uzv -w1 $1 $2 > /dev/null |
||||
|
||||
nc_flavor=$($nc_cmd --version 2>&1 | grep -o nmap) |
||||
case "$nc_flavor" in |
||||
nmap) |
||||
nc_flavor_opts="-i1" |
||||
;; |
||||
*) # default, probably openbsd |
||||
nc_flavor_opts="-w1" |
||||
;; |
||||
esac |
||||
|
||||
$nc_cmd -uzv $nc_flavor_opts $1 $2 > /dev/null |
||||
exit $? |
||||
|
Loading…
Reference in new issue