Created
July 20, 2013 16:13
-
-
Save JordanMussi/6045580 to your computer and use it in GitHub Desktop.
MyBB check_template function.
Checks whether there are any 'security' issues in templates via complex syntax. Location: ./admin/inc/functions.php:640
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Checks whether there are any 'security' issues in templates via complex syntax | |
* | |
* @param string The template to be scanned | |
* @return boolean A true/false depending on if an issue was detected | |
*/ | |
function check_template($template) | |
{ | |
// Check to see if our database password is in the template | |
if(preg_match("#database'?\\s*\]\\s*\[\\s*'?password#", $template)) | |
{ | |
return true; | |
} | |
// System calls via backtick | |
if(preg_match('#\$\s*\{#', $template)) | |
{ | |
return true; | |
} | |
// Any other malicious acts? | |
// Courtesy of ZiNgA BuRgA | |
if(preg_match("~\\{\\$.+?\\}~s", preg_replace('~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\>|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\'"]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~', '', $template))) | |
{ | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment