Skip to content

Commit 390898d

Browse files
author
Hysia
authored
Merge pull request #148 from knownsec/bugfix/issue_147
bugfix for #147
2 parents 2acf8a4 + f31b738 commit 390898d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: pocsuite/lib/utils/funs.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@
1919
from pocsuite.api.request import req
2020

2121

22-
def url2ip(url):
22+
def url2ip(url, with_port=False):
2323
"""
2424
works like turning 'http://baidu.com' => '180.149.132.47'
2525
"""
2626

27-
urlPrased = urlparse(url)
28-
if urlPrased.port:
29-
return gethostbyname(urlPrased.hostname), urlPrased.port
30-
return gethostbyname(urlPrased.hostname)
27+
url_prased = urlparse(url)
28+
if url_prased.port:
29+
ret = gethostbyname(url_prased.hostname), url_prased.port
30+
elif not url_prased.port and url_prased.scheme == 'https':
31+
ret = gethostbyname(url_prased.hostname), 443
32+
else:
33+
ret = gethostbyname(url_prased.hostname), 80
34+
35+
return ret if with_port else ret[0]
3136

3237

3338
def writeText(fileName, content, encoding='utf8'):

0 commit comments

Comments
 (0)