[Plugins-writers] Help Converting a VB script to a Plug in

From: jfvanmeter@private
Date: Fri Sep 01 2006 - 03:43:34 PDT


I've written a vb script to enumerate the DCOM launch permissions that I would like to convert to a Nessus Plug in.  And I was wondering what woud be the best way, would it be easier to convert it if  I convert the vb script to perl then rewrite it in nasl? 

I've include the code, basicly the script output is written to a text file.

'Hive Constants
Const ForReading = 1
Const ForAppending = 8
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004 
Const HKEY_CURRENT_CONFIG = &H80000005 
Const HKEY_DYN_DATA = &H80000006
 
'RegFormat Constants
Const REG_NONE = 0
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_LINK = 5
Const REG_MULTI_SZ = 6
Const REG_RESOURCE_LIST = 7
'Well Known Sids - http://support.microsoft.com/kb/243330
'Everyone
EO = "S-1-1-0"
'Creator Owner
CO = "S-1-3-0"
'Network
Net = "S-1-5-2"
'Batch 
Bat = "S-1-5-3"
'Interactive 
IA = "S-1-5-4"
'Service 
Ser = "S-1-5-6"
'Anonymous 
Anon = "S-1-5-7"
'Authorized Users
AU = "S-1-5-11"
'Terminal User
TU = "S-1-5-13"
'Local System 
LS = "S-1-5-18"
'NTAuthority 
NA = "S-1-5-19"
'NTAuthority 
NTA = "S-1-5-20"
'Administrators 
AD = "S-1-5-32-544"
User = "S-1-5-32-545"
Guests = "S-1-5-32-546"
'Power User
PU  = "S-1-5-32-547"
'Account Operators 
AO = "S-1-5-32-548"
'Print Operators 
PO = "S-1-5-32-550"
'Backup Operators
BO = "S-1-5-32-551"

strComputer = "."
'************************************************************************************
'ENumerates System Name
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
Set objTextFile = objFSO.OpenTextFile ("c:\dcom\dcom1.txt", ForAppending, True)
For Each objItem in colItems
objTextFile.WriteLine(objItem.SystemName)
Next
objTextFile.Close
'****************************************************************************************
'Enumerates what Operation System and Service Pack
on Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
Set objTextFile = objFSO.OpenTextFile ("dcom1.txt", ForAppending, True)
For Each objItem in colItems
objTextFile.WriteLine(objItem.Caption & vbTab & "Service Pack: " & objItem.ServicePackMajorVersion)
Next
objTextFile.Close
'************************************************************************************************
'Enumerates the DCOM Application ID, Application Name and RunAs configuration
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DCOMApplicationSetting",,48)
Set objTextFile = objFSO.OpenTextFile ("dcom1.txt", ForAppending, True)
For Each objItem in colItems
objTextFile.WriteLine(objItem.AppID & vbTab & ObjItem.Description & vbTab & objItem.RunAsUser)
Next
objTextFile.Close
'**************************************************************************************************
'Enumerates DCOM Launch Permissions
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DCOMApplicationLaunchAllowedSetting", "WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)
Set objTextFile = objFSO.OpenTextFile ("dcom1.txt", ForAppending, True)
For Each objItem in colItems
objTextFile.WriteLine(objItem.Element & vbTab & objItem.Setting)

LP = ObjItem.Setting
Next
'*******************************************************************************************************
' reads the contents of the DCOM1.txt file into an Array
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("dcom1.txt", ForReading)
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrdcomList = Split(strNextLine , ",")
    Wscript.Echo "dcom setting: " & arrdcomList(0)

Thank You in advance for the Help --John


_______________________________________________
Plugins-writers mailing list
Plugins-writers@private
http://mail.nessus.org/mailman/listinfo/plugins-writers



This archive was generated by hypermail 2.1.3 : Fri Sep 01 2006 - 03:52:37 PDT