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(user_scan): reject Last.fm false positives

Kristo Isberga47f0cb6b095
diff --git a/user_scanner/user_scan/music/lastfm.py b/user_scanner/user_scan/music/lastfm.py
index c45c0df..003fff6 100644
--- a/user_scanner/user_scan/music/lastfm.py
+++ b/user_scanner/user_scan/music/lastfm.py
@@ -1,47 +1,45 @@
-from user_scanner.core.orchestrator import generic_validate, Result
+import re
+from urllib.parse import quote
+from user_scanner.core.orchestrator import Result, generic_validate
-def validate_lastfm(user):
- url = f"https://www.last.fm/user/{user}"
- show_url = f"https://www.last.fm/user/{user}"
+
+def validate_lastfm(user: str) -> Result:
+ url = f"https://www.last.fm/user/{quote(user, safe='')}"
def process(response):
- if response.status_code == 404:
+ text = response.text
+ text_lower = text.lower()
+
+ if "<title>client challenge</title>" in text_lower:
+ return Result.error("Blocked by Last.fm client challenge")
+ if "<title>page not found | last.fm</title>" in text_lower:
return Result.available()
- elif response.status_code == 200:
+ if response.status_code == 200 and 'class="header-title"' in text:
extra = {}
media = {}
- try:
- import re as local_re
- # 1. Display Name
- display_name_match = local_re.search(r'class="header-title-display-name">\s*([^<\n\r]+)', response.text)
- if display_name_match:
- extra["display_name"] = display_name_match.group(1).strip()
- # 2. Scrobbling since
- since_match = local_re.search(r'scrobbling since\s*([^<\n\r]+)', response.text)
- if since_match:
- extra["scrobbling_since"] = since_match.group(1).strip()
- # 3. Scrobbles
- scrobbles_match = local_re.search(r'Scrobbles.*?<p[^>]*>.*?<a[^>]*>([^<]+)</a>', response.text, local_re.DOTALL)
- if scrobbles_match:
- extra["scrobbles"] = scrobbles_match.group(1).strip()
- # 4. Artists
- artists_match = local_re.search(r'Artists.*?<p[^>]*>.*?<a[^>]*>([^<]+)</a>', response.text, local_re.DOTALL)
- if artists_match:
- extra["artists"] = artists_match.group(1).strip()
- # 5. Avatar
- avatar_match = local_re.search(r'src="([^"]+)"[^>]*alt="Avatar for [^"]+"[^>]*itemprop="image"', response.text, local_re.DOTALL)
- if avatar_match:
- media["avatar"] = avatar_match.group(1).strip()
- except Exception:
- pass
+ display_name_match = re.search(
+ r'class="header-title-display-name">\s*([^<\n\r]+)', text
+ )
+ if display_name_match:
+ extra["display_name"] = display_name_match.group(1).strip()
+ since_match = re.search(r"scrobbling since\s*([^<\n\r]+)", text)
+ if since_match:
+ extra["scrobbling_since"] = since_match.group(1).strip()
+ for label in ("Scrobbles", "Artists"):
+ if match := re.search(
+ rf"{label}.*?<p[^>]*>.*?<a[^>]*>([^<]+)</a>", text, re.DOTALL
+ ):
+ extra[label.lower()] = match.group(1).strip()
+ avatar_match = re.search(
+ r'src="([^"]+)"[^>]*alt="Avatar for [^"]+"[^>]*itemprop="image"',
+ text,
+ )
+ if avatar_match:
+ media["avatar"] = avatar_match.group(1).strip()
return Result.taken(extra=extra, media=media)
- else:
- return Result.error(f"HTTP {response.status_code}")
+ return Result.error(
+ f"HTTP {response.status_code} without Last.fm profile markers"
+ )
- headers = {
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.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",
- "Accept-Language": "en-US,en;q=0.9",
- }
- return generic_validate(url, process, show_url=show_url, headers=headers)
+ return generic_validate(url, process, show_url=url)