Natas Level 23
Natas Level 23 — a password check mixes string search with a numeric comparison; learn how PHP's loose typing can be satisfied in surprising ways.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas23
URL: http://natas23.natas.labs.overthewire.org
Study guide
Level map: sign in as natas23 and find the password for natas24.
What this level teaches
How comparing text and numbers together in a dynamically typed language creates logic holes.
Key ideas
- Type juggling. In older PHP, comparing a string with a number converts one into the other, often in surprising ways.
- Two conditions at once. The code requires a string to contain a specific word and to compare as a number against a threshold.
- Satisfying both. An input can start with digits and contain the required word.
- Read the source. The two checks are written explicitly.
How to approach it
- Read the conditions and look up how PHP converts strings to numbers.
- Construct one input that satisfies both.
How developers prevent it
Use strict comparison (===), validate types explicitly and keep password logic out of hand-written conditions.