| Server IP : 23.94.149.180 / Your IP : 216.73.216.147 Web Server : nginx/1.20.1 System : Linux deadrock 5.14.0-741.22.1.el9_9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 12 15:18:14 UTC 2026 x86_64 User : nginx ( 991) PHP Version : 8.6.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /files/www/hacklab/phpfwgen/ |
Upload File : |
<?php
#############################################################################
#
# $Id: files.inc,v 1.6 2000/04/14 06:57:57 delson Exp $
#
# Read in all definitions.
#
#############################################################################
function check_files() {
global $CONF;
if (! is_dir($CONF)) {
print "<FONT COLOR=\"#FF0000\">";
print "Warning! The directory $CONF does not exist on this system.";
mkdir($CONF, 0755);
if (! is_dir($CONF)) {
print "The directory $CONF could not be created. Check the file";
print "system permissions, and try again.";
print "</FONT><P>\n";
} else {
print "It was created successfully, but the default network objects";
print "and rules will not exist.";
print "</FONT><P>\n";
}
}
if (! file_exists("/sbin/ipchains") ) {
print "<FONT COLOR=\"#FF0000\">";
print "Warning! /sbin/ipchains is not installed on this system. The ";
print "firewall script will not work without it. You should install the ";
print "ipchains package from your Linux distribution CD.";
print "</FONT><P>\n";
}
if (! file_exists("/usr/sbin/ipmasqadm") ) {
print "<FONT COLOR=\"#FF0000\">";
print "Warning! /usr/sbin/ipmasqadm is not installed on this system. ";
print "Port forwarding will not work without it. You should install the ";
print "ipmasqadm RPM from the RedHat/contrib FTP site.";
print "</FONT><P>\n";
}
}
function read_interfaces() {
global $CONF;
if (is_file("$CONF/interfaces")) {
$interfacesr = file("$CONF/interfaces");
} else {
$interfacesr[] = "lo";
}
return $interfacesr;
}
function read_protocols() {
$protocolr = file("/etc/protocols");
while ( list( $key, $val ) = each($protocolr) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$exploded = preg_split ("/[\s\/]+/", $val);
$protocols[$exploded[0]] = intval($exploded[1]);
$port = intval($exploded[1]);
}
ksort($protocols);
return $protocols;
}
function read_services() {
$servicer = file("/etc/services");
# Stuff at the top ...
$services["HIPORTS/udp"] = "1024:65535";
$services["HIPORTS/tcp"] = "1024:65535";
while ( list($key,$val ) = each($servicer) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$exploded = preg_split ("/[\s\/]+/", $val);
$service = $exploded[0];
$port = intval($exploded[1]);
$proto = $exploded[2];
$services["$service/$proto"] = $port;
}
#
# Add the ICMP types
#
$icmpp = popen("/sbin/ipchains -h icmp", "r");
# Discard first 3 lines of header
$buffer = fgets($icmpp, 255);
$buffer = fgets($icmpp, 255);
$buffer = fgets($icmpp, 255);
# Slurp the rest in
while (!feof($icmpp)) {
$buffer = trim(fgets($icmpp, 255));
$buffer = ereg_replace(" .*$","",$buffer);
if (empty($buffer)) continue;
$services["$buffer/icmp"] = "ICMP";
}
$term = pclose($icmpp);
ksort($services);
return $services;
}
function read_objects() {
global $CONF;
if (is_file("$CONF/netobjects")) {
$netobjectr = file("$CONF/netobjects");
while ( list($key,$val ) = each($netobjectr) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$exploded = explode (" ", $val);
$netobjects[$exploded[0]] = "$exploded[1] $exploded[2] " . chop($exploded[3]);
}
} else {
$netobjects["LO"] = "127.0.0.0 255.0.0.0 NO";
}
return $netobjects;
}
function write_objects($netobjects) {
global $CONF;
$objfile = fopen ("$CONF/netobjects","w+");
reset($netobjects);
while ( list($key,$val) = each($netobjects) ) {
fwrite ($objfile, "$key $val\n");
}
fclose($objfile);
}
function read_rulesets() {
global $CONF;
if (is_file("$CONF/rulesets")) {
$ruler = file("$CONF/rulesets");
$rulekey = 100;
while ( list( $key, $val ) = each($ruler) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$rules[$rulekey] = chop($val);
$rulekey += 100;
}
} else {
$rules = array();
}
return $rules;
}
function write_rulesets($rules) {
global $CONF;
$rulefile = fopen ("$CONF/rulesets","w+");
reset($rules);
while ( list($key,$val) = each($rules) ) {
fwrite ($rulefile, "$val\n");
}
fclose ($rulefile);
}
function read_portfwds() {
global $CONF;
if (is_file("$CONF/portfwds")) {
$ruler = file("$CONF/portfwds");
$rulekey = 100;
while ( list($key,$val ) = each($ruler) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$rules[$rulekey] = chop($val);
$rulekey += 100;
}
} else {
$rules = array();
}
return $rules;
}
function write_portfwds($portfwds) {
global $CONF;
$rulefile = fopen ("$CONF/portfwds","w+");
reset($portfwds);
while ( list($key,$val) = each($portfwds) ) {
fwrite ($rulefile, "$val\n");
}
fclose ($rulefile);
}
function read_redirectors() {
global $CONF;
if (is_file("$CONF/redirectors")) {
$ruler = file("$CONF/redirectors");
$rulekey = 100;
while ( list($key,$val ) = each($ruler) ) {
#
# Skip blank lines and comments
#
if ( strlen($val) < 5 ) continue;
if ( substr($val, 0, 1) == "#" ) continue;
$rules[$rulekey] = chop($val);
$rulekey += 100;
}
} else {
$rules = array();
}
return $rules;
}
function write_redirectors($redirectors) {
global $CONF;
$rulefile = fopen ("$CONF/redirectors","w+");
reset($redirectors);
while ( list($key,$val) = each($redirectors) ) {
fwrite ($rulefile, "$val\n");
}
fclose ($rulefile);
}
?>