def test_digestible_json(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel) json_finds = convert_to_digestible(local_finds, digest="json") unjson_finds = json.loads(json_finds) self.assertEqual(len(unjson_finds[EXPLOIT_AVAILABLE]), len(local_finds[EXPLOIT_AVAILABLE]))
def test_vulnerable_kernel_matching(self): # TODO: this kernel is not vulnerable to any of the exploits in the project, but is listed as vulnerable # TODO: we need to unfortunately track down the kernel windows for each specific exploit for each # TODO: specific distro for each specific kernel (i.e. 4.4.0-0 -> 4.4.x-last_patch) test_uname = 'Linux-4.4.0-75-generic-x86_64-with-Ubuntu-16.04-xenial' test_kernel = Kernel(test_uname) exploit_results = find_exploit_locally(test_kernel) print("") self.assertTrue(total_exploits(exploit_results["confirmed"]) < 1)
def test_dump_to_file(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel) json_finds = convert_to_digestible(local_finds, digest="json") test_outfile = os.path.join(ROOT_DIR, "output.json") if os.path.exists(test_outfile): os.remove(test_outfile) write_digestible_to_file(test_outfile, json_finds) self.assertTrue(os.path.exists(test_outfile)) # remove it so it's not in the project if os.path.exists(test_outfile): os.remove(test_outfile)
def test_find_exploit_locally(self): test_uname = "Linux-4.10.0-1-generic-x86_64-with-Ubuntu-16.04-xenial" test_kernel = Kernel(test_uname) exploit_results = find_exploit_locally(test_kernel) self.assertGreaterEqual( len(exploit_results["confirmed"][HIGH_RELIABILITY]), 1)
def test_digestible_xml(self): test_uname = "Linux-3.10.0-1-generic-x86_64-with-Ubuntu-14.04-xenial" test_kernel = get_kernel_version(uname=test_uname) local_finds = find_exploit_locally(test_kernel)
def test_patched_kernel_matching(self): test_uname = "Linux-4.99.0-1-generic-i686-with-Ubuntu-16.04-xenial" test_kernel = Kernel(test_uname) exploit_results = find_exploit_locally(test_kernel) self.assertTrue(total_exploits(exploit_results["confirmed"]) < 1)