#!/usr/bin/perl -w ### Version ### ### 1.1.1 Working on file upload and loop ### 1.1.2 File will upload but pulls only 1 id ### muppet.cgi ### file based case id grabber ### use strict; use CGI qw/:standard/; ### Print HTML ### print header, start_html('The Muppet'), h1('Waka_W4k4!'); print_form() unless param; print_results() if param; print end_html; ### Sub Print Form ### ### Form Subset ### sub print_form { print start_multipart_form(), filefield(-name=>'payload',-size=>60),br, submit(-label=>'Upload File'), end_form; } ### Sub Print Results ### ### Do work and print results ### sub print_results { ### Payload Variables ### my $file = param('payload'); $file=~m/^.*(\\|\/)(.*)/; my $file_name = $2; my $upload_file = upload('payload'); my $upload_dir = "/var/www/html/abuse"; ### Check for File Upload ### if (!$file) { print "No file uploaded."; return; } ### Write Uploaded file to disk ### open UPLOADFILE, ">$upload_dir/$file_name"; while (<$upload_file>) { print UPLOADFILE; } close UPLOADFILE; ### Prepare the goods to be delivered ### my $goods = "/var/www/html/abuse/$file_name"; my $caseid = 'Case - '; my $cases; open GOODS, "$goods"; my @goods=; close GOODS; foreach(@goods){ if (s/$caseid//){ $cases = $_; } } ### Print the Relavent Information ### print h2('File Name'),$file_name; print h2('File MIME type'), uploadInfo($file)->{'Content-Type'}; print h2('Cases'), $cases; print h2('Try Again'); } ### End of Sub Print Results ### ### FIN ###