Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented MailChimp API Key Analyzer (#142)
- Loading branch information
1 parent
c884cb6
commit 2e5302d
Showing
3 changed files
with
49 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 MailChimpApiKeyAnalyzer(RegexAnalyzer): | ||
|
||
def __init__(self, actions): | ||
regex = r"[0-9a-f]{32}-us[0-9]{12}" | ||
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,39 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.mailchimpapikeyanalyzer import MailChimpApiKeyAnalyzer | ||
|
||
|
||
class TestMailChimpApiKeyAnalyzer(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.analyzer = MailChimpApiKeyAnalyzer(None) | ||
self.paste = mock.Mock() | ||
|
||
def test_match_positive(self): | ||
"""Test if positives are recognized""" | ||
self.paste.body = "87b6ac876aca87c687a6c87a6ca876c8-us000000000000" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
self.paste.body = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-us000000000000" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
self.paste.body = "12312312312312312312312312312312-us000000000000" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
self.paste.body = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-us345646456456" | ||
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)) | ||
self.paste.body = "asdasdasdasdasdasdasdasdasdasdas-us000000000000" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
self.paste.body = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-it000000000000" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
self.paste.body = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-usasdasdasdasd" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |