We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2acf8a4 + f31b738 commit 390898dCopy full SHA for 390898d
pocsuite/lib/utils/funs.py
@@ -19,15 +19,20 @@
19
from pocsuite.api.request import req
20
21
22
-def url2ip(url):
+def url2ip(url, with_port=False):
23
"""
24
works like turning 'http://baidu.com' => '180.149.132.47'
25
26
27
- urlPrased = urlparse(url)
28
- if urlPrased.port:
29
- return gethostbyname(urlPrased.hostname), urlPrased.port
30
- return gethostbyname(urlPrased.hostname)
+ url_prased = urlparse(url)
+ if url_prased.port:
+ ret = gethostbyname(url_prased.hostname), url_prased.port
+ 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]
36
37
38
def writeText(fileName, content, encoding='utf8'):
0 commit comments