Monthly Archives: March 2007

MyWinFwWebAdmin

Simple ASP-script for Windows Firewall that allow editing of existing enabled firewall services from a web page.
I use this to open up Remote Desktop to my computer when Im out on the big bad internet.
Usage: First add your firewall rules to Windows Firewall.
(don´t forget to secure the script properly)

<%
'=================================================================================================== 
'MyWinFwWebAdmin.asp
'
'Created by: Goran Tornqvist. 
'This script is freeware, do what you like with it ;)
' 
'Description: 
'Simple ASP-script for Windows Firewall that allow editing of existing enabled firewall services from a web page.
'I use this to open up Remote Desktop to my computer when Im out on the big bad internet.
'Usage: First add your firewall rules to Windows Firewall.
'=================================================================================================== 

Option Explicit
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 10
Response.AddHeader "pragma","nocache"
Response.CacheControl = "nocache"
Response.Buffer = True

Dim objFirewall, objPolicy, colServices, Service, arrRemoteAddresses, OldValue, blnRemoteAddrUpdated
%>
<HTML>
<HEAD>
<TITLE>Firewall Services Administration</TITLE>
</HEAD>
<BODY>
<H1>Firewall Services Administration</H1>
<HR>
<P>The following firewall rules are available for administration.</P>
<%
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.Services

For Each Service In colServices 
	If Service.Enabled Then
		Response.Write "<b><P>" & Service.Name & "</P></b>"

		Response.Write "<FORM ACTION=""MyWinFwWebAdmin.asp"" METHOD=""POST"">" & _
				"<TABLE BORDER=""0"" CELLPADDING=""0"" CELLSPACING=""0"">" & _
				"<TR>" & _
				"<TD WIDTH=""50"">&nbsp;</TD>" & _
				"<TD COLSPAN=""2"" HEIGHT=""30""><U>Remote addresses</U></TD>" & _
				"</TR>"

		If Request.ServerVariables("REQUEST_METHOD") = "POST" AND Request.Form("Service") = Service.Name Then
			OldValue = Service.RemoteAddresses
			Service.RemoteAddresses = Request.Form("RemoteAddresses")
			blnRemoteAddrUpdated = True
		End If

		Response.Write "<TR>" & _
				"<TD WIDTH=""50"">&nbsp;</TD>" & _
				"<TD WIDTH=""150""><textarea rows=""5"" cols=""50"" NAME=""RemoteAddresses"">" & Service.RemoteAddresses & "</textarea></TD>" & _
				"<TD WIDTH=""50""></TD>" & _
				"</TR>"

		If blnRemoteAddrUpdated Then
			Response.Write "<TR>" & _
					"<TD WIDTH=""50"">&nbsp;</TD>" & _
					"<TD WIDTH=""150""><font color=""red"">Updated ...</font><br/>Old value: " & OldValue & "</TD>" & _
					"<TD WIDTH=""50""></TD>" & _
					"</TR>"
			blnRemoteAddrUpdated = False
		End If

		Response.Write "<TR>" & _
				"<TD COLSPAN=""3"" HEIGHT=""30""><INPUT TYPE=""HIDDEN"" NAME=""Service"" VALUE=""" & Service.Name & """/><INPUT TYPE=""SUBMIT"" VALUE=""Update""></TD>" & _
				"</TR>" & _
				"<TR>" & _
				"<TD COLSPAN=""3"" HEIGHT=""30""><hr></TD>" & _
				"</TR>" & _
				"</TABLE>" & _
				"</FORM>"
	End If
Next

%>
<a href="/">Home</a>...
</BODY>
</HTML>