|
| 1 | +import httpx |
| 2 | +import json |
| 3 | +from colorama import Fore, Style |
| 4 | +from user_scanner.core.helpers import load_config, _get_config_path |
| 5 | + |
| 6 | +# Color configs |
| 7 | +R = Fore.RED |
| 8 | +G = Fore.GREEN |
| 9 | +C = Fore.CYAN |
| 10 | +Y = Fore.YELLOW |
| 11 | +M = Fore.MAGENTA |
| 12 | +X = Style.RESET_ALL |
| 13 | + |
| 14 | +def update_hudson_preference(show_prompt: bool): |
| 15 | + """Updates the config file using your existing helper logic.""" |
| 16 | + cp = _get_config_path() |
| 17 | + content = load_config() |
| 18 | + content["auto_hudson_prompt"] = show_prompt |
| 19 | + cp.write_text(json.dumps(content, indent=2)) |
| 20 | + |
| 21 | +def check_hudson_permission(target: str) -> bool: |
| 22 | + """Disclaimers and prompts based on user config.""" |
| 23 | + config = load_config() |
| 24 | + |
| 25 | + # If the user already set this to false, skip the prompt and run |
| 26 | + if not config.get("auto_hudson_prompt", True): |
| 27 | + return True |
| 28 | + |
| 29 | + print(f"\n{Y}[!] PRIVACY NOTICE & DISCLAIMER:{X}") |
| 30 | + print(" Hudson Rock is a third-party intelligence service.") |
| 31 | + print(f" By proceeding, the identifier '{C}{target}{Y}' will be sent to their API.") |
| 32 | + print(f" They may log queries. We are not responsible for their data handling.{X}") |
| 33 | + |
| 34 | + while True: |
| 35 | + choice = input(f"\n{C}Query Hudson Rock? (y/n/d for don't ask again): {X}").lower().strip() |
| 36 | + if choice == 'y': |
| 37 | + return True |
| 38 | + elif choice == 'n': |
| 39 | + print(f"{Y}[i] Hudson Rock scan skipped.{X}") |
| 40 | + return False |
| 41 | + elif choice == 'd': |
| 42 | + update_hudson_preference(False) |
| 43 | + print(f"{G}[+] Preference saved. You won't be prompted again.{X}") |
| 44 | + return True |
| 45 | + else: |
| 46 | + print(f"{R}[!] Please enter 'y', 'n', or 'd'.{X}") |
| 47 | + |
| 48 | +def run_hudson_scan(target: str, is_email: bool = False): |
| 49 | + """ |
| 50 | + Fetch and display intelligence from Hudson Rock's OSINT API. |
| 51 | + """ |
| 52 | + # Permission check using the new logic |
| 53 | + if not check_hudson_permission(target): |
| 54 | + return |
| 55 | + |
| 56 | + base_url = "https://cavalier.hudsonrock.com/api/json/v2/osint-tools/" |
| 57 | + endpoint = "search-by-email" if is_email else "search-by-username" |
| 58 | + param = "email" if is_email else "username" |
| 59 | + |
| 60 | + url = f"{base_url}{endpoint}?{param}={target}" |
| 61 | + |
| 62 | + print(f"\n{M}== HUDSON ROCK INFOSTEALER INTELLIGENCE =={X}") |
| 63 | + print(f"{C}[i] Attribution: Data provided by Hudson Rock (https://www.hudsonrock.com){X}") |
| 64 | + print(f"{C}[*] Querying Hudson Rock for {target}...{X}") |
| 65 | + |
| 66 | + try: |
| 67 | + with httpx.Client(timeout=10.0) as client: |
| 68 | + response = client.get(url) |
| 69 | + |
| 70 | + if response.status_code == 200: |
| 71 | + data = response.json() |
| 72 | + stealers = data.get("stealers", []) |
| 73 | + |
| 74 | + if not stealers: |
| 75 | + print(f"{G}[✔] No infostealer infections found for this {param}.{X}") |
| 76 | + return |
| 77 | + |
| 78 | + total_stealers = len(stealers) |
| 79 | + print(f"{R}[!] FOUND {total_stealers} INFOSTEALER INFECTION(S) ASSOCIATED WITH THIS {param.upper()}!{X}") |
| 80 | + |
| 81 | + for i, stealer in enumerate(stealers, 1): |
| 82 | + print(f"\n {Y}Infection #{i}:{X}") |
| 83 | + print(f" - Stealer Family: {stealer.get('stealer_family', 'Unknown')}") |
| 84 | + print(f" - Date Compromised: {stealer.get('date_compromised', 'Unknown')}") |
| 85 | + print(f" - Operating System: {stealer.get('operating_system', 'Unknown')}") |
| 86 | + print(f" - Computer Name: {stealer.get('computer_name', 'Unknown')}") |
| 87 | + |
| 88 | + antiviruses = stealer.get('antiviruses', []) |
| 89 | + if antiviruses: |
| 90 | + print(f" - Antiviruses: {', '.join(antiviruses)}") |
| 91 | + |
| 92 | + top_logins = stealer.get('top_logins', []) |
| 93 | + if top_logins: |
| 94 | + print(f" - Sample Logins Found: {', '.join(top_logins[:3])}...") |
| 95 | + |
| 96 | + print(f"\n{Y}[!] Recommendation: All credentials saved on infected computers are at risk.{X}") |
| 97 | + print(f"{Y}[!] Visit https://www.hudsonrock.com/free-tools for more info.{X}") |
| 98 | + |
| 99 | + elif response.status_code == 404: |
| 100 | + print(f"{G}[✔] No data found for this {param} in Hudson Rock database.{X}") |
| 101 | + else: |
| 102 | + print(f"{R}[✘] Hudson Rock API error: HTTP {response.status_code}{X}") |
| 103 | + |
| 104 | + except Exception as e: |
| 105 | + print(f"{R}[✘] Error connecting to Hudson Rock: {e}{X}") |
0 commit comments