Skip to content

πŸ•΅οΈβ€β™‚οΈ (2-in-1) Email & Username OSINT suite featuring native MCP support for deep data extraction just from a single Email/Username. Analyzes 2720+ actively maintained scan vectors (210+ email / 2510+ username) for security research, investigations, and digital footprinting.

feat: json output

Vamato9de08a236334
diff --git a/user_scanner/__main__.py b/user_scanner/__main__.py
index c50bdb9..e89dbbf 100644
--- a/user_scanner/__main__.py
+++ b/user_scanner/__main__.py
@@ -1,10 +1,10 @@
import argparse
import time
import re
+from user_scanner.cli import printer
from user_scanner.core.orchestrator import run_checks, load_modules , generate_permutations, load_categories
from colorama import Fore, Style
-from .cli import banner
-from .cli.banner import print_banner
+from user_scanner.cli.banner import print_banner
MAX_PERMUTATIONS_LIMIT = 100 # To prevent excessive generation
@@ -54,6 +54,10 @@ def main():
parser.add_argument(
"-d", "--delay",type=float,default=0,help="Delay in seconds between requests (recommended: 1-2 seconds)"
)
+
+ parser.add_argument(
+ "-o", "--output-format", choices=["console", "csv", "json"], default="console", help="Specify output format (default: console)"
+ )
args = parser.parse_args()
@@ -64,19 +68,22 @@ def main():
if not args.username:
parser.print_help()
return
-
- # Special username checks before run
- if (args.module == "x" or args.category == "social"):
- if re.search(r"[^a-zA-Z0-9._-]", args.username):
- print(
- Fore.RED + f"[!] Username '{args.username}' contains unsupported special characters. X (Twitter) doesn't support these." + Style.RESET_ALL)
- if (args.module == "bluesky" or args.category == "social"):
- if re.search(r"[^a-zA-Z0-9\.-]", args.username):
- print(
- Fore.RED + f"[!] Username '{args.username}' contains unsupported special characters. Bluesky will throw error. (Supported: only hyphens and digits)" + Style.RESET_ALL + "\n")
- print_banner()
+
+ Printer = printer.Printer(args.output_format)
+
+ if Printer.is_console:
+ print_banner()
+ # Special username checks before run
+ if (args.module == "x" or args.category == "social"):
+ if re.search(r"[^a-zA-Z0-9._-]", args.username):
+ print(
+ Fore.RED + f"[!] Username '{args.username}' contains unsupported special characters. X (Twitter) doesn't support these." + Style.RESET_ALL)
+ if (args.module == "bluesky" or args.category == "social"):
+ if re.search(r"[^a-zA-Z0-9\.-]", args.username):
+ print(
+ Fore.RED + f"[!] Username '{args.username}' contains unsupported special characters. Bluesky will throw error. (Supported: only hyphens and digits)" + Style.RESET_ALL + "\n")
- if args.permute and args.delay == 0:
+ if args.permute and args.delay == 0 and Printer.is_console:
print(
Fore.YELLOW
+ "[!] Warning: You're generating multiple usernames with NO delay between requests. "
@@ -88,13 +95,14 @@ def main():
#Added permutation support , generate all possible permutation of given sequence.
if args.permute:
usernames = generate_permutations(args.username, args.permute , args.stop)
- print(Fore.CYAN + f"[+] Generated {len(usernames)} username permutations" + Style.RESET_ALL)
+ if Printer.is_console:
+ print(
+ Fore.CYAN + f"[+] Generated {len(usernames)} username permutations" + Style.RESET_ALL)
-
-
if args.module and "." in args.module:
args.module = args.module.replace(".", "_")
+ is_last = lambda x: x == len(usernames) - 1
if args.module:
# Single module search across all categories
@@ -105,10 +113,15 @@ def main():
site_name = module.__name__.split(".")[-1]
if site_name.lower() == args.module.lower():
from user_scanner.core.orchestrator import run_module_single
- for name in usernames: # <-- permutation support here
- run_module_single(module, name)
- if args.delay > 0:
+
+ Printer.print_json_start()
+
+ for i, name in enumerate(usernames): # <-- permutation support here
+ run_module_single(module, name, Printer, is_last(i))
+ if args.delay > 0 and not is_last(i):
time.sleep(args.delay)
+
+ Printer.print_json_end()
found = True
if not found:
print(
@@ -118,17 +131,26 @@ def main():
category_package = load_categories().get(args.category)
from user_scanner.core.orchestrator import run_checks_category
- for name in usernames: # <-- permutation support here
- run_checks_category(category_package, name, args.verbose)
- if args.delay > 0:
+ Printer.print_json_start()
+
+ for i, name in enumerate(usernames): # <-- permutation support here
+ run_checks_category(category_package, name, Printer, is_last(i))
+ if args.delay > 0 and not is_last(i):
time.sleep(args.delay)
+
+ Printer.print_json_end()
+
else:
# Full scan
- for name in usernames:
- run_checks(name)
- if args.delay > 0:
+ Printer.print_json_start()
+
+ for i, name in enumerate(usernames):
+ run_checks(name, Printer, is_last(i))
+ if args.delay > 0 and not is_last(i):
time.sleep(args.delay)
+ Printer.print_json_end()
+
if __name__ == "__main__":
main()
diff --git a/user_scanner/cli/printer.py b/user_scanner/cli/printer.py
new file mode 100644
index 0000000..029c649
--- /dev/null
+++ b/user_scanner/cli/printer.py
@@ -0,0 +1,90 @@
+from colorama import Fore, Style
+from typing import Literal
+from user_scanner.core.result import Result, Status
+
+JSON_TEMPLATE = """{{
+\t"site_name": "{site_name}",
+\t"username": "{username}",
+\t"result": "{result}"
+}}"""
+
+JSON_TEMPLATE_ERROR = """{{
+\t"site_name": "{site_name}",
+\t"username": "{username}",
+\t"result": "Error",
+\t"reason": "{reason}"
+}}"""
+
+
+def identate(msg: str, ident: int):
+ tabs = "\t" * ident
+ return "\n".join([f"{tabs}{line}" for line in msg.split("\n")])
+
+
+class Printer:
+ def __init__(self, output_format: Literal["console", "csv", "json"]) -> None:
+ if not output_format in ["console", "csv", "json"]:
+ raise ValueError(f"Invalid output-format: {output_format}")
+ self.mode: str = output_format
+ self.ident: int = 0
+
+ @property
+ def is_console(self) -> bool:
+ return self.mode == "console"
+
+ @property
+ def is_csv(self) -> bool:
+ return self.mode == "csv"
+
+ @property
+ def is_json(self) -> bool:
+ return self.mode == "json"
+
+ def print_json_start(self) -> None:
+ if not self.is_json:
+ return
+ self.ident += 1
+ print(identate("[", self.ident - 1))
+
+ def print_json_end(self) -> None:
+ if not self.is_json:
+ return
+ self.ident = max(self.ident - 1, 0)
+ print(identate("]", self.ident))
+
+ def get_result_output(self, site_name: str, username: str, result: Result) -> str:
+ if result == None:
+ result = Result.error("Invalid return value: None")
+
+ if isinstance(result, int):
+ result = Result.from_number(result)
+
+ match (result.status, self.mode):
+ case (Status.AVAILABLE, "console"):
+ return f" {Fore.GREEN}[βœ”] {site_name} ({username}): Available{Style.RESET_ALL}"
+
+ case (Status.TAKEN, "console"):
+ return f" {Fore.RED}[✘] {site_name} ({username}): Taken{Style.RESET_ALL}"
+
+ case (Status.ERROR, "console"):
+ reason = ""
+ if isinstance(result, Result) and result.has_reason():
+ reason = f" ({result.get_reason()})"
+ return f" {Fore.YELLOW}[!] {site_name} ({username}): Error{reason}{Style.RESET_ALL}"
+
+ case (Status.AVAILABLE, "json") | (Status.TAKEN, "json"):
+ msg = identate(JSON_TEMPLATE, self.ident).format(
+ site_name=site_name,
+ username=username,
+ result=str(result.status)
+ )
+ return msg
+
+ case (Status.ERROR, "json"):
+ msg = identate(JSON_TEMPLATE_ERROR, self.ident).format(
+ site_name=site_name,
+ username=username,
+ reason=result.get_reason()
+ )
+ return msg
+
diff --git a/user_scanner/core/orchestrator.py b/user_scanner/core/orchestrator.py
index 5e9e3cc..e615793 100644
--- a/user_scanner/core/orchestrator.py
+++ b/user_scanner/core/orchestrator.py
@@ -5,6 +5,7 @@ import threading
from itertools import permutations
import httpx
from pathlib import Path
+from user_scanner.cli.printer import Printer
from user_scanner.core.result import Result, AnyResult
from typing import Callable, Dict, List
@@ -39,7 +40,7 @@ def load_categories() -> Dict[str, Path]:
return categories
-def worker_single(module, username, i):
+def worker_single(module, username: str, i: int, printer: Printer, last: bool = True) -> AnyResult:
global print_queue
func = next((getattr(module, f) for f in dir(module)
@@ -52,49 +53,46 @@ def worker_single(module, username, i):
if func:
try:
result = func(username)
- reason = ""
-
- if isinstance(result, Result) and result.has_reason():
- reason = f" ({result.get_reason()})"
-
- if result == 1:
- output = f" {Fore.GREEN}[βœ”] {site_name} ({username}): Available{Style.RESET_ALL}"
- elif result == 0:
- output = f" {Fore.RED}[✘] {site_name} ({username}): Taken{Style.RESET_ALL}"
- else:
- output = f" {Fore.YELLOW}[!] {site_name} ({username}): Error{reason}{Style.RESET_ALL}"
+ output = printer.get_result_output(site_name, username, result)
+ if last == False and printer.is_json:
+ output += ","
except Exception as e:
- output = f" {Fore.YELLOW}[!] {site_name}: Exception - {e}{Style.RESET_ALL}"
+ if Printer.is_console:
+ output = f" {Fore.YELLOW}[!] {site_name}: Exception - {e}{Style.RESET_ALL}"
else:
- output = f" {Fore.YELLOW}[!] {site_name} has no validate_ function{Style.RESET_ALL}"
+ if Printer.is_console:
+ output = f" {Fore.YELLOW}[!] {site_name} has no validate_ function{Style.RESET_ALL}"
with lock:
# Waits for in-order printing
while i != print_queue:
lock.wait()
- print(output)
+ if output != "":
+ print(output)
print_queue += 1
lock.notify_all()
-def run_module_single(module, username):
+def run_module_single(module, username: str, printer: Printer, last: bool = True) -> AnyResult:
# Just executes as if it was a thread
- worker_single(module, username, print_queue)
+ return worker_single(module, username, print_queue, printer, last)
-def run_checks_category(category_path:Path, username:str, verbose=False):
+def run_checks_category(category_path: Path, username: str, printer: Printer, last: bool = True):
global print_queue
modules = load_modules(category_path)
- category_name = category_path.stem.capitalize()
- print(f"{Fore.MAGENTA}== {category_name} SITES =={Style.RESET_ALL}")
+ if printer.is_console:
+ category_name = category_path.stem.capitalize()
+ print(f"\n{Fore.MAGENTA}== {category_name} SITES =={Style.RESET_ALL}")
print_queue = 0
threads = []
for i, module in enumerate(modules):
- t = threading.Thread(target=worker_single, args=(module, username, i))
+ last_thread = last and (i == len(modules) - 1)
+ t = threading.Thread(target=worker_single, args=(module, username, i, printer, last_thread))
threads.append(t)
t.start()
@@ -102,13 +100,14 @@ def run_checks_category(category_path:Path, username:str, verbose=False):
t.join()
-def run_checks(username):
- print(f"\n{Fore.CYAN} Checking username: {username}{Style.RESET_ALL}\n")
-
- for category_path in load_categories().values():
- run_checks_category(category_path, username)
- print()
+def run_checks(username: str, printer: Printer, last:bool = True):
+ if printer.is_console:
+ print(f"\n{Fore.CYAN} Checking username: {username}{Style.RESET_ALL}")
+ categories = list(load_categories().values())
+ for i, category_path in enumerate(categories):
+ last_cat: int = last and (i == len(categories) - 1)
+ run_checks_category(category_path, username, printer, last_cat)
def make_get_request(url: str, **kwargs) -> httpx.Response:
"""Simple wrapper to **httpx.get** that predefines headers and timeout"""
diff --git a/user_scanner/core/result.py b/user_scanner/core/result.py
index ea55b47..15365a3 100644
--- a/user_scanner/core/result.py
+++ b/user_scanner/core/result.py
@@ -18,6 +18,9 @@ class Status(Enum):
AVAILABLE = 1
ERROR = 2
+ def __str__(self):
+ return super().__str__().split(".")[1].capitalize()
+
class Result:
def __init__(self, status: Status, reason: str | Exception | None = None):