async def main(): args: Type[URLDownloaderArgumentParser. Namespace] = URLDownloaderArgumentParser().parse_args() try: if not args.urls and not args.urls_files: args.all_urls = set(stdin.read().splitlines()) download_summary = await url_downloader( urls=args.all_urls, output_directory=args.output_directory, use_hashing=args.use_hashing, num_total_timeout_seconds=args.num_total_timeout_seconds, quiet=args.quiet, ignore_warnings=args.ignore_warnings, num_concurrent=args.num_concurrent) except KeyboardInterrupt: pass except: LOG.exception('Unexpected error.') else: if not args.quiet: print( text_align_delimiter( f'Elapsed time: {download_summary.elapsed_time}\n' f'Num URLs: {len(args.all_urls)}\n' f'{download_summary}'))
async def main(): args = NTLMTargetInformationArgumentParser().parse_args() LOG.addHandler(hdlr=ColoredLogHandler()) LOG.setLevel(level=WARNING) try: print( text_align_delimiter(text=str(await ntlm_target_information( url=args.url, timeout=args.timeout)), delimiter=': ')) except: LOG.exception('Unexpected error.')
def get_secrets_output_string( sam_entries: Optional[Iterable[SAMEntry]] = None, domain_cached_credentials: Optional[ Iterable[DomainCachedCredentials2]] = None, policy_secrets: Optional[dict[str, bytes]] = None, service_account_name_to_password: Optional[dict[str, str]] = None) -> str: return ('\n\n'.join(section for section in [ text_align_delimiter( text=(f"{underline(string='SAM entries')}\n\n" + ('\n\n'.join(f'Account name: {sam_entry.account_name}\n' f'NT hash: {sam_entry.nt_hash.hex()}' for sam_entry in sam_entries if sam_entry.nt_hash is not None))), put_non_match_after_delimiter=False) if sam_entries else None, text_align_delimiter(text=( f"{underline(string='Service credentials')}\n\n" + ('\n\n'.join(f'Account name: {account_name}\n' f'Password: {password}' for account_name, password in service_account_name_to_password.items()))), put_non_match_after_delimiter=False ) if service_account_name_to_password else None, text_align_delimiter(text=( f"{underline(string='Domain cached credentials')}\n\n" + ('\n'.join( str(domain_cached_credentials_entry) for domain_cached_credentials_entry in domain_cached_credentials))), put_non_match_after_delimiter=False ) if domain_cached_credentials else None, text_align_delimiter( text=(f"{underline(string='Policy secrets')}\n\n" + ('\n'.join(f'{key}: {value.hex()}' for key, value in policy_secrets.items()))), put_non_match_after_delimiter=False) if policy_secrets else None, ] if section))
async def main(): args: ArgparseNamespace = EnumerateSMBShareArgumentParser().parse_args() share_entries: Tuple[ShareInfo1, ...] = await pre_enumerate_smb_shares( address=args.target_address, username=args.username, authentication_secret=args.password or bytes.fromhex(args.nt_hash)) if args.json: print(json_dumps(share_entries, default=default_json_serializer)) else: print( text_align_delimiter(text='\n\n'.join([ f'Name: {entry.netname}\n' f'Type: {entry.share_type}\n' f'Remark: {entry.remark}' for entry in share_entries ]), delimiter=': '))
async def main(): args = PublicSuffixArgumentParser().parse_args() public_suffix_list_trie = PublicSuffixListTrie( root_node=PublicSuffixListTrieNode.from_public_suffix_list( rules=(args.list_file_path.read() if args.list_file_path else ( await download_public_suffix_list())).splitlines())) domain_properties_list: list[DomainProperties] = [ public_suffix_list_trie.get_domain_properties( domain=domain_name.strip()) for domain_name in (args.domain_names or stdin) ] print( json_dumps([ asdict(domain_properties) for domain_properties in domain_properties_list ]) if args.json else '\n\n'.join( text_align_delimiter(text=str(domain_properties)) for domain_properties in domain_properties_list))