2011-10-03 03:41:58 +02:00
|
|
|
#
|
2012-11-01 15:20:50 +01:00
|
|
|
# Shorewall version 4 - Drop TCPFlags Action
|
2011-10-03 03:41:58 +02:00
|
|
|
#
|
2012-11-01 15:20:50 +01:00
|
|
|
# /usr/share/shorewall/action.TCPFlags
|
2011-10-03 03:41:58 +02:00
|
|
|
#
|
2011-10-05 18:32:26 +02:00
|
|
|
# Accepts a single optional parameter:
|
2011-10-03 03:41:58 +02:00
|
|
|
#
|
|
|
|
# - = Do not Audit
|
2011-10-05 18:32:26 +02:00
|
|
|
# audit = Audit dropped packets.
|
2011-10-03 03:41:58 +02:00
|
|
|
#
|
|
|
|
#################################################################################
|
|
|
|
FORMAT 2
|
|
|
|
|
|
|
|
DEFAULTS DROP,-
|
|
|
|
|
2012-06-05 16:32:43 +02:00
|
|
|
?BEGIN PERL;
|
2011-10-05 18:32:26 +02:00
|
|
|
use strict;
|
2011-10-03 03:41:58 +02:00
|
|
|
use Shorewall::Config qw(:DEFAULT F_IPV4 F_IPV6);
|
|
|
|
use Shorewall::Chains;
|
|
|
|
|
|
|
|
my ( $disposition, $audit ) = get_action_params( 2 );
|
|
|
|
|
|
|
|
my $chainref = get_action_chain;
|
|
|
|
my ( $level, $tag ) = get_action_logging;
|
|
|
|
|
2012-04-24 23:52:57 +02:00
|
|
|
fatal_error q(The first argument to 'TCPFlags' must be ACCEPT, REJECT, or DROP) unless $disposition =~ /^(ACCEPT|REJECT|DROP)$/;
|
2011-10-03 03:41:58 +02:00
|
|
|
|
|
|
|
if ( $level ne '-' || $audit ne '-' ) {
|
|
|
|
my $logchainref = ensure_filter_chain newlogchain( $chainref->{table} ), 0;
|
|
|
|
|
|
|
|
log_rule_limit( $level,
|
|
|
|
$logchainref,
|
|
|
|
$chainref->{name},
|
|
|
|
$disposition,
|
|
|
|
'',
|
|
|
|
$tag,
|
|
|
|
'add',
|
|
|
|
'' ) if $level;
|
|
|
|
|
|
|
|
if ( supplied $audit ) {
|
2011-10-05 18:32:26 +02:00
|
|
|
fatal_error "Invalid argument ($audit) to TCPFlags" if $audit ne 'audit';
|
2011-10-03 03:41:58 +02:00
|
|
|
require_capability 'AUDIT_TARGET', q(Passing 'audit' to the TCPFlags action), 's';
|
|
|
|
add_ijump( $logchainref, j => 'AUDIT --type ' . lc $disposition );
|
2012-04-24 23:52:57 +02:00
|
|
|
}
|
2011-10-03 03:41:58 +02:00
|
|
|
|
|
|
|
add_ijump( $logchainref, g => $disposition );
|
|
|
|
|
|
|
|
$disposition = $logchainref;
|
|
|
|
}
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2011-10-03 03:41:58 +02:00
|
|
|
add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags ALL FIN,URG,PSH';
|
|
|
|
add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags ALL NONE';
|
|
|
|
add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags SYN,RST SYN,RST';
|
|
|
|
add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags SYN,FIN SYN,FIN';
|
|
|
|
add_ijump $chainref , g => $disposition, p => 'tcp --syn --sport 0';
|
|
|
|
|
2012-06-05 16:32:43 +02:00
|
|
|
?END PERL;
|
2011-10-03 03:41:58 +02:00
|
|
|
|
|
|
|
|
2012-04-24 23:52:57 +02:00
|
|
|
|
2011-10-03 03:41:58 +02:00
|
|
|
|
|
|
|
|