Natas Level 29
Natas Level 29 — a Perl script opens a filename taken from the request; learn how Perl's open function can run commands.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas29
URL: http://natas29.natas.labs.overthewire.org
Study guide
Level map: sign in as natas29 and find the password for natas30.
What this level teaches
How features of a language runtime can turn a file parameter into command execution.
Key ideas
- Perl’s
open. In its two-argument form, the string you provide is interpreted: certain characters make Perl run a command rather than open a file. - Filters. The application tries to block obvious abuse, so the details of the filter matter.
- Encoding. URL-encoded characters can pass through places raw ones do not.
- Not PHP. The earlier levels were PHP; this one shows the same ideas in another language.
How to approach it
- Notice that the page parameter names a file, and read the Perl documentation for
open. - Test what the filter blocks, then find a way to express the command you need.
How developers prevent it
Use the three-argument form of open with an explicit mode, validate filenames, and never pass user input to the shell.