MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / getHostHeader

Function getHostHeader

lib/core/common.py:4813–4834  ·  view source on GitHub ↗

Returns proper Host header value for a given target URL >>> getHostHeader('http://www.target.com/vuln.php?id=1') 'www.target.com'

(url)

Source from the content-addressed store, hash-verified

4811 return all(re.sub(r"(?i)\Awww\.", "", _urllib.parse.urlparse(_(url) or "").netloc.split(':')[0]) == re.sub(r"(?i)\Awww\.", "", _urllib.parse.urlparse(_(urls[0]) or "").netloc.split(':')[0]) for url in urls[1:])
4812
4813def getHostHeader(url):
4814 """
4815 Returns proper Host header value for a given target URL
4816
4817 >>> getHostHeader('http://www.target.com/vuln.php?id=1')
4818 'www.target.com'
4819 """
4820
4821 retVal = url
4822
4823 if url:
4824 retVal = _urllib.parse.urlparse(url).netloc
4825
4826 if re.search(r"http(s)?://\[.+\]", url, re.I):
4827 retVal = extractRegexResult(r"http(s)?://\[(?P<result>.+)\]", url)
4828 elif any(retVal.endswith(':%d' % _) for _ in (80, 443)):
4829 retVal = retVal.split(':')[0]
4830
4831 if retVal and retVal.count(':') > 1 and not any(_ in retVal for _ in ('[', ']')):
4832 retVal = "[%s]" % retVal
4833
4834 return retVal
4835
4836def checkOldOptions(args):
4837 """

Callers 3

http_error_302Method · 0.90
getPageMethod · 0.90
parseTargetUrlFunction · 0.85

Calls 2

extractRegexResultFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…