Closed LogicBypass closed 2 years ago
Hello @No0ob1e , the serve option does not support Ncat (yet), it only supports nc.openbsd
and nc.traditional
. I don't know what linux distribution installs the Ncat binary as nc
. It seems quite irregular, but I'd love to know :)
The -q
option is supported just in nc.traditional
netcat
used as nc
preinstalled or installed by default on my machines:
Manjaro 5.10.79-1 on bare metal, netcat installed from pacman don't support "-q" option
Kali 5.14.16 vmware, preinstalled netcat used as nc
will be from "https://nmap.org/ncat" don't support "-q" option
Kali WSL2 installed from apt install the same version as preinstalled in kali from vmware
Even nc.openbsd
don't support "-q" option: https://man.openbsd.org/nc.1
Let's find the usage for the -q
option in this script:
-q seconds
- Are used to wait the specified amount of time after the end of the received file from a stdin and then to close the connection. "To make sure that the file is fully received and it's not a connection issue"
Now let's take a look at the syntax in the script nc -l -q0 -p "$port" < "$0" >/dev/null
-q
is set to 0 so it's doesn't have any useful usage than creating errors on different versions of netcat installed on users machines, or I may be wrong :)
Serve options it's a really useful feature and it's not a big deal to change it for my usage, but I want to share my experience to help to make it easy to use for other people :)
Hi again @No0ob1e , first of all thank you for taking your time looking into this.
I mostly use debian systems and there, the nc.openbsd
has the -q
option. I only tested from debian-like systems...😇
$ nc.openbsd -h
OpenBSD netcat (Debian patchlevel 1.217-3)
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
[-m minttl] [-O length] [-P proxy_username] [-p source_port]
[-q seconds] [-s sourceaddr] [-T keyword] [-V rtable] [-W recvlimit]
[-w timeout] [-X proxy_protocol] [-x proxy_address[:port]]
[destination] [port]
Command Summary:
-4 Use IPv4
-6 Use IPv6
-b Allow broadcast
-C Send CRLF as line-ending
-D Enable the debug socket option
-d Detach from stdin
-F Pass socket fd
-h This help text
-I length TCP receive buffer length
-i interval Delay interval for lines sent, ports scanned
-k Keep inbound sockets open for multiple connects
-l Listen mode, for inbound connects
-M ttl Outgoing TTL / Hop Limit
-m minttl Minimum incoming TTL / Hop Limit
-N Shutdown the network socket after EOF on stdin
-n Suppress name/port resolutions
-O length TCP send buffer length
-P proxyuser Username for proxy authentication
-p port Specify local port for remote connects
-q secs quit after EOF on stdin and delay of secs
-r Randomize remote ports
-S Enable the TCP MD5 signature option
-s sourceaddr Local source address
-T keyword TOS value
-t Answer TELNET negotiation
-U Use UNIX domain socket
-u UDP mode
-V rtable Specify alternate routing table
-v Verbose
-W recvlimit Terminate after receiving a number of packets
-w timeout Timeout for connects and final net reads
-X proto Proxy protocol: "4", "5" (SOCKS) or "connect"
-x addr[:port] Specify proxy address and port
-Z DCCP mode
-z Zero-I/O mode [used for scanning]
Port numbers can be individual or ranges: lo-hi [inclusive]
The purpose of the -q0
is so the netcat that sends the script quits after EOF. For nc.openbsd
we have -N
, but nc.traditional
doesn't have it so... as both nc.openbsd
and nc.traditional
had -q
(at least in the systems I tested), I used -q
.
I think I already have a patch for the problem.
Alright, I have just released version 3.8
, which should solve the problem. This version should support nc.openbsd
, nc.traditional
and ncat
.
I am closing the ticket, but feel free to reopen if it wasn't properly fixed.
Tried to use the serve "-S" option and it gets a netcat error
nc: invalid option -- 'q'
Netcat version 7.92I fixed my version of script on line 505