Skip to content

SemaSCDG crashes when enabling hooks on windows executables #44

@Thib-fkr

Description

@Thib-fkr

Pre-requisites (starting with the default config file)

Issue

When analysing a windows executable that contains any recognized hard-coded byte sequence from PluginHooks.internal_function_hooks:

File ".../sema_scdg/application/SemaSCDG.py", line 563, in run
    self.setup_hooks(proj, state, os_obj)
  File ".../sema_scdg/application/SemaSCDG.py", line 475, in setup_hooks
    self.plugins.enable_plugin_hooks(self.content, state, proj, self.call_sim)
  File ".../sema_scdg/application/plugin/PluginManager.py", line 54, in enable_plugin_hooks
    self.hooks.hook(state,proj,call_sim)
  File ".../sema_scdg/application/plugin/PluginHooks.py", line 248, in hook
    call_sim.custom_simproc_windows["custom_hook"]["MagicRATForceHook"](plength=len(self.internal_functions_hooks[fun])),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WindowsSimProcedure' object has no attribute 'custom_simproc_windows'

custom_simproc_windows does not seem to appear in any other place than when it is used in PluginHooks.hook().

Additional information

Adding something similar to the following snippet in procedures/WindowsSimProcedure.__init__() seems to prevent the crash from happening.

self.custom_simproc_windows = {}
self.custom_simproc_windows["custom_hook"] = {}
from .windows.custom_hook.HookName import HookClass # Replace HookName by the name of the relevant file in procedures/windows/custom_hook/ and HookClass by the name of the SimProc
self.custom_simproc_windows["custom_hook"]["HookName"] = HookClass # Same here with HookName and HookClass

While I was able to confirm that the class hooked this way were initialized by placing print statements in HookClass.__init__(), I was not able to confirm whether or not the hook themselves (HookClass.run()) are properly executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions