vulhub之DC-2

简介: vulhub之DC-2

01 靶机信息


靶机信息:


https://www.vulnhub.com/?q=dc-2
Name: DC: 2
Date release: 22 Mar 2019
Author: DCAU
Series: DC
Web page: http://www.five86.com/dc-2.html


靶机描述:


DESCRIPTION
Much like DC-1, DC-2 is another purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.
As with the original DC-1, it's designed with beginners in mind.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
Just like with DC-1, there are five flags including the final flag.
And again, just like with DC-1, the flags are important for beginners, but not so important for those who have experience.
In short, the only flag that really counts, is the final flag.
For beginners, Google is your friend. Well, apart from all the privacy concerns etc etc.
I haven't explored all the ways to achieve root, as I scrapped the previous version I had been working on, and started completely fresh apart from the base OS install.



02 信息搜集


因为打开之后无法获取有效的ip地址,这里配置为NAT模式


使用nmap进行扫描

nmap -sS 192.168.238.0/24


扫描到存在一个

192.168.238.19

继续扫描端口



开放了80和7744端口,直接访问ip地址,跳转到域名地址



这里可以看到无法跳转dc2 的主机,这里应该需要配置hosts文件


2. 修改hosts文件


先将文件备份



再进行修改



此时浏览web就显示正常了





03  进后台


网页一眼看过去就是wordpress的,很经典



在这里提示有一个flag1



应该是需要使用工具cewl将网页的信息都作为关键词来使用


cewl dc-2 > password



然后使用wpscan来爆破用户




--enumerate //列举枚举u  //用户-P  //指定用于暴力破解的口令字典


开始测试:


wpscan --url http://dc-2 -e -P password



跑出来了三个用户:

admin   jerry  tom



而且也跑出来了密码




[SUCCESS] - jerry / adipiscing[SUCCESS] - tom / parturient


众所周知,wp的后台就是wp-admin



啊这,失算了

还是再跑下吧

nikto目录遍历


nikto -host dc-2



发现了,原来是我记错了。。。。



使用刚刚爆破的用户名登录



在这里发现了另外一个flag2



那就尝试登录ssh吧


04  ssh



[SUCCESS] - jerry / adipiscing[SUCCESS] - tom / parturient


拒绝连接,使用全端口扫描看下:


jerry账号无法登陆成功:


但是tom用户是可以登陆的:





在这里可以看到好多命令无法使用:


虽然看到了flag3,但是拿不到,这里使用了rbash什么是rbash?什么是rbash?受限shell是LinuxShell限制一些bash shell中的功能,并且是从名字上很清楚。该限制很好地实现了命令以及脚本在受限shell中运行。它为Linux中的bash shell提供了一个额外的安全层。限制在rbash中实现cd命令(更改目录)PATH(设置/取消设置)ENV aka BASH_ENV(环境设置/取消设置)导入功能指定包含参数’/'的文件名指定包含参数’ - '的文件名使用重定向输出*****’>’,’>>’,’>*** *****|’,“<>”,“>&”,“&>”*******关闭使用限制“ **设置+ R”**或“ 设置+ O’注 :rbash限制任何启动文件被读取后执行。参考资料:https://blog.csdn.net/qq_45320164/article/details/109084488

r意味着restrict,rbash(restricted bash),即受限制的 bash,也就是说现在的shell受到了限制,在这里可以使用以下方法解除限制:

在这里无法使用vim,但是可以使用vi,而且还可以使用export命令。

vi 命令用于编辑文件Linux export 命令用于设置或显示环境变量。




vi:set shell=/bin/bash:shellexport PATH=/bin:/usr/bin:$PATHexport SHELL=/bin/bash:$SHELL



05 绕过rbash 获取flag3


直接在命令行里面执行:


BASH_CMDS[a]=/bin/sh;aexport PATH=$PATH:/bin/export PATH=$PATH:/usr/bin




此时拿到flag3


Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.


06  获取flag4


现在寻找flag4,只需要使用切换用户到jerry试试



[SUCCESS] - jerry / adipiscing[SUCCESS] - tom / parturient





Good to see that you've made it this far - but you're not home yet.You still need to get the final flag (the only flag that really counts!!!).No hints here - you're on your own now.  :-)Go on - git outta here!!!!


07 提权root获取flag


提权的方法可以参考:


https://www.cnblogs.com/zaqzzz/p/12075132.html

这里有提示,使用git提权。git提权方式:


法1: sudo git help config    !/bin/bash或者!'sh'完成提权法2: sudo git  -p help    !/bin/bash

法1:sudo git help config


获取flag



法2: sudo git  -p help






相关文章
|
Shell 开发工具 数据安全/隐私保护
解决git clone与git push出现的若干问题:Failed to connect to github.com port 443: Timed out
解决git clone与git push出现的若干问题:Failed to connect to github.com port 443: Timed out
4906 1
解决git clone与git push出现的若干问题:Failed to connect to github.com port 443: Timed out
|
监控 流计算
dc_labs--lab1的学习与总结
本节为dc_labs系列的第一篇,主要根据自己对于lab的理解,简述实验的过程,同时对于笔者自己觉得需要进一步理解的进行总结学习。本节重点在于理解启动文件与DC的综合流程。建议与对应博文([DC学习笔记正式篇之零——综述与基本流程介绍](https://guodongblog.com/posts/80912d01b675/))进行结合起来进行学习。该文为对应部分的实践篇的内容。本系列博文不会只是带着进行实验内容,个人觉得单纯跑一遍实验意义不大。会结合自己学习的理解进行部分展开。有问题欢迎留言一起学习。
636 0
|
算法 Java Linux
|
Docker 容器
GitHub Actions CI/CD Pipeline with Docker
GitHub Actions CI/CD Pipeline with Docker
GitHub Actions CI/CD Pipeline with Docker
|
缓存 开发工具 git
Git本地仓库操作_part2|学习笔记
快速学习Git本地仓库操作_part2
49 0
Git本地仓库操作_part2|学习笔记
|
Linux Shell 开发工具
Git本地仓库操作_part1|学习笔记
快速学习Git本地仓库操作_part1
75 0
Git本地仓库操作_part1|学习笔记
|
存储 JavaScript 前端开发
Angular 结合 Git Commit 版本处理
我们接下来用 Angular 实现下效果,React 和 Vue 同理。
Angular 结合 Git Commit 版本处理
|
Linux 开发工具 git
git、github、gitlab之间的关系
Git - 版本控制工具 Github - 一个网站,提供给用户空间创建git仓储,保存用户的一些数据文档或者代码等 GitLab - 基于Git的项目管理软件 Git分布式版本控制系统 Git是一款自由和开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。
2763 0
|
安全 Ubuntu Linux
Kali中搭建vulhub时镜像git失败
Kali中搭建vulhub时镜像git失败
216 0
Kali中搭建vulhub时镜像git失败
|
缓存 安全 测试技术
用 GitHub Action 构建一套 CI/CD 系统
在讲 Action 实践之前还需先讲下 Nebula Graph 的需求:首要目标比较明确就是自动化测试,分为单元测试和集成测试,顺带再解决一下 PM 小姐姐的发布需求,构建起来了第一版的 CI/CD 流程。
1251 0