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 5:49 am

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Added more CD Keys
PostPosted: Fri Sep 23, 2011 6:51 am 
Offline
Newbie

Joined: Thu Sep 22, 2011 5:20 am
Posts: 7
Below is code to add CD Keys for Microsoft Visual Studio 2005, 2008, and 2010, as well as Microsoft SQL Server 2005 (2000 and 2008 was included). I originally wrote it for OAv1, and re-wrote it for OAv2....

[code]''''''''''''''''''''''''''''''''
' SQL Svr 2005 '
''''''''''''''''''''''''''''''''
strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID\"
key_name = "Microsoft SQL Server 2005"
key_release = ""
key_edition = ""
subKey = "DigitalProductID77556"
key_text = GetSN(strComputer,HKEY_LOCAL_MACHINE,strKeyPath,subKey)
if IsNull(key_text) or key_text = "" then
strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\Setup\"
subKey = "DigitalProductID"
key_text = GetSN(strComputer,HKEY_LOCAL_MACHINE,strKeyPath,subKey)
if IsNull(key_text) or key_text = "" then
else
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if
else
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if[/code]

[code]''''''''''''''''''''''''''''''''
' Visual Studio 2010 '
''''''''''''''''''''''''''''''''
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Registration"
key_name = "Microsoft Visual Studio 2010"
key_release = ""
key_edition = ""
subKey = "ProductID"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,subKey,key

If IsNull(key) OR key = "" then
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Registration\01018"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,subKey,key
if IsNull(key) OR key = "" then
else
key_text = key
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if
else
key_text = key
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if


''''''''''''''''''''''''''''''''
' Visual Studio 2008 '
''''''''''''''''''''''''''''''''
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Registration"
key_name = "Microsoft Visual Studio 2008"
key_edition = ""
key_release = ""
subKey = "ProductID"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,subKey,key_text
if IsNull(key_text) or key_text = "" then
' do nothing
else
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if


''''''''''''''''''''''''''''''''
' Visual Studio 2005 '
''''''''''''''''''''''''''''''''
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\8.0\Registration"
key_name = "Microsoft Visual Studio 2005"
key_edition = ""
key_release = ""
subKey = "ProductID"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,subKey,key_text
if IsNull(key_text) or key_text = "" then
' do nothing
else
result = result & " <key>" & vbcrlf
result = result & " <key_name>" & escape_xml(key_name) & "</key_name>" & vbcrlf
result = result & " <key_text>" & escape_xml(key_text) & "</key_text>" & vbcrlf
result = result & " <key_release>" & escape_xml(key_release) & "</key_release>" & vbcrlf
result = result & " <key_edition>" & escape_xml(key_edition) & "</key_edition>" & vbcrlf
result = result & " </key>" & vbcrlf
key_text = ""
key_release = ""
key_edition = ""
end if[/code]

[code]Function GetSN(sComputer,sRoot,sKeyPath,sValueName)
On Error Resume Next
Set objRegistry = GetObject("winmgmts:\\" & sComputer & "\root\default:StdRegProv")
If Err.Number = 0 Then
'On Error Resume Next
'HexBuf = WshShell.RegRead(sRegLocation)
intReturn = objRegistry.GetBinaryValue(sRoot, sKeyPath, sValueName, Hexbuf)
If intReturn = 0 Then
'If Err.Number = 0 Then
'On Error GoTo 0
For l = LBound(HexBuf) To UBound(HexBuf)
tmp=tmp & " "& Hex (HexBuf(l))
Next

StartOffset = 52
EndOffset =67
Dim Digits (24)

Digits (0) = "B" : Digits (1) = "C": Digits (2) = "D": Digits (3) = "F":
Digits (4) = "G": Digits (5) = "H": Digits (6) = "J": Digits (7) = "K":
Digits (8) = "M": Digits (9) = "P": Digits (10) = "Q": Digits (11) = "R":
Digits (12) = "T": Digits (13) = "V": Digits (14) = "W": Digits (15) = "X":
Digits (16) = "Y": Digits (17) = "2": Digits (18) = "3": Digits (19) = "4":
Digits (20) = "6" : Digits (21) = "7" : Digits (22) = "8": Digits (23) = "9"

dLen = 29
sLen = 15
Dim HexDigitalPID (15)
Dim Des (30)
For i = StartOffset To EndOffset
HexDigitalPID (i-StartOffset) = HexBuf(i)
tmp2=tmp2 & " "& Hex (HexDigitalPID(i-StartOffset))
Next

KEYSTRING =""
For i=dLen-1 To 0 Step -1
If ((i + 1) mod 6) = 0 Then
Des (i) = "-"
KEYSTRING =KEYSTRING & "-"
Else
HN = 0
For N = (sLen -1) To 0 Step -1
Value = ( (HN *2^8 ) Or HexDigitalPID (N))
HexDigitalPID (N) = Value \ 24
HN = (Value mod 24)
Next
Des(i) = Digits(HN)
KEYSTRING =KEYSTRING & Digits(HN)
End If
Next
KEYSTRING2 = StrReverse (KEYSTRING)
GetSN = KEYSTRING2
Else
'Err.Clear
'On Error GoTo 0
'GetSN = sProduct & " is not installed"
End If
Else
Err.Clear
On Error GoTo 0
'GetSN = "Error reading registry of " & sComputer
End If
End Function[/code]

I always included [code]OR key = "" then[/code] because sometimes the function would catch keys as "" but not null and insert that into the database.

Also, for Visual Studio 2010 and SQL Server 2005 I have 2 possible paths as depending on the Windows version and such, they were found in 2 different locations.


Top
 Profile  
Reply with quote  
 Post subject: Re: Added more CD Keys
PostPosted: Thu Oct 06, 2011 12:16 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
Have added to my version of the audit_windows script.
Thanks a heap.
Will be in next release.

_________________
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.  [ 2 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:  
Powered by phpBB® Forum Software © phpBB Group