leoshiang
New Member
Posts: 1
Joined: May 2012
|
O.P. A tool to decrypt .ple files
hi All,
This is a tool I wrote to decrypt .ple files. The usage is
PLEDecryptor filename password
where
filename --> the ple file name
password --> your password
PLEDecryptor will decrypt to ple file and create a .txt file.
Below is part of my sour code.
code: procedure DecryptFile(const FileName, Password: string);
var
BlockSize: Cardinal;
Buffer: TBytes;
DataLen: Cardinal;
DataLength: Cardinal;
DataSize: Int32;
FileHeader: TPLE2Header;
IsEndOfFile: Boolean;
Mark: Int16;
OutputStream: TFileStream;
PasswordKey: HCRYPTKEY;
PrivateKey: HCRYPTKEY;
PublicKey: HCRYPTKEY;
SourceStream: TFileStream;
UnicodePassword: WideString;
hProv: HCRYPTPROV;
hash: HCRYPTHASH;
begin
UnicodePassword := Password;
SourceStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
SetLength(Buffer, 8192);
SourceStream.Read(FileHeader, SizeOf(FileHeader));
if (not CompareMem(@FileHeader, @MPLE2, SizeOf(FileHeader))) then
Halt(GetLastError);
SourceStream.Position := SourceStream.Position + $E0;
if not CryptAcquireContextW(hProv, 'Messenger Plus! Crypto', MS_ENH_RSA_AES_PROV, PROV_RSA_AES, 0) then
Halt(GetLastError);
SourceStream.Read(DataLength, SizeOf(DataLength));
SourceStream.Read(Buffer[0], DataLength);
if not CryptImportKey(hProv, @Buffer[0], DataLength, 0, 0, PublicKey) then
Halt(GetLastError);
if not CryptCreateHash(hProv, CALG_SHA, 0, 0, hash) then
Halt(GetLastError);
if not CryptHashData(hash, @UnicodePassword[1], Length(UnicodePassword) * SizeOf(UnicodePassword[1]), 0) then
Halt(GetLastError);
if not CryptDeriveKey(hProv, CALG_AES_256, hash, 16777216, PasswordKey) then
Halt(GetLastError);
SourceStream.Read(DataLength, SizeOf(DataLength));
SourceStream.Read(Buffer[0], DataLength);
if not CryptImportKey(hProv, @Buffer[0], DataLength, PasswordKey, 0, PrivateKey) then
Halt(GetLastError);
SourceStream.Read(Buffer[0], 1);
SourceStream.Read(BlockSize, 4);
SourceStream.Read(Buffer[0], BlockSize);
DataLen := BlockSize;
if not CryptDecrypt(PrivateKey, 0, False, 0, @Buffer[0], DataLen) then
Halt(GetLastError);
OutputStream := TFileStream.Create(ChangeFileExt(FileName, '.txt'), fmCreate);
try
OutputStream.Write(Buffer[0], DataLen);
repeat
SourceStream.Read(Mark, 2);
SourceStream.Read(DataSize, 4);
while (DataSize > 0) do
begin
SourceStream.Read(Buffer[0], BlockSize);
Dec(DataSize, BlockSize);
IsEndOfFile := (DataSize = 0);
DataLen := BlockSize;
if not CryptDecrypt(PrivateKey, 0, IsEndOfFile, 0, @Buffer[0], DataLen) then
Halt(GetLastError);
OutputStream.Write(Buffer[0], DataLen);
end;
until (SourceStream.Position >= SourceStream.Size);
finally
OutputStream.Free;
end;
finally
SourceStream.Free;
end;
end;
Attachment: PLEDecrypter.rar (121.22 KB)
This file has been downloaded 1024 time(s).
|
|