Ejemplo n.º 1
0
    def test_run_invalid_option(self, capsys):
        instance = pe.PE()
        instance.set_commandline(["invalid"])

        instance.run()
        out, err = capsys.readouterr()
        assert re.search(r".*argument subname: invalid choice.*", out)
Ejemplo n.º 2
0
    def test_run_short_help(self, capsys):
        instance = pe.PE()
        instance.set_commandline(["-h"])

        instance.run()
        out, err = capsys.readouterr()
        assert re.search(r"^usage:.*", out)
Ejemplo n.º 3
0
    def test_security(self, capsys, filename, expected):
        __sessions__.new(os.path.join(FIXTURE_DIR, filename))
        instance = pe.PE()
        instance.command_line = ["security"]

        instance.run()
        out, err = capsys.readouterr()

        assert re.search(r".*{}*".format(expected), out)
Ejemplo n.º 4
0
    def test_resources(self, capsys, filename, expected):
        __sessions__.new(os.path.join(FIXTURE_DIR, filename))
        instance = pe.PE()
        instance.command_line = ["resources"]

        instance.run()
        out, err = capsys.readouterr()

        assert re.search(expected, expected)
Ejemplo n.º 5
0
    def test_language(self, capsys, filename, expected):
        __sessions__.new(os.path.join(FIXTURE_DIR, filename))
        instance = pe.PE()
        instance.command_line = ["language"]

        instance.run()
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(expected, lines[1])
Ejemplo n.º 6
0
    def test_sections(self, capsys, filename, expected):
        __sessions__.new(os.path.join(FIXTURE_DIR, filename))
        instance = pe.PE()
        instance.command_line = ["sections"]

        instance.run()
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened*", lines[0])
        assert re.search(r".*PE Sections.*", lines[1])
        assert len(instance.result_sections) == expected
Ejemplo n.º 7
0
    def test_compiletime(self, capsys, filename, expected):
        __sessions__.new(os.path.join(FIXTURE_DIR, filename))
        instance = pe.PE()
        instance.command_line = ["compiletime"]

        instance.run()
        out, err = capsys.readouterr()
        lines = out.split("\n")
        assert re.search(r".*Session opened*", lines[0])
        assert re.search(r".*Compile Time*", lines[1])
        assert re.search(r".*{}*".format(expected), lines[1])
        assert instance.result_compile_time == expected
Ejemplo n.º 8
0
    def test_args_exception(self):
        instance = pe.PE()

        with pytest.raises(ArgumentErrorCallback) as excinfo:
            instance.parser.parse_args(["-h"])
        excinfo.match(r".*Extract information from PE32 headers.*")
Ejemplo n.º 9
0
 def test_init(self):
     instance = pe.PE()
     assert isinstance(instance, pe.PE)
     assert isinstance(instance, Module)