With the release of the SCYTHE Software Development Kit (SDK), we released two new and important components to help make the development of SCYTHE modules frictionless for third party developers: the Module Buster application and the Python3 runtime.
We feel that one of the best ways for us to demonstrate how easy it is to create a new SCYTHE module is to demonstrate how we ported an open source tool, written in Python, to SCYTHE.
Our criteria for choosing a tool to port to SCYTHE was:
The winner of our search was the LMO utility by Rob Fuller (@mubix), which is the client-side of the LetMeOutOfYour.net website.
The specific file we want to port to SCYTHE is lmo-oob.py, which performs two functions:
With our file selected (and it being less than 50 lines of Python) we can now move forward with constructing a module for SCYTHE!
In order to make lmo-oob.py SCYTHE-import-friendly, we only had to change the following:
First we created a global array object to store all of the results in, so instead of just printing them or sending them OOB, we can return them to a Python script calling this tool.
Second, we wrapped the primary functionality in a def main function call, converting
for port in ports:
to:
And that’s it! The lmo-oob.py file can now be used in SCYTHE!
(Note: Because SCYTHE will be acting as a C2 in this example, we actually don’t need any of the “OOB” part of the Python script; so that can optionally be removed as well!)
The LMO script does require the use of the Python requests package so we will need to embed those third party packages into the SCYTHE module. These were gathered by executing the following (on Windows):
We can then get the produced folders by navigating to .\venv\Lib\site-packages\ and saving the new downloaded package folders somewhere for us to use later.
We are now in the SCYTHE SDK part of the process and to get started we need just a couple of prerequisites (for a Windows environment):
Once the above are completed, we can create our default SCYTHE Module “skeleton” by opening Module Buster, and selecting “New Module”.
We then define the following:
… and click “Create Module”!
This will create the following directory structure on your desktop:
C:\Users\<YOUR_USERNAME>\Desktop\modules\python3\test_lmo\windows\src\
All the files contained within the src directory utilize the default “Echo” SCYTHE Module. And there are two files particular worth noting:
A. The SCYTHE “client” file, which is the code that will be run on a target endpoint. Located at the following location:
B. The SCYTHE “server” file, which is the code the SCYTHE server uses to define arguments sent to the client, server-side formatting, etc., is located at:
(Additional note: In this example we will only be working with the “client” file, this is done for the sake of brevity. However example source code will be provided for a more elegant “server” file.)
We now need to add in the LMO code and packages to the SCYTHE Module skelton directory structure. This can be done by:
With the SCYTHE SDK, consider the following:
With all the third party dependencies in place we are now ready to modify the SCYTHE module's client side code to import and run the LMO code we have imported into the directory structure!
In order to call the our just-copied lmo_oob.py file, we simply have to:
And that is it. You’ve now successfully ported LMO to a SCYTHE Module!
(Note: The above code examples are commented/explained in the example code shared at the bottom of this post!)
With the Module code in place, we need to build a package and test that it runs as expected.
To build the Module package we can use the already included build script in the module’s folder.
cd C:\Users\<YOUR_USERNAME>\Desktop\modules\python3\test_lmo\windows\
This will create a package.zip at the following location:
C:\Users\<YOUR_USERNAME>\Desktop\modules\python3\test_lmo\windows\bin\package.zip
(Note: Remember the location of this package.zip file, as this is the file we will install into SCYTHE later!)
With the Module package created we are ready to validate it working in SCYTHE's in-memory Python3 runtime environment. To test this we need to:
If everything went according to plan you should see “Module Passed Validation” at the top, and towards the bottom, you should see the output of LMO!
Now that we have created a working SCYTHE Python Module package, we can take the final step to install and run the Module in SCYTHE. Note that this requires SCYTHE v3.0 or higher!
And with that final command you should see the output of your custom/ported SCYTHE Module in the Shell interface! Congratulations, you have just ported a custom Python script to SCYTHE, and ran it on an endpoint in an in-memory Python runtime environment!!!
We have gone ahead and published a slightly-more-advanced version of the Module described above on our Github here. The published version includes the sending of parameters, some validation, and the formatting of Request messages in the SCYTHE server user interface.
We want to give a massive thank you to Rob Fuller (Mubix) for working with us on the creation of this SCYTHE Module and this walkthrough. Rob does amazing work, and we are incredibly grateful for his time and support. Please go check out all the awesome work Rob is doing here: https://twitter.com/mubix.
SCYTHE provides an advanced attack emulation platform for the enterprise and cybersecurity consulting market. The SCYTHE platform enables Red, Blue, and Purple teams to build and emulate real-world adversarial campaigns in a matter of minutes. Customers are in turn enabled to validate the risk posture and exposure of their business and employees and the performance of enterprise security teams and existing security solutions. Based in Arlington, VA, the company is privately held and is funded by Gula Tech Adventures, Paladin Capital, Evolution Equity, and private industry investors. For more information email info@scythe.io, visit https://scythe.io, or follow on Twitter @scythe_io.