guardicode / agentpluginapi

Interfaces and components that comprise the Infection Monkey Agent Plugin API
GNU General Public License v3.0
1 stars 0 forks source link

Add a parameter to build_run_command methods that controls OTP usage #11

Closed VakarisZ closed 2 weeks ago

VakarisZ commented 2 weeks ago

https://github.com/guardicore/monkey/issues/4201

VakarisZ commented 2 weeks ago

Most methods for linux and windows are the same. I wonder if it would make sense to use inheritance

mssalvatore commented 2 weeks ago

Most methods for linux and windows are the same. I wonder if it would make sense to use inheritance

We tried that initially. It ends up causing more problems than it solves.

mssalvatore commented 2 weeks ago

We also need the interface to provide a way to get the portion of the command to set the OTP environment variable.

VakarisZ commented 2 weeks ago

We tried that initially. It ends up causing more problems than it solves.

Right, because of different options, I presume

We also need the interface to provide a way to get the portion of the command to set the OTP environment variable.

Why? OTP is only relevant to the run command and it's best to set it for the duration of the run command (OTP=something /tmp/m0nk3y). It makes sense to have them together.

mssalvatore commented 2 weeks ago

We tried that initially. It ends up causing more problems than it solves.

Right, because of different options, I presume

We also need the interface to provide a way to get the portion of the command to set the OTP environment variable.

Why? OTP is only relevant to the run command and it's best to set it for the duration of the run command (OTP=something /tmp/m0nk3y). It makes sense to have them together.

If it's not included in the run command (because the run command is in the bash script), it still needs to be set in the environment the bash script runs in.

mssalvatore commented 2 weeks ago

One solution might be another utility function (maybe a static method on the command builders??) that accepts an OTP as input and generates the necessary command to set the environment variable. the command builder can use this if the otp variable is set and anyone else can use it to generate just that component if they need it.

VakarisZ commented 2 weeks ago

If it's not included in the run command (because the run command is in the bash script), it still needs to be set in the environment the bash script runs in.

It will be set in the run command that runs the bash script.

run_options = LinuxRunOptions(
                dropper_execution_mode=DropperExecutionMode.SCRIPT,
                agent_destination_path=f"{FILE_PATH}")
agent_command_builder.build_run_command(run_options)
mssalvatore commented 2 weeks ago

If it's not included in the run command (because the run command is in the bash script), it still needs to be set in the environment the bash script runs in.

It will be set in the run command that runs the bash script.

run_options = LinuxRunOptions(
                dropper_execution_mode=DropperExecutionMode.SCRIPT,
                agent_destination_path=f"{FILE_PATH}")
agent_command_builder.build_run_command(run_options)

Ok. Got it.