Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion hashid.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import os
import re
import sys
import base64
import binascii
import argparse
from collections import namedtuple

Expand All @@ -33,6 +35,23 @@
Prototype = namedtuple('Prototype', ['regex', 'modes'])
HashInfo = namedtuple('HashInfo', ['name', 'hashcat', 'john', 'extended'])


def is_base64(data):
try:
base64.b64decode(data)
return True
except (TypeError, binascii.Error):
return False


def is_hexstring(data):
try:
binascii.unhexlify(data)
return True
except binascii.Error:
return False


prototypes = [
Prototype(
regex=re.compile(r'^[a-f0-9]{4}$', re.IGNORECASE),
Expand Down Expand Up @@ -740,7 +759,17 @@
Prototype(
regex=re.compile(r'^\$pdf\$[24]\*[34]\*128\*[0-9-]{1,5}\*1\*(16|32)\*[a-f0-9]{32,64}\*32\*[a-f0-9]{64}\*(8|16|32)\*[a-f0-9]{16,64}$', re.IGNORECASE),
modes=[
HashInfo(name='PDF 1.4 - 1.6 (Acrobat 5 - 8)', hashcat=10500, john='pdf', extended=False)])
HashInfo(name='PDF 1.4 - 1.6 (Acrobat 5 - 8)', hashcat=10500, john='pdf', extended=False)]),
Prototype(
regex=re.compile(r'^([a-fA-F0-9]{2})+$', re.IGNORECASE),
modes=[
HashInfo(name='Hex string', hashcat=None, john=None, extended=False),
]),
Prototype(
regex=re.compile(r'^([a-zA-Z0-9+/]{4})*([a-zA-Z0-9+/]{4}|[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)$'),
modes=[
HashInfo(name='Base64', hashcat=None, john=None, extended=False)
]),
]


Expand Down