Sign in to follow this  
Followers 0
pinkbits

Convert VBS to AutoIT

5 posts in this topic

Hey, I found this and am trying to convert it to AutoIT.

So far I've managed to cock it up and am completely lost.

What I'm trying to convert:

CODE
Rem lookup digital product id from registry

Set WshShell = WScript.CreateObject("WScript.Shell")

HexBuf = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")

For l = lBound(HexBuf) to uBound(HexBuf)

tmp=tmp & " "& Hex (HexBuf(l))

next

WshShell.Popup tmp

WshShell.Popup "Found Digital Product Id in registry:-" & _

" " & _

" " & _

" " & tmp

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

WshShell.Popup "Found Digital Product Id in registry:-" & _

" " & _

" " & _

" " & tmp & _

" " & _

" " & _

" " & _

" " & _

"Located the sequence in the digital product ID. Can you see it in the one above (Tip:- 2nd line, 8 in from the left) :- " & _

" " & _

" " & tmp2

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)

WScript.Echo "Having finished messing about performing mathmatical stuff" & _

" on your Product ID i have come to the conclusion your XP Key is:- " & _

" " & KEYSTRING2

What I've written so far:

CODE

#include <array.au3>

Global $HexBuffer = StringTrimLeft(String(RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")), 2)

Global $aASCArray = StringSplit($HexBuffer, '')

Global $tmp = ''

Global $tmp2 = ''

Global $i = ''

Global $aDigits[24]

$aDigits[0] = "B"

$aDigits[1] = "C"

$aDigits[2] = "D"

$aDigits[3] = "F"

$aDigits[4] = "G"

$aDigits[5] = "H"

$aDigits[6] = "J"

$aDigits[7] = "K"

$aDigits[8] = "M"

$aDigits[9] = "P"

$aDigits[10] = "Q"

$aDigits[11] = "R"

$aDigits[12] = "T"

$aDigits[13] = "V"

$aDigits[14] = "W"

$aDigits[15] = "X"

$aDigits[16] = "Y"

$aDigits[17] = "2"

$aDigits[18] = "3"

$aDigits[19] = "4"

$aDigits[20] = "6"

$aDigits[21] = "7"

$aDigits[22] = "8"

$aDigits[23] = "9"

Global $dLen = 29, $sLen = 15

Global $HexDigitalPID[15]

Global $Des[30]

Global $iStartOffset = 52

Global $iEndOffset = 67

For $i = 1 To $aASCArray[0] Step 2

$tmp = $tmp & " " & Hex($aASCArray[$i] & $aASCArray[$i + 1],2)

Next

msgbox(0,'',$tmp)

I'm having issues just trying to put the reg key out to the tmp. I've split the reg into $aArray using stringsplit as the vbscript seems to be able to reference a hex like an array. My digitalproductid has an A4 at the start, but when I try adding it into the tmp string, it comes up as 0, it's the only one, all of the others play nice.

Also with the $aDigits array I'd like to know if it's possible to declare all of the array contents at the start.

I'm going batty... please help!

Share this post


Link to post
Share on other sites



I tried your code but I'm not reading $HexBuffer (it returns blank) so I can't help much.

For your other question try this:

$aDigits[24] = ["B", "C", "D", .... "9"]

I should've mentioned, this needs to be run on a Windows XP machine.

I've already tried declaring the array like that and it threw me a syntax error.

Share this post


Link to post
Share on other sites

There has already been written scripts that does this, you could find one of those and compare it with yours to see what is wrong (tip: search for DigitalProductId)

You're a champ. Admins feel free to close this topic.

Anyone who looks at this: http://www.autoitscript.com/forum/index.ph...igitalProductId is the solution.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0