【问题标题】:Modify ip addresses in a socks capture pcap修改袜子捕获pcap中的IP地址
【发布时间】:2017-08-20 05:33:24
【问题描述】:

我对 socks 流量进行了 pcap 捕获。交通就像-

client_ip <-> 127.0.0.1:9050 <-> destination_ip

在wireshark中查看pcap,因此,显示:

src_ip = 127.0.0.1 
dst_ip = 127.0.0.1

src_ip和dst_ip地址可以改吗?

我尝试 bittwiste 为:

bittwiste -I in.pcap -O out.pcap -T ip -p 6 -s 127.0.0.1,1.2.3.4 -d
127.0.0.1,4.3.2.1

但是,只有第一个数据包被修改。从第 2 次开始,所有数据包都保持不变。

我也试过 tcprewrite 为:

tcprewrite --seed=325 --infile=in.pcap --outfile=out.pcap

这会将所有 src_ip 和 dst_ip (127.0.0.1) 更改为相同的随机 IP,因为它似乎只找到一个(相同的)端点 IP。

如何在 socks 流量捕获中修改 src 和 dst ip 地址?

谢谢

【问题讨论】:

    标签: pcap socks


    【解决方案1】:

    TL;DR. tcprewrite--endpoints 选项正是您要找的。它需要来自tcpprep 的缓存文件:

    $ tcpprep --port --pcap=in.pcap --cachefile=in.cache
    $ tcprewrite --cachefile=in.cache --endpoints=1.2.3.4:4.3.2.1  --infile=in.pcap --outfile=out.pcap
    $
    $ tshark -r out.pcap
    1   0.000000     1.2.3.4 → 4.3.2.1     TCP 74 49870 → 80 [SYN] Seq=0 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=10438137 TSecr=0 WS=128
    2   0.000030     4.3.2.1 → 1.2.3.4     TCP 74 80 → 49870 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=10438137 TSecr=10438137 WS=128
    3   0.000051     1.2.3.4 → 4.3.2.1     TCP 66 49870 → 80 [ACK] Seq=1 Ack=1 Win=43776 Len=0 TSval=10438137 TSecr=10438137
    4   0.000101     1.2.3.4 → 4.3.2.1     HTTP 139 GET / HTTP/1.1 
    5   0.000121     4.3.2.1 → 1.2.3.4     TCP 66 80 → 49870 [ACK] Seq=1 Ack=74 Win=43776 Len=0 TSval=10438137 TSecr=10438137
    6   0.023045     4.3.2.1 → 1.2.3.4     HTTP 11642 HTTP/1.1 200 OK  (text/html)
    7   0.023094     1.2.3.4 → 4.3.2.1     TCP 66 49870 → 80 [ACK] Seq=74 Ack=11577 Win=174720 Len=0 TSval=10438143 TSecr=10438143
    8   0.023517     1.2.3.4 → 4.3.2.1     TCP 66 49870 → 80 [FIN, ACK] Seq=74 Ack=11577 Win=174720 Len=0 TSval=10438143 TSecr=10438143
    9   0.023547     4.3.2.1 → 1.2.3.4     TCP 66 80 → 49870 [FIN, ACK] Seq=11577 Ack=75 Win=43776 Len=0 TSval=10438143 TSecr=10438143
    10   0.023560     1.2.3.4 → 4.3.2.1     TCP 66 49870 → 80 [ACK] Seq=75 Ack=11578 Win=174720 Len=0 TSval=10438143 TSecr=10438143
    

    说明

    根据the documentation for tcprewrite--endpoints=ip1:ip2 将所有数据包重写为似乎介于 ip1 和 ip2 之间。但是,此选项需要 --cachefile 选项。

    tcpprep缓存文件根据端口、IP地址、MAC地址等使用to split traffic in two sides,这里根据the tcpprep wiki,我们要使用--port选项。

    【讨论】:

      猜你喜欢
      • 2013-12-04
      • 2022-10-21
      • 2012-03-15
      • 1970-01-01
      • 2019-06-03
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多