博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS Cookies.binarycookies(俗称63数据)存取
阅读量:4149 次
发布时间:2019-05-25

本文共 1972 字,大约阅读时间需要 6 分钟。

 

iOS 系统会自动将Safari或APP中网络请求的cookie保存为文件,APP的cookie保存路径为

APP的沙盒路径:var/mobile/Containers/Data/Application/x-x-x/Library/Cookies/Cookies.binarycookies
Cookies.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

Page(可以理解为cookie属性中domain,即相同domain的cookie保存在一个page里

字段 大小端 类型 大小 备注
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

Cookie

字段 大小端 类型 大小 备注
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

上面的Creation字段指的是,保存cookie这一时刻相对于2001/1/1 00:00:00的时间戳
Expiration指:如果cookie有max-age属性,Creation + max-age;如果cookie有expires属性,为expires转为时间戳
了解文件结构后,具体存取就很简单了,只要按照结构进行字节操作就可以了,不再赘述。

 

 

 

转载地址:http://xyxti.baihongyu.com/

你可能感兴趣的文章
Learn to speak vim – verbs, nouns, and modifiers!
查看>>
vim删除^M
查看>>
STM32 配置PC13~PC15
查看>>
vim 搜索替换
查看>>
Openocd 安装并在Eclipse环境下通过J-Link调试
查看>>
浅谈Kafka快速读写机制
查看>>
Python 3
查看>>
变量和替换
查看>>
引用和流程控制
查看>>
getopts用法
查看>>
关于char *ptr;
查看>>
该死的IFS变量
查看>>
ls的详解
查看>>
例析#define
查看>>
C写的实现wc和ls函数
查看>>
一个汉字真的由两个字节存放吗?
查看>>
查看ubuntu的温度
查看>>
ubuntu下j在安装ava环境
查看>>
使用优盘装系统
查看>>
整型数据和字符串数据相互转化代码
查看>>