Skip to content

Commit

Permalink
🗓 May 7, 2022 10:22:23 PM
Browse files Browse the repository at this point in the history
🔥 move hashid to Hash plugin
  • Loading branch information
securisec committed May 8, 2022
1 parent 2dff4a1 commit 9124d24
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 39 deletions.
2 changes: 1 addition & 1 deletion chepy/chepy_plugins
27 changes: 0 additions & 27 deletions chepy/modules/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import lazy_import

hashid = lazy_import.lazy_module("hashid")
from typing import TypeVar, Union

from crccheck.crc import Crc8, Crc32, CrcArc
Expand Down Expand Up @@ -38,32 +37,6 @@ class Hashing(ChepyCore):
def __init__(self, *data):
super().__init__(*data)

@ChepyDecorators.call_stack
def identify_hash(self) -> HashingT:
"""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

@ChepyDecorators.call_stack
def sha1(self) -> HashingT:
"""Get SHA1 hash
Expand Down
2 changes: 0 additions & 2 deletions chepy/modules/hashing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from ..core import ChepyCore
from typing import Any, TypeVar, Union
from typing_extensions import Literal as Literal

hashid: Any
HashingT = TypeVar('HashingT', bound='Hashing')
hmac: Any
MD2: Any
Expand All @@ -22,7 +21,6 @@ KDF: Any
class Hashing(ChepyCore):
def __init__(self, *data: Any) -> None: ...
state: Any = ...
def identify_hash(self: HashingT) -> HashingT: ...
def sha1(self: HashingT) -> HashingT: ...
def sha2_256(self: HashingT) -> HashingT: ...
def sha2_512(self: HashingT) -> HashingT: ...
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ emoji
exrex
fire==0.4.0
lazy-import
hashid
hexdump
jsonpickle
prompt_toolkit>=2.0.8
Expand Down
8 changes: 0 additions & 8 deletions tests/test_hashing.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from chepy import Chepy


def test_identify_hash():
assert (
Chepy("6dcd4ce23d88e2ee9568ba546c007c63d9131c1b").identify_hash().o[0]["name"]
== "SHA-1"
)


def test_sha1():
assert Chepy("A").sha1().output == "6dcd4ce23d88e2ee9568ba546c007c63d9131c1b"

Expand Down Expand Up @@ -229,4 +222,3 @@ def test_derive_pbkdf2_key():
.o[:10]
== "6d2a9c4b24"
)

7 changes: 7 additions & 0 deletions tests_plugins/test_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from chepy import Chepy

def test_identify_hash():
assert (
Chepy("6dcd4ce23d88e2ee9568ba546c007c63d9131c1b").identify_hash().o[0]["name"]
== "SHA-1"
)

0 comments on commit 9124d24

Please sign in to comment.