mirror of https://github.com/cowrie/cowrie.git
Merge branch 'master' of https://github.com/cowrie/cowrie
This commit is contained in:
commit
0ca426ac06
|
@ -25,6 +25,7 @@ def makeMask(n):
|
|||
def dottedQuadToNum(ip):
|
||||
"""
|
||||
convert decimal dotted quad string to long integer
|
||||
this will throw builtins.OSError on failure
|
||||
"""
|
||||
return struct.unpack('I', socket.inet_aton(ip))[0]
|
||||
|
||||
|
@ -72,7 +73,7 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
|||
host = args[0]
|
||||
port = args[1]
|
||||
|
||||
if not re.match(r'\d+', port):
|
||||
if not re.match(r'^\d+$', port):
|
||||
self.errorWrite('nc: port number invalid: {}\n'.format(port))
|
||||
self.exit()
|
||||
return
|
||||
|
@ -80,10 +81,15 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
|||
if re.match(r'^\d+$', host):
|
||||
address = int(host)
|
||||
elif re.match(r'^[\d\.]+$', host):
|
||||
try:
|
||||
address = dottedQuadToNum(host)
|
||||
except OSError:
|
||||
self.exit()
|
||||
return
|
||||
else:
|
||||
# TODO: should do dns lookup
|
||||
self.exit()
|
||||
return
|
||||
|
||||
for net in local_networks:
|
||||
if addressInNetwork(address, net):
|
||||
|
|
Loading…
Reference in New Issue