時間:2020-09-28來源:www.farandoo.com作者:電腦系統城
yum install nc -y
1、實現任意TCP/UDP端口的偵聽,nc可以作為server以TCP或UDP方式偵聽指定端口
2、端口的掃描,nc可以作為client發起TCP或UDP連接
3、機器之間傳輸文件
4、機器之間網絡測速
一般nc只用來做TCP/UDP協議的端口測試,其它功能少用!
# nc --help
Ncat 7.50 ( https://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
-U, --unixsock Use Unix domain sockets 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
--lua-exec <filename> Executes the given Lua script
-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 <filename> Dump session data to a file
-x, --hex-dump <filename> 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 several times)
-w, --wait <time> Connect timeout
-z Zero-I/O mode, report connection status only
--append-output Append rather than clobber specified output files
--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" or "socks5")
--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
--ssl-ciphers Cipherlist containing SSL ciphers to use
--version Display Ncat's version information and exit
192.168.10.11
啟動一個tcp的監聽nc -l 80
telnet 192.168.10.11 80
或:nmap 192.168.10.11 -p 80
nc -lu 80
通過netstat可以看到udp協議已經監聽:
> # netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:80 0.0.0.0:* 15401/nc
nc -vuz 192.168.10.11 80
(u表示udp端口,v表示可視化輸出,z表示掃描時不發送數據)
使用nc傳輸文件不用scp或rsync那種輸入密碼的操作,當然也存在一定安全性。
例如:要把A機器上的一個sql文件發送到B機器上
(需要先開啟偵聽B機器端口,再到A機器發送數據到該端口)
步驟1,先在B機器上啟動一個接收文件的監聽,格式如下
nc -l 888 > zabbix.sql
步驟2,在A機器上往B機器的888端口發送數據,把下面sql包發送過去
nc 192.168.10.11 888 < zabbix.sql
也可通過nc傳輸目錄,但這里不推薦使用,暫不舉例。
這里也不推薦使用nc,直接使用speedtest,簡單:
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli
./speedtest-cli
用CTRL+]
鍵,這時會強制退到telnet命令界面下,再輸入quit
退出就行。
2022-04-13
蘋果系統安裝雙系統圖文教程 蘋果系統怎么裝雙系統 ?2022-04-13
遠程登錄Linux CentOS系統方法 怎么遠程登錄Linux CentOS系統?2022-03-21
CentOS7安裝MYSQL8.X的詳解教程很多網友對于linux系統比較陌生,更別說linux系統安裝了。有使用筆記本電腦的網友需要用到linux系統,不過卻不知道怎么安裝,所以下面小編要來跟大家說說linux操作系統安裝步驟詳細,大家一起來看看吧。...
2022-03-07
RedFlag紅旗Linux系統怎么安裝?電腦想要安裝雙系統,該怎么安裝RedFlag紅旗系統呢?下面我們就來看看紅旗Red Flag安裝全程圖解,詳細請看下文介紹...
2022-01-23