List IIS IP Restrictions Using VBScript

Even though one of my old engineer friends, Greg, would be saying to me all the time, “why the hell are you still messing around with VBScript when you should be doing that in Powershell”.

I say if you can do it in any language or framework, why not know how. Especially, when there are so many repositories of great vbscripts out there for the Windows OS. If there is a way to do something, I’ll try it and then just to put that code in my library for some rainy day or integrate it in to something I’ve already written to improve it.

Run this VBSCript if you want to get a list of the IP restrictions that have been set on a Windows Server running Microsoft’s IIS .

This code will pop-up a message box as it iterates through a list of the server’s IP restrictions which can be set on a collection of objects. It can go on forever.

Sample Code

You can get a copy of this VBScript from my GitHub Repo.

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsIPSecuritySetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    For Each strDeny in objItem.DomainDeny
        Wscript.Echo "Domain Deny: " & strDeny
    Next
    For Each strGrant in objItem.DomainGrant
        Wscript.Echo "Domain Grant: " & strGrant
    Next
    Wscript.Echo "Grant By Default: " & objItem.GrantByDefault
    For Each strDeny in objItem.IPDeny
        Wscript.Echo "IP Deny: " & strDeny
    Next
    For Each strGrant in objItem.IPGrant
        Wscript.Echo "IP Grant: " & strGrant
    Next
Next

As always, I like to share and give credit to the online resources where I find these gems.

CRUTO.com

http://www.cruto.com/resources/vbscript/vbscript-examples/iis/iis6/auth/List-IIS-IP-Address-and-Domain-Restrictions.asp

VBSEdit.com

https://www.vbsedit.com/scripts/iis/iis6/auth/scr_502.asp

Author: Rick Cable / AKA Cyber Abyss

A 16 year US Navy Veteran with 25+ years experience in various IT Roles in the US Navy, Startups and Healthcare. Founder of FinditClassifieds.com in 1997 to present and co-founder of Sports Card Collector Software startup, LK2 Software 1999-2002. For last 7 years working as a full-stack developer supporting multiple agile teams and products in a large healthcare organization. Part-time Cyber Researcher, Aspiring Hacker, Lock Picker and OSINT enthusiast.