Challenge Description
so basically the Ultimative identity platform is shutting down its old PHP login thing and it wants one request with admin access, two recovery answers, a weird dual-hash migration code and a serialized PHP profile. every check looks like it has a lock on it but the locks are all using different versions of PHP logic so i just had to make them disagree in the right way
XP crash dump
I grabbed the handout and read index.php first. The migration is stateless so all the proof has to land in one GET request. The source shows four gates: the admin parameter, matching recovery fingerprints, a compatibility hash check, then an unserialize call with two allowed classes. that last part made the profile worth checking instead of treating it like boring data
User Account Control.exe
The admin check looks contradictory at first. It searches the raw query string for the literal text access_level, then checks that $_GET['access_level'] is administrator. But PHP normalizes dots in query parameter names to underscores when it builds $_GET. so i sent access.level=administrator: the raw query never contains access_level, but PHP still provides $_GET['access_level'] as administrator. UAC clicked allow lmao
Recovery Password Worm
The recovery answers have to use the same type, be different, and then hash to the same fingerprint. Arrays take care of all three. I used primary[]=one and backup[]=two, so both are arrays but they are not strictly equal. Then the code concatenates each array onto a string; PHP converts both to the literal string Array. The SHA-256 inputs are therefore identical and the fingerprints match. It throws an array-to-string warning, but display_errors is off so it doesn't stop the request
0e.exe Compatibility Virus
The code needs the first nine characters of the MD5 and SHA-256 digests to be loosely equal but strictly different. PHP treats numeric strings in scientific notation as numbers, so two different strings like 0e1234567 and 0e7654321 both compare as zero. I searched decimal candidates until both digest prefixes had that shape. Code 59036305 works:
digest prefixes
MD5: 0e3791209
SHA-256: 0e9920675
They differ with !==, but compare equal with ==, so the compatibility gate lets the migration continue. classic legacy software moment
System Restore: profile.dat
The profile is base64url-decoded and unserialized with MigratedProfile and LegacyTemplate allowed. I made the displayName of the MigratedProfile a LegacyTemplate object, so printing the imported profile triggers LegacyTemplate::__toString(). Its template check is if (strpos($this->template, '../')): because the traversal begins at position zero, strpos returns 0 and PHP treats that as false. The path is then built under templates/ and four ../ segments climb back to /, reaching /tmp/flag
Serialized profile:
profile.dat
O:15:"MigratedProfile":1:{s:11:"displayName";O:14:"LegacyTemplate":1:{s:8:"template";s:20:"../../../../tmp/flag";}}
here's the lil helper i used to assemble the portable profile, send the whole request and print the flag:
xp_migration.py
import base64, html, re, urllib.parse, urllib.request
base = 'https://ultimative-php-86c2e87d71f7.inst13.ctf.fortid.com'
serialized = 'O:15:"MigratedProfile":1:{s:11:"displayName";O:14:"LegacyTemplate":1:{s:8:"template";s:20:"../../../../tmp/flag";}}'
profile = base64.urlsafe_b64encode(serialized.encode()).decode().rstrip('=')
params = [
('access.level', 'administrator'),
('primary[]', 'one'),
('backup[]', 'two'),
('code', '59036305'),
('profile', profile),
]
url = base + '/?' + urllib.parse.urlencode(params)
with urllib.request.urlopen(url, timeout=20) as response:
page = response.read().decode()
match = re.search(r'<p class="flag">(.*?)</p>', page, re.S)
if not match:
print(page)
else:
print(html.unescape(match.group(1).strip()))
The Final Reboot
The one GET passes every check, unserialize builds the nested objects, and the cast to string makes LegacyTemplate read the flag file. no shell, no password guessing, just PHP deciding an array is the same word twice and a zero-looking hash is close enough
Windows XP found new hardware!!!!!!!!!!!!!
flag
FortID{C0RP_M1GR4T10N_1S_WH3R3_D4T4_G03S_T0_D13_cb84a6d804}