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.

Implemented Result and Status

Vamato68483978dc13
diff --git a/user_scanner/core/orchestrator.py b/user_scanner/core/orchestrator.py
index d310012..eb26aab 100644
--- a/user_scanner/core/orchestrator.py
+++ b/user_scanner/core/orchestrator.py
@@ -1,3 +1,4 @@
+from enum import Enum
import importlib
import pkgutil
from colorama import Fore, Style
@@ -8,11 +9,26 @@ from httpx import ConnectError, TimeoutException
from pathlib import Path
from typing import Dict
+from typing import Callable, Literal, List
+
lock = threading.Condition()
# Basically which thread is the one to print
print_queue = 0
+def load_modules(category_path: Path):
+ modules = []
+ for file in category_path.glob("*.py"):
+ if file.name == "__init__.py":
+ continue
+ spec = importlib.util.spec_from_file_location(file.stem, str(file))
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+
+ modules.append(module)
+ return modules
+
+
def load_categories() -> Dict[str, Path]:
root = Path(__file__).resolve().parent.parent # Should be user_scanner
categories = {}
@@ -25,20 +41,55 @@ def load_categories() -> Dict[str, Path]:
return categories
+class Status(Enum):
+ TAKEN = 0
+ AVAILABLE = 1
+ ERROR = 2
-def load_modules(category_path: Path):
- modules = []
- for file in category_path.glob("*.py"):
- if file.name == "__init__.py":
- continue
- spec = importlib.util.spec_from_file_location(file.stem, str(file))
- module = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(module)
+class Result:
+ def __init__(self, status: Status, reason: str | None = None):
+ self.status = status
+ self.reason = reason
- modules.append(module)
- return modules
+ @classmethod
+ def taken(cls):
+ return cls(Status.TAKEN)
+
+ @classmethod
+ def available(cls):
+ return cls(Status.AVAILABLE)
+
+ @classmethod
+ def error(cls, reason: str | None = None):
+ return cls(Status.ERROR, reason)
+
+ @classmethod
+ def from_number(cls, i: int, reason: str | None):
+ try:
+ status = Status(i)
+ except ValueError:
+ return cls(Status.ERROR, "Invalid status. Please contact maintainers.")
+ return cls(status, reason if status == Status.TAKEN else None)
+
+ def to_number(self) -> int:
+ return self.status.value
+
+ def __eq__(self, other):
+ if isinstance(other, Status):
+ return self.status == other
+
+ if isinstance(other, Result):
+ return self.status == other.status
+
+ if isinstance(other, int):
+ return self.to_number() == other
+
+ return NotImplemented
+
+
+AnyResult = Literal[0, 1, 2] | Result
def worker_single(module, username, i):
global print_queue
@@ -53,12 +104,17 @@ def worker_single(module, username, i):
if func:
try:
result = func(username)
+ reason = ""
+
+ if isinstance(result, Result) and result.reason != None:
+ reason = f" - {result.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{Style.RESET_ALL}"
+ output = f" {Fore.YELLOW}[!] {site_name} ({username}): Error{reason}{Style.RESET_ALL}"
except Exception as e:
output = f" {Fore.YELLOW}[!] {site_name}: Exception - {e}{Style.RESET_ALL}"
else:
@@ -106,7 +162,7 @@ def run_checks(username):
print()
-def make_get_request(url, **kwargs):
+def make_get_request(url: str, **kwargs) -> httpx.Response:
"""Simple wrapper to **httpx.get** that predefines headers and timeout"""
if not "headers" in kwargs:
kwargs["headers"] = {
@@ -123,7 +179,7 @@ def make_get_request(url, **kwargs):
return httpx.get(url, **kwargs)
-def generic_validate(url, func, **kwargs):
+def generic_validate(url: str, func: Callable[[httpx.Response], AnyResult], **kwargs) -> AnyResult:
"""
A generic validate function that makes a request and executes the provided function on the response.
"""
@@ -131,18 +187,18 @@ def generic_validate(url, func, **kwargs):
response = make_get_request(url, **kwargs)
return func(response)
except (ConnectError, TimeoutException):
- return 2
+ return Result.error()
except Exception:
- return 2
+ return Result.error()
-def status_validate(url, available, taken, **kwargs):
+def status_validate(url: str, available: int | List[int], taken: int | List[int], **kwargs) -> Result:
"""
Function that takes a **url** and **kwargs** for the request and
checks if the request status matches the availabe or taken.
**Available** and **Taken** must either be whole numbers or lists of whole numbers.
"""
- def inner(response):
+ def inner(response: httpx.Response):
# Checks if a number is equal or is contained inside
def contains(a, b): return (isinstance(a, list) and b in a) or (a == b)
status = response.status_code
@@ -150,12 +206,13 @@ def status_validate(url, available, taken, **kwargs):
taken_value = contains(taken, status)
if available_value and taken_value:
- return 2 # Can't be both available and taken
+ # Can't be both available and taken
+ return Result.error("Invalid status match. Report this on Github.")
elif available_value:
- return 1
+ return Result.available()
elif taken_value:
- return 0
- return 2
+ return Result.taken()
+ return Result.error()
return generic_validate(url, inner, **kwargs)
diff --git a/user_scanner/social/x.py b/user_scanner/social/x.py
index 7b56cc7..f264ff3 100644
--- a/user_scanner/social/x.py
+++ b/user_scanner/social/x.py
@@ -3,6 +3,8 @@ import json
from colorama import Fore, Style
from httpx import ConnectError, TimeoutException
+from user_scanner.core.orchestrator import Result
+
def validate_x(user):
url = "https://api.twitter.com/i/users/username_available.json"
@@ -21,22 +23,20 @@ def validate_x(user):
try:
response = httpx.get(url, params=params, headers=headers, timeout=3.0)
status = response.status_code
- # print(response.text)
+
if status in [401, 403, 429]:
- return 2
+ return Result.error()
elif status == 200:
data = response.json()
if data.get('valid') is True:
- return 1
+ return Result.available()
elif data.get('reason') == 'taken':
- return 0
+ return Result.taken()
elif (data.get('reason') == "improper_format" or data.get('reason') == "invalid_username"):
- print(
- "\n" + " "+f"{Fore.CYAN}X says: {data.get('desc')}{Style.RESET_ALL}")
- return 2
- else:
- return 2
+ return Result.error(f"\n\t{Fore.CYAN}{Fore.CYAN}X says: {data.get('desc')}{Style.RESET_ALL}")
+
+ return Result.error()
except (ConnectError, TimeoutException, json.JSONDecodeError):
return 2