You can downloaded a precompiled binary version of the utility from Nmap.org or this site.
You can check the version of the utility using the --version
.
You can obtain information on the options that the command supports by
typing netcat --help
.
C:\Program Files\Network\>ncat --version Ncat: Version 5.59BETA1 ( http://nmap.org/ncat ) C:\Program Files\Network\>ncat --help Ncat 5.59BETA1 ( http://nmap.org/ncat ) Usage: ncat [options] [hostname] [port] Options taking a time assume seconds. Append 'ms' for milliseconds, 's' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms). -4 Use IPv4 only -6 Use IPv6 only -C, --crlf Use CRLF for EOL sequence -c, --sh-exec <command> Executes the given command via /bin/sh -e, --exec <command> Executes the given command -g hop1[,hop2,...] Loose source routing hop points (8 max) -G <n> Loose source routing hop pointer (4, 8, 12, ...) -m, --max-conns <n> Maximum <n> simultaneous connections -h, --help Display this help screen -d, --delay <time> Wait between read/writes -o, --output Dump session data to a file -x, --hex-dump Dump session data as hex to a file -i, --idle-timeout <time> Idle read/write timeout -p, --source-port port Specify source port to use -s, --source addr Specify source address to use (doesn't affect -l) -l, --listen Bind and listen for incoming connections -k, --keep-open Accept multiple connections in listen mode -n, --nodns Do not resolve hostnames via DNS -t, --telnet Answer Telnet negotiations -u, --udp Use UDP instead of default TCP --sctp Use SCTP instead of default TCP -v, --verbose Set verbosity level (can be used up to 3 times) -w, --wait <time> Connect timeout --send-only Only send data, ignoring received; quit on EOF --recv-only Only receive data, never send anything --allow Allow only given hosts to connect to Ncat --allowfile A file of hosts allowed to connect to Ncat --deny Deny given hosts from connecting to Ncat --denyfile A file of hosts denied from connecting to Ncat --broker Enable Ncat's connection brokering mode --chat Start a simple Ncat chat server --proxy <addr[:port]> Specify address of host to proxy through --proxy-type <type> Specify proxy type ("http" or "socks4") --proxy-auth <auth> Authenticate with HTTP or SOCKS proxy server --ssl Connect or listen with SSL --ssl-cert Specify SSL certificate file (PEM) for listening --ssl-key Specify SSL private key (PEM) for listening --ssl-verify Verify trust and domain name of certificates --ssl-trustfile PEM file containing trusted SSL certificates --version Display Ncat's version information and exit See the ncat(1) manpage for full options, descriptions and usage examples C:\Program Files\Network\>
You can have a Windows system function as a simple web server which serves just one web page using the command below:
ncat -lk -p 8080 --sh-exec "echo HTTP/1.1 200OK& echo(&type index.html"
If you want the server to listen on the
well-known port for a web server, port 80, you can change the -p
8080
, which causes ncat to listen
on port 8080 to -p 80
. You can test that the
system is listening on that port by opening a browser on the same system and
using http://localhost:8080
for the URL. Or you can test it from
another system by using the IP address of the system on which ncat is listening,
e.g., http://192.168.0.12
, if the system had an IP address of
192.168.0.12. You can stop ncat from listening on the port by
hitting Ctrl-C to terminate the program.
You could create a simple text file named index.html
in the
directory from which you run ncat to be served to browsers. E.g.:
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h1>Test Page</h1>
<p>This is a test page.</p>
</body>
</html>
That page would then be displayed by a browser visiting
http://localhost:8080
- you could substitute the IP address of
the system, if you wished to access the ncat web server from an external
system - if you used the ncat command shown above.