当前位置:   article > 正文

shellcode1--messagebox的应用_shellmessagebox

shellmessagebox
// 12345.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "windows.h"
int main(int argc, char* argv[])
{
    char *str="test";
	printf("begin\n");
    HINSTANCE libHandle;
	char *dll="user32.dll";
    libHandle=LoadLibrary(dll);

_asm{
      sub sp,0x454       //给栈区分配一个空间,没有也可以运行
	  xor ebx,ebx       //因为字符串中不能出现0,所以使用异或运算来规避push 0的出现  
	  push ebx
	  push str            //messagebox的四个参数进栈
	  push str
	  push ebx
	  mov  eax,0x77d507ea   //messagebox()的绝对地址
	  call eax
	  mov  esp,20   } *///用于平衡堆栈
	}
   return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

这串代码可以成功弹框如下:
在这里插入图片描述接下来我们把它切换到反汇编模式去,提取出它的机器码:
在这里插入图片描述把这些机器码取出来放到一文本文档里,然后每两个给前面加\x
在这里插入图片描述

接下来上面的代码我们可以通过这段shellcode来实现:

#include "stdafx.h"
#include "stdio.h"
#include "windows.h"
char shellcode[]="\x66\x81\xEC\x54\x04\x33\xDB\x53\xFF\x75\xFC\xFF\x75\xFC\x53\xB8\xEA\x07\xD5\x77\xFF\xD0\xBC\x14";
int main(int argc, char* argv[])
{
    char *str="test";
	printf("begin\n");
    HINSTANCE libHandle;
	char *dll="user32.dll";
    libHandle=LoadLibrary(dll);

_asm{
     lea eax,shellcode   //shellcode地址给eax
	 push eax            //eax压栈
	 ret            //ret就会跳到shellcode首地址那里去执行
	}
   return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/705337
推荐阅读
相关标签
  

闽ICP备14008679号