標籤:netcat
netcat用於調試和檢查網路,能通過TCP和UDP在網路中讀寫資料。netcat是在兩台電腦之間建立連結並返回兩個資料流,可以建立一個伺服器,傳輸檔案,與朋友聊天,傳輸串流媒體或者用它作為其它協議的獨立用戶端。
0x01、連接埠掃描
ncat-v -n 192.168.1.1 80
-v:顯示詳細資料
-n:使用純數字ip地址,不用DNS來解析ip地址
-w 1 :設定逾時時間為1
-u:掃描UDP連接埠,預設TCP
-z:使用0IO,串連成功後立即關閉串連, 不進行資料交換
-l:串連和收聽到來的串連
-e:執行傳遞的命令列
-k:接受多個聽模式的串連
0x02、聊天服務
Server
在10086連接埠啟動一個tcp伺服器
ncat -l 10086
Client
在機器上Clent上輸入,Server會顯示出來
ncat localhost 10086
0x03、檔案傳輸
伺服器向用戶端傳輸檔案
Server
ncat-l 10086 < test.txt
Client
ncat -n 127.0.0.1 10086 > test.txt
用戶端向伺服器傳輸檔案
Server
touch test.txt
ncat -l 10086 > test.txt
Clinet
cat test.txt | ncat localhost 10086
0x03、目錄傳輸
Server
tar -czvf - python | ncat -l10086
Clinet
ncat -n 127.0.0.1 10086 | tar -xvf -
0x04、複製一個裝置
Server
ddif=/dev/sda | nc -l 10086
Clinet
ncat -n 127.0.0.1 10086 | dd of=/dev/sda
0x05、開啟一個shell
Server
ncat -l 10086 -e /bin/bash -i
Client
ncat -l 192.168.1.1 10086
反向shell
Server
ncat -l 10086
Cliet
ncat 127.0.0.1 10086 -e /bin/bash
本文出自 “情未了庸人自擾” 部落格,請務必保留此出處http://guojianglong.blog.51cto.com/9344755/1894458
Linux Netcat 命令