SpookyCTF 2026Reverse Engineering
Too Much Love is Scary
The binary asks for two integers start end, then a line of text. If the text at offset start begins with "Shall I compare thee" (the first line of Shakespeare's Sonnet 18, "a certain famous summer day"), it calls…
- Competition
SpookyCTF 2026- Category
- Reverse EngineeringEasy · estimated
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition2 min read
Brief
The challenge
TL;DR
The binary asks for two integers start end, then a line of text. If the text at offset start begins with "Shall I compare thee" (the first line of Shakespeare's Sonnet 18, "a certain famous summer day"), it calls print_flag(start, end), which XORs a hard-coded blob with end - start + 0x47. The flag starts with spooky{, so the key has to be 0x5a, which means end - start = 19.
blob[0] ^ 's' = 0x5a → XOR every byte with 0x5a → flag01
Recon
$ file philophobiaELF 64-bit LSB pie executable, x86-64, dynamically linked, ..., not strippedThe strings include a poem, an ASCII heart, and two prompts:
Enter where the heart breaks (Enter <start end>):read withscanf("%d %d")Now based on our difference speak about a certain famous summer day. Make sure that it is aimed at the right spot in the heart:read withfgetsinto a 1000-byte buffer
The symbol table shows main, setup, and print_flag.
02
main
Simplified from the disassembly:
int start, end;char buf[1000];char target[20] = "Shall I compare thee"; // built on the stack, no NULscanf("%d %d", &start, &end);getchar();fgets(buf, 1000, stdin);if (strncmp(buf + start, target, 20) == 0) print_flag(start, end);else puts("..no..No...NO...NOOOOOO");So start picks where in the input the sonnet line has to appear ("aimed at the right spot in the heart"), and end only matters through the difference end - start ("based on our difference").
03
print_flag
uint8_t enc[] = { 0x29,0x2a,0x35,0x35,0x31,0x23,0x21,0x37, ... , 0x6b,0x3c,0x27, 0 };int key = end - start + 0x47;for (int i = 0; enc[i]; i++) putchar(enc[i] ^ key);The 36 encrypted bytes come from four movabs immediates plus one mov dword (little-endian):
0x3721233135352a29 0x34056b056938236e 0x6b056a2e053e6969 0x6929233705692c6a 0x00273c6b04
Recovering the key
putchar only outputs the low byte, so the key is effectively one byte. The first encrypted byte is 0x29 and the flag must start with s (0x73):
key = 0x29 ^ 0x73 = 0x5aend - start = 0x5a - 0x47 = 1919 is exactly len("Shall I compare thee") - 1, so the intended input is the inclusive index range of the sonnet line, e.g. 0 19. solve.py decrypts the blob statically:
$ python solve.pykey = 0x5a, end - start = 19spooky{m4yb3_1_n33d_t0_10v3_mys31f}05
Confirming with the binary
$ printf "0 19\nShall I compare thee to a summer's day?\n" | ./philophobia... I guess I don't have a choice...spooky{m4yb3_1_n33d_t0_10v3_mys31f}Flag
Flag
spooky{m4yb3_1_n33d_t0_10v3_mys31f}
Source-documented · not platform-verified
