Repository navigation
Conversation
Split non-IPv6 host:port values at the first colon in parseTargetUrl() and _setHTTPHandlers() so malformed ports like ':80:90' are rejected with SqlmapSyntaxException instead of silently falling back to default ports or passing through as proxy addresses.
Member
|
Thanks, but closing — this only affects malformed input ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves silent misparsing and acceptance of malformed multi-colon ports (e.g.,
:80:90,:8443:9000,:1080:90) inparseTargetUrl()and_setHTTPHandlers().Root Cause
lib/core/common.py(parseTargetUrl): Non-IPv6netlocvalues were split withnetloc.split(:). For inputs likehttp://example.com:80:90/path, this produced 3 segments, failedlen(hostnamePort) == 2, skipped port validation, and silently fell back to the scheme default port (80/443) while leaving theurlvalue inconsistent with the fallback.lib/core/option.py(_setHTTPHandlers): Proxyhost:portextraction used.rsplit(:, 1), which parsed127.0.0.1:80:90as hostname127.0.0.1:80and port90(or[::1]:80:90as hostname[::1]:80and port90), bypassing port validation and passing malformed proxy addresses downstream. It also split inside unbracketed/bare IPv6 hosts without bracket handling.Changes
parseTargetUrl()inlib/core/common.pyto split non-IPv6netlocvalues at the first colon (netloc.split(:, 1)), matching the existing IPv6maxsplit=1branch so extra colons in the port fail numeric/range validation withSqlmapSyntaxException._setHTTPHandlers()inlib/core/option.pyto use the same bracket-awarehost:portsplit (hostPort.split(:, 1)for non-IPv6 andre.split(r(?<=\]):, hostPort, maxsplit=1)for bracketed IPv6).tests/test_targeturl.pyandtests/test_option.pycovering multi-colon HTTP/HTTPS/WS/WSS target URLs, userinfo + malformed ports, multi-colon HTTP/SOCKS5 proxies (IPv4 and bracketed IPv6), missing IPv6 proxy ports, and valid IPv6 proxies with credentials.Verification
master(4 failures intest_targeturl/test_option).python -B -m unittest tests.test_targeturl tests.test_option tests.test_target_parsing tests.test_urls tests.test_common->Ran 476 tests in 0.901s/OK.python -m pyflakes lib/core/common.py lib/core/option.py tests/test_targeturl.py tests/test_option.py-> clean (exit 0).python -B sqlmap.py --payload-lint->PASSED(51,041 payloads across 31/31 DBMSes checked, 0 malformed).python -B extra/esperanto/run.py --self-test->SELF-TEST PASSED.