Assembly 用刀具进行简单的反向成形练习
我目前正在学习使用Cutter对二进制文件进行一些基本的反向工程。我正在测试的程序,如果作为参数输入的密码正确,则返回一条错误消息。我有一些严重的差距,在组装和我不能找出这个密码。我已经为此努力了好几次,现在我已经到了进退两难的地步 这是反编译的代码,密码测试在while/if迭代过程中进行,所以之前要做的只是给出一些上下文Assembly 用刀具进行简单的反向成形练习,assembly,reverse-engineering,Assembly,Reverse Engineering,我目前正在学习使用Cutter对二进制文件进行一些基本的反向工程。我正在测试的程序,如果作为参数输入的密码正确,则返回一条错误消息。我有一些严重的差距,在组装和我不能找出这个密码。我已经为此努力了好几次,现在我已经到了进退两难的地步 这是反编译的代码,密码测试在while/if迭代过程中进行,所以之前要做的只是给出一些上下文 undefined4 main(int param_1,int param_2){ undefined4 uVar1; size_t sVar2;
undefined4 main(int param_1,int param_2){
undefined4 uVar1;
size_t sVar2;
undefined4 local_21;
undefined4 local_1d;
undefined local_19;
char *local_18;
int local_14;
undefined4 *local_10;
local_10 = ¶m_1;
local_14 = 0;
if (param_1 == 2) {
local_21 = 0x776f7264;
local_1d = 0x70617373;
local_19 = 0;
local_18 = *(char **)(param_2 + 4);
sVar2 = strlen(local_18);
if (sVar2 < 8) {
uVar1 = 0xffffffff;
}
else {
while (local_14 < 8) {
if ((int)local_18[local_14] + 1 != (int)*(char
*)((int)&local_21 + local_14)) {
puts("Wrong password.");
return 0xffffffff;
}
local_14 = local_14 + 1;
}
puts("Access granted.");
uVar1 = 0;
}
}
else {
puts("One and only one argument PLS.");
uVar1 = 0xffffffff;
}
return uVar1;
}
我很难理解0x776f7264实际上是地址还是eax中的值。所以当我加1时,实际发生了什么(2,3等等)?我是直接向HEXA的吗?或者我会考虑把它添加到字符中吗?
比如77=w,我把1加在w上,它给我x
我真的很抱歉,如果我没有很好地解释我的问题,我会尽我所能回答任何关于我的帖子的问题
非常感谢,祝你度过愉快的一天
\uuux86.get\uPC\uThunk.bx()代码>-不幸的是,有人给了你一个x86 32位馅饼来处理。他们必须从GOT加载指针才能访问静态数据(如全局变量和字符串文本,例如错误消息),因为x86上的PC相对寻址直到x86-64才引入。看起来你的反编译程序做得不错,但这就是为什么你有像unaf_EBX+0x17f
这样的垃圾。非常感谢你的回答。。我仍然可以直接使用汇编代码no找到它?一些注释:1)您可以忽略movsx eax,al
指令,这些指令只是符号扩展char
到int
2)lea ecx,[eax+1]
用作简单的算术,即ecx=eax+1
。它不是作为地址取消引用的。3) 代码似乎只是检查移位1个字母的输入是否为password
,即if(input[i]+1!=password[i])fail()代码>非常感谢您提供的anwser,所以在调用字节[eax]的地方,实际上只需要字符并向其中添加1?所以它将整个单词移动了1个字符?我只是想确定我明白了!我要试试!!我找到了密码,它被一个字母移动了。所以你完全正确,但我很难理解十六进制的值(local_21=0x776f7264;local_1d=0x70617373),当我试图转换它们时,我对这些值有“pass”和“word”,但似乎取决于“little endian”和“big endian”,顺序可以改变,所以我无法得到正确的答案<代码>\uuux86.get\uPC\uThunk.bx()代码>-不幸的是,有人给了你一个x86 32位馅饼来处理。他们必须从GOT加载指针才能访问静态数据(如全局变量和字符串文本,例如错误消息),因为x86上的PC相对寻址直到x86-64才引入。看起来你的反编译程序做得不错,但这就是为什么你有像unaf_EBX+0x17f
这样的垃圾。非常感谢你的回答。。我仍然可以直接使用汇编代码no找到它?一些注释:1)您可以忽略movsx eax,al
指令,这些指令只是符号扩展char
到int
2)lea ecx,[eax+1]
用作简单的算术,即ecx=eax+1
。它不是作为地址取消引用的。3) 代码似乎只是检查移位1个字母的输入是否为password
,即if(input[i]+1!=password[i])fail()代码>非常感谢您提供的anwser,所以在调用字节[eax]的地方,实际上只需要字符并向其中添加1?所以它将整个单词移动了1个字符?我只是想确定我明白了!我要试试!!我找到了密码,它被一个字母移动了。所以你完全正确,但我很难理解十六进制的值(local_21=0x776f7264;local_1d=0x70617373),当我试图转换它们时,我对这些值有“pass”和“word”,但似乎取决于“little endian”和“big endian”,顺序可以改变,所以我无法得到正确的答案!
VARS :
local_21 = 0x776f7264 ; (String) word used in password comparaison
local_1d = 0x70617373 ;(String) pass but unused
local_14 = 0 ;iterator
local_18 = argv[1] (it's the string given as an argument, let's
assume i've entered "examples")
- mov edx, dword [local_14] --> load the value of local_14 into edx
local_14 = 0
- mov eax, dword[local_18] --> load the function argument into the
register
local_18 = examples
- add eax, edx --> add the value 0 to our password (does it means we
add 0 to the address of our input or directly to
the input ?)
- movzx eax, byte[eax] --> get the first character in eax (is he
taking the hexa character 7 ?
- movsx eax, al --> ?
- lea ecx, [eax + 1] --> load the address of [eax+1] into eax (don't
know what is in eax+1..)
- lea edx, [local_21] --> load the address of local_21 in edx
it is 0x776f7264 so what does it stock ? Do
I considerer this as a value or as an
address?
- mov eax, dword[local_14] --> load the value of local_14 (0) into
eax, so 0x0 ?
- add eax, edx -> we add local_14 (0) to eax, so do we have 0x776f7264
- movzx eax, byte[eax] --> exact same thing as before.
- movsx eax, al --> same as before
- cmp ecx, eax --> we compare ecx et eax (eax=?, ecx = [eax+1] = ?)
- add dword [local_14], 1 --> we add 1 to (local_14), it became 1 (our
iterator)
- cmp dword [local-14], 7 --> we compare our iterator with with 7, if
it is lower we continue
- we start again from the start