#!/bin/bash VERBOSE=1 #set key file locations banlist=./firewall.banned banlistfull=./firewall.banned.full natlist=./firewall.nat natlistfull=./firewall.nat.full lockfile=/var/lock/firewall initfile=/etc/init.d/basetables configfile=./basetablesconfig defaultconfing=./config.def interfaces=/etc/network/interfaces localrules=./firewall.local frontend=./basetables.frontend #Zenity frontend # #TODO: #Controls for default behavior with no firewall -- Defunct #Beginner Mode --CHECK #Intermediat Mode --CHECK #God Mode? -- Delayed #Offload to file --CHECK #Selection Persistance --CHECK #Cancel buttons should cancel the script! -- CHECK #Port Forwarding Configurator -- CHECK #IP Blocking Configurator -- CHECK #Section Roundups # optional in advanced #Multiple n00b setups #Multiple profiles #Fix ip syntax checking -- CHECK #Remove Hard linked files -- CHECK #subnet supernet logic #Firewall on/off after config changes #n00b groupings #Profile Manager # # echo check function startread { #Introduction to script, purpose, and priming read of key values # # This area sets several key (used in iptables script) variables, they are: (in apprx order) # # VERBOSE # EXTERNAL_INTERFACE # DHCP # EXTERNAL_IP # BROADCAST_NET # EXTERNAL_NETWORK # MASQUERADING # VERBOSE=1 mode=`zenity --list --text="Select User Mode" --radiolist --width=600 --height=300 --column="" --column=$"Mode" --column=$"Description"\ TRUE $"Newbie" $"Let BaseTables do the work for you! Try Me First!"\ FALSE $"Intermediate" $"Set Some Options, Not Fully Implimented"\ FALSE $"Advanced" $"Set Advanced Options"\ FALSE $"Master of the Known Universe" $"Not Implimented Yet"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if [ "$mode" = "Newbie" ] then skip=3 elif [ "$mode" = "Intermediate" ] then skip=2 elif [ "$mode" = "Advanced" ] then skip=1 else skip=0 fi ## Cat out interfaces file, greping out the interfaces, then getting rid of any comments and loopback, then getting rid of the leftover auto ifaces=$(echo `cat $interfaces | grep auto | grep -v \# | grep -v lo$ | awk '{print $2}'`) counter=10 ##nasty zenity hack because well... it doesnt seem to set variables while running the progress bar counter=10 ( for iface in ${ifaces} do ping -W 1 -c 1 -I $iface www.google.com if [ $? -eq 0 ] then echo $iface > iface.guess fi echo $counter counter=`expr $counter + 15` done ) | zenity --progress \ --title="Detecting Network Interface" \ --text="Scanning all interfaces..." \ --autoclose \ --percentage=0 read bestguess < iface.guess [ ! $bestguess ] && bestguess=`echo $ifaces | awk '{print $1}'` ## Prompting user for external interface, awk and sed magic dirty but it works EXTERNAL_INTERFACE=$(zenity --entry --title="External Interface" --text="BaseTables has detected the following interfaces: $ifaces. Which of them is your external (internet) interface? Note: If your interfaces is not listed, just type it in." --entry-text=$bestguess) ##Check for DHCP if [ $skip -lt 3 ] then DHCPCHECK=`zenity --list --radiolist --width=500 --column="" --column=$"DHCP" --column=$"Description"\ TRUE $"On" $"Your external interface uses DHCP to get an address"\ FALSE $"Off" $"Your external interface has a static IP" ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $DHCPCHECK | grep "Off" then DHCP=0 else DHCP=1 fi else DHCP=1 fi if [ $DHCP -eq 0 ] then ## Grabbing IP of external interface EXTERNAL_IPGUESS=`ifconfig $EXTERNAL_INTERFACE | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'` ## Asking user if guessed IP is correct (should be, might remove later if success rate is 100 EXTERNAL_IP=`zenity --entry --title="External IP" --text="BaseTables has attempted to detect your external IP. If it is assigned by DHCP you may safely ignore this" --entry-text=$EXTERNAL_IPGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing Broadcast address BROADCAST_NETGUESS=`ifconfig $EXTERNAL_INTERFACE | grep Bcast | awk '{print $3}' | awk -F: '{print $2}'` ## Confirming with user that guess is correct BROADCAST_NET=`zenity --entry --title="Broadcast Address" --text="BaseTables has attempted to detect your Bcast address. If it is assigned by DHCP you may safely ignore this" --entry-text=$BROADCAST_NETGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing subnet mask to aid in grabbing of Network Address SUBNET_MASKNET=`ifconfig wlan0 | grep Bcast | awk '{print $4}' | awk -F: '{print $2}'` if [ $SUBNET_MASKNET = 255.255.255.0 ] then SUBGOOD=1 elif [ $SUBNET_MASKNET = 255.255.0.0 ] then SUBGOOD=2 elif [ $SUBNET_MASKNET = 255.0.0.0 ] then SUBGOOD=3 else zenity --error --text="BaseTables could not guess your Network IP properly. This is the first IP in your subnet. This error should not occur, but the programmer who made this sucks. He intends to fix it... as soon as he gets smarter... You will have to manually enter this for now." fi ## Making the Network Address, provided the previous grab went ok, else we just prompt. if [ $SUBGOOD -eq 1 ] then ## Here we modify the external IP based upon the broadcast address EXTERNAL_NETWORKGUESS=`echo $EXTERNAL_IP | awk -F. '{print $1 "." $2 "." $3 "." 0}'` EXTERNAL_NETWORK=`zenity --entry --title="External Network" --text="BaseTables has attempted to detect your network address. If it is assigned by DHCP you may safely ignore this" --entry-text=$EXTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $SUBGOOD -eq 2 ] then EXTERNAL_NETWORKGUESS=`echo $EXTERNAL_IP | awk -F. '{print $1 "." $2 "." 0 "." 0}'` EXTERNAL_NETWORK=`zenity --entry --title="External Network" --text="BaseTables has attempted to detect your network address. If it is assigned by DHCP you may safely ignore this" --entry-text=$EXTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $SUBGOOD -eq 3 ] then EXTERNAL_NETWORKGUESS=`echo $EXTERNAL_IP | awk -F. '{print $1 "." 0 "." 0 "." 0}'` EXTERNAL_NETWORK=`zenity --entry --title="External Network" --text="BaseTables has attempted to detect your network address. If it is assigned by DHCP you may safely ignore this" --entry-text=$EXTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi else EXTERNAL_NETWORK=`zenity --entry --title="External Network" --text="BaseTables was unable to detect your network address. If it is assigned by DHCP you may safely ignore this" --entry-text=$EXTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi fi else # Declaring variables (probably not needed) EXTERNAL_IP="" EXTERNAL_NETWORK="" BROADCAST_NET="" fi if [ $skip -lt 3 ] then zenity --info --text="BaseTables is capable of configuring NAT, a method of sharing one internet connection across many comptuers. You will now be presented with the option to configure this service." MASQRES=`zenity --list --radiolist --width=600 --height=300 --column="" --column=$"Value" --column=$"Description"\ FALSE $"On" $"Clients connected to the internal network can access the internet"\ TRUE $"Off" $"Clients connected to the internal network cannot access the internet" ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $MASQRES | grep "On" then MASQUERADING=1 nat else MASQUERADING=0 fi else MASQUERADING=0 fi ##ROUNDUP## #skip if in n00blerland if [ $skip -lt 3 ] then # EXTERNAL_INTERFACE DHCP EXTERNAL_IP BROADCAST_NET EXTERNAL_NETWORK MASQUERADING if [ $DHCP -eq 1 ] then ROUNDDHCP=Yes else ROUNDDHCP=No fi if [ $MASQUERADING -eq 1 ] then ROUNDNAT=Enabled else ROUNDNAT=Disabled fi zenity --question --title="Base Configuration Roundup" --width=600 --text="You have made the following selections: External Interface: $EXTERNAL_INTERFACE DHCP Used?: $ROUNDDHCP ~~NOTE~~ If DHCP is used, External IP and Broadcast Address do not matter External IP: $EXTERNAL_IP Broadcast Address: $BROADCAST_NET NAT (Internet Sharing): $ROUNDNAT You may press ok to continue, or cancel to restart this section." if [ $? -eq 1 ] then startread fi fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function nat { ##this whole section frustrated me to no end... at several points I wanted to use for loops and had issues with them. I need someone smarter than me. # # This area sets all variables related to NAT, below you will find key variables # # INTERNAL_INTERFACE # INTERNAL_IP # INTERNAL_NETWORK # INTERNAL_INTERFACE1 # INTERNAL_IP1 # INTERNAL_NETWORK1 # # WANRING!!! The scheme here is not correct. Need to change Variables to INTERNAL_INTERFACE2 etc... MSQifaces=`echo $ifaces | sed -e "s/$EXTERNAL_INTERFACE//"` ## Figuring out remaining ifaces MSQnmbr=`echo $MSQifaces | wc -w` ##Counting so proper number of options might be displayed if [ $MSQnmbr -eq 0 ] then zenity --info --text="You do not seem to have an extra interface for configuration" elif [ $MSQnmbr -eq 1 ] then MASQUERADERESULTS=`zenity --list --checklist --width=500 --column="" --column=$"Value" --column=$"Description"\ TRUE $"$MSQifaces" $"Select to masquerade this interface"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $MSQnmbr -eq 2 ] then MSQifaces1=`echo $MSQifaces | awk '{print $1}'` MSQifaces2=`echo $MSQifaces | awk '{print $2}'` MASQUERADERESULTS=`zenity --list --checklist --width=500 --column="" --column=$"Value" --column=$"Description"\ TRUE $"$MSQifaces1" $"Select to masquerade this interface"\ FLASE $"$MSQifaces2" $"Select to masquerade this interface"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $MSQnmbr -eq 3 ] ## If you have 3 adapters presents a warning then zenity --info --text="It appears you have 3 or more interfaces, you may only select 2 of them for NAT. If you select more than 2, only 2 will be configured. This is not a limitation of iptables but of this script. I might fix it one day if I can figure out how to get it to play nice with what I want to do." MSQifaces1=`echo $MSQifaces | awk '{print $1}'` MSQifaces2=`echo $MSQifaces | awk '{print $2}'` MSQifaces3=`echo $MSQifaces | awk '{print $3}'` MASQUERADERESULTS=`zenity --list --checklist --width=500 --column="" --column=$"Value" --column=$"Description"\ TRUE $"$MSQifaces1" $"Select to masquerade this interface"\ FLASE $"$MSQifaces2" $"Select to masquerade this interface"\ FLASE $"$MSQifaces3" $"Select to masquerade this interface"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi else zenity --info --text="It appears you have a HUGE number of network adapters (or lots of virtual ones). Check back later when we figure out how to weed those out. A manual override will be added sooner or later (note to self... override)." fi if [ `echo $MASQUERADERESULTS | sed 's/|/ /g' | wc -w` -eq 2 ] ## checks to see if 2 results were returned then DOUBLEMASQ=1 ##used to enable second interface in iptables script INTERNAL_INTERFACE=`echo $MASQUERADERESULTS | awk -F"|" '{print $1}'` INTERNAL_INTERFACE1=`echo $MASQUERADERESULTS | awk -F"|" '{print $2}'` elif [ `echo $MASQUERADERESULTS | sed 's/|/ /g' | wc -w` -eq 1 ] ## checks to see if 2 results were returned then INTERNAL_INTERFACE=`echo $MASQUERADERESULTS | awk -F"|" '{print $1}'` #gets rid of any extra spaces elif [ `echo $MASQUERADERESULTS | sed 's/|/ /g' | wc -w` -eq 0 -o `echo $MASQUERADERESULTS | sed 's/|/ /g' | wc -w` -gt 2 ] then masqretry=`zenity --question --text="You did not select any interfaces or you selected too many interfaces, press OK to continue with NAT disabled or cancel to start configuring NAT again"` if [ $? -ne 0 ] then nat #calls the whole thing over if you screwed up else MASQUERADE=0 ##Disables NAT fi else zenity --error --text="A serious error has occured. No changes have been made to your system, but BaseTables cannot continue" exit 1 fi ##We have FINALLY gotten our interfaces for NAT declared, now we need to configure them. God help us. ##INTERFACE 1 ## Grabbing IP of external interface INTERNAL_IPGUESS=`ifconfig $INTERNAL_INTERFACE | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'` ## Asking user if guessed IP is correct (should be, might remove later if success rate is 100 INTERNAL_IP=`zenity --entry --title="External IP" --text="BaseTables has attempted to detect your external IP." --entry-text=$INTERNAL_IPGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing Broadcast address INTBROADCAST_NETGUESS=`ifconfig $INTERNAL_INTERFACE | grep Bcast | awk '{print $3}' | awk -F: '{print $2}'` ## Confirming with user that guess is correct INTBROADCAST_NET=`zenity --entry --title="Broadcast Address" --text="BaseTables has attempted to detect your Bcast address." --entry-text=$INTBROADCAST_NETGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing subnet mask to aid in grabbing of Network Address INTSUBNET_MASKNET=`ifconfig wlan0 | grep Bcast | awk '{print $4}' | awk -F: '{print $2}'` if [ $INTSUBNET_MASKNET = 255.255.255.0 ] then SUBGOOD=1 elif [ $INTSUBNET_MASKNET = 255.255.0.0 ] then SUBGOOD=2 elif [ $INTSUBNET_MASKNET = 255.0.0.0 ] then SUBGOOD=3 else zenity --error --text="BaseTables could not guess your Network IP properly. This is the first IP in your subnet. This error should not occur, but the programmer who made this sucks. He intends to fix it... as soon as he gets smarter... You will have to manually enter this for now." SUBGOOD=25 ##making sure previous run doesnt mess us up here, who doesnt know how to properly use functions!? I DONT! So I should actually make BOTH these functions later... for now I just want it get it working. fi ## Making the Network Address, provided the previous grab went ok, else we just prompt. if [ $SUBGOOD -eq 1 ] then ## Here we modify the external IP based upon the broadcast address INTERNAL_NETWORKGUESS=`echo $INTERNAL_IP | awk -F. '{print $1 "." $2 "." $3 "." "0/24"}'` INTERNAL_NETWORK=`zenity --entry --title="Internal Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $SUBGOOD -eq 2 ] then INTERNAL_NETWORKGUESS=`echo $INTERNAL_IP | awk -F. '{print $1 "." $2 "." 0 "." "0/16"}'` INTERNAL_NETWORK=`zenity --entry --title="Internal Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $SUBGOOD -eq 3 ] then INTERNAL_NETWORKGUESS=`echo $INTERNAL_IP | awk -F. '{print $1 "." 0 "." 0 "." "0/8"}'` INTERNAL_NETWORK=`zenity --entry --title="External Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi else INTERNAL_NETWORK=`zenity --entry --title="Internal Network" --text="BaseTables was unable to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi fi ##Interface 2 if [ $DOUBLEMASQ -eq 1 ] then ## Grabbing IP of external interface INTERNAL_IPGUESS1=`ifconfig $INTERNAL_INTERFACE1 | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'` ## Asking user if guessed IP is correct (should be, might remove later if success rate is 100 INTERNAL_IP1=`zenity --entry --title="Internal IP 2" --text="BaseTables has attempted to detect your external IP." --entry-text=$INTERNAL_IPGUESS1` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing Broadcast address INTBROADCAST_NETGUESS1=`ifconfig $INTERNAL_INTERFACE1 | grep Bcast | awk '{print $3}' | awk -F: '{print $2}'` ## Confirming with user that guess is correct INTBROADCAST_NET1=`zenity --entry --title="Broadcast Address" --text="BaseTables has attempted to detect your Bcast address." --entry-text=$INTBROADCAST_NETGUESS1` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi ## Grabbing subnet mask to aid in grabbing of Network Address INTSUBNET_MASKNET1=`ifconfig wlan0 | grep Bcast | awk '{print $4}' | awk -F: '{print $2}'` if [ $INTSUBNET_MASKNET1 = 255.255.255.0 ] then SUBGOOD=1 elif [ $INTSUBNET_MASKNET1 = 255.255.0.0 ] then SUBGOOD=2 elif [ $INTSUBNET_MASKNET1 = 255.0.0.0 ] then SUBGOOD=3 else zenity --error --text="BaseTables could not guess your Network IP properly. This is the first IP in your subnet. This error should not occur, but the programmer who made this sucks. He intends to fix it... as soon as he gets smarter... You will have to manually enter this for now." SUBGOOD=25 ##making sure previous run doesnt mess us up here, who doesnt know how to properly use functions!? I DONT! So I should actually make BOTH these functions later... for now I just want it get it working. fi ## Making the Network Address, provided the previous grab went ok, else we just prompt. if [ $SUBGOOD -eq 1 ] then ## Here we modify the external IP based upon the broadcast address INTERNAL_NETWORKGUESS1=`echo $INTERNAL_IP1 | awk -F. '{print $1 "." $2 "." $3 "." "0/24"}'` INTERNAL_NETWORK1=`zenity --entry --title="Internal Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS1` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi elif [ $SUBGOOD -eq 2 ] then INTERNAL_NETWORKGUESS1=`echo $INTERNAL_IP1 | awk -F. '{print $1 "." $2 "." 0 "." "0/16"}'` INTERNAL_NETWORK1=`zenity --entry --title="Internal Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS1` elif [ $SUBGOOD -eq 3 ] then INTERNAL_NETWORKGUESS1=`echo $INTERNAL_IP1 | awk -F. '{print $1 "." 0 "." 0 "." "0/8"}'` INTERNAL_NETWORK1=`zenity --entry --title="Internal Network" --text="BaseTables has attempted to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi else INTERNAL_NETWORK1=`zenity --entry --title="Internal Network" --text="BaseTables was unable to detect your network address." --entry-text=$INTERNAL_NETWORKGUESS` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi fi fi ###sloppy hack, just like the rest of this INTERNAL_NETWORK2=$INTERNAL_NETWORK1 INTERNAL_IP2=$INTERNAL_IP1 INTERNAL_INTERFACE2=$INTERNAL_INTERFACE1 } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function globalconfig { ## area for setting global options # # The Following options will be set in here # # DHCP_SERVER_IP # SMTP_SERVER # POP_SERVER # POP3S_SERVER # MY_IMAP_SERVER # MY_IMAPS_SERVER # NEWS_SERVER # SNEWS_SERVER # MY_NEWS_FEED # # ##PROXY OPTIONS## These are untested, but should work. Proxy has to be flipped on for these to matter # WEB_PROXY_SERVER # WEB_PROXY_PORT # # if [ $skip -lt 2 ] then zenity --info --text="You are about to go through the global configuration of your firewall. It is perfectly ok to accept the default response on all of the following questions. They are only provided if you wish to really narrow things down security wise." DHCP_SERVER_IP=`zenity --entry --title="DHCP Server IP" --text="Enter IP of DHCP server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi SMTP_SERVER=`zenity --entry --title="SMTP Server IP" --text="Enter IP of your SMTP server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi POP_SERVER=`zenity --entry --title="POP Server IP" --text="Enter IP of your POP server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi POP3S_SERVERS=`zenity --entry --title="POP3S Server IP" --text="Enter IP of your POP3S server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi MY_IMAP_SERVER=`zenity --entry --title="IMAP Server IP" --text="Enter IP of your IMAP server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi MY_IMAPS_SERVER=`zenity --entry --title="IMAPS Server IP" --text="Enter IP of your IMAPS server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi NEWS_SERVER=`zenity --entry --title="NNTP News Server IP" --text="Enter IP of your NNTP News server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi SNEWS_SERVER=`zenity --entry --title="Secure NNTP News Server IP" --text="Enter IP of your Secure NNTP News server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi MY_NEWS_FEED=`zenity --entry --title="NNTP News Feeds Server IP" --text="Enter IP of your NNTP News Feeds server:" --entry-text=any/0` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi PROXYCHECK=`zenity --list --radiolist --width=500 --column="" --column=$"Proxy" --column=$"Description"\ FALSE $"On" $"Your external interface uses a proxy"\ TRUE $"Off" $"Your external interface does not use a proxy" ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $PROXYCHECK | grep "On" then HTTP_PROXY=1 WEB_PROXY_SERVER=`zenity --entry --title="Proxy Server Domain" --text="Enter location of your proxy server:" --entry-text=ENTER IP HERE` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi WEB_PROXY_PORT=`zenity --entry --title="Proxy Server Port" --text="Enter port for your proxy server:" --entry-text=8008` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi else HTTP_PROXY=0 fi else advperm DHCP_SERVER_IP DHCP_SERVER_IP="$finalperm" advperm SMTP_SERVER SMTP_SERVER="$finalperm" advperm POP_SERVER POP_SERVER="$finalperm" advperm POP3S_SERVERS POP3S_SERVERS="$finalperm" advperm MY_IMAP_SERVER MY_IMAP_SERVER="$finalperm" advperm MY_IMAPS_SERVER MY_IMAPS_SERVER="$finalperm" advperm NEWS_SERVER NEWS_SERVER="$finalperm" advperm SNEWS_SERVER SNEWS_SERVER="$finalperm" advperm MY_NEWS_FEED MY_NEWS_FEED="$finalperm" fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function selectorsecurity { if [ $skip -lt 2 ] then #Choose rules, for now, default are hardcoded, should be changed!!! # Relevant Variables # # PORT_FORWARD # OUTBOUND_PING # INBOUND_PING # OUTBOUND_TRACEROUTE # INBOUND_TRACEROUTE # # RESULTSEC=`zenity --list --checklist --width=600 --height=800 --title "Beta BaseTables Script" \ --column="" --column $"Rules" --column $"Description" \ $PORT_FORWARD_TF $"Port Forwarding" $"Enable Port Forwarding to local clients"\ $OUTBOUND_PING_TF $"Outbound Ping" $"Allow local network to ping external networks"\ $INBOUND_PING_TF $"Inbound Ping" $"Allows external sites to ping firewall"\ $OUTBOUND_TRACEROUTE_TF $"Outbound Traceroute" $"Allows internal network(s) to traceroute external networks"\ $INBOUND_TRACEROUTE_TF $"Inbound Traceroute" $"Allows external networks to traceroute up to the firewall"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $RESULTSEC | grep "Port Forwarding" then if [ -f $natlist ] then PORT_FORWARD=1 else zenity --info --title="Forwarding File Not Found" --text="Port Forwarding requires a file in $natlist" PORT_FORWARD=0 fi else PORT_FORWARD=0 fi if echo $RESULTSEC | grep "Outbound Ping" then OUTBOUND_PING=1 else OUTBOUND_PING=0 fi if echo $RESULTSEC | grep "Inbound Ping" then INBOUND_PING=1 else INBOUNT_PING=0 fi if echo $RESULTSEC | grep "Outbound Traceroute" then OUTBOUND_TRACEROUTE=1 else OUTBOUND_TRACEROUTE=0 fi if echo $RESULTSEC | grep "Inbound Traceroute" then INBOUND_TRACEROUTE=1 else INBOUND_TRACEROUTE=0 fi else OUTBOUND_PING=1 INBOUND_PING=1 OUTBOUND_TRACEROUTE=1 INBOUND_TRACEROUTE=1 fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function selectorclient { #Choose rules, for now, default are hardcoded, should be changed!!! # LOTS of variables set here... LOTS LOTS LOTS #SMTP_REMOTE_SERVER #POP3_CLIENT #IMAP_CLIENT #IMAPS_CLIENT #SMTP_LOCAL_SERVER #AUTH_CLIENT #DNS_CLIENT #FINGER_CLIENT #FTP_CLIENT #GOPHER_CLIENT #HTTP_CLIENT #HTTPS_CLIENT #HTTP_PROXY #NNTP_CLIENT #NNTPS_CLIENT #NTP_CLIENT #SSH_CLIENT #TELNET_CLIENT #WAIS_CLIENT #WHOIS_CLIENT #ICQ_CLIENT #RV_CLIENT #PPTP_CLIENT #SAMBA_CLIENT RESULTCLIENT=`zenity --list --checklist --width=600 --height=800 --title "Beta BaseTables Script" \ --column="" --column $"Rules" --column $"Description" \ $SMTP_REMOTE_SERVER_TF $"SMTP Remote Server" $"Check if you send email via SMTP (like thunderbird or evolution)"\ $POP3_CLIENT_TF $"POP3 Client" $"Check if you receive your email via POP3 or POP3S"\ $IMAP_CLIENT_TF $"IMAP Client" $"Check if you receive email via IMAP"\ $IMAPS_CLIENT_TF $"IMAPS Client" $"Check if you receive email via a secure IMAP server"\ $SMTP_LOCAL_SERVER_TF $"SMTP Local Server" $"Check this if you are running Sendmail or Postfix for clients on your LOCAL network"\ $AUTH_CLIENT_TF $"Auth Protocol" $"Allow internal clients to access auth protocol"\ $DNS_CLIENT_TF $"DNS Client" $"Allow internal clients access to DNS"\ $FINGER_CLIENT_TF $"Finger Client" $"Allow internal clients access to finger protocol"\ $FTP_CLIENT_TF $"FTP Client" $"Allow internal clients access to FTP"\ $GOPHER_CLIENT_TF $"Gopher Client" $"Allow internal clients access to the gopher protocol"\ $HTTP_CLIENT_TF $"HTTP Client" $"Allow internal clients web access"\ $HTTPS_CLIENT_TF $"HTTPS Client" $"Allow internal clients secure web access"\ $NNTP_CLIENT_TF $"NNTP Client" $"Allow internal clients access to usenet"\ $NNTPS_CLIENT_TF $"NNTPS Client" $"Allow internal clients access to usenet over SSL"\ $NTP_CLIENT_TF $"NTP Client" $"Allow internal clients access to Network Time Protocol"\ $SSH_CLIENT_TF $"SSH Client" $"Allow internal clients access to SSH servers"\ $TELNET_CLIENT_TF $"Telnet Client" $"Allow internal clients access to Telnet"\ $WAIS_CLIENT_TF $"WAIS Client" $"Allow internal clients access to the WAIS protocol"\ $WHOIS_CLIENT_TF $"WHOIS Client" $"Allow internal clients access to the WHOIS protocol"\ $ICQ_CLIENT_TF $"ICQ Client" $"Allow internal clients access to ICQ"\ $RV_CLIENT_TF $"Real Video" $"Allow internal clients access to port 554"\ $PPTP_CLIENT_TF $"PPTP Client" $"Allow internal clients to access PPTP servers"\ $SAMBA_CLIENT_TF $"Samba Client" $"Allow internal clients access to SAMBA servers"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $RESULTCLIENT | grep "SMTP Remote Server" then SMTP_REMOTE_SERVER=1 else SMTP_REMOTE_SERVER=0 fi if echo $RESULTCLIENT | grep "POP3 Client" then POP3_CLIENT=1 else POP3_CLIENT=0 fi if echo $RESULTCLIENT | grep "IMAP Client" then IMAP_CLIENT=1 else IMAP_CLIENT=0 fi if echo $RESULTCLIENT | grep "IMAPS Client" then IMAPS_CLIENT=1 else IMAPS_CLIENT=0 fi if echo $RESULTCLIENT | grep "SMTP Local Server" then SMTP_LOCAL_SERVER=1 else SMTP_LOCAL_SERVER=0 fi if echo $RESULTCLIENT | grep "Auth Protocol" then AUTH_CLIENT=1 else AUTH_CLIENT=0 fi if echo $RESULTCLIENT | grep "DNS Client" then DNS_CLIENT=1 else DNS_CLIENT=0 fi if echo $RESULTCLIENT | grep "Finger Client" then FINGER_CLIENT=1 else FINGER_CLIENT=0 fi if echo $RESULTCLIENT | grep "FTP Client" then FTP_CLIENT=1 else FTP_CLIENT=0 fi if echo $RESULTCLIENT | grep "Gopher Client" then GOPHER_CLIENT=1 else GOPHER_CLIENT=0 fi if echo $RESULTCLIENT | grep "HTTP Client" then HTTP_CLIENT=1 else HTTP_CLIENT=0 fi # if echo $RESULTCLIENT | grep "HTTP Proxy" # then # HTTP_PROXY=1 # else # HTTP_PROXY=0 # fi if echo $RESULTCLIENT | grep "HTTPS Client" then HTTPS_CLIENT=1 else HTTPS_CLIENT=0 fi if echo $RESULTCLIENT | grep "NNTP Client" then NNTP_CLIENT=1 else NNTP_CLIENT=0 fi if echo $RESULTCLIENT | grep "NNTPS Client" then NNTPS_CLIENT=1 else NNTPS_CLIENT=0 fi if echo $RESULTCLIENT | grep "NTP Client" then NTP_CLIENT=1 else NTP_CLIENT=0 fi if echo $RESULTCLIENT | grep "SSH Client" then SSH_CLIENT=1 else SSH_CLIENT=0 fi if echo $RESULTCLIENT | grep "Telnet Client" then TELNET_CLIENT=1 else TELNET_CLIENT=0 fi if echo $RESULTCLIENT | grep "WAIS Client" then WAIS_CLIENT=1 else WAIS_CLIENT=0 fi if echo $RESULTCLIENT | grep "WHOIS Client" then WHOIS_CLIENT=1 else WHOIS_CLIENT=0 fi if echo $RESULTCLIENT | grep "ICQ Client" then ICQ_CLIENT=1 else ICQ_CLIENT=0 fi if echo $RESULTCLIENT | grep "Real Video" then RV_CLIENT=1 else RV_CLIENT=0 fi if echo $RESULTCLIENT | grep "PPTP Client" then PPTP_CLIENT=1 else PPTP_CLIENT=0 fi if echo $RESULTCLIENT | grep "Samba Client" then SAMBA_CLIENT=1 else SAMBA_CLIENT=0 fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function selectorserver { # Relevant Variables #DHCP_SERVER #FTP_SERVER #MY_FTP_CLIENTS # #DNS_CACHING_SERVER #DNS_FULL_SERVER # #AUTH_SERVER # #POP3_SERVER #MY_POP3_CLIENTS #POP3S_SERVER #MY_POP3S_CLIENTS # #IMAP_SERVER #MY_IMAP_CLIENTS #IMAPS_SERVER #MY_IMAPS_CLIENTS # #NNTP_SERVER #MY_NNTP_CLIENTS #NNTP_NEWS_FEED # #TELNET_SERVER #MY_TELNET_CLIENTS # #SSH_SERVER #MY_SSH_CLIENTS #SSH_PORT # #HTTP_SERVER #MY_HTTP_CLIENTS #HTTPS_SERVER #MY_HTTPS_CLIENTS # #FINGER_SERVER #MY_FINGER_CLIENTS # #SAMBA_SERVER #MY_SAMBA_CLIENTS # if [ $skip -lt 3 ] then RESULTSERV=`zenity --list --checklist --width=600 --height=600 --title "Beta BaseTables Script" \ --column="" --column $"Rules" --column $"Description" \ $DHCP_SERVER_TF $"DHCP Server" $"Check this box of your computer is running dhcpd"\ $FTP_SERVER_TF $"FTP Server" $"Check if you are running an FTP server"\ $DNS_CACHING_SERVER_TF $"DNS Caching Server" $"Check if you are running a caching only DNS server"\ $DNS_FULL_SERVER_TF $"DNS Full Server" $"Check if you have a full DNS server"\ $AUTH_SERVER_TF $"Auth Server" $"Check for Auth Protocol Servers"\ $POP3_SERVER_TF $"POP3 Server" $"Check if you are running a POP3 Server"\ $POP3S_SERVER_TF $"POP3S Server" $"Chcek if you are running a secure POP3 Server"\ $IMAP_SERVER_TF $"IMAP Server" $"Check if you are running an IMAP server"\ $IMAPS_SERVER_TF $"IMAPS Server" $"Check if you are running a secure IMAP server"\ $NNTP_SERVER_TF $"NNTP Server" $"Check if you are running an usenet news server"\ $NNTP_NEWS_FEED_TF $"NNTP News Feeds" $"Check if you have NNTP news feeds"\ $TELNET_SERVER_TF $"Telnet Server" $"Check if you are running a telnet server. Consider switching to SSH"\ $SSH_SERVER_TF $"SSH Server" $"Check if you are running an SSH Server"\ $HTTP_SERVER_TF $"HTTP Server" $"Check if you are running a web server"\ $HTTPS_SERVER_TF $"HTTPS Server" $"Check if you are running a web server with SSL"\ $FINGER_SERVER_TF $"Finger Server" $"Check if you are running a finger server"\ $SAMBA_SERVER_TF $"Samba Server" $"Check if you are running a Samba Server"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $RESULTSERV | grep "DHCP Server" then DHCP_SERVER=1 else DHCP_SERVER=0 fi if echo $RESULTSERV | grep "FTP Server" then FTP_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="FTP Server Configuration" --text="You have selected an FTP Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_FTP_CLIENTS=$range else advperm MY_FTP_CLIENTS MY_FTP_CLIENTS="$finalperm" fi else FTP_SERVER=0 fi if echo $RESULTSERV | grep "DNS Caching Server" then DNS_CACHING_SERVER=1 else DNS_CACHING_SERVER=0 fi if echo $RESULTSERV | grep "DNS Full Server" then DNS_FULL_SERVER=1 else DNS_FULL_SERVER=0 fi if echo $RESULTSERV | grep "Auth Server" then AUTH_SERVER=1 else AUTH_SERVER=0 fi if echo $RESULTSERV | grep "POP3 Server" then POP3_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="POP3 Server Configuration" --text="You have selected a POP3 Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_POP3_CLIENTS=$range else advperm MY_POP3_CLIENTS MY_POP3_CLIENTS=$finalperm fi else POP3_SERVER=0 fi if echo $RESULTSERV | grep "POP3S Server" then POP3S_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="POP3S Server Configuration" --text="You have selected a POP3S Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_POP3S_CLIENTS=$range else advperm MY_POP3S_CLIENTS MY_POP3S_CLIENTS=$finalperm fi else POP3S_SERVER=0 fi if echo $RESULTSERV | grep "IMAP Server" then IMAP_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="IMAP Server Configuration" --text="You have selected a IMAP Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_IMAP_CLIENTS=$range else advperm MY_IMAP_CLIENTS MY_IMAP_CLIENTS=$finalperm fi else IMAP_SERVER=0 fi if echo $RESULTSERV | grep "IMAPS Server" then IMAPS_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="IMAPS Server Configuration" --text="You have selected a IMAPS Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_IMAPS_CLIENTS=$range else advperm MY_IMAPS_CLIENTS MY_IMAPS_CLIENTS=$finalperm fi else IMAPS_SERVER=0 fi if echo $RESULTSERV | grep "NNTP Server" then NNTP_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="NNTP Server Configuration" --text="You have selected a NNTP Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_NNTP_CLIENTS=$range else advperm MY_NNTP_CLIENTS MY_NNTP_CLIENTS=$finalperm fi else NNTP_SERVER=0 fi if echo $RESULTSERV | grep "NNTP News Feeds" then NNTP_NEWS_FEED=1 else NNTP_NEWS_FEED=0 fi if echo $RESULTSERV | grep "Telnet Server" then TELNET_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="TELNET Server Configuration" --text="You have selected a TELNET Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_TELNET_CLIENTS=$range else advperm MY_TELNET_CLIENTS MY_TELNET_CLIENTS=$finalperm fi else TELNET_SERVER=0 fi if echo $RESULTSERV | grep "SSH Server" then SSH_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="SSH Server Configuration" --text="You have selected to have your firewall configured for an SSH server, you will be prompted for the range of clients you would like to have able to access this server. For all possible IP's, or if you are unsure, enter any/0." rangeread MY_SSH_CLIENTS=$range zenity --info --title="SSH Server Configuration" --text="If your server runs on a port other than port 22, please enter it here." SSH_PORT=`zenity --entry --title="Enter Port:" --entry-text="22" --text="Enter SSH Server Port"` else SSH_PORT=22 advperm MY_TELNET_CLIENTS MY_TELNET_CLIENTS=$finalperm fi else SSH_SERVER=0 fi if echo $RESULTSERV | grep "HTTP Server" then HTTP_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="HTTP Server Configuration" --text="You have selected a HTTP Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_HTTP_CLIENTS=$range else advperm MY_HTTP_CLIENTS MY_HTTP_CLIENTS=$finalperm fi else HTTP_SERVER=0 fi if echo $RESULTSERV | grep "HTTPS Server" then HTTPS_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="HTTPS Server Configuration" --text="You have selected a HTTPS Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_HTTPS_CLIENTS=$range else advperm MY_HTTPS_CLIENTS MY_HTTPS_CLIENTS=$finalperm fi else HTTPS_SERVER=0 fi if echo $RESULTSERV | grep "Finger Server" then FINGER_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="FINGER Server Configuration" --text="You have selected a FINGER Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_FINGER_CLIENTS=$range else advperm MY_FINGER_CLIENTS MY_FINGER_CLIENTS=$finalperm fi else FINGER_SERVER=0 fi if echo $RESULTSERV | grep "Samba Server" then SAMBA_SERVER=1 if [ $skip -lt 2 ] then zenity --info --title="SAMBA Server Configuration" --text="You have selected a SAMBA Server configuration, you need to enter the CIDR range of clients. Use any/0 for all, or if you are unsure." rangeread MY_SAMBA_CLIENTS=$range else advperm MY_SAMBA_CLIENTS MY_SAMBA_CLIENTS=$finalperm fi else SAMBA_SERVER=0 fi else #Hard coding needs to be changed to use config file for on off switches -- FIXED [ ! $FTP_SERVER ] && FTP_SERVER=0 MY_FTP_CLIENTS="any/0" [ ! $DNS_CACHING_SERVER ] && DNS_CACHING_SERVER=0 [ ! $DNS_FULL_SERVER ] && DNS_FULL_SERVER=0 [ ! $AUTH_SERVER ] && AUTH_SERVER=0 [ ! $POP3_SERVER ] && POP3_SERVER=0 MY_POP3_CLIENTS="any/0" [ ! $POP3S_SERVER ] && POP3S_SERVER=0 MY_POP3S_CLIENTS="any/0" [ ! $IMAP_SERVER ] && IMAP_SERVER=0 MY_IMAP_CLIENTS="any/0" [ ! $IMAPS_SERVER ] && IMAPS_SERVER=0 MY_IMAPS_CLIENTS="any/0" [ ! $NNTP_SERVER ] && NNTP_SERVER=0 MY_NNTP_CLIENTS="any/0" [ ! $NNTP_NEWS_FEED ] && NNTP_NEWS_FEED=0 [ ! $TELNET_SERVER ] && TELNET_SERVER=0 MY_TELNET_CLIENTS="any/0" [ ! $SSH_SERVER ] && SSH_SERVER=0 MY_SSH_CLIENTS="any/0" [ ! $SSH_PORT ] && SSH_PORT=22 [ ! $HTTP_SERVER ] && HTTP_SERVER=0 MY_HTTP_CLIENTS="any/0" [ ! $HTTPS_SERVER ] && HTTPS_SERVER=0 MY_HTTPS_CLIENTS="any/0" [ ! $FINGER_SERVER ] && FINGER_SERVER=0 MY_FINGER_CLIENTS="any/0" [ ! $SAMBA_SERVER ] && SAMBA_SERVER=0 MY_SAMBA_CLIENTS="any/0" fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check function selectorgames { # # HALF_LIFE # WOLF_CLIENT # if [ $skip -lt 3 ] then RESULTGAMES=`zenity --list --checklist --width=600 --height=300 --title "Beta BaseTables Script" \ --column="" --column $"Rules" --column $"Description" \ $HALF_LIFE_TF $"Half Life" $"Enable if you run a HL server"\ $WOLF_CLIENT_TF $"Wolfenstein" $"Check if your clients run return to castle wolfenstein"\ ` if [ $? -ne 0 ] #ok so its not the best idea... Will fix when code sees a re-write then $frontend & exit 35 fi if echo $RESULTGAMES | grep "Half Life" then HALF_LIFE=1 else HALF_LIFE=0 fi if echo $RESULTGAMES | grep "Wolfenstein" then WOLF_CLIENT=1 else WOLF_CLIENT=0 fi else [ ! $HALF_LIFE ] && HALF_LIFE=0 [ ! $WOLF_CLIENT ] && WOLF_CLIENT=0 fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function rangeread { if [ "$1" = "nodef" ] then range=`zenity --entry --title="IP Range Entry" --text="Enter IP or range of IP's. e.g. 192.168.0.14/32 for single IP, or 192.168.2.0/24 for an entire network. You may also enter a list seperated with spaces"` else range=`zenity --entry --entry-text="any/0"--title="IP Range Entry" --text="Enter IP or range of IP's. e.g. 192.168.0.14/32 for single IP, or 192.168.2.0/24 for an entire network. You may also enter a list seperated with spaces"` fi ipcheck $range if [ $ipgood -eq 0 ] then zenity --error --text="You have entered an invalid range, try again" rangeread fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function filemake { #Setting all unset variables to zero, probably can go now, but it just keeps thing in check in case something wonky (like pressing cancel) happens [ $PORT_FORWARD ] || PORT_FORWARD=0 [ $SMTP_REMOTE_SERVER ] || SMTP_REMOTE_SERVER=0 [ $POP3_CLIENT ] || POP3_CLIENT=0 [ $IMAP_CLIENT ] || IMAP_CLIENT=0 [ $IMAPS_CLIENT ] || IMAPS_CLIENT=0 [ $SMTP_LOCAL_SERVER ] || SMTP_LOCAL_SERVER=0 [ $AUTH_CLIENT ] || AUTH_CLIENT=0 [ $DNS_CLIENT ] || DNS_CLIENT=0 [ $FINGER_CLIENT ] || FINGER_CLIENT=0 [ $FTP_CLIENT ] || FTP_CLIENT=0 [ $GOPHER_CLIENT ] || GOPHER_CLIENT=0 [ $HTTP_CLIENT ] || HTTP_CLIENT=0 [ $HTTPS_CLIENT ] || HTTPS_CLIENT=0 [ $HTTP_PROXY ] || HTTP_PROXY=0 [ $NNTP_CLIENT ] || NNTP_CLIENT=0 [ $NNTPS_CLIENT ] || NNTPS_CLIENT=0 [ $NTP_CLIENT ] || NTP_CLIENT=0 [ $SSH_CLIENT ] || SSH_CLIENT=0 [ $TELNET_CLIENT ] || TELNET_CLIENT=0 [ $WAIS_CLIENT ] || WAIS_CLIENT=0 [ $WHOIS_CLIENT ] || WHOIS_CLIENT=0 [ $ICQ_CLIENT ] || ICQ_CLIENT=0 [ $RV_CLIENT ] || RV_CLIENT=0 [ $PPTP_CLIENT ] || PPTP_CLIENT=0 [ $SAMBA_CLIENT ] || SAMBA_CLIENT=0 [ $FTP_SERVER ] || FTP_SERVER=0 [ $MY_FTP_CLIENTS ] || MY_FTP_CLIENTS=0 [ $DNS_CACHING_SERVER ] || DNS_CACHING_SERVER=0 [ $DNS_FULL_SERVER ] || DNS_FULL_SERVER=0 [ $AUTH_SERVER ] || AUTH_SERVER=0 [ $POP3_SERVER ] || POP3_SERVER=0 [ $MY_POP3_CLIENTS ] || MY_POP3_CLIENTS=0 [ $POP3S_SERVER ] || POP3S_SERVER=0 [ $MY_POP3S_CLIENTS ] || MY_POP3S_CLIENTS=0 [ $IMAP_SERVER ] || IMAP_SERVER=0 [ $MY_IMAP_CLIENTS ] || MY_IMAP_CLIENTS=0 [ $IMAPS_SERVER ] || IMAPS_SERVER=0 [ $MY_IMAPS_CLIENTS ] || MY_IMAPS_CLIENTS=0 [ $NNTP_SERVER ] || NNTP_SERVER=0 [ $MY_NNTP_CLIENTS ] || MY_NNTP_CLIENTS=0 [ $NNTP_NEWS_FEED ] || NNTP_NEWS_FEED=0 [ $TELNET_SERVER ] || TELNET_SERVER=0 [ $MY_TELNET_CLIENTS ] || MY_TELNET_CLIENTS=0 [ $SSH_SERVER ] || SSH_SERVER=0 [ $MY_SSH_CLIENTS ] || MY_SSH_CLIENTS=0 [ $SSH_PORT ] || SSH_PORT=0 [ $HTTP_SERVER ] || HTTP_SERVER=0 [ $MY_HTTP_CLIENTS ] || MY_HTTP_CLIENTS=0 [ $HTTPS_SERVER ] || HTTPS_SERVER=0 [ $MY_HTTPS_CLIENTS ] || MY_HTTPS_CLIENTS=0 [ $FINGER_SERVER ] || FINGER_SERVER=0 [ $MY_FINGER_CLIENTS ] || MY_FINGER_CLIENTS=0 [ $SAMBA_SERVER ] || SAMBA_SERVER=0 [ $MY_SAMBA_CLIENTS ] || MY_SAMBA_CLIENTS=0 [ $HALF_LIFE ] || HALF_LIFE=0 [ $WOLF_CLIENT ] || WOLF_CLIENT=0 #Generating config file echo "VERBOSE=\"$VERBOSE\"" > $configfile echo "EXTERNAL_INTERFACE=\"$EXTERNAL_INTERFACE\"" >> $configfile echo "DHCP=\"$DHCP\"" >> $configfile echo "EXTERNAL_IP=\"$EXTERNAL_IP\"" >> $configfile echo "BROADCAST_NET=\"$BROADCAST_NET\"" >> $configfile echo "EXTERNAL_NETWORK=\"$EXTERNAL_NETWORK\"" >> $configfile echo "MASQUERADING=\"$MASQUERADING\"" >> $configfile echo "DOUBLEMASQ=\"$DOUBLEMASQ\"" >> $configfile echo "INTERNAL_INTERFACE=\"$INTERNAL_INTERFACE\"" >> $configfile echo "INTERNAL_IP=\"$INTERNAL_IP\"" >> $configfile echo "INTERNAL_NETWORK=\"$INTERNAL_NETWORK\"" >> $configfile echo "INTERNAL_INTERFACE2=\"$INTERNAL_INTERFACE2\"" >> $configfile echo "INTERNAL_IP2=\"$INTERNAL_IP2\"" >> $configfile echo "INTERNAL_NETWORK2=\"$INTERNAL_NETWORK2\"" >> $configfile echo "DHCP_SERVER_IP=\"$DHCP_SERVER_IP\"" >> $configfile echo "SMTP_SERVER=\"$SMTP_SERVER\"" >> $configfile echo "POP_SERVER=\"$POP_SERVER\"" >> $configfile echo "POP3S_SERVERS=\"$POP3S_SERVERS\"" >> $configfile echo "MY_IMAP_SERVER=\"$MY_IMAP_SERVER\"" >> $configfile echo "MY_IMAPS_SERVER=\"$MY_IMAPS_SERVER\"" >> $configfile echo "NEWS_SERVER=\"$NEWS_SERVER\"" >> $configfile echo "SNEWS_SERVER=\"$SNEWS_SERVER\"" >> $configfile echo "MY_NEWS_FEED=\"$MY_NEWS_FEED\"" >> $configfile echo "WEB_PROXY_SERVER=\"$WEB_PROXY_SERVER\"" >> $configfile echo "WEB_PROXY_PORT=\"$WEB_PROXY_PORT\"" >> $configfile echo "PORT_FORWARD=\"$PORT_FORWARD\"" >> $configfile echo "OUTBOUND_PING=\"$OUTBOUND_PING\"" >> $configfile echo "INBOUND_PING=\"$INBOUND_PING\"" >> $configfile echo "OUTBOUND_TRACEROUTE=\"$OUTBOUND_TRACEROUTE\"" >> $configfile echo "INBOUND_TRACEROUTE=\"$INBOUND_TRACEROUTE\"" >> $configfile echo "SMTP_REMOTE_SERVER=\"$SMTP_REMOTE_SERVER\"" >> $configfile echo "POP3_CLIENT=\"$POP3_CLIENT\"" >> $configfile echo "POP3S_CLIENT=\"$POP3S_CLIENT\"" >> $configfile echo "IMAP_CLIENT=\"$IMAP_CLIENT\"" >> $configfile echo "IMAPS_CLIENT=\"$IMAPS_CLIENT\"" >> $configfile echo "SMTP_LOCAL_SERVER=\"$SMTP_LOCAL_SERVER\"" >> $configfile echo "AUTH_CLIENT=\"$AUTH_CLIENT\"" >> $configfile echo "DNS_CLIENT=\"$DNS_CLIENT\"" >> $configfile echo "FINGER_CLIENT=\"$FINGER_CLIENT\"" >> $configfile echo "FTP_CLIENT=\"$FTP_CLIENT\"" >> $configfile echo "GOPHER_CLIENT=\"$GOPHER_CLIENT\"" >> $configfile echo "HTTP_CLIENT=\"$HTTP_CLIENT\"" >> $configfile echo "HTTPS_CLIENT=\"$HTTPS_CLIENT\"" >> $configfile echo "HTTP_PROXY=\"$HTTP_PROXY\"" >> $configfile echo "NNTP_CLIENT=\"$NNTP_CLIENT\"" >> $configfile echo "NNTPS_CLIENT=\"$NNTPS_CLIENT\"" >> $configfile echo "NTP_CLIENT=\"$NTP_CLIENT\"" >> $configfile echo "SSH_CLIENT=\"$SSH_CLIENT\"" >> $configfile echo "TELNET_CLIENT=\"$TELNET_CLIENT\"" >> $configfile echo "WAIS_CLIENT=\"$WAIS_CLIENT\"" >> $configfile echo "WHOIS_CLIENT=\"$WHOIS_CLIENT\"" >> $configfile echo "ICQ_CLIENT=\"$ICQ_CLIENT\"" >> $configfile echo "RV_CLIENT=\"$RV_CLIENT\"" >> $configfile echo "PPTP_CLIENT=\"$PPTP_CLIENT\"" >> $configfile echo "SAMBA_CLIENT=\"$SAMBA_CLIENT\"" >> $configfile echo "DHCP_SERVER=\"$DHCP_SERVER\"" >> $configfile echo "FTP_SERVER=\"$FTP_SERVER\"" >> $configfile echo "MY_FTP_CLIENTS=\"$MY_FTP_CLIENTS\"" >> $configfile echo "DNS_CACHING_SERVER=\"$DNS_CACHING_SERVER\"" >> $configfile echo "DNS_FULL_SERVER=\"$DNS_FULL_SERVER\"" >> $configfile echo "AUTH_SERVER=\"$AUTH_SERVER\"" >> $configfile echo "POP3_SERVER=\"$POP3_SERVER\"" >> $configfile echo "MY_POP3_CLIENTS=\"$MY_POP3_CLIENTS\"" >> $configfile echo "POP3S_SERVER=\"$POP3S_SERVER\"" >> $configfile echo "MY_POP3S_CLIENTS=\"$MY_POP3S_CLIENTS\"" >> $configfile echo "IMAP_SERVER=\"$IMAP_SERVER\"" >> $configfile echo "MY_IMAP_CLIENTS=\"$MY_IMAP_CLIENTS\"" >> $configfile echo "IMAPS_SERVER=\"$IMAPS_SERVER\"" >> $configfile echo "MY_IMAPS_CLIENTS=\"$MY_IMAPS_CLIENTS\"" >> $configfile echo "NNTP_SERVER=\"$NNTP_SERVER\"" >> $configfile echo "MY_NNTP_CLIENTS=\"$MY_NNTP_CLIENTS\"" >> $configfile echo "NNTP_NEWS_FEED=\"$NNTP_NEWS_FEED\"" >> $configfile echo "TELNET_SERVER=\"$TELNET_SERVER\"" >> $configfile echo "MY_TELNET_CLIENTS=\"$MY_TELNET_CLIENTS\"" >> $configfile echo "SSH_SERVER=\"$SSH_SERVER\"" >> $configfile echo "MY_SSH_CLIENTS=\"$MY_SSH_CLIENTS\"" >> $configfile echo "SSH_PORT=\"$SSH_PORT\"" >> $configfile echo "HTTP_SERVER=\"$HTTP_SERVER\"" >> $configfile echo "MY_HTTP_CLIENTS=\"$MY_HTTP_CLIENTS\"" >> $configfile echo "HTTPS_SERVER=\"$HTTPS_SERVER\"" >> $configfile echo "MY_HTTPS_CLIENTS=\"$MY_HTTPS_CLIENTS\"" >> $configfile echo "FINGER_SERVER=\"$FINGER_SERVER\"" >> $configfile echo "MY_FINGER_CLIENTS=\"$MY_FINGER_CLIENTS\"" >> $configfile echo "SAMBA_SERVER=\"$SAMBA_SERVER\"" >> $configfile echo "MY_SAMBA_CLIENTS=\"$MY_SAMBA_CLIENTS\"" >> $configfile echo "HALF_LIFE=\"$HALF_LIFE\"" >> $configfile echo "WOLF_CLIENT=\"$WOLF_CLIENT\"" >> $configfile } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function configreadin { . $configfile ##Persistance variables ##Yes, I do see the redundancy here too... its just a matter of how it got coded... I'll fix it eventually if [ $DHCP -eq 1 ] then DHCP_TF=TRUE elif [ $DHCP -eq 0 ] then DHCP_TF=FALSE else DHCP_TF=FALSE fi if [ $MASQUERADING -eq 1 ] then MASQUERADING_TF=TRUE elif [ $MASQUERADING -eq 0 ] then MASQUERADING_TF=FALSE else MASQUERADING_TF=FALSE fi if [ $PORT_FORWARD -eq 1 ] then PORT_FORWARD_TF=TRUE elif [ $PORT_FORWARD -eq 0 ] then PORT_FORWARD_TF=FALSE else PORT_FORWARD_TF=FALSE fi if [ $OUTBOUND_PING -eq 1 ] then OUTBOUND_PING_TF=TRUE elif [ $OUTBOUND_PING -eq 0 ] then OUTBOUND_PING_TF=FALSE else OUTBOUND_PING_TF=FALSE fi if [ $INBOUND_PING -eq 1 ] then INBOUND_PING_TF=TRUE elif [ $INBOUND_PING -eq 0 ] then INBOUND_PING_TF=FALSE else INBOUND_PING_TF=FALSE fi if [ $OUTBOUND_TRACEROUTE -eq 1 ] then OUTBOUND_TRACEROUTE_TF=TRUE elif [ $OUTBOUND_TRACEROUTE -eq 0 ] then OUTBOUND_TRACEROUTE_TF=FALSE else OUTBOUND_TRACEROUTE_TF=FALSE fi if [ $INBOUND_TRACEROUTE -eq 1 ] then INBOUND_TRACEROUTE_TF=TRUE elif [ $INBOUND_TRACEROUTE -eq 0 ] then INBOUND_TRACEROUTE_TF=FALSE else INBOUND_TRACEROUTE_TF=FALSE fi if [ $SMTP_REMOTE_SERVER -eq 1 ] then SMTP_REMOTE_SERVER_TF=TRUE elif [ $SMTP_REMOTE_SERVER -eq 0 ] then SMTP_REMOTE_SERVER_TF=FALSE else SMTP_REMOTE_SERVER_TF=FALSE fi if [ $POP3_CLIENT -eq 1 ] then POP3_CLIENT_TF=TRUE elif [ $POP3_CLIENT -eq 0 ] then POP3_CLIENT_TF=FALSE else POP3_CLIENT_TF=FALSE fi if [ $IMAP_CLIENT -eq 1 ] then IMAP_CLIENT_TF=TRUE elif [ $IMAP_CLIENT -eq 0 ] then IMAP_CLIENT_TF=FALSE else IMAP_CLIENT_TF=FALSE fi if [ $IMAPS_CLIENT -eq 1 ] then IMAPS_CLIENT_TF=TRUE elif [ $IMAPS_CLIENT -eq 0 ] then IMAPS_CLIENT_TF=FALSE else IMAPS_CLIENT_TF=FALSE fi if [ $SMTP_LOCAL_SERVER -eq 1 ] then SMTP_LOCAL_SERVER_TF=TRUE elif [ $SMTP_LOCAL_SERVER -eq 0 ] then SMTP_LOCAL_SERVER_TF=FALSE else SMTP_LOCAL_SERVER_TF=FALSE fi if [ $AUTH_CLIENT -eq 1 ] then AUTH_CLIENT_TF=TRUE elif [ $AUTH_CLIENT -eq 0 ] then AUTH_CLIENT_TF=FALSE else AUTH_CLIENT_TF=FALSE fi if [ $DNS_CLIENT -eq 1 ] then DNS_CLIENT_TF=TRUE elif [ $DNS_CLIENT -eq 0 ] then DNS_CLIENT_TF=FALSE else DNS_CLIENT_TF=FALSE fi if [ $FINGER_CLIENT -eq 1 ] then FINGER_CLIENT_TF=TRUE elif [ $FINGER_CLIENT -eq 0 ] then FINGER_CLIENT_TF=FALSE else FINGER_CLIENT_TF=FALSE fi if [ $FTP_CLIENT -eq 1 ] then FTP_CLIENT_TF=TRUE elif [ $FTP_CLIENT -eq 0 ] then FTP_CLIENT_TF=FALSE else FTP_CLIENT_TF=FALSE fi if [ $GOPHER_CLIENT -eq 1 ] then GOPHER_CLIENT_TF=TRUE elif [ $GOPHER_CLIENT -eq 0 ] then GOPHER_CLIENT_TF=FALSE else GOPHER_CLIENT_TF=FALSE fi if [ $HTTP_CLIENT -eq 1 ] then HTTP_CLIENT_TF=TRUE elif [ $HTTP_CLIENT -eq 0 ] then HTTP_CLIENT_TF=FALSE else HTTP_CLIENT_TF=FALSE fi if [ $HTTPS_CLIENT -eq 1 ] then HTTPS_CLIENT_TF=TRUE elif [ $HTTPS_CLIENT -eq 0 ] then HTTPS_CLIENT_TF=FALSE else HTTPS_CLIENT_TF=FALSE fi if [ $HTTP_PROXY -eq 1 ] then HTTP_PROXY_TF=TRUE elif [ $HTTP_PROXY -eq 0 ] then HTTP_PROXY_TF=FALSE else HTTP_PROXY_TF=FALSE fi if [ $NNTP_CLIENT -eq 1 ] then NNTP_CLIENT_TF=TRUE elif [ $NNTP_CLIENT -eq 0 ] then NNTP_CLIENT_TF=FALSE else NNTP_CLIENT_TF=FALSE fi if [ $NNTPS_CLIENT -eq 1 ] then NNTPS_CLIENT_TF=TRUE elif [ $NNTPS_CLIENT -eq 0 ] then NNTPS_CLIENT_TF=FALSE else NNTPS_CLIENT_TF=FALSE fi if [ $NTP_CLIENT -eq 1 ] then NTP_CLIENT_TF=TRUE elif [ $NTP_CLIENT -eq 0 ] then NTP_CLIENT_TF=FALSE else NTP_CLIENT_TF=FALSE fi if [ $SSH_CLIENT -eq 1 ] then SSH_CLIENT_TF=TRUE elif [ $SSH_CLIENT -eq 0 ] then SSH_CLIENT_TF=FALSE else SSH_CLIENT_TF=FALSE fi if [ $TELNET_CLIENT -eq 1 ] then TELNET_CLIENT_TF=TRUE elif [ $TELNET_CLIENT -eq 0 ] then TELNET_CLIENT_TF=FALSE else TELNET_CLIENT_TF=FALSE fi if [ $WAIS_CLIENT -eq 1 ] then WAIS_CLIENT_TF=TRUE elif [ $WAIS_CLIENT -eq 0 ] then WAIS_CLIENT_TF=FALSE else WAIS_CLIENT_TF=FALSE fi if [ $WHOIS_CLIENT -eq 1 ] then WHOIS_CLIENT_TF=TRUE elif [ $WHOIS_CLIENT -eq 0 ] then WHOIS_CLIENT_TF=FALSE else WHOIS_CLIENT_TF=FALSE fi if [ $ICQ_CLIENT -eq 1 ] then ICQ_CLIENT_TF=TRUE elif [ $ICQ_CLIENT -eq 0 ] then ICQ_CLIENT_TF=FALSE else ICQ_CLIENT_TF=FALSE fi if [ $RV_CLIENT -eq 1 ] then RV_CLIENT_TF=TRUE elif [ $RV_CLIENT -eq 0 ] then RV_CLIENT_TF=FALSE else RV_CLIENT_TF=FALSE fi if [ $PPTP_CLIENT -eq 1 ] then PPTP_CLIENT_TF=TRUE elif [ $PPTP_CLIENT -eq 0 ] then PPTP_CLIENT_TF=FALSE else PPTP_CLIENT_TF=FALSE fi if [ $SAMBA_CLIENT -eq 1 ] then SAMBA_CLIENT_TF=TRUE elif [ $SAMBA_CLIENT -eq 0 ] then SAMBA_CLIENT_TF=FALSE else SAMBA_CLIENT_TF=FALSE fi if [ $DHCP_SERVER -eq 1 ] then DHCP_SERVER_TF=TRUE elif [ $DHCP_SERVER -eq 0 ] then DHCP_SERVER_TF=FALSE else DHCP_SERVER_TF=FALSE fi if [ $FTP_SERVER -eq 1 ] then FTP_SERVER_TF=TRUE elif [ $FTP_SERVER -eq 0 ] then FTP_SERVER_TF=FALSE else FTP_SERVER_TF=FALSE fi if [ $DNS_CACHING_SERVER -eq 1 ] then DNS_CACHING_SERVER_TF=TRUE elif [ $DNS_CACHING_SERVER -eq 0 ] then DNS_CACHING_SERVER_TF=FALSE else DNS_CACHING_SERVER_TF=FALSE fi if [ $DNS_FULL_SERVER -eq 1 ] then DNS_FULL_SERVER_TF=TRUE elif [ $DNS_FULL_SERVER -eq 0 ] then DNS_FULL_SERVER_TF=FALSE else DNS_FULL_SERVER_TF=FALSE fi if [ $AUTH_SERVER -eq 1 ] then AUTH_SERVER_TF=TRUE elif [ $AUTH_SERVER -eq 0 ] then AUTH_SERVER_TF=FALSE else AUTH_SERVER_TF=FALSE fi if [ $POP3_SERVER -eq 1 ] then POP3_SERVER_TF=TRUE elif [ $POP3_SERVER -eq 0 ] then POP3_SERVER_TF=FALSE else POP3_SERVER_TF=FALSE fi if [ $POP3S_SERVER -eq 1 ] then POP3S_SERVER_TF=TRUE elif [ $POP3S_SERVER -eq 0 ] then POP3S_SERVER_TF=FALSE else POP3S_SERVER_TF=FALSE fi if [ $IMAP_SERVER -eq 1 ] then IMAP_SERVER_TF=TRUE elif [ $IMAP_SERVER -eq 0 ] then IMAP_SERVER_TF=FALSE else IMAP_SERVER_TF=FALSE fi if [ $IMAPS_SERVER -eq 1 ] then IMAPS_SERVER_TF=TRUE elif [ $IMAPS_SERVER -eq 0 ] then IMAPS_SERVER_TF=FALSE else IMAPS_SERVER_TF=FALSE fi if [ $NNTP_SERVER -eq 1 ] then NNTP_SERVER_TF=TRUE elif [ $NNTP_SERVER -eq 0 ] then NNTP_SERVER_TF=FALSE else NNTP_SERVER_TF=FALSE fi if [ $NNTP_NEWS_FEED -eq 1 ] then NNTP_NEWS_FEED_TF=TRUE elif [ $NNTP_NEWS_FEED -eq 0 ] then NNTP_NEWS_FEED_TF=FALSE else NNTP_NEWS_FEED_TF=FALSE fi if [ $TELNET_SERVER -eq 1 ] then TELNET_SERVER_TF=TRUE elif [ $TELNET_SERVER -eq 0 ] then TELNET_SERVER_TF=FALSE else TELNET_SERVER_TF=FALSE fi if [ $SSH_SERVER -eq 1 ] then SSH_SERVER_TF=TRUE elif [ $SSH_SERVER -eq 0 ] then SSH_SERVER_TF=FALSE else SSH_SERVER_TF=FALSE fi if [ $HTTP_SERVER -eq 1 ] then HTTP_SERVER_TF=TRUE elif [ $HTTP_SERVER -eq 0 ] then HTTP_SERVER_TF=FALSE else HTTP_SERVER_TF=FALSE fi if [ $HTTPS_SERVER -eq 1 ] then HTTPS_SERVER_TF=TRUE elif [ $HTTPS_SERVER -eq 0 ] then HTTPS_SERVER_TF=FALSE else HTTPS_SERVER_TF=FALSE fi if [ $FINGER_SERVER -eq 1 ] then FINGER_SERVER_TF=TRUE elif [ $FINGER_SERVER -eq 0 ] then FINGER_SERVER_TF=FALSE else FINGER_SERVER_TF=FALSE fi if [ $SAMBA_SERVER -eq 1 ] then SAMBA_SERVER_TF=TRUE elif [ $SAMBA_SERVER -eq 0 ] then SAMBA_SERVER_TF=FALSE else SAMBA_SERVER_TF=FALSE fi if [ $HALF_LIFE -eq 1 ] then HALF_LIFE_TF=TRUE elif [ $HALF_LIFE -eq 0 ] then HALF_LIFE_TF=FALSE else HALF_LIFE_TF=FALSE fi if [ $WOLF_CLIENT -eq 1 ] then WOLF_CLIENT_TF=TRUE elif [ $WOLF_CLIENT -eq 0 ] then WOLF_CLIENT_TF=FALSE else WOLF_CLIENT_TF=FALSE fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check2 function banadd { integcheck $banlistfull $banlist temp=$banlist.temp echo "#!/bin/bash" > $temp echo 'zenity --list --radiolist --text="Select Rule To Edit or Remove:" --width=600 --height=300 --print-column=ALL --separator=" " --title "Beta BaseTables Script" \' >> $temp echo '--column="" --column $"Entry" --column $"Range" \' >> $temp count=1 while read conf do echo FALSE \$\"$count\)\" \$\"`echo $conf | awk '{print $1}'`\" \\ >> $temp count=`expr $count + 1` done < $banlistfull echo FALSE $"$count\)" $"New_Entry" \ >> $temp RESULT=`. $temp` if [ $? -eq 1 ] #used to stop script in main loop then cancel=1 else cancel=0 fi if [ "$RESULT" ] then RESULTrange=`echo "$RESULT" | awk '{print $2}'` if echo $RESULT | grep "New_Entry" then rangeread nodef if [ $range ] then for ban in ${range} do if echo $ban | grep [a-Z] #this sucks, find a better way to check then zenity --error --text="Error, incorrect format" else echo $ban >> $banlist #Default active echo $ban >> $banlistfull #Add to full list fi done fi elif cat $banlistfull | grep "$RESLUTrange" then banmodify=`zenity --entry --title="Modify Range" --text="Enter new range or leave blank to delete" --entry-text=$RESULTrange` if [ "$banmodify" ] ##what to do if they choose to change it then ipcheck $banmodify if [ $ipgood -eq 1 ] then cat $banlistfull | grep -v "$RESULT" > temp$$ echo $banmodify >> $banlistfull if cat $banlist | grep "$RESULT" ##make rule active if it was previously active then cat $banlist | grep -v "$RESULT" > temp$$ mv temp$$ $banlist echo $banmodify >> $banlist else cat $banlistfull | grep -v "$RESULTrange" > temp$$ mv temp$$ $banlistfull cat $banlistfull | grep -v "$RESULTrange" > temp$$ mv temp$$ $banlist fi else zenity --error --text="You have entered an invalid IP range" fi fi fi else cancel=1 fi dupcheck $banlistfull $banlist } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # echo check2 function banview { echo "#!/bin/bash" > firewall.banned.temp echo 'zenity --list --checklist --width=600 --height=300 --print-column=ALL --editable --separator=" " --title "Beta BaseTables Script" \' >> firewall.banned.temp echo '--column="" --column $"Entry" --column $"Range" \' >> firewall.banned.temp count=1 while read conf do if grep "$conf" $banlist then onoff=TRUE else onoff=FALSE fi echo $onoff \$\"$count\)\" \$\"`echo $conf | awk '{print $1}'`\" \\ >> firewall.banned.temp count=`expr $count + 1` done < $banlistfull RESULT=`. ./firewall.banned.temp` echo $RESULT | sed -e 's/.)/\ /g' | grep . > $banlist } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function portenable { #integrity check integcheck $natlistfull $natlist temp=./firewall.nat.temp echo "#!/bin/bash" > $temp echo 'zenity --list --checklist --width=600 --height=300 --print-column=ALL --editable --separator=" " --title "Beta BaseTables Script" \' >> $temp echo '--column="" --column $"Entry" --column $"Protocol" --column $"External Port" --column $"Internal IP" --column $"Internal Port" \' >> $temp count=1 while read conf do #HOLY CRAP! If this works ill... ill be surprised, setting perminance this way is dumb, fix this! HEY! It did work... I guess im only half as dumb as I thought... if grep ".*`echo $conf | awk '{print $1}'`.*`echo $conf | awk '{print $2}'`.*`echo $conf | awk '{print $3}'`.*`echo $conf | awk '{print $4}'`" $natlist then onoff=TRUE else onoff=FALSE fi echo $onoff \$\"$count\)\" \$\"`echo $conf | awk '{print $1}'`\" \"`echo $conf | awk '{print $2}'`\" \$\"`echo $conf | awk '{print $3}'`\" \$\"`echo $conf | awk '{print $4}'`\" \\ >> $temp count=`expr $count + 1` done < $natlistfull RESULT=`. ./firewall.nat.temp` ##replacing #) with newline, return IS important, grep . to get rid of extra return and beginning echo $RESULT | sed -e 's/.)/\ /g' | grep . > $natlist } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function portsetting { temp=./firewall.nat.temp ##check file integrity integcheck $natlistfull $natlist echo "#!/bin/bash" > $temp echo 'zenity --list --radiolist --text="Select Rule To Edit:" --width=600 --height=300 --print-column=ALL --separator=" " --title "Beta BaseTables Script" \' >> $temp echo '--column="" --column $"Entry" --column $"Protocol" --column $"External Port" --column $"Internal IP" --column $"Internal Port" \' >> $temp count=1 while read conf do echo FALSE \$\"$count\)\" \$\"`echo $conf | awk '{print $1}'`\" \"`echo $conf | awk '{print $2}'`\" \$\"`echo $conf | awk '{print $3}'`\" \$\"`echo $conf | awk '{print $4}'`\" \\ >> $temp count=`expr $count + 1` done < $natlistfull echo FALSE $"$count\)" $"" $"New_Entry" $"" $"" \ >> $temp RESULT=`. ./firewall.nat.temp` if [ $? -eq 1 ] #used to stop script in main loop then cancel=1 else cancel=0 fi if echo $RESULT | grep "New_Entry" then protocol=`zenity --list --radiolist --title="Protocol Selection" --width=600 --height=300 \ --column="" --column $"Protocol" --column $"Description" \ TRUE $"TCP" $"Primary protocol of the internet, lost packets retransmitted" \ FALSE $"UDP" $"Secondary protocol of the internet, lost packets not retransmitted" \ ` extport=`zenity --entry --text="Enter External Port: "` intip=`zenity --entry --text="Enter Internal Computer IP Address: "` intport=`zenity --entry --text="Enter Internal Port: "` fi if echo $extport | grep [a-Z] then zenity --error --text="You have entered an invalid entry, try again" setvar fi if echo $intport | grep [a-Z] then zenity --error --text="You have entered an invalid entry, try again" setvar fi ipcheck if [ $ipgood -eq 0 ] then zenity --error --text="You have entered an invalid entry, try again" setvar fi if [ $protocol ] then echo " $protocol $extport $intip $intport" >> $natlistfull echo " $protocol $extport $intip $intport" >> $natlist #just some cleanup protocol="" extport="" intip="" intport="" fi ##cleanup routine dupcheck $natlistfull $natlist } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function statuscheck { statusmain=`zenity --list --text="Select an option:" --radiolist --width=600 --height=300 --column="" --column=$"Option" --column=$"Description"\ TRUE $"Check Firewall" $"Check Firewall Status"\ FALSE $"Start Firewall" $"Start BaseTables Firewall"\ FALSE $"Stop Firewall" $"Stop BaseTables Firewall"\ FALSE $"Restart Firewall" $"Restart BaseTables Firewall"\ ` if [ "$statusmain" = "Check Firewall" ] then if [ -e $lockfile ] then zenity --info --text="Firewall is ON" else zenity --info --text="Firewall is OFF" fi statuscheck elif [ "$statusmain" = "Start Firewall" ] then $initfile start zenity --info --text="Firewall started" elif [ "$statusmain" = "Stop Firewall" ] then $initfile stop zenity --info --text="Firewall stopped" elif [ "$statusmain" = "Restart Firewall" ] then $initfile restart zenity --info --text="Firewall restarted" fi } # # # # #NEW FUNCTION #Sorry, Im blind, and this was handy to find #NEW FUNCTION # # # # function ipcheck { ip=`echo $1 | awk -F/ '{print $1}'` subnet=`echo $1 | awk -F/ '{print $2}'` ipgood=0 if [ "$1" = "any/0" ] then ipgood=1 fi if [ `echo $ip | awk -F"." '{print $1}'` -lt 256 ] then if [ `echo $ip | awk -F"." '{print $2}'` -lt 256 ] then if [ `echo $ip | awk -F"." '{print $3}'` -lt 256 ] then if [ `echo $ip | awk -F"." '{print $4}'` -lt 256 ] then if [ $subnet -lt 33 ] then ipgood=1 fi fi fi fi fi } function dupcheck { if [ `cat $2 | wc -l` -gt `cat $2 | sort | uniq | wc -l` ] then cat $2 | sort | uniq >> tmp$$ mv tmp$$ $2 elif [ `cat $1 | wc -l` -gt `cat $1 | sort | uniq | wc -l` ] then cat $1 | sort | uniq >> tmp$$ mv tmp$$ $1 fi } function integcheck { # $1 should be .full, $2 should be active list while read iprange do if cat $1 | grep "$iprange" then echo check else echo fail echo $iprange >> $1 fi done < $2 } function advperm { finalperm="any/0" permsearch=`cat $configfile | grep $1 | awk -F= '{print $2}' | sed 's/"//g'` if [ "$permsearch" ] then finalperm=$permsearch fi echo $finalperm } function localadd { custominfo=`zenity --list --width=600 --height=300 --print-column=ALL --editable --separator="_" --title "Beta BaseTables Script" \ --column $"Entry Name" --column $"TCP/UDP" --column $"Source IP" --column $"Port" --column $"ACCEPT/REJECT" \ $"Enter Name" $"TCP" $"anywhere" $"Enter Port" $"ACCEPT" ` customname=`echo $custominfo | awk -F"_" '{print $1}'` protocol=`echo $custominfo | awk -F"_" '{print $2}'` sport=`echo $custominfo | awk -F"_" '{print $4}'` sip=`echo $custominfo | awk -F"_" '{print $3}'` acrej=`echo $custominfo | awk -F"_" '{print $5}'` if [ "$protocol" != "TCP" ] then if [ "$protocol" != "UDP" ] then zenity --error fi fi if echo $sport | grep [a-Z] then zenity --error fi if [ "$sip" = "anywhere" ] then sip="\$ANYWHERE" else ipcheck $sip fi if [ "$acrej" != "ACCEPT" ] then if [ "$acrej" != "REJECT" ] then zenity --error fi fi echo "#$customname" >> firewall.local echo "iptables -A INPUT -i \$EXTERNAL_INTERFACE -p $protocol -m state --state ESTABLISHED,RELATED --sport $sport --dport \$UNPRIVPORTS -s $sip -d \$EXTERNAL_IP -j $acrej" >> firewall.local } zenity --info --text="Welcome to BaseTables Beta, this script is designed to provide a point and click front end to some of the more advanced options for the linux firewall iptables. This script will attempt to find as much information on its own, but it will still ask you for verification. This script is BETA, so it might hurt your firewall. If you dont know how to flush your firewall rules, dont use it!" --title="Welcome" quit=0 while [ $quit -eq 0 ] do mode=`zenity --list --text="Welcome" --radiolist --width=700 --height=300 --column="" --column=$"Configuration" --column=$"Description"\ TRUE $"Base Configuration" $"Initial firewall configuration. Select to configure or reconfigure."\ FALSE $"Profile Manager" $"Create, view, modify, and activate profiles. Not Working"\ FALSE $"Advanced Configuration" $"Select here to modify port forwarding settings and Banned IP Ranges"\ FALSE $"Firewall Status" $"Check the status of the firewall and turn it on and off"\ ` if [ $? -eq 1 ] then quit=1 fi if [ "$mode" = "Base Configuration" ] then configreadin startread globalconfig selectorsecurity selectorclient selectorserver selectorgames filemake elif [ "$mode" = "Profile Manager" ] then echo "not done" elif [ "$mode" = "Advanced Configuration" ] then stop=0 while [ $stop -eq 0 ] do advancemode=`zenity --list --radiolist --text="Select User Mode" --radiolist --width=600 --height=300 --column="" --column=$"DHCP" --column=$"Description"\ FALSE $"Custom Rules" $"Make custom firewall rules"\ FALSE $"Port Forward Disable/Enable" $"Disable and Enable Forwarded Ports"\ FALSE $"Port Forward Add/Edit" $"Add and Edit Forwarded Ports to Configuration"\ FALSE $"Blocked Ranges Disable/Enable" $"Disable and Enable Blocked Ranges"\ FALSE $"Blocked Ranges Add/Edit" $"Add and Edit Blocked Ranges to Configuration"\ ` if [ $? -eq 1 ] then stop=1 elif [ "$advancemode" = "Custom Rules" ] then echo "not done" elif [ "$advancemode" = "Port Forward Disable/Enable" ] then portenable elif [ "$advancemode" = "Port Forward Add/Edit" ] then cancel=0 while [ $cancel -eq 0 ] do portsetting done elif [ "$advancemode" = "Blocked Ranges Disable/Enable" ] then banview elif [ "$advancemode" = "Blocked Ranges Add/Edit" ] then cancel=0 while [ $cancel -eq 0 ] do banadd done fi done ##making sure nothing wonky happened dupcheck $natlistfull $natlist dupcheck $banlistfull $banlist integcheck $natlistfull $natlist integcheck $banlistfull $banlist zenity --question --text="New Settings will not be applied until firewall is restarted. Press ok to restart firewall now or cancel to restart later" if [ $? -eq 0 ] then # $initfile restart echo "For testing purposes this was disabled, if for some reason I forget to re-enable this before public release, please let me know" fi elif [ "$mode" = "Firewall Status" ] then statuscheck fi done