【原创】Firda+typescript 读取XX联系人列表

这段代码展示了如何利用Frida动态分析工具,读取微信(WeChatWin.dll,版本3.6.0.18)的内存来获取联系人链表。通过指定的内存偏移量,代码解析链表结构,提取联系人的序号、微信号、昵称等关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

直接上代码
联系人链表,数据读取

class WeChatContract {
    private moudule_name: string = "WeChatWin.dll";
    private wechat_version: string = "3.6.0.18";
    private moudule: Module;
    private contract_offset: number = 0;
    private welcome() {
        console.log("======================", new Date().toISOString(), "==========================");
        console.log("Frida.version\t\t\t", Frida.version);
        console.log("Frida.heapSize\t\t\t", Frida.heapSize);
        console.log("ProcessId\t\t\t", Process.id);
        console.log("ProcessArch\t\t\t", Process.arch);
        console.log("ProcessPlatform\t\t\t", Process.platform);
        console.log("ProcessIsDebuggerAttached\t", Process.isDebuggerAttached());
        console.log("ProcessPointerSize\t\t", Process.pointerSize);
        console.log("ProcessCodeSigningPolicy\t", Process.codeSigningPolicy);
        console.log('BaseAddress\t\t\t', this.moudule.base);
        console.log(`This script only run for Wechat ${this.wechat_version} by Frida`);
    }

    constructor() {
        this.moudule = Process.getModuleByName(this.moudule_name);
        if (this.moudule == undefined) {
            throw Error(`${this.moudule_name} was not found!`);
        }
        this.welcome();
        this.contract_offset = 0x222F3BC;
    }

    get contract_count() {
        // console.log("联系人信息");

        // let contract_offset = 0x222F3BC;
        // console.log("偏移\t\t", "0x" + offset.toString(16).padStart(8, 0));

        let list_header = this.moudule.base.add(this.contract_offset);
        // console.log("地址\t\t", list_header);

        // +0x50指向链表联系人的数量
        return list_header.readPointer().add(0x50).readS32();
    }

    contract_list(startIndex: number = 1, contract_count: number = 100) {
        if (contract_count > 100) {
            throw Error(`每次取值范围,最多100个`);
        }

        if (startIndex < 1) {
            throw Error(`start index  must > 0`);
        }

        let count = this.contract_count;
        if (contract_count + startIndex > count) {
            contract_count = count - startIndex;
        }

        let index = 0;
        let contract_info = [];
        //+0x4C指向链表开始的地方
        let list_head = this.moudule.base.add(this.contract_offset).readPointer().add(0x4C).readPointer();
        // console.log("list_head\t\t", list_head);
        let list_next = list_head.readPointer();
        // console.log("list_next\t\t", list_next);
        while (list_next != list_head) {
            index++;
            if (index > startIndex) {
                contract_info.push(this.get_contract_info(index, list_next));
                contract_count--;
                if (contract_count <= 0) {
                    break;
                }
            }
            list_next = list_next.readPointer();
        }
        return contract_info;
    }

    private get_contract_info(index: number, pointer: NativePointer) {
        let contract_info = [];
        let data: any = "";

        //序号
        contract_info.push(index - 1);
        // $ ==>    >125C2708
        // $+4      >092C37D8
        // $+8      >11C0A1F8  ASCII "wxid_75p64xas84ye12"
        // $+C      >67003733
        // $+10     >006E696D
        // $+14     >00003432
        // $+18     >00000013
        // $+1C     >0000001F
        // $+20     >7B62E9E4  WeChatWi.7B62E9E4
        // $+24     >00000000
        // $+28     >00000000
        // $+2C     >00000000
        // $+30     >11CB6538  UNICODE "wxid_75p64xas84ye12"
        data = pointer.add(0x30).readPointer().readUtf16String();
        contract_info.push(data);
        // console.log(data);
        // $+34     >00000013
        // $+38     >00000013
        // $+3C     >00000000
        // $+40     >00000000
        // $+44     >11BF2E20  UNICODE "zyjl1021"
        data = pointer.add(0x44).readPointer().readUtf16String();
        contract_info.push(data);
        // console.log(data);
        // $+48     >00000008
        // $+4C     >00000008
        // $+50     >00000000
        // $+54     >00000000
        // $+58     >00000000
        // $+5C     >00000000
        // $+60     >00000000
        // $+64     >00000000
        // $+68     >00000000
        // $+6C     >00000000
        // $+70     >0000000B
        // $+74     >00000000
        // $+78     >00000000
        // $+7C     >00000000
        // $+80     >00000000
        // $+84     >00000000
        // $+88     >00000000
        // $+8C     >11C0D1E8  UNICODE "爱笑的眼睛"
        data = pointer.add(0x8c).readPointer().readUtf16String();
        contract_info.push(data);
        // console.log(data);
        // $+90     >00000005
        // $+94     >00000005
        // $+98     >00000000
        // $+9C     >00000000
        // $+A0     >00000000
        // $+A4     >00000000
        // $+A8     >00000000
        // $+AC     >00000000
        // $+B0     >00000000
        // $+B4     >00000000
        // $+B8     >00000000
        // $+BC     >00000000
        // $+C0     >00000000
        // $+C4     >00000000
        // $+C8     >00000000
        // $+CC     >11C0D110  UNICODE "AXDYJ"
        // $+D0     >00000005
        // $+D4     >00000005
        // $+D8     >00000000
        // $+DC     >00000000
        // $+E0     >11C0A1D0  UNICODE "aixiaodeyanjing"
        // $+E4     >0000000F
        // $+E8     >0000000F
        // $+EC     >00000000
        // $+F0     >00000000
        // $+F4     >00000000
        // $+F8     >00000000
        // $+FC     >00000000
        // $+100    >00000000
        // $+104    >00000000
        // $+108    >00000000
        // $+10C    >00000000
        // $+110    >00000000
        // $+114    >00000000
        // $+118    >00000000
        // $+11C    >00000000
        // $+120    >00000000
        // $+124    >00000000
        // $+128    >00000000
        // $+12C    >00000000
        // $+130    >00000000
        // $+134    >00000000
        // $+138    >00000000
        // $+13C    >00000000
        // $+140    >00000000
        // $+144    >00000000
        // $+148    >00000000
        // $+14C    >00000000
        // $+150    >00000000
        // $+154    >00000000
        // $+158    >0000000F
        // $+15C    >00000000
        // $+160    >00000000
        // $+164    >00000001
        // $+168    >00000001
        // $+16C    >00000000
        // $+170    >11C138D8
        // $+174    >00000179
        // $+178    >00000000
        // $+17C    >00000000
        // $+180    >00000000
        // $+184    >00000000
        // $+188    >00000000
        // $+18C    >00000000
        // $+190    >00000000
        // $+194    >00000000
        // $+198    >00000000
        // $+19C    >00000000
        // $+1A0    >00000000
        // $+1A4    >00000000
        // $+1A8    >00000000
        // $+1AC    >00000000
        // $+1B0    >00000000
        // $+1B4    >00000000
        // $+1B8    >00000000
        // $+1BC    >00000000
        // $+1C0    >00000000
        // $+1C4    >00000000
        // $+1C8    >00000000
        // $+1CC    >00000000
        // $+1D0    >00000000
        // $+1D4    >00000000
        // $+1D8    >00000000
        // $+1DC    >00000000
        // $+1E0    >00000000
        // $+1E4    >00000000
        // $+1E8    >00000000
        // $+1EC    >00000000
        // $+1F0    >00000000
        // $+1F4    >00000000
        // $+1F8    >00000000
        // $+1FC    >00000000
        // $+200    >00000000
        // $+204    >00000000
        // $+208    >00000000
        // $+20C    >00000000
        // $+210    >00000000
        // $+214    >00000000
        // $+218    >00000000
        // $+21C    >00000000
        // $+220    >00000000
        // $+224    >00000000
        // $+228    >00000000
        // $+22C    >00000000
        // $+230    >00000000
        // $+234    >00000000
        // $+238    >00000000
        // $+23C    >00000000
        // $+240    >00000000
        // $+244    >00000000
        // $+248    >00000000
        // $+24C    >00000000
        // $+250    >00000000
        // $+254    >00000000
        // $+258    >00000000
        // $+25C    >00000000
        // $+260    >00000000
        // $+264    >00000000
        // $+268    >00000000
        // $+26C    >00000000
        // $+270    >00000000
        // $+274    >00000000
        // $+278    >00000000
        // $+27C    >00000000
        // $+280    >00000000
        // $+284    >00000000
        // $+288    >00000000
        // $+28C    >00000000
        // $+290    >00000000
        // $+294    >00000000
        // $+298    >00000000
        // $+29C    >00000000
        // $+2A0    >00000000
        // $+2A4    >00000000
        // $+2A8    >00000000
        // $+2AC    >00000000
        // $+2B0    >00000000
        // $+2B4    >00000000
        // $+2B8    >00000000
        // $+2BC    >00000000
        // $+2C0    >00000000
        // $+2C4    >00000000
        // $+2C8    >00000000
        // $+2CC    >00000000
        // $+2D0    >00000000
        // $+2D4    >00000000
        // $+2D8    >00000000
        // $+2DC    >00000000
        // $+2E0    >00000000
        // $+2E4    >00000000
        // $+2E8    >00000000
        // $+2EC    >00000000
        // $+2F0    >00000000
        // $+2F4    >00000000
        // $+2F8    >00000000
        // $+2FC    >00000000
        // $+300    >00000000
        // $+304    >00000000
        // $+308    >00000000
        // $+30C    >00000000
        // $+310    >00000000
        // $+314    >00000000
        // $+318    >00000000
        // $+31C    >00000000
        // $+320    >00000000
        // $+324    >00000000
        // $+328    >00000000
        // $+32C    >00000000
        // $+330    >00000000
        // $+334    >00000000
        // $+338    >00000000
        // $+33C    >00000000
        // $+340    >00000000
        // $+344    >00000000
        // $+348    >00000000
        // $+34C    >00000000
        // $+350    >00000000
        // $+354    >00000000
        // $+358    >00000000
        // $+35C    >00000000
        // $+360    >00000000
        // $+364    >00000000
        // $+368    >00000000
        // $+36C    >00000000
        // $+370    >00000000
        // $+374    >00000000
        // $+378    >00000000
        // $+37C    >00000000
        // $+380    >00000000
        // $+384    >00000000
        // $+388    >00000000
        // $+38C    >00000000
        // $+390    >00000000
        // $+394    >00000000
        // $+398    >00000000
        // $+39C    >00000000
        // $+3A0    >00000000
        // $+3A4    >00000000
        // $+3A8    >00000000
        // $+3AC    >00000000
        // $+3B0    >00000000
        // $+3B4    >00000000
        // $+3B8    >00000000
        // $+3BC    >00000000
        // $+3C0    >00000000
        // $+3C4    >00000000
        // $+3C8    >00000000
        // $+3CC    >00000000
        // $+3D0    >00000000
        // $+3D4    >00000000
        // $+3D8    >00000000
        // $+3DC    >00000000
        // $+3E0    >00000000
        // $+3E4    >00000000
        // $+3E8    >00000000
        // $+3EC    >00000000
        // $+3F0    >00000000
        // $+3F4    >00000000
        // $+3F8    >00000000
        // $+3FC    >00000000
        // $+400    >00000000
        // $+404    >00000000
        // $+408    >00000000
        // $+40C    >00000000
        // $+410    >00000000
        // $+414    >00000000
        // $+418    >00000000
        // $+41C    >00000000
        // $+420    >00000000
        // $+424    >00000000
        // $+428    >00000000
        // $+42C    >00000000
        // $+430    >00000000
        // $+434    >00000000
        // $+438    >00000000
        // $+43C    >00000040
        return contract_info;
    }



}
let wechat = new WeChatContract();

let contract_count = wechat.contract_count;
console.log("联系人数量:", contract_count);

let contract_start_index: number = 1;
let contract_number = 100;
let contracts_list = wechat.contract_list(contract_start_index, contract_number);
console.log(`联系人:从第${contract_start_index}个开始取${contract_number}`);
for (const iterator of contracts_list) {
    console.log(JSON.stringify(iterator));
}

视频讲座,请参考《Frida快速入门》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵庆明老师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值