sh 使用bash和[nc | socat]的http请求示例(在unix域套接字中)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 使用bash和[nc | socat]的http请求示例(在unix域套接字中)相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# References
# http://www.computerhope.com/unix/nc.htm#03
# https://github.com/daniloegea/netcat
# http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
# http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
# http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
# http://www.dest-unreach.org/socat/
# http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
# http://ubuntuforums.org/showthread.php?t=828870

# Socat version
echo -e "GET /images/json HTTP/1.1\r\n" | socat unix-connect:/var/run/docker.sock STDIO

# nc version (netcat-freebsd)
echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

# bonus round: relay socket
socat -d -d TCP-L:8080,fork UNIX:/var/run/docker.sock

以上是关于sh 使用bash和[nc | socat]的http请求示例(在unix域套接字中)的主要内容,如果未能解决你的问题,请参考以下文章

linux怎么使用nc命令来发送一串使用udp协议的数据?或者不是NC也可以的命令

Linux/Windows反弹shell

sh socat提示

sh Socat HTTP echo服务器

SOCAT详解

NC反弹shell