Use Netcat (Swiss Army Knife) for file transfer _linux shell

Source: Internet
Author: User
Tags socket stdin unix domain socket

NC (Netcat) is known as the "Swiss Army Knife" in the network tool, although the volume is small but powerful, NC the simplest function is the port scan, here I take note of it as a file transfer of magical use.

First look at the help information.

$ nc-h OpenBSD netcat (Debian patchlevel 1.105-7ubuntu1) This is NC from the NETCAT-OPENBSD package.
An alternative NC are available in the Netcat-traditional package. USAGE:NC [ -46bcddhjklnrstuuvzz] [-i-length] [-I interval] [-o-length] [-P proxy_username] [-P source_port] [-Q seconds ] [-S source] [-t Toskeyword] [-v rtable] [-w timeout] [-X Proxy_protocol] [-X proxy_address[:p ORT]] [destination] [ Port] Command Summary:-4 use ipv4-6 ipv6-b Allow broadcast-c Send CRLF as Line-endin  g-d Enable the debug socket option-d Detach from stdin-h this help text-i length TCP receive Buffer length-i secs Delay interval for lines sent, ports scanned-j use Jumbo Frame-k Keep Inboun
    D sockets open for multiple connects-l Listen mode, for inbound connects-n suppress, Name/port -O length TCP send buffer length-p proxyuser Username for proxy authentication-p PORT specify local port for remote connects-q secs quit over EOF on stdin and delay of Secs-r Randomiz  E remote ports-s Enable the TCP MD5 signature option-s addr Local source address-t Toskeyword Set IP Type of service-t Answer TELNET negotiation-u use UNIX domain socket-u UDP mode-v rtable Sp Ecify Alternate Routing table-v verbose-w secs Timeout for connects and final net Reads-x Proto ProX    Y protocol: "4", "5" (SOCKS) or "Connect"-X addr[:p ORT] Specify proxy address and port-z DCCP
 ZERO-I/O mode [used for scanning] Port numbers can is individual or ranges:lo-hi [inclusive]

Port Scan:

$ nc-z-v-n 127.0.0.1 20-100
...
Connection to 127.0.0.1 Port [tcp/*] succeeded!
...

Simple File Transfer:

Client:

$ nc-l 192.168.1.11 1234 > Passwd.txt &

Service side:

$ NC 192.168.1.11 1234 </etc/passwd

can also be

cat/etc/passwd | NC 192.168.1.11 1234

Service-side IP is 192.169.1.11, port is 1234

So, when two Linux machines need to simply transfer files, it's better

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.