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.

rm: printer; added: formatter

Vamato19d8d172850c
diff --git a/tests/test_formatter.py b/tests/test_formatter.py
new file mode 100644
index 0000000..c023eee
--- /dev/null
+++ b/tests/test_formatter.py
@@ -0,0 +1,35 @@
+from user_scanner.core.formatter import into_csv, into_json, indentate, INDENT
+from user_scanner.core.result import Result
+
+
+def test_indentate():
+ assert indentate("", -1) == ""
+ assert indentate("", 0) == ""
+ assert indentate("", 2) == 2 * INDENT
+
+ msg = ("This is a test message\n"
+ "made to test the identation\n"
+ "and shouldn't be changed.")
+
+ for i in range(0, 4):
+ new = indentate(msg, i)
+ for line in new.split("\n"):
+ assert line.find(INDENT * i) == 0
+
+
+def test_get_result_output_formats():
+ res = Result.available(
+ username="alice", site_name="ExampleSite", category="Cat")
+
+ out_console = res.get_console_output()
+ assert "Available" in out_console
+ assert "ExampleSite" in out_console
+ assert "alice" in out_console
+
+ out_json = into_json([res])
+ assert '"username": "alice"' in out_json
+ assert '"site_name": "ExampleSite"' in out_json
+
+ out_csv = into_csv([res])
+ assert "alice" in out_csv
+ assert "ExampleSite" in out_csv
diff --git a/tests/test_orchestrator.py b/tests/test_orchestrator.py
index b012f9b..15e6dd3 100644
--- a/tests/test_orchestrator.py
+++ b/tests/test_orchestrator.py
@@ -1,7 +1,6 @@
import types
from types import SimpleNamespace
from user_scanner.core import orchestrator
-from user_scanner.cli.printer import Printer
from user_scanner.core.result import Result
@@ -44,16 +43,10 @@ def test_run_module_single_prints_json_and_csv(capsys):
setattr(module, "validate_testsite", validate_testsite)
- p_json = Printer("json")
- orchestrator.run_module_single(module, "bob", p_json, last=True)
+ orchestrator.run_module_single(module, "bob")
out = capsys.readouterr().out
- assert '"username": "bob"' in out
+ assert 'bob' in out #Needs to be improved
- p_csv = Printer("csv")
- orchestrator.run_module_single(module, "bob", p_csv, last=True)
- out2 = capsys.readouterr().out
- assert "bob" in out2
- assert "Testsite" in out2 or "testsite" in out2
def test_run_checks_category_threaded(monkeypatch, tmp_path):
@@ -70,8 +63,7 @@ def test_run_checks_category_threaded(monkeypatch, tmp_path):
monkeypatch.setattr(orchestrator, "load_modules", lambda p: [module])
monkeypatch.setattr(orchestrator, "get_site_name", lambda m: "Testsite")
- p = Printer("console")
- results = orchestrator.run_checks_category(tmp_path, "someone", p, last=True)
+ results = orchestrator.run_checks_category(tmp_path, "someone")
assert isinstance(results, list)
assert len(results) == 1
assert results[0].to_number() == 0 # TAKEN
diff --git a/tests/test_printer.py b/tests/test_printer.py
deleted file mode 100644
index ad398e7..0000000
--- a/tests/test_printer.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from user_scanner.cli.printer import Printer, indentate, INDENT
-from user_scanner.core.result import Result
-import pytest
-
-
-def test_indentate():
- assert indentate("", -1) == ""
- assert indentate("", 0) == ""
- assert indentate("", 2) == 2 * INDENT
-
- msg = ("This is a test message\n"
- "made to test the identation\n"
- "and shouldn't be changed.")
-
- for i in range(0, 4):
- new = indentate(msg, i)
- for line in new.split("\n"):
- assert line.find(INDENT * i) == 0
-
-
-def test_creation():
- assert Printer("console").mode == "console"
- assert Printer("csv").mode == "csv"
- assert Printer("json").mode == "json"
-
- with pytest.raises(ValueError):
- Printer(2)
-
-
-def test_is_properties():
- p = Printer("console")
- assert p.is_console is True
- assert p.is_csv is False
- assert p.is_json is False
-
- p = Printer("csv")
- assert p.is_console is False
- assert p.is_csv is True
- assert p.is_json is False
-
- p = Printer("json")
- assert p.is_console is False
- assert p.is_csv is False
- assert p.is_json is True
-
-
-def test_get_result_output_formats():
- res = Result.available(username="alice", site_name="ExampleSite", category="Cat")
-
- p_console = Printer("console")
- out_console = p_console.get_result_output(res)
- assert "Available" in out_console
- assert "ExampleSite" in out_console
- assert "alice" in out_console
-
- p_json = Printer("json")
- out_json = p_json.get_result_output(res)
- assert '"username": "alice"' in out_json
- assert '"site_name": "ExampleSite"' in out_json
-
- p_csv = Printer("csv")
- out_csv = p_csv.get_result_output(res)
- assert "alice" in out_csv
- assert "ExampleSite" in out_csv
diff --git a/user_scanner/__main__.py b/user_scanner/__main__.py
index 49b8149..00669f7 100644
--- a/user_scanner/__main__.py
+++ b/user_scanner/__main__.py
@@ -2,14 +2,14 @@ import argparse
import time
import sys
import re
-from user_scanner.cli import printer
-from user_scanner.core.orchestrator import generate_permutations, load_categories
+from user_scanner.core.orchestrator import generate_permutations, load_categories, load_modules
from colorama import Fore, Style
from user_scanner.cli.banner import print_banner
from typing import List
from user_scanner.core.result import Result
from user_scanner.core.version import load_local_version
from user_scanner.core.helpers import is_last_value
+from user_scanner.core import formatter
from user_scanner.utils.updater_logic import check_for_updates
from user_scanner.utils.update import update_self
@@ -21,7 +21,7 @@ Y = Fore.YELLOW
X = Fore.RESET
-MAX_PERMUTATIONS_LIMIT = 100 # To prevent excessive generation
+MAX_PERMUTATIONS_LIMIT = 100 # To prevent excessive generation
def main():
@@ -53,13 +53,13 @@ def main():
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
parser.add_argument(
- "-p", "--permute",type=str,help="Generate username permutations using a string pattern (e.g -p 234)"
+ "-p", "--permute", type=str, help="Generate username permutations using a string pattern (e.g -p 234)"
)
parser.add_argument(
- "-s", "--stop",type=int,default=MAX_PERMUTATIONS_LIMIT,help="Limit the number of username permutations generated"
+ "-s", "--stop", type=int, default=MAX_PERMUTATIONS_LIMIT, help="Limit the number of username permutations generated"
)
parser.add_argument(
- "-d", "--delay",type=float,default=0,help="Delay in seconds between requests (recommended: 1-2 seconds)"
+ "-d", "--delay", type=float, default=0, help="Delay in seconds between requests (recommended: 1-2 seconds)"
)
parser.add_argument(
"-f", "--format", choices=["console", "csv", "json"], default="console", help="Specify the output format (default: console)"
@@ -75,15 +75,21 @@ def main():
)
args = parser.parse_args()
- Printer = printer.Printer(args.format)
-
if args.update is True:
update_self()
print(f"[{G}+{X}] {G}Update successful. Please restart the tool.{X}")
sys.exit(0)
if args.list:
- Printer.print_modules(args.category)
+ categories = load_categories()
+ for cat_name, cat_path in categories.items():
+ modules = load_modules(cat_path)
+ print(Fore.MAGENTA +
+ f"\n== {cat_name.upper()} SITES =={Style.RESET_ALL}")
+ for module in modules:
+ site_name = module.__name__.split(".")[-1].capitalize()
+ print(f" - {site_name}")
+
return
if args.version:
@@ -93,57 +99,53 @@ def main():
check_for_updates()
if not (args.username or args.email):
- parser.print_help()
- return
+ parser.print_help()
+ return
- if Printer.is_console:
- print_banner()
+ print_banner()
is_email = args.email is not None
if is_email and not re.findall(r"^[^@\s]+@[^@\s]+\.[^@\s]+$", args.email):
print(R + "[✘] Error: Invalid email." + X)
sys.exit(1)
- if args.permute and args.delay == 0 and Printer.is_console:
+ if args.permute and args.delay == 0:
print(
- Y
- + "[!] Warning: You're generating multiple usernames with NO delay between requests. "
- "This may trigger rate limits or IP bans. Use --delay 1 or higher. (Use only if the sites throw errors otherwise ignore)\n"
- + Style.RESET_ALL)
+ Y
+ + "[!] Warning: You're generating multiple usernames with NO delay between requests. "
+ "This may trigger rate limits or IP bans. Use --delay 1 or higher. (Use only if the sites throw errors otherwise ignore)\n"
+ + Style.RESET_ALL)
- name = args.username or args.email #Username or email
+ name = args.username or args.email # Username or email
usernames = [name] # Default single username list
# Added permutation support , generate all possible permutation of given sequence.
if args.permute:
- usernames = generate_permutations(name, args.permute , args.stop, is_email)
- if Printer.is_console:
- print(
- C + f"[+] Generated {len(usernames)} username permutations" + Style.RESET_ALL)
+ usernames = generate_permutations(
+ name, args.permute, args.stop, is_email)
+ print(
+ C + f"[+] Generated {len(usernames)} username permutations" + Style.RESET_ALL)
if args.module and "." in args.module:
args.module = args.module.replace(".", "_")
- def run_all_usernames(func, arg = None) -> List[Result]:
+ def run_all_usernames(func, arg=None) -> List[Result]:
"""
Executes a function for all given usernames.
Made in order to simplify main()
"""
results = []
- print(Printer.get_start())
for i, name in enumerate(usernames):
- is_last = i == len(usernames) - 1
+ is_last = is_last_value(usernames, i)
if arg is None:
- results.extend(func(name, Printer, is_last))
+ results.extend(func(name))
else:
- results.extend(func(arg, name, Printer, is_last))
+ results.extend(func(arg, name))
if args.delay > 0 and not is_last:
time.sleep(args.delay)
- if Printer.is_json:
- print(Printer.get_end())
return results
- results = []
+ results = []
if args.module:
# Single module search across all categories
@@ -171,7 +173,7 @@ def main():
if not args.output:
return
- if args.output and Printer.is_console:
+ if args.output and args.format == "console":
msg = (
"\n[!] The console format cannot be "
f"written to file: '{args.output}'."
@@ -179,14 +181,8 @@ def main():
print(R + msg + Style.RESET_ALL)
return
- content = Printer.get_start()
-
- for i,result in enumerate(results):
- char = "" if Printer.is_csv or is_last_value(results, i) else ","
- content += "\n" + Printer.get_result_output(result) + char
-
- if Printer.is_json:
- content += "\n" + Printer.get_end()
+
+ content = formatter.into_csv(results) if args.format == "csv" else formatter.into_json(results)
with open(args.output, "a", encoding="utf-8") as f:
f.write(content)
diff --git a/user_scanner/cli/printer.py b/user_scanner/cli/printer.py
deleted file mode 100644
index 01f035f..0000000
--- a/user_scanner/cli/printer.py
+++ /dev/null
@@ -1,117 +0,0 @@
-from colorama import Fore, Style
-from typing import Literal
-from user_scanner.core.result import Result, Status
-
-INDENT = " "
-CSV_HEADER = "username,category,site_name,status,url,reason"
-
-
-def indentate(msg: str, indent: int):
- if indent <= 0:
- return msg
- tabs = INDENT * indent
- return "\n".join([f"{tabs}{line}" for line in msg.split("\n")])
-
-
-class Printer:
- def __init__(self, format: Literal["console", "csv", "json"]) -> None:
- if format not in ["console", "csv", "json"]:
- raise ValueError(f"Invalid output-format: {format}")
- self.mode: str = format
- self.indent: 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 get_start(self, json_char: str = "[") -> str:
- if self.is_json:
- self.indent += 1
- return indentate(json_char, self.indent - 1)
- elif self.is_csv:
- return CSV_HEADER
- return ""
-
- def get_end(self, json_char: str = "]") -> str:
- if not self.is_json:
- return ""
- self.indent = max(self.indent - 1, 0)
- return indentate(json_char, self.indent)
-
- def get_result_output(self, result: Result) -> str:
- # In principle result should always have this
- site_name = result.site_name
- username = result.username
-
- match (result.status, self.mode):
- case (Status.AVAILABLE, "console"):
- return f"{INDENT}{Fore.GREEN}[βœ”] {site_name} ({username}): Available{Style.RESET_ALL}"
-
- case (Status.TAKEN, "console"):
- return f"{INDENT}{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"{INDENT}{Fore.YELLOW}[!] {site_name} ({username}): Error{reason}{Style.RESET_ALL}"
-
- case (_, "json"):
- return indentate(result.to_json().replace("\t", INDENT), self.indent)
-
- case (_, "csv"):
- return result.to_csv()
-
- return ""
-
- def print_modules(self, category: str | None = None):
- from user_scanner.core.orchestrator import load_categories, load_modules
- categories = load_categories()
- categories_to_list = [category] if category else categories.keys()
-
- # Print the start
- if self.is_json:
- print(self.get_start("{"))
- elif self.is_csv:
- print("category,site_name")
-
- for i, cat_name in enumerate(categories_to_list):
- path = categories[cat_name]
- modules = load_modules(path)
-
- # Print for each category
- match self.mode:
- case "console":
- print(Fore.MAGENTA +
- f"\n== {cat_name.upper()} SITES =={Style.RESET_ALL}")
- case "json":
- print(self.get_start(f"\"{cat_name}\": ["))
-
- for j, module in enumerate(modules):
- is_last = j == len(modules) - 1
- site_name = module.__name__.split(".")[-1].capitalize()
-
- # Print for each site name
- match self.mode:
- case "console":
- print(f"{INDENT}- {site_name}")
- case "json":
- msg = f"\"{site_name}\"" + ("" if is_last else ",")
- print(indentate(msg, self.indent))
- case "csv":
- print(f"{cat_name},{site_name}")
-
- if self.is_json:
- is_last = i == len(categories_to_list) - 1
- print(self.get_end("]" if is_last else "],"))
-
- if self.is_json:
- print(self.get_end("}"))
diff --git a/user_scanner/core/formatter.py b/user_scanner/core/formatter.py
new file mode 100644
index 0000000..1018861
--- /dev/null
+++ b/user_scanner/core/formatter.py
@@ -0,0 +1,27 @@
+from user_scanner.core.result import Result
+from typing import List
+
+INDENT = " "
+CSV_HEADER = "username,category,site_name,status,reason"
+
+
+def indentate(msg: str, indent: int):
+ if indent <= 0:
+ return msg
+ tabs = INDENT * indent
+ return "\n".join([f"{tabs}{line}" for line in msg.split("\n")])
+
+
+def into_json(results: List[Result]) -> str:
+ res = "[\n"
+
+ for i, result in enumerate(results):
+ is_last = i == len(results) - 1
+ end = "" if is_last else ","
+ res += indentate(result.to_json().replace("\t", INDENT), 1) + end + "\n"
+
+ return res + "]"
+
+
+def into_csv(results: List[Result]) -> str:
+ return CSV_HEADER + "\n" + "\n".join(result.to_csv() for result in results)
diff --git a/user_scanner/core/orchestrator.py b/user_scanner/core/orchestrator.py
index 1cda1a1..9666fe4 100644
--- a/user_scanner/core/orchestrator.py
+++ b/user_scanner/core/orchestrator.py
@@ -5,11 +5,10 @@ from concurrent.futures import ThreadPoolExecutor
from itertools import permutations
import httpx
from pathlib import Path
-from user_scanner.cli.printer import Printer
from user_scanner.core.result import Result
from types import ModuleType
from typing import Callable, Dict, List
-from user_scanner.core.helpers import get_site_name, is_last_value
+from user_scanner.core.helpers import get_site_name
def load_modules(category_path: Path) -> List[ModuleType]:
@@ -82,57 +81,46 @@ def worker_single(module, username: str) -> Result:
return Result.error(e, site_name=site_name, username=username)
-def run_module_single(module, username: str, printer: Printer, last: bool = True) -> List[Result]:
+def run_module_single(module, username: str) -> List[Result]:
result = worker_single(module, username)
category = find_category(module)
if category:
result.update(category=category)
- get_site_name(module)
- msg = printer.get_result_output(result)
- if not last and printer.is_json:
- msg += ","
- print(msg)
+ print(result.get_console_output())
return [result]
-def run_checks_category(category_path: Path, username: str, printer: Printer, last: bool = True) -> List[Result]:
+def run_checks_category(category_path: Path, username: str) -> List[Result]:
modules = load_modules(category_path)
category_name = category_path.stem.capitalize()
- if printer.is_console:
- print(f"\n{Fore.MAGENTA}== {category_name} SITES =={Style.RESET_ALL}")
+ print(f"\n{Fore.MAGENTA}== {category_name} SITES =={Style.RESET_ALL}")
results = []
with ThreadPoolExecutor(max_workers=10) as executor:
exec_map = executor.map(lambda m: worker_single(m, username), modules)
- for i, result in enumerate(exec_map):
- result.update(category = category_name)
+ for result in exec_map:
+ result.update(category=category_name)
results.append(result)
- is_last = last and is_last_value(modules, i)
- get_site_name(modules[i])
- msg = printer.get_result_output(result)
- if not is_last and printer.is_json:
- msg += ","
- print(msg)
+ print(result.get_console_output())
return results
-def run_checks(username: str, printer: Printer, last: bool = True) -> List[Result]:
- if printer.is_console:
- print(f"\n{Fore.CYAN} Checking username: {username}{Style.RESET_ALL}")
+def run_checks(username: str) -> List[Result]:
+
+ print(f"\n{Fore.CYAN} Checking username: {username}{Style.RESET_ALL}")
results = []
categories = list(load_categories().values())
- for i, category_path in enumerate(categories):
- last_cat = last and (i == len(categories) - 1)
- temp = run_checks_category(category_path, username, printer, last_cat)
+ for category_path in categories:
+ temp = run_checks_category(category_path, username)
results.extend(temp)
return results
diff --git a/user_scanner/core/result.py b/user_scanner/core/result.py
index 865657f..025be4c 100644
--- a/user_scanner/core/result.py
+++ b/user_scanner/core/result.py
@@ -1,4 +1,5 @@
from enum import Enum
+from colorama import Fore, Style
DEBUG_MSG = """Result {{
status: {status},
@@ -123,3 +124,18 @@ class Result:
return NotImplemented
+ def get_console_output(self) -> str:
+ site_name = self.site_name
+ username = self.username
+
+ if self == Status.AVAILABLE:
+ return f" {Fore.GREEN}[βœ”] {site_name} ({username}): Available{Style.RESET_ALL}"
+ elif self == Status.TAKEN:
+ return f" {Fore.RED}[✘] {site_name} ({username}): Taken{Style.RESET_ALL}"
+ elif self == Status.ERROR:
+ reason = ""
+ if isinstance(self, Result) and self.has_reason():
+ reason = f" ({self.get_reason()})"
+ return f" {Fore.YELLOW}[!] {site_name} ({username}): Error{reason}{Style.RESET_ALL}"
+
+ return ""