stampery / mongoaudit

🔥 A powerful MongoDB auditing and pentesting tool 🔥
https://mongoaud.it
MIT License
1.32k stars 136 forks source link

re-updated mail regex #21

Closed Ekultek closed 7 years ago

Ekultek commented 7 years ago

Fixed:

>>> def validate_email(r, email):
    import re
    valid = re.compile(r)
    if valid.match(email):
        print "Regex: '{}' matched: {}".format(r, email)
    else:
        print "Regex: '{}' did not match: {}".format(r, email)
>>> emails = ["almira_eckl@mail.com", "por.bop@msn.com", "trinit_eckley@myspace.com", "fifranc@freewebmail.com", "test@test.academy", "test@test.accountant", "test@test.accountants", "bop.bop@gmail.рф"]
>>> regs = [r"(\w+.\w+?@\w+?\x2E.+)", r"^[^@]+@[^@]+\.[^@]+$"]
>>> for email in emails:
    for r in regs:
        validate_email(r, email)
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: almira_eckl@mail.com
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: almira_eckl@mail.com
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: por.bop@msn.com
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: por.bop@msn.com
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: trinit_eckley@myspace.com
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: trinit_eckley@myspace.com
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: fifranc@freewebmail.com
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: fifranc@freewebmail.com
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: test@test.academy
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: test@test.academy
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: test@test.accountant
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: test@test.accountant
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: test@test.accountants
Regex: '^[^@]+@[^@]+\.[^@]+$' matched: test@test.accountants
Regex: '(\w+.\w+?@\w+?\x2E.+)' matched: bop.bop@gmail.рф
Regex: '^[^@]+@[^@]+\.[^@]+$' did not match: bop.bop@gmail.рф
aesedepece commented 7 years ago

Hi @Ekultek, Sorry to bother, but r"(\w+.\w+?@\w+?\x2E.+)" would match foo@bar@beer.tld, which is not an acceptable email address at all. Before final pull request, please rebase or pull changes, as the src/tools.py files no longer exists. Look instead for mongoaudit/tools.py. :+1:

Ekultek commented 7 years ago

Damn will it really? Alright give me a bit and I'll resubmit it.

Ekultek commented 7 years ago

I admit it, your regex is better, closing