- 论坛徽章:
- 84
|
本帖最后由 yjh777 于 2016-01-13 17:53 编辑
If bash was compiled with --enable-net-redirections, it has the capability of
using a special character device for both TCP and UDP redirections. These
redirections are used identically as STDIN/STDOUT/STDERR. The device entries
are 30,36 for /dev/tcp:
mknod /dev/tcp c 30 36
>From the bash reference:
/dev/tcp/host/port
If host is a valid hostname or Internet address, and port is an integer
port number or service name, Bash attempts to open a TCP connection to the
corresponding socket.- $ sudo mknod /dev/tcp c 30 36
- $ for ((i=1; i<1024; i++)); do port=$i; timeout 1 bash -c "echo >/dev/tcp/$host/$port" 2>/dev/null && echo "port $port is open"; done
- port 22 is open
- port 631 is open
复制代码 不过下面的测试没有得道想要的结果,cat 没有得到数据,可能时请求报文格式不对?- $ exec 100<>/dev/tcp/127.0.0.1/8080; echo -e "GET / HTTP/1.0\n" >&100; cat <&100
复制代码 |
评分
-
查看全部评分
|