Пример #1
0
 def a_test_run_all(self):
     conf = WhatTheFileConfiguration()
     conf.parse_dict({
         "whatthefile": {
             "modules_package": "src.modules",
             "output": "list",
             "log_output": "stdout",
             "safe_output_path": "./tests/examples/safe_directory"
         },
         "module.commentextractor": {
             "active": True
         },
         "module.entropy": {
             "active": True
         },
         "module.hashes": {
             "active": True,
             'hashes_to_calculate': "MD5,SHA1,SHA256"
         },
         "module.imagerecognitiontensorflow": {
             "active": True
         },
         "module.metadata": {
             "active": True
         },
         "module.ocrtesseract": {
             "active": True
         },
         "module.qrbcreader": {
             "active": True
         },
         "module.strings": {
             "active": True,
             "char_min": 4
         },
         "module.virustotal": {
             "active": True
         },
         "module.zipextractor": {
             "active": True
         },
         "module.tikaparser": {
             "active": True
         },
         "module.certificatereader": {
             "active": True
         },
         "module.browserhisstory": {
             "active": True
         }
     })
     path = "./tests/examples/collie.jpg"
     output = OutputFactory.get_output_by_conf(conf)
     core = Core(conf, output)
     core.run(path)
     self.assertEqual(
         "collie" in output.get_list()[0]["imagerecognitiontensorflow"])
Пример #2
0
 def test_run_hashes(self):
     conf = WhatTheFileConfiguration()
     conf.parse_dict({
         "whatthefile": {
             "modules_package": "src.modules",
             "output": "list",
             "log_output": "stdout",
             "safe_output_path": "./tests/examples/safe_directory"
         },
         "module.commentextractor": {
             "active": True
         },
         "module.entropy": {
             "active": False
         },
         "module.hashes": {
             "active": True,
             'hashes_to_calculate': "MD5,SHA1,SHA256"
         },
         "module.imagerecognitiontensorflow": {
             "active": False
         },
         "module.metadata": {
             "active": False
         },
         "module.ocrtesseract": {
             "active": False
         },
         "module.qrbcreader": {
             "active": False
         },
         "module.strings": {
             "active": False,
             "char_min": 10
         },
         "module.virustotal": {
             "active": False
         },
         "module.zipextractor": {
             "active": False
         }
     })
     path = "./tests/examples/collie.jpg.zip"
     output = OutputFactory.get_output_by_conf(conf)
     core = Core(conf, output)
     core.run(path)
     self.assertTrue("SHA256" in output.get_list()[0]["hashes"])
     self.assertTrue("start_module" in output.get_list()[0]["hashes"])
     self.assertTrue("end_module" in output.get_list()[0]["hashes"])
     self.assertTrue("begin_analysis" in output.get_list()[0])
     self.assertTrue("end_analysis" in output.get_list()[0])
Пример #3
0
    def test_run_directory(self):
        conf = WhatTheFileConfiguration()
        conf.parse_dict({
            "whatthefile": {
                "modules_package": "src.modules",
                "output": "list",
                "log_output": "stdout",
                "safe_output_path": "./tests/examples/safe_directory"
            },
            "module.commentextractor": {
                "active": True
            },
            "module.entropy": {
                "active": True
            },
            "module.hashes": {
                "active": True,
                'hashes_to_calculate': "MD5,SHA1,SHA256"
            },
            "module.imagerecognitiontensorflow": {
                "active": True
            },
            "module.metadata": {
                "active": True
            },
            "module.ocrtesseract": {
                "active": True
            },
            "module.qrbcreader": {
                "active": True
            },
            "module.strings": {
                "active": True,
                "char_min": 4
            },
            "module.virustotal": {
                "active": False
            },
            "module.zipextractor": {
                "active": True
            }
        })

        path = "./tests/examples/testdirectorydonotinsertmoreitems"
        output = OutputFactory.get_output_by_conf(conf)
        core = Core(conf, output)
        core.run(path)
        self.assertEqual(len(output.get_list()), 3)
Пример #4
0
 def test_ignore(self):
     conf = WhatTheFileConfiguration()
     conf.parse_dict({
         "whatthefile": {
             "modules_package": "src.modules",
             "output": "list",
             "log_output": "stdout",
             "safe_output_path": "./tests/examples/safe_directory"
         },
         "module.hashes": {
             "active": True,
             'hashes_to_calculate': "MD5,SHA1,SHA256"
         },
         "module.ignore": {
             "active":
             True,
             'file_hashes_md5_to_ignore':
             './tests/examples/ignoredhashesmd5.txt'
         },
         "module.imagerecognitiontensorflow": {
             "active": False
         },
         "module.metadata": {
             "active": False
         },
         "module.ocrtesseract": {
             "active": False
         },
         "module.qrbcreader": {
             "active": False
         },
         "module.strings": {
             "active": True,
             "char_min": 10
         },
         "module.virustotal": {
             "active": False
         },
         "module.zipextractor": {
             "active": False
         }
     })
     path = "./tests/examples/collie.jpg"
     output = OutputFactory.get_output_by_conf(conf)
     core = Core(conf, output)
     core.run(path)
     self.assertEqual(len(output.get_list()), 0)
Пример #5
0
 def test_load_modules(self):
     config = WhatTheFileConfiguration()
     config.parse_dict(self.get_config_dict())
     modules = LoaderModules(config).get_modules()
     self.assertEqual(len(modules), len(config.get_modules_names()))
Пример #6
0
 def test_load_simple_modules(self):
     config = WhatTheFileConfiguration()
     config.parse_dict(self.get_simple_config_dict())
     modules = LoaderModules(config).get_modules()
     self.assertEqual(len(modules), 1)
     self.assertEqual(modules[0].get_name(), "entropy")
 def test_load_conf_dict(self):
     conf = WhatTheFileConfiguration()
     conf.parse_dict(self.get_conf_dict())
     self.assertEqual(len(conf.get_modules_names()), 10)
     self.assertTrue(conf.get_property_boolean("module.hashes", "active"))
     self.assertTrue("active" in conf.get_section("module.hashes"))