VBScript Error – MSXML3.dll error ‘800C0005’

This is a popular re-post from my old Blogger blog.

I’m working on  a website up-time monitoring script.

After I had my initial prototype working, I received more requirements for logging output to CSV in addition to storing output in Access DB and decided to add CPU usage percentages to the logging.

Once I had all that done, I started getting odd errors when solution should be detecting a down-time event.

Testing the script with older version of Microsoft.XmlHttp had issues where certain but not all websites the script would call were incorrectly displaying HTTP status code 404 but a 200 OK was really sent back verified by using Fiddler.  Very odd behavior.

The error is related to VBScript’s use of the older version of the Microsoft.XmlHttp object.

The Code

Function isPortalOffline(strURL)
 'Set WshShell = WScript.CreateObject("WScript.Shell")
 Set http = CreateObject("Microsoft.XmlHttp")

 http.open "GET", strURL, False
 http.send 
 
 'Only check for error of the http Get request
 if err.Number <> 0 Then
  isPortalOffline = True
 Else
  'Wscript.Echo "error" & Err.Number & ": " & Err.Description
  isPortalOffline = False
 End If

 'Clear the error after setting isPortalOffline
 err.clear
 'set WshShell = Nothing
 Set http = Nothing 

 ReportError("isPortalOffline")
End Function

Error: MSXML3.dll error ‘800C0005’ The System cannot locate the resource

Changed MSXML Objects.

The Fixed Code

Replaced Microsoft.XmlHttp with MSXML2.ServerXMLHTTP.

Function isPortalOffline(strURL)
 'Set WshShell = WScript.CreateObject("WScript.Shell")
 Set http = CreateObject("MSXML2.ServerXMLHTTP")

 http.open "GET", strURL, False
 http.send
 
 'Only check for error of the http Get request
 if err.Number <> 0 Then
  isPortalOffline = True
 Else
  'Wscript.Echo "error" & Err.Number & ": " & Err.Description
  isPortalOffline = False
 End If

 'Clear the error after setting isPortalOffline
 err.clear
 'set WshShell = Nothing
 Set http = Nothing 

 ReportError("isPortalOffline")
End Function

This resolved my issues!

I hope this helps someone. 🙂

InfoSec Tip: What’s in those web server 404 NOT FOUND errors?

Catching Bad Guys using Web Server 404 Errors!

404 NOT FOUND pages in your web server logs are often the earliest sign of surveillance, foot printing or reconnaissance.

This probing event I caught was using the IP, bypassing DNS while probing for non-existent file called “/admin/config.php” all the way from Ramallah Palestine. #Infosec#OSINT#cybersecurity

Hope this helps someone!

Regards,
Rick

Exporting IIS IP Restrictions to a File using a Powershell Script

If you ever find yourself needing to export a list of site or IP restrictions from a Windows based web server running IIS then this is how you do it using Powershell. 

I believe that there is a vbscript that can do this as well but I chose Powershell for this challenge and it worked so why not.
At this point I am assuming you know what Powershell is, have it installed and know how to execute scripts. With that being said.

Create a Powershell script and name the file “export-ip-restrictions.ps1” and paste in the text below.
Execute it and you should have a list of IP restrictions in the same folder as the script you ran.

Powershell Code Example

[string]$SitesVar = Read-Host "Enter Sitenames with no spaces in between, Seperated by ';' i.e site1;site2;site3" 
$exportfolder = Read-Host "Enter Export Folder i.e. C:\folder1" 
 
sl c:\windows\system32\inetsrv\ 
 
$a = 0 
$Sites = $SitesVar.Split(";") 
$count = $Sites.count 
 
do { 
foreach ($site in $Sites){ 
[xml]$out = .\appcmd.exe list config $site -section:system.webServer/security/ipSecurity  
 
$out."system.webserver"."security"."ipsecurity" | %{ 
$_.innerxml.split("<*>") | out-file $exportfolder\$site.txt 
 
} 
$a++ 
} 
} 
while ($a -ne $count)