Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class DBConnAnalyzer(RegexAnalyzer):
"""Analyzer to match on email addresses via regex"""
name = "DBConnAnalyzer"
def __init__(self, actions):
# https:// should be ignored
regex = r"(\b(?!http(?:s)?\b)\w+[a-zA-Z]+:\/\/[a-zA-z0-9.:,\-@]+)"
super().__init__(actions, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class SHAHashAnalyzer(RegexAnalyzer):
"""Analyzer to match SHA password hashes via regex"""
name = "SHAHashAnalyzer"
def __init__(self, actions):
regex = r"[a-f0-9]{40}"
super().__init__(actions, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class PhoneNumberAnalyzer(RegexAnalyzer):
"""Analyzer to match Phone Numbers"""
def __init__(self, action):
"""Analyzer to match international phone numbers"""
# from stackoverflow: https://stackoverflow.com/questions/2113908/what-regular-expression-will-match-valid-international-phone-numbers
country_code_regex = "\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)"
# adapted from the same stackoverflow
national_number = "(\W*\d){2,17}"
regex = "(^|\s)" + country_code_regex + "\s*" + national_number + "($|\s)"
super().__init__(action, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class BcryptHashAnalyzer(RegexAnalyzer):
"""Analyzer to match bcrypt password hashes via regex"""
name = "BcryptHashAnalyzer"
def __init__(self, action):
regex = "\$2[ayb]\$.{56}"
super().__init__(action, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class EpicKeyAnalyzer(RegexAnalyzer):
"""Analyzer to match Epic Licensing Keys"""
def __init__(self, action):
"""
Analyzer to match Epic Licensing Keys
:param action: Single action or list of actions to be executed when a paste matches
"""
# Applied general A-Z or 0-9 based on example provided
# Regex can be adjusted if certain characters are not valid
regex = r"\b(?
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class PrivateKeyAnalyzer(RegexAnalyzer):
"""Analyzer to match private keys beginnigs via regex"""
name = "PrivateKeyAnalyzer"
def __init__(self, actions):
regex = r"[\-]{4,5}(?: )?BEGIN(?: [A-Z0-9]+)? PRIVATE KEY(?: BLOCK)?(?: )?[\-]{4,5}[\s\w\:\"\-\/\+\=]+?[\-]{4,5}(?: )?END(?: [A-Z0-9]+)? " \
r"PRIVATE KEY( BLOCK)?(?: )?[\-]{4,5}"
super().__init__(actions, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class SlackWebhookAnalyzer(RegexAnalyzer):
"""Analyzer to match (likely) Slack Webhook URLs"""
def __init__(self, action):
"""
Analyzer to match (likely) Slack Webhook URLs
:param action: Single action or list of actions to be executed when a paste matches
"""
regex = r'https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'
super().__init__(action, regex)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class GoogleOAuthKeyAnalyzer(RegexAnalyzer):
def __init__(self, actions):
regex = r"[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com"
super().__init__(actions, regex)
# -*- coding: utf-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)
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer
class MD5HashAnalyzer(RegexAnalyzer):
"""Analyzer to match MD5 password hashes via regex"""
name = "MD5HashAnalyzer"
def __init__(self, actions):
regex = r"[a-f0-9]{32}"
super().__init__(actions, regex)