所有用户应明确知悉,任何利用本博客进行的违反国家法律、行政法规、部门规章以及网络安全相关规定的活动,包括但不限于非法入侵、恶意攻击、传播有害信息(如病毒、恶意软件、色情内容、恐怖主义信息、虚假谣言等)、侵犯他人知识产权或隐私等行为,均由用户自行承担法律责任。我们坚决反对并禁止此类非法行为,若发现任何违反法律法规的情况,我们将积极配合相关部门进行调查和处理。

  1. bp VirtualProtect断点
  2. 查找命令
    1. 结构
      mov ecx,dword ptr ss:[ebp+0x8]
      mov edx,dword ptr ss:[ebp-0x8]
      mov eax,dword ptr ds:[edx]
      mov dword ptr ds:[ecx],eax
      
    2. 二进制查找: 8B 4D 08 8B 55 F8 8B 02 89 01
  3. 处理ITA
    1. ​mov dword ptr ds:[ecx],eax​ ⇒ NOP
    2. ​magic jump​
      ​​
  4. 查找命令
    1. 结构
      popad
      pop eax
      pop eax
      call eax
      
    2. 二进制查找:61 58 58 FF D0​
  5. OEP
    • 在CALL EAX下段之后F9运行再F7就跳转到OEP

// MoleBox脱壳脚本

// 在调试开始时运行
RunAt(0x401000, function()
{
    // 搜索PE文件头
    var base = GetModuleHandle(NULL);
    var pefile = base + 0x3C;
    var peoffset = base + ReadInt(pefile);
    var sign = base + peoffset;

    // 检查PE文件是否MoleBox加壳
    if (ReadInt(sign) == 0x00004550)
    {
        // 获取OEP
        var entrypoint = base + ReadInt(sign + 0x28);

        // 反算ImageBase
        var imagebase = entrypoint - base;

        // 获取MoleBox头信息
        var moleboxoffset = ReadInt(base + entrypoint - 0x30);
        var moleboxsize = ReadInt(base + entrypoint - 0x2C);
        var originalentry = ReadInt(base + entrypoint - 0x24);

        // 解密MoleBox头信息
        for (var i = 0; i < moleboxsize; i++)
        {
            PatchByte(base + moleboxoffset + i, ReadByte(base + moleboxoffset + i) ^ 0xAA);
        }

        // 恢复IAT表
        var iatoffset = base + entrypoint - 0x20;
        var iatcount = 0;
        while (ReadInt(iatoffset) != 0)
        {
            iatcount++;
            var iataddress = base + ReadInt(iatoffset);
            var iatvalue = ReadInt(iataddress);
            PatchDword(iataddress, iatvalue - imagebase);
            iatoffset += 4;
        }

        // 恢复OEP
        PatchByte(entrypoint, 0xE9);
        PatchDword(entrypoint + 1, originalentry - entrypoint - 5);

        // 修复重定位表
        var relocbase = base + ReadInt(sign + 0x34);
        if (relocbase != 0)
        {
            var relocsize = ReadInt(sign + 0x38);
            var relocdata = relocbase + 8;
            while (relocdata < relocbase + relocsize)
            {
                var relocblock = base + ReadInt(relocdata);
                var relocblocksize = ReadInt(relocdata + 4);
                var reloccount = (relocblocksize - 8) / 2;
                var relocitem = relocdata + 8;
                for (var j = 0; j < reloccount; j++)
                {
                    var relocoffset = ReadWord(relocitem);
                    var relocaddress = base + relocblock + relocoffset;
                    var relocvalue = ReadInt(relocaddress);
                    PatchDword(relocaddress, relocvalue - imagebase);
                    relocitem += 2;
                }
                relocdata += relocblocksize;
            }
        }

        // 完成脱壳
        Log("MoleBox unpacked!");
    }
});