[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PERL script to make SPEWS Level 2 into pf rules



Thank you. It really works well for me.

Harry

---------------------
# SPEWS Level 2 is available from
# http://spews.org/spews_list_level2.txt
# the Level 1 file should work too
# spews2.pf is the spews list made into pf rules
# after the program is run cut-and-paste spews2.pf into the total pf.conf file



open(INFILE, 'spews_list_level2.txt') or die "Can't open input.\n";
open(OUTFILE, '>pfrules.txt') or die "Can't open output.\n";

while(<INFILE>) {

	@Hunks = split(/ /, $_);
	$Block = $Hunks[0];

		if(substr($Block,0,1) =~ /[0-9]/) {
			print OUTFILE "block in log quick on \$Ext proto tcp from ", $Block, " to any port
25\n";
		}
	}

close(INFILE);
close(OUTFILE);

# remove duplicates

open(INFILE, 'pfrules.txt') or die "Can't open input.\n";
open(OUTFILE, '>unipfrules.txt') or die "Can't open output.\n";

@Oneofakind=();

while (<INFILE>) {
unless($a{$_}++) { push(@Oneofakind, $_) }
	}

foreach $b (@Oneofakind) {
	print OUTFILE $b;
	}

close(INFILE);
close(OUTFILE);

# sort

open(INFILE, 'unipfrules.txt') or die "Can't open input.\n";
open(OUTFILE, '>spews2.pf') or die "Can't open output.\n";

print OUTFILE sort <INFILE>;

close(INFILE);
close(OUTFILE);

unlink('pfrules.txt');
unlink('unipfrules.txt');
-----------------------------



Visit your host, monkey.org