def _get_special_ports(self): return_value = [] if cfg['service.scans.physical']: interfaces = netifaces.interfaces() for interface in interfaces: addr = netifaces.ifaddresses(interface) if netifaces.AF_INET not in addr: continue port = PhysicalPort() port.interface = interface port.scan = Scan(start=time.time()) return_value.append(port) return return_value
async def call(self, *args, **kwargs): if not self.port: self.port = PhysicalPort(node=self._node) self.context.add_task(CiscoApisPsirtTask( context=self.context, port=self.port, exploits=[self.aucote.exploits.find('ciscoapis', 'psirt')]), manager=TaskManagerType.QUICK)
async def call(self, *args, **kwargs): if not self.port: self.port = PhysicalPort(node=self._node) self.context.add_task(CVESearchServiceTask( context=self.context, port=self.port, exploits=[self.aucote.exploits.find('cve-search', 'cve-search')]), manager=TaskManagerType.QUICK)
class SpecialPortTest(TestCase): def setUp(self): self.physical = PhysicalPort() self.broadcast = BroadcastPort() def test_copy_physical(self): self.assertIsInstance(self.physical.copy(), PhysicalPort) def test_copy_broadcast(self): self.assertIsInstance(self.broadcast.copy(), BroadcastPort)
def test_prepare_args_physical(self, cfg, cfg_cct): cfg_cct._cfg = cfg._cfg = {'tools': {'nmap': {'scripts_dir': ''}}} self.scan_task._port = PhysicalPort() self.scan_task._port.interface = 'wlan0' result = set(self.scan_task.prepare_args()) expected = { '--max-rate', '1337', '--script', '--script-args', 'test_args', '-e', 'wlan0' } self.assertTrue(expected.issubset(result)) self.assertTrue('+test,+test2' in result or '+test2,+test' in result)
def test_prepare_args_scripts_args(self, cfg, cfg_cct): cfg_cct._cfg = cfg._cfg = { 'tools': { 'nmap': { 'scripts_dir': './test_dir/' } } } self.script2.args = 'other_args' self.scan_task._port = PhysicalPort() self.scan_task._port.interface = 'wlan0' result = set(self.scan_task.prepare_args()) self.assertTrue('test_args,other_args' in result or 'other_args,test_args' in result)
def test_get_node_cpe(self): self.task._port = PhysicalPort(node=self.node) cpe = self.task.get_cpes() self.assertEqual(cpe, [self.node.os.cpe])
def setUp(self): self.port = PhysicalPort() self.port.interface = 'wlan0'
def setUp(self): self.physical = PhysicalPort() self.broadcast = BroadcastPort()
def test_is_physical(self): port = PhysicalPort() self.assertFalse(isinstance(port, BroadcastPort)) self.assertTrue(isinstance(port, PhysicalPort))