File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 19
19
from pocsuite .api .request import req
20
20
21
21
22
- def url2ip (url ):
22
+ def url2ip (url , with_port = False ):
23
23
"""
24
24
works like turning 'http://baidu.com' => '180.149.132.47'
25
25
"""
26
26
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 ]
31
36
32
37
33
38
def writeText (fileName , content , encoding = 'utf8' ):
You can’t perform that action at this time.
0 commit comments