Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHA1, SHA256, SHA384, SHA512 are not working #53

Open
23harshhita opened this issue Dec 20, 2023 · 1 comment
Open

SHA1, SHA256, SHA384, SHA512 are not working #53

23harshhita opened this issue Dec 20, 2023 · 1 comment

Comments

@23harshhita
Copy link

CODE ERREUR : 002

@Shaggy736
Copy link

#!/usr/bin/env python3

import re
import os
import requests
import argparse
import concurrent.futures
import hashlib # Import hashlib for local hash calculation

parser = argparse.ArgumentParser()
parser.add_argument('-s', help='hash', dest='hash')
parser.add_argument('-f', help='file containing hashes', dest='file')
parser.add_argument('-d', help='directory containing hashes', dest='dir')
parser.add_argument('-t', help='number of threads', dest='threads', type=int)
args = parser.parse_args()

Other existing imports

Existing code...

Update supported hash functions

md5 = [gamma, alpha, beta, theta, delta]
sha1 = [alpha, beta, theta, delta]
sha256 = [alpha, beta, theta]
sha384 = [alpha, beta, theta]
sha512 = [alpha, beta, theta]

New hash function for local calculation

def local_hash(hashvalue, hashtype):
try:
algorithm = getattr(hashlib, hashtype.lower())()
algorithm.update(hashvalue.encode())
return algorithm.hexdigest()
except AttributeError:
return False

Add local hash function to corresponding hash types

sha1.append(local_hash)
sha256.append(local_hash)
sha384.append(local_hash)
sha512.append(local_hash)

Existing code...

Modify the crack function to handle both external API and local hash

def crack(hashvalue, hashtype):
result = False
for api in globals()[hashtype.lower()]: # Use globals() to dynamically select the hash functions
r = api(hashvalue, hashtype)
if r:
return r
return False

Existing code...

if directory:
try:
grepper(directory)
except KeyboardInterrupt:
pass

elif file:
try:
miner(file)
except KeyboardInterrupt:
pass
with open('cracked-%s' % file.split('/')[-1], 'w+') as f:
for hashvalue, cracked in result.items():
f.write(hashvalue + ':' + cracked + '\n')
print('%s Results saved in cracked-%s' % (info, file.split('/')[-1]))

elif args.hash:
single(args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants