snortlog
来自「入侵检测源代码,参考snort结构编程. 可修改,编译连接.」· 代码 · 共 74 行
TXT
74 行
#!/usr/bin/perl# Syslog analysis script orignially written by# Angelos Karageorgiou <angelos@StockTrade.GR> and# tweaked by Martin Roesch <roesch@clark.net>if($ARGV[1] eq undef){ print "USAGE: snortlog <logname> <machinename>\n"; print "EXAMPLE: snortlog /var/log/messages sentinel\n"; print "Note: The machine name is just the hostname, not the FQDN!\n"; exit;}$machine = $ARGV[1];$targetlen=25;$sourcelen=35;$protolen=12;use Socket;open(LOG,"< $ARGV[0]") || die "No can do";printf("%15s %-35s %-25s %-25s\n","DATE","WARNING", "FROM", "TO");print "=" x 100;print "\n";while(<LOG>) { chomp(); if ( ( ! /.*snort*/gi ) ) { next ; } $_ =~ s/ $machine snort//gi ; $date=substr($_,0,15); $rest=substr($_,16,500); @fields=split(": ", $rest); $text=$fields[0]; $fields[1] =~ s/ \-\> /-/gi; ($source,$dest)=split('-', $fields[1]); ($host,$port)=split(':',$source); $iaddr = inet_aton($host); # or whatever address $name = gethostbyaddr($iaddr, AF_INET); if ( $name =~ /^$/ ) { $name=$host; } $name = $name . ":" . $port; $skipit=0; ($shost,$sport)=split(':',$dest); $sport =~ s/ //gi; $siaddr = inet_aton($shost); # or whatever address $sname = gethostbyaddr($siaddr, AF_INET) ; if ( $sname =~ /^$/ ) { $sname=$shost; } $sname = $sname . ":" . $sport; printf("%15s %-32s %-30s %s\n", $date, $text, $name,$sname);}close(LOG);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?