-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Discord bot token and Grafana service (#574)
* Refactoring&retrain * fix PYLINT.USELESS_ELSE_ON_LOOP * skip lambda usage * Apply suggestions from code review * test data fix * optimisation * style * discord_and_grafana * style * slack-token-regex-rollback * [no ci] renamed new rules * [no ci] default ml_batch_size * sk-proj- prefix for openai * [skip actions] [sanitizer] 2024-07-05T12:30:02+03:00 * FB token [no ci] * style * BM scores fix * keyword pattern - apply quotation first * value_array_dictionary_check skip wellquoted * [skip actions] [main] 2024-07-08T18:14:59+03:00 * custom BM * BM fix * python 3.8 is not applicable for benchmark * sample LF * rollback * fix full value
- Loading branch information
Showing
23 changed files
with
672 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import contextlib | ||
|
||
from credsweeper.config import Config | ||
from credsweeper.credentials import LineData | ||
from credsweeper.file_handler.analysis_target import AnalysisTarget | ||
from credsweeper.filters import Filter | ||
from credsweeper.utils import Util | ||
|
||
|
||
class ValueDiscordBotCheck(Filter): | ||
"""Discord bot Token""" | ||
|
||
def __init__(self, config: Config = None) -> None: | ||
pass | ||
|
||
def run(self, line_data: LineData, target: AnalysisTarget) -> bool: | ||
"""Run filter checks on received token which might be structured. | ||
Args: | ||
line_data: credential candidate data | ||
target: multiline target from which line data was obtained | ||
Return: | ||
True, when need to filter candidate and False if left | ||
""" | ||
with contextlib.suppress(Exception): | ||
parts = line_data.value.split('.') | ||
if int(Util.decode_base64(parts[0], padding_safe=True, urlsafe_detect=True)): | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import binascii | ||
import contextlib | ||
import struct | ||
|
||
from credsweeper.common.constants import ASCII | ||
from credsweeper.config import Config | ||
from credsweeper.credentials import LineData | ||
from credsweeper.file_handler.analysis_target import AnalysisTarget | ||
from credsweeper.filters import Filter | ||
|
||
|
||
class ValueGrafanaServiceCheck(Filter): | ||
"""Check that candidate have a known structure""" | ||
|
||
def __init__(self, config: Config = None) -> None: | ||
pass | ||
|
||
def run(self, line_data: LineData, target: AnalysisTarget) -> bool: | ||
"""Run filter checks on received token which might be structured. | ||
Args: | ||
line_data: credential candidate data | ||
target: multiline target from which line data was obtained | ||
Return: | ||
True, if need to filter candidate and False if left | ||
""" | ||
with contextlib.suppress(Exception): | ||
checksum = struct.unpack("<I", bytes.fromhex(line_data.value[38:]))[0] | ||
data = line_data.value[:37].encode(ASCII) | ||
crc32 = binascii.crc32(data) | ||
if checksum == crc32: | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.