client-like communiquer avec un service (telnet like sans aucune interprétation) visualisation des résultats en hexadécimal sauvegarde réseau : nc -l -p 4000 | tar xz // tar cz . | nc -w 3 machine_distante 4000 MENTIONNER ATTENTION AU FIREWALL ET ESSAIS EN LOCAL (AVEC UNE SEULE MACHINE) POSSIBLE en remplaçant toutes les mentions de "machine" par localhost server-like se faire passer pour un serveur (??? openssl) port scanning : nc -w 3 -z -v localhost 1-6000 MENTIONNER ATTENTION CELA PEUT PRENDRE BEAUCOUP PLUS DE TEMPS QUE LE SCAN TCP port scanning UDP : nc -w 3 -z -v -u localhost 1-6000 [vérification fonctionnement services / watchdog] mini irc : nc -l -p 4000 (sur machine_1), nc adresse_IP_machine_1 4000 sur machine_2 et ctrl-c sur n'importe lequel des postes pour interrompre la communication mini web-client1: echo -e 'GET /prestations/\n' | nc diablotin.com 80 > /tmp/page.htm mini web-client : echo -e 'POST /ucc/convert.cgi HTTP/1.0\nContent-Length: 25\n\nAmount=50&From=EUR&To=USD' | nc www.xe.com 80 | sed -n 's/^.*\([0-9.]*\) USD<.*$/\1/p' mini web-client : pbpaste | nc www.xe.com 80 POST /ucc/convert.cgi HTTP/1.1 Host: www.xe.net Connection: close Referer: http://www.xe.com/ucc/fr/ User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; fr-fr) AppleWebKit/106.2 (KHTML, like Gecko) Safari/100.1 Accept: */* Accept-Encoding: gzip, deflate;q=1.0, identity;q=0.5, *;q=0 Accept-Language: fr-fr, ja;q=0.07, en-us;q=0.86, en;q=0.79, de-de;q=0.71, de;q=0.64, es-es;q=0.57, es;q=0.50, it-it;q=0.43, it;q=0.36, nl-nl;q=0.29, nl;q=0.21, ja-jp;q=0.14, fr;q=0.93 Cookie: ID=193.251.65.54.343321075138577231 Content-Type: application/x-www-form-urlencoded Content-Length: 37 template=fr&Amount=50&From=EUR&To=USD cat "/Volumes/Data/MEDION WinMe/Mes documents/Documentations/Internet/Sniffing/netcat.txt" open "/Volumes/Data/40Go/Archives B/A_GRAVER_GRAVURE_FAITE/Docs/netcat.html" NAME nc (netcat) - use network sockets from the command line SYNOPSIS nc [-h] [-ruvz] [-g gateway] [-G num] [-i secs] [-p port] [-o file] [-s addr] [-w secs] hostname port[s] [ports] ... -l -p port [-nsuvwz] [-o file] [hostname] [port] DESCRIPTION nc allows you to use network sockets (tcp or udp) from the shell. For connecting to remote sites, it's usually only necessary to supply the host or ip address and port for the connection. For a listening on a socket, you must specify -l for listening, and -p port to specify the port on which you want to listen. The options are as follows (with C and S indicating whether the option applies to the "client" or "server" roles in a tcp conversation): -g gateway (C) Specifies a source routing hop for outbound connections. -G num (C) Can be used to specify the source routing pointer in the ip header, presumably in order to forge unused previous steps in the source routed path. -h Minor help. -i secs (C) Delay interval for lines sent or ports scanned. -l (S) Selects "listen" mode instead of connect mode so that people can connect to you. -n (S) The -n option indicates that all ip addresses should be printed out instead of being looked up in the DNS. -o file (CS) Sends a hex-dump of the traffic to the specified file. -p local port number (CS) When connecting to a remote service, this is the port from which the connection will originate. When listening for remote clients, this specifies the local port on which to listen. -r (C) Randomizes local source ports and addresses for outbound connec- tions. -s source address (CS) Specifies the local source address on which to listen, or from which to connect. -u (CS) Selects UDP transport as opposed to TCP (the default). -v (CS) Turns on verbosity. Use two (or more) for more verbosity. -w secs (CS) This sets a timeout for connects or for final net reads. -z (CS) Zero I/O mode. While mostly used for scanning, I'm sure you could find a way to use it for connect mode. The nc utility exits after both input streams (it's stdin and the remote socket) have been closed. It doesn't do this very well, and relies rather heavily on the network layers at both ends for this. SEE ALSO cat(1) HISTORY The nc utility, a "damn useful little backend utility" begun 950915 or thereabouts, as *Hobbit*'s first real stab at some sockets programming. Something that should have and indeed may have existed ten years ago, but never became a standard Unix utility. IMHO, nc could take its place right next to cat, cp, rm, mv, dd, ls, and all those other cryptic and Unix-like things.