❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayHacking and InfoSec

Open Source Intelligence (OSINT): Finding Leaked Secrets with TruffleHog

10 September 2026 at 09:36

Welcome back, cyberwarriors!Β 

You’ve probably seen people committing their env files to GitHub without noticing it. When you’re looking for a job as a coder, that mistake alone is significant enough to get you rejected if it happens during the technical portion. And if it ever happened to you, it’s happened to plenty of others too.

Today we’ll look at TruffleHog. It’s a tool that scans Git repositories and their full history for secrets that got committed by accident. It uses high entropy checks with custom regular expressions to catch strings that look like API keys, tokens, passwords and other sensitive data. You can point it at one repository or use a GitHub or GitLab API to hit a lot of projects in one go.

A developer can delete a key from the latest commit, but it will still live in Git’s past. With those credentials, you access services without making much noise.

Installation

First install git-dumper and TruffleHog. The Python package and the GitHub release are not the same, so pay attention to which one you’re on.

kali > pip3 install git-dumper  
kali > pip3 install trufflehog

We’ll use git-dumper when we find an exposed .git directory and then run TruffleHog against that dump. Leaked .git folders are still common.

Dump a Repository

Some servers leave the entire .git directory open. Below you can see a website where it was fully accessible.

viewing exposed git directory

Dump it by giving git-dumper the URL and a local folder for the files.

kali > git-dumper http://example.com/.git dump
dumping exposed git directory with git-dumper

Other websites block the directory listing but still serve some of the files.

Git-dumper can pull every object, commit and reference it can reach.

kali > git-dumper http://example.com/.git/  dump

Everything will be stored in the dump folder.

Analyzing the Repositories

Once the dump is on disk, run TruffleHog against it. By default it runs entropy-based matching. That can help, but it shouldn’t be the only mode you know. In our case, regex with entropy off gave us more results.Β 

kali > trufflehog --regex --entropy NO dump
experimenting with tufflehog flags

discovered credentials with trufflehog

In one of the files we found database credentials.

You can also install TruffleHog from the GitHub release and scan the filesystem directly:

kali > curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin 

kali > trufflehog filesystem /home/kali/Documents/dump  
trufflehog filesystem mode

This build is fine for tuning your scans, but it often makes more noise and false positives, so just be aware of it.

Other Ways to Analyze Repositories

Depending on which build you’re using, try these flags to change what you get in the output.

Scan a repo for verified secrets:

kali > trufflehog git https://github.com/trufflesecurity/test_keys --results=verified,unknown
scanning for verified secrets with trufflehog

Verified means TruffleHog checked these finding live against the service API (AWS, GitHub and so on). Unknown is both high entropy and regex hits that it couldn’t confirm.

Same scan with JSON output:

kali > trufflehog git https://github.com/trufflesecurity/test_keys --results=verified,unknown --json
scanning all repos of an organization with trufflehog

Scan a GitHub repo including issues and pull requests:

kali > trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments  
scanning issues comments and pull requests with trufflehog

finding gems with trufflehog

That digs into issues, comments, PR bodies and comments. You can find leaks in discussions too.

Scan a local Git repo:

kali > trufflehog git file://test_keys --results=verified,unknown  

Useful when you’ve compromised a dev Linux machine with multiple projects on it. There’s a better chance of finding something locally than pushed to GitHub, although both can happen, as you now know.

Summary

We had an external pentest where several services were accessible but no credentials could be found. Surprisingly, some developers had kept projects they were doing for the company publicly accessible on GitHub. Eventually we found a working pair and got into a database.

TruffleHog can be really helpful here. Sensitive files sometimes get exposed without the publisher even knowing it. We’re humans and we make mistakes. Offensive or defensive, the point is the same.

The post Open Source Intelligence (OSINT): Finding Leaked Secrets with TruffleHog first appeared on Hackers Arise.

❌
❌