Skip to content

Exploit templates

VakarisZ edited this page Oct 16, 2020 · 8 revisions

The Infection Monkey exploiters are all built in a similar fashion inheriting from the HostExploiter. This class exposes two interface functions:

  • is_os_supported - Returns a boolean value on whether the victim is supported by the exploiter (for example, returning False on Windows victims for the SSHExploiter). This can be sub classed and check the victim more thoroughly, for example checking for open services matching specific versions.
  • exploit_host - Exploits the host, returning a boolean value on success.

A good example of an exploiter is the SSHExploiter class.

Adding a new exploiter

Adding a new exploiter involves the following steps:

  1. Adding exploiter's logic. Add a new class subclassing HostExploiter or WebRCE (if it's a web RCE exploit) under the exploit directory.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-232a049216cdc9aab0b1ef679007e44dbd1b6fe9d3e22a9cb73434d6ce055af7

  2. Adding exploiter's description for UI. Add your exploiters description to Configuration schema.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-0e81d8da765fdf53805a69dc455937c2ab27a193a22f5050b5c2e3228559bf72

  3. Adding exploiter to the list in UI config. Add exploiter's class name to the list of exploiters in Config.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-e823ce216f1d11e6b0c1fcf24ade9c6c6aaa0a99c870c8d13e70a18ef008fd23

  4. Define exploiter's data processing. Define how exploiter's data should be processed for report and add this process to report generation pipeline.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-4a70d8fabb4b770ad0350aef94409e4068ebce30a38fec4c80505856d340139a

  5. Define how security report will look like. Define the UI contents of your report section.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-59135095fe3ae314f1f3728eb08a85f1495f2e6a43c6797cf15ec4e28c76c9ca

  6. (Optional) Add documentation about your exploiter. You can add documentation about what your exploiter does in documentation framework.

    Example: https://github.com/guardicore/monkey/pull/808/files#diff-5d3acb00808795aeeaa8ed280b46d553bf69b3d5ee77fc08ce5314e571a917d1