intrigueio / intrigue-ident

Application and Service Fingerprinting
https://core.intrigue.io
Other
131 stars 40 forks source link

Bugfix use original scheme #99

Closed shpendk closed 3 years ago

shpendk commented 3 years ago

This is a better fix for https://github.com/intrigueio/intrigue-ident/pull/98. Original PR comment:

This PR fixes a bug where ident would return "Generic Connection Reset (attempted HTTP connection)" when passing an https link with a non-standard port. For example, the following link would trigger a connection reset even though there's a webapp running on that port: https://myawesomedomain:8443.

The reason for this bug is that for non-common ports, we were automatically defaulting to http . Since the fingerprint_uri method conveniently has an opts parameter, I've solved it by passing {ssl: true} as an option, and then using https if its set.

This PR offers a better fix, by saving the original scheme in the opts hash when fingerprint_uri is called. Later, in fingerprint_service we check whether the original scheme is present and use it. We still default to http if no scheme is given, because fingerprint_service may be called from other places (i found at least one place) and hence there may not be an original scheme.

ps: the variable schema is deliberately named wrong, to not interfere with possible variables named scheme.