dismap icon indicating copy to clipboard operation
dismap copied to clipboard

指纹识别过程中在处理网页访问重定向的过程中出现bug

Open Gitqiubai opened this issue 2 years ago • 1 comments

url中出现 ?mod=phpcms&file=login&forward=http%3A%2F%2F127.0.0.1%3A8080%2Fadmin.php连接的时候代码中会错误的把他当成一个完整的连接,直接去请求然后导致报错 unsupported protocol scheme

BUG代码

internal/protocol/judge/tcp_http.go

导致bug的原因是使用正则直接匹配url里是否存在http字符串,如果重定向后的链接参数里带有http的话会导致被匹配出来逻辑出错,直接使用 ?mod=phpcms&file=login&forward=http%3A%2F%2F127.0.0.1%3A8080%2Fadmin.php 作为完整连接请求,导致bug出现。

if len(regexp.MustCompile("http").FindAllStringIndex(redirectPath, -1)) == 1 {
			redirectUrl = redirectPath
		} else {
			if Url[len(Url)-1:] == "/" {
				redirectUrl = Url + redirectPath
			}
			redirectUrl = Url + "/" + redirectPath
		}

修改建议

只对前4个字符进行匹配

if len(regexp.MustCompile("http").FindAllStringIndex(redirectPath[:4], -1)) == 1 {
			redirectUrl = redirectPath
		} else {
			if Url[len(Url)-1:] == "/" {
				redirectUrl = Url + redirectPath
			}
			redirectUrl = Url + "/" + redirectPath
		}

Gitqiubai avatar Apr 24 '22 13:04 Gitqiubai

mark 感谢改进意见

zhzyker avatar Apr 25 '22 06:04 zhzyker