Provo a calcolare GET
Richiesta dal mio server.Come filtrare i risultati di tshark prima di scrivere su file?
Io uso tshark
.
corro comando seguito per filtrare il traffico in entrata e prendere solo GET
richieste:
/usr/sbin/tshark -b filesize:1024000 -b files:1 \
'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
-w samples.pcap -R 'http.request.method == "GET"'
Come vedi ho definito per memorizzare i risultati filtrati per 1 file con dimensione massima 1G e il nome: samples.pcap
.
Il problema è che quando cerco di aprire il file pcap vedo che tshark stored all traffic there
:
3245 172.692247 1.1.1.1 -> 2.2.2.2 HTTP [TCP Retransmission] Continuation or non-HTTP traffic
3246 172.730928 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3247 172.731944 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3248 172.791934 1.1.1.1 -> 2.2.2.2 HTTP GET /services/client/client.php?cnc=13 HTTP/1.1
3249 172.825303 1.1.1.1 -> 2.2.2.2 HTTP HTTP/1.1 200 OK [Unreassembled Packet [incorrect TCP checksum]]
3250 172.826329 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3251 172.826341 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3252 172.826347 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3253 172.826354 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
3254 172.826359 1.1.1.1 -> 2.2.2.2 HTTP Continuation or non-HTTP traffic
devo davvero grande traffico, durante 10 min ottengo pcap dimensioni del file 950M. E ci vogliono circa 4 minuti per analizzarlo.
La cosa interessante è quando provo a farlo funzionare, senza per memorizzare al file locale (ma sotto/tmp):
/usr/sbin/tshark \
'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
-R 'http.request.method == "GET"':
3.776587 1.1.1.1 -> 2.2.2.2 HTTP GET /services/client/client.php?cnc=13 HTTP/1.1
4.775624 1.1.1.1 -> 2.2.2.2 HTTP GET /services/client/clsWebClient.php HTTP/1.1
8.804702 1.1.1.1 -> 2.2.2.2 HTTP GET /services/client/client.php?cnc=13 HTTP/1.1
funziona, ma in questo caso ho sotto/tmp diversi file temporanei con dimensioni enormi 1G +.
Mi sono perso qualcosa?
Grazie
======================================== ===============
Modifica
Lars ha chiesto di aggiungere -f
:
sudo /usr/sbin/tshark -T fields -e 'http.request.uri contains "cnc=13"' \
-b filesize:1024000 -b files:1 \
-f 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
-w samples.pcap
non aiuta, ancora negozi samples.pcap tutto traffico:
74 6.908388 172.20.0.23 -> 89.78.170.96 HTTP Continuation or non-HTTP traffic
75 6.908394 172.20.0.23 -> 89.78.170.96 HTTP Continuation or non-HTTP traffic
Hai provato a fornire l'espressione del filtro di acquisizione all'opzione '-f'? –
Ho provato, ho ancora tutto il traffico. Dove metti '-f'? –
Proprio davanti all'espressione filtro, ovvero '-f 'tcp ...' –