def attack(self, local:bool = False, force: bool = False, pre_attack_output: Any = None, db_status:bool = False, workspace:str = None, db_credential_file: Path = None): """ Wordlist attack using John the Ripper with HashId as pre attack module Args: local (bool): if local is True run attack localy otherwise submiting parallel tasks in a cluster using slurm """ #import pdb; pdb.set_trace() try: if not force: self.no_empty_required_options(local) hc = Hashcat() hash_types = self.most_probably_hash_identities(pre_attack_output) hc.wordlist_attack(hash_types = hash_types, hashes_file = self.options['hashes_file'].value, wordlist = self.options['wordlist'].value, slurm = self.slurm, local = local, db_status= db_status, workspace= workspace, db_credential_file=db_credential_file) except Exception as error: print_failure(error)
def main(): try: parser = amadb_parser() args = parser.parse_args() workspace = args.workspace credentials_file = Path(args.creds_file) cracker = args.cracker if args.insert_hashes and cracker in [John.MAINNAME, Hashcat.MAINNAME]: hashes_file = Path(args.insert_hashes) if cracker == John.MAINNAME: John.insert_hashes_to_db(hashes_file, workspace, credentials_file) elif cracker == Hashcat.MAINNAME: Hashcat.insert_hashes_to_db(hashes_file, workspace, credentials_file) elif args.insert_hashes and cracker not in [ John.MAINNAME, Hashcat.MAINNAME ]: raise Exception(f"Cracker {args.cracker} doesn't crack hashes") if args.insert_services: print_status("Please, implement me") #services_file = Path(args.insert_hashes) except Exception as error: print_failure(error)
def do_hashes(self, args): """ Search by valid hashes types """ if args.cracker == John.MAINNAME: John.search_hash(args.pattern, sensitive=args.sensitive) else: # cracker == hc Hashcat.search_hash(args.pattern, sensitive=args.sensitive)
def attack(self, *, local: bool = False, force: bool = False, pre_attack_output: Any = None, db_status: bool = False, workspace: str = None, db_credential_file: Path = None, cracker_main_exec: Path = None): """ Combination attack using Hashcat Args: local (bool): if local is True run attack localy otherwise submiting parallel tasks in a cluster using slurm """ #import pdb; pdb.set_trace() try: if not force: self.no_empty_required_options(local) if cracker_main_exec: hc = Hashcat(hashcat_exec=cracker_main_exec) else: hc = Hashcat() hash_type = None if isinstance(self.options['hash_type'].value, int): hash_types = [self.options['hash_type'].value] elif isinstance(self.options['hash_type'].value, str): hash_types = [ int(hash_type) for hash_type in self.options['hash_type'].value.split(',') ] else: raise TypeError(f"Invalid type hash_type: {type(hash_type)}") wordlists = [ wordlist.strip() for wordlist in self.options['wordlists'].value.split(',') ] hc.combination_attack( hash_types=hash_types, hashes_file=self.options['hashes_file'].value, wordlists=wordlists, slurm=self.slurm, sleep=self.options['sleep'].value, local=local, db_status=db_status, workspace=workspace, db_credential_file=db_credential_file) except Exception as error: print_failure(error)
def attack(self, *, local:bool = False, force:bool = False, pre_attack_output: Any = None, db_status:bool = False, workspace:str = None, db_credential_file: Path = None, cracker_main_exec:Path = None): """ Hybrid Attack using hashcat cracker """ #import pdb; pdb.set_trace() try: if not force: self.no_empty_required_options(local) if cracker_main_exec: hc = Hashcat(hashcat_exec=cracker_main_exec) else: hc = Hashcat() hash_type = None if isinstance(self.options['hash_type'].value, int): hash_types = [self.options['hash_type'].value] elif isinstance(self.options['hash_type'].value, str): hash_types = [int(hash_type) for hash_type in self.options['hash_type'].value.split(',')] else: raise TypeError(f"Invalid type hash_type: {type(hash_type)}") wordlists = [wordlist.strip() for wordlist in self.options['wordlists'].value.split(',')] masks = self.options['masks'].value if os.path.isfile(masks) and os.access(masks, os.R_OK): #a masks file was supplied masks_file = Path(masks) hc.hybrid_attack( hash_types = hash_types, hashes_file = self.options['hashes_file'].value, inverse = self.options['inverse'].value, wordlists = wordlists, masks_file = masks_file, sleep = self.options['sleep'].value, slurm = self.slurm, local = local, db_status= db_status, workspace= workspace, db_credential_file=db_credential_file) else: masks = [mask.strip() for mask in masks.split(',')] hc.hybrid_attack( hash_types = hash_types, hashes_file = self.options['hashes_file'].value, inverse = self.options['inverse'].value, wordlists = wordlists, masks = masks, sleep = self.options['sleep'].value, slurm = self.slurm, local = local, db_status= db_status, workspace= workspace, db_credential_file=db_credential_file) except Exception as error: print_failure(error)