def identify_hash(self): """Identify hash type Tries to determine information about a given hash and suggests which algorithm may have been used to generate it based on its length. Returns: Chepy: The Chepy object. Examples: >>> Chepy("6dcd4ce23d88e2ee9568ba546c007c63d9131c1b").identify_hash().o [ {'hashcat': 100, 'john': 'raw-sha1', 'name': 'SHA-1'}, {'hashcat': 4500, 'john': None, 'name': 'Double SHA-1'}, {'hashcat': 6000, 'john': 'ripemd-160', 'name': 'RIPEMD-160'}, {'hashcat': None, 'john': None, 'name': 'Haval-160'}, ... ] """ hashes = [] for h in hashid.HashID().identifyHash(self._convert_to_str()): hashes.append({ "name": h.name, "hashcat": h.hashcat, "john": h.john }) self.state = hashes return self
def verify_hash(self, id): try: hash = hashid.HashID() validhash = False for hashtype in hash.identifyHash(id): if re.search(r'^(sha|md5|blake)', hashtype.name, re.IGNORECASE): validhash = True return validhash except Exception: return False
import logging tmpDirectory = "/sharedTmp" print("App start") #======================================================================== #Setting up regular expressions #This regular expression is used to check passwords list in this format TextOrUser:Password Whitespaces between the semicolon : are ignored. #We first compile it, which create an object we can sue to apply the regex, it is also faster than using the re. function directly #I had to split the negative look-behinds (?<!https) into multiple because python does not seems to support them together (eg : (?<!https|http)) idSemicolumnThenItem = regex.compile( r'\b[^:^\n0-9]+(?<!http)(?<!https)(?<!ftp)(?<!sftp)(?<!rtmp)(?<!ws):([^\s\n]+)' ) #TODO: check this hashID = hashid.HashID() def ack_message(channel, delivery_tag): if channel.is_open: channel.basic_ack(delivery_tag) else: pass def wccount(filename): out = subprocess.Popen(['wc', '-l', filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] return int(out.partition(b' ')[0])