Like a Glove
Author: 0xIDA
Platform: HTB · Category: misc · Difficulty: easy
Solvers
Summary
Word analogy puzzle using GloVe Twitter 25-dimensional embeddings. Each line is "Like A is to B, C is to ?", encoding a standard word analogy A:B :: C:D. The formula vec(D) ≈ vec(B) - vec(A) + vec(C) is solved with a critical detail: the vector arithmetic must use unnormalized GloVe vectors, while the final nearest-neighbor search uses cosine similarity on normalized vectors. The answers form a leetspeak-encoded phrase when concatenated.
Solution
Step 1: Understand the data
The challenge provides 84 analogy questions in chal.txt. Each line follows:
Like <A> is to <B>, <C> is to?
Example: "Like non-mainstream is to efl, battery-powered is to?"
Step 2: The GloVe embedding model
The embedding model glove-twitter-25 is the 25-dimensional GloVe model trained on 27 billion Twitter tokens. Each word maps to a 25-dimensional vector.
Step 3: Solving analogies
Standard word analogy approach: If A:B :: C:D, then in the embedding space:
vec(D) ≈ vec(B) - vec(A) + vec(C)
Critical detail: The vectors must be unnormalized for the arithmetic step. Using normalized vectors (where all magnitudes equal 1) loses the word-frequency information that GloVe encodes in vector magnitudes. The target vector is then normalized for the cosine similarity search.
# Load raw unnormalized vectors
va, vb, vc = V[a_idx], V[b_idx], V[c_idx]
# Arithmetic with unnormalized vectors
target = vb - va + vc
# Normalize for cosine similarity search
target /= np.linalg.norm(target)
# Find closest word by cosine similarity
sims = np.dot(N, target) # N = normalized row vectors
best = np.argmax(sims)
Step 4: Decoding the flag
Each analogy produces a word. All 84 words concatenated form the flag. The words are encoded in leetspeak with fullwidth/halfwidth Unicode characters that need normalization:
Fullwidth normalization:
0-9(U+FF10-U+FF19) →0-94→4,1→1, etc.- Fullwidth parentheses, symbols map to ASCII equivalents
After normalization, the flag reads as leetspeak:
htb{h4rm0n1ou5_hymn_0f_h1ghd1m3ns10n4l_subl1me_5ymph0ny_0f_num3r1cal_nuanc3_1n_tr3mend0u5_t4p3stry_0f_t3xtu4l_7r4n5f0rma7ion}
Translation: "harmonious hymn of highdimensional sublime symphony of numerical nuance in tremendous tapestry of textual transformation"
Key Insight
The use of unnormalized vectors for the arithmetic step is crucial. GloVe vectors encode word co-occurrence statistics where the magnitude correlates with word frequency (common words have larger norms). Normalized vector arithmetic loses this information, shifting the target away from the correct analogy solution.
Flag
htb{h4rm0n1ou5_hymn_0f_h1ghd1m3ns10n4l_subl1me_5ymph0ny_0f_num3r1cal_nuanc3_1n_tr3mend0u5_t4p3stry_0f_t3xtu4l_7r4n5f0rma7ion}