#!/usr/bin/perl # adtr v1.00 - This program pulls out Address Translation from Checkpoints # Firewall-1's objects.C file then outputs to a HTML file # # Copyright (C) 1999 Jon Erickson # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ex. USAGE "./adtr.pl /etc/fw/conf/objects.C outfile.html" # # open(FILE, "$ARGV[0]") || usage(); @indata = ; close(FILE); if ($ARGV[1] eq "") { $outfilename = "fwadtr.html"; } else { $outfilename = $ARGV[1]; } open(OUTFILE, ">>$outfilename"); print OUTFILE ""; close(OUTFILE); $RULES = 0; $FLAGSERVER = 0; $VALID_IP = "TEST"; foreach $i (@indata) { if ($FLAGSERVER != 1) { $server_name = grep /: \(/,$i; if ($server_name == 1) { # print "$i"; $SERVER_NAME = $i; $FLAGSERVER = 1; $IPADDR = 0; # $TR = 0; } } $ipaddr = grep /:ipaddr/,$i; if ($ipaddr == 1) { # print "$i"; $IPADDRESS = $i; $IPADDR = 1; $FLAGSERVER = 0; } $addrule = grep /:add_adtr_rule \(true\)/,$i; if ($addrule == 1) { # print "$i"; $RULE = $i; # $TR = 1; $RULES = 1; } #} #if ($TR == 1) { $adtr_method = grep /:netobj_adtr_method/,$i; if ($adtr_method == 1) { $METHOD = $i; $FLAGSERVER = 0; $IPADDR = 0; #$TR = 1; } $valid = grep /:valid_ipaddr/,$i; if ($valid == 1) { # print "$i"; $VALID_IP = $i; $TR = 1; $TEMP2 =1; } if ($TR == 1) { ($c1,$c2,$c3) = split(/\s+/,$SERVER_NAME); ($d1,$d2,$d3) = split(/\s+/,$IPADDRESS); ($e1,$e2,$e3) = split(/\s+/,$RULE); ($f1,$f2,$f3) = split(/\s+/,$VALID_IP); ($g1,$g2,$g3) = split(/\s+/,$METHOD); ($cs1,$cs2) = split(/\(/,$c3); $me = grep /static/, $g3; if ($me == 1) { $g3 = "Static" } else { $g3 = "Hide" } $TEST = grep /true/,$e3; if ($TEST == 1) { open(OUTFILE, ">>$outfilename"); print OUTFILE "\n"; close(OUFILE); } $TR = 0; $RULES = 0; $FLAG_SERVER=0; $TEMP2 =0; $SERVER_NAME=""; $IPADDRESS=""; $RULE=""; $VALID_IP=""; $METHOD=""; } } open(OUTFILE, ">>$outfilename"); print OUTFILE "
Server NameIP AddressValid IP AddressMethod
$cs2$d3$f3$g3
\n"; close(OUTFILE); sub usage { print "adtr v1.00 Copyright (C) 1999, Jon Erickson\n"; print "USAGE: ./adtr.pl filename\n\n"; }