quota from "http://nmap.org/ncat/guide/ncat-usage.html":
Main usage:
Ncat always operates in one of two basic modes: connect mode and listen mode. In connect mode, Ncat initiates a connection (or sends UDP data) to a service that is listening somewhere. For those familiar with socket programming, connect mode is like using the
connect
function. In listen mode, Ncat waits for an incoming connection (or data receipt), like using the bind
and listen
functions. You can think of connect mode as “client” mode and listen mode as “server” mode.Connect mode:
ncat <host> [<port>]
Listen mode:
ncat -l [<host>] [<port>]
In listen mode, <host> controls the address on which Ncat listens; if you omit it, Ncat will bind to all local interfaces (INADDR_ANY). If the port number is omitted, Ncat uses its default port 31337.Typically only privileged (root) users may bind to a port number lower than 1024. A listening TCP server normally accepts only one connection and will exit after the client disconnects. Combined with the --keep-open option, Ncat accepts multiple concurrent connections up to the connection limit. With --keep-open (or -k for short), the server receives everything sent by any of its clients, and anything the server sends is sent to all of them. A UDP server will communicate with only one client (the first one to send it data), because in UDP there is no list of “connected” clients.
Ncat can use TCP, UDP, SCTP, SSL, IPv4, IPv6, and various combinations of these. TCP over IPv4 is the default.
-------------------------------------------------------------------------
File transfer using ncat:
input file on host1
output file on host2
Transfer a file, receiver listens
host2$ ncat -l > outputfile
host1$ ncat --send-only host2 < inputfile
Transfer a file, sender listens
host1$ ncat -l --send-only < inputfile
host2$ ncat host1 > outputfile
Transfer a bundle of files
host2$ ncat -l | tar xzv
host1$ tar czv <files> | ncat --send-only host2
---------------------------------------------------------------------------
Example. Running a command with
--sh-exec
ncat -l --sh-exec "echo `pwd`"
Example. Ncat as mail client
$ ncat -C mail.example.com 25 220 mail.example.com ESMTP HELO client.example.com 250 mail.example.com Hello client.example.com MAIL FROM:a@example.com 250 OK RCPT TO:b@example.com 250 Accepted DATA 354 Enter message, ending with "." on a line by itself From: a@example.com To: b@example.com Subject: Greetings from Ncat Hello. This short message is being sent by Ncat. . 250 OK QUIT 221 mail.example.com closing connection
沒有留言:
發佈留言