-
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.
Browse files
Browse the repository at this point in the history
Fixes #82
- Loading branch information
1 parent
320b6a9
commit f0af9cb
Showing
3 changed files
with
85 additions
and
10 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,12 @@ | ||
# -*- coding: utf-8 -*- | ||
from .regexanalyzer import RegexAnalyzer | ||
|
||
_EMAIL_PASSWORD_REGEX = r'[\w\.\+_-]+@[\w\._-]+\.[a-zA-Z]*\:[\w\.\+\!\$\#\^&\*\(\)\{\}\[\]\_\-\@\%\=\§\\\/\'\`\´\?\<\>\;\"\:\|\,\~]+$' | ||
|
||
|
||
class EmailPasswordPairAnalyzer(RegexAnalyzer): | ||
"""Analyzer to match username:password pairs""" | ||
name = "EmailPasswordPairAnalyzer" | ||
|
||
def __init__(self, actions): | ||
super().__init__(actions, _EMAIL_PASSWORD_REGEX) |
55 changes: 55 additions & 0 deletions
55
pastepwn/analyzers/tests/emailpasswordpairanalyzer_test.py
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,55 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.emailpasswordpairanalyzer import EmailPasswordPairAnalyzer | ||
|
||
|
||
class TestWordAnalyzer(unittest.TestCase): | ||
def setUp(self): | ||
self.obj = mock.Mock() | ||
|
||
def test_match(self): | ||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "This is a Test" | ||
self.assertFalse(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "{a: 'b'}" | ||
self.assertFalse(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "" | ||
self.assertFalse(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "\t\n" | ||
self.assertFalse(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "\n\n" | ||
self.assertFalse(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "[email protected]:Firebird1@" | ||
self.assertTrue(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "[email protected]:abcd" | ||
self.assertTrue(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "[email protected]:aq12ws" | ||
self.assertTrue(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "[email protected]:Fireb§" | ||
self.assertTrue(analyzer.match(self.obj)) | ||
|
||
analyzer = EmailPasswordPairAnalyzer(None) | ||
self.obj.body = "[email protected]:Firebird1@" | ||
self.assertTrue(analyzer.match(self.obj)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |