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 Fri Mar 29, 2024 3:56 pm

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: Tue Jun 08, 2010 6:34 am 
Offline
Newbie

Joined: Tue Jun 08, 2010 6:23 am
Posts: 3
Hey everyone,

I just wanted to share a script I've created.

This vbs script downloads the audit.vbs file from the https site, creates an audit.conf based on list_export_config.php. Then executes the audit (posts via ssl) and then cleans up downloaded files.
[code]

'Declare variables
Dim oXMLHTTP
Dim oStream
Dim WSHShell
Dim AuditFiles(1)
Dim objFile
Dim objRandom
Dim CleanupFiles(2)

'Input variables
OAURL = "https://audit.webserver.com"

AuditFiles(0)="audit.vbs"
AuditFiles(1)="list_export_config.php"

'Create Objects
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objRandom = CreateObject( "System.Random" )

'Get Script folder
scriptFullName = WScript.ScriptFullName
TargetDir = Left ( scriptFullName, _
InStrRev ( scriptFullName, WScript.ScriptName) - 1 )

'Retrieve Audit Files
For Each objFile in AuditFiles
'Check if file exists and delete if possible
If (fso.FileExists(TargetDir & objFile)) Then
Set aFile = fso.GetFile(TargetDir & objFile)
aFile.Delete
End If
Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
oXMLHTTP.Open "GET", OAURL & "/" & objFile, False
oXMLHTTP.setOption 2, 13056
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
'Try to download from root
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile TargetDir & objFile
oStream.Close
Else
oXMLHTTP.Open "GET", OAURL & "/scripts/" & objFile, False
oXMLHTTP.Send
If oXMLHTTP.Status = 200 Then
'Try to download from scripts folder
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile TargetDir & objFile
oStream.Close
Else
'Error downloading, exiting script
WScript.Quit(2)
End If
End If
Next

'Check if file exists and delete if possible
If (fso.FileExists(TargetDir & "audit.config")) Then
Set aFile = fso.GetFile(TargetDir & "audit.config")
aFile.Delete
End If

'Rename php file to config
fso.MoveFile TargetDir & AuditFiles(1), TargetDir & "audit.config"

'Execute audit
WSHShell.Run "cscript """ & TargetDir & AuditFiles(0) & """", 2, true

'Cleanup
CleanupFiles(0)=TargetDir & "audit.config"
CleanupFiles(1)=TargetDir & AuditFiles(0)
CleanupFiles(2)=TargetDir & AuditFiles(1)
For Each objFile in CleanupFiles
If (fso.FileExists(objFile)) Then
Set aFile = fso.GetFile(objFile)
aFile.Delete
End If
Next
[/code]


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 22, 2010 6:15 am 
Offline
Newbie
User avatar

Joined: Mon Jun 21, 2010 11:39 pm
Posts: 13
Location: Iowa, USA
Wow that's a really cool idea. That way you don't have to worry about having an outdated audit file if something in the audit script changes.

I haven't tried it, but this may be the solution I'm looking for. Thanks for sharing :D


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 16, 2010 2:38 am 
Offline
Newbie
User avatar

Joined: Mon Jun 21, 2010 11:39 pm
Posts: 13
Location: Iowa, USA
I have been using this for a while now. This is GREAT! Thanks so much.


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