Py2rest
Library that provides Python examples for interacting with the Cobalt Strike REST API
Install / Use
/learn @Cobalt-Strike/Py2restREADME
Cobalt Strike REST API Python Script Examples
This project provides Python Examples for interacting with the Cobalt Strike REST API. The examples are built on top of the Code generated by the OpenAPI Generator.
<p align="center"> <img width="60%" alt="py2rest" src="https://github.com/user-attachments/assets/bf961771-3104-416f-ac80-790b461dfbc8" /> </p>[!NOTE] This tool is still in early development stage and subject to breaking changes.
Video Walkthrough
<center><video width="720" heigth="480" crossorigin="anonymous" aria-label="py2rest demo" x-webkit-airplay="allow" playsinline="" controls controlslist="nodownload"><source src="https://linoma.wistia.com/medias/8gw1vl7cw6?wvideo=8gw1vl7cw6" type="video/mp4"></video></center>Requirements
- The Cobalt Strike API Server should be running.
- Cobalt Strike should be installed and configured.
- Cobalt Strike should be properly licensed
Setup Environment
Download the openapi-generator-cli
curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.17.0/openapi-generator-cli-7.17.0.jar -o openapi-generator-cli.jar
Get the Cobalt Strike REST API Specification
curl -k -o api-docs.json https://172.22.192.130:50443/v3/api-docs
Generate the client lib for Python
java -jar openapi-generator-cli.jar generate -i .\api-docs.json -g python -o .\CS_python_SDK --skip-validate-spec
Setup Python Environment
python -m venv cs_env
cs_env\Scripts\activate
pip install ./CS_python_SDK
pip install -r requirements.txt
🎮 Usage
Check this Jupyter Notebook for the actual examples.
🚑 Support
For issues and questions:
- Review Cobalt Strike documentation for API requirements
[!WARNING] This tool provides direct access to Cobalt Strike capabilities, which include powerful adversary simulation capabilities. Use responsibly and only in environments where you have explicit permission to perform security testing.
