Returns proper Host header value for a given target URL >>> getHostHeader('http://www.target.com/vuln.php?id=1') 'www.target.com'
(url)
| 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 | |
| 4813 | def 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 | |
| 4836 | def checkOldOptions(args): |
| 4837 | """ |
no test coverage detected
searching dependent graphs…