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 TOTP URIs #190

Merged
merged 3 commits into from
Oct 9, 2021
Merged

Add TOTP URIs #190

merged 3 commits into from
Oct 9, 2021

Conversation

PabloLec
Copy link
Contributor

@PabloLec PabloLec commented Oct 9, 2021

This commit adds TOTP URIs regex and related tests.
You might find TOTP URIs in Google Authenticator, Authy, Bitwarden, etc. backups. Or just anywhere if you're doing Android/iOS pentesting. And with its base-32 key, TOTP is all yours !

I might add some other pentesting related regex in the next few days :)

Comment on lines 974 to 985
{
"Name": "TOTP URI",
"Regex": "^([^?\\n]+:\/\/totp\/[^\\n]+secret=[A-Z2-7=]+[^\\n]+)$",
"plural_name": false,
"Description": "TOTP URI with user secret key",
"Rarity": 1,
"URL": "",
"Tags": [
"Credentials",
"TOTP"
]
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
"Name": "TOTP URI",
"Regex": "^([^?\\n]+:\/\/totp\/[^\\n]+secret=[A-Z2-7=]+[^\\n]+)$",
"plural_name": false,
"Description": "TOTP URI with user secret key",
"Rarity": 1,
"URL": "",
"Tags": [
"Credentials",
"TOTP"
]
},
{
"Name": "Time-Based One-Time Password (TOTP) URI",
"Regex": "^([^?\\n]+:\/\/totp\/[^\\n]+secret=[A-Z2-7=]+[^\\n]+)$",
"plural_name": false,
"Description": null,
"Rarity": 1,
"URL": null,
"Tags": [
"Credentials",
"TOTP",
"Bug Bounty"
]
},

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this? :)

Copy link
Contributor Author

@PabloLec PabloLec Oct 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not ! Not sure about the bug bounty tag though. I guess it would be rather useful for a pentester, searching for vulnerabilities/credentials and not proper bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I'll leave the Bug Bounty tag. Looking at other entries in regex.json I see it associated with similar topics like API keys.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the bug bounty tag though

If you have this URL, you can access someones 2FA right? That's definitely a vuln :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the secret arg value is what you need to get the 2FA code. This kind of URI is what is inside QR Codes provided by all websites. And you can also find it inside backup files made by people using Authy, Google Authenticator, Bitwarden, etc.

Comment on lines 623 to 627
def test_file_fixture_totp_URI():
runner = CliRunner()
result = runner.invoke(main, ["fixtures/file"])
assert result.exit_code == 0
assert re.findall("TOTP URI", str(result.output))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice test!

Comment on lines 1019 to 1024
res = r.check(
[
"otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
]
)
assert "TOTP URI" in str(res)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert it's the first item? We have a function for this at the top of this file :) _assert_match_first_item

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just tested it, it does work. I think I had a doubt with regular URL match but it indeed come as first item.

@bee-san
Copy link
Owner

bee-san commented Oct 9, 2021

Woo! Thanks :) gonna merge! 🥳

@bee-san bee-san enabled auto-merge October 9, 2021 09:03
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2021

Codecov Report

Merging #190 (c7418ff) into main (07f167c) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #190      +/-   ##
==========================================
+ Coverage   92.06%   92.11%   +0.05%     
==========================================
  Files          13       13              
  Lines        1600     1611      +11     
==========================================
+ Hits         1473     1484      +11     
  Misses        127      127              
Impacted Files Coverage Δ
tests/test_click.py 98.15% <100.00%> (+0.02%) ⬆️
tests/test_regex_identifier.py 98.52% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f167c...c7418ff. Read the comment docs.

@PabloLec
Copy link
Contributor Author

PabloLec commented Oct 9, 2021

Ok, just pushed the above edits and added a more complex test, especially to test arguments position swapping inside the URI.

@bee-san bee-san merged commit 69786ae into bee-san:main Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants