!c99Shell v. 1.0 pre-release build #16!

Software: Apache/2.2.3 (CentOS). PHP/5.1.6 

uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44
EDT 2010 i686
 

uid=48(apache) gid=48(apache) groups=48(apache) 

Safe-mode: OFF (not secure)

/usr/libexec/webmin/file/   drwxr-xr-x
Free 49.58 GB of 127.8 GB (38.8%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     preview.cgi (3.59 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
# Scale some image down to the preview size

require './file-lib.pl';
&ReadParse();
use POSIX;
$p = $ENV{'PATH_INFO'};

# Try to guess type from filename
$type = &guess_mime_type($p, undef);
if (!$type) {
    # No idea .. use the 'file' command
    $out = &backquote_command("file ".
                  quotemeta(&resolve_links($p)), 1);
    if ($out =~ /text|script/) {
        $type = "text/plain";
        }
    else {
        &error_exit(&text('preview_etype', $p));
        }
    }

# Make sure the type is OK
if ($type ne "image/gif" && $type ne "image/jpeg" && $type ne "image/png" &&
    $type ne "image/tiff" && $type ne "application/pdf" &&
    $type !~ /^image\/x-portable/ && $type ne "application/postscript") {
    &error_exit(&text('preview_etype2', $p));
    }

&switch_acl_uid_and_chroot();
if (!&can_access($p)) {
    # ACL rules prevent access to file
    &error_exit(&text('view_eaccess', $p));
    }

# Test if the file can be opened
if (!open(FILE, $p)) {
    # Unix permissions prevent access
    &error_exit(&text('view_eopen', $p, $!));
    }
close(FILE);

eval "use GD";
if ($@ || $type eq "image/tiff" || $type eq "application/pdf" ||
          $type =~ /^image\/x-portable/ || $type eq "application/postscript") {
    # Find an appropriate scaler
    $pnmcmd = $type eq "image/gif" ? "giftopnm" :
          $type eq "image/jpeg" ? "djpeg" :
          $type eq "image/png" ? "pngtopnm" :
          $type eq "image/tiff" ? "tifftopnm" :
          $type =~ /^image\/x-portable/ ? "cat" :
          $type eq "application/postscript" ? "pstopnm" :
          $type eq "application/pdf" ? "pdftoppm" :
                      undef;
    &has_command($pnmcmd) ||
        &error_exit(&text('preview_ecmd', $pnmcmd));
    &has_command("pnmscale") ||
        &error_exit(&text('preview_ecmd', "pnmscale"));
    &has_command("cjpeg") ||
        &error_exit(&text('preview_ecmd', "cjpeg"));

    # Run scaler
    $width = $config{'width'} || $userconfig{'width'} || 300;
    $errout = &transname();
    print "Content-type: image/jpeg\n";
    print "\n";
    if ($type eq "application/pdf") {
        # Previewing first page of PDF
        $temp = &tempname();
        $out = &backquote_command("$pnmcmd -f 1 -l 1 ".quotemeta($p)." ".$temp." 2>&1");
        if ($? || !-r "$temp-000001.ppm") {
            &error_exit("$pnmcmd failed : $out");
            }
        open(SCALE, "(cat $temp-000001.ppm | pnmscale --width $width | cjpeg) 2>$errout |");
        push(@main::temporary_files, "$temp-000001.ppm");
        }
    elsif ($type eq "application/postscript") {
        # Previewing first page of a postscript file
        $temp = &transname();
        mkdir($temp, 0755);
        &copy_source_dest($p, "$temp/file.ps");
        $out = &backquote_command("$pnmcmd $temp/file.ps 2>&1");
        if ($? || !-r "$temp/file001.ppm") {
            &error_exit("$pnmcmd failed : $out");
            }
        open(SCALE, "(cat $temp/file001.ppm | pnmscale --width $width | cjpeg) 2>$errout |");
        }
    else {
        # Converting to JPEG
        open(SCALE, "($pnmcmd <".quotemeta($p)." | pnmscale --width $width | cjpeg) 2>$errout |");
        }
    $err = &read_file_contents($errout);
    print STDERR $err;
    while(<SCALE>) {
        print;
        }
    close(SCALE);
    }
else {
    # Use the GD library
    $image = $type eq "image/gif" ? GD::Image->newFromGif($p) :
         $type eq "image/jpeg" ? GD::Image->newFromJpeg($p) :
         $type eq "image/png" ? GD::Image->newFromPng($p) : undef;
    $image || &error_exit(&text('preview_egd'));

    $width = $config{'width'} || $userconfig{'width'} || 300;
    $height = $image->height * (($width*1.0) / $image->width);

    $scaled = new GD::Image($width, $height);
    $scaled->copyResampled($image, 0, 0, 0, 0, $width, $height,
                   $image->width, $image->height);
    print "Content-type: image/jpeg\n";
    print "\n";
    print $scaled->jpeg();
    }

sub error_exit
{
print "Content-type: text/plain\n";
print "Content-length: ",length($_[0]),"\n\n";
print $_[0];
exit;
}


:: Command execute ::

Enter:
 
Select:
 

:: Shadow's tricks :D ::

Useful Commands
 
Warning. Kernel may be alerted using higher levels
Kernel Info:

:: Preddy's tricks :D ::

Php Safe-Mode Bypass (Read Files)

File:

eg: /etc/passwd

Php Safe-Mode Bypass (List Directories):

Dir:

eg: /etc/

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.012 ]--