爱意满满的作品展示区。
kingddc314

写了一个用 Shell 写 HTTP 服务的工具

  •  
  •   kingddc314 ·
    six-ddc · Apr 24, 2017 · 3954 views
    This topic created in 3336 days ago, the information mentioned may be changed or developed.

    工具效果是每接收到一个 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

    11 replies    2017-07-08 21:29:53 +08:00
    Finest
        1
    Finest  
       Apr 24, 2017
    我看标题以为是用 shell 写了个 http 服务端
    lsongdev
        2
    lsongdev  
       Apr 24, 2017 via iPhone
    @hand515 我也以为是,因为我之前确实写了个。。
    https://github.com/song940/shell-scripts/blob/master/http-server
    lsongdev
        3
    lsongdev  
       Apr 24, 2017 via iPhone
    @hand515 大概效果就是,如果可执行就执行并返回结果( CGI ),不能执行就输出原文。
    whileFalse
        4
    whileFalse  
       Apr 24, 2017
    脑洞不错。
    yangyanggnu
        5
    yangyanggnu  
       Apr 24, 2017
    command injection :p
    ryd994
        6
    ryd994  
       Apr 24, 2017 via Android
    这该算重新发明 CGI 么………
    Tink
        7
    Tink  
    PRO
       Apr 25, 2017 via iPhone
    这个还挺好玩的,能方便不少
    sunjourney
        8
    sunjourney  
       Apr 25, 2017
    说好的 shell 呢
    Tink
        9
    Tink  
    PRO
       Apr 25, 2017
    最好能一个进程实现多个 shell commands 就好了
    gyorou
        10
    gyorou  
       Apr 25, 2017
    突然发现, CGI 原来已经是 20 多年前的东西了。。。
    mingyun
        11
    mingyun  
       Jul 8, 2017
    记得好像有个 Python 版的 httpbin
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   913 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 79ms · UTC 22:27 · PVG 06:27 · LAX 15:27 · JFK 18:27
    ♥ Do have faith in what you're doing.