Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new adobe key analyzer. Also adds tests for the md5 analyzer.
- Loading branch information
1 parent
f0af9cb
commit 4e52345
Showing
5 changed files
with
141 additions
and
3 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,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from .regexanalyzer import RegexAnalyzer | ||
|
||
|
||
class AdobeKeyAnalyzer(RegexAnalyzer): | ||
"""Analyzer to match Adobe License Keys""" | ||
|
||
def __init__(self, action): | ||
""" | ||
Analyzer to match Adobe License Keys | ||
:param action: Single action or list of actions to be executed when a paste matches | ||
""" | ||
# Tested Regex against https://pastebin.com/fxWBGf8t | ||
regex = r"\b[0-9]{4}(-[0-9]{4}){5}\b" | ||
|
||
super().__init__(action, 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
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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.adobekeyanalyzer import AdobeKeyAnalyzer | ||
|
||
|
||
class TestAdobeKeyAnalyzer(unittest.TestCase): | ||
def setUp(self): | ||
self.analyzer = AdobeKeyAnalyzer(None) | ||
self.paste = mock.Mock() | ||
|
||
def test_match_positive(self): | ||
"""Test if positives are recognized""" | ||
# adobe key dump | ||
self.paste.body = "1118-1993-2045-6322-6067-9110" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# adobe key dump | ||
self.paste.body = "1118-1551-7298-8490-8910-4435" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# adobe key dump | ||
self.paste.body = "1118-1088-9818-3636-2479-0297" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# adobe key dump | ||
self.paste.body = "1118-1194-1581-4556-8113-6593" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# part of a sentence | ||
self.paste.body = "Hey, I have your key right here: 1118-1470-8779-0264-4009-3244!" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# Newline seperated microsoft key | ||
self.paste.body = "1118-1993-2046-6322-6067-9110\n1118-1470-8779-0264-4009-3244" | ||
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 = "1118-1470-8779-0264-4009-32445" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid length | ||
self.paste.body = "1118-1470-8779-0264-4009-324" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid Characters | ||
self.paste.body = "1118-1194-1581-4556-8113-659A" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,60 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.md5hashanalyzer import MD5HashAnalyzer | ||
|
||
|
||
class TestMD5HashAnalyzer(unittest.TestCase): | ||
def setUp(self): | ||
self.analyzer = MD5HashAnalyzer(None) | ||
self.paste = mock.Mock() | ||
|
||
def test_match_positive(self): | ||
"""Test if positives are recognized""" | ||
# md5 hash of 128 character string: ndq=S)t<5dgQhD7rCyAZ<?k,b&Zh-t^@'d=kaf:tK$PH\8HSzt%q9pX&RsGuYAcnmy9Rh!'(9sWt.d&\hS,LSA4>#Gn@sYn``5Tt6X`h'Hn_Y-"F>DkGr'\/:4kLF:D" | ||
self.paste.body = "5812c57a01b5efa30af09d4f9388e50d" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# md5 hash of 64 character string: sa.tpMvv#J{q)tZfz,W[5Hq*Yz%kN(,8j)p>'g["d^mSLHkD)gZLVxk/,}#aVxv* | ||
self.paste.body = "372f202bdf0f16dfa41c101fc6a41695" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# md5 hash of 32 character string: zw8hspDAZ(\w]K/v~yZaa_m$6awgF4rj | ||
self.paste.body = "2287c6975240f865a9945ec9bcc0eead" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# md5 hash of 16 character string: cY4>szK'>(?48tz= | ||
self.paste.body = "f2195cea00cc796676f77b9d19473f7a" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
self.paste.body = "my super cool hash is 2287c6975240f865a9945ec9bcc0eead and here's some more text" | ||
self.assertTrue(self.analyzer.match(self.paste)) | ||
|
||
# Newline-separated valid hashes | ||
self.paste.body = "2287c6975240f865a9945ec9bcc0eead\n372f202bdf0f16dfa41c101fc6a41695" | ||
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 character 'g' | ||
self.paste.body = "f2195cea00cc796676f77b9d19473f7g" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# SHA Hash | ||
self.paste.body = "f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
# Invalid MD5 hash length | ||
self.paste.body = "f2195cea00cc796676f77b9d19473f7" | ||
self.assertFalse(self.analyzer.match(self.paste)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |