cve-2024-38477/scenario1/listings.cgi
2025-06-05 15:09:30 +02:00

27 lines
499 B
Perl

#!/usr/bin/perl
use CGI;
use strict;
use warnings;
use Path::Tiny;
my $q = CGI->new;
my $dir = $q->param("r");
#if ($dir =~ m"/usr/") {
if (rindex ($dir, "/", 0) == 0) {
print "Content-Type: text/html\n\n";
my $uri = path($dir);
# Iterate over the content of foo/bar
my $iter = $uri->iterator;
while (my $file = $iter->()) {
# See if it is a directory and skip
# next if $file->is_dir();
# Print out the file name and path
print "$file\n";
}
}
else {
print $dir;
}