Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Tue Mar 19, 2024 8:00 pm

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
PostPosted: Sun Apr 26, 2015 2:33 am 
Offline
Newbie

Joined: Thu Apr 09, 2015 4:30 pm
Posts: 25
Hi,

I'm running the latest version of open audit (1.6.2). There appears to be an assumption in the windows audit script that the open audit server will definitely be reachable as there is no protection in the script code for it not responding when the audit is submitted. This results in an unpleasant script failure.
"audit_windows.vbs(6656, 2) msxml3.dll: The server returned an invalid or unrecognized response"

I'm not sure how to modify the code to properly protect against this error and have the code exit neatly. Does anyone have any ideas?

It fails on line 6656 which is:
objHTTP.Send "form_systemXML=" + urlEncode(result.ReadText()) + vbcrlf


Last edited by swilkey on Sun May 10, 2015 12:09 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 30, 2015 6:03 am 
Offline
Contributor
User avatar

Joined: Thu Mar 02, 2006 4:41 am
Posts: 205
Location: Massachusetts
Change a couple of settings within the audit_windows.vbs file

' submit the audit to the OAv2 server
submit_online = "n"

' create an XML text file of the result in the current directory
create_file = "y"


This will create an audit results file in the directory that the script is run from, and it won't attempt to upload audit results to OA server...

_________________
Server Info: running on a CentOS 7 vm
OA Version: 2.0.6 @ 500 devices


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 30, 2015 7:40 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
WARNING! Hack and slash (of [url=http://stackoverflow.com/questions/24863986/vbscript-msxml12-xmlhttp-error-handling]stackoverflow answer[/url]) to follow. This should work better but someone who can code should probably fix this and not me. This only fixes one of the submit locations. There are others. Should probably break submit out into a function.

[code]
if submit_online = "y" then
if debugging > "0" then wscript.echo "Submitting audit online" end if
Err.clear
Set objHTTP = WScript.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objHTTP.setTimeouts 5000, 5000, 5000, 480000
objHTTP.SetOption 2, 13056 ' Ignore all SSL errors
On Error Resume Next
objHTTP.Open "POST", url, False
aErr = Array(Err.Number, Err.Description)
On Error GoTo 0
If 0 = aErr(0) Then
result.position = 0
On Error Resume Next
objHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
objHTTP.Send "form_systemXML=" + urlEncode(result.ReadText()) + vbcrlf
aErr = Array(Err.Number, Err.Description)
On Error GoTo 0
Select Case True
Case 0 <> aErr(0)
if debugging > "0" then
wscript.echo "Error with http request. Audit not submitted."
end if
if debugging > "1" then
wscript.echo "HTTP Error: " & aErr(0)
wscript.echo "HTTP Status: " & aErr(1)
end if
responseAvailable = False
Case 200 = objHTTP.status
if debugging > "0" then wscript.echo "Audit Submitted" end if
responseAvailable = True
Case Else
if debugging > "0" then wscript.echo "Error with http request(2). Audit not submitted." end if
responseAvailable = True
End Select

if responseAvailable = True then
if (objHTTP.ResponseText > "" and debugging > "1") then
wscript.echo
wscript.echo
wscript.echo "Response"
wscript.echo "--------"
wscript.echo objHTTP.ResponseText
if (inStr(objHTTP.ResponseText, "error")) then
wscript.sleep 50000
end if
end if
end if
else
if debugging > "0" then
wscript.echo "Error opening http url. Audit not submitted."
end if
if debugging > "1" then
wscript.echo "HTTP Error: " & aErr(0)
wscript.echo "HTTP Description: " & aErr(1)
end if
end if
end if[/code]


Top
 Profile  
Reply with quote  
PostPosted: Sat May 02, 2015 8:58 pm 
Offline
Newbie

Joined: Thu Apr 09, 2015 4:30 pm
Posts: 25
Hi jpa,

Thanks for your code hack. I've tried it and I'm running into the same problem as when I tried to do something about it myself. The script fails at:

Select Case True
Case 0 <> aErr(0)

With this error:
The data necessary to complete this operation is not yet available.

This seems to do with the aErr variable that was set with this command:
aErr = Array(Err.Number, Err.Description)

I can only conclude that this must be happenning in a different thread.

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Sun May 03, 2015 2:00 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
Could you post the actual output you're seeing? Just the output after it displays "Submitting audit online" to the end.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 03, 2015 2:31 am 
Offline
Newbie

Joined: Thu Apr 09, 2015 4:30 pm
Posts: 25
Hi jpa, Unfortunately it is no more than I said in my last message.

Submitting audit online
C:\Users\removed\Dropbox\removed\pcaudit\audit_windows.vbs(6845, 4) msxml3.dll: The data necessary to complete this operation is not yet available.

ignore the line number-I'm testing a bunch of extra code earlier in the script so it won't match what you are using. The line matches what I described in my last message.

If I am online when I run it it works perfectly. I tested it not working by being offline.

Stephen


Top
 Profile  
Reply with quote  
PostPosted: Sun May 03, 2015 12:29 pm 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
I'm having trouble understanding how you're getting the error message you are getting on the lines you've indicated. It should not happen. The msxml3.dll error should be associated with a line that has objHTTP in it.

What happens if you go online but pass a bad URL to the script?

cscript audit_windows.vbs url=http://shouldnotexist
or
cscript audit_windows.vbs url=httpXX://localhost
Or some other variation of bad URL like good host but bad path?


Top
 Profile  
Reply with quote  
PostPosted: Sun May 10, 2015 12:08 pm 
Offline
Newbie

Joined: Thu Apr 09, 2015 4:30 pm
Posts: 25
jpa, I'm sorry, there is nothing wrong with your code. No idea what I did wrong in transcribing it originally. It works beautifully. I recommend that Mark use this code in the next version of the audit script.

Regards,
Stephen


Top
 Profile  
Reply with quote  
PostPosted: Tue May 12, 2015 9:01 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
Have added this to my code for the next release - thanks guys!

_________________
Support and Development hours available from [url=https://opmantek.com]Opmantek[/url].
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group