分享一个用于服务器抓包 HTTP 的工具,比 tcpdump+wireshark 更方便 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
kingddc314
V2EX    分享创造

分享一个用于服务器抓包 HTTP 的工具,比 tcpdump+wireshark 更方便

  •  1
     
  •   kingddc314
    six-ddc 2017-02-26 10:58:23 +08:00 7899 次点击
    这是一个创建于 3148 天前的主题,其中的信息可能已经有所发展或是发生改变。

    经常有需要在服务器抓 HTTP 包看接口情况,配合 tcpdump 和 wireshark 分析,感觉很麻烦,于是写了一个抓包工具

    Github: https://github.com/six-ddc/httpflow

    效果如下,欢迎大家提意见:

    25 条回复    2017-03-02 17:38:54 +08:00
    lxrmido
        1
    lxrmido  
       2017-02-26 11:06:41 +08:00
    已 star ……
    TangMonk
        2
    TangMonk  
       2017-02-26 11:23:40 +08:00
    不错!
    MinonHeart
        3
    MinonHeart  
       2017-02-26 12:46:55 +08:00 via iPhone
    和 curl 有什么区别么
    看起来就是 curl
    Muninn
        4
    Muninn  
       2017-02-26 13:03:45 +08:00 via Android
    @MinonHeart 十万八千里
    KCheshireCat
        5
    KCheshireCat  
       2017-02-26 13:14:37 +08:00
    按实际功能来说不是应该跟 Fiddler 类似的工具比较么,虽然 Fiddler 是 win 平台的。
    kindjeff
        6
    kindjeff  
       2017-02-26 13:16:55 +08:00
    @KCheshireCat fiddler 有个基于 mono 的 linux 版本,就是偶尔会卡。
    ctsed
        7
    ctsed  
       2017-02-26 13:18:28 +08:00 via Android
    有保存功能吗 在 fiddler chrome 等工具查看更方便一些
    webjin1
        8
    webjin1  
       2017-02-26 13:23:22 +08:00
    协议分析呢?
    kingddc314
        9
    kingddc314  
    OP
       2017-02-26 13:53:04 +08:00
    @ctsed 可以保存呢, http_dump -w ./out ,按 Host 分文件夹保存
    slixurd
        10
    slixurd  
       2017-02-26 14:08:03 +08:00
    大概楼主想要的是这个效果?
    ~ curl -D - v2ex.com
    HTTP/1.1 301 Moved Permanently
    Server: nginx/1.11.6
    Date: Sun, 26 Feb 2017 06:02:14 GMT
    Content-Type: text/html
    Content-Length: 185
    Connection: keep-alive
    Location: https://v2ex.com/
    X-ORCA-Accelerator: from 093.chn.fuo01.cn.krill.c3edge.net

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body bgcolor="white">
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx/1.11.6</center>
    </body>
    </html>
    ~ curl -iv --raw https://v2ex.com
    * Rebuilt URL to: https://v2ex.com/
    * Trying 14.152.44.135...
    * TCP_NODELAY set
    * Connected to v2ex.com (14.152.44.135) port 443 (#0)
    * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    * Server certificate: *.v2ex.com
    * Server certificate: TrustAsia DV SSL CA - G5
    * Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
    > GET / HTTP/1.1
    > Host: v2ex.com
    > User-Agent: curl/7.51.0
    > Accept: */*
    >
    < HTTP/1.1 301 Moved Permanently
    HTTP/1.1 301 Moved Permanently
    < Server: nginx/1.11.6
    Server: nginx/1.11.6
    < Date: Sun, 26 Feb 2017 06:02:40 GMT
    Date: Sun, 26 Feb 2017 06:02:40 GMT
    < Content-Type: text/html
    Content-Type: text/html
    < Content-Length: 185
    Content-Length: 185
    < Connection: keep-alive
    Connection: keep-alive
    < Location:
    Location:
    < Strict-Transport-Security: max-age=10886400; includeSubDomains; preload
    Strict-Transport-Security: max-age=10886400; includeSubDomains; preload
    < X-ORCA-Accelerator: from 093.chn.fuo01.cn.krill.c3edge.net
    X-ORCA-Accelerator: from 093.chn.fuo01.cn.krill.c3edge.net

    <
    <html>
    <head><title>301 Moved Permanently</title></head>
    <body bgcolor="white">
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx/1.11.6</center>
    </body>
    </html>
    * Curl_http_done: called premature == 0
    * Connection #0 to host v2ex.com left intact
    unsec
        11
    unsec  
       2017-02-26 14:30:59 +08:00
    @slixurd @MinonHeart 你们没看懂这个是什么东西...

    楼主只是用 cURL 作为 HTTP 客户来配合他的工具演示。实际环境里 HTTP 请求可能是其他客户端发起的
    tony1016
        12
    tony1016  
       2017-02-26 15:03:17 +08:00
    可以看看 bettercap
    linhua
        13
    linhua  
       2017-02-26 15:47:43 +08:00   1
    tcpdump 和 wireshark 配合很方便呀
    ssh root@HOST tcpdump -U -s0 -w - 'not port 22' | "D:\Program Files\Wireshark\Wireshark.exe" -k -i -

    http://www.commandlinefu.com/commands/view/4373/analyze-traffic-remotely-over-ssh-w-wireshark
    Lax
        14
    Lax  
       2017-02-26 16:58:42 +08:00 via iPad
    compress 和 https 支持怎么样?
    kingddc314
        15
    kingddc314  
    OP
       2017-02-26 17:23:25 +08:00 via iPhone
    @Lax 支持 gzip ,不支持 https ,这种不用代理的抓包对 https 似乎无解
    TangMonk
        16
    TangMonk  
       2017-02-27 09:19:57 +08:00
    二进制文件怎么处理好。。

    kingddc314
        17
    kingddc314  
    OP
       2017-02-27 11:21:10 +08:00
    @TangMonk
    在终端执行:
    > chmod +x ./httpflow-Darwin-x86_64
    > ./httpflow-Darwin-x86_64
    TangMonk
        18
    TangMonk  
       2017-02-27 11:28:24 +08:00
    @kingddc314 恩,这个已经编译好了,问题是可不可以对二进制的文件抓包显示优化下。。。比如说显示

    [/asets/image.png] 'binary'
    anyforever
        19
    anyforever  
       2017-02-27 14:59:17 +08:00
    想问下楼主怎么实现在右屏输入,在左屏响应的?
    anyforever
        20
    anyforever  
       2017-02-27 15:00:26 +08:00
    另外,这个是不是你想要的? https://github.com/jkbrzt/httpie
    huangmingyou
        21
    huangmingyou  
       2017-02-27 17:09:45 +08:00
    少年,你用过 tcpick 吗
    kingddc314
        22
    kingddc314  
    OP
       2017-02-27 18:07:02 +08:00
    @huangmingyou 原来有这个工具,不错可以借鉴一下,另外他这个好像不支持 gzip 解压
    kingddc314
        23
    kingddc314  
    OP
       2017-02-27 20:39:18 +08:00   1
    @TangMonk 二进制显示问题已经加上了,暂时直接做忽略处理
    antowa
        24
    antowa  
       2017-03-01 09:42:17 +08:00
    感觉可以借鉴下。不过我一直用 chrome inspect (逃)
    cattrace
        25
    cattrace  
       2017-03-02 17:38:54 +08:00
    @linhua 好用,采纳了
    .wwads-cn { border-radius: 3px !important; } .wwads-text { color: var(--link-color) !important; }
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1245 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 17:21 PVG 01:21 LAX 10:21 JFK 13:21
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86