An extensible framework for emulating attacker TTPs with Selenium.
Project description
Scythe
An extensible framework for emulating attacker TTPs with Selenium.
Overview
Scythe is a Python-based framework that allows you to test the security of your web applications by emulating Tactics, Techniques, and Procedures (TTPs) of attackers. It uses Selenium to automate browser interactions and simulate attacks like SQL injection, cross-site scripting (XSS), and brute-forcing. This allows you to validate that your web application protects against these attacks and helps you test your detection capabilities.
Features
- Extensible TTP Framework: Easily create new TTPs by extending the abstract base class.
- Payload Generators: Generate payloads from wordlists or static lists.
- Selenium-based: Utilizes the power of Selenium for realistic browser automation.
- Configurable: Easily configure TTPs with different selectors and payloads.
- Logging: Detailed logging for each TTP execution.
Getting Started
Prerequisites
- Python 3.8+
- Google Chrome
Installation
- Clone the repository:
git clone https://github.com/EpykLab/scythe.git cd scythe
- Install the dependencies:
pip install -r requirements.txt
Usage
-
Configure a TTP: In your test script, import the desired TTP and create an instance with the necessary parameters. For example, to use the
LoginBruteforceTTP:from scythe.core.executor import TTPExecutor from scythe.ttps.web.login_bruteforce import LoginBruteforceTTP from scythe.payloads.generators import WordlistPayloadGenerator # Create a payload generator payload_generator = WordlistPayloadGenerator("path/to/your/password_list.txt") # Create a TTP instance login_bruteforce_ttp = LoginBruteforceTTP( payload_generator=payload_generator, username="testuser", username_selector="#username", password_selector="#password", submit_selector="#submit" ) # Create a TTP executor executor = TTPExecutor( ttp=login_bruteforce_ttp, target_url="http://localhost:5000/login" ) # Run the TTP executor.run()
-
Run the Test: Execute the Python script to run the TTP.
python your_test_script.py -
View the Results: The results of the TTP execution will be logged to the console and to a file named
ttp_test.log.
Contributing
Contributions are welcome! Please see the DEVELOPER_GUIDE.md for more
information on how to contribute to the project.
License
This project is licensed under the MIT License. See the LICENSE file for more
details.
DEVELOPER GUIDE
This guide provides instructions for developers who want to contribute to the Scythe framework by creating new TTPs.
Core Concepts
The Scythe framework is built around a few core concepts:
- TTP (Tactic, Technique, and Procedure): A TTP is a single test that
emulates a specific attacker behavior. Each TTP is a Python class that
inherits from the
TTPabstract base class. - Payload Generator: A payload generator is a class that generates
payloads for a TTP. The framework provides two types of payload generators:
WordlistPayloadGeneratorandStaticPayloadGenerator. - TTP Executor: The
TTPExecutoris the main engine for running TTP tests. It takes a TTP instance and a target URL as input and executes the TTP against the target.
Creating a New TTP
To create a new TTP, you need to create a new Python class that inherits from
the TTP abstract base class and implements the following methods:
get_payloads(self): This method should yield payloads for the test execution.execute_step(self, driver: WebDriver, payload: Any): This method executes a single test action using the provided payload. This method should perform the action (e.g., fill form, click button).verify_result(self, driver: WebDriver) -> bool: This method verifies the outcome of the executed step. It should returnTrueif the test indicates a potential success/vulnerability, andFalseotherwise.
Example TTP: SQL Injection
Here is an example of a simple SQL injection TTP:
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from scythe.core.ttp import TTP
from scythe.payloads.generators import StaticPayloadGenerator
class SQLInjectionTTP(TTP):
def __init__(self, target_url: str):
super().__init__(
name="SQL Injection",
description="Tests for basic SQL injection vulnerabilities."
)
self.target_url = target_url
self.payload_generator = StaticPayloadGenerator([
"' OR '1'='1",
"' OR '1'='1' --",
"' OR 1=1 --",
])
def get_payloads(self):
yield from self.payload_generator()
def execute_step(self, driver: WebDriver, payload: str):
# Assumes a search input with the name 'q'
driver.get(f"{self.target_url}?q={payload}")
def verify_result(self, driver: WebDriver) -> bool:
# A simple check for a generic SQL error message
return "sql" in driver.page_source.lower() or \
"syntax" in driver.page_source.lower()
Coding Conventions
Please follow these coding conventions when contributing to the Scythe framework:
- All code should be formatted using the Black code formatter.
- Type hints should be used for all function signatures.
- Docstrings should be included for all modules, classes, and functions.
- Follow the PEP 8 style guide for Python code.
By following these guidelines, you can help ensure that the Scythe framework remains a high-quality and maintainable project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scythe_ttp-0.7.1.tar.gz.
File metadata
- Download URL: scythe_ttp-0.7.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f7320477df2a06afa45331431a6be7799294a1e4272f693e84d2c26bec5ccee
|
|
| MD5 |
8fe69fd30e9d0ee06c0e3e6e300259bf
|
|
| BLAKE2b-256 |
54094ca375edf3c1ddfd41fba39ac6bc13a99a16f506ff67e12a4cff0dc4b26f
|
Provenance
The following attestation bundles were made for scythe_ttp-0.7.1.tar.gz:
Publisher:
pypi.yaml on EpykLab/scythe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scythe_ttp-0.7.1.tar.gz -
Subject digest:
5f7320477df2a06afa45331431a6be7799294a1e4272f693e84d2c26bec5ccee - Sigstore transparency entry: 268762788
- Sigstore integration time:
-
Permalink:
EpykLab/scythe@8049f55c313352c53742123bd38da162602f3ad0 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/EpykLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@8049f55c313352c53742123bd38da162602f3ad0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scythe_ttp-0.7.1-py3-none-any.whl.
File metadata
- Download URL: scythe_ttp-0.7.1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cffd75b084907a8e6c2e84a2b4a6571daecf471d093384f9f9c3e2d0a61e59b
|
|
| MD5 |
4f3312c4f978886271587cb600f741b5
|
|
| BLAKE2b-256 |
8c88b70a9f0189c0fec11c177558cdc651ef055f0e4b7438175a26f47da15476
|
Provenance
The following attestation bundles were made for scythe_ttp-0.7.1-py3-none-any.whl:
Publisher:
pypi.yaml on EpykLab/scythe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scythe_ttp-0.7.1-py3-none-any.whl -
Subject digest:
6cffd75b084907a8e6c2e84a2b4a6571daecf471d093384f9f9c3e2d0a61e59b - Sigstore transparency entry: 268762790
- Sigstore integration time:
-
Permalink:
EpykLab/scythe@8049f55c313352c53742123bd38da162602f3ad0 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/EpykLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@8049f55c313352c53742123bd38da162602f3ad0 -
Trigger Event:
push
-
Statement type: