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 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/bin/ drwxr-xr-x |
Viewing file: ppmtolss16 (9.44 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) | #!/usr/bin/perl ## $Id: ppmtolss16,v 1.12 2004/12/14 23:03:28 hpa Exp $ ## ----------------------------------------------------------------------- ## ## Copyright 2004 H. Peter Anvin - All Rights Reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, Inc., 53 Temple Place Ste 330, ## Boston MA 02111-1307, USA; either version 2 of the License, or ## (at your option) any later version; incorporated herein by reference. ## ## ----------------------------------------------------------------------- ## ## ppmtolss16 ## ## Convert a PNM file with max 16 colors to a simple RLE-based format: ## ## uint32 0x1413f33d ; magic (littleendian) ## uint16 xsize ; littleendian ## uint16 ysize ; littleendian ## 16 x uint8 r,g,b ; color map, in 6-bit format (each byte is 0..63) ## ## Then, a sequence of nybbles: ## ## N ... if N is != previous pixel, one pixel of color N ## ... otherwise run sequence follows ... ## M ... if M > 0 then run length is M+1 ## ... otherwise run sequence is encoded in two nybbles, ## littleendian, +17 ## ## The nybble sequences are on a per-row basis; runs may not extend ## across rows and odd-nybble rows are zero-padded. ## ## At the start of row, the "previous pixel" is assumed to be zero. ## ## Usage: ## ## ppmtolss16 [#rrggbb=i ...] < input.ppm > output.rle ## ## Command line options of the form #rrggbb=i indicate that ## the color #rrggbb (hex) should be assigned index i (decimal) ## eval { use bytes; }; eval { binmode STDIN; }; eval { binmode STDOUT; }; $magic = 0x1413f33d; # Get a token from the PPM header. Ignore comments and leading # and trailing whitespace, as is required by the spec. # This routine eats exactly one character of trailing whitespace, # unless it is a comment (in which case it eats the comment up # to and including the end of line.) sub get_token() { my($token, $ch); my($ch); do { $ch = getc(STDIN); return undef if ( !defined($ch) ); # EOF if ( $ch eq '#' ) { do { $ch = getc(STDIN); return undef if ( !defined($ch) ); } while ( $ch ne "\n" ); } } while ( $ch =~ /^[ \t\n\v\f\r]$/ ); $token = $ch; while ( 1 ) { $ch = getc(STDIN); last if ( $ch =~ /^[ \t\n\v\f\r\#]$/ ); $token .= $ch; } if ( $ch eq '#' ) { do { $ch = getc(STDIN); } while ( defined($ch) && $ch ne "\n" ); } return $token; } # Get a token, and make sure it is numeric (and exists) sub get_numeric_token() { my($token) = get_token(); if ( $token !~ /^[0-9]+$/ ) { print STDERR "Format error on input\n"; exit 1; } return $token + 0; } # Must be called before each pixel row is read sub start_new_row() { $getrgb_leftover_bit_cnt = 0; $getrgb_leftover_bit_val = 0; } # Get a single RGB token depending on the PNM type sub getrgb($) { my($form) = @_; my($rgb,$r,$g,$b); if ( $form == 6 ) { # Raw PPM, most common return undef unless ( read(STDIN,$rgb,3) == 3 ); return unpack("CCC", $rgb); } elsif ( $form == 3 ) { # Plain PPM $r = get_numeric_token(); $g = get_numeric_token(); $b = get_numeric_token(); return ($r,$g,$b); } elsif ( $form == 5 ) { # Raw PGM return undef unless ( read(STDIN,$rgb,1) == 1 ); $r = unpack("C", $rgb); return ($r,$r,$r); } elsif ( $form == 2 ) { # Plain PGM $r = get_numeric_token(); return ($r,$r,$r); } elsif ( $form == 4 ) { # Raw PBM if ( !$getrgb_leftover_bit_cnt ) { return undef unless ( read(STDIN,$rgb,1) == 1 ); $getrgb_leftover_bit_val = unpack("C", $rgb); $getrgb_leftover_bit_cnt = 8; } $r = ( $getrgb_leftover_bit_val & 0x80 ) ? 0x00 : 0xff; $getrgb_leftover_bit_val <<= 1; $getrgb_leftover_bit_cnt--; return ($r,$r,$r); } elsif ( $form == 1 ) { # Plain PBM my($ch); do { $ch = getc(STDIN); return undef if ( !defined($ch) ); return (255,255,255) if ( $ch eq '0' ); # White return (0,0,0) if ( $ch eq '1'); # Black if ( $ch eq '#' ) { do { $ch = getc(STDIN); return undef if ( !defined($ch) ); } while ( $ch ne "\n" ); } } while ( $ch =~ /^[ \t\n\v\f\r]$/ ); return undef; } else { die "Internal error: unknown format: $form\n"; } } sub rgbconvert($$$$) { my($r,$g,$b,$maxmult) = @_; my($rgb); $r = int($r*$maxmult); $g = int($g*$maxmult); $b = int($b*$maxmult); $rgb = pack("CCC", $r, $g, $b); return $rgb; } foreach $arg ( @ARGV ) { if ( $arg =~ /^\#([0-9a-f])([0-9a-f])([0-9a-f])=([0-9]+)$/i ) { $r = hex($1) << 4; $g = hex($2) << 4; $b = hex($3) << 4; $i = $4 + 0; } elsif ( $arg =~ /^\#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})=([0-9]+)$/i ) { $r = hex($1); $g = hex($2); $b = hex($3); $i = $4 + 0; } elsif ( $arg =~ /^\#([0-9a-f]{3})([0-9a-f]{3})([0-9a-f]{3})=([0-9]+)$/i ) { $r = hex($1) >> 4; $g = hex($2) >> 4; $b = hex($3) >> 4; $i = $4 + 0; } elsif ( $arg =~ /^\#([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})=([0-9]+)$/i ) { $r = hex($1) >> 8; $g = hex($2) >> 8; $b = hex($3) >> 8; $i = $4 + 0; } else { print STDERR "$0: Unknown argument: $arg\n"; next; } if ( $i > 15 ) { print STDERR "$0: Color index out of range: $arg\n"; next; } $rgb = rgbconvert($r, $g, $b, 64/256); if ( defined($index_forced{$i}) ) { print STDERR "$0: More than one color index $i\n"; exit(1); } $index_forced{$i} = $rgb; $force_index{$rgb} = $i; } $form = get_token(); die "$0: stdin is not a PNM file" if ( $form !~ /^P([1-6])$/ ); $form = $1+0; $xsize = get_numeric_token(); $ysize = get_numeric_token(); if ( $form == 1 |
:: Command execute :: | |
:: Shadow's tricks :D :: | |
Useful Commands
|
:: Preddy's tricks :D :: | |
Php Safe-Mode Bypass (Read Files)
|
--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0058 ]-- |