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

Command line password patterns #601

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
810c578
enchancements
babenek Aug 27, 2024
6139df7
updBMscor
babenek Aug 27, 2024
3380a28
testfix
babenek Aug 27, 2024
2eebf31
BM custom ref: auxiliary
babenek Aug 27, 2024
fbc5388
BM markup scores fix, style
babenek Aug 28, 2024
cf00ff3
ML integrity CI check
babenek Aug 28, 2024
056ebc0
fix WordInPath
babenek Aug 28, 2024
0c51c20
ml upd
babenek Aug 28, 2024
14bf342
ml_model integrity
babenek Aug 28, 2024
dbcf085
BM scores upd
babenek Aug 28, 2024
302e31d
cmdpass
babenek Aug 28, 2024
28416f6
split the rules
babenek Aug 28, 2024
841f145
samples
babenek Aug 28, 2024
ae75d71
testfix
babenek Aug 28, 2024
c58991e
commandline pass for openssl prefix 'pass:'
babenek Aug 29, 2024
6145a9e
cmdpass BM ref
babenek Aug 29, 2024
d31720b
file: env: fd: invalid prefixes
babenek Aug 29, 2024
3ab7d5a
[skip actions] [cmdpass] 2024-08-29T14:23:20+03:00
babenek Aug 29, 2024
562b7e5
[skip actions] [cmdpass] 2024-08-29T14:23:48+03:00
babenek Aug 29, 2024
72677be
[skip actions] [auxiliary] 2024-08-29T16:58:32+03:00
babenek Aug 29, 2024
8f886af
retrained
babenek Aug 29, 2024
0e1e9b1
BMcustom ref
babenek Aug 29, 2024
44b6cd4
test fix
babenek Aug 29, 2024
9d38b78
retrain
babenek Aug 29, 2024
acb6575
ml_hashes order
babenek Aug 30, 2024
84f26ee
paired brackets refactoring
babenek Aug 30, 2024
2b3286c
retrain
babenek Aug 30, 2024
f8ed3dc
style
babenek Aug 30, 2024
d97c5f5
refactorriga
babenek Aug 31, 2024
c3f9b8b
retrain
babenek Aug 31, 2024
2d39f03
[skip actions] [cmdpass] 2024-08-31T12:52:24+03:00
babenek Aug 31, 2024
abd5ac8
refactoring
babenek Aug 31, 2024
91b87bf
PossibleComment uses regex
babenek Aug 31, 2024
6c09f08
regex
babenek Aug 31, 2024
03ac805
PossibleComment replacing
babenek Aug 31, 2024
19cb99d
PossibleComment replacing2
babenek Aug 31, 2024
ea7fb19
upd
babenek Aug 31, 2024
6e63489
fix
babenek Aug 31, 2024
c99f548
Example pattern <xxx>
babenek Aug 31, 2024
2df0fea
[skip actions] [cmdpass] 2024-08-31T18:37:32+03:00
babenek Aug 31, 2024
d25601a
tmp
babenek Aug 31, 2024
3ff118d
fixes
babenek Sep 1, 2024
8f37a37
draw improved
babenek Sep 1, 2024
f37a5fc
plot improved
babenek Sep 1, 2024
3cae675
retrain
babenek Sep 1, 2024
d531c58
testfix
babenek Sep 1, 2024
69de5e8
print info in bottom
babenek Sep 1, 2024
4694cfd
style
babenek Sep 1, 2024
254c7d4
docs
babenek Sep 1, 2024
6518c50
token, secret for cmd passwd
babenek Sep 2, 2024
e9dceb8
token, secret fix
babenek Sep 2, 2024
4d1a04b
renaming
babenek Sep 2, 2024
46f43ba
[skip actions] [cmdpass] 2024-09-02T15:21:57+03:00
babenek Sep 2, 2024
9d18807
retrain
babenek Sep 2, 2024
331c57f
testfix
babenek Sep 2, 2024
8fd86a4
checkfix
babenek Sep 2, 2024
4969a03
stylefix
babenek Sep 2, 2024
c937d75
doc fix
babenek Sep 3, 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
93 changes: 48 additions & 45 deletions .ci/benchmark.txt

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
Expand Down Expand Up @@ -72,7 +73,8 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
Expand Down Expand Up @@ -169,7 +171,8 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
Expand Down Expand Up @@ -351,7 +354,8 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ jobs:
- name: Check ml_model.onnx integrity
if: ${{ always() && steps.code_checkout.conclusion == 'success' }}
run: |
md5sum --binary credsweeper/ml_model/ml_config.json | grep 2b29c5e1aa199d14b788652bd542c7c0
md5sum --binary credsweeper/ml_model/ml_model.onnx | grep 88f37978fc0599ac8d1bf732ad40c077

md5sum --binary credsweeper/ml_model/ml_config.json | grep caa591316d13b6fde3d27f7929c44651
md5sum --binary credsweeper/ml_model/ml_model.onnx | grep 201150931cfea4261d35626237585afe

# # # line ending

Expand Down
8 changes: 5 additions & 3 deletions credsweeper/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ class KeywordPattern:
r"[^:='\"`<>{?!&]*)[`'\"]*)" # <variable>
separator = r"\s*\]?\s*" \
r"(?P<separator>:( [a-z]{3,9}[?]? )?=" \
r"|:|=>|!=|===|==|=)" \
r"\s*(?P<wrap>((new\s*)?\w|\.|->|\(|\[)*[\[\(\{](\w{1,32}=)?\s*)?"
r"|:|=(>|&gt;|\\u0026gt;)|!=|===|==|=)" \
r"(\s|\\[tnr])*"\
r"(ConvertTo-SecureString(\s*-String)?\s*)?" \
r"(?P<wrap>((new\s*)?\w|\.|-(>|&gt;|\\u0026gt;)|\(|\[)*[\[\(\{](\w{1,32}=)?\s*)?"
# Authentication scheme ( oauth | basic | bearer | apikey ) precedes to credential
value = r"(?P<value_leftquote>((b|r|br|rb|u|f|rf|fr|\\{0,8})?[`'\"]){1,4})?" \
r"( ?(oauth|bot|basic|bearer|apikey|accesskey) )?" \
r"(?P<value>" \
r"(?(value_leftquote)(?:\\[tnrux0-7][0-9a-f]*|[^`'\"\\])|(?:\\n|\\r|\\?[^\s`'\"\\,;])){1,8000}" \
r"(?(value_leftquote)(?:\\[tnr]|\\[ux0-7][0-9a-f]*|[^`'\"\\])|(?:\\t|\\n|\\r|\\?[^\s`'\"\\,;])){1,8000}" \
r"|(?:\{[^}]{3,8000}\})|(?:<[^>]{3,8000}>)" \
r")" \
r"(?(value_leftquote)(?P<value_rightquote>(\\{0,8}[`'\"]){1,4})?|(?(wrap)[\]\)\},;]))"
Expand Down
14 changes: 11 additions & 3 deletions credsweeper/credentials/line_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,17 @@ def clean_bash_parameters(self) -> None:
self.value = value_whsp[0]

def clean_toml_parameters(self) -> None:
"""Curly brackets may be caught in TOML format"""
while self.value.endswith('}') and '{' in self.line[:self.value_start]:
self.value = self.value[:-1]
"""Parenthesis, curly and squared brackets may be caught in TOML format and bash. Simple clearing"""
dirty = self.value and self.value[-1] in ['}', ']', ')']
line_before_value = self.line[:self.value_start]
while dirty:
dirty = False
for left, right in [('{', '}'), ('[', ']'), ('(', ')')]:
if self.value.endswith(right) and left not in self.value \
and line_before_value.count(left) > line_before_value.count(right):
# full match does not reasonable to implement due open character may be in other line
self.value = self.value[:-1]
dirty = True

def sanitize_variable(self) -> None:
"""Remove trailing spaces, dashes and quotations around the variable. Correct position."""
Expand Down
11 changes: 9 additions & 2 deletions credsweeper/filters/value_allowlist_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ class ValueAllowlistCheck(Filter):
"""Check that patterns from the list is not present in the candidate value."""

ALLOWED = [
r"ENC\(.*\)", r"ENC\[.*\]", r"\$\{.*\}", r"#\{.*\}", r"\{\{.+\}\}", r"([.a-z0-9]|->)+\(.*\)", r"\S{0,5}\*{5,}",
r".*@@@hl@@@(암호|비번|PW|PASS)@@@endhl@@@.*"
r"ENC\(.*\)", #
r"ENC\[.*\]", #
r"\$\{[a-z_][0-9a-z_]*\}", #
r"\$[a-z_][0-9a-z_]*", #
r"#\{.*\}", #
r"\{\{.+\}\}", #
r"([.a-z0-9]|->)+\(.*\)(\W|$)", #
r"\S{0,5}\*{5,}", #
r".*@@@hl@@@(암호|비번|PW|PASS)@@@endhl@@@.*", #
]
ALLOWED_PATTERN = re.compile( #
Util.get_regex_combine_or(ALLOWED), #
Expand Down
2 changes: 1 addition & 1 deletion credsweeper/filters/value_pattern_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, config: Config):
self.pattern_len = config.pem_pattern_len
else:
self.pattern_len = config.pattern_len
self.pattern = re.compile(fr"(.)\1{{{str(self.pattern_len - 1)},}}")
self.pattern = re.compile(fr"([^ ])\1{{{str(self.pattern_len - 1)},}}")

def equal_pattern_check(self, line_data_value: str) -> bool:
"""Check if candidate value contain 4 and more same chars or numbers sequences.
Expand Down
Loading
Loading