Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gitqiubai opened this issue Apr 24, 2022 · 1 comment

Comments

@Gitqiubai
Copy link

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
		}
@zhzyker
Copy link
Owner

zhzyker commented Apr 25, 2022

mark
感谢改进意见

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants