예제 #1
0
 def test_open_tor(self, capsys):
     commands.Open().run('-h')
     commands.Open().run(
         '-t', '-u',
         'https://github.com/viper-framework/viper-test-files/raw/master/test_files/cmd.exe'
     )
     out, err = capsys.readouterr()
     assert re.search("usage: open \[-h\] .*", out)
     assert re.search(".*Session opened on /tmp/.*", out)
예제 #2
0
 def setup_method(self, method):
     """setUp by adding clean file"""
     # create api_test
     commands.Projects().run('-s', 'api_test')
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Store().run()
예제 #3
0
 def test_analysis(self, capsys):
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Analysis().run('-h')
     commands.Analysis().run('-l')
     commands.Analysis().run('-v', '1')
     out, err = capsys.readouterr()
     assert re.search("usage: analysis \[-h\] .*", out)
     assert re.search(".*Saved On.*", out)
     assert re.search(".*Cmd Line.*", out)
예제 #4
0
 def test_notes_existing(self, capsys):
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     Database().add_note(commands.__sessions__.current.file.sha256,
                         'Note test', 'This is the content')
     commands.Notes().run('-l')
     commands.Notes().run('-v', '1')
     commands.Notes().run('-d', '1')
     out, err = capsys.readouterr()
     assert re.search(".*1  | Note test.*", out)
     assert re.search(".*This is the content.*", out)
예제 #5
0
 def test_tags_use(self, capsys):
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Tags().run('-a', 'mytag')
     commands.Tags().run('-d', 'mytag')
     out, err = capsys.readouterr()
     lines = out.split('\n')
     assert re.search(".*Tags added to the currently opened file.*",
                      lines[1])
     assert re.search(".*Refreshing session to update attributes....*",
                      lines[2])
예제 #6
0
    def test_store_all_py3(self, capsys, filename):
        commands.Open().run('-f', os.path.join(FIXTURE_DIR, filename))
        commands.Store().run()
        commands.Store().run('-f', FIXTURE_DIR)
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened on.*", lines[0])
        assert re.search(r".*appears to be already stored.*", out)
        assert re.search(
            r".*Skip, file \"chromeinstall-8u31.exe\" appears to be already stored.*",
            out)
예제 #7
0
    def test_copy(self, capsys):
        commands.Projects().run('-s', 'copy_test_dst')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Switched to project.*", lines[0])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""

        commands.Projects().run('-s', 'copy_test_src')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Switched to project.*", lines[0])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""

        commands.Open().run(
            '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
        commands.Store().run()
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Session opened on.*", lines[0])
        assert re.search(r".*Stored file.*", lines[1])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)

        commands.Copy().run('-d', 'copy_test_dst')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Copied:.*", lines[0])
        assert re.search(r".*Deleted:.*", lines[1])
        assert re.search(r".*Successfully copied sample.*", lines[2])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""
        assert not re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)

        commands.Projects().run('-s', 'copy_test_dst')
        out, err = capsys.readouterr()
        assert re.search(r".*Switched to project.*", out)

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)
예제 #8
0
    def test_open(self, capsys, filename):
        with open(os.path.join(FIXTURE_DIR, filename), 'rb') as f:
            hashfile = sha256(f.read()).hexdigest()
        commands.Open().run(hashfile)
        commands.Info().run()
        commands.Close().run()
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened on.*", lines[0])
        assert re.search(
            r".*| SHA1     | 56c5b6cd34fa9532b5a873d6bdd4380cfd102218.*",
            lines[11])
예제 #9
0
    def test_find(self, capsys, filename):
        with open(os.path.join(FIXTURE_DIR, filename), 'rb') as f:
            data = f.read()
            hashfile_sha = sha256(data).hexdigest()
        commands.Find().run('all')
        commands.Find().run('sha256', hashfile_sha)
        commands.Open().run('-l', '1')
        commands.Close().run()
        commands.Tags().run('-a', 'blah')
        commands.Find().run('-t')
        commands.Tags().run('-d', 'blah')
        out, err = capsys.readouterr()

        assert re.search(r".*EICAR.com.*", out)
        assert re.search(r".*{0}.*".format(filename), out)
        assert re.search(r".*Tag.*|.*# Entries.*", out)
예제 #10
0
    def test_store_unicode_py3(self, capsys, filename, name):
        # use cleandir fixture operate on clean ./ local dir
        copyfile(os.path.join(FIXTURE_DIR, filename),
                 os.path.join(".", os.path.basename(filename)))
        commands.Open().run('-f', os.path.join(".",
                                               os.path.basename(filename)))
        commands.Store().run()
        if sys.version_info <= (3, 0):
            in_fct = 'viper.core.ui.commands.input'
        else:
            in_fct = 'builtins.input'
        with mock.patch(in_fct, return_value='y'):
            commands.Delete().run()
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened on.*", lines[0])
        assert not re.search(r".*Unable to store file.*", out)
        assert re.search(r".*{}.*".format(name), lines[1])
        assert re.search(r".*Running command.*", lines[5])
        assert re.search(r".*Deleted opened file.*", lines[7])
예제 #11
0
    def test_rename(self, capsys):
        commands.Find().run("all")
        out, err = capsys.readouterr()
        assert out == ""

        commands.Open().run(
            '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
        commands.Store().run()
        _, _ = capsys.readouterr()

        if sys.version_info <= (3, 0):
            in_fct = 'viper.core.ui.commands.input'
        else:
            in_fct = 'builtins.input'
        with mock.patch(in_fct, return_value='chromeinstall-8u31.exe.new'):
            commands.Rename().run()
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Current name is.*1mchromeinstall-8u31.exe.*",
                         lines[0])
        assert re.search(r".*Refreshing session to update attributes.*",
                         lines[1])
예제 #12
0
 def setup_class(cls):
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Store().run()