Skip to content

SemaSCDG crashes when enabling hooks on windows executables #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Thib-fkr opened this issue Feb 26, 2025 · 0 comments
Open

SemaSCDG crashes when enabling hooks on windows executables #44

Thib-fkr opened this issue Feb 26, 2025 · 0 comments

Comments

@Thib-fkr
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant