mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-06 14:07:49 +08:00
Compare commits
3 Commits
aeffac72b0
...
0830bf4289
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0830bf4289 | ||
|
|
80d35b3231 | ||
|
|
c011389c3f |
@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
@ -40,6 +39,7 @@ import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.header.CallIdHeader;
|
||||
import javax.sip.message.Response;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
@ -481,6 +481,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
try {
|
||||
Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString);
|
||||
SessionDescription sdp = gb28181Sdp.getBaseSdb();
|
||||
|
||||
if (ObjectUtils.isEmpty(gb28181Sdp.getSsrc()) ) {
|
||||
String ssrc = Integer.toUnsignedString(new SecureRandom().nextInt());
|
||||
log.warn("来自设备的Invite请求,未携带SSRC,生成随机ssrc: {},requesterId: {}/{}", ssrc, inviteInfo.getRequesterId(), inviteInfo.getSourceChannelId());
|
||||
gb28181Sdp.setSsrc(ssrc);
|
||||
}
|
||||
|
||||
// 获取支持的格式
|
||||
Vector mediaDescriptions = sdp.getMediaDescriptions(true);
|
||||
|
||||
@ -622,7 +629,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
content.append("a=setup:passive\r\n");
|
||||
}
|
||||
}
|
||||
content.append("y=" + ssrc + "\r\n");
|
||||
if (ssrc != null) {
|
||||
content.append("y=" + ssrc + "\r\n");
|
||||
}
|
||||
content.append("f=v/////a/1/8/1\r\n");
|
||||
|
||||
Platform parentPlatform = new Platform();
|
||||
|
||||
@ -204,6 +204,21 @@ public class SipUtils {
|
||||
}
|
||||
|
||||
public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException {
|
||||
|
||||
// 校验:拦截空内容与注入攻击特征
|
||||
if (sdpStr == null || sdpStr.trim().isEmpty()) {
|
||||
throw new SdpParseException(0, 0, "SDP内容为空");
|
||||
}
|
||||
// 标准SDP每行格式固定为 "x=value",不存在SQL关键字;出现则视为注入攻击
|
||||
String sdpUpper = sdpStr.toUpperCase();
|
||||
if (sdpUpper.contains("' OR '") || sdpUpper.contains("' OR 1") || sdpUpper.contains(" OR 1=1")
|
||||
|| sdpUpper.contains("--") || sdpUpper.contains("/*") || sdpUpper.contains("*/")
|
||||
|| sdpUpper.contains("DROP ") || sdpUpper.contains("INSERT ") || sdpUpper.contains("UPDATE ")
|
||||
|| sdpUpper.contains("DELETE ") || sdpUpper.contains("UNION ") || sdpUpper.contains("SELECT ")) {
|
||||
log.error("[SDP注入攻击] 检测到非法SDP内容,已拒绝解析,内容长度: {}", sdpStr.length());
|
||||
throw new SdpParseException(0, 0, "非法SDP内容");
|
||||
}
|
||||
//校验结束
|
||||
|
||||
// jainSip不支持y= f=字段, 移除以解析。
|
||||
int ssrcIndex = sdpStr.indexOf("y=");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user