mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-03 03:59:16 +01:00
Add DNSAmp action
- Allow escaping '@' allowing u32 in action body - Allow inline matches in actions Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
fd42fa9f74
commit
a2f1c57246
@ -280,42 +280,42 @@ sub generate_script_2() {
|
|||||||
|
|
||||||
if ( $global_variables ) {
|
if ( $global_variables ) {
|
||||||
|
|
||||||
emit( 'case $COMMAND in' );
|
|
||||||
|
|
||||||
push_indent;
|
|
||||||
|
|
||||||
if ( $global_variables & NOT_RESTORE ) {
|
if ( $global_variables & NOT_RESTORE ) {
|
||||||
emit( 'start|restart|refresh|disable|enable|run)' );
|
|
||||||
} else {
|
|
||||||
emit( 'start|restart|refresh|disable|enable|restore|run)' );
|
|
||||||
}
|
|
||||||
|
|
||||||
push_indent;
|
emit( 'case $COMMAND in' );
|
||||||
|
|
||||||
set_global_variables(1);
|
push_indent;
|
||||||
|
|
||||||
handle_optional_interfaces(0);
|
|
||||||
|
|
||||||
emit ';;';
|
|
||||||
|
|
||||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
|
||||||
pop_indent;
|
|
||||||
|
|
||||||
emit 'restore)';
|
emit 'restore)';
|
||||||
|
|
||||||
push_indent;
|
push_indent;
|
||||||
|
|
||||||
set_global_variables(0);
|
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||||
|
|
||||||
handle_optional_interfaces(0);
|
set_global_variables(0);
|
||||||
|
|
||||||
|
handle_optional_interfaces(0);
|
||||||
|
}
|
||||||
|
|
||||||
emit ';;';
|
emit ';;';
|
||||||
|
|
||||||
|
pop_indent;
|
||||||
|
|
||||||
|
emit '*)';
|
||||||
|
|
||||||
|
push_indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
pop_indent;
|
set_global_variables(1);
|
||||||
pop_indent;
|
|
||||||
|
|
||||||
emit ( 'esac' ) ,
|
handle_optional_interfaces(0);
|
||||||
|
|
||||||
|
if ( $global_variables & NOT_RESTORE ) {
|
||||||
|
emit ';;';
|
||||||
|
pop_indent;
|
||||||
|
pop_indent;
|
||||||
|
emit ( 'esac' );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
emit( 'true' ) unless handle_optional_interfaces(1);
|
emit( 'true' ) unless handle_optional_interfaces(1);
|
||||||
}
|
}
|
||||||
|
@ -3260,6 +3260,10 @@ sub expand_variables( \$ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $actparms{0} ) {
|
if ( $actparms{0} ) {
|
||||||
|
#
|
||||||
|
# Allow escaping at signs (@) for u32
|
||||||
|
#
|
||||||
|
$$lineref =~ s/\\@/??/g;
|
||||||
# $1 $2 $3 - $4
|
# $1 $2 $3 - $4
|
||||||
while ( $$lineref =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
while ( $$lineref =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||||
@ -3268,6 +3272,8 @@ sub expand_variables( \$ ) {
|
|||||||
$$lineref = join( '', $first , $val , $rest );
|
$$lineref = join( '', $first , $val , $rest );
|
||||||
fatal_error "Variable Expansion Loop" if ++$count > 100;
|
fatal_error "Variable Expansion Loop" if ++$count > 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$$lineref =~ s/??/@/g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,9 +1673,11 @@ sub process_action($$) {
|
|||||||
$origdest = $connlimit = $time = $headers = $condition = $helper = '-';
|
$origdest = $connlimit = $time = $headers = $condition = $helper = '-';
|
||||||
} else {
|
} else {
|
||||||
($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper )
|
($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper )
|
||||||
= split_line1( 'action file',
|
= split_line2( 'action file',
|
||||||
\%rulecolumns,
|
\%rulecolumns,
|
||||||
$action_commands );
|
$action_commands,
|
||||||
|
undef,
|
||||||
|
1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error 'TARGET must be specified' if $target eq '-';
|
fatal_error 'TARGET must be specified' if $target eq '-';
|
||||||
|
34
Shorewall/action.DNSAmp
Normal file
34
Shorewall/action.DNSAmp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Shorewall 4 - DNS Amplification Action
|
||||||
|
#
|
||||||
|
# /usr/share/shorewall/action.DNSAmp
|
||||||
|
#
|
||||||
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||||
|
#
|
||||||
|
# (c) 2011,2012 - Tom Eastep (teastep@shorewall.net)
|
||||||
|
#
|
||||||
|
# Complete documentation is available at http://shorewall.net
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of Version 2 of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# DNSAmp[([<action>])]
|
||||||
|
#
|
||||||
|
# Default action is DROP
|
||||||
|
#
|
||||||
|
##########################################################################################
|
||||||
|
?format 2
|
||||||
|
|
||||||
|
DEFAULTS DROP
|
||||||
|
|
||||||
|
IPTABLES(@1) - - udp 53 ; -m u32 --u32 "0>>22&0x3C\@8&0x0100=0x0100 && 0>>22&0x3C\@12>>16=1"
|
@ -31,6 +31,7 @@ allowInvalid inline # Accepts packets in the INVALID conntrack state
|
|||||||
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
||||||
AutoBLL noinline # Helper for AutoBL
|
AutoBLL noinline # Helper for AutoBL
|
||||||
Broadcast noinline # Handles Broadcast/Multicast/Anycast
|
Broadcast noinline # Handles Broadcast/Multicast/Anycast
|
||||||
|
DNSAmp # Matches one-question recursive DNS queries
|
||||||
Drop # Default Action for DROP policy
|
Drop # Default Action for DROP policy
|
||||||
dropInvalid inline # Drops packets in the INVALID conntrack state
|
dropInvalid inline # Drops packets in the INVALID conntrack state
|
||||||
DropSmurfs noinline # Drop smurf packets
|
DropSmurfs noinline # Drop smurf packets
|
||||||
|
Loading…
Reference in New Issue
Block a user