OptiAttack (OA) is an optimization-based adversarial example generation framework designed for network test generation. It provides a modular, extensible platform for generating adversarial examples using evolutionary and search-based algorithms, with a focus on image-based attacks. The project includes both a core engine and a client-server architecture for remote testing, as well as a modern web UI for interactive use.
- Features
- Installation
- Quick Start
- Web UI
- Client Usage
- Configuration
- Project Structure
- Contributing
- License
- Acknowledgements
- Optimization-based adversarial example generation for network testing.
- Modular architecture: Easily extend algorithms, fitness functions, and mutators.
- Remote controller: Test against remote models or systems under test (NUT).
- Web UI: User-friendly Gradio interface for interactive attack generation and visualization.
- Comprehensive logging and reporting: Output images, statistics, and confidence charts.
- Configurable parameters: Fine-tune every aspect of the search and attack process.
- Python 3.9 or higher
- pip
pip install -r requirements.txtcd client
pip install -e .To run OptiAttack from the command line:
python main.py --input_image path/to/image.jpg --nut_host localhost --nut_port 38000 --max_evaluations 1000Common arguments:
--input_image: Path to the input image.--nut_host: Host address of the network under test (NUT).--nut_port: Port number of the NUT.--max_evaluations: Maximum number of search evaluations.
For a full list of parameters, see Configuration.
OptiAttack includes a Gradio-based web interface for interactive use.
python main.py --enable_ui True- Upload an input image.
- Set parameters (host, port, image size, max evaluations, etc.).
- Click "Run OptiAttack" to start the attack.
- View results, confidence charts, and reports directly in the browser.
The optiattack_client package provides a FastAPI-based server for integrating with remote models or systems under test (NUT).
from optiattack_client import collect_info
@collect_info(host="localhost", port=38000)
def predict(image_array):
# Your prediction logic here
return {"predictions": ...}- The client exposes endpoints for running attacks, getting info, and managing state.
- See
client/optiattack_client.pyfor details.
OptiAttack is highly configurable. You can set parameters via command-line arguments or configuration files.
| Parameter | Default | Description |
|---|---|---|
algorithm |
mio | Search algorithm for optimization |
input_image |
./tests/test_img.jpeg | Path to the input image |
image_width |
224 | Image width (pixels) |
image_height |
224 | Image height (pixels) |
max_evaluations |
1000 | Maximum number of search evaluations |
nut_host |
localhost | Host address for the NUT |
nut_port |
38000 | Port number for the NUT |
enable_ui |
False | Enable the web UI |
enable_pruning |
False | Enable pruning of final results |
| ... | ... | See docs/parameters.md for all parameters |
.
├── main.py # Entry point for the core application
├── gradio_ui.py # Web UI implementation
├── core/ # Core logic: algorithms, problem definitions, services
├── client/ # Client package for remote NUT integration
├── docs/ # Documentation (parameters, usage, etc.)
├── requirements.txt # Python dependencies
└── tests/ # Test cases and test images
OptiAttack can be run using Docker, which provides an isolated environment for running the application. You can either pull the pre-built image from Docker Hub or build it locally.
The easiest way to get started is to pull the pre-built image from Docker Hub:
docker pull oaresearch/optiattackAfter pulling the image, you can run it with:
docker run -v /path/to/images:/app/images -v /path/to/output:/app/output oaresearch/optiattack [options]The Docker container requires two volume mappings:
/app/images: Directory containing input images/app/output: Directory for storing output results
docker run --rm \
-v $(pwd)/images/:/app/images \
-v $(pwd)/output:/app/output \
oaresearch/optiattack \
--input_image ./images/test_img.jpeg \
--nut_host host.docker.internal \
--seed 8To run the container with the web UI:
docker run --rm \
-v $(pwd)/images/:/app/images \
-v $(pwd)/output:/app/output \
oaresearch/optiattack \
--enable_ui True-
Volume Paths:
- Use absolute paths for volume mappings
- Windows paths should use forward slashes (/) or escaped backslashes (\)
- The paths should exist on your host machine
-
Network Access:
- Use
host.docker.internalto access services running on your host machine - This is particularly important for the NUT (Network Under Test) connection
- Use
-
Common Parameters:
--input_image: Path to the input image (relative to the mounted images directory)--nut_host: Host address for the NUT (usehost.docker.internalfor local services)--seed: Random seed for reproducibility- Other parameters can be added as needed
If you need to build the Docker image locally instead of pulling from Docker Hub:
docker-compose buildFor development or testing, you can use Docker Compose:
docker-compose upThis will use the configuration from docker-compose.yml and automatically set up the required volumes and environment variables.
Contributions are welcome! Please open issues or pull requests for bug fixes, new features, or documentation improvements.
- Fork the repository.
- Create a new branch for your feature or fix.
- Ensure code passes linting and tests.
- Submit a pull request with a clear description.
This project is licensed under the GNU Lesser General Public License v3 (LGPLv3). See the LICENSE file for details.
This work was supported by the Erciyes University Scientific Research Fund (ERU-BAP, Project No: FBA-2024-13536).
This project is accompanied by academic research. A list of publications can be found in docs/publications.md.
To cite our work, please refer to the relevant paper(s) listed there.
- Developed by OptiAttack Team.
- Built with FastAPI, Gradio, and other open-source libraries.
For more details, see the docs/parameters.md file and in-code documentation.