Skip to content

Instantly share code, notes, and snippets.

@pfsmorigo
Created May 28, 2012 17:28
Show Gist options
  • Save pfsmorigo/2820190 to your computer and use it in GitHub Desktop.
Save pfsmorigo/2820190 to your computer and use it in GitHub Desktop.
extractor.sh
#!/bin/bash
IP="189.126.11.82"
MAC="00:0f:20:2f:63:d9"
function printcount() {
tshark -r trafego1.pcap -R "$1" -w temp.pcap > /dev/null 2>&1
capinfos -c temp.pcap | grep packets | cut -f 6 -d " "
}
# quantidade de pacotes que utilizam protocolo TCP
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && tcp"
# quantidade de pacotes que utilizam protocolo UDP
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && udp"
# quantidade de sessões TCP presentes no arquivo de tráfego
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && (tcp.flags.syn == 1 and tcp.flags.ack == 0)"
# número de sessões encontradas dado um ou mais protocolos de aplicação
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && (tcp.flags.syn == 1 and tcp.flags.ack == 0) && (tcp.port == 25)"
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && (tcp.flags.syn == 1 and tcp.flags.ack == 0) && (tcp.port == 80)"
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && (tcp.flags.syn == 1 and tcp.flags.ack == 0) && (tcp.port == 110)"
printcount "(ip.addr == $IP) && (eth.addr == $MAC) && (tcp.flags.syn == 1 and tcp.flags.ack == 0) && (tcp.port == 389)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment