π» Platform Integration Guide¶
CTFBridge supports a range of CTF platforms through modular, pluggable platform implementations. Each platform encapsulates its own logic for authentication, challenges, and other services, while exposing a consistent API to users.
π§ Platform Architecture¶
Each supported platform lives in its own subdirectory under ctfbridge.platforms.<platform> and includes:
- A custom client (e.g.
<PlatformName>Client) - Platform-specific service implementations (auth, challenges, scoreboard, etc.)
- Optional utilities, extractors, or HTTP overrides
π§± Platform Folder Structure¶
ctfbridge/platforms/<platform>/
βββ client.py
βββ services/
β βββ auth.py
β βββ challenges.py
β βββ scoreboard.py
β βββ ...
βββ http/
βββ utils/
βββ __init__.py
Only the necessary components need to be implemented. Platform folders follow a consistent structure to ensure discoverability and ease of extension.
π Platform Detection¶
Platform detection is handled in two steps:
1. platforms/detect.py¶
Contains logic to probe a target instance (usually via /) and return a platform identifier string like ctfd or rctf.
2. platforms/registry.py¶
Maps platform IDs to their client classes:
This lets create_client() automatically instantiate the right implementation.
π§ Adding a New Platform¶
- Create a folder under
platforms/<new_platform> - Implement
client.pywith a subclass ofCTFBridgeClient - Implement the necessary services in
services/ - Add platform detection logic in
detect.py - Register your client in
registry.py
You can reuse base and core services or override only what's necessary.
π Example: Adding examplectf¶
platforms/examplectf/client.py:
class ExampleCTFClient(CTFBridgeClient):
def __init__(self, url: str):
self.auth = ExampleAuthService(self)
self.challenges = ExampleChallengeService(self)
...
services/auth.py,challenges.py, etc.- Add detection logic:
async def static_detect(self, response: httpx.Response) -> Optional[bool]:
if "Powered by ExampleCTF" in response.text:
- Update
registry.py:
This modular system allows CTFBridge to scale and adapt as new platforms emerge, with minimal duplication of logic.