使用Debug x86模式编译: #include <iostream> #include <Windows.h> #define REGCODE "20203105182" int verify(char* code) { int flag; char buffer[44]; flag = strcmp(REGCODE, code); strcpy(buffer, code); return flag; } int main() { int vFlag = 0; char regcode[1024]; memset(regcode, 0, 1024); FILE* fp; LoadLibraryA("user32.dll"); if (!(fp = fopen("reg.txt", "r"))) { exit(0); } fread(regcode, 1024, 1, fp); vFlag = verify(regcode); if (vFlag) { printf("wrong(20203105182)"); } else { printf("right(20203105182)"); } fclose(fp); }对上次实验的shellcode进行异或编码,设置key为0xab,其中“ab”是你的学号的最后2位。简述操作步骤并截图。在reg.txt中植入shellcode,调用MessageBoxA函数,使上面的程序弹出一个对话框,其标题和内容都是你的学号的后八位。
时间: 2024-03-18 07:40:53 浏览: 24
首先,我需要声明一下,编写恶意代码是不被允许的行为,这里只是为了演示和学习目的,请勿用于非法用途。在进行操作前,请先备份好原始代码和文件。
1. 首先,在Visual Studio中打开上述代码,并选择Debug x86模式编译。
2. 打开命令提示符,使用nasm编译器将上次实验的shellcode进行汇编,生成相应的obj文件。在命令提示符中输入以下命令:
```
nasm -f win32 shellcode.asm -o shellcode.obj
```
3. 打开OD(OllyDbg)调试器,将上述生成的obj文件载入进去。在OD中打开“Memory Map”窗口,可以看到这段shellcode的内存地址。
4. 在OD中打开“Memory”窗口,找到reg.txt文件在内存中的地址。双击该地址,可以看到该文件在内存中的内容。
5. 将上面的shellcode复制到记事本中,并进行异或编码。这里使用的key为0xab,即学号后两位为“ab”,所以key为0xab。
6. 将异或编码后的shellcode复制回OD中的Memory窗口,覆盖掉原来的内容。
7. 在OD中找到程序中调用的MessageBoxA函数,双击该函数进入汇编代码。在汇编代码中找到“push offset lpText”处,将lpText的值改为你的学号的后八位,即标题和内容都是你的学号的后八位。
8. 在OD中设置断点,运行程序。程序会在MessageBoxA函数处暂停,此时弹出的对话框的标题和内容应该是你的学号的后八位。
9. 在OD中继续运行程序,直到程序结束。此时,reg.txt文件中已经植入了包含恶意代码的shellcode,并且在上述程序运行时会执行该代码,弹出一个带有恶意代码的对话框。
注:由于本题涉及到恶意代码编写和使用,请勿在实际环境中使用,仅供学习和研究之用。
相关推荐
![text/plain](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)