Skip to content

Searches through git repositories for high entropy strings and secrets, digging deep into commit history

License

Notifications You must be signed in to change notification settings

sortigoza/truffleHog

This branch is 124 commits ahead of, 3841 commits behind trufflesecurity/trufflehog:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Dec 24, 2019
ef08326 · Dec 24, 2019
Dec 24, 2019
Dec 13, 2019
Dec 24, 2019
Dec 24, 2019
Dec 13, 2019
Dec 24, 2019
Dec 24, 2019
Dec 31, 2016
Dec 24, 2019
Dec 24, 2019
Dec 24, 2019
Dec 24, 2019
Jan 10, 2017
Dec 24, 2019

Repository files navigation

Truffle Hog

Searches through git repositories for secrets, digging deep into commit history and branches. This is effective at finding secrets accidentally committed.

NEW

Trufflehog previously functioned by running entropy checks on git diffs. This functionality still exists, but high signal regex checks have been added, and the ability to surpress entropy checking has also been added.

These features help cut down on noise, and makes the tool easier to shove into a devops pipeline.

truffleHog --regex --entropy=False https://github.com/dxa4481/truffleHog.git

or

truffleHog file:///user/dxa4481/codeprojects/truffleHog/

Example

Install

pip install truffleHog

Customizing

Custom regexes can be added with the following flag --rules /path/to/rules. This should be a json file of the following format:

{
    "RSA private key": "-----BEGIN EC PRIVATE KEY-----"
}

Things like subdomain enumeration, s3 bucket detection, and other useful regexes highly custom to the situation can be added.

Feel free to also contribute high signal regexes upstream that you think will benifit the community. Things like Azure keys, Twilio keys, Google Compute keys, are welcome, provided a high signal regex can be constructed.

Trufflehog's base rule set sources from https://github.com/dxa4481/truffleHogRegexes/blob/master/truffleHogRegexes/regexes.json

How it works

This module will go through the entire commit history of each branch, and check each diff from each commit, and check for secrets. This is both by regex and by entropy. For entropy checks, trufflehog will evaluate the shannon entropy for both the base64 char set and hexidecimal char set for every blob of text greater than 20 characters comprised of those character sets in each diff. If at any point a high entropy string >20 characters is detected, it will print to the screen.

Help

usage: trufflehog [-h] [--json] [--regex] [--rules RULES]
                  [--entropy DO_ENTROPY] [--since_commit SINCE_COMMIT]
                  [--max_depth MAX_DEPTH]
                  git_url

Find secrets hidden in the depths of git.

positional arguments:
  git_url               URL for secret searching

optional arguments:
  -h, --help            show this help message and exit
  --json                Output in JSON
  --regex               Enable high signal regex checks
  --rules RULES         Ignore default regexes and source from json list file
  --entropy DO_ENTROPY  Enable entropy checks
  --since_commit SINCE_COMMIT
                        Only scan from a given commit hash
  --max_depth MAX_DEPTH
                        The max commit depth to go back when searching for
                        secrets

To Do - in order of priority

  • A way to detect and not scan binary diffs
  • Don't rescan diffs if already looked at in another branch -> remove duplicate entries with same diff hash
  • Print the file affected
  • CLI interface
  • output as json
  • find by regexp
  • Able to scan a plain file or directory to use as a stand alone tool in CIs and pre-commit
  • able to ignore secific lines in files
  • able to ignore specific files with .secretsignore

About

Searches through git repositories for high entropy strings and secrets, digging deep into commit history

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.6%
  • Shell 5.8%
  • Dockerfile 1.6%