win7下测试shellcode的方法1:关闭DEP
在win7下,通过下面的方法测试shellcode:char shellcode [] ="..." ;
int main ( int argc , char ** argv)
{
__asm
{
lea eax , shellcode
call eax
}
return 0;
}
必须要关闭DEP,不然shellcode所在的数据段由于受系统保护不允许被执行,导致出现异常,而测试失败。
关闭和启用DEP的方法如下:
关闭:
bcdedit.exe /set {current} nx AlwaysOff
启用:
bcdedit.exe /set {current} nx AlwaysOn
关闭和启用要生效,记住:都需要重新启动电脑。 看DEP状态,也可以到:
系统属性->>高级->>性能->>设置->>数据执行保护
查看,DEP状态,也可以在这里,对个别程序关闭DEP保护。
附几种测试shellcode的简单汇编代码:
method -1
int (*func)();
func = (int (*)())shellcode;
(int)(*func)();
method -2
__asm{
lea eax, shellcode
push eax
ret
}
method -3
((void (*)())shellcode)();
method-4
__asm{
lea eax , shellcode
call eax
}
其实都是一样的原理...
页:
[1]