main中执行shellcode的一段代码的解释

一些黑客教程中常见的在main中执行shellcode的代码:

char shellcode[] ="  your shellcode";       //replace your shellcode here

int main() {

    int *ret; //define a variable  on the stack 
    ret = (int *)&ret+2; //let ret point to place that the place of ret(&ret)add offset(2,return address on there)
    (*ret) = (int)shellcode; //change the saved return value to the address of the shellcode, so it executes.
}


  注释简略介绍了代码的含义。 代码表面没有做什么工作,但是通过其对栈的影响,尤其是覆盖main函数返回地址,影响了正常的返回操作,

使运行时库无法接管控制权,而把控制权转到我们改写的shellcode上去。


  通过下图能更好的理解代码的运行



 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值