Skip to content
Adam Omar Saleh

SpookyCTF 2026 "Phobias" logoSpookyCTF 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 "Phobias" logoSpookyCTF 2026
Category
Reverse EngineeringEasy · estimated
Source status
Source-documented · not platform-verified
Document
PDF edition2 min read

Brief

The challenge

Category
s3b (reverse engineering)
Points
254
File
philophobia (ELF 64-bit, x86-64, PIE, not stripped)

Last time I loved I was left broken and in shambles. That's when I realized that my heart could only hold so much, I must protect it. So I won't fall in love again, it's just too scary...

Challenge page
Challenge page

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.

Text
blob[0] ^ 's' = 0x5a  →  XOR every byte with 0x5a  →  flag

01

Recon

Text
$ file philophobiaELF 64-bit LSB pie executable, x86-64, dynamically linked, ..., not stripped

The strings include a poem, an ASCII heart, and two prompts:

  • Enter where the heart breaks (Enter <start end>): read with scanf("%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 with fgets into a 1000-byte buffer

The symbol table shows main, setup, and print_flag.

02

main

Simplified from the disassembly:

C
int start, end;char buf[1000];char target[20] = "Shall I compare thee";   // built on the stack, no NUL​scanf("%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").

04

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):

Python
key = 0x29 ^ 0x73 = 0x5aend - start = 0x5a - 0x47 = 19

19 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:

Text
$ python solve.pykey = 0x5a, end - start = 19spooky{m4yb3_1_n33d_t0_10v3_mys31f}

05

Confirming with the binary

Text
$ 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

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 4 pages.