Skip to content

Instantly share code, notes, and snippets.

@senky
Last active July 12, 2017 19:41
Show Gist options
  • Save senky/ba5d2de2662ad6e00d3d93ca1bb9ea8a to your computer and use it in GitHub Desktop.
Save senky/ba5d2de2662ad6e00d3d93ca1bb9ea8a to your computer and use it in GitHub Desktop.
Potential SQL injection in phpBB extensions validator
<?php
$code = file_get_contents('manager.php');
$code_exploded = explode("\n", $code);
if (preg_match_all('/WHERE[^;\$]+[=<>]+[^;]+("|\') \. \$/mU', $code, $matches, PREG_OFFSET_CAPTURE))
{
foreach ($matches[0] as $match)
{
$prelines = substr_count($code, "\n", 0, $match[1]);
$inlines = substr_count($match[0], "\n");
$line = $prelines + $inlines;
if (strpos($code_exploded[$line], 'sql_in_set') !== false || strpos($code_exploded[$line], 'sql_escape') !== false || strpos($code_exploded[$line], 'sql_bit_and') !== false || strpos($code_exploded[$line], 'get_visibility_sql') !== false || strpos($code_exploded[$line], 'get_sql_where') !== false || strpos($code_exploded[$line], 'get_forums_visibility_sql') !== false)
{
continue;
}
echo 'potential SQL injection in on line ' . ($line + 1) . ":\n";
echo $code_exploded[$line];
echo "\n\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment