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

1597 implement exploitation #1657

Merged
merged 13 commits into from
Dec 15, 2021
Merged

Conversation

mssalvatore
Copy link
Collaborator

What does this PR do?

Calls the exploiters from the AutomatedMaster for issue #1597

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by running unit tests
    Tested by running AutomatedMaster in isolation

  • If applicable, add screenshots or log transcripts of the feature working

@mssalvatore mssalvatore changed the base branch from develop to agent-refactor December 14, 2021 20:41
def build_victim_host(self, ip: str):
victim_host = VictimHost(ip)

# TODO: Reimplement the below logic from the old monkey.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will get done when we integrate the automated master with monkey.py

mssalvatore and others added 2 commits December 15, 2021 06:48
Comment on lines +82 to +83
if stop.is_set():
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Same consideration as before: each layer of logic contains the same

if stop.is_set():
    return

This logic is not specific to the Exploiter, it's an exception logic. Maybe there's a way to raise an exception when stop.is_set() instead. Maybe this can be solved with an interface/re-usable decorator

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A decorator won't work because the Event needs to be available on import, but we could potentially add a utility function that handles this. We're going to need it for the plugins as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the moment I'm going to leave it. Each loop is using it in a slightly different way, or has slightly different requirements. As we accumulate more, similar loops, we can find the common patterns and make them reusable. At the moment I think it may be too early to do so.

self, exploiter_name: str, victim_host: VictimHost, stop: Event
) -> ExploiterResultData:
logger.debug(f"Attempting to use {exploiter_name} on {victim_host}")
return self._puppet.exploit_host(exploiter_name, victim_host.ip_addr, {}, stop)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's worth considering creating the stop event in the agent. Then, puppet and master will be created with it. This way we wouldn't need to pass stop through the parameters everywhere. This would de-couple stopping logic from execution logic a bit, for better or worse.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would leak too much information into the agent, give the agent the ability to stop parts of the master that it shouldn't, and limit how the master is able to control functionality.

The stop signal is something that the master can control per-run of the Propagator. The master controls the Propagator, the Propagator controls the scanner and exploiter. Giving the higher-level abstractions the ability to skip layers and control the lower-level abstractions increases complexity and coupling.

@mssalvatore mssalvatore merged commit ba5d755 into agent-refactor Dec 15, 2021
@mssalvatore mssalvatore deleted the 1597-implement-exploitation branch December 15, 2021 14:11
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

Successfully merging this pull request may close these issues.

4 participants