25. marts 2006 - 20:51Der er
15 kommentarer og 1 løsning
Udlæse product key på en Windows XP
Jeg er på MS hjemmeside faldet over et VB script, hvormed man kan ændre sin product key. I samme forbindelse faldt jeg over et lille program, som kunne udlæse den indtastede product key.
Er der nogen der kan hjælpe mig med, hvorfra jeg kan udlæse den indtastede product key samt ændre et VB script til Delphi-kode. (VB scriptet benyttet WMI)
I dette særtema om aspekter af AI ser vi på skiftet fra sprogmodeller til AI-agenter, og hvordan virksomheder kan navigere i spændet mellem teknologisk hastighed og behovet for menneskelig kontrol.
' ' WMI Script - ChangeVLKey.vbs ' ' This script changes the product key on the computer ' '***************************************************************************
ON ERROR RESUME NEXT
if Wscript.arguments.count<1 then Wscript.echo "Script can't run without VolumeProductKey argument" Wscript.echo "Correct usage: Cscript ChangeVLKey.vbs ABCDE-FGHIJ-KLMNO-PRSTU-WYQZX" Wscript.quit end if
Dim VOL_PROD_KEY VOL_PROD_KEY = Wscript.arguments.Item(0) VOL_PROD_KEY = Replace(VOL_PROD_KEY,"-","") 'remove hyphens if any
for each Obj in GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation")
result = Obj.SetProductKey (VOL_PROD_KEY)
if err <> 0 then WScript.Echo Err.Description, "0x" & Hex(Err.Number) Err.Clear end if
Det er et super program, men jeg har fundet et program, der kan udlæse nøglen, i den forbindelse blev jeg nysgerrig og kunne derfor godt tænke mig, at lave mit eget lille program, der kan klare begge dele :-)
oh, så er vi ude i at skulle omdanne produktnøglen til hexadecimale værdier. den gemmes under HKEY_LOCAL_MACHINE\software\microsoft\windows nt\current version, i nøglen DigitalproductId :-)
Retrieves a binary value from a specified data value associated with the current key.
Delphi syntax:
function ReadBinaryData(const Name: String; var Buffer; BufSize: Integer): Integer;
C++ syntax:
int __fastcall ReadBinaryData(const AnsiString Name, void *Buffer, int BufSize);
Description
Call ReadBinaryData to read a binary value from a specified data value associated with the current key. Name is the name of the data value to read. Buffer is the application variable into which to read the registry data. Buffer must be large enough to hold all of the data returned. BufSize specifies the size of Buffer.
If successful, ReadBinaryData writes the requested data into Buffer and returns the number of bytes written. If the Registry entry contains a known type (such as a string), ReadBinaryData raises an exception.
Note: Binary data is typically a complex data structure (a record in Delphi or struct in C++). It might also be an icon or a bitmap although Microsoft recommends against storing graphics objects in the registry for performance reasons.
Jeg har fundet en funktion, der dekoder nøglen for mig.
function DecodeProductKey(const HexSrc: array of byte): string; const StartOffset: integer = $34; { //Offset 34 = Array[52] } EndOffset: integer = $34 + 15; { //Offset 34 + 15(Bytes) = Array[64] } Digits: array[0..23] of char = ('B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'); dLen: integer = 29; { //Length of Decoded Product Key } sLen: integer = 15; { //Length of Encoded Product Key in Bytes (An total of 30 in chars) } var HexDigitalPID: array of cardinal; Des: array of char; I, N: integer; HN, Value: cardinal; begin SetLength(HexDigitalPID, dLen); for I := StartOffset to EndOffset do begin HexDigitalPID[I - StartOffSet] := HexSrc[I]; end; SetLength(Des, dLen + 1); for I := dLen - 1 downto 0 do begin if (((I + 1) mod 6) = 0) then Des[I] := '-' else begin HN := 0; for N := sLen - 1 downto 0 do begin Value := (HN shl 8) or HexDigitalPID[N]; HexDigitalPID[N] := value div 24; HN := Value mod 24; end; Des[I] := Digits[HN]; end; end; Des[dLen] := Chr(0); for I := 0 to Length(Des) do begin Result := Result + Des[I]; end; end;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.