本文共 1972 字,大约阅读时间需要 6 分钟。
iOS 系统会自动将Safari或APP中网络请求的cookie保存为文件,APP的cookie保存路径为
APP的沙盒路径:var/mobile/Containers/Data/Application/x-x-x/Library/Cookies/Cookies.binarycookiesCookies.binarycookies是二进制文件,文件结构有个魔术头:字符串:“cook”,二进制为636f6f6b,所以Cookies.binarycookies数据又被称为63数据。要对文件内容进行存取,首先得了解文件结构:字段 | 大小端 | 类型 | 大小 | 备注 |
Magic | 大端 | UTF-8 | 4 | "cook", no terminator |
Number of pages | 大端 | Unsigned Int | 4 | |
Page N size | 大端 | Unsigned Int | 4 | Repeat for N pages |
Page | Page N size | Page N content |
字段 | 大小端 | 类型 | 大小 | 备注 |
Header | 大端 | 4 | 0x00000100 | |
Number of cookies | 小端 | Unsigned Int | 4 | |
Cookie N offset | 小端 | Unsigned Int | 4 | Repeat for N cookies |
Footer | 4 | 0x00000000 | ||
Cookie N | Cookie N size | Cookie N content |
字段 | 大小端 | 类型 | 大小 | 备注 |
Size | 小端 | Unsigned Int | 4 | Size in bytes |
Version | 小端 | Unsigned Int | 4 | 0 or 1 |
Flags | 小端 | Bit field | 4 | isSecure = 1, isHTTPOnly = 1 << 2, unknown1 = 1 << 3, unknown2 = 1 << 4 |
Has port | 小端 | Unsigned Int | 4 | 0 or 1 |
URL Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie |
Name Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie |
Path Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie |
Value Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie |
Comment Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie, 0x00000000 if not present |
Comment URL Offset | 小端 | Unsigned Int | 4 | Offset from the start of the cookie, 0x00000000 if not present |
Expiration | 小端 | Double | 8 | Number of seconds since 00:00:00 UTC on 1 January 2001 |
Creation | 小端 | Double | 8 | Number of seconds since 00:00:00 UTC on 1 January 2001 |
Port | 小端 | Unsigned Int | 2 | Only present if the "Has port" field is 1 |
Comment | 小端 | String | Null-terminated, optional | |
Comment URL | 小端 | String | Null-terminated, optional | |
URL | 小端 | String | Null-terminated | |
Name | 小端 | String | Null-terminated | |
Path | 小端 | String | Null-terminated | |
Value | 小端 | String | Null-terminated |
转载地址:http://xyxti.baihongyu.com/