[ Avaa Bypassed ]




Upload:

Command:

www-data@18.188.211.44: ~ $
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * This class includes various sanitization methods that can be called statically
 *
 * @package PhpMyAdmin
 */
namespace PhpMyAdmin;

use PhpMyAdmin\Core;
use PhpMyAdmin\Util;

/**
 * This class includes various sanitization methods that can be called statically
 *
 * @package PhpMyAdmin
 */
class Sanitize
{
    /**
     * Checks whether given link is valid
     *
     * @param string  $url   URL to check
     * @param boolean $http  Whether to allow http links
     * @param boolean $other Whether to allow ftp and mailto links
     *
     * @return boolean True if string can be used as link
     */
    public static function checkLink($url, $http=false, $other=false)
    {
        $url = strtolower($url);
        $valid_starts = array(
            'https://',
            './url.php?url=https%3a%2f%2f',
            './doc/html/',
            # possible return values from Util::getScriptNameForOption
            './index.php?',
            './server_databases.php?',
            './server_status.php?',
            './server_variables.php?',
            './server_privileges.php?',
            './db_structure.php?',
            './db_sql.php?',
            './db_search.php?',
            './db_operations.php?',
            './tbl_structure.php?',
            './tbl_sql.php?',
            './tbl_select.php?',
            './tbl_change.php?',
            './sql.php?',
            # Hardcoded options in libraries/special_schema_links.inc.php
            './db_events.php?',
            './db_routines.php?',
            './server_privileges.php?',
            './tbl_structure.php?',
        );
        $is_setup = !is_null($GLOBALS['PMA_Config']) && $GLOBALS['PMA_Config']->get('is_setup');
        // Adjust path to setup script location
        if ($is_setup) {
            foreach ($valid_starts as $key => $value) {
                if (substr($value, 0, 2) === './') {
                    $valid_starts[$key] = '.' . $value;
                }
            }
        }
        if ($other) {
            $valid_starts[] = 'mailto:';
            $valid_starts[] = 'ftp://';
        }
        if ($http) {
            $valid_starts[] = 'http://';
        }
        if ($is_setup) {
            $valid_starts[] = '?page=form&';
            $valid_starts[] = '?page=servers&';
        }
        foreach ($valid_starts as $val) {
            if (substr($url, 0, strlen($val)) == $val) {
                return true;
            }
        }
        return false;
    }

    /**
     * Callback function for replacing [a@link@target] links in bb code.
     *
     * @param array $found Array of preg matches
     *
     * @return string Replaced string
     */
    public static function replaceBBLink(array $found)
    {
        /* Check for valid link */
        if (! self::checkLink($found[1])) {
            return $found[0];
        }
        /* a-z and _ allowed in target */
        if (! empty($found[3]) && preg_match('/[^a-z_]+/i', $found[3])) {
            return $found[0];
        }

        /* Construct target */
        $target = '';
        if (! empty($found[3])) {
            $target = ' target="' . $found[3] . '"';
            if ($found[3] == '_blank') {
                $target .= ' rel="noopener noreferrer"';
            }
        }

        /* Construct url */
        if (substr($found[1], 0, 4) == 'http') {
            $url = Core::linkURL($found[1]);
        } else {
            $url = $found[1];
        }

        return '<a href="' . $url . '"' . $target . '>';
    }

    /**
     * Callback function for replacing [doc@anchor] links in bb code.
     *
     * @param array $found Array of preg matches
     *
     * @return string Replaced string
     */
    public static function replaceDocLink(array $found)
    {
        if (count($found) >= 4) {
            $page = $found[1];
            $anchor = $found[3];
        } else {
            $anchor = $found[1];
            if (strncmp('faq', $anchor, 3) == 0) {
                $page = 'faq';
            } elseif (strncmp('cfg', $anchor, 3) == 0) {
                $page = 'config';
            } else {
                /* Guess */
                $page = 'setup';
            }
        }
        $link = Util::getDocuLink($page, $anchor);
        return '<a href="' . $link . '" target="documentation">';
    }

    /**
     * Sanitizes $message, taking into account our special codes
     * for formatting.
     *
     * If you want to include result in element attribute, you should escape it.
     *
     * Examples:
     *
     * <p><?php echo Sanitize::sanitize($foo); ?></p>
     *
     * <a title="<?php echo Sanitize::sanitize($foo, true); ?>">bar</a>
     *
     * @param string  $message the message
     * @param boolean $escape  whether to escape html in result
     * @param boolean $safe    whether string is safe (can keep < and > chars)
     *
     * @return string   the sanitized message
     */
    public static function sanitize($message, $escape = false, $safe = false)
    {
        if (!$safe) {
            $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
        }

        /* Interpret bb code */
        $replace_pairs = array(
            '[em]'      => '<em>',
            '[/em]'     => '</em>',
            '[strong]'  => '<strong>',
            '[/strong]' => '</strong>',
            '[code]'    => '<code>',
            '[/code]'   => '</code>',
            '[kbd]'     => '<kbd>',
            '[/kbd]'    => '</kbd>',
            '[br]'      => '<br />',
            '[/a]'      => '</a>',
            '[/doc]'      => '</a>',
            '[sup]'     => '<sup>',
            '[/sup]'    => '</sup>',
            // used in common.inc.php:
            '[conferr]' => '<iframe src="show_config_errors.php"><a href="show_config_errors.php">show_config_errors.php</a></iframe>',
            // used in libraries/Util.php
            '[dochelpicon]' => Util::getImage('b_help', __('Documentation')),
        );

        $message = strtr($message, $replace_pairs);

        /* Match links in bb code ([a@url@target], where @target is options) */
        $pattern = '/\[a@([^]"@]*)(@([^]"]*))?\]/';

        /* Find and replace all links */
        $message = preg_replace_callback($pattern, function($match){
            return self::replaceBBLink($match);
        }, $message);

        /* Replace documentation links */
        $message = preg_replace_callback(
            '/\[doc@([a-zA-Z0-9_-]+)(@([a-zA-Z0-9_-]*))?\]/',
            function($match){
                return self::replaceDocLink($match);
            },
                $message
            );

        /* Possibly escape result */
        if ($escape) {
            $message = htmlspecialchars($message);
        }

        return $message;
    }


    /**
     * Sanitize a filename by removing anything besides legit characters
     *
     * Intended usecase:
     *    When using a filename in a Content-Disposition header
     *    the value should not contain ; or "
     *
     *    When exporting, avoiding generation of an unexpected double-extension file
     *
     * @param string  $filename    The filename
     * @param boolean $replaceDots Whether to also replace dots
     *
     * @return string  the sanitized filename
     *
     */
    public static function sanitizeFilename($filename, $replaceDots = false)
    {
        $pattern = '/[^A-Za-z0-9_';
        // if we don't have to replace dots
        if (! $replaceDots) {
            // then add the dot to the list of legit characters
            $pattern .= '.';
        }
        $pattern .= '-]/';
        $filename = preg_replace($pattern, '_', $filename);
        return $filename;
    }

    /**
     * Format a string so it can be a string inside JavaScript code inside an
     * eventhandler (onclick, onchange, on..., ).
     * This function is used to displays a javascript confirmation box for
     * "DROP/DELETE/ALTER" queries.
     *
     * @param string  $a_string       the string to format
     * @param boolean $add_backquotes whether to add backquotes to the string or not
     *
     * @return string   the formatted string
     *
     * @access  public
     */
    public static function jsFormat($a_string = '', $add_backquotes = true)
    {
        $a_string = htmlspecialchars($a_string);
        $a_string = self::escapeJsString($a_string);
        // Needed for inline javascript to prevent some browsers
        // treating it as a anchor
        $a_string = str_replace('#', '\\#', $a_string);

        return $add_backquotes
            ? Util::backquote($a_string)
            : $a_string;
    } // end of the 'jsFormat' function

    /**
     * escapes a string to be inserted as string a JavaScript block
     * enclosed by <![CDATA[ ... ]]>
     * this requires only to escape ' with \' and end of script block
     *
     * We also remove NUL byte as some browsers (namely MSIE) ignore it and
     * inserting it anywhere inside </script would allow to bypass this check.
     *
     * @param string $string the string to be escaped
     *
     * @return string  the escaped string
     */
    public static function escapeJsString($string)
    {
        return preg_replace(
            '@</script@i', '</\' + \'script',
            strtr(
                $string,
                array(
                    "\000" => '',
                    '\\' => '\\\\',
                    '\'' => '\\\'',
                    '"' => '\"',
                    "\n" => '\n',
                    "\r" => '\r'
                )
            )
        );
    }

    /**
     * Formats a value for javascript code.
     *
     * @param string $value String to be formatted.
     *
     * @return string formatted value.
     */
    public static function formatJsVal($value)
    {
        if (is_bool($value)) {
            if ($value) {
                return 'true';
            }

            return 'false';
        }

        if (is_int($value)) {
            return (int)$value;
        }

        return '"' . self::escapeJsString($value) . '"';
    }

    /**
     * Formats an javascript assignment with proper escaping of a value
     * and support for assigning array of strings.
     *
     * @param string $key    Name of value to set
     * @param mixed  $value  Value to set, can be either string or array of strings
     * @param bool   $escape Whether to escape value or keep it as it is
     *                       (for inclusion of js code)
     *
     * @return string Javascript code.
     */
    public static function getJsValue($key, $value, $escape = true)
    {
        $result = $key . ' = ';
        if (!$escape) {
            $result .= $value;
        } elseif (is_array($value)) {
            $result .= '[';
            foreach ($value as $val) {
                $result .= self::formatJsVal($val) . ",";
            }
            $result .= "];\n";
        } else {
            $result .= self::formatJsVal($value) . ";\n";
        }
        return $result;
    }

    /**
     * Prints an javascript assignment with proper escaping of a value
     * and support for assigning array of strings.
     *
     * @param string $key   Name of value to set
     * @param mixed  $value Value to set, can be either string or array of strings
     *
     * @return void
     */
    public static function printJsValue($key, $value)
    {
        echo self::getJsValue($key, $value);
    }

    /**
     * Formats javascript assignment for form validation api
     * with proper escaping of a value.
     *
     * @param string  $key   Name of value to set
     * @param string  $value Value to set
     * @param boolean $addOn Check if $.validator.format is required or not
     * @param boolean $comma Check if comma is required
     *
     * @return string Javascript code.
     */
    public static function getJsValueForFormValidation($key, $value, $addOn, $comma)
    {
        $result = $key . ': ';
        if ($addOn) {
            $result .= '$.validator.format(';
        }
        $result .= self::formatJsVal($value);
        if ($addOn) {
            $result .= ')';
        }
        if ($comma) {
            $result .= ', ';
        }
        return $result;
    }

    /**
     * Prints javascript assignment for form validation api
     * with proper escaping of a value.
     *
     * @param string  $key   Name of value to set
     * @param string  $value Value to set
     * @param boolean $addOn Check if $.validator.format is required or not
     * @param boolean $comma Check if comma is required
     *
     * @return void
     */
    public static function printJsValueForFormValidation($key, $value, $addOn=false, $comma=true)
    {
        echo self::getJsValueForFormValidation($key, $value, $addOn, $comma);
    }

    /**
     * Removes all variables from request except whitelisted ones.
     *
     * @param string &$whitelist list of variables to allow
     *
     * @return void
     * @access public
     */
    public static function removeRequestVars(&$whitelist)
    {
        // do not check only $_REQUEST because it could have been overwritten
        // and use type casting because the variables could have become
        // strings
        if (! isset($_REQUEST)) {
            $_REQUEST = array();
        }
        if (! isset($_GET)) {
            $_GET = array();
        }
        if (! isset($_POST)) {
            $_POST = array();
        }
        if (! isset($_COOKIE)) {
            $_COOKIE = array();
        }
        $keys = array_keys(
            array_merge((array)$_REQUEST, (array)$_GET, (array)$_POST, (array)$_COOKIE)
        );

        foreach ($keys as $key) {
            if (! in_array($key, $whitelist)) {
                unset($_REQUEST[$key], $_GET[$key], $_POST[$key]);
                continue;
            }

            // allowed stuff could be compromised so escape it
            // we require it to be a string
            if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) {
                unset($_REQUEST[$key]);
            }
            if (isset($_POST[$key]) && ! is_string($_POST[$key])) {
                unset($_POST[$key]);
            }
            if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) {
                unset($_COOKIE[$key]);
            }
            if (isset($_GET[$key]) && ! is_string($_GET[$key])) {
                unset($_GET[$key]);
            }
        }
    }
}

Filemanager

Name Type Size Permission Actions
Config Folder 0755
Controllers Folder 0755
Database Folder 0755
Dbi Folder 0755
Di Folder 0755
Display Folder 0755
Engines Folder 0755
Gis Folder 0755
Navigation Folder 0755
Plugins Folder 0755
Properties Folder 0755
Rte Folder 0755
Server Folder 0755
Twig Folder 0755
Utils Folder 0755
Advisor.php File 18.79 KB 0644
Bookmark.php File 10.37 KB 0644
BrowseForeigners.php File 10.73 KB 0644
CentralColumns.php File 53.12 KB 0644
Charsets.php File 24.92 KB 0644
CheckUserPrivileges.php File 11.58 KB 0644
Config.php File 59.69 KB 0644
Console.php File 3.58 KB 0644
Core.php File 38.98 KB 0644
CreateAddField.php File 17.97 KB 0644
DatabaseInterface.php File 103.86 KB 0644
Encoding.php File 8.25 KB 0644
Error.php File 13.05 KB 0644
ErrorHandler.php File 16.68 KB 0644
ErrorReport.php File 8.37 KB 0644
Export.php File 40.32 KB 0644
File.php File 20.53 KB 0644
FileListing.php File 2.83 KB 0644
Font.php File 4.25 KB 0644
Footer.php File 10.54 KB 0644
Header.php File 25.81 KB 0644
Import.php File 55.59 KB 0644
Index.php File 24.63 KB 0644
IndexColumn.php File 4.43 KB 0644
InsertEdit.php File 129.29 KB 0644
IpAllowDeny.php File 9.21 KB 0644
Language.php File 4.3 KB 0644
LanguageManager.php File 23.42 KB 0644
Linter.php File 5.1 KB 0644
ListAbstract.php File 3.15 KB 0644
ListDatabase.php File 4.22 KB 0644
Logging.php File 2.56 KB 0644
Menu.php File 22.34 KB 0644
Message.php File 19.19 KB 0644
Mime.php File 891 B 0644
MultSubmits.php File 23.19 KB 0644
Normalization.php File 39.03 KB 0644
OpenDocument.php File 8.5 KB 0644
Operations.php File 79.06 KB 0644
OutputBuffering.php File 3.63 KB 0644
ParseAnalyze.php File 2.46 KB 0644
Partition.php File 7.26 KB 0644
Pdf.php File 4.07 KB 0644
Plugins.php File 21.42 KB 0644
RecentFavoriteTable.php File 12.13 KB 0644
Relation.php File 78.19 KB 0644
RelationCleanup.php File 14.7 KB 0644
Replication.php File 5.37 KB 0644
ReplicationGui.php File 41.79 KB 0644
Response.php File 16.31 KB 0644
Sanitize.php File 14.15 KB 0644
SavedSearches.php File 11.95 KB 0644
Scripts.php File 5.33 KB 0644
Session.php File 7.82 KB 0644
Sql.php File 88.22 KB 0644
SqlQueryForm.php File 17.19 KB 0644
StorageEngine.php File 13.47 KB 0644
SubPartition.php File 3.53 KB 0644
SysInfo.php File 1.54 KB 0644
SysInfoBase.php File 801 B 0644
SysInfoLinux.php File 1.96 KB 0644
SysInfoSunOS.php File 1.87 KB 0644
SysInfoWINNT.php File 3.25 KB 0644
SystemDatabase.php File 3.84 KB 0644
Table.php File 92.59 KB 0644
Template.php File 3.91 KB 0644
Theme.php File 10.53 KB 0644
ThemeManager.php File 10.73 KB 0644
Tracker.php File 29.72 KB 0644
Tracking.php File 41.99 KB 0644
Transformations.php File 16.12 KB 0644
TwoFactor.php File 7.1 KB 0644
Types.php File 22.75 KB 0644
Url.php File 8.17 KB 0644
UserPassword.php File 8.47 KB 0644
UserPreferences.php File 8.52 KB 0644
Util.php File 162.99 KB 0644
VersionInformation.php File 6.34 KB 0644
ZipExtension.php File 9.98 KB 0644