#!/usr/bin/perl -w # 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() { @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 () { 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 ; close(INFILE); close(OUTFILE); unlink('pfrules.txt'); unlink('unipfrules.txt');