打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
如何获取HttpOnly Cookie

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.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
delphi操作注册表
用Delphi实现开机自动启动程序_delphi 开机自动启动
Delphi Chromium Embedded
用好软件清理电脑内部垃圾
Windows: 彻底删除本地计算机上的用户
delphi中Webbrowser疑难问题集锦
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服