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.

fix(tumblr): resolve blogs through the www route

Bruno Leonardo Michels8e3d7f9488c1
diff --git a/user_scanner/user_scan/social/tumblr.py b/user_scanner/user_scan/social/tumblr.py
index 5eaa4a8..2ff576a 100644
--- a/user_scanner/user_scan/social/tumblr.py
+++ b/user_scanner/user_scan/social/tumblr.py
@@ -1,35 +1,109 @@
+import json
import re
-from user_scanner.core.helpers import get_random_user_agent
-from user_scanner.core.orchestrator import Result, make_request
-
-def validate_tumblr(user):
- url = f"https://{user}.tumblr.com/"
- show_url = url
- headers = {"User-Agent": get_random_user_agent()}
-
- try:
- response = make_request(url, headers=headers)
- if response.status_code == 200:
- extra = {}
- media = {}
- title = re.search(r'<title[^>]*>(.*?)</title>', response.text, re.IGNORECASE)
- if title:
- extra["title"] = title.group(1).strip()
-
- desc = re.search(r'<meta[^>]*name="description"[^>]*content="([^"]+)"', response.text, re.IGNORECASE)
- if not desc:
- desc = re.search(r'<meta[^>]*property="og:description"[^>]*content="([^"]+)"', response.text, re.IGNORECASE)
- if desc:
- extra["description"] = desc.group(1).strip()
-
- img = re.search(r'<meta[^>]*property="og:image"[^>]*content="([^"]+)"', response.text, re.IGNORECASE)
- if img:
- media["avatar"] = img.group(1).strip()
-
- return Result.taken(extra=extra, media=media, url=show_url)
- elif response.status_code == 404:
- return Result.available(url=show_url)
- else:
- return Result.error(f"Unexpected status: {response.status_code}", url=show_url)
- except Exception as e:
- return Result.error(e, url=show_url)
+
+from user_scanner.core.impersonate import impersonate_validate
+from user_scanner.core.result import Result
+
+BLOG_MARKER = '"blog":'
+NOT_FOUND_TITLE_RE = re.compile(r"<title[^>]*>\s*Not found\.", re.IGNORECASE)
+
+
+def validate_tumblr(user: str) -> Result:
+ if not re.fullmatch(r"[A-Za-z0-9-]{1,32}", user):
+ return Result.error("Only letters, numbers and hyphens allowed (max 32)")
+
+ # Blog names are always lowercase and the www route is case-sensitive, so an
+ # unnormalised handle 404s on a name that is in fact taken.
+ user = user.lower()
+ show_url = f"https://www.tumblr.com/{user}"
+
+ def process(response) -> Result:
+ if response.status_code == 404 and NOT_FOUND_TITLE_RE.search(response.text):
+ return Result.available()
+
+ location = response.headers.get("location", "")
+ if response.status_code == 302 and f"/login_required/{user}" in location:
+ return Result.taken(extra={"username": user, "visibility": "login required"})
+
+ if response.status_code != 200:
+ return Result.error(f"Unexpected status: {response.status_code}")
+
+ blog = _find_blog(response.text, user)
+ if not blog:
+ return Result.error("Unrecognised profile payload")
+
+ extra = {"username": blog["name"]}
+ if title := blog.get("title"):
+ extra["title"] = title
+ if description := _npf_text(blog.get("descriptionNpf")):
+ extra["description"] = description
+ if uuid := blog.get("uuid"):
+ extra["uuid"] = uuid
+ if (url := blog.get("url")) and url != show_url:
+ extra["blog_url"] = url
+ if tags := _top_tags(blog.get("topTags")):
+ extra["top_tags"] = tags
+ if blog.get("isAdult"):
+ extra["adult"] = "true"
+ if blog.get("isPasswordProtected"):
+ extra["password_protected"] = "true"
+ if blog.get("ask"):
+ extra["asks_enabled"] = "true"
+
+ media = {}
+ if avatar := _largest_avatar(blog.get("avatar")):
+ media["avatar"] = avatar
+ if header := (blog.get("theme") or {}).get("headerImage"):
+ media["header"] = header
+
+ return Result.taken(extra=extra, media=media)
+
+ # The <user>.tumblr.com host answers every request with Tumblr's own
+ # "Checking your browser..." interstitial, which no HTTP client clears;
+ # the www route serves the blog payload directly.
+ return impersonate_validate(show_url, process, show_url=show_url)
+
+
+def _find_blog(html: str, user: str) -> dict | None:
+ """Return the embedded blog object whose name matches ``user``.
+
+ The page carries sibling blog objects for recommendation rails, so the
+ first match is not necessarily the requested one.
+ """
+ decoder = json.JSONDecoder()
+ index = html.find(BLOG_MARKER)
+ while index != -1:
+ try:
+ blog, _ = decoder.raw_decode(html, index + len(BLOG_MARKER))
+ except ValueError:
+ blog = None
+ if isinstance(blog, dict) and blog.get("name", "").lower() == user.lower():
+ return blog
+ index = html.find(BLOG_MARKER, index + len(BLOG_MARKER))
+ return None
+
+
+def _npf_text(blocks) -> str:
+ if not isinstance(blocks, list):
+ return ""
+ texts = [
+ block["text"]
+ for block in blocks
+ if isinstance(block, dict) and block.get("type") == "text" and block.get("text")
+ ]
+ return "\n".join(texts).strip()
+
+
+def _top_tags(tags) -> str:
+ if not isinstance(tags, list):
+ return ""
+ return ", ".join(tag["tag"] for tag in tags if isinstance(tag, dict) and tag.get("tag"))
+
+
+def _largest_avatar(avatars) -> str:
+ if not isinstance(avatars, list):
+ return ""
+ sized = [a for a in avatars if isinstance(a, dict) and a.get("url")]
+ if not sized:
+ return ""
+ return max(sized, key=lambda a: a.get("width") or 0)["url"]