-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from Ideneal/GoogleOAuthKeyAnalyzer
Implemented Google OAuth Key Analyzer
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .regexanalyzer import RegexAnalyzer | ||
|
||
|
||
class GoogleOAuthKeyAnalyzer(RegexAnalyzer): | ||
|
||
def __init__(self, actions): | ||
regex = r"[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com" | ||
super().__init__(actions, regex) |
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,57 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.googleoauthkeyanalyzer import GoogleOAuthKeyAnalyzer | ||
|
||
|
||
class TestGoogleOAuthKeyAnalyzer(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.analyzer = GoogleOAuthKeyAnalyzer(None) | ||
self.paste = mock.Mock() | ||
|
||
def test_match_positive(self): | ||
"""Test if positives are recognized""" | ||
# google key dump | ||
self.paste.body = "6243-jhgcawesuycgaweiufyugfaiwyesfbaw.apps.googleusercontent.com" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# google key dump | ||
self.paste.body = "6243-IUFHERIUFHASOEIRUFGHDOZIFUGVDHSF.apps.googleusercontent.com" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# google key dump | ||
self.paste.body = "6243-18723612873612873621367128736128.apps.googleusercontent.com" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# google key dump | ||
self.paste.body = "1-jhgcawesuycgaweiufyugfaiwyesfbaw.apps.googleusercontent.com" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# google key dump | ||
self.paste.body = "6242345234234234234234234233-jhgcawesuycgaweiufyugfaiwyesfbaw.apps.googleusercontent.com" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
def test_match_negative(self): | ||
"""Test if negatives are not recognized""" | ||
self.paste.body = "" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
self.paste.body = None | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid length | ||
self.paste.body = "6243-jhgcawesuycgaweiufyugfaisfbaw.apps.googleusercontent.com" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid numbers | ||
self.paste.body = "-jhgcawesuycgaweiufyugfaiwyesfbaw.apps.googleusercontent.com" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid domain | ||
self.paste.body = "6243-jhgcawesuycgaweiufyugfaiwyesfbaw.apps.google.com" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |