| 1245 | | if ($pkt{'fwsnort_sid'} and not $no_snort_sids) { |
|---|
| 1246 | | ### found a snort sid in the packet log message |
|---|
| 1247 | | my $dl = &add_snort_sid($pkt{'src'}, $pkt{'dst'}, |
|---|
| 1248 | | $pkt{'chain'}, $pkt{'proto'}, $pkt{'fwsnort_sid'}); |
|---|
| 1249 | | $curr_sids_dl{$pkt{'src'}} = $dl if $dl; |
|---|
| 1250 | | } else { |
|---|
| 1251 | | ### attempt to match any tcp/udp/icmp signatures in the |
|---|
| 1252 | | ### main signatures hash |
|---|
| 1253 | | unless ($no_signatures) { |
|---|
| 1254 | | |
|---|
| 1255 | | my $dl = &match_sigs(\%pkt); |
|---|
| 1256 | | |
|---|
| 1257 | | $curr_sigs_dl{$pkt{'src'}} = $dl if $dl; |
|---|
| | 1245 | unless ($no_snort_sids) { |
|---|
| | 1246 | if ($pkt{'fwsnort_sid'}) { |
|---|
| | 1247 | ### found a snort sid in the packet log message |
|---|
| | 1248 | my $dl = &add_snort_sid(\%pkt); |
|---|
| | 1249 | $curr_sids_dl{$pkt{'src'}} = $dl if $dl; |
|---|
| | 1250 | } else { |
|---|
| | 1251 | ### attempt to match any tcp/udp/icmp signatures in the |
|---|
| | 1252 | ### main signatures hash |
|---|
| | 1253 | unless ($no_signatures) { |
|---|
| | 1254 | |
|---|
| | 1255 | my $dl = &match_sigs(\%pkt); |
|---|
| | 1256 | |
|---|
| | 1257 | $curr_sigs_dl{$pkt{'src'}} = $dl if $dl; |
|---|
| | 1258 | } |
|---|
| 4282 | | my $pkts = $href->{'sid'}->{$sid}->{$chain}; |
|---|
| 4283 | | print $fh qq( "$sm_hr->{'msg'}"\n); |
|---|
| | 4292 | my $dp = -1; |
|---|
| | 4293 | my $flags = ''; |
|---|
| | 4294 | if ($proto eq 'tcp' or $proto eq 'udp') { |
|---|
| | 4295 | $dp = $href->{'sid'}->{$sid}->{$chain}->{'dp'}; |
|---|
| | 4296 | $flags = $href->{'sid'}->{$sid}->{$chain}->{'flags'}; |
|---|
| | 4297 | } |
|---|
| | 4298 | my $pkts = $href->{'sid'}->{$sid}->{$chain}->{'pkts'}; |
|---|
| | 4299 | |
|---|
| | 4300 | print $fh qq| "$sm_hr->{'msg'}"\n|; |
|---|
| | 4301 | if ($proto eq 'tcp' or $proto eq 'udp') { |
|---|
| | 4302 | if ($chain eq 'INPUT') { |
|---|
| | 4303 | if (defined $local_ports{$proto} |
|---|
| | 4304 | and defined $local_ports{$dp}) { |
|---|
| | 4305 | print $fh " dst port: $dp (server bound to port!)\n", |
|---|
| | 4306 | " flags: $flags\n"; |
|---|
| | 4307 | } else { |
|---|
| | 4308 | print $fh " dst port: $dp (no server bound to port)\n", |
|---|
| | 4309 | " flags: $flags\n"; |
|---|
| | 4310 | } |
|---|
| | 4311 | } else { |
|---|
| | 4312 | print $fh " dst port: $dp\n", |
|---|
| | 4313 | " flags: $flags\n"; |
|---|
| | 4314 | } |
|---|
| | 4315 | } |
|---|
| 4331 | | for my $sid (keys %{$href->{'curr_sig'}}) { |
|---|
| 4332 | | my $msg = $sigs{$sid}{'msg'}; |
|---|
| 4333 | | |
|---|
| 4334 | | for my $chain (keys %{$href->{'curr_sig'}->{$sid}}) { |
|---|
| 4335 | | if ($proto eq 'tcp' or $proto eq 'udp') { |
|---|
| 4336 | | for my $dp (keys %{$href->{'curr_sig'} |
|---|
| 4337 | | {$sid}->{$chain}->{'dp'}}) { |
|---|
| 4338 | | my $flags = ''; |
|---|
| 4339 | | my $pkts = $href->{'curr_sig'} |
|---|
| 4340 | | {$sid}->{$chain}->{'dp'}->{$dp}; |
|---|
| 4341 | | if (defined $href->{'curr_sig'}->{$sid}->{$chain}->{'flags'} |
|---|
| 4342 | | and defined $href->{'curr_sig'}-> |
|---|
| 4343 | | {$sid}->{$chain}->{'flags'}->{$dp}) { |
|---|
| 4344 | | $flags = $href->{'curr_sig'}-> |
|---|
| 4345 | | {$sid}->{$chain}->{'flags'}->{$dp}; |
|---|
| 4346 | | } |
|---|
| 4347 | | |
|---|
| 4348 | | if ($dst_ip_is_local) { |
|---|
| 4349 | | ### check local ports here since we know the |
|---|
| 4350 | | ### destination is a local ip address |
|---|
| 4351 | | if (defined $local_ports{$proto}{$dp}) { |
|---|
| 4352 | | if ($flags) { |
|---|
| 4353 | | print $fh " \"$msg\"\n", |
|---|
| 4354 | | " sid=$sid chain=$chain packets=$pkts dp=$dp flags=[$flags] ", |
|---|
| 4355 | | "[*] Your machine is listening on $proto port: $dp!\n"; |
|---|
| 4356 | | } else { |
|---|
| 4357 | | print $fh " \"$msg\"\n", |
|---|
| 4358 | | " sid=$sid chain=$chain packets=$pkts dp=$dp ", |
|---|
| 4359 | | "[*] Your machine is listening on $proto port: $dp!\n"; |
|---|
| 4360 | | } |
|---|
| 4361 | | } else { |
|---|
| 4362 | | if ($flags) { |
|---|
| 4363 | | print $fh " \"$msg\"\n", |
|---|
| 4364 | | " sid=$sid chain=$chain packets=$pkts dp=$dp flags=[$flags] ", |
|---|
| 4365 | | "No local server on $proto/$dp\n"; |
|---|
| 4366 | | } else { |
|---|
| 4367 | | print $fh " \"$msg\"\n", |
|---|
| 4368 | | " sid=$sid chain=$chain packets=$pkts dp=$dp No local ", |
|---|
| 4369 | | "server on $proto/$dp\n"; |
|---|
| 4370 | | } |
|---|
| 4371 | | } |
|---|
| 4372 | | } else { |
|---|
| 4373 | | if ($flags) { |
|---|
| 4374 | | print $fh " \"$msg\"\n", |
|---|
| 4375 | | " sid=$sid chain=$chain packets=$pkts dp=$dp flags=[$flags]\n"; |
|---|
| 4376 | | } else { |
|---|
| 4377 | | print $fh " \"$msg\"\n", |
|---|
| 4378 | | " sid=$sid chain=$chain packets=$pkts dp=$dp\n"; |
|---|
| 4379 | | } |
|---|
| 4380 | | } |
|---|
| 4381 | | } |
|---|
| 4382 | | } else { |
|---|
| 4383 | | my $pkts = $scan{$src}{$dst}{$proto} |
|---|
| 4384 | | {'curr_sig'}{$sid}{$chain}{'pkts'}; |
|---|
| 4385 | | print $fh qq( "$msg" sid=$sid chain=$chain packets=$pkts\n); |
|---|
| 4386 | | } |
|---|
| 4387 | | ### signature logging with syslog is not yet supported |
|---|
| 4388 | | ### (requires a message for each matched signature). |
|---|
| 4389 | | # if ($sigmatch =~ /^(\".*\")/) { |
|---|
| 4390 | | # $syslog_sig_title = "signature=$1"; |
|---|
| 4391 | | # } |
|---|
| 4392 | | } |
|---|
| 4393 | | } |
|---|
| | 4363 | |
|---|