🕵️♂️ (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: added a parser that treats Facebook profile HTML as taken, the current unavailable-page HTML as available, and ambiguous bodies as error. changed the fetch path to the public URL https://www.facebook.com/{user}
Brumbelowd7cbc1d1e4be
diff --git a/tests/test_facebook.py b/tests/test_facebook.pynew file mode 100644index 0000000..836c35a--- /dev/null+++ b/tests/test_facebook.py@@ -0,0 +1,62 @@+from user_scanner.core.result import Result+from user_scanner.user_scan.social import facebook+++def test_process_profile_response_taken():+ result = facebook._process_profile_response(+ 200,+ '<meta property="og:title" content="Mark Zuckerberg" />'+ '<meta property="og:url" content="https://www.facebook.com/zuck" />'+ )++ assert result == Result.taken()+++def test_process_profile_response_available():+ result = facebook._process_profile_response(+ 200,+ 'This content isn\'t available right now","body":"When this happens, '+ "it's usually because the owner only shared it with a small group"+ )++ assert result == Result.available()+++def test_process_profile_response_ambiguous():+ result = facebook._process_profile_response(200, "<html><title>Facebook</title></html>")++ assert result == Result.error()+++def test_validate_facebook_uses_public_profile_url(monkeypatch):+ captured = {}++ class FakeResponse:+ status = 200++ def __enter__(self):+ return self++ def __exit__(self, exc_type, exc, tb):+ return False++ def read(self):+ return (+ b'<meta property="og:title" content="Meta" />'+ b'<meta property="og:url" content="https://www.facebook.com/Meta" />'+ )++ def fake_urlopen(request, timeout):+ captured["url"] = request.full_url+ captured["headers"] = dict(request.header_items())+ captured["timeout"] = timeout+ return FakeResponse()++ monkeypatch.setattr(facebook, "urlopen", fake_urlopen)++ result = facebook.validate_facebook("Meta")++ assert result == Result.taken()+ assert captured["url"] == "https://www.facebook.com/Meta"+ assert captured["timeout"] == 8.0+ assert captured["headers"]["User-agent"]diff --git a/user_scanner/user_scan/social/facebook.py b/user_scanner/user_scan/social/facebook.pyindex dc10e9a..8325c1a 100644--- a/user_scanner/user_scan/social/facebook.py+++ b/user_scanner/user_scan/social/facebook.py@@ -1,137 +1,67 @@import re--import httpx+from urllib.error import HTTPError, URLError+from urllib.request import Request, urlopenfrom user_scanner.core.result import Result+PROFILE_TITLE_RE = re.compile(r'<meta property="og:title" content="[^"]+"')+PROFILE_URL_RE = re.compile(+ r'<meta property="og:url" content="https://www\.facebook\.com/[^"]+"'+)+UNAVAILABLE_MARKER = "This content isn't available right now"-def _check(user: str) -> Result:- show_url = f"https://www.facebook.com/{user}"+def _process_profile_response(status_code: int, html: str) -> Result:+ if status_code == 429:+ return Result.error("Rate limited by Facebook")++ if status_code >= 500:+ return Result.error(f"Facebook returned HTTP {status_code}")++ has_profile_markers = bool(+ PROFILE_TITLE_RE.search(html) and PROFILE_URL_RE.search(html)+ )+ has_unavailable_marker = UNAVAILABLE_MARKER in html++ if has_profile_markers and not has_unavailable_marker:+ return Result.taken()++ if has_unavailable_marker and not has_profile_markers:+ return Result.available()++ return Result.error("Unexpected response body, report it via GitHub issues.")+++def validate_facebook(user: str) -> Result:if not (1 <= len(user) <= 50):- return Result.error("Length must be 1-50 characters", url=show_url)+ return Result.error("Length must be 1-50 characters")if not re.match(r"^[a-zA-Z0-9.]+$", user):- return Result.error("Only letters, numbers and periods allowed", url=show_url)+ return Result.error("Only letters, numbers and periods allowed")if user.isdigit():- return Result.error("Username cannot be numbers only", url=show_url)+ return Result.error("Username cannot be numbers only")if user.startswith(".") or user.endswith("."):- return Result.error(- "Username cannot start or end with a period", url=show_url- )+ return Result.error("Username cannot start or end with a period")- try:- with httpx.Client(http2=True, follow_redirects=False, timeout=10.0) as client:- headers1 = {- "User-Agent": (- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "- "(KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"- ),- "Accept": (- "text/html,application/xhtml+xml,application/xml;q=0.9,"- "image/avif,image/webp,image/apng,*/*;q=0.8,"- "application/signed-exchange;v=b3;q=0.7"- ),- "Accept-Encoding": "identity",- "sec-ch-ua": '"Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"',- }- client.get("https://m.facebook.com/login/", headers=headers1)-- headers2 = {- "User-Agent": (- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "- "(KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"- ),- "Accept": (- "text/html,application/xhtml+xml,application/xml;q=0.9,"- "image/avif,image/webp,image/apng,*/*;q=0.8,"- "application/signed-exchange;v=b3;q=0.7"- ),- "Accept-Encoding": "identity",- "upgrade-insecure-requests": "1",- "sec-fetch-site": "cross-site",- "sec-fetch-mode": "navigate",- "sec-fetch-user": "?1",- "sec-fetch-dest": "document",- "sec-ch-ua": '"Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"',- "sec-ch-ua-mobile": "?0",- "sec-ch-ua-platform": '"Linux"',- "referer": "https://www.google.com/",- "accept-language": "en-US,en;q=0.9",- "priority": "u=0, i",- }- response = client.get(- "https://www.facebook.com", params={"_rdr": ""}, headers=headers2- )- html = response.text-- lsd_match = (- re.search(r'\["LSD",\[\],\{"token":"([^"]+)"\}', html)- or re.search(r'name="lsd"\s+value="([^"]+)"', html)- or re.search(r'"lsd":"([^"]+)"', html)- )- jazoest_match = re.search(r"jazoest=(\d+)", html) or re.search(- r'name="jazoest"\s+value="(\d+)"', html- )-- lsd = lsd_match.group(1) if lsd_match else None- jazoest = jazoest_match.group(1) if jazoest_match else None-- if not lsd or not jazoest:- return Result.error(- f"Token extraction failed (LSD: {bool(lsd)}, Jazoest: {bool(jazoest)})",- url=show_url,- )-- headers3 = {- "User-Agent": (- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "- "(KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"- ),- "Accept": (- "text/html,application/xhtml+xml,application/xml;q=0.9,"- "image/avif,image/webp,image/apng,*/*;q=0.8,"- "application/signed-exchange;v=b3;q=0.7"- ),- "Accept-Encoding": "identity",- "sec-fetch-site": "same-origin",- "sec-fetch-mode": "cors",- "sec-fetch-dest": "empty",- "sec-ch-ua": '"Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"',- "sec-ch-ua-mobile": "?0",- "sec-ch-ua-platform": '"Linux"',- "referer": "https://www.facebook.com",- "x-ig-app-id": "936619743392459",- "x-requested-with": "XMLHttpRequest",- "accept-language": "en-US,en;q=0.9",- }-- params = {- "username": user,- "fb_dtsg": lsd,- "jazoest": jazoest,- }- response = client.get(- "https://www.facebook.com/ajax/username availability/",- headers=headers3,- params=params,- )-- if response.status_code == 200:- return Result.available(- f"Username {user} is available", url=show_url- )-- return Result.error(- f"Unexpected status code: {response.status_code}", url=show_url- )- except httpx.TimeoutException:- return Result.error("Request timed out", url=show_url)- except Exception as exc:- return Result.error(f"Error: {exc}", url=show_url)+ show_url = f"https://www.facebook.com/{user}"+ headers = {+ "User-Agent": "Mozilla/5.0",+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",+ "Accept-Language": "en-US,en;q=0.9",+ }+ request = Request(show_url, headers=headers)-def validate_facebook(user: str) -> Result:- return _check(user)+ try:+ with urlopen(request, timeout=8.0) as response:+ html = response.read().decode("utf-8", "ignore")+ return _process_profile_response(response.status, html).update(url=show_url)+ except HTTPError as exc:+ html = exc.read().decode("utf-8", "ignore")+ return _process_profile_response(exc.code, html).update(url=show_url)+ except URLError as exc:+ return Result.error(exc, url=show_url)+ except Exception as exc:+ return Result.error(exc, url=show_url)