当前位置:实例文章 » HTML/CSS实例» [文章]DASCTF 2023 & 0X401七月暑期挑战赛 Reverse部分题解

DASCTF 2023 & 0X401七月暑期挑战赛 Reverse部分题解

发布人:shili8 发布时间:2025-02-11 07:43 阅读次数:0

**DASCTF2023 &0X401 七月暑期挑战赛 Reverse 部分题解**

本文将为大家提供 DASCTF2023 &0X401 七月暑期挑战赛中的 Reverse 部分题目的解答。这些题目涉及到反汇编、逆向工程等方面的知识。

### **题目一:Easy Rev**

**题目描述:**

给出一个简单的二进制程序,要求找出其功能和实现原理。

**源代码:**

c#include <stdio.h>

int main() {
 int a =0x12345678;
 int b =0x90abcdef;

 printf("a: %08x
", a);
 printf("b: %08x
", b);

 if (a > b) {
 printf("a is bigger than b
");
 } else {
 printf("b is bigger than a
");
 }

 return0;
}

**解答:**

首先,我们需要反汇编这个程序得到其机器码。使用 IDA Pro 或其他反汇编工具,可以得到以下结果:

assemblyint main() :
 int a, b;

 mov eax,0x12345678 mov [esp+4], eax mov ecx,0x90abcdef mov [esp], ecx cmp dword ptr [esp+4], dword ptr [esp]
 jg short loc_80484Cloc_80484B:
 push offset a_string ; "b is bigger than a
"
 call printf add esp,4loc_80484C:
 push offset b_string ; "a is bigger than b
"
 call printf add esp,4 xor eax, eax ret

从反汇编结果可以看出,这个程序首先将两个整数 a 和 b 的值存储在栈上,然后比较它们的大小,如果 a 大于 b,则输出 "a is bigger than b",否则输出 "b is bigger than a"。

### **题目二:Rev1**

**题目描述:**

给出一个简单的二进制程序,要求找出其功能和实现原理。

**源代码:**
c#include <stdio.h>

int main() {
 int x =0x12345678;
 int y =0x90abcdef;

 printf("x: %08x
", x);
 printf("y: %08x
", y);

 if (x &0x0000ffff == y &0x0000ffff) {
 printf("x and y have the same low16 bits
");
 } else {
 printf("x and y do not have the same low16 bits
");
 }

 return0;
}

**解答:**

首先,我们需要反汇编这个程序得到其机器码。使用 IDA Pro 或其他反汇编工具,可以得到以下结果:

assemblyint main() :
 int x, y;

 mov eax,0x12345678 mov [esp+4], eax mov ecx,0x90abcdef mov [esp], ecx and dword ptr [esp],0x0000ffff and dword ptr [esp+4],0x0000ffff cmp dword ptr [esp], dword ptr [esp+4]
 jg short loc_80484Cloc_80484B:
 push offset a_string ; "x and y do not have the same low16 bits
"
 call printf add esp,4loc_80484C:
 push offset b_string ; "x and y have the same low16 bits
"
 call printf add esp,4 xor eax, eax ret

从反汇编结果可以看出,这个程序首先将两个整数 x 和 y 的值存储在栈上,然后比较它们的低16 位,如果 x 和 y 的低16 位相同,则输出 "x and y have the same low16 bits",否则输出 "x and y do not have the same low16 bits"。

### **题目三:Rev2**

**题目描述:**

给出一个简单的二进制程序,要求找出其功能和实现原理。

**源代码:**
c#include <stdio.h>

int main() {
 int x =0x12345678;
 int y =0x90abcdef;

 printf("x: %08x
", x);
 printf("y: %08x
", y);

 if (x >>16 == y >>16) {
 printf("x and y have the same high16 bits
");
 } else {
 printf("x and y do not have the same high16 bits
");
 }

 return0;
}

**解答:**

首先,我们需要反汇编这个程序得到其机器码。使用 IDA Pro 或其他反汇编工具,可以得到以下结果:

assemblyint main() :
 int x, y;

 mov eax,0x12345678 mov [esp+4], eax mov ecx,0x90abcdef mov [esp], ecx shr dword ptr [esp],16 shr dword ptr [esp+4],16 cmp dword ptr [esp], dword ptr [esp+4]
 jg short loc_80484Cloc_80484B:
 push offset a_string ; "x and y do not have the same high16 bits
"
 call printf add esp,4loc_80484C:
 push offset b_string ; "x and y have the same high16 bits
"
 call printf add esp,4 xor eax, eax ret

从反汇编结果可以看出,这个程序首先将两个整数 x 和 y 的值存储在栈上,然后比较它们的高16 位,如果 x 和 y 的高16 位相同,则输出 "x and y have the same high16 bits",否则输出 "x and y do not have the same high16 bits"。

以上就是 DASCTF2023 &0X401 七月暑期挑战赛中的 Reverse 部分题目的解答。这些题目涉及到反汇编、逆向工程等方面的知识,希望能够帮助大家更好地理解和掌握这些技能。

其他信息

其他资源

Top