[Reverse]关于idapython中PatchByte函数的一些小实验

源代码

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<string>
#include<cstring>
#include<list>
#include<stdlib.h>
#include<windows.h>
using namespace std;
typedef int status;
typedef int selemtype;

int main ()
{
    int n;
    scanf("%d",&n);//cin >> n;
    if(n==233)
    {
        printf("666");//cout<<"666"
    }
    else{
        printf("boring"); 
    }
    Sleep(10000);
}

当我们输入233的时候程序会出现666,反之出现boring
而我们要做的是即便我们输入任意数值也能变成666
所需要用到的就是idapython 的idc_bc695库中的PatchByte函数了。
首先将编译出来的exe文件放入ida反编译

int main()
{
  int v1; // [esp+1Ch] [ebp-Ch] BYREF

  __main();
  scanf("%d", &v1);
  if ( v1 == 233 )
    printf("666");
  else
    printf("boring");
  Sleep(0x2710u);
  return 0;
}

我们再scanf处下断点
动态调试然后输入123

file

此时看到v1在栈内的地址确实是0x7B也就是123
我们需要记住v1的地址0x007AFF0C
按shif+f2打开嵌入式脚本窗口
输入如下指令
file

点击run后再对调试窗口按空格更新一下我们会发现
file

0x00aff0c地址变成了0xE9
也就是233
然后我们继续f8
file

成功执行666

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇