forked from p15670423/monkey
Agent: Check for spaces in IP or domain names
socket.gethostbyname() may return different results on different systems when provided with an IP address that contains a space. This depends on python version or other environmental factors. For example: System 1: >>> socket.gethostbyname('172.60 .9.109') Traceback (most recent call last): File "<stdin>", line 1, in <module> socket.gaierror: [Errno -2] Name or service not known >>> socket.gethostbyname('172.17 .9.109') Traceback (most recent call last): File "<stdin>", line 1, in <module> socket.gaierror: [Errno -2] Name or service not known System 2: >>> socket.gethostbyname('172.60 .9.109') '172.0.0.60' To remedy this, this commit adds a check to verify that the IP/domain does not contain a space, as a space is an illegal character in either.
This commit is contained in:
parent
8371a268ba
commit
678db40e25
|
@ -192,6 +192,9 @@ class SingleIpRange(NetworkRange):
|
|||
# The most common use case is to enter ip/range into "Scan IP/subnet list"
|
||||
domain_name = None
|
||||
|
||||
if " " in string_:
|
||||
raise ValueError(f'"{string_}" is not a valid IP address or domain name.')
|
||||
|
||||
# Try casting user's input as IP
|
||||
try:
|
||||
ip = ipaddress.ip_address(string_).exploded
|
||||
|
|
Loading…
Reference in New Issue