$ cat writeup.md…
$ cat writeup.md…
hackthebox
Task: Parse mixed emails and passwords, find valid credential pairs where the firstname from the email appears as a substring in the password. Solution: Extract firstname from email local part (all chars except last), check substring match against all passwords, sort pairs lexicographically.
| Field | Value |
|---|---|
| Event | HackTheBox |
| Category | Programming/Misc |
| Difficulty | Easy |
| Target | 94.237.56.175:43741 |
| Flag | HTB{th4t_1s_4n_0bvi0us_p41r1ng} |
The data leaked quietly - unnoticed, unguarded, and brimming with opportunity. You're in deep now. A tangle of credentials spilled from a forgotten system connected to CygnusCorp's sprawling digital perimeter. Half garbage, half gold. Somewhere in this chaos are access keys - real names, real logins, real passwords. You just have to find the ones that match.
This is a web-based coding challenge using Monaco editor interface. The task involves:
firstname + first_letter_of_lastname@domain
[email protected] (Alice J.)[email protected] (Josh R.)The email format firstnameX@domain means:
firstname + first_letter_of_lastnamefirstname = local_part[:-1] (remove last character)For example:
[email protected] -> firstname = lisabeth[email protected] -> firstname = nevin[email protected] -> firstname = joicelocal_part[:-1]import re def solve(): n = int(input()) lines = [] for _ in range(n): lines.append(input().strip()) # Email pattern: firstname + first letter of lastname @ domain email_pattern = re.compile(r"^[a-z]+@[a-z0-9.-]+\.[a-z]{2,}$", re.IGNORECASE) emails = [] passwords = [] for line in lines: if "@" in line and email_pattern.match(line): local_part = line.split("@")[0] if len(local_part) >= 2: firstname = local_part[:-1] # All except last letter emails.append((line, firstname)) else: passwords.append(line) pairs = [] for email, firstname in emails: for password in passwords: if firstname in password: pairs.append((email, password)) pairs.sort(key=lambda x: (x[0], x[1])) for email, password in pairs: print(f"{email} {password}") solve()
Input:
17
[email protected]
nevin2024!@
[email protected]
...
[email protected]
2025joiceTheDev!@
Processing:
[email protected] -> firstname = lisabeth[email protected] -> firstname = nevin[email protected] -> firstname = joiceMatching:
lisabeth found in lisabeth2024 -> valid pairnevin found in nevin2024!@ -> valid pairjoice found in 2025joiceTheDev!@ and joiceqwerty2025 -> two valid pairsOutput (sorted):
[email protected] 2025joiceTheDev!@
[email protected] joiceqwerty2025
[email protected] lisabeth2024
[email protected] nevin2024!@
Given constraints (N <= 10^4), the O(N^2) approach is acceptable.
Use this technique when you see:
.lower() needed)$ cat /etc/motd
Liked this one?
Pro unlocks every writeup, every flag, and API access. $9/mo.
$ cat pricing.md$ grep --similar