Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ✅ Unified Password Cracker: PasswordCracker Class
- import hashlib
- import os
- from typing import List, Optional
- from datetime import datetime
- # Optional libraries
- try:
- from passlib.hash import bcrypt as passlib_bcrypt
- from passlib.hash import pbkdf2_sha256 as passlib_pbkdf2_sha256
- HAS_PASSLIB = True
- except ImportError:
- HAS_PASSLIB = False
- try:
- from argon2 import PasswordHasher
- from argon2.exceptions import VerifyMismatchError, InvalidHash
- _ARGON2_PH = PasswordHasher()
- HAS_ARGON2 = True
- except ImportError:
- HAS_ARGON2 = False
- _ARGON2_PH = None
- class PasswordCracker:
- def __init__(self, kb=None):
- self.kb = kb # Optional KnowledgeBase integration
- self.common_passwords = ['123456', 'password', 'admin', 'letmein']
- def detect_algorithm(self, h: str) -> str:
- hl = h.lower()
- if hl.startswith("$2a$") or hl.startswith("$2b$") or hl.startswith("$2y$"):
- return "bcrypt"
- if hl.startswith("$argon2"):
- return "argon2"
- if hl.startswith("$pbkdf2-sha256$") or "pbkdf2:sha256" in hl:
- return "pbkdf2_sha256"
- hex_only = all(c in '0123456789abcdef' for c in hl) and len(hl) in [32, 40, 64, 128]
- if hex_only:
- return {32: "md5", 40: "sha1", 64: "sha256", 128: "sha512"}[len(hl)]
- return "unknown"
- def hash_password(self, password: str, algo: str = "sha256", salt: str = "", salt_pos: str = "none") -> str:
- salted = self._apply_salt(password, salt, salt_pos)
- if algo == "md5":
- return hashlib.md5(salted).hexdigest()
- if algo == "sha1":
- return hashlib.sha1(salted).hexdigest()
- if algo == "sha256":
- return hashlib.sha256(salted).hexdigest()
- if algo == "sha512":
- return hashlib.sha512(salted).hexdigest()
- return "unsupported"
- def _apply_salt(self, pwd: str, salt: str, salt_pos: str) -> bytes:
- if not salt or salt_pos == "none":
- return pwd.encode()
- if salt_pos == "prefix":
- return (salt + pwd).encode()
- if salt_pos == "suffix":
- return (pwd + salt).encode()
- if salt_pos == "both":
- return (salt + pwd + salt).encode()
- return pwd.encode()
- def verify(self, password: str, target_hash: str, algo: str, salt: str = "", salt_pos: str = "none") -> bool:
- try:
- if algo in ("md5", "sha1", "sha256", "sha512"):
- return self.hash_password(password, algo, salt, salt_pos).lower() == target_hash.lower()
- if algo == "bcrypt" and HAS_PASSLIB:
- return passlib_bcrypt.verify(password, target_hash)
- if algo == "argon2" and HAS_ARGON2:
- _ARGON2_PH.verify(target_hash, password)
- return True
- if algo == "pbkdf2_sha256" and HAS_PASSLIB:
- return passlib_pbkdf2_sha256.verify(password, target_hash)
- except Exception:
- return False
- return False
- def crack(self, target_hash: str, algo: Optional[str] = None, wordlist: Optional[str] = None,
- salt: str = "", salt_pos: str = "none", store_result: bool = True) -> Optional[str]:
- algorithm = algo or self.detect_algorithm(target_hash)
- candidates = self.common_passwords.copy()
- if wordlist and os.path.exists(wordlist):
- try:
- with open(wordlist, 'r', encoding='utf-8', errors='ignore') as f:
- candidates.extend([line.strip() for line in f])
- except Exception as e:
- print(f"Error reading wordlist: {e}")
- for pwd in candidates:
- if self.verify(pwd, target_hash, algorithm, salt, salt_pos):
- if self.kb and store_result:
- self.kb.store_cracked_password(target_hash, algorithm, pwd, salt)
- return pwd
- return None
- ✅ Usage Example
- cracker = PasswordCracker(kb=my_kb_instance)
- hash_to_crack = "5e884898da28047151d0e56f8dc6292773603d0d6aabbddc56f5c9ee" # sha256 for "password"
- cracked = cracker.crack(hash_to_crack, algo="sha256")
- print(f"Cracked: {cracked}")
- ✅ Optional: Hook into KnowledgeBase
- If you pass a KnowledgeBase instance (like in your full framework), it will automatically store cracked passwords in the password_cracks table:
- self.kb.store_cracked_password(hash, algorithm, password, salt)
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=lavwmkxhha
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment