Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
support for URLs containing credentials
  • Loading branch information
the-rend committed Mar 15, 2022
commit 29e08d80cc31c93d28188e0bdb4796eceb2428e4
6 changes: 3 additions & 3 deletions lib/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,13 +1721,13 @@ def parseTargetUrl():

try:
urlSplit = _urllib.parse.urlsplit(conf.url)
hostnamePort = [urlSplit.hostname, urlSplit.port]
except ValueError as ex:
errMsg = "invalid URL '%s' has been given ('%s'). " % (conf.url, getSafeExString(ex))
errMsg += "Please be sure that you don't have any leftover characters (e.g. '[' or ']') "
errMsg += "in the hostname part"
raise SqlmapGenericException(errMsg)

hostnamePort = urlSplit.netloc.split(":") if not re.search(r"\[.+\]", urlSplit.netloc) else filterNone((re.search(r"\[.+\]", urlSplit.netloc).group(0), re.search(r"\](:(?P<port>\d+))?", urlSplit.netloc).group("port")))

conf.scheme = (urlSplit.scheme.strip().lower() or "http")
conf.path = urlSplit.path.strip()
Expand All @@ -1736,8 +1736,8 @@ def parseTargetUrl():
if conf.forceSSL:
conf.scheme = re.sub(r"(?i)\A(http|ws)\Z", r"\g<1>s", conf.scheme)

conf.ipv6 = conf.hostname != conf.hostname.strip("[]")
conf.hostname = conf.hostname.strip("[]").replace(kb.customInjectionMark, "")
conf.ipv6 = ":" in conf.hostname
conf.hostname = conf.hostname.replace(kb.customInjectionMark, "")

try:
conf.hostname.encode("idna")
Expand Down
2 changes: 1 addition & 1 deletion lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ def _setHostname():

if conf.url:
try:
conf.hostname = _urllib.parse.urlsplit(conf.url).netloc.split(':')[0]
conf.hostname = _urllib.parse.urlsplit(conf.url).hostname
except ValueError as ex:
errMsg = "problem occurred while "
errMsg += "parsing an URL '%s' ('%s')" % (conf.url, getSafeExString(ex))
Expand Down