🕵️♂️ (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
fix(stackb): enrich profile metadata from public pages (#636)
Kristo Isberga412c6d1ac48
diff --git a/user_scanner/email_scan/gaming/stackb.py b/user_scanner/email_scan/gaming/stackb.pyindex 13f0e04..98302a0 100644--- a/user_scanner/email_scan/gaming/stackb.py+++ b/user_scanner/email_scan/gaming/stackb.py@@ -3,25 +3,16 @@ import reimport httpx-from user_scanner.core.helpers import get_random_user_agent+from user_scanner.core.helpers import get_global_timeoutfrom user_scanner.core.result import Result-async def _check(email: str) -> Result:+async def validate_stackb(email: str) -> Result:show_url = "https://stackb.net"login_url = f"{show_url}/login"- headers = {- "User-Agent": get_random_user_agent(),- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",- "Accept-Language": "ru,en-US;q=0.9,en;q=0.8",- }try:- async with httpx.AsyncClient(- timeout=15.0,- headers=headers,- follow_redirects=True,- ) as client:+ async with httpx.AsyncClient(timeout=get_global_timeout() or 15.0) as client:login_response = await client.get(login_url)if login_response.status_code != 200:return Result.error(@@ -34,8 +25,8 @@ async def _check(email: str) -> Result:login_response.text,)snapshot_match = re.search(- r'<div[^>]*wire:snapshot="([^"]+)"'- r'[^>]*x-data="loginFormCaptcha',+ r'<div(?=[^>]*wire:name="login-form")'+ r'(?=[^>]*wire:snapshot="([^"]+)")[^>]*>',login_response.text,)if not csrf_match or not snapshot_match:@@ -46,7 +37,6 @@ async def _check(email: str) -> Result:csrf_token = html.unescape(csrf_match.group(1))payload = {- "_token": csrf_token,"components": [{"snapshot": html.unescape(snapshot_match.group(1)),@@ -54,19 +44,13 @@ async def _check(email: str) -> Result:"identifier": email,"password": "StackB-not-the-password-12345",},- "calls": [- {"path": "", "method": "submitLogin", "params": []}- ],+ "calls": [{"path": "", "method": "submitLogin", "params": []}],}],}login_check = await client.post(f"{show_url}/livewire/update",headers={- "Accept": "application/json",- "Content-Type": "application/json",- "Origin": show_url,- "Referer": login_url,"X-CSRF-TOKEN": csrf_token,"X-Livewire": "true",},@@ -79,23 +63,12 @@ async def _check(email: str) -> Result:url=show_url,)- components = login_check.json().get("components", [])- login_messages = " ".join(- str(dispatch.get("params", {}).get("message", ""))- for component in components- for dispatch in component.get("effects", {}).get(- "dispatches", []- )- )+ login_messages = str(login_check.json().get("components", []))if "Таких пользователей не нашлось" in login_messages:return Result.available(url=show_url)if "Пароль введен неверно" in login_messages:return Result.taken(url=show_url)return Result.error("Unexpected login check response", url=show_url)- except Exception as exc:+ except (httpx.HTTPError, ValueError, AttributeError) as exc:return Result.error(exc, url=show_url)---async def validate_stackb(email: str) -> Result:- return await _check(email)diff --git a/user_scanner/user_scan/gaming/stackb.py b/user_scanner/user_scan/gaming/stackb.pyindex 63c4da3..5723e44 100644--- a/user_scanner/user_scan/gaming/stackb.py+++ b/user_scanner/user_scan/gaming/stackb.py@@ -3,131 +3,119 @@ import jsonimport refrom urllib.parse import quote-from user_scanner.core.helpers import get_random_user_agent-from user_scanner.core.orchestrator import make_request+from user_scanner.core.orchestrator import generic_validatefrom user_scanner.core.result import Result+def _text(markup: str) -> str:+ return " ".join(html.unescape(re.sub(r"<[^>]*>", " ", markup)).split())+++def _extract_profile(response_text: str, profile: dict) -> tuple[dict, dict]:+ extra = {+ "username": str(profile.get("identifier", "")).removeprefix("@"),+ "display_name": profile.get("name"),+ "bio": profile.get("description"),+ }+ media = {"avatar": profile.get("image")}++ description_match = re.search(+ r'<meta\s[^>]*property=["\']og:description["\'][^>]*content=["\']([^"\']*)',+ response_text,+ re.IGNORECASE,+ )+ stats_text = html.unescape(description_match.group(1)) if description_match else ""+ if rank_match := re.search(r"Ранг:\s*([^\.]+)", stats_text):+ extra["rank"] = rank_match.group(1).strip()+ if followers_match := re.search(r"Подписчики:\s*(\d+)", stats_text):+ extra["followers"] = int(followers_match.group(1))+ if following_match := re.search(+ r'href="[^"]+/follows">\s*<span[^>]*>(\d+)</span>',+ response_text,+ ):+ extra["following"] = int(following_match.group(1))++ if user_id_match := re.search(+ r'<div\s+wire:key="(\d+)"[^>]*wire:name="profile"', response_text+ ):+ extra["user_id"] = int(user_id_match.group(1))++ if demographics_match := re.search(+ r"<div\b(?=[^>]*\bdata-profile-demographics\b)[^>]*>(.*?)</div>\s*</div>",+ response_text,+ re.DOTALL,+ ):+ demographics = _text(demographics_match.group(1))+ if match := re.fullmatch(r"(.+?)(?:\s+(\d+))?\s*•\s*(\S+)", demographics):+ extra["gender"] = match.group(1)+ extra["age"] = int(match.group(2)) if match.group(2) else None+ extra["region"] = match.group(3)++ identity_match = re.search(+ r"data-profile-name-row\b[^>]*>.*?</h1>", response_text, re.DOTALL+ )+ extra["verified"] = bool(identity_match and "<svg" in identity_match.group(0))++ if badge_match := re.search(+ r"<button\b(?=[^>]*\bdata-profile-badge\b)[^>]*>(.*?)</button>",+ response_text,+ re.DOTALL,+ ):+ extra["badge"] = _text(badge_match.group(1))++ if (+ website_tag := re.search(+ r"<a\b(?=[^>]*\bdata-profile-website\b)[^>]*>", response_text+ )+ ) and (href_match := re.search(r'href=["\']([^"\']+)', website_tag.group(0))):+ extra["website"] = html.unescape(href_match.group(1)).removeprefix(+ "https://stackb.net/redirect/"+ )++ if games := [+ _text(match)+ for match in re.findall(+ r"<a\b(?=[^>]*class=[\"\'][^\"\']*\bgame-card\b)[^>]*>(.*?)</a>",+ response_text,+ re.DOTALL,+ )+ ]:+ extra["games"] = games++ if cover_tag := re.search(+ r"<div\b(?=[^>]*\bdata-profile-cover\b)[^>]*>", response_text+ ):+ decoded_tag = html.unescape(cover_tag.group(0))+ if cover_match := re.search(+ r"background-image:\s*url\(['\"]?([^'\")]+)", decoded_tag+ ):+ media["banner"] = cover_match.group(1)++ return extra, media++def validate_stackb(user: str) -> Result:- profile_url = f"https://stackb.net/@{user}"url = f"https://stackb.net/@{quote(user, safe='')}"- login_url = "https://stackb.net/login"+ show_url = f"https://stackb.net/@{user}"- headers = {- "User-Agent": get_random_user_agent(),- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",- "Accept-Language": "ru,en-US;q=0.9,en;q=0.8",- }+ def process(response):+ if response.status_code == 404 and "Ошибка 404" in response.text:+ return Result.available()- try:- login_response = make_request(login_url, headers=headers, follow_redirects=True)- if login_response.status_code != 200:- return Result.error(f"Unexpected login status: {login_response.status_code}", url=url)+ if response.status_code != 200:+ return Result.error(f"Unexpected profile status: {response.status_code}")- login_text = login_response.text- csrf_match = re.search(r'<meta name="csrf-token" content="([^"]+)"', login_text)- snapshot_match = re.search(- r'<div[^>]*wire:snapshot="([^"]+)"[^>]*x-data="loginFormCaptcha',- login_text,- )- if not csrf_match or not snapshot_match:- return Result.error("Could not find login form tokens", url=url)-- csrf_token = html.unescape(csrf_match.group(1))- snapshot = html.unescape(snapshot_match.group(1))- payload = {- "_token": csrf_token,- "components": [- {- "snapshot": snapshot,- "updates": {- "identifier": user,- "password": "StackB-not-the-password-12345",- },- "calls": [{"path": "", "method": "submitLogin", "params": []}],- }- ],- }- login_check = make_request(- "https://stackb.net/livewire/update",- method="POST",- headers={- **headers,- "Accept": "application/json",- "Content-Type": "application/json",- "Origin": "https://stackb.net",- "Referer": login_url,- "X-CSRF-TOKEN": csrf_token,- "X-Livewire": "true",- },- json=payload,+ match = re.search(+ r'<script[^>]*type="application/ld\+json"[^>]*>(.*?)</script>',+ response.text,+ re.DOTALL,)+ data = json.loads(html.unescape(match.group(1))) if match else {}+ profile = data.get("mainEntity") if data.get("@type") == "ProfilePage" else None+ if isinstance(profile, dict) and profile.get("@type") == "Person":+ extra, media = _extract_profile(response.text, profile)+ return Result.taken(extra=extra, media=media)++ return Result.error("Unexpected profile response")- if login_check.status_code != 200:- return Result.error(f"Unexpected login check status: {login_check.status_code}", url=url)-- try:- login_data = login_check.json()- login_messages = " ".join(- str(dispatch.get("params", {}).get("message", ""))- for component in login_data.get("components", [])- for dispatch in component.get("effects", {}).get("dispatches", [])- )- except (ValueError, AttributeError):- return Result.error("Unexpected login check response", url=url)-- if "Максимальная длина никнейма" in login_messages:- return Result.available(- "Username format rejected by StackB",- url=url,- )- if "Таких пользователей не нашлось" in login_messages:- return Result.available(url=url)- if "Пароль введен неверно" not in login_messages:- return Result.error("Unexpected login check response", url=url)-- extra = {}- media = {}-- try:- profile_response = make_request(- url,- headers=headers,- show_url=url,- follow_redirects=True,- )- response_text = profile_response.text- profile = {}- for json_match in re.finditer(r'<script[^>]*type="application/ld\+json"[^>]*>(.*?)</script>', response_text, re.DOTALL):- try:- data = json.loads(html.unescape(json_match.group(1)))- except json.JSONDecodeError:- continue-- if data.get("@type") == "ProfilePage":- entity = data.get("mainEntity")- if isinstance(entity, dict):- profile = entity- break-- if profile:- description_match = re.search(r'<meta [^>]*property=["\']og:description["\'][^>]*content=["\']([^"\']*)', response_text, re.IGNORECASE)- stats_text = html.unescape(description_match.group(1)).strip() if description_match else None-- if name := profile.get("name"): extra["display_name"] = name- if description := profile.get("description"): extra["bio"] = description- if image := profile.get("image"): media["avatar"] = image-- if stats_text:- if rank_match := re.search(r"Ранг:\s*([^\.]+)", stats_text):- extra["rank"] = rank_match.group(1).strip()- if followers_match := re.search(r"Подписчики:\s*(\d+)", stats_text):- extra["followers"] = int(followers_match.group(1))-- extra["profile_url"] = profile_url- except Exception:- pass-- return Result.taken(extra=extra, media=media, url=url)- except Exception as exc:- return Result.error(exc, url=url)+ return generic_validate(url, process, show_url=show_url, follow_redirects=True)