Questions tagged [directory-traversal]

Directory traversal is a form of HTTP exploit in which a hacker uses the software on a Web server to access data in a directory other than the server's root directory. If the attempt is successful, the hacker can view restricted files or even execute commands on the server. Directory traversal attacks are commonly performed using Web browsers. Any server in which input data from Web browsers is not validated is vulnerable to this type of attack.

Directory traversal is a form of HTTP exploit in which a hacker uses the software on a Web server to access data in a directory other than the server's root directory. If the attempt is successful, the hacker can view restricted files or even execute commands on the server. Directory traversal attacks are commonly performed using Web browsers. Any server in which input data from Web browsers is not validated is vulnerable to this type of attack.

Although some educated guesswork is involved in finding paths to restricted files on a Web server, a skilled hacker can easily carry out this type of attack on an inadequately protected server by searching through the directory tree. The risk of such attacks can be minimized by careful Web server programming, the installation of software updates and patches, filtering of input from browsers, and the use of vulnerability scanners.

Directory traversal is also known as directory climbing or backtracking.

81 questions
4
votes
2 answers

Understanding path normalization in IIS

I'd like to disable directory traversal like example.com/page/../other-page (even to real pages) in my IIS website. I've tried Request Filtering and URL Rewrites with a custom response. The Microsoft documentation on the denyUrlSequences part of…
Michael
  • 5,910
  • 4
  • 52
  • 74
4
votes
2 answers

How to prevent directory traversal attack from Python code

I need to prevent from directory traversal attack from my code using Python. My code is below: if request.GET.get('param') is not None and request.GET.get('param') != '': param = request.GET.get('param') startdir =…
satya
  • 3,282
  • 6
  • 37
  • 104
4
votes
4 answers

Get reason for permission denied due to traversed directory not executable

I have a file /a/b that is readable by a user A. But /a does not provide executable permission by A, and thus the path /a/b cannot traverse through /a. For an arbitrarily long path, how would I determine the cause for not being able to access a…
Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
4
votes
4 answers

Why can't I remove this empty directory in Perl?

I am converting a linux script from http://www.perlmonks.org/index.pl?node_id=217166 specifically this: #!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find; @ARGV > 0 and getopts('a:', \my %opt) or die << "USAGE"; # Deletes any old files…
Mark Allison
  • 6,043
  • 26
  • 90
  • 140
4
votes
4 answers

Reasonably faster way to traverse a directory tree in Python?

Assuming that the given directory tree is of reasonable size: say an open source project like Twisted or Python, what is the fastest way to traverse and iterate over the absolute path of all files/directories inside that directory? I want to do this…
Sridhar Ratnakumar
  • 68,948
  • 61
  • 139
  • 172
4
votes
1 answer

Is dirname adequate to prevent directory traversal attacks?

Consider the following classic problem case:
Jon
  • 396,160
  • 71
  • 697
  • 768
4
votes
2 answers

How to recursively scan directories in Android

How can I recursively scan directories in Android and display file name(s)? I'm trying to scan, but it's slow (force close or wait). I'm using the FileWalker class given in a separate answer to this question.
3
votes
1 answer

php $_GET is it interpreted as single quoted or double quoted string?

I'm making the assumption that $_GET variables are interpreted as single quoted strings (and not double quoted strings). I believe this is true because of the following test (trying to directory traversal attack myself): $file = "../test.php"; /** *…
ling
  • 7,505
  • 3
  • 41
  • 39
3
votes
5 answers

GNU find: Search in current directory first

how can I tell find to look in the current folder first and then continue search in subfolders? I have the following: $ find . -iname '.note' folder/1/.note folder/2/.note folder/3/.note folder/.note What I want is this: $ find . -iname…
dmorlock
  • 1,745
  • 4
  • 16
  • 20
3
votes
6 answers

Using directory traversal attack to execute commands

Is there a way to execute commands using directory traversal attacks? For instance, I access a server's etc/passwd file like this http://server.com/..%01/..%01/..%01//etc/passwd Is there a way to run a command instead?…
HyderA
  • 18,174
  • 41
  • 103
  • 169
3
votes
1 answer

Python search for filename pattern within a specific directory pattern

How can I use os.walk ( or any other way ) to search in a way such that I can locate a file with specific name under directories with certain pattern under a root directory What I mean is if I have a directory d:\installedApps under which I have…
adbdkb
  • 1,331
  • 4
  • 26
  • 45
3
votes
3 answers

Code to get *.aspx in a website

Is there a method to get all of the .aspx files in my website? Maybe iterate through the site's file structure and add to an array?
Anders
  • 11,090
  • 34
  • 91
  • 142
3
votes
1 answer

directory traverse c

I'm trying to traverse a directory and check for duplicate files. void findDuplicates(){ char *dot[] = {".", 0}; FTS *ftsp, *temp_ftsp; FTSENT *entry, *temp_entry; int fts_options = FTS_LOGICAL; ftsp = fts_open(dot, fts_options,…
3
votes
1 answer

Differences between webroot and document root when preventing directory traversing

I've been told it's good practice to keep as much of my PHP files outside of public_html whenever possible. It's been suggested to me to use define magical constants to refer to files outside of public_html which is fine, I can go one directory up…
Kalcoder
  • 191
  • 5
  • 13
3
votes
3 answers

How to display all images of a directory in javascript?

I want to display all images from a directory dynamically with the help of javascript. How can I do this?
Vivek Parikh
  • 599
  • 8
  • 16
  • 31