Jump to content

Editing a string


Recommended Posts

The script I use find the Windows product key and that's working fine. What I'm trying to do is edit the code he found so it will display it differently in the Msg Box. What Im trying to do is:

- Add + 7 to each number in the product key

- Add + 14 letters to each letter in the product key ( ex: If it's the letter A then it will change to O )

Wich String command should I use?

Here's my script:

Dim $Bin = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")

$Productkey = DecodeProductKey($Bin)
$StringProduct = String($Productkey)

MsgBox(0,"Product Key","" & $StringProduct)


Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result
    
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    For $i = 1 To 29 Step 2
        $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    For $i = $dlen - 1 To 0 Step - 1
        If Mod(($i + 1), 6) = 0 Then
            $sKey[$i] = "-"
        Else
            $hi = 0
            For $n = $slen - 1 To 0 Step - 1
                $Value = BitOR(BitShift($hi, -8), $bKey[$n])
                $bKey[$n] = Int($Value / 24)
                $hi = Mod($Value, 24)
            Next
            $sKey[$i] = $Digits[$hi + 1]
        EndIf
    Next
    For $i = 0 To 28
        $Result = $Result & $sKey[$i]
    Next
    Return $Result
EndFunc
Edited by J0ker
Link to comment
Share on other sites

  • Moderators

You are probably trying to register someone based on their Product Key, but keep in mind, they can be changed easily (and often).

What do you change any number over 3 with?

What do you change anything "M" and over with?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yep I will be using it as a password but it doesnt matter because if someone change the Product key, the password will change to because the function will get the new product key infos.

What do you change any number over 3 with?

Another number...

What do you change anything "M" and over with?

Another letter...

StringReplace() ?

Edited by J0ker
Link to comment
Share on other sites

  • Moderators

Yep I will be using it as a password but it doesnt matter because if someone change the Product key, the password will change to because the function will get the new product key infos.

Another number...

Another letter...

StringReplace() ?

You're not getting it...

What letter is 14 chars over M?

What number is 7 added to 4?... Now you're in Double digits.

I think it's best if you figure everything out, then ask the questions.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

This is what your exact request looks like to me:

CODE
Dim $Bin = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")

$Productkey = DecodeProductKey($Bin)

$sPKeyAfter = _EnCodeKey($Productkey)

MsgBox(64, 'Info', 'Before:' & @CRLF & $Productkey & @CRLF & 'After:' & @CRLF & $sPKeyAfter)

Func _EnCodeKey($sText, $nNum = 7, $sChar = 14)
    Local $sHold, $sMid
    For $iCC = 1 To StringLen($sText)
        $sMid = StringMid($sText, $iCC, 1)
        If StringIsDigit($sMid) Then
            $sHold &= Int($sMid) + $nNum;$sHold &= StringLeft(Int($sMid) + $nNum, 1)
        ElseIf $sMid <> '-' Then
            $sHold &= Chr(Asc($sMid) + $sChar)
        Else
            $sHold &= $sMid
        EndIf
    Next
    Return $sHold
EndFunc

Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result
   
    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    For $i = 1 To 29 Step 2
        $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    For $i = $dlen - 1 To 0 Step - 1
        If Mod(($i + 1), 6) = 0 Then
            $sKey[$i] = "-"
        Else
            $hi = 0
            For $n = $slen - 1 To 0 Step - 1
                $Value = BitOR(BitShift($hi, -8), $bKey[$n])
                $bKey[$n] = Int($Value / 24)
                $hi = Mod($Value, 24)
            Next
            $sKey[$i] = $Digits[$hi + 1]
        EndIf
    Next
    For $i = 0 To 28
        $Result = $Result & $sKey[$i]
    Next
    Return $Result
EndFuncoÝ÷ Û÷(uæèÄGbµ8b²+&¢·°«r¢êk¡¶,Öî¶;¬µÚ'ßÛd"·'­r^nZºÚ"µÍ[H  ÌÍÐ[HYÔXY
    ][ÝÒÑVWÓÐÐSÓPPÒSIÌLÔÓÑÐTIÌLÓZXÜÜÛÙ   ÌLÕÚ[ÝÜÈ  ÌLÐÝ[Ú[Û][ÝË ][ÝÑYÚ][ÙXÝQ   ][ÝÊBÌÍÔÙXÝÙ^HHXÛÙTÙXÝÙ^J  ÌÍÐ[BÌÍÜÔÙ^PYHÑ[ÛÙRÙ^J  ÌÍÔÙXÝÙ^JBÙÐÞ
    ÌÎNÒ[ÉÌÎNË   ÌÎNÐYÜNÌÎNÈ  [ÈÔ   [È ÌÍÔÙXÝÙ^H [ÈÔ   [È ÌÎNÐYÌÎNÈ [ÈÔ   [È ÌÍÜÔÙ^PYB[ÈÑ[ÛÙRÙ^J   ÌÍÜÕ^   ÌÍÛ[HH
Ë  ÌÍÜÐÚHM
BSØØ[ ÌÍÜÒÛ  ÌÍÜÓZY  ÌÍÛÚH

LH
H   ÌÍÜÐÚJHHJBQÜ  ÌÍÚPÐÈHHÈÝ[Ó[   ÌÍÜÕ^
BBIÌÍÜÓZYHÝ[ÓZY
    ÌÍÜÕ^   ÌÍÚPÐËJBBRYÝ[ÒÑYÚ]
    ÌÍÜÓZY
H[BBIÌÍÜÒÛ [ÏHÝ[ÔYÚ
[
    ÌÍÜÓZY
H
È  ÌÍÛ[KJBBQ[ÙRY   ÌÍÜÓZY  ÉÝÈ  ÌÎNËIÌÎNÈ[BBRYØÊ    ÌÍÜÓZY
HH  ÌÍÛÚ[BBBIÌÍÜÒÛ [ÏHÚ  ÌÍÛÚBBBQ[ÙRYØÊ   ÌÍÜÓZY
H   È  ÌÍÛÚ[BBBIÌÍÜÒÛ [ÏHÚØÊ  ÌÍÜÓZY
H
È  ÌÍÜÐÚBBBQ[ÙBBBBIÌÍÜÒÛ    [ÏHÚØÊ  ÌÍÜÓZY
HH  ÌÍÜÐÚBBBQ[YBQ[ÙBBBIÌÍÜÒÛ [ÏH    ÌÍÜÓZYBQ[YS^T]  ÌÍÜÒÛ[[Â[ÈXÛÙTÙXÝÙ^J    ÌÍÐ[QQ
BØØ[  ÌÍØÙ^VÌMWBØØ[    ÌÍÜÒÙ^VÌWBØØ[   ÌÍÑYÚ]ÖÌBØØ[    ÌÍÕ[YHHØØ[ ÌÍÚHHØØ[   ÌÍÛHØØ[    ÌÍÚHHØØ[   ÌÍÙ[HBØØ[  ÌÍÜÛ[HMBØØ[   ÌÍÔÝ[   ÌÍÑYÚ]ÈHÝ[ÔÜ]
    ][ÝÐÑÒÓTTÖLÍ
ÎI][ÝË   ][ÝÉ][ÝÊB   ÌÍÐ[QQHÝ[ÓZY
    ÌÍÐ[QQL
KÌ
BÜ ÌÍÚHHHÈHÝ  ÌÍØÙ^[
    ÌÍÚHÈHHHXÊÝ[ÓZY
    ÌÍÐ[QQ   ÌÍÚKJB^Ü    ÌÍÚHH    ÌÍÙ[HHÈÝHBY[Ù

    ÌÍÚH
ÈJK
HH[ ÌÍÜÒÙ^VÉÌÍÚWHH ][ÝËI][ÝÂ[ÙB   ÌÍÚHHÜ  ÌÍÛH ÌÍÜÛ[HHÈÝHB   ÌÍÕ[YHH]Ô]ÚY
    ÌÍÚKN
K   ÌÍØÙ^VÉÌÍÛJB    ÌÍØÙ^VÉÌÍÛHH[
    ÌÍÕ[YHÈ
B   ÌÍÚHH[Ù
    ÌÍÕ[YK
B^  ÌÍÜÒÙ^VÉÌÍÚWHH ÌÍÑYÚ]ÖÉÌÍÚH
ÈWB[Y^Ü   ÌÍÚHHÈ  ÌÍÔÝ[H  ÌÍÔÝ[   [È ÌÍÜÒÙ^VÉÌÍÚWB^]    ÌÍÔÝ[[[
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yes I know it we will be in double digit but it doesnt matter.I already thought of that. I dont want to modify the product key into the registry, I just want the product key to be modify in the msg box. I was looking for a specific password for each computer. Every computer have a different Product key number so I took that. I could have taken anything else ( serial, comp specifications). It doesnt matter if it's a double digit cause it will only appear in the msg box like I said. As for the letter, I can make it so if it's ex: Z + 4 letter then it will be D.

EDIT: You posted while I was posting. I will have a look at your scripts, thx!

Edited by J0ker
Link to comment
Share on other sites

  • Moderators

Every computer have a different Product key number so I took that. I could have taken anything else ( serial, comp specifications).

Might want to re-check what you are saying there, 3 of my PCs have the same. As I said in my first post, it can be changed and changed often to whatever the end-user chooses.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Do you think using Windows Serial would be better?

I think you should do some research on UUID ... You'll find that many of us have made attempts in finding a "Unique" string only available to that PC.

If you do what you are doing, anyone could change it, or worse yet for you (if it's important to you) just clone it in a virtual environment and poof, you're measures to password protect are null and void.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

As I can see UUID generate a different number everytime ( ex HERE) I'm in need of a code that will stay the same on a specific computer but will be different for every computer. I could make the UUID launch only one time and store the code in a ini to use it as a password but it would be easy to find. The advantage of something like Serial or Product key is that it stay the same on a certain computer even if the user change it manually.

Edited by J0ker
Link to comment
Share on other sites

  • Moderators

As I can see UUID generate a different number everytime ( ex HERE) I'm in need of a code that will stay the same on a specific computer but will be different for every computer. I could make the UUID launch only one time and store the code in a ini to use it as a password but it would be easy to find. The advantage of something like Serial or Product key is that it stay the same on a certain computer even if the user change it manually.

Most computers have some sort of UUID, if they use WMI they more than likely have one... if you can't do the UUID then you may look at using a MAC address.

Ideally it would be a wondrous world, if WMI didn't pick up the UUID, if you could create and set one with the methods that are presented on the forum where it searches for the UUID to begin with, however, I haven't found a way to do that personally.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...