2017-12-04 5 views
0

ich dieses Skript verwendet haben aufzuspalten automatisch eine pcap-Datei in einzelne TCP-Streams:von cap-Datei mit ASCII-Ausgabe ohne Option -Z lesen

for stream in $(tshark -r $1 -T fields -e tcp.stream | sort -n | uniq) 
do 
    echo $stream 
    tshark -r $1 -w $2/stream-$stream.cap -Y "tcp.stream==$stream" 
done 

jetzt für jede einzelne Capture-Datei, die einen Strom I darstellt, können sie mit

tshark -r somefile.cap 

lesen, aber ich diese Art der Ausgabe:

1 0.000000 172.18.0.4 → 172.18.0.5 HTTP 386 GET /eureka/apps/delta HTTP/1.1 
    2 0.001457 172.18.0.5 → 172.18.0.4 HTTP 466 HTTP/1.1 200 OK (application/json) 
    3 0.001490 172.18.0.4 → 172.18.0.5 TCP 66 37830 → 8761 [ACK] Seq=321 Ack=401 Win=287 Len=0 TSval=330522 TSecr=330522 
... 

ich würde li ke es mit dem gleichen Format zu lesen, die Sie erhalten, wenn Sie einen Stream mit -z, zum Beispiel folgen

tshark -r somefile.pcap -z "follow,http,ascii,172.18.0.6:57238,172.18.0.4:8081" 

, die Ihnen das gleiche wie oben gibt, sowie

=================================================================== 
Follow: http,ascii 
Filter: ((ip.src eq 172.18.0.6 and tcp.srcport eq 57238) and (ip.dst eq 172.18.0.4 and tcp.dstport eq 8081)) or ((ip.src eq 172.18.0.4 and tcp.srcport eq 8081) and (ip.dst eq 172.18.0.6 and tcp.dstport eq 57238)) 
Node 0: 172.18.0.6:57238 
Node 1: 172.18.0.4:8081 
821 
POST /api/cars?cacheBuster=1511774200847 HTTP/1.1 
Origin: http://localhost:8080 
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTUxMzI1NzU5MX0.xyXj0-7xjluW0jB9y2UGzcZcruADHkgTH_mnTIYsSmggqDW7XIeHC7ftKPmaMjozLhpIGofHAbrXj6TOTQlvXQ 
Accept: application/json, text/plain, */* 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 
Referer: http://localhost:8080/ 
Accept-Language: en-US,en;q=0.9,it;q=0.8,ru;q=0.7 
Accept-Encoding: gzip 
Content-Type: application/json;charset=UTF-8 
x-forwarded-host: localhost:8080 
x-forwarded-proto: http 
x-forwarded-prefix: /carapp 
x-forwarded-port: 8080 
x-forwarded-for: 172.18.0.1 
Content-Length: 61 
Host: 172.18.0.4:8081 
Connection: Keep-Alive 
... 

am Ende.

gibt es eine Option, die existiert?

Antwort

0

Vielleicht würde so etwas wie das folgende helfen?

tshark -r somefile.pcap -Y "http and (((ip.src eq 172.18.0.6 and tcp.srcport eq 57238) and (ip.dst eq 172.18.0.4 and tcp.dstport eq 8081)) or ((ip.src eq 172.18.0.4 and tcp.srcport eq 8081) and (ip.dst eq 172.18.0.6 and tcp.dstport eq 57238)))" -O http 

... oder ein bisschen einfacher, die das Gleiche erreichen sollten:

tshark -r somefile.pcap -Y "http and (ip.addr eq 172.18.0.6 and tcp.port eq 57238 and ip.addr eq 172.18.0.4 and tcp.port eq 8081)" -O http 

... oder noch einfacher, wenn Sie die TCP-Stream-Nummer kennen, die mit diesem Gespräch:

tshark -r somefile.pcap -Y "http and tcp.stream eq 0" -O http 

(Hier habe ich angenommen, nur der Stream-Index ist 0.)

auf diesiehefür weitere Informationen.

+0

Danke für die Einsicht, nichts davon funktioniert, aber Sie haben mir klar gemacht, dass ich nur die "tcp.stream EQ 0" jeder Datei (da sie bereits durch Strom geteilt sind), so mit 'tshark - r stream-6.cap -z "folge, http, ascii, 0" ' Ich kann bekommen, was ich will. – user1534252