Exemplo n.º 1
0
    def test_performs_correct_actions_when_only_api_key_and_input_file_are_given(self):
        main(['decompiler.py', '--api-key', 'API-KEY', 'prog.exe'])

        # Decompiler is instantiated with correct arguments.
        self.DecompilerMock.assert_called_once_with(
            api_url=DEFAULT_API_URL,
            api_key='API-KEY'
        )

        # Decompilation is started with correct arguments.
        self.decompiler.start_decompilation.assert_called_once_with(
            input_file='prog.exe',
            mode=None,
            generate_archive=False
        )

        # The tool waits until the decompilation is finished.
        decompilation = self.get_started_decompilation()
        self.assertEqual(
            len(decompilation.wait_until_finished.mock_calls), 1
        )

        # The generated HLL code is saved.
        decompilation.save_hll_code.assert_called_once_with(os.getcwd())

        # The generated DSM code is saved.
        decompilation.save_dsm_code.assert_called_once_with(os.getcwd())
Exemplo n.º 2
0
    def test_does_not_save_output_compiled_binary_when_input_is_binary_file(self):
        main([
            'decompiler.py',
            '--api-key', 'API-KEY',
            'file.exe'
        ])

        decompilation = self.get_started_decompilation()
        self.assertFalse(decompilation.save_binary.called)
Exemplo n.º 3
0
    def test_saves_output_compiled_binary_when_input_is_c_file_uppercase_c(self):
        main([
            'decompiler.py',
            '--api-key', 'API-KEY',
            'file.C'
        ])

        decompilation = self.get_started_decompilation()
        decompilation.save_binary.assert_called_once_with(os.getcwd())
Exemplo n.º 4
0
 def call_main_with_standard_arguments_and(self, *additional_args):
     """Calls ``main()`` with standard arguments (such as ``--api-key``),
     but also includes `additional_args`.
     """
     standard_args = (
         'decompiler.py',
         '--api-key', 'API-KEY',
         'prog.exe'
     )
     main(standard_args + additional_args)
Exemplo n.º 5
0
    def test_saves_output_compiled_binary_when_mode_is_c(self):
        main([
            'decompiler.py',
            '--api-key', 'API-KEY',
            '--mode', 'c',
            'file'
        ])

        decompilation = self.get_started_decompilation()
        decompilation.save_binary.assert_called_once_with(os.getcwd())
Exemplo n.º 6
0
    def test_performs_correct_actions_when_only_api_key_and_input_file_are_given(
            self):
        main(['decompiler.py', '--api-key', 'API-KEY', 'prog.exe'])

        # Decompiler is instantiated with correct arguments.
        self.DecompilerMock.assert_called_once_with(api_url=None,
                                                    api_key='API-KEY')

        # Decompilation is started with correct arguments.
        self.decompiler.start_decompilation.assert_called_once_with(
            input_file='prog.exe')

        # The tool waits until the decompilation is finished.
        decompilation = self.get_started_decompilation()
        self.assertEqual(len(decompilation.wait_until_finished.mock_calls), 1)

        # The generated HLL code is saved.
        decompilation.save_hll_code.assert_called_once_with(os.getcwd())

        # The generated DSM code is saved.
        decompilation.save_dsm_code.assert_called_once_with(os.getcwd())
Exemplo n.º 7
0
    def test_does_not_save_output_compiled_binary_when_input_is_binary_file(
            self):
        main(['decompiler.py', '--api-key', 'API-KEY', 'file.exe'])

        decompilation = self.get_started_decompilation()
        self.assertFalse(decompilation.save_binary.called)
Exemplo n.º 8
0
    def test_saves_output_compiled_binary_when_input_is_c_file_uppercase_c(
            self):
        main(['decompiler.py', '--api-key', 'API-KEY', 'file.C'])

        decompilation = self.get_started_decompilation()
        decompilation.save_binary.assert_called_once_with(os.getcwd())
Exemplo n.º 9
0
    def test_saves_output_compiled_binary_when_mode_is_c(self):
        main(['decompiler.py', '--api-key', 'API-KEY', '--mode', 'c', 'file'])

        decompilation = self.get_started_decompilation()
        decompilation.save_binary.assert_called_once_with(os.getcwd())
Exemplo n.º 10
0
 def call_main_with_standard_arguments_and(self, *additional_args):
     """Calls ``main()`` with standard arguments (such as ``--api-key``),
     but also includes `additional_args`.
     """
     standard_args = ('decompiler.py', '--api-key', 'API-KEY', 'prog.exe')
     return main(standard_args + additional_args)