dismap
dismap copied to clipboard
指纹识别过程中在处理网页访问重定向的过程中出现bug
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
}
mark 感谢改进意见