Tampilkan postingan dengan label ipsumdump. Tampilkan semua postingan
Tampilkan postingan dengan label ipsumdump. Tampilkan semua postingan

Minggu, 18 April 2010

tcpslice II


More uses for tcpslice, ipsumdump, BASH 4.1 :

[This gives you today's top source IP and source IP Port combination: 


/usr/sbin/tcpslice `date +%Y"y"%m"m"%d"d"` $BASH_ARGV | ipsumdump --no-headers -sD - 

./todays_dump.sh MarApr.snort.in.tcpd | sort -nr | uniq -c | sort -nr
     13 85.144.201.237 7959
      3 95.179.99.147 5900
      3 64.206.157.2 23
      3 222.45.112.59 8085
      3 109.187.8.70 5900
      2 98.247.214.152 23 ...


This gives you today's top source IP and source IP location:


/usr/sbin/tcpslice `date +%Y"y"%m"m"%d"d"` $BASH_ARGV |
for i in `ipsumdump --no-headers -s -`
     do echo $i : $(printf "%s" `./geoip.sh $i | awk -F":" '{print $2}' | awk -F"," '{print $1","$2","$3}' ` ) 
done
 


./tgeodump.sh MarApr.snort.in.tcpd | sort -nr | uniq -c | sort -nr
     13 85.144.201.237 : NL,07,Amsterdam
     12 222.45.112.59 : CN,22,Beijing
      4 222.215.230.49 : CN,32,Chengdu
      3 95.179.99.147 : RU,43,Lipetsk
      3 64.206.157.2 : US,NH,Nashua
      3 109.187.8.70 : IPAddressnotfound,,
      2 98.247.214.152 : US,WA,Bothell ...


where 'geoip.sh' is:
geoiplookup -f /usr/local/share/GeoIP/GeoLiteCity.dat $1


I note that file names like this '08Mar1142PST2010.in.1268074842' don't process through tcpslice.

Rabu, 14 April 2010

tcpslice


Tcpslice is a useful tool from LBL network group that allows you to carve up a large pcap file format into time slices. 
To look at the start and finish time stamps of the entire pcap file in various time formats:
tcpslice -r Marchrferrisx.snort.in 
Marchrferrisx.snort.in  Mon Mar  8 11:08:09 2010        Mon Apr  5 09:09:37 2010
tcpslice -t Marchrferrisx.snort.in
Marchrferrisx.snort.in  2010y03m08d11h08m09s660222u     2010y04m05d09h09m37s390876u
tcpslice -R Marchrferrisx.snort.in
Marchrferrisx.snort.in  1268075289.660222       1270483777.390876
To return data from a particular time slice to a file with BPF filters use syntax like this: 
tcpslice 1257347146.060 1257347146.061 inputFile.tcpd | tcpdump -r - -w outputFile.tcpd 'host 192.168.1.175'
(Check out bothunter logs for more examples like this..)
In this example, I want all the packets that are not IPv6 for one date:
/usr/sbin/tcpslice 2010y04m05d Marchrferrisx.snort.in | /usr/sbin/tcpdump -r - 'not(ip6)' | less
reading from file -, link-type EN10MB (Ethernet)
01:06:17.290514 IP 125.141.195.190.35460 > 192.168.0.12.ssh: S 1607742099:1607742099(0) win 65535

01:40:16.181816 IP c-98-247-214-152.hsd1.wa.comcast.net.catchpole > 192.168.0.12.telnet: SWE 498716114:498716114(0) win 5840
01:40:19.172942 IP c-98-247-214-152.hsd1.wa.comcast.net.catchpole > 192.168.0.12.telnet: SWE 498716114:498716114(0) win 5840
01:44:01.423708 IP hn.kd.ny.adsl.x11 > 192.168.0.12.ms-sql-s: S 833421312:833421312(0) win 16384
03:37:06.073237 IP 75.125.252.76.http > 192.168.0.12.48532: S 1175613974:1175613974(0) ack 143375003 win 14420
04:07:03.019711 IP 222.45.112.59.12200 > 192.168.0.12.ssm-els: S 363594672:363594672(0) win 8192 ...
Now I want all ms-sql-s destination packets from the ingress pcap that are not IPv6 for all of March:
/usr/sbin/tcpslice 2010y04m01d 2010y04m31d Marchrferrisx.snort.in | /usr/sbin/tcpdump -r - -n 'dst port(1433)'
reading from file -, link-type EN10MB (Ethernet)
18:33:42.614843 IP 125.46.78.100.x11 > 192.168.0.12.ms-sql-s: S 908984320:908984320(0) win 16384
23:38:50.771853 IP 61.183.172.35.x11 > 192.168.0.12.ms-sql-s: S 47316992:47316992(0) win 16384
03:35:18.351118 IP 121.12.125.7.x11 > 192.168.0.12.ms-sql-s: S 640548864:640548864(0) win 16384
11:09:45.631103 IP 218.61.127.71.x11 > 192.168.0.12.ms-sql-s: S 1613627392:1613627392(0) win 16384
00:47:21.207593 IP 218.90.163.66.x11 > 192.168.0.12.ms-sql-s: S 648937472:648937472(0) win 16384
08:56:05.732622 IP 61.183.172.35.x11 > 192.168.0.12.ms-sql-s: S 47316992:47316992(0) win 16384
18:06:53.798198 IP 59.51.114.39.x11 > 192.168.0.12.ms-sql-s: S 648937472:648937472(0) win 16384 ...
 
Something similar, but a little cleaner, can be done with ipsumdump:


/usr/sbin/tcpslice 2010y04m01d 2010y04m31d Marchrferrisx.snort.in | ipsumdump -tsD | grep -w 1433
 
1270172022.614843 125.46.78.100 1433 
1270190330.771853 61.183.172.35 1433 
1270204518.351118 121.12.125.7 1433 
1270231785.631103 218.61.127.71 1433 
1270280841.207593 218.90.163.66 1433 
1270310165.732622 61.183.172.35 1433 
1270343213.798198 59.51.114.39 1433 ...

Kamis, 04 Juni 2009

Viisualizing SIPs over time,port,IP range

Being able to quickly visualize Source IP Addresses over time and port and IP range is significant. The following utilities help:
  • mergecap
  • ipsumdump
  • pcregrep
  • gnuplot
Mergecap is part of the Wireshark distribution. It merges pcap files quickly and with little fanfare. Ipsumdump is a brilliant piece of software by UCLA prof Eddie Kohler. It is based on his "Click" router development which provides functional replacement for pcap code. Gnuplot is indispensable as part of the *Nix toolkit.What I want to do here is:

(1) merge two weeks of tcpdump captures into one pcap file
(2) filter out some common ports (e.g. noise)
(3) meaningfully analyze SIP behavior

The examples below are simple and straightforward. I expect to explore this software more.
[Here I filter out some common 'noisy' internal traffic:]

more no_search.txt
514
520
137
138
67

[Now I merge a couple weeks of pcap files and then columnize them with ipsumdump:]

mergecap -w May22-Jun4.cap May*2009 Jun012009
ipsumdump -r --no-headers -qtsSdDpO May22-Jun4.cap | pcregrep -v -f no_search.txt | sort -n -k 2 | more
....
1243564232.633833 110.8.212.14 3232 192.168.0.12 12712 U -
1243819790.146836 113.12.190.38 41300 192.168.0.12 1434 U -
1243962105.530513 113.12.190.38 40074 192.168.0.12 1434 U -
1243948162.113607 114.44.118.145 2522 192.168.0.12 25 T mss1440;sackok
1243948162.891020 114.44.118.145 2522 192.168.0.12 25 T mss1440;sackok
1243948163.661370 114.44.118.145 2522 192.168.0.12 25 T mss1440;sackok
1242915720.575869 114.45.61.61 4121 192.168.0.12 25 T mss1440;sackok
1242915727.208449 114.45.61.61 4121 192.168.0.12 25 T mss1440;sackok
1243948165.160091 115.150.202.176 1358 192.168.0.12 12712 U -
1243580800.176250 115.30.142.186 46453 192.168.0.12 1434 U -
.....

[Now I re-ordered one SIP I want to explore more closely:]

grep 121.15.245.215 out.dat 121.15.245.215.dat
sort -nr 121.15.245.215.dat > 121.15.245.215.graph.dat

1243935815.497855 121.15.245.215 12200 192.168.0.12 8000 T .
1243896403.852720 121.15.245.215 12200 192.168.0.12 3128 T .
1243786852.873342 121.15.245.215 12200 192.168.0.12 8000 T .
1243786749.219621 121.15.245.215 12200 192.168.0.12 3128 T .
1243751923.943017 121.15.245.215 12200 192.168.0.12 8000 T .
1243751811.136522 121.15.245.215 12200 192.168.0.12 3128 T .
1243702801.387269 121.15.245.215 12200 192.168.0.12 8000 T .
1243702687.231474 121.15.245.215 12200 192.168.0.12 3128 T .
1243678638.723457 121.15.245.215 12200 192.168.0.12 7212 T .
....

[Then I plot that SIP's activity over time:]

gnuplot> set terminal dumb
Terminal type set to 'dumb'
Options are 'feed 79 24'
gnuplot> plot "121.15.245.215.graph.dat" using 1 with lines


1.244e+09 ++-------+-------+--------+--------+--------+-------+-------++
** + + "121.15.245.215.graph.dat" using 1 ****** +
| * |
1.2438e+09 ++ * ++
| ******* |
| ******* |
| ********* |
1.2436e+09 ++ **** ++
| ******* |
| * |
1.2434e+09 ++ * ++
| * |
| * |
1.2432e+09 ++ * ++
| * |
| * |
| ** |
1.243e+09 ++ ******* ++
| ** |
+ + + + + + ********** +
1.2428e+09 ++-------+-------+--------+--------+--------+-------+-------++
0 5 10 15 20 25 30 35


[Here, the SIPs behaviour makes me more interested in plotting per port...]

grep 218.103.62.150 out.dat > 218.103.62.150.dat
more 218.103.62.150.dat

1242901282.013137 218.103.62.150 55248 192.168.0.12 19899 T mss1394;sackok
1242901282.670295 218.103.62.150 55248 192.168.0.12 19899 T mss1394;sackok
1242901283.342359 218.103.62.150 55248 192.168.0.12 19899 T mss1394;sackok
1242901284.902925 218.103.62.150 55254 192.168.0.12 17337 T mss1394;sackok
1242901285.542566 218.103.62.150 55254 192.168.0.12 17337 T mss1394;sackok
1242901286.151354 218.103.62.150 55254 192.168.0.12 17337 T mss1394;sackok
1242901287.088508 218.103.62.150 55257 192.168.0.12 17681 T mss1394;sackok
1242901287.664895 218.103.62.150 55257 192.168.0.12 17681 T mss1394;sackok
1242901288.291307 218.103.62.150 55257 192.168.0.12 17681 T mss1394;sackok
...

gnuplot
gnuplot> set terminal dumb
gnuplot> plot "218.103.62.150.dat" using 5:1 with points

1.2429e+09 ++------+------+-------+-------+------+-------+------+------++
+ + + "218.103.62.150.dat" using 5:1+ A +
A |
1.2429e+09 ++ ++
| |
| |
| |
1.2429e+09 ++ ++
| A |
| A |
1.2429e+09 ++ AA ++
A A A |
| A AA A |
1.2429e+09 ++A A++
| A A A A |
| |
| A |
1.2429e+09 A+ ++
| |
+ + + + AA A+ + + + +
1.2429e+09 ++------+------+-------+------A+------+-------+------+------++
0 5000 10000 15000 20000 25000 30000 35000 40000