Anonymous | 2016-08-15 11:09:29 UTC | #1
Witam,
Przeszukując internet znalazłem skrypt automatycznego zapisywania logów do pliku .cap przy pomocy tcpdumpa.
Może się wam przyda :)
Autor : http://xnite.org/
[code]<?php
$CONFIG = [
‘device’ => ‘eth0’, //Usually eth0, if you are unsure, you can find the device name by running ifconfig.
‘reportspeed’ => ‘15’, //MBps that you want to start tracking at.
‘packets2capture’ => ‘1000’, //Number of packets to capture in pcap dump.
‘saveto’ => ‘/var/log/ddos’ //Path to save ddos pcap logs to without the trailing /.
];
exec(“/usr/bin/ifstat .5 1 | /bin/grep -o ‘[0-9]{1,9}.[0-9]{1,9}‘“, $iospeed);
$reportspeed = $CONFIG[‘reportspeed’]1024;
$ts = date(‘U’);
$folder = $CONFIG[‘saveto’];
$interface = $CONFIG[‘device’];
$packnum = $CONFIG[‘packets2capture’];
if($iospeed[0]+$iospeed[1] >= $CONFIG[‘reportspeed’]1024) {
echo $iospeed[0]+$iospeed[1].” is equal to or greater than $reportspeed.\n”;
echo “Capturing tcpdump.\nPackets: $packnum\nInterface: $interface\n Saving to: $folder/$ts.ddos.pcap\n”;
exec(“/usr/bin/pkill -9 tcpdump”);
exec(“/usr/sbin/tcpdump -nn -i $interface -s 0 -c $packnum -w $folder/$ts.ddos.pcap”);
} else {
echo $iospeed[0]+$iospeed[1].” is less than $reportspeed.\n”;
}
?>[/code]
SystemZ | 2016-08-15 12:14:46 UTC | #2
Bardzo fajna sprawa, ma też spory potencjał do przeróbek i innego użycia.
Aylin | 2018-06-21 11:36:55 UTC | #3