SOCAT 被称为nc++ (增强增强版的nc) - 双向数据流通道工具 连接端口 - Socat - tcp:1.1.1.1:80 侦听端口 - socat - tcp-listen:22 / socat - tcp-l:333 接收文件 - socat tcp4-listen:333 open:2.txt,creat,append 发送文件 - cat 1.txt | socat - tcp4:1.1.1.1:333 |
root@K:~# socat - tcp:192.168.1.1:80
get /http 1.1/
Http/1.1 200 OK
Content-Type: text/html;charset=gb2312
Cahe-Control: no-cache
Connection: close
408 Request Timeout
root@K:~# socat tcp4:192.168.1.1:80
head
HTTP/1.1 200 OK
Content-Type: text/html;charset=gb2312
Cache-Control: no-cache
Connection: close
408 Request Timeout
root@K:~# socat - tcp4-listen:2222
root@K:~# netstat -pantu | grep :2222
tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN 2066+/socat
yuanfh@Bodhi:~$ sudo apt-get install socat
yuanfh@Bodhi:~$ socat - tcp:192.168.1.110:2222
root@K:~# socat tcp4-listen:333 open:2.txt,creat,append
yuanfh@Bodhi:~$ echo "abasasdfdfafsfadsf" > 1.txt
yuanfh@Bodhi:~$ cat 1.txt | socat -tcp:192.168.1.110:333
yuanfh@Bodhi:~$ cat 2.txt
abasasdfdfafsfadsf
SOCAT 远程-----服务器端 - socat tcp-l:23 exec:sh,pty.stderr 端口转发 - socat tcp4-listen:22,fork tcp4:1.1.1.1:22 远程执行命令 - 服务器:socat - udp-l:2001 - 客户端:echo "'id'" | socat - udp4-datagram:1.1.1.1:2001 UDP全端口任意内容发包 - for PORT in {1..65535}; do echo "aaaaa" | socat - UDP4- DATAGRAM:1.1.1.1:$PORT; sleep .1 ;done |
root@K:~# socat tcp-1:23 exec:sh,pty.stderr
yuanfh@Bodhi:~$ socat - tcp:192.168.1.110:23
# id
id
uid=0(root) gid=0(root) groups=0(root)
# ifconfig
root@K:~# socat tcp4-listen:8080,fork tcp4:1.1.1.1:80
root@K:~# netstat -pantu | grep :8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2464+/socat
root@K:~# socat - udp-l:2000
aaaaaaaaaaaaaaa
2016/05/13 18:40:55 socat[2476] E read(5, 0x111fc30, 8192): Connection refused
yuanfh@Bodhi:~$ echo "aaaaaaaaaaaaaaa" | socat - udp-datagram:192.168.1.110:2000
yuanfh@Bodhi:~$ socat - udp-datagram:192.168.1.110:2000
asdfsdfagfddfsaf
root@K:~# socat - udp-l:2000
uid=1000(yuanfh) gid=1000(yuanfh) grougs=1000(yuanfh),4(adm),24(cdrom),27(sudo),
30(dig),46(plugdev,109(lpadmin),110(sambashare)
2016/05/13 18:43:00 socat[2476] E read(5, 0x111fc30, 8192): Connection refused
root@K:~# for PORT in {1..65535}; do echo "aaaaa" | socat - UDP4-DATAGRAM:1.1.1.1:$PORT; sleep .1 ;done
SOCAT 二进制编辑器 - echo -e "\0\14\0\-\c" | socat -u - file:/usr/bin/squid.exe,seek,seek=0x00074420 简单的WEB服务器 - socat -T 1 -d -d TCP-L:10081,reuseaddr,fork,crlf SYSTEM:"echo -e \"\\\"HTTP/1.0 200 OK\\nDocumnetType: text/plain\\\n\\\ndate: \$\(data\)\\\nserver:\$SOCAT_SOCKADDR:\$SOCAT_SOCKPORT\\\ncl ient: \$SOCAT_PEERADDR:\$SOCAT_PEERPORT\\\n\\\"\"; cat; echo -e \"\\\"\\\n\\\"\"" |
root@K:~# socat -T 1 -d -d TCP-L:10081,reuseaddr,fork,crlf SYSTEM:"echo -e \"\\\"HTTP/1.0 200 OK\\nDocumnetType:text/plain\\\n\\\ndate: \$\(data\)\\\nserver:\$SOCAT_SOCKADDR:\$SOCAT_SOCKPORT\\\nclient: \$SOCAT_PEERADDR:\$SOCAT_PEERPORT\\\n\\\"\"; cat; echo -e \"\\\"\\\n\\\"\""
yuanfh@Bodhi:~$ socat - tcp:192.168.1.110:10081
-w HTTP/1.0 200 OK
data: 20160 050 310 0 0 0 18:27:27 CST
server: 192.168.1.110:10081
client: 192.168.1.134:39472