Skip to content
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

Add a build_permission_change_command method to ILinuxAgentCommandBuilder #10

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion agentpluginapi/i_linux_agent_command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional

from monkeytypes import InfectionMonkeyBaseModel
from pydantic import model_validator
from pydantic import Field, model_validator

from .dropper_execution_mode import DropperExecutionMode

Expand All @@ -20,6 +20,11 @@ class LinuxDownloadOptions(InfectionMonkeyBaseModel):
download_url: str


class LinuxPermissionChangeOptions(InfectionMonkeyBaseModel):
file_path: PurePosixPath
permissions: int = Field(ge=0, le=0o777, default=700)


class LinuxRunOptions(InfectionMonkeyBaseModel):
agent_destination_path: PurePosixPath
dropper_execution_mode: DropperExecutionMode
Expand Down Expand Up @@ -47,6 +52,16 @@ def build_download_command(self, download_options: LinuxDownloadOptions):
:param download_options: Options needed for the command to be built
"""

@abc.abstractmethod
def build_permission_change_command(
self, permission_change_options: LinuxPermissionChangeOptions
):
"""
Build Agent's binary permission change command

:param permission_change_options: Options needed for the command to be built
"""

@abc.abstractmethod
def build_run_command(self, run_options: LinuxRunOptions):
"""
Expand Down
5 changes: 5 additions & 0 deletions vulture_allowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
WindowsRunOptions,
WindowsShell,
)
from agentpluginapi.i_linux_agent_command_builder import LinuxPermissionChangeOptions

IAgentEventPublisher.publish
IAgentEventPublisher.event
Expand Down Expand Up @@ -126,6 +127,8 @@
LinuxDownloadOptions.download_url
LinuxDownloadOptions.download_method

LinuxPermissionChangeOptions.file_path
LinuxPermissionChangeOptions.permissions

LinuxRunOptions.agent_destination_path
LinuxRunOptions.dropper_destination_path
Expand All @@ -134,6 +137,8 @@

ILinuxAgentCommandBuilder.build_download_command
ILinuxAgentCommandBuilder.build_run_command
ILinuxAgentCommandBuilder.build_permission_change_command
ILinuxAgentCommandBuilder.permission_change_options
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove vulture from this repository

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. The right way to go about it is to make it an option in the cookiecutter template and then use cruft to update this repo and not include it.

ILinuxAgentCommandBuilder.get_command
ILinuxAgentCommandBuilder.reset_command
ILinuxAgentCommandBuilder.download_options
Expand Down