And inspecting your logs at: /var/log/apache2/error.log for your output. Its likely because you did not create your html headers, but that may be off. If you are going to `use CGI;`, you could at least replace the printing of the Content-type: line with:print STDERR "my \$valid_dir is: $valid_dir \n"; print STDERR "my \$valid_zip is: $valid_zip \n";
Since that module is built to handle that sort of thing.print $query->header; print $query->start_html('My Application');
Not sure of the true scope and purpose of your application, but I would go pc88mxer at least one more step down the path toward securing this app. I would urge that you not permit someone to simply name any old directory on your server where they are permitted to upload an arbitrary and potentially hostile zip file. I would choose a directory which I controlled and over which I could exercise some supervision. In fact, if you are running a web server, it makes alot of sense to create a disk partition from which an executable can not be executed. (See `man mount` for further details, and set your configuration for that partition in /etc/fstab). Then you can mount it to /tmp/uploads and use it as an additional layer of protection between your server and potentially hostile operators at a browser.
I would start by trying (the untested):
This follows one of the first rules of programming: laziness, by reusing other people's code. Adam Kennedy already figured out all this manipulating a zip file stuff for you. If you take a few minutes to read his documentation, with `perldoc Archive::Zip`, you might find it could save you hours of working this all out for yourself, as well as teach you more about the structure of a zip archive than you ever wanted to know. You might find that this works better for you.my $safe_uploads_directory = '/tmp/uploads'; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new( $valid_zip ); chdir( $safe_uploads_directory ) && $zip->extractTree();
-- Hugh
UPDATE:
I corrected a typo to provide a complete and absolute path in my definition of the $safe_uploads_directory.
In reply to Re: HTML Form and Perl
by hesco
in thread HTML Form and Perl
by workman_m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |