#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# hashid.py - Software to identify the different types of hashes
# Copyright (C) 2013-2015 by c0re <c0re@psypanda.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import io
import os
import re
import sys
import argparse
from collections import namedtuple
__author__ = "c0re"
__version__ = "3.2.0-dev"
__github__ = "https://github.com/psypanda/hashID"
__license__ = "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"
__banner__ = "hashID v{0} by {1} ({2})".format(__version__, __author__, __github__)
Prototype = namedtuple('Prototype', ['regex', 'modes'])
HashInfo = namedtuple('HashInfo', ['name', 'hashcat', 'john', 'extended'])
prototypes = [
Prototype(
regex=re.compile(r'^[a-f0-9]{4}$', re.IGNORECASE),
modes=[
HashInfo(name='CRC-16', hashcat=None, john=None, extended=False),
HashInfo(name='CRC-16-CCITT', hashcat=None, john=None, extended=False),
HashInfo(name='FCS-16', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^[a-f0-9]{8}$', re.IGNORECASE),
modes=[
HashInfo(name='Adler-32', hashcat=None, john=None, extended=False),
HashInfo(name='CRC-32B', hashcat=None, john=None, extended=False),
HashInfo(name='FCS-32', hashcat=None, john=None, extended=False),
HashInfo(name='GHash-32-3', hashcat=None, john=None, extended=False),
HashInfo(name='GHash-32-5', hashcat=None, john=None, extended=False),
HashInfo(name='FNV-132', hashcat=None, john=None, extended=False),
HashInfo(name='Fletcher-32', hashcat=None, john=None, extended=False),
HashInfo(name='Joaat', hashcat=None, john=None, extended=False),
HashInfo(name='ELF-32', hashcat=None, john=None, extended=False),
HashInfo(name='XOR-32', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^[a-f0-9]{6}$', re.IGNORECASE),
modes=[
HashInfo(name='CRC-24', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^(\$crc32\$[a-f0-9]{8}.)?[a-f0-9]{8}$', re.IGNORECASE),
modes=[
HashInfo(name='CRC-32', hashcat=None, john='crc32', extended=False)]),
Prototype(
regex=re.compile(r'^\+[a-z0-9\/.]{12}$', re.IGNORECASE),
modes=[
HashInfo(name='Eggdrop IRC Bot', hashcat=None, john='bfegg', extended=False)]),
Prototype(
regex=re.compile(r'^[a-z0-9\/.]{13}$', re.IGNORECASE),
modes=[
HashInfo(name='DES(Unix)', hashcat=1500, john='descrypt', extended=False),
HashInfo(name='Traditional DES', hashcat=1500, john='descrypt', extended=False),
HashInfo(name='DEScrypt', hashcat=1500, john='descrypt', extended=False)]),
Prototype(
regex=re.compile(r'^[a-f0-9]{16}$', re.IGNORECASE),
modes=[
HashInfo(name='MySQL323', hashcat=200, john='mysql', extended=False),
HashInfo(name='DES(Oracle)', hashcat=3100, john=None, extended=False),
HashInfo(name='Half MD5', hashcat=5100, john=None, extended=False),
HashInfo(name='Oracle 7-10g', hashcat=3100, john=None, extended=False),
HashInfo(name='FNV-164', hashcat=None, john=None, extended=False),
HashInfo(name='CRC-64', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^[a-z0-9\/.]{16}$', re.IGNORECASE),
modes=[
HashInfo(name='Cisco-PIX(MD5)', hashcat=2400, john='pix-md5', extended=False)]),
Prototype(
regex=re.compile(r'^\([a-z0-9\/+]{20}\)$', re.IGNORECASE),
modes=[
HashInfo(name='Lotus Notes/Domino 6', hashcat=8700, john='dominosec', extended=False)]),
Prototype(
regex=re.compile(r'^_[a-z0-9\/.]{19}$', re.IGNORECASE),
modes=[
HashInfo(name='BSDi Crypt', hashcat=None, john='bsdicrypt', extended=False)]),
Prototype(
regex=re.compile(r'^[a-f0-9]{24}$', re.IGNORECASE),
modes=[
HashInfo(name='CRC-96(ZIP)', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^[a-z0-9\/.]{24}$', re.IGNORECASE),
modes=[
HashInfo(name='Crypt16', hashcat=None, john=None, extended=False)]),
Prototype(
regex=re.compile(r'^(\$md2\$)?[a-f0-9]{32}$', re.IGNORECASE),
modes=[
HashInfo(name='MD2', hashcat=None, john='md2', extended=False)]),
Prototype(
regex=re.compile(r'^[a-f0-9]{32}(:.+)?$', re.IGNORECASE),
modes=[
HashInfo(name='MD5', hashcat=0, john='raw-md5', extended=False),
HashInfo(name='MD4', hashcat=900, john='raw-md4', extended=False),
HashInfo(name='Double MD5', hashcat=2600, john=None, extended=False),
HashInfo(name='LM', hashcat=3000, john='lm', extended=False),
HashInfo(name='RIPEMD-128', hashcat=None, john='ripemd-128', extended=False),
HashInfo(name='Haval-128', hashcat=None, john='haval-128-4', extended=False),
HashInfo(name='Tiger-128', hashcat=None, john=None, extended=False),
HashInfo(name='Skein-256(128)', hashcat=None, john=None, extended=False),
HashInfo(name='Skein-512(128)', hashcat=None, john=None, extended=False),
HashInfo(name='Lotus Notes/Domino 5', hashcat=8600, john='lotus5', extended=False),
HashInfo(name='Skype', hashcat=23, john=None, extended=False),
HashInfo(name='ZipMonster', hashcat=None, john=None, extended=True),
HashInfo(name='PrestaShop', hashcat=11000, john=None, extended=True),
HashInfo(name='md5(md5(md5($pass)))', hashcat=3500, john=None, extended=True),
HashInfo(name='md5(strtoupper(md5($pass)))', hashcat=4300, john=None, extended=True),
HashInfo(name='md5(sha1($pass))', hashcat=4400, john=None, extended=True),
HashInfo(name='md5($pass.$salt)', hashcat=10, john=None, extended=True),
HashInfo(name='md5($salt.$pass)', hashcat=20, john=None, extended=True),
HashInfo(name='md5(unicode($pass).$salt)', hashcat=30, john=None, extended=True),
HashInfo(name='md5($salt.unicode($pass))', hashcat=40, john=None, extended=True),
HashInfo(name='HMAC-MD5 (key = $pass)', hashcat=50, john='hmac-md5', extended=True),
HashInfo(name='HMAC-MD5 (key = $salt)', hashcat=60, john='hmac-md5', extended=True),
HashInfo(name='md5(md5($salt).$pass)', hashcat=3610, john=None, extended=True),
HashInfo(name='md5($salt.md5($pass))', hashcat=3710, john=None, extended=True),
HashInfo(name='md5($pass.md5($salt))', hashcat=3720, john=None, extended=True),
HashInfo(name='md5($salt.$pass.$salt)', hashcat=3810, john=None, extended=True),
HashInfo(name='md5(md5($pass).md5($salt))', hashcat=3910, john=None, extended=True),
HashInfo(name='md5($salt.md5($salt.$pass))', hashcat=4010, john=None, extended=True),
HashInfo(name='md5($salt.md5($pass.$salt))', hashcat=4110, john=None, extended=True),
HashInfo(name='md5($username.0.$pass)', hashcat=4210, john=None, extended=True)]),
Prototype(
regex=re.compile(r'^(\$snefru\$)?[a-f0-9]{32}$', re.IGNORECASE),
mode