level 1
牛头寨
楼主
procedure TForm7.Button1Click(Sender: TObject);
var
slDBpath,title,encrypted_value: string;
sldb: TSQLiteDatabase;
sltb: TSQLIteTable;
sSQL: String;
i,nums:integer;
DataCheck: DATA_BLOB;
encrypstr:string;
bs : TMemoryStream;
DataBlobOut,DataBlobIn:DATA_BLOB;
DataIn,DataOut:TBytes;
begin
slDBPath := 'F:\abc.sqlite3';
sldb := TSQLiteDatabase.Create(slDBPath);
bs:=TMemoryStream.Create ;
try
sSQL := 'select host_key,name,encrypted_value from cookies where host_key like ''%.suning.com%'' limit 2';
//showmessage(sSQL);
sltb := slDb.GetTable(sSQL);
try
nums := sltb.Count;
if sltb.Count > 0 then
begin
for i:=0 to nums-1 do
begin
//encrypstr := s;
//encrypstr := TidURI.URLDecode(encrypstr);
//DecryptString(sltb.FieldAsBlob(sltb.FieldByName('encrypted_value')));
encrypted_value := sltb.FieldAsBlobText(sltb.FieldIndex['encrypted_value']);
memo1.Lines.Add(encrypted_value);
DataIn:=TEncoding.UTF8.GetBytes(encrypted_value);
ZeroMemory(@DataBlobIn,SizeOf(DataBlobIn));
DataBlobIn.cbData:=Length(DataIn);
DataBlobIn.pbData:=@DataIn[0];
if CryptUnprotectData(@DataBlobIn,nil,nil,nil,nil,CRYPTPROTECT_LOCAL_MACHINE,@DataBlobOut)then
try
//DecryptString(sltb.FieldAsBlob(sltb.FieldIndex['encrypted_value']));
SetLength(DataOut,DataBlobOut.cbData);
Move(DataBlobOut.pbData^,DataOut[1],DataBlobOut.cbData);
memo1.Lines.Add(TEncoding.UTF8.Getstring(DataOut[1]));
finally
LocalFree(HLOCAL(DataBlobOut.pbData));
RaiseLastosError;
end;
//memo1.Lines.add(encrypstr);
//blobF := sltb.FieldByName('encrypted_value') as TBlobField;
//DecryptString(sltb.FieldAsBlob['encrypted_value']);
//memo1.Lines.add(sltb.FieldAsString(sltb.FieldIndex['name']));
//memo1.Lines.add(sltb.FieldAsString(sltb.FieldAsBlobText['encrypted_value']));
sltb.Next;
end;
end;
finally
sltb.Free;
end;
finally
end;
end;
2023年05月03日 12点05分
1
var
slDBpath,title,encrypted_value: string;
sldb: TSQLiteDatabase;
sltb: TSQLIteTable;
sSQL: String;
i,nums:integer;
DataCheck: DATA_BLOB;
encrypstr:string;
bs : TMemoryStream;
DataBlobOut,DataBlobIn:DATA_BLOB;
DataIn,DataOut:TBytes;
begin
slDBPath := 'F:\abc.sqlite3';
sldb := TSQLiteDatabase.Create(slDBPath);
bs:=TMemoryStream.Create ;
try
sSQL := 'select host_key,name,encrypted_value from cookies where host_key like ''%.suning.com%'' limit 2';
//showmessage(sSQL);
sltb := slDb.GetTable(sSQL);
try
nums := sltb.Count;
if sltb.Count > 0 then
begin
for i:=0 to nums-1 do
begin
//encrypstr := s;
//encrypstr := TidURI.URLDecode(encrypstr);
//DecryptString(sltb.FieldAsBlob(sltb.FieldByName('encrypted_value')));
encrypted_value := sltb.FieldAsBlobText(sltb.FieldIndex['encrypted_value']);
memo1.Lines.Add(encrypted_value);
DataIn:=TEncoding.UTF8.GetBytes(encrypted_value);
ZeroMemory(@DataBlobIn,SizeOf(DataBlobIn));
DataBlobIn.cbData:=Length(DataIn);
DataBlobIn.pbData:=@DataIn[0];
if CryptUnprotectData(@DataBlobIn,nil,nil,nil,nil,CRYPTPROTECT_LOCAL_MACHINE,@DataBlobOut)then
try
//DecryptString(sltb.FieldAsBlob(sltb.FieldIndex['encrypted_value']));
SetLength(DataOut,DataBlobOut.cbData);
Move(DataBlobOut.pbData^,DataOut[1],DataBlobOut.cbData);
memo1.Lines.Add(TEncoding.UTF8.Getstring(DataOut[1]));
finally
LocalFree(HLOCAL(DataBlobOut.pbData));
RaiseLastosError;
end;
//memo1.Lines.add(encrypstr);
//blobF := sltb.FieldByName('encrypted_value') as TBlobField;
//DecryptString(sltb.FieldAsBlob['encrypted_value']);
//memo1.Lines.add(sltb.FieldAsString(sltb.FieldIndex['name']));
//memo1.Lines.add(sltb.FieldAsString(sltb.FieldAsBlobText['encrypted_value']));
sltb.Next;
end;
end;
finally
sltb.Free;
end;
finally
end;
end;