directory-traversal

How to rename all folders and files to lowercase on Linux?

I have to rename a complete folder tree recursively so that no uppercase letter appears anywhere (it's C++ sourcecode, but that shouldn't matter). Bonus points for ignoring CVS and SVN control files/folders. Preferred way would be a shell script, since shell should be available at any Linux box. There were some valid arguments about det...

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? ...

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

Hi there, 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 from the directory tree(s) given and # removes empty directories en passant. ...

What are all the ways to traverse directory trees?

How do you traverse a directory tree in your favorite language? What do you need to know to traverse a directory tree in different operating systems? On different filesystems? What's your favorite library/module for aiding in traversing a directory tree? ...

Preventing directory traversal with web-facing application - are regular expressions bullet-proof?

I am in a situation where I need to allow a user to download a file dynamically determined from the URL. Before the download begins, I need to do some authentication, so the download has to run through a script first. All files would be stored outside of the web root to prevent manual downloading. For example, any of the following could...

Ensure a user-defined path is safe in PHP

I am implementing a simple directory listing script in PHP. I want to ensure that the passed path is safe before opening directory handles and echoing the results willy-nilly. $f = $_GET["f"]; if(! $f) { $f = "/"; } // make sure $f is safe $farr = explode("/",$f); $unsafe = false; foreach($farr as $farre) { // protect against d...

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? Like... http://server.com/..%01/..%01/..%01//ls ..... and get an output? EDIT: To be clear here, I've found the ...

Copy directory using Qt

I want to copy a directory from one drive to another drive. My selected directory contains many sub directories and files. How can I implement the same using Qt? ...

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 from within Python (subprocess is allowed). os.path.walk is slow. So I tried ls -lR and ...

JFile Chooser decide if Directory or File is selected

My main goal: if the user selects a directory it scans the whole folder for mp3 files and returns them. If he selects some mp3 files it returns them. To return the selected files was an easy one but to scan the directory for mp3's isn't as easy as I first thought. And I think to do that I first new to decide if the user selected a fil...

Python os.walk + follow symlinks

How do I get this piece to follow symlinks in python 2.6? def load_recursive(self, path): for subdir, dirs, files in os.walk(path): for file in files: if file.endswith('.xml'): file_path = os.path.join(subdir, file) try: do_stuff(file_path) exce...