2017-02-16 121 views
3

我有一個pcap捕獲的襪子流量。交通是這樣 -修改ip地址襪子捕獲pcap

client_ip <-> 127.0.0.1:9050 <-> destination_ip

在PCAP展望Wireshark的,因此顯示:

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 

但是,只有第一個數據包被修改。從第二個起的所有數據包保持不變。

我也試過tcprewrite爲:

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

這改變了一切src_ip & dst_ip(127.0.0.1)相同的隨機的IP,因爲它似乎只找到一個(下同)端點IP。

如何修改src &襪子流量捕獲中的dst ip地址。

感謝

回答

0

TL; DR。tcprewrite--endpoints選項是您正在尋找的。它需要一個求CacheFile從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地址等在這裏,根據the tcpprep wiki,我們要使用的--port選項一起使用to split traffic in two sides