def __init__(self, *args, **kwargs): super(Port_Knocking, self).__init__(*args, **kwargs) ## server location self.server_known = False # declares a server has been defined, and addresses set self.server_ipv4_address = IPAddress( '10.0.0.2' ) # IPv4 address that access is restricted to (the 'server') self.server_ipv6_address = IPAddress( 'fe80::200:ff:fe00:2' ) # IPv6 address that access is restricted to (the 'server') self.server_mac_address = '00:00:00:00:00:02' # MAC address that access is restricted to (the 'server') # record of server location on each switch self.datapaths = {} # dpid -> datapath object self.server_port = {} # dpid -> port number on switch to reach server ## key config self.auth_port = 1332 # TCP port to initiate authentication key self.active_keys = { } # Keys available to auth on; key_id -> key sequence (seq of decimal numbers) self.key_length = 4 # number of packets per key self.seq_size = get_seq_len( self.key_length ) # number of bits used for the sequence number (1-8 are valid) ## host records self.authenticated_hosts = { } # Authorised hosts; host_ip -> timeleft (time of expiry? time to remove access) self.authing_hosts = { } # Hosts currently entering keys; host_ip -> key buffer s.t. key buffer [port0==keyID,port1,port2,port3,..] self.blocked_hosts = { } # Hosts who entered incorrect key; host_ip -> timeout ## may not implement atm self.default_time = 1800 # seconds till invalid (3600 == one hour) # get/register other classes self.switching = SimpleHubSwitch() wsgi = kwargs['wsgi'] wsgi.register(Portknock_Server, {'port_knocking': self}) # testing key self.add_auth_key([{ "value": 1489, "seq": 0, "port": 1489 }, { "value": 15961, "seq": 1, "port": 32345 }, { "value": 8637, "seq": 2, "port": 41405 }, { "value": 2929, "seq": 3, "port": 52081 }]) self.load_keys_from_file('test_keys.txt')
def __init__(self, *args, **kwargs): super(Port_Knocking, self).__init__(*args, **kwargs) # record of server location on each switch self.datapaths = {} # dpid -> datapath object self.server_port = {} # dpid -> port number on switch to reach server ## server location, MAC address that access is restricted to (the 'server') self.server_mac_address = ['00:00:00:00:00:02', '00:00:00:00:00:03'] ## key config self.auth_port = 1332 # TCP port to initiate authentication key self.active_keys = { "10.0.0.2": { "current_key": -1, "current_seq": -1, "keys": { 1000: [1000, 1001, 1002], 1001: [1001, 1002, 1003] }, "authenticated_hosts": {} }, "10.0.0.3": { "current_key": -1, "current_seq": -1, "keys": { 1000: [1000, 1001, 1002], 1001: [1001, 1002, 1003] }, "authenticated_hosts": {} } } self.active_keys_v6 = { str(IPAddress('fe80::200:ff:fe00:2')): { "current_key": -1, "current_seq": -1, "keys": { 1000: [1000, 1001, 1002], 1001: [1001, 1002, 1003] }, "authenticated_hosts": {}, }, str(IPAddress('fe80::200:ff:fe00:3')): { "current_key": -1, "current_seq": -1, "keys": { 1000: [1000, 1001, 1002], 1001: [1001, 1002, 1003] }, "authenticated_hosts": {}, } } ## host records self.authing_hosts = { } # Hosts currently entering keys; host_ip -> key buffer s.t. key buffer [port0==keyID,port1,port2,port3,..] self.blocked_hosts = { } # Hosts who entered incorrect key; host_ip -> timeout ## may not implement atm self.default_time = 1800 # seconds till invalid (3600 == one hour) # get/register other classes self.switching = SimpleHubSwitch() wsgi = kwargs['wsgi'] wsgi.register(Portknock_Server, {'port_knocking': self})