GitHub Dorking
GitHub Dorking is a technique used to search for sensitive information, vulnerabilities, or misconfigured repositories on GitHub by leveraging advanced search operators. These operators allow users to refine their searches and uncover data that may not be intended for public exposure. While GitHub Dorking can be used for legitimate purposes, such as security research, it can also be exploited maliciously to find exposed credentials, private keys, or other sensitive data.
Common GitHub Search Operators
Here are some commonly used GitHub search operators for dorking:
filename:
- Searches for specific filenames.Example:
filename:.env
(searches for.env
files, which often contain sensitive environment variables).
path:
- Searches within specific directories or paths.Example:
path:/config
(searches for files in the/config
directory).
extension:
- Searches for files with specific extensions.Example:
extension:pem
(searches for.pem
files, often used for private keys).
repo:
- Limits the search to a specific repository.Example:
repo:user/repo
(searches within a specific repository).
user:
- Searches within repositories owned by a specific user or organization.Example:
user:github
(searches within GitHub's repositories).
language:
- Searches for code written in a specific programming language.Example:
language:python
(searches for Python code).
size:
- Searches for files of a specific size.Example:
size:>1000
(searches for files larger than 1000 bytes).
in:
- Searches within specific parts of a repository (e.g., file contents, path, or readme).Example:
in:file password
(searches for the word "password" in file contents).
created:
- Searches for repositories or files created within a specific time frame.Example:
created:2023-01-01
(searches for repositories created on January 1, 2023).
updated:
- Searches for repositories or files updated within a specific time frame.Example:
updated:>2023-01-01
(searches for repositories updated after January 1, 2023).
fork:
- Searches for repositories that are forks of another repository.Example:
fork:true
(searches for forked repositories).
stars:
- Searches for repositories with a specific number of stars.Example:
stars:>1000
(searches for repositories with more than 1000 stars).
is:
- Filters search results based on repository attributes.Example:
is:public
(searches for public repositories).
NOT
- Excludes specific terms from the search.Example:
password NOT example
(searches for "password" but excludes results containing "example").
Examples of GitHub Dorking Queries
Search for exposed API keys:
"api_key" OR "api-key" OR "api key" in:file
This query looks for files containing the terms "api_key," "api-key," or "api key."
Find
.env
files with sensitive information:filename:.env
This query searches for
.env
files, which often contain sensitive environment variables like database credentials.Search for private keys:
extension:pem OR extension:key
This query looks for
.pem
or.key
files, which may contain private keys.Find hardcoded credentials:
"password" OR "passwd" OR "pwd" in:file
This query searches for files containing the terms "password," "passwd," or "pwd."
Search for AWS credentials:
"aws_access_key_id" AND "aws_secret_access_key" in:file
This query looks for files containing both AWS access key ID and secret access key.
Find exposed configuration files:
filename:config OR filename:settings
This query searches for files named
config
orsettings
, which may contain sensitive configuration data.Search for exposed database credentials:
"DB_USERNAME" OR "DB_PASSWORD" in:file
This query looks for files containing database usernames or passwords.
Find repositories with exposed SSH keys:
filename:id_rsa OR filename:id_dsa
This query searches for files named
id_rsa
orid_dsa
, which are SSH private keys.Search for exposed Firebase credentials:
"firebaseio.com" in:file
This query looks for files containing Firebase database URLs, which may expose sensitive data.
Find repositories with exposed Docker configurations:
filename:docker-compose.yml
This query searches for
docker-compose.yml
files, which may contain sensitive environment variables.
Ethical Considerations
GitHub Dorking can be a powerful tool for security researchers to identify and report vulnerabilities. However, it can also be misused for malicious purposes. If you discover sensitive information through GitHub Dorking, it is important to report it responsibly to the repository owner or GitHub's security team.
Protecting Your Repositories
To avoid exposing sensitive information on GitHub:
Use
.gitignore
to exclude sensitive files from being committed.Avoid hardcoding credentials or secrets in your code.
Use environment variables or secret management tools.
Regularly audit your repositories for exposed data.
Enable GitHub's secret scanning feature to detect and alert you of exposed secrets.
By understanding GitHub Dorking, you can better secure your repositories and prevent unintended data exposure.
Last updated