def _generate_correlated_hosts(self, alpha_H, alpha_V, lambda_V): hosts = dict() prev_configs = [] prev_os = [] prev_srvs = [] prev_procs = [] host_num = 0 for subnet, size in enumerate(self.subnets): if subnet == u.INTERNET: continue for m in range(size): os, services, processes = self._get_host_config( host_num, alpha_H, prev_configs, alpha_V, lambda_V, prev_os, prev_srvs, prev_procs) os_cfg = self._convert_to_os_map(os) service_cfg = self._convert_to_service_map(services) process_cfg = self._convert_to_process_map(processes) host_num += 1 address = (subnet, m) value = self._get_host_value(address) host = Host(address=address, os=os_cfg.copy(), services=service_cfg.copy(), processes=process_cfg.copy(), firewall={}, value=value, discovery_value=self.host_discovery_value) hosts[address] = host self.hosts = hosts
def _generate_uniform_hosts(self): hosts = dict() srv_config_set, proc_config_set = self._possible_host_configs() num_srv_configs = len(srv_config_set) num_proc_configs = len(proc_config_set) for subnet, size in enumerate(self.subnets): if subnet == u.INTERNET: continue for h in range(size): srv_cfg = srv_config_set[np.random.choice(num_srv_configs)] srv_cfg = self._convert_to_service_map(srv_cfg) proc_cfg = proc_config_set[np.random.choice(num_proc_configs)] proc_cfg = self._convert_to_process_map(proc_cfg) os = np.random.choice(self.os) os_cfg = self._convert_to_os_map(os) address = (subnet, h) value = self._get_host_value(address) host = Host(address=address, os=os_cfg.copy(), services=srv_cfg.copy(), processes=proc_cfg.copy(), firewall={}, value=value, discovery_value=self.host_discovery_value) hosts[address] = host self.hosts = hosts
def _parse_hosts(self): """Returns ordered dictionary of hosts in network, with address as keys and host objects as values """ hosts = dict() for address, h_cfg in self.host_configs.items(): formatted_address = eval(address) services_cfg, os_cfg = self._construct_host_config(h_cfg) value = self._get_host_value(formatted_address) hosts[formatted_address] = Host(formatted_address, os_cfg, services_cfg, value) self.hosts = hosts
def _parse_hosts(self): """Returns ordered dictionary of hosts in network, with address as keys and host objects as values """ hosts = dict() for address, h_cfg in self.host_configs.items(): formatted_address = eval(address) os_cfg, srv_cfg, proc_cfg = self._construct_host_config(h_cfg) value = self._get_host_value(formatted_address, h_cfg) hosts[formatted_address] = Host(address=formatted_address, os=os_cfg, services=srv_cfg, processes=proc_cfg, firewall=h_cfg[u.HOST_FIREWALL], value=value) self.hosts = hosts
def _generate_uniform_hosts(self): hosts = dict() host_config_set = self._possible_host_configs() num_configs = len(host_config_set) for subnet, size in enumerate(self.subnets): if subnet == u.INTERNET: continue for h in range(size): service_cfg = host_config_set[np.random.choice(num_configs)] service_cfg = self._convert_to_service_map(service_cfg) os = np.random.choice(self.os) os_cfg = self._convert_to_os_map(os) address = (subnet, h) value = self._get_host_value(address) host = Host(address, os_cfg.copy(), service_cfg.copy(), value, self.host_discovery_value) hosts[address] = host self.hosts = hosts