コード例 #1
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testDelNoteFromService(self):
        """ Creates a Hosts, adds an Interface, a Service and a Note, then removes the
        note """

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        note = ModelObjectNote(name='NoteTest', text='TestDescription')

        self.model_controller.addNoteToServiceSYNC(host.getID(),
                                                   service.getID(), note)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        self.assertIn(note, notes, 'Note not added')

        # Then

        self.model_controller.delNoteFromServiceSYNC(host.getID(),
                                                     service.getID(),
                                                     note.getID())

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        self.assertNotIn(note, notes, 'Note not removed')
コード例 #2
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testDeleteService(self):
        """ Creates a Host an Interface and a Service, then deletes the Service
        to test it's removal from the controllers list """

        host1 = test_utils.create_host(self, "coquito")
        interface1 = test_utils.create_interface(self, host1, iname="pepito")
        service1 = test_utils.create_service(self, host1, interface1)

        hosts_ids = [h.getID() for h in self.model_controller.getAllHosts()]
        self.assertIn(host1.getID(), hosts_ids, "Host not in controller")

        host1 = self.model_controller.getHost(host1.getID())
        interfaces_ids = [i.getID() for i in host1.getAllInterfaces()]
        self.assertIn(interface1.getID(), interfaces_ids,
                      "Interface not in host!")

        services_ids = [s.getID() for s in \
                            self.model_controller.getHost(host1.getID())
                            .getInterface(interface1.getID()).getAllServices()]

        self.assertIn(service1.getID(), services_ids,
                      "Service not in Interface!")

        self.model_controller.delServiceFromInterfaceSYNC(
            host1.getID(), interface1.getID(), service1.getID())

        services_ids = [s.getID() for s in \
                            self.model_controller.getHost(host1.getID())
                            .getInterface(interface1.getID()).getAllServices()]

        self.assertNotIn(service1.getID(), services_ids, \
                        "Service not deleted")
コード例 #3
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testDelVulnFromService(self):
        """ This test case creates a host within the Model Controller context
        adds an interface to it then adds service then a Vuln, then removes the
        Vuln"""

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        vuln = ModelObjectVuln(name='VulnTest',
                               desc='TestDescription',
                               severity='high')

        self.model_controller.addVulnToServiceSYNC(host.getID(),
                                                   service.getID(), vuln)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        vulns = added_service.getVulns()
        self.assertIn(vuln, vulns, 'Vuln not added')

        # Then

        self.model_controller.delVulnFromServiceSYNC(host.getID(),
                                                     service.getID(),
                                                     vuln.getID())

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        vulns = added_service.getVulns()
        self.assertNotIn(vuln, vulns, 'Vuln not removed')
コード例 #4
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testDelNoteFromService(self):
        """ Creates a Hosts, adds an Interface, a Service and a Note, then removes the
        note """

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        note = ModelObjectNote(name='NoteTest', text='TestDescription')

        self.model_controller.addNoteToServiceSYNC(host.getID(),
                                service.getID(), note)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        self.assertIn(note, notes, 'Note not added')

        # Then

        self.model_controller.delNoteFromServiceSYNC(host.getID(),
                            service.getID(), note.getID())

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        self.assertNotIn(note, notes, 'Note not removed')
コード例 #5
0
    def test_model_edit_serv_vuln(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        serv = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, serv, 'vuln', 'desc',
                                           'high')

        data = {
            "vulnid": vuln.getID(),
            "hostid": host.getID(),
            'name': 'coco',
            'desc': 'newdesc',
            'severity': 'low'
        }

        response = requests.post(self.url_model_edit_vulns,
                                 data=json.dumps(data),
                                 headers=self.headers)

        self.assertEquals(response.status_code, 200,
                          "Status Code should be 200: OK")

        addedhost = self.model_controller.getHost(host.getID())
        addedInterface = addedhost.getInterface(inter.getID())
        addedService = addedInterface.getService(serv.getID())
        addedvuln = addedService.getVuln(vuln.getID())

        self.assertEquals(addedvuln.name, 'coco', 'Name not updated')
        self.assertEquals(addedvuln.desc, 'newdesc', 'Desc not updated')
        self.assertEquals(addedvuln.severity, 'low', 'Severity not updated')
コード例 #6
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testDelVulnFromService(self):
        """ This test case creates a host within the Model Controller context
        adds an interface to it then adds service then a Vuln, then removes the
        Vuln"""

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        vuln = ModelObjectVuln(name='VulnTest', desc='TestDescription',
                                severity='high')

        self.model_controller.addVulnToServiceSYNC(host.getID(),
                                service.getID(), vuln)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        vulns = added_service.getVulns()
        self.assertIn(vuln, vulns, 'Vuln not added')

        # Then

        self.model_controller.delVulnFromServiceSYNC(host.getID(),
                            service.getID(), vuln.getID())

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        vulns = added_service.getVulns()
        self.assertNotIn(vuln, vulns, 'Vuln not removed')
コード例 #7
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testDeleteService(self):
        """ Creates a Host an Interface and a Service, then deletes the Service
        to test it's removal from the controllers list """

        host1 = test_utils.create_host(self, "coquito")
        interface1 = test_utils.create_interface(self, host1, iname="pepito")
        service1 = test_utils.create_service(self, host1, interface1)

        hosts_ids = [h.getID() for h in self.model_controller.getAllHosts()]
        self.assertIn(host1.getID(), hosts_ids,
                                "Host not in controller")

        host1 = self.model_controller.getHost(host1.getID())
        interfaces_ids = [i.getID() for i in host1.getAllInterfaces()]
        self.assertIn(interface1.getID(), interfaces_ids,
                                "Interface not in host!")

        services_ids = [s.getID() for s in \
                            self.model_controller.getHost(host1.getID())
                            .getInterface(interface1.getID()).getAllServices()]

        self.assertIn(service1.getID(), services_ids,
                                "Service not in Interface!")

        self.model_controller.delServiceFromInterfaceSYNC(host1.getID(),
                                    interface1.getID(), service1.getID())

        services_ids = [s.getID() for s in \
                            self.model_controller.getHost(host1.getID())
                            .getInterface(interface1.getID()).getAllServices()]

        self.assertNotIn(service1.getID(), services_ids, \
                        "Service not deleted")
コード例 #8
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testVulnServiceLookup(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, service, 'vuln', 'desc', 'high')
        visitor = VulnsLookupVisitor(vuln.getID())
        host.accept(visitor) 

        self.assertEquals(len(visitor.parents[0]), 3,
                "object hierarchy should be host, interface and service")
        self.assertIn(vuln, visitor.vulns)
コード例 #9
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testVulnServiceLookup(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, service, 'vuln', 'desc',
                                           'high')
        visitor = VulnsLookupVisitor(vuln.getID())
        host.accept(visitor)

        self.assertEquals(
            len(visitor.parents[0]), 3,
            "object hierarchy should be host, interface and service")
        self.assertIn(vuln, visitor.vulns)
コード例 #10
0
    def test_model_remove_serv_vuln(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        serv = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, serv, 'vuln', 'desc', 'high')

        data = {"vulnid": vuln.getID(), "hostid": host.getID()}

        response = requests.delete(self.url_model_del_vulns,
                                 data=json.dumps(data),
                                 headers=self.headers)

        self.assertEquals(response.status_code, 200, "Status Code should be 200: OK")

        addedhost = self.model_controller.getHost(host.getID())
        addedInterface = addedhost.getInterface(inter.getID())
        addedService = addedInterface.getService(serv.getID())

        self.assertEquals(len(addedService.getVulns()), 0, 'Service vulns not removed')
コード例 #11
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testAddNoteToService(self):
        """ This test case creates a host within the Model Controller context
        adds an interface to it then adds service then a Note"""

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        note = ModelObjectNote(name='NoteTest', text='TestDescription')

        self.model_controller.addNoteToServiceSYNC(host.getID(),
                                                   service.getID(), note)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        # Then
        self.assertIn(note, notes, 'Note not added')
コード例 #12
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testAddNoteToService(self):
        """ This test case creates a host within the Model Controller context
        adds an interface to it then adds service then a Note"""

        # When
        host = test_utils.create_host(self)
        interface = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, interface)

        note = ModelObjectNote(name='NoteTest', text='TestDescription')

        self.model_controller.addNoteToServiceSYNC(host.getID(),
                                service.getID(), note)

        added_host = self.model_controller.getHost(host.getName())
        added_interface = added_host.getInterface(interface.getID())
        added_service = added_interface.getService(service.getID())
        notes = added_service.getNotes()
        # Then
        self.assertIn(note, notes, 'Note not added')
コード例 #13
0
ファイル: model_object.py プロジェクト: raum01/faraday
    def testMultipleVulnLookup(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, service, 'vuln', 'desc',
                                           'high')
        vuln2 = test_utils.create_int_vuln(self, host, inter, 'vuln', 'desc',
                                           'high')
        visitor = VulnsLookupVisitor(vuln.getID())
        host.accept(visitor)

        parents1 = visitor.parents[0]
        parents2 = visitor.parents[1]

        self.assertIn(host, parents1, "Host should be in parents")

        self.assertIn(host, parents2, "Host should be in parents")

        self.assertIn(inter, parents2, "Interface should be in parents")

        self.assertIn(inter, parents2, "Interface should be in parents")
コード例 #14
0
    def test_model_remove_serv_vuln(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        serv = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, serv, 'vuln', 'desc',
                                           'high')

        data = {"vulnid": vuln.getID(), "hostid": host.getID()}

        response = requests.delete(self.url_model_del_vulns,
                                   data=json.dumps(data),
                                   headers=self.headers)

        self.assertEquals(response.status_code, 200,
                          "Status Code should be 200: OK")

        addedhost = self.model_controller.getHost(host.getID())
        addedInterface = addedhost.getInterface(inter.getID())
        addedService = addedInterface.getService(serv.getID())

        self.assertEquals(len(addedService.getVulns()), 0,
                          'Service vulns not removed')
コード例 #15
0
    def test_model_edit_serv_vuln(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        serv = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, serv, 'vuln', 'desc', 'high')

        data = {"vulnid": vuln.getID(), "hostid": host.getID(), 'name': 'coco',
                'desc': 'newdesc', 'severity': 'low'}

        response = requests.post(self.url_model_edit_vulns,
                                 data=json.dumps(data),
                                 headers=self.headers)

        self.assertEquals(response.status_code, 200, "Status Code should be 200: OK")

        addedhost = self.model_controller.getHost(host.getID())
        addedInterface = addedhost.getInterface(inter.getID())
        addedService = addedInterface.getService(serv.getID())
        addedvuln = addedService.getVuln(vuln.getID())

        self.assertEquals(addedvuln.name, 'coco', 'Name not updated')
        self.assertEquals(addedvuln.desc, 'newdesc', 'Desc not updated')
        self.assertEquals(addedvuln.severity, 'low', 'Severity not updated')
コード例 #16
0
ファイル: model_object.py プロジェクト: 0x24bin/BurpSuite
    def testMultipleVulnLookup(self):
        host = test_utils.create_host(self)
        inter = test_utils.create_interface(self, host)
        service = test_utils.create_service(self, host, inter)
        vuln = test_utils.create_serv_vuln(self, host, service, 'vuln', 'desc', 'high')
        vuln2 = test_utils.create_int_vuln(self, host, inter, 'vuln', 'desc', 'high')
        visitor = VulnsLookupVisitor(vuln.getID())
        host.accept(visitor) 

        parents1 = visitor.parents[0]
        parents2 = visitor.parents[1]

        self.assertIn(host, parents1,
                "Host should be in parents")

        self.assertIn(host, parents2,
                "Host should be in parents")

        self.assertIn(inter, parents2,
                "Interface should be in parents")

        self.assertIn(inter, parents2,
                "Interface should be in parents")