Hack The Box——Ready

目录

简介

信息收集

漏洞发现与利用

 权限提升

Docker逃逸 

总结


简介

该靶机非常简单,也很有趣,比较贴近实际机器。通过信息收集发现5080端口的GitLab服务,注册账号并利用CVE-2018-19571,CVE-2018-19585获得git用户的shell,然后通过信息收集获得smtp密码,使用该密码获得docker容器root用户shell,最后利用高危启动项逃逸到宿主机器中,成功获得宿主机器root权限。

信息收集

使用nmap --min-rate 10000 -A -sC -p- 10.10.10.220扫描目标主机端口及服务发现开启22和5080端口,操作系统为Ubuntu,5080端口运行着HTTP服务,标题存在GitLab单词,且存在robots.txt文件,如图:

访问页面发现是GitLab,查看robots.txt文件内容如下:

# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-Agent: *
# Disallow: /

# Add a 1 second delay between successive requests to the same server, limits resources used by crawler
# Only some crawlers respect this setting, e.g. Googlebot does not
# Crawl-delay: 1

# Based on details in https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/routes.rb, https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/routing, and using application
User-Agent: *
Disallow: /autocomplete/users
Disallow: /search
Disallow: /api
Disallow: /admin
Disallow: /profile
Disallow: /dashboard
Disallow: /projects/new
Disallow: /groups/new
Disallow: /groups/*/edit
Disallow: /users
Disallow: /help
# Only specifically allow the Sign In page to avoid very ugly search results
Allow: /users/sign_in

# Global snippets
User-Agent: *
Disallow: /s/
Disallow: /snippets/new
Disallow: /snippets/*/edit
Disallow: /snippets/*/raw

# Project details
User-Agent: *
Disallow: /*/*.git
Disallow: /*/*/fork/new
Disallow: /*/*/repository/archive*
Disallow: /*/*/activity
Disallow: /*/*/new
Disallow: /*/*/edit
Disallow: /*/*/raw
Disallow: /*/*/blame
Disallow: /*/*/commits/*/*
Disallow: /*/*/commit/*.patch
Disallow: /*/*/commit/*.diff
Disallow: /*/*/compare
Disallow: /*/*/branches/new
Disallow: /*/*/tags/new
Disallow: /*/*/network
Disallow: /*/*/graphs
Disallow: /*/*/milestones/new
Disallow: /*/*/milestones/*/edit
Disallow: /*/*/issues/new
Disallow: /*/*/issues/*/edit
Disallow: /*/*/merge_requests/new
Disallow: /*/*/merge_requests/*.patch
Disallow: /*/*/merge_requests/*.diff
Disallow: /*/*/merge_requests/*/edit
Disallow: /*/*/merge_requests/*/diffs
Disallow: /*/*/project_members/import
Disallow: /*/*/labels/new
Disallow: /*/*/labels/*/edit
Disallow: /*/*/wikis/*/edit
Disallow: /*/*/snippets/new
Disallow: /*/*/snippets/*/edit
Disallow: /*/*/snippets/*/raw
Disallow: /*/*/deploy_keys
Disallow: /*/*/hooks
Disallow: /*/*/services
Disallow: /*/*/protected_branches
Disallow: /*/*/uploads/

使用Google搜索发现GitLab存在远程代码执行(CVE-2018-14364)(CVE-2018-19571,CVE-2018-19585)和任意文件读取漏洞(CVE-2016-9086)(CVE-2020-10977)。

漏洞发现与利用

手工测试CVE-2018-14364发现不存在该漏洞,通过枚举发现存在test/test1234弱口令,但仅仅是普通用户,应该是其它用户注册的。Google搜索发现CVE-2018-19571,CVE-2018-19585。漏洞利用代码:https://www.exploit-db.com/exploits/49257。修改用户名、token等信息(通过抓取POST数据包即可获得),如图:

执行之后获得git用户的shell,如图:

 权限提升

直接上传linPEAS提权辅助脚本,查看执行结果发现当前shell为Docker环境,如图:

在执行结果中发现一些私钥文件,但并不能通过ssh连接,发现smtp密码:wW59U!ZKMbG9+*#h,如图:

尝试使用该密码切换至root用户,成功获得root权限shell,如图:

 在/root目录下未发现root.txt文件,本以为是有人删除了,重置靶机后依旧没有找到root.txt,全盘搜索也未发现。回想起提权辅助脚本的执行结果显示当前shell在Docker容器中,猜测需要进行逃逸。

Docker逃逸 

搜索Docker逃逸漏洞发现dirtycow-vdso,但未成功逃逸,测试CVE-2019-5736也未成功,在Docker 容器逃逸案例汇集中发现其它逃逸方法,利用Docker高危启动参数成功逃逸到宿主机,如图:

查看root用户.ssh目录发现id_rsa文件,如图:

使用该文件连接目标主机ssh服务,成功获得root用户shell,如图:

总结

对该靶机的渗透是我目前做过的所有HTB的靶机中花费事件最少的,可能是靶机太简单的原因吗,整体比较流畅,就是在找不到root.txt文件时有点蒙了,不过还好注意到了提权辅助脚本执行结果中的异常点——Looks like we're  in a Docker ...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值