诛仙3挖宝任务:如何获取HttpOnly Cookie
来源:百度文库 编辑:九乡新闻网 时间:2024/05/08 19:04:52
1、更改webbrowser的cookie路径
2、延时1秒,启动webbrowser
3、更改webbrowser的cookie路径为原来的
4、登录账号
5、记录下cookie
6、设置cookie, internetsetcookie
7、测试是否成功
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses unitFunc;
function GetIECookiePath():string;
var
UserProfile :string;
Key ,Name ,CookiePath ,CachePath :string;
begin
UserProfile := GetEnvironmentVariable('USERPROFILE'); //获取环境变量
//...1、Cookies 文件夹路径
Key := 'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders';
Name := 'Cookies';
CookiePath := regRead(HKEY_CURRENT_USER ,Key ,Name);
CookiePath := StringReplace(CookiePath,'%USERPROFILE%',UserProfile,[rfReplaceAll]);
//...2、Cache 文件夹路径
Key := 'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders';
Name := 'Cache';
CachePath := regRead(HKEY_CURRENT_USER ,Key ,Name);
CachePath := StringReplace(CachePath,'%USERPROFILE%',UserProfile,[rfReplaceAll]);
Result := CookiePath;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CookiePath :string;
fs :TFileStream;
ms :TMemoryStream;
ss :TStringStream;
begin
CookiePath := GetIECookiePath + '\index.dat';
fs := TFileStream.Create(CookiePath,fmShareDenyNone);
ms := TMemoryStream.Create;
ss := TStringStream.Create('');
try
fs.Position := 0;
ms.CopyFrom(fs,fs.Size);
fs.Position := 0;
ss.CopyFrom(fs,fs.Size);
finally
fs.Free;
end;
memo1.Text := ss.DataString;
ss.Free;
ms.Free;
end;
end.