WPE|52wpe|我爱WPE

 找回密码
 注册会员
搜索
  • 2272查看
  • 0回复

主题

好友

1936

积分

金牌会员

发表于 2010-1-6 19:52:28 |显示全部楼层
去简单花指令的IDC脚本
发现手改花指令太无聊,于是简单学了下IDC,觉得不爽,但是为了稍微节省些体力,还是硬着头皮写了一个,可能有bug,能改的花指令也很有限,我只为了应付我碰到的情况,有和我同样情况的可以直接用,效果应该还行,但是做的不完全,只是把一些无用的花指令替换成0x90,没有重新分析,如果碰到IDA提示红字的地方,按D再按C,呵呵.

代码:

#include <idc.idc>


static matchBytes(StartAddr, Match)
{
auto Len, i, PatSub, SrcSub;
Len = strlen(Match);

while (i < Len)
{
   PatSub = substr(Match, i, i+1);
   SrcSub = form("%02X", Byte(StartAddr));
   SrcSub = substr(SrcSub, i % 2, (i % 2) + 1);
   
   if (PatSub != "?" && PatSub != SrcSub)
   {
    return 0;
   }
   
   if (i % 2 == 1)
   {
    StartAddr++;
   }
   i++;
}

return 1;
}


static main()
{
   auto StartVa, SavedStartVa, StopVa, Size, i, j;

StartVa = 0x000102A0;
StopVa = 0x000120A0;

Size = StopVa - StartVa;
SavedStartVa = StartVa;

for (i = 0; i < Size; i++)
{
   // 0F 82 07 00 00 00 0F 83 01 00 00 00
   // jz xxxx + jnz xxxx + 0xE8
   // 0F 84 07 00 00 00 0F 85 01 00 00 00 E8
   // jo xxxx + jno xxxx + 0xE8
   // 0F 80 07 00 00 00 0F 81 01 00 00 00 E8
   // js xxxx + jns xxxx + 0xE8
   // 0F 88 07 00 00 00 0F 89 01 00 00 00 E8
   if (matchBytes(StartVa, "0F8?070000000F8?01000000E8"))
   {
    for (j = 0; j < 13; j++)
    {
     PatchByte(StartVa, 0x90);
     MakeCode(StartVa);
     StartVa++;
    }
   }
   
   // jb short near xxxx + jnb short near xxxx + 0xE8
   // 72 03 73 01 E8
   // jo short near xxxx + jno short near xxxx + 0xE8
   // 70 03 71 01 E8
   // jz short near xxxx + jnz short near xxxx + 0xE8
   // 74 03 75 01 E8
   if (matchBytes(StartVa, "7?037?01E8"))
   {
    for (j = 0; j < 5; j++)
    {
     PatchByte(StartVa, 0x90);
     MakeCode(StartVa);
     StartVa++;
    }
   }
   
   StartVa++;
}

AnalyzeArea(SavedStartVa, StopVa);
Message("Clear Fake-Jmp Opcode Ok\n");
}

快速发帖

您需要登录后才可以回帖 登录 | 注册会员

手机版|Archiver|WPE|52wpe|我爱WPE ( 闽ICP备15009081号 )

GMT+8, 2024-5-5 03:33 , Processed in 0.054127 second(s), 16 queries .

返回顶部