Open-AudIT
https://www.open-audit.org/phpBB3/

[solved]Audit script fails if open audit server is unreachab
https://www.open-audit.org/phpBB3/viewtopic.php?f=20&t=6436
Page 1 of 1

Author:  swilkey [ Sun Apr 26, 2015 2:33 am ]
Post subject:  [solved]Audit script fails if open audit server is unreachab

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

Author:  shanimal [ Thu Apr 30, 2015 6:03 am ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

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...

Author:  jpa [ Thu Apr 30, 2015 7:40 am ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

WARNING! Hack and slash (of stackoverflow answer) 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

Author:  swilkey [ Sat May 02, 2015 8:58 pm ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

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?

Author:  jpa [ Sun May 03, 2015 2:00 am ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

Could you post the actual output you're seeing? Just the output after it displays "Submitting audit online" to the end.

Author:  swilkey [ Sun May 03, 2015 2:31 am ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

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

Author:  jpa [ Sun May 03, 2015 12:29 pm ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

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?

Author:  swilkey [ Sun May 10, 2015 12:08 pm ]
Post subject:  Re: [help]Audit script fails if open audit server is unreach

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

Author:  Mark [ Tue May 12, 2015 9:01 am ]
Post subject:  Re: [solved]Audit script fails if open audit server is unrea

Have added this to my code for the next release - thanks guys!

Page 1 of 1 All times are UTC + 10 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/