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

Add mount commands and fstab entries with clear credentials #210

Merged
merged 5 commits into from
Oct 15, 2021
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
28 changes: 26 additions & 2 deletions pywhat/Data/regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@
},
{
"Name": "SSHPass Clear Password Argument",
"Regex": "^(sshpass [^\\n]*-p[ ]+[^ ]+)$",
"Regex": "^(sshpass [^\\n]*-p\\s+[^ ]+)$",
"plural_name": false,
"Description": null,
"Rarity": 1,
Expand All @@ -1026,6 +1026,30 @@
"Bug Bounty"
]
},
{
"Name": "Mount Command With Clear Credentials",
"Regex": "^(mount(.cifs)?\\s+[^\\n]*(username=[^, \\n]+[^\\n ]*password=[^, \\n]+|password=[^, \\n]+[^\\n ]*username=[^, \\n]+))$",
"plural_name": false,
"Description": null,
"Rarity": 1,
"URL": null,
"Tags": [
"Credentials",
"Bug Bounty"
]
},
{
"Name": "CIFS Fstab Entry With Clear Credentials",
"Regex": "^(cifs\\s+[^\\n]*(username=[^, \\n]+[^\\n ]*password=[^, \\n]+|password=[^, \\n]+[^\\n ]*username=[^, \\n]+))$",
"plural_name": false,
"Description": null,
"Rarity": 1,
"URL": null,
"Tags": [
"Credentials",
"Bug Bounty"
]
},
{
"Name": "Google Cloud Platform API Key",
"Regex": "(?i)^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
Expand Down Expand Up @@ -1783,7 +1807,7 @@
"ObjectID"
]
},

{
"Name": "Recent Unix Timestamp",
"Regex": "^([0-9]{10})$",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_regex_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_name_capitalization():
assert word.title() == word, (
f'Wrong capitalization in regex name: "{entry_name}"\n'
f'Expected: "{entry_name.title()}"\n'
"Please capitalize every the first letter of each word."
"Please capitalize the first letter of each word."
)


Expand Down
26 changes: 26 additions & 0 deletions tests/test_regex_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,3 +1035,29 @@ def test_sshpass():
def test_sshpass_multiple_args():
res = r.check(["sshpass -P 'Please enter your password' -p MyPassw0RD!"])
_assert_match_first_item("SSHPass Clear Password Argument", res)


def test_mount_command():
res = r.check(["mount -o username=myuser,password=password"])
_assert_match_first_item("Mount Command With Clear Credentials", res)


def test_mountcifs_command():
res = r.check(["mount.cifs -o username=myuser,password=password"])
_assert_match_first_item("Mount Command With Clear Credentials", res)


def test_complex_mount_command():
res = r.check(
[
"mount -t cifs -osec=ntlmv2,password=S3cUr3D!,domain=mydomain,noserverino,username=H4x0r"
]
)
_assert_match_first_item("Mount Command With Clear Credentials", res)


def test_cifs_fstab_entry():
res = r.check(
["cifs uid=1000,password=password,gid=1000,noperm,nofail,username=myuser"]
)
_assert_match_first_item("CIFS Fstab Entry With Clear Credentials", res)