π΅οΈββοΈ (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.
Python cybersecuritycybersecurity-toolsemail-osintethical-hackingethical-hacking-toolsidentificationinfosecosintosint-emailosint-toolosint-toolsosint-usernamepentestingpythonredteam-toolsredteamingthreat-intelligence
feat(pdf): implement hybrid media extraction, fix SVG scaling and export bug, update CONTRIBUTING
Kaif9f4d10a7916e
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 85aa9cf..46fa842 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -133,7 +133,7 @@ def validate_<sitename>(user: str) -> Result:**CRITICAL Rules for `user_scan` Modules:**1. **Explicit Verification (No False Positives):** Never rely solely on a generic HTTP 200 to assume availability. Many WAFs and CDNs intercept requests and return 200 OK. You MUST explicitly verify a unique string or JSON key for BOTH the `taken` and `available` states. **Never use a bare `else: return Result.available()` block.**-2. **Deep Data Extraction:** If the user is found, attempt to extract rich metadata (fullname, location, bio, stats) and return it via `Result.taken(extra={"fullname": "John Doe", ...})`.+2. **Deep Data Extraction:** If the user is found, attempt to extract rich metadata (fullname, location, bio, stats) and return it via `Result.taken(extra={"fullname": "John Doe", ...})`. **If extracting profile pictures, banners, or other images, you MUST pass their URLs in the `media` dictionary** (e.g., `Result.taken(media={"avatar": "https://..."})`), not in `extra`.3. **Strict Error Handling:** NEVER use `raise Exception()`. All unhandled states or unexpected status codes must return `Result.error(f"Unexpected status code {resp.status_code}")`.4. **Use Orchestrator Helpers:** Use `generic_validate` to standardize `httpx` logic, but write robust `process` callbacks.@@ -184,7 +184,43 @@ def validate_example(user: str) -> Result:return generic_validate(url, process, headers=headers, show_url=show_url, follow_redirects=True)```-### 2. status_validate (Discouraged)+### 2. impersonate_validate++- **Purpose:** Run a request through a cookie-persistent `curl_cffi` session that impersonates a browser TLS fingerprint. Use it for services protected by strict anti-bot walls such as DataDome or Cloudflare, which may reject standard Python HTTP clients even when their headers look like a browser's.+- **When to use:** Prefer `generic_validate` for ordinary endpoints. Choose `impersonate_validate` when the site is known to inspect the TLS fingerprint or requires browser-like session cookies.+- **Key parameters:**+ - `warmup_url` optionally fetches a page once per session before the main request so the session can obtain clearance cookies.+ - `impersonate` selects the browser profile and defaults to `"chrome"`.+ - `show_url` controls the URL attached to the returned `Result`; it defaults to the request URL.+ - `allow_redirects` defaults to `False`, unlike httpx's `follow_redirects=True` in the `generic_validate` example. Pass `allow_redirects=True` when the profile URL redirects. Additional keyword arguments are forwarded to `impersonate_request`.++```python+from user_scanner.core.impersonate import impersonate_validate+from user_scanner.core.result import Result+++def validate_example(user: str) -> Result:+ url = f"https://www.example.com/profile/{user}"++ def process(response):+ if response.status_code == 404 and "User does not exist" in response.text:+ return Result.available()+ if response.status_code == 200 and f'profile/{user}' in response.text:+ return Result.taken()+ return Result.error(f"Unexpected response status: {response.status_code}")++ return impersonate_validate(+ url,+ process,+ warmup_url="https://www.example.com/",+ impersonate="chrome",+ show_url=url,+ )+```++For multi-step flows, use `impersonate_request` directly. It returns the raw `curl_cffi` response and reuses the same browser-like session, cookies, proxy, and optional warm-up as `impersonate_validate`.++### 3. status_validate (Discouraged)- **Purpose:** Simple helper for sites where availability can be determined purely from HTTP status codes (e.g., 404 = available, 200 = taken).- **Warning:** Use this *only* as a last resort if the site has absolutely no WAF and reliably returns strict HTTP codes without custom redirect/error pages. Modern sites heavily punish this approach.@@ -195,7 +231,7 @@ def validate_example(user: str) -> Result:- Always return a Result object:- `Result.available()`- - `Result.taken(extra={"fullname": "..."})`+ - `Result.taken(extra={"fullname": "..."}, media={"avatar": "..."})`- `Result.error("short diagnostic message")`- The orchestrator captures network errors (`httpx.ConnectError`, `httpx.TimeoutException`, etc.) and returns `Result.error(...)` automatically.- **NEVER** use `raise Exception("...")`. If you encounter an anomaly in your `process` function, always return `Result.error("...")` so the scanner can gracefully continue to the next module.diff --git a/tests/test_result.py b/tests/test_result.pyindex 012690e..ded3416 100644--- a/tests/test_result.py+++ b/tests/test_result.py@@ -90,6 +90,26 @@ def test_number_roundtrip():assert Result.from_number(c.to_number()) == c+def test_result_update_empty_values():+ result = Result(Status.TAKEN)+ result.update(username="test", site_name="", category=None, url=" ", extra={"key": " "})+ assert result.username == "test"+ assert result.site_name == ""+ assert result.category is None+ assert result.url == " "+ assert "key" not in result.extra+++def test_result_media():+ result = Result.taken(media={"avatar": "https://example.com/a.png", " banner ": "https://example.com/b.png "})+ assert result.media == {"avatar": "https://example.com/a.png", "banner": "https://example.com/b.png"}++ # Test fallback ignores empty media values+ result.update(media={"empty": " ", "none": None})+ assert "empty" not in result.media+ assert "none" not in result.media++def test_update_and_fields():res = Result.available()assert res.username is Nonediff --git a/user_scanner/__main__.py b/user_scanner/__main__.pyindex 9b190dd..d13ffb9 100644--- a/user_scanner/__main__.py+++ b/user_scanner/__main__.py@@ -430,6 +430,18 @@ def main():if args.hudson_scan:sys.exit(0)+ if args.output and not args.format:+ ext = args.output.lower()+ if ext.endswith('.json'):+ args.format = 'json'+ elif ext.endswith('.csv'):+ args.format = 'csv'+ elif ext.endswith('.pdf'):+ args.format = 'pdf'+ else:+ print(f"\n{Fore.RED}[β] Specify output format using -f (json, csv, pdf) or use a known file extension.{Style.RESET_ALL}")+ sys.exit(1)+is_pdf_export = args.format == "pdf" or (args.output and args.output.lower().endswith(".pdf"))if args.output or is_pdf_export:diff --git a/user_scanner/core/pdf_generator.py b/user_scanner/core/pdf_generator.pyindex 8a3da04..d15d813 100644--- a/user_scanner/core/pdf_generator.py+++ b/user_scanner/core/pdf_generator.py@@ -39,7 +39,7 @@ def truncate(val: Any, max_length: int = 300) -> str:s = str(val)else:s = str(val)-+s = "".join([c for c in s if ord(c) < 128])if len(s) > max_length:return s[:max_length] + "..."@@ -49,7 +49,7 @@ def truncate(val: Any, max_length: int = 300) -> str:def clean_metadata(extra: Any) -> List[tuple]:if not extra or not isinstance(extra, dict):return []- return [(k, v) for k, v in extra.items() if k not in ["avatar", "image"]]+ return [(k, v) for k, v in extra.items() if not any(x in k.lower() for x in ["avatar", "image", "pfp", "avatar_url", "image_url", "snapcode"])]def fetch_and_resize_image(url: str, max_size: tuple = (600, 600)) -> Optional[Any]:@@ -192,7 +192,7 @@ def generate_pdf_report(version_str = f" v{version}" if version else ""header_left = [- Paragraph(f"USER SCANNER{version_str.upper()}", header_brand_style),+ Paragraph(f"User Scanner{version_str.lower()}", header_brand_style),Spacer(1, 2),Paragraph("INTELLIGENCE DOSSIER", header_title_style),Spacer(1, 2),@@ -266,10 +266,22 @@ def generate_pdf_report(if include_media and PIL_AVAILABLE:unique_photos = {}for idx, hit in enumerate(hits):+ media = hit.get("media", {})extra = hit.get("extra", {})- if isinstance(extra, dict):- url = extra.get("avatar") or extra.get("image")- if url and isinstance(url, str) and url not in unique_photos:++ urls = []++ if isinstance(media, dict) and media:+ urls.extend(str(v) for v in media.values() if v)+ elif isinstance(extra, dict) and extra:+ for k, v in extra.items():+ if v and isinstance(v, str):+ k_lower = k.lower()+ if any(x in k_lower for x in ["avatar", "image", "pfp", "profile_picture", "snapcode"]):+ urls.append(v)++ for url in urls:+ if url and isinstance(url, str) and url.startswith("http") and url not in unique_photos:unique_photos[url] = {"site": hit.get("site_name", "Unknown"),"slNo": idx + 1,@@ -287,7 +299,14 @@ def generate_pdf_report(if isinstance(img_io_or_drawing, io.BytesIO):rl_img = RLImage(img_io_or_drawing, width=60, height=60)else:- rl_img = img_io_or_drawing+ # For SVGs, we must scale the layout drawing itself to 60x60+ drawing = img_io_or_drawing+ if hasattr(drawing, "width") and hasattr(drawing, "height") and drawing.width > 0 and drawing.height > 0:+ s = min(60.0 / drawing.width, 60.0 / drawing.height)+ drawing.scale(s, s)+ drawing.width = drawing.width * s+ drawing.height = drawing.height * s+ rl_img = drawingcaption = Paragraph(f"<font size=6 color='#6b7280'>{info['slNo']}. {html.escape(str(info['site']))}</font>",ParagraphStyle("c", alignment=1),diff --git a/user_scanner/core/result.py b/user_scanner/core/result.pyindex 0a2ddbe..b787a69 100644--- a/user_scanner/core/result.py+++ b/user_scanner/core/result.py@@ -89,6 +89,7 @@ class Result:self.category = Noneself.url = "" # Initialized url fieldself.extra: dict[str, str | bool | int] = {}+ self.media: dict[str, str] = {}self.is_email = Falseself.update(**kwargs)@@ -112,6 +113,12 @@ class Result:self.extra[clean_key] = value+ if "media" in kwargs and isinstance(kwargs["media"], dict):+ for key, value in kwargs["media"].items():+ if value is None or not str(value).strip():+ continue+ self.media[key.strip().lower()] = str(value).strip()+return self@classmethod