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

Discord Webhook pattern #648

Merged
merged 8 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 18 additions & 2 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,11 @@
- doc

- name: Slack Webhook
severity: high
severity: medium
confidence: strong
type: pattern
values:
- (?P<value>hooks\.slack\.com/services/T[0-9A-Z]{8,16}/B[0-9A-Z]{8,16}/\w{24})
- (?P<variable>hooks\.slack\.com/services)(?P<value>/T[0-9A-Z]{8,16}/B[0-9A-Z]{8,16}/[0-9A-Za-z_]{24})
filter_type: GeneralPattern
required_substrings:
- hooks.slack.com/services/T
Expand Down Expand Up @@ -1373,6 +1373,22 @@
- code
- doc

- name: Discord Webhook
severity: medium
confidence: strong
type: pattern
values:
- (?P<variable>discord(?:app)?\.com/api/webhooks)(?P<value>/[0-9]{16,22}/[0-9A-Za-z_-]{40,100})
filter_type:
- ValueCoupleKeywordCheck(3)
required_substrings:
- discordapp.com/api/webhooks
- discord.com/api/webhooks
min_line_len: 61
target:
- code
- doc

- name: Tencent WeChat API App ID
severity: medium
confidence: weak
Expand Down
6 changes: 3 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pathlib import Path

# total number of files in test samples
SAMPLES_FILES_COUNT = 143
SAMPLES_FILES_COUNT = 144

# the lowest value of ML threshold is used to display possible lowest values
NEGLIGIBLE_ML_THRESHOLD = 0.0001

# credentials count after scan with negligible ML threshold
SAMPLES_CRED_COUNT = 428
SAMPLES_CRED_COUNT = 429
SAMPLES_CRED_LINE_COUNT = SAMPLES_CRED_COUNT + 19

# Number of filtered credentials with ML
Expand All @@ -17,7 +17,7 @@
SAMPLES_POST_CRED_COUNT = SAMPLES_CRED_COUNT - ML_FILTERED

# with option --doc
SAMPLES_IN_DOC = 674
SAMPLES_IN_DOC = 675

# archived credentials that are not found without --depth
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 35
Expand Down
40 changes: 33 additions & 7 deletions tests/data/depth_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Discord Webhook",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": "T https://discordapp.com/api/webhooks/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"line_num": 1,
"path": "./tests/samples/discord_webhook",
"info": "./tests/samples/discord_webhook|RAW",
"value": "/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"value_start": 37,
"value_end": 125,
"variable": "discordapp.com/api/webhooks",
"variable_start": 10,
"variable_end": 37,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 5.087734877965757,
"valid": true
}
}
]
},
{
"ml_validation": "VALIDATED_KEY",
"ml_probability": 0.744,
Expand Down Expand Up @@ -11601,23 +11627,23 @@
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Slack Webhook",
"severity": "high",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": " \"hook\": \"https://hooks.slack.com/services/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\",",
"line_num": 1,
"path": "./tests/samples/slack_webhook.template",
"info": "./tests/samples/slack_webhook.template|RAW",
"value": "hooks.slack.com/services/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",
"value_start": 21,
"value": "/T1029384756/B102984756/sjsbfzowhhqbsgftrvajxzpg",
"value_start": 45,
"value_end": 93,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"variable": "hooks.slack.com/services",
"variable_start": 21,
"variable_end": 45,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.843520703364329,
"entropy": 4.761842188131013,
"valid": true
}
}
Expand Down
40 changes: 33 additions & 7 deletions tests/data/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Discord Webhook",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": "T https://discordapp.com/api/webhooks/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"line_num": 1,
"path": "./tests/samples/discord_webhook",
"info": "./tests/samples/discord_webhook|RAW",
"value": "/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"value_start": 37,
"value_end": 125,
"variable": "discordapp.com/api/webhooks",
"variable_start": 10,
"variable_end": 37,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 5.087734877965757,
"valid": true
}
}
]
},
{
"ml_validation": "VALIDATED_KEY",
"ml_probability": 0.999,
Expand Down Expand Up @@ -18502,23 +18528,23 @@
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Slack Webhook",
"severity": "high",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": "\"hook\": \"https://hooks.slack.com/services/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\",",
"line_num": 1,
"path": "./tests/samples/slack_webhook.template",
"info": "./tests/samples/slack_webhook.template|RAW",
"value": "hooks.slack.com/services/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",
"value_start": 21,
"value": "/T1029384756/B102984756/sjsbfzowhhqbsgftrvajxzpg",
"value_start": 45,
"value_end": 93,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"variable": "hooks.slack.com/services",
"variable_start": 21,
"variable_end": 45,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.843520703364329,
"entropy": 4.761842188131013,
"valid": true
}
}
Expand Down
40 changes: 33 additions & 7 deletions tests/data/ml_threshold.json
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Discord Webhook",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": "T https://discordapp.com/api/webhooks/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"line_num": 1,
"path": "./tests/samples/discord_webhook",
"info": "",
"value": "/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"value_start": 37,
"value_end": 125,
"variable": "discordapp.com/api/webhooks",
"variable_start": 10,
"variable_end": 37,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 5.087734877965757,
"valid": true
}
}
]
},
{
"ml_validation": "VALIDATED_KEY",
"ml_probability": 0.472,
Expand Down Expand Up @@ -10466,23 +10492,23 @@
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Slack Webhook",
"severity": "high",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": " \"hook\": \"https://hooks.slack.com/services/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\",",
"line_num": 1,
"path": "./tests/samples/slack_webhook.template",
"info": "",
"value": "hooks.slack.com/services/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",
"value_start": 21,
"value": "/T1029384756/B102984756/sjsbfzowhhqbsgftrvajxzpg",
"value_start": 45,
"value_end": 93,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"variable": "hooks.slack.com/services",
"variable_start": 21,
"variable_end": 45,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.843520703364329,
"entropy": 4.761842188131013,
"valid": true
}
}
Expand Down
40 changes: 33 additions & 7 deletions tests/data/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,32 @@
}
]
},
{
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Discord Webhook",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": "T https://discordapp.com/api/webhooks/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"line_num": 1,
"path": "./tests/samples/discord_webhook",
"info": "",
"value": "/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h",
"value_start": 37,
"value_end": 125,
"variable": "discordapp.com/api/webhooks",
"variable_start": 10,
"variable_end": 37,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 5.087734877965757,
"valid": true
}
}
]
},
{
"ml_validation": "VALIDATED_KEY",
"ml_probability": 0.744,
Expand Down Expand Up @@ -9686,23 +9712,23 @@
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Slack Webhook",
"severity": "high",
"severity": "medium",
"confidence": "strong",
"line_data_list": [
{
"line": " \"hook\": \"https://hooks.slack.com/services/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\",",
"line_num": 1,
"path": "./tests/samples/slack_webhook.template",
"info": "",
"value": "hooks.slack.com/services/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",
"value_start": 21,
"value": "/T1029384756/B102984756/sjsbfzowhhqbsgftrvajxzpg",
"value_start": 45,
"value_end": 93,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"variable": "hooks.slack.com/services",
"variable_start": 21,
"variable_end": 45,
"entropy_validation": {
"iterator": "BASE64STDPAD_CHARS",
"entropy": 4.843520703364329,
"entropy": 4.761842188131013,
"valid": true
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/samples/discord_webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
T https://discordapp.com/api/webhooks/148392840000482200/ihUFAgIi-OsnNHsjJBpvzkzZOicbe0R2UkWo1nvOnkLGHWJnW8HZjF_dRDj7fi5q3u2h

F discord.com/api/webhooks/148392840000482200/OsnNHsifi5q3u2_there-are-not-the-webhook-you-are-looking-for_8HZjFgIi
Loading