-
Notifications
You must be signed in to change notification settings - Fork 66
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
Introduction of the mail:password analyzer. #84
Changes from 1 commit
858f191
a97358e
499e51b
4225c0f
5576897
c55ed43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
from .mailanalyzer import MailAnalyzer | ||
from .regexanalyzer import RegexAnalyzer | ||
|
||
|
||
class MailPasswordAnalyzer(RegexAnalyzer): | ||
""" | ||
Analyzer to match an email and password pair. | ||
""" | ||
|
||
name = "EmailPasswordAnalyzer" | ||
|
||
def __init__(self, actions): | ||
regex = MailAnalyzer.pattern + ":(.*)" | ||
super().__init__(actions, regex) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
from unittest import mock | ||
|
||
from pastepwn.analyzers.mailpasswordanalyzer import MailPasswordAnalyzer | ||
|
||
|
||
class TestDBConnAnalyzer(unittest.TestCase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename this one 🙈 . |
||
def setUp(self): | ||
self.analyzer = MailPasswordAnalyzer(None) | ||
self.paste = mock.Mock() | ||
|
||
def test_match_positive(self): | ||
"""Test if positives are recognized""" | ||
|
||
positives = [ | ||
"thesaxmaniac@hotmail.com:neverhood", | ||
"ledzepln1@aol.com:stairway", | ||
"kelsean75@hotmail.com:computer1elray8379@gmail.com:josh8598", | ||
"mekim45@hotmail.com:mullins74", | ||
"jjenkins19@yahoo.com:faster", | ||
"r_m_vincent@yahoo.com:soling12", | ||
"deadally@hotmail.com:balajaga1", | ||
"Choas23@gmail.com:8KlAs432", | ||
"jefftrey@yahoo.com:tanqueray", | ||
"syntex05@mac.com:kobela87", | ||
"michaelbarbra@hotmail.com:2177", | ||
"mcginnis_98@yahoo.com:bentley", | ||
"majikcityqban82@gmail.com:tinpen39", | ||
"pekanays@yahoo.com:warriors", | ||
"g_vanmeter@yahoo.com:torbeet", | ||
"rrothn@yahoo.com:rebsopjul3", | ||
"apryle_douglas@yahoo.com:campbell", | ||
"estocanam2@gmail.com:Firebird1@", | ||
"Samirenzer@yahoo.com:pepper0120", | ||
"davebialik@gmail.com:tr1ang1e", | ||
"kellyjames@atmc.net:ginnyanna", | ||
"Kennedy123@aol.com:Edmonia1", | ||
"rcstanley@ms.metrocast.net:jjba1304", | ||
"this_isatest@example.org:hello,world" | ||
"this-is-another-thest@müller-beispiel.de", | ||
] | ||
|
||
for positive in positives: | ||
self.paste.body = positive | ||
self.assertTrue( | ||
self.analyzer.match(self.paste), f"{positive} do not match." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And as you stated in your comment, this somehow fails on Python 3.5 and earlier (see Travis). Maybe you can change it so that it does work with python 3.4 at least.
|
||
) | ||
|
||
def test_match_negative(self): | ||
"""Test if negatives are not recognized""" | ||
|
||
negatives = [ | ||
"", | ||
None, | ||
"test@example.org", | ||
"example@:hello", | ||
"example@example:hello", | ||
"hello:test@example.org", | ||
] | ||
|
||
for negative in negatives: | ||
self.paste.body = negative | ||
self.assertFalse(self.analyzer.match(self.paste), f"{negative} matches.") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to do
from pastepwn.analyzers import MailPasswordAnalyzer
if you add the analyzer to the package init file