Sign in to follow this  
Followers 0
engjcowi

Firewall

3 posts in this topic

Hi Guys

Ive seen some code using WMI to see if antivirus software is installed and then list what software it is. does anyone know of any code using WMI or otherwise to see if any firewalls are installed?

Im writing a program to check the security on a pc and if no antivirus or firewall is installed then it will automatically install it. Ill post when complete.

thanks in advance


Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites



You might try something like this (not WMI, though):

$oFW = ObjCreate("HNetCfg.FwMgr")
$oLocPol = $oFW.LocalPolicy
$oCurrProf = $oLocPol.CurrentProfile
$sText = "Firewall/CurrentProfileType: " & $oFW.CurrentProfileType & @LF
$sText &= "Profile/FirewallEnabled: " & $oCurrProf.FirewallEnabled & @LF
ConsoleWrite($sText & @LF)

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi thanks

thought id share some other firewall code i had found on another site for a different language and changed to work in autoit

$strComputer = "."
$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\SecurityCenter2")
$colItems = $oWMI.ExecQuery("Select * from FirewallProduct"); "from FirewallProduct" works as well

  For $objAntiVirusProduct In $colItems
      MsgBox(0, "Firewall name", $objAntiVirusProduct.displayName)

  Next



;is firewall enabled
$oFW = ObjCreate("HNetCfg.FwMgr")
$oLocPol = $oFW.LocalPolicy
$oCurrProf = $oLocPol.CurrentProfile
$sText = $oCurrProf.FirewallEnabled
if $sText = "True" then
MsgBox(0, "Firewall enabled", "firewall is active")
Else
MsgBox(0, "Firewall enabled", $sText)
EndIf


;not sure what it does yet - i think it might enable the firewall?????
$ofwj = ObjCreate("HNetCfg.FwMgr")
$profile = $ofwj.LocalPolicy.CurrentProfile

$profile.FirewallEnabled = True
;end of not sure lol


;Lists Windows Firewall properties for the current profile.

$objFirewall = ObjCreate("HNetCfg.FwMgr")
$objPolicy = $objFirewall.LocalPolicy.CurrentProfile
MsgBox(0, "Current Profile Type", $objPolicy.FirewallEnabled)
MsgBox(0, "Firewall Enabled ", $objPolicy.FirewallEnabled)
MsgBox(0, "Exceptions not allowed: ", $objPolicy.ExceptionsNotAllowed)
MsgBox(0, "Notifications disabled: ", $objPolicy.NotificationsDisabled)
MsgBox(0, "Unicast responses to multicast broadcast disabled: ", $objPolicy.UnicastResponsestoMulticastBroadcastDisabled)

Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0