Profinet Plugin Code
December 7, 2023 ยท View on GitHub
Where possible, the Caldera for OT plugins leverage open-source libraries and payloads, unifying their exposure through the Caldera Adversary Emulation framework.
-
The Profinet plugin leverages the open-source library pnio-dcp - version 1.1.6.
-
The pnio-dcp library is licensed with the MIT License
-
A custom command-line interface was created by our team for the pnio-dcp library to allow for Caldera agent interoperability. The CLI payload comes precompiled with the plugin, but can be recompiled following the instructions below.
Specific Code Modifications
- Change 1: Expose timeout as a variable instead of constant.
The file 'pnio_dcp.py' is modified to add another parameter to the DCP object constructor for timeout. See lines 47, 55-57 for changes.
Reproducing Builds
Build System Configuration
| Item | Windows binary | Linux binary |
|---|---|---|
| OS ver. | Windows 10 v21H2 | Ubuntu 22.04.2 LTS |
| Python ver. | 3.8.10 | 3.8-dev |
| Pyinstaller ver. | 6.10.2 | 6.10.2 |
| pnio_dcp ver. | 1.1.6 | 1.1.6 |
| binary name | dcp_utility.exe | dcp_utility |
Step-by-Step Instructions
- Download source
git clone --depth 1 --branch v1.1.6 https://gitlab.com/pyshacks/pnio_dcp.git
-
Replace pnio_dcp.py in downloaded source with provided modified version.
-
Validate you have the proper version of python installed. Optionally, create and enter a virtual environment with the required python version using packages like pyenv, venv, pipenv, or poetry.
python --version
- Install pnio_dcp library
pip install /src/pnio_dcp
- Silence setuptools_scm warning
modify _warn_on_old_setuptools function in the setuptools_scm package to silence false-positive warning. See line 28, setuptools_scm/_integration/setuptools.py
def _warn_on_old_setuptools(_version: str = setuptools.__version__) -> None:
return
...
- Test functionality of python cli prior to build
python /src/dcp_utility.py --help
- Build the binary with a static builder
pip install pyinstaller
sudo env "PATH=$PATH" pyinstaller /src/dcp_utility.py --onefile