工具效果是每接收到一个 HTTP Request ,就执行指定的 Shell Commands ,并返回内容
在脚本里面可以做这些事情:
- 正常的 Shell 操作,输出重定向到 Server 终端
- 读取当前 HTTP 请求内容
- 自定义 Response 返回
我们可以这样玩:
# Hello World
$ httpbin :8080/hello -c 'httpbin add body world'
$ curl http://127.0.0.1:8080/hello
# 获取服务器进程
$ httpbin 127.0.0.1:8080/ps -c "ps | httpbin add body"
$ curl http://127.0.0.1:8080/ps
# 获取本机 IP
$ httpbin :8080/ip -c "httpbin get ip | httpbin add body"
$ curl http://192.168.1.101:8080/ip
# 下服务器文件
$ httpbin :8080/download -c 'file=$( httpbin get form file); httpbin add body < $file'
$ curl http://127.0.0.1:8080/download?file=/Users/haha/a.gif
Github : https://github.com/six-ddc/httpbin 来吧, F**k Me