Git GitHub Pentesting
Git Commands for the Repository Investigation
Check Information
# Basic information
git show
git show <branch-name>
git show <commit-id>
git show <tag-name>
git --git-dir /path/to/.git show
# Configuration
git config --list
# Commit history
git log
git log --stat
git --git-dir /path/to/.git log --stat
# Compare the two commits
git diff
git diff --staged
git diff --cached
# Working tree status
git status
Back to the Previous Commits
# We can get the "commit-id" by 'git log'
git checkout <commit-id>
git --git-dir /path/to/.git checkout <commit-id>
# Return the recent commit
git checkout master
git checkout main
Search the Other Branches
For getting all branches.
Btw, for creating a new branch.
Clone the Repository
git clone https://github.com/username/repo.git
# via SSH
git clone ssh://git-user@10.0.0.1/path/to/repo
git clone ssh://git-user@10.0.0.1/path/to/repo.git
Find Tags
Restore Deleted Files
First off, check deleted files.
Then restore them.
GitHub Dorks
Search Target Repository
You may be able to get the desired repository by searching in the Google.
The searching word is like "
Find Sensitive Data in the Repository
If you can access to the GitHub repository, research files and find the sensitive information. For example:
- Hard-coded contents
- Past commits
- Deleted files in past commits
- Commit messages
- Email address which may leak sensitive information about personal accounts
- Different branches
For more details, see the github-dorks{:target="_blank"}{:rel="noopener"}.
Find Email Address
- Click the target repository.
- Move to the commit history.
-
Click the commit and add “.patch” to the URL. For example:
-
Check the “From” section in the page. You should find the email address of the commiter.