Open vinnybod opened 5 months ago
@vinnybod - I have enhanced the feature as mentioned. Could you please review part 1: https://github.com/BC-SECURITY/Empire/pull/717
Hey @git-tirthankar I reviewed the pull request, looks like you just need to lint the code. When I did locally, it found some syntactical errors. Thanks for your help!
Description
Empire 5.9.0 introduced a new way of doing error handling: https://bc-security.gitbook.io/empire-wiki/module-development/powershell-modules#error-handling
Instead of returning a tuple containing an error message or using the
handle_error_message
function, an exception should be raised and the generated module script should be returned as astr
Empire 5.9.0 introduced 2 decorators
auto_get_source
andauto_finalize
: https://bc-security.gitbook.io/empire-wiki/module-development/powershell-modules#decoratorsUsing these decorators eliminates a bit of boiler plate code from the beginning and end of a module's generate function.
auto_finalize
cannot be used without replacing tuple returns with raised exceptions.Solution
Remove the use of
handle_error_message
, instead using the raised exceptions described in the docs https://bc-security.gitbook.io/empire-wiki/module-development/powershell-modules#error-handlingFor modules that are not deviating from the boiler plate template, replace the
get_module_source
andfinalize_module
calls with theauto_get_source
andauto_finalize
decorators.An example module conversion is here: https://github.com/BC-SECURITY/Empire/commit/4eb02f637b300f2aa87b607b88487ae4c4108794#diff-c41918d437c0bf39ac6fc692e1bb881586f8d1b0c583864f72bdcfbf5ba0ad65R12-R48
Alternatives
No response
Additional Context
No response