mirror of https://github.com/cowrie/cowrie.git
whitespacing
This commit is contained in:
parent
42a0b2c9cd
commit
dd5b75864c
|
@ -13,20 +13,24 @@ def makeMask(n):
|
||||||
return (2L << n - 1) - 1
|
return (2L << n - 1) - 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def dottedQuadToNum(ip):
|
def dottedQuadToNum(ip):
|
||||||
"""convert decimal dotted quad string to long integer"""
|
"""convert decimal dotted quad string to long integer"""
|
||||||
return struct.unpack('I', socket.inet_aton(ip))[0]
|
return struct.unpack('I', socket.inet_aton(ip))[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def networkMask(ip, bits):
|
def networkMask(ip, bits):
|
||||||
"""Convert a network address to a long integer"""
|
"""Convert a network address to a long integer"""
|
||||||
return dottedQuadToNum(ip) & makeMask(bits)
|
return dottedQuadToNum(ip) & makeMask(bits)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addressInNetwork(ip, net):
|
def addressInNetwork(ip, net):
|
||||||
"""Is an address in a network"""
|
"""Is an address in a network"""
|
||||||
return ip & net == net
|
return ip & net == net
|
||||||
|
|
||||||
|
|
||||||
local_networks = [networkMask('10.0.0.0', 8), networkMask('172.16.0.0', 12), networkMask('192.168.0.0', 16)]
|
local_networks = [networkMask('10.0.0.0', 8), networkMask('172.16.0.0', 12), networkMask('192.168.0.0', 16)]
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +46,7 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
||||||
[-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
|
[-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
|
||||||
[-x proxy_address[:port]] [destination] [port]\n""")
|
[-x proxy_address[:port]] [destination] [port]\n""")
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@ -84,6 +89,7 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
||||||
self.s.connect((host, int(port)))
|
self.s.connect((host, int(port)))
|
||||||
self.recv_data()
|
self.recv_data()
|
||||||
|
|
||||||
|
|
||||||
def recv_data(self):
|
def recv_data(self):
|
||||||
|
|
||||||
data = ''
|
data = ''
|
||||||
|
@ -99,17 +105,20 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
||||||
self.s.close()
|
self.s.close()
|
||||||
self.exit()
|
self.exit()
|
||||||
|
|
||||||
|
|
||||||
def lineReceived(self, line):
|
def lineReceived(self, line):
|
||||||
|
|
||||||
if hasattr(self, 's'):
|
if hasattr(self, 's'):
|
||||||
self.s.send(line)
|
self.s.send(line)
|
||||||
|
|
||||||
|
|
||||||
def handle_CTRL_C(self):
|
def handle_CTRL_C(self):
|
||||||
|
|
||||||
self.write('^C\n')
|
self.write('^C\n')
|
||||||
if hasattr(self, 's'):
|
if hasattr(self, 's'):
|
||||||
self.s.close()
|
self.s.close()
|
||||||
|
|
||||||
|
|
||||||
def handle_CTRL_D(self):
|
def handle_CTRL_D(self):
|
||||||
|
|
||||||
if hasattr(self, 's'):
|
if hasattr(self, 's'):
|
||||||
|
|
Loading…
Reference in New Issue