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):
|
def dottedQuadToNum(ip):
|
||||||
"""
|
"""
|
||||||
convert decimal dotted quad string to long integer
|
convert decimal dotted quad string to long integer
|
||||||
|
this will throw builtins.OSError on failure
|
||||||
"""
|
"""
|
||||||
return struct.unpack('I', socket.inet_aton(ip))[0]
|
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]
|
host = args[0]
|
||||||
port = args[1]
|
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.errorWrite('nc: port number invalid: {}\n'.format(port))
|
||||||
self.exit()
|
self.exit()
|
||||||
return
|
return
|
||||||
|
@ -80,10 +81,15 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
||||||
if re.match(r'^\d+$', host):
|
if re.match(r'^\d+$', host):
|
||||||
address = int(host)
|
address = int(host)
|
||||||
elif re.match(r'^[\d\.]+$', host):
|
elif re.match(r'^[\d\.]+$', host):
|
||||||
address = dottedQuadToNum(host)
|
try:
|
||||||
|
address = dottedQuadToNum(host)
|
||||||
|
except OSError:
|
||||||
|
self.exit()
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
# TODO: should do dns lookup
|
# TODO: should do dns lookup
|
||||||
self.exit()
|
self.exit()
|
||||||
|
return
|
||||||
|
|
||||||
for net in local_networks:
|
for net in local_networks:
|
||||||
if addressInNetwork(address, net):
|
if addressInNetwork(address, net):
|
||||||
|
|
Loading…
Reference in New Issue