From caf1f3f3dfc7985ad7c3cc03c8f51f5f056decf1 Mon Sep 17 00:00:00 2001 From: Morgan-Phoenix <73711602+Morgan-Phoenix@users.noreply.github.com> Date: Sat, 6 Nov 2021 20:57:44 +0530 Subject: [PATCH 1/4] Created a Map of to be used functions of passlib --- enrocrypt/hashing.py | 15 ++++---- map/passlib_functions.json | 74 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 map/passlib_functions.json diff --git a/enrocrypt/hashing.py b/enrocrypt/hashing.py index 97abacb..91c742d 100644 --- a/enrocrypt/hashing.py +++ b/enrocrypt/hashing.py @@ -1,12 +1,12 @@ -import hashlib, base64, uuid, passlib +import hashlib, base64, uuid from cryptography.hazmat.primitives import hashes -from typing import Any, final +from typing import Any class Hashing(): - def __init__(self) -> None: + def __init__(self): self.salt = None def __call__(self, *args:Any): self.salt = args[0] - def __str__(self) -> str: + def __str__(self): return "Hashing Funcitions In Here" def Standard_Multi_Hash(self,Data:str): @@ -66,11 +66,6 @@ def SHA244(self,data:str): hash = str(sha.digest()) return self.__Salt(hash,salt=self.salt) - def MD5(self,data:str): - sha = hashlib.md5(bytes(data.encode())) - hash = str(sha.digest()) - return self.__Salt(hash,salt=self.salt) - def SHA384(self,data:str): sha = hashlib.sha384(bytes(data.encode())) hash = str(sha.digest()) @@ -81,3 +76,5 @@ def BLAKE2(self,data:bytes): a.update(data) return self.__Salt(a.finalize(),salt=self.salt) +obj = Hashing() +print(obj.PBKDF2_SHA256()) \ No newline at end of file diff --git a/map/passlib_functions.json b/map/passlib_functions.json new file mode 100644 index 0000000..6b39cec --- /dev/null +++ b/map/passlib_functions.json @@ -0,0 +1,74 @@ +{ +"passlib":{ + "pbkdf2":{ + "1":"pbkdf2_sha1", + "2":"pbkdf2_sha256", + "3":"pbkdf2_sha512", + "4": "cta_pbkdf2_sha1", + "5":"dlitz_pbkdf2_sha1", + "6":"grub_pbkdf2_sha512" + }, + "argon2":{ + "1":"argon2" + }, + "bcrypt":{ + "1":"bcrypt" + }, + "cisco":{ + "1":"cisco_pix", + "2":"cisco_asa", + "3":"cisco_type7" + }, + "des_crypt":{ + "1":"des_crypt", + "2":"bsdi_crypt", + "3":"bigcrypt", + "4":"crypt16" + }, + "digests":{ + "1":"create_hex_hash", + "2":"hex_md4", + "3":"hex_md5", + "4":"hex_sha1", + "5":"hex_sha256", + "6":"hex_sha512" + }, + "django":{ + "1":"django_salted_sha1", + "2":"django_salted_md5", + "3":"django_bcrypt", + "4":"django_pbkdf2_sha1", + "5":"django_pbkdf2_sha256", + "6":"django_argon2", + "7":"django_des_crypt", + "8":"django_disabled" + }, + "fshp":{ + "1":"fshp" + }, + "ldap_digest":{ + "1":"ldap_plaintext", + "2":"ldap_md5", + "3":"ldap_sha1", + "4":"ldap_salted_md5", + "5": "ldap_salted_sha1", + "6":"ldap_salted_sha256", + "7":"ldap_salted_sha512" + }, + "mysql":{ + "1":"mysql323", + "2":"mysq41" + }, + "oracle":{ + "1":"oracle10g", + "2":"oracle11g" + }, + "windows":{ + "1":"lmhash", + "2": "nthash", + "3":"bsd_nthash", + "4":"msdcc", + "5":"msdcc2" + } +} +} \ No newline at end of file From 8d999dee736b97d7e3dc2febb3a07b8de1e632d4 Mon Sep 17 00:00:00 2001 From: Morgan-Phoenix <73711602+Morgan-Phoenix@users.noreply.github.com> Date: Sun, 22 May 2022 21:39:00 +0530 Subject: [PATCH 2/4] hashing limiter added --- enrocrypt/core.py | 14 +++++---- enrocrypt/hashing.py | 36 +++++++++++++++++++--- map/disection.txt | 73 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 map/disection.txt diff --git a/enrocrypt/core.py b/enrocrypt/core.py index 7f4fb2e..e80ebc3 100644 --- a/enrocrypt/core.py +++ b/enrocrypt/core.py @@ -1,4 +1,3 @@ -from typing import Any from enrocrypt.hashing import Hashing from enrocrypt.encryption import Encryption from enrocrypt.basic import Basic @@ -13,8 +12,9 @@ class Core(Hashing,Encryption,Basic): }''' def __init__(self) -> None: self.salt = '' - def set_config(self,*args: Any): - configs = (args[0]['configs']['salt_file']) + self.byt = 512 + def set_config(self,con:dict): + configs = (con['salt_file']) value = self.__Set_Salt(configs) return value def __str__(self) -> str: @@ -26,10 +26,12 @@ def __Set_Salt(self,salt:list): self.salt = bytes(salts.encode()) return True except FileNotFoundError: - return Warning("No Salt File Found At The Given Location Using Random Salt") + return print(Warning("No Salt File Found At The Given Location Using Random Salt")) else: return False def get_hash_object(self): hashing = Hashing() - hashing(bytes(self.salt.encode())) - return hashing + if self.salt == "": + print(print(Warning("No Personalized Salt Loaded In The Memory, Using Random Salt"))) + hashing(bytes(self.salt.encode()),self.byt) + return hashing \ No newline at end of file diff --git a/enrocrypt/hashing.py b/enrocrypt/hashing.py index 91c742d..ca702b0 100644 --- a/enrocrypt/hashing.py +++ b/enrocrypt/hashing.py @@ -1,9 +1,11 @@ import hashlib, base64, uuid +from passlib.handlers.pbkdf2 import pbkdf2_sha256 from cryptography.hazmat.primitives import hashes from typing import Any class Hashing(): def __init__(self): self.salt = None + self.byt = 512 def __call__(self, *args:Any): self.salt = args[0] def __str__(self): @@ -39,7 +41,10 @@ def __Salt(self,data,salt:bytes = None): salts.append(str(data).split("'")[1]) salts.append(str(data).split("'")[1]) salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + salting = base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + if len(salting) > self.byt: + salting = salting.decode()[0:self.byt] + return salting if salt: salts = [] salts.append(str(hashlib.sha256(salt).digest()).split("'")[1]) @@ -49,8 +54,29 @@ def __Salt(self,data,salt:bytes = None): salts.append(str(data).split("'")[1]) salts.append(str(data).split("'")[1]) salts.append(str(hashlib.sha256(salt).digest()).split("'")[1]) - return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) - + salting2 = base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + if salting2 > self.byt: + salting2 = salting2.decode()[0:self.byt] + return salting2 + + def __Salt_PBKDF(self,data): + salts = [] + dataset = [] # len([]) == 7 TRUE + count = 0 + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + datas = str(data).split("/") #len([]) == 4 TRUE + for i in datas: + dataset.append(str(i).split("$")) + count+=1 + dataset.pop(0) + dataset.pop(1) + for i in range(count): + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(dataset[i])) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + def SHA256(self,data:str): sha = hashlib.sha256(bytes(data.encode())) hash = sha.digest() @@ -76,5 +102,5 @@ def BLAKE2(self,data:bytes): a.update(data) return self.__Salt(a.finalize(),salt=self.salt) -obj = Hashing() -print(obj.PBKDF2_SHA256()) \ No newline at end of file + def PBKDF2_SHA256(self,data:bytes): + return self.__Salt_PBKDF(pbkdf2_sha256.hash(str(data.decode))) \ No newline at end of file diff --git a/map/disection.txt b/map/disection.txt new file mode 100644 index 0000000..4e232f1 --- /dev/null +++ b/map/disection.txt @@ -0,0 +1,73 @@ + BREAKING + +pbkdf2-sha256$29000$C8F4r/U.5/yfM2ZszVnr3Q$7obwOw/4aZ.hYnhme9Zxqr4KgPIZ4EhRBnLKR6K9WeY (happiness) + +Step -> 1 + +pbkdf2-sha256$29000$C8F4r +/ +U.5 +/ +yfM2ZszVnr3Q$7obwOw +/ +4aZ.hYnhme9Zxqr4KgPIZ4EhRBnLKR6K9WeY + +Step -> 2 + +pbkdf2-sha256 NO +$ NO +29000 NO +$ NO +C8F4r YES +/ NO +U.5 YES +/ NO +yfM2ZszVnr3Q YES +$ NO +7obwOw YES +/ NO +4aZ.hYnhme9Zxqr4KgPIZ4EhRBnLKR6K9WeY YES + + + + TILL NOW RESULT + + C8F4rU.5yfM2ZszVnr3Q4aZ.hYnhme9Zxqr4KgPIZ4EhRBnLKR6K9WeY + + + SALTING + +will use basic SHA256 to hash some random text and then add it randomly (i.e. in any order) +to the original text. As everything is hashed it will be very hard to find out the original +text and the Salt + + BASIC SALT MODLE + + salts = [] + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(data).split("'")[1]) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(data).split("'")[1]) + salts.append(str(data).split("'")[1]) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + + EDITED SALT MODLE (random mode) + + salts = [] + dataset = [] # len([]) == 7 TRUE + count = 0 + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + data = str(data).split("/") #len([]) == 4 TRUE + for i in data: + dataset.append(str(i).split("$")) + count+=1 + dataset.pop(0) + dataset.pop(1) + for i in range(count): + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + salts.append(str(dataset[i])) + salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) + return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) \ No newline at end of file From 6b15795c04e51e1380feccdc0e4c10c0610537bc Mon Sep 17 00:00:00 2001 From: Morgan-Phoenix <73711602+Morgan-Phoenix@users.noreply.github.com> Date: Mon, 23 May 2022 19:34:01 +0530 Subject: [PATCH 3/4] updated pbkdf salting --- enrocrypt/hashing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/enrocrypt/hashing.py b/enrocrypt/hashing.py index ca702b0..3bfe619 100644 --- a/enrocrypt/hashing.py +++ b/enrocrypt/hashing.py @@ -75,7 +75,10 @@ def __Salt_PBKDF(self,data): salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) salts.append(str(dataset[i])) salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - return base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + salting = base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) + if len(salting) > self.byt: + salting = salting.decode()[0:self.byt] + return salting def SHA256(self,data:str): sha = hashlib.sha256(bytes(data.encode())) From 53771471b85ece7afd099846b859ac5aad644edf Mon Sep 17 00:00:00 2001 From: Morgan-Phoenix <73711602+Morgan-Phoenix@users.noreply.github.com> Date: Tue, 24 May 2022 20:30:39 +0530 Subject: [PATCH 4/4] removed passlib --- enrocrypt/hashing.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/enrocrypt/hashing.py b/enrocrypt/hashing.py index 3bfe619..5d66ba4 100644 --- a/enrocrypt/hashing.py +++ b/enrocrypt/hashing.py @@ -1,5 +1,4 @@ import hashlib, base64, uuid -from passlib.handlers.pbkdf2 import pbkdf2_sha256 from cryptography.hazmat.primitives import hashes from typing import Any class Hashing(): @@ -59,27 +58,6 @@ def __Salt(self,data,salt:bytes = None): salting2 = salting2.decode()[0:self.byt] return salting2 - def __Salt_PBKDF(self,data): - salts = [] - dataset = [] # len([]) == 7 TRUE - count = 0 - salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - datas = str(data).split("/") #len([]) == 4 TRUE - for i in datas: - dataset.append(str(i).split("$")) - count+=1 - dataset.pop(0) - dataset.pop(1) - for i in range(count): - salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - salts.append(str(dataset[i])) - salts.append(str(hashlib.sha256(uuid.uuid4().bytes).digest()).split("'")[1]) - salting = base64.standard_b64encode(bytes((str(base64.urlsafe_b64encode(bytes(''.join(salts).encode()))).split("'")[1]+str(base64.urlsafe_b64encode(base64.standard_b64encode((bytes(''.join(salts).encode()))))).split("'")[1]).encode())) - if len(salting) > self.byt: - salting = salting.decode()[0:self.byt] - return salting - def SHA256(self,data:str): sha = hashlib.sha256(bytes(data.encode())) hash = sha.digest() @@ -103,7 +81,4 @@ def SHA384(self,data:str): def BLAKE2(self,data:bytes): a = hashes.Hash(hashes.BLAKE2s(32)) a.update(data) - return self.__Salt(a.finalize(),salt=self.salt) - - def PBKDF2_SHA256(self,data:bytes): - return self.__Salt_PBKDF(pbkdf2_sha256.hash(str(data.decode))) \ No newline at end of file + return self.__Salt(a.finalize(),salt=self.salt) \ No newline at end of file