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
|
||||
|
||||
|
||||
|
||||
def dottedQuadToNum(ip):
|
||||
"""convert decimal dotted quad string to long integer"""
|
||||
return struct.unpack('I', socket.inet_aton(ip))[0]
|
||||
|
||||
|
||||
|
||||
def networkMask(ip, bits):
|
||||
"""Convert a network address to a long integer"""
|
||||
return dottedQuadToNum(ip) & makeMask(bits)
|
||||
|
||||
|
||||
|
||||
def addressInNetwork(ip, net):
|
||||
"""Is an address in a network"""
|
||||
return ip & net == net
|
||||
|
||||
|
||||
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]
|
||||
[-x proxy_address[:port]] [destination] [port]\n""")
|
||||
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
"""
|
||||
|
@ -84,6 +89,7 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
|||
self.s.connect((host, int(port)))
|
||||
self.recv_data()
|
||||
|
||||
|
||||
def recv_data(self):
|
||||
|
||||
data = ''
|
||||
|
@ -99,17 +105,20 @@ usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
|
|||
self.s.close()
|
||||
self.exit()
|
||||
|
||||
|
||||
def lineReceived(self, line):
|
||||
|
||||
if hasattr(self, 's'):
|
||||
self.s.send(line)
|
||||
|
||||
|
||||
def handle_CTRL_C(self):
|
||||
|
||||
self.write('^C\n')
|
||||
if hasattr(self, 's'):
|
||||
self.s.close()
|
||||
|
||||
|
||||
def handle_CTRL_D(self):
|
||||
|
||||
if hasattr(self, 's'):
|
||||
|
|
Loading…
Reference in New Issue