# ridter/redis-rce architecture

> Architecture diagram of the GitHub repository ridter/redis-rce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ridter/redis-rce
- Repository: https://github.com/ridter/redis-rce

## Overview

#### Purpose and Entry Point

This repository is a single-purpose offensive security tool targeting Redis 4.x/5.x instances. It attempts remote code execution by presenting a rogue Redis replication server, causing the target to synchronize a supplied Redis module, then loading that module.

The only executable entry point is `redis-rce.py`; usage, target/version scope, and required module artifact are documented in `README.md`.

#### Operator Interface

`redis-rce.py` exposes a CLI for:
- Target Redis host, port, and optional authentication.
- Attacker-controlled rogue-server bind address and port.
- Path to the Redis module shared object, defaulting to `exp.so`.
- Verbose runtime output.

The module binary is not included in the repository; operators must compile or obtain it externally as specified in `README.md`.

#### Exploit Orchestration

The main control flow is concentrated in `redis-rce.py`:
1. Connect to the target Redis service.
2. Authenticate when an `AUTH` value is supplied.
3. Reconfigure or direct Redis replication toward the attacker’s rogue server.
4. Serve replication data containing the selected module payload.
5. Trigger Redis module loading and interact with the resulting command-execution capability.

This combines a client role toward the target Redis instance with a server role toward the target’s replication connection.

#### Rogue Replication Boundary

The attacker-hosted listener in `redis-rce.py` is the key protocol boundary. It must emulate enough Redis replication behavior for the target to accept the replication stream and persist the delivered module. Its address is supplied through `-L/--lhost`; its default listener port is 21000.

The target boundary is the Redis RESP/TCP service, normally port 6379, configured by `-r/--rhost` and `-p/--rport`.

#### Module Execution Boundary

The exploit payload is a Redis module shared library, expected as `exp.so` unless overridden with `-f/--file`. The tool depends on an externally compiled module from RedisModules-ExecuteCommand, rather than implementing arbitrary command execution wholly in Python.

`redis-rce.py` is therefore responsible for delivery and activation; the native module provides execution functionality after Redis loads it.

#### Runtime and Dependencies

The tool runs under Python and declares its runtime dependencies in `requirements.txt`. It requires:
- Network reachability from operator host to the target Redis service.
- Reachability from target Redis back to the operator’s rogue listener.
- A susceptible Redis 4.x/5.x deployment with replication/module-loading conditions that permit the attack.

Repository scope is intentionally narrow: `README.md` provides operational guidance, while `redis-rce.py` contains the exploit implementation.

Main entry points: [`redis-rce.py`](https://github.com/ridter/redis-rce/blob/master/redis-rce.py) (Exploit Controller), [`README.md`](https://github.com/ridter/redis-rce/blob/master/README.md) (Operational Guide), [`requirements.txt`](https://github.com/ridter/redis-rce/blob/master/requirements.txt) (Python Dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator Inputs"]
  node_readme["Operational Guide<br/>documentation<br/>[README.md]"]
  node_cli["CLI Options<br/>argument parser<br/>[redis-rce.py]"]
  node_requirements["Python Dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_operator_host["Operator Host<br/>runtime environment"]
end

subgraph group_exploit["Exploit Orchestration"]
  node_exploit_script["Exploit Controller<br/>Python entry point<br/>[redis-rce.py]"]
  node_target_client["Redis Target Client<br/>RESP/TCP client<br/>[redis-rce.py]"]
  node_replication_setup["Replication Setup<br/>Redis control flow<br/>[redis-rce.py]"]
  node_rogue_listener["Rogue Replication Server<br/>TCP listener<br/>[redis-rce.py]"]
  node_module_activation["Module Load Trigger<br/>Redis control flow<br/>[redis-rce.py]"]
end

subgraph group_target["Target &amp; Payload"]
  node_target_redis[("Target Redis 4.x/5.x<br/>Redis service")]
  node_module_payload["Redis Module Payload<br/>native shared library"]
  node_execution_capability["Command Execution<br/>loaded module capability"]
end

node_readme -->|"documents"| node_cli
node_requirements -->|"supports runtime"| node_exploit_script
node_operator_host -->|"runs"| node_exploit_script
node_cli -->|"configures"| node_exploit_script
node_exploit_script -->|"connects through"| node_target_client
node_target_client -->|"RESP/TCP and optional AUTH"| node_target_redis
node_exploit_script -->|"initiates"| node_replication_setup
node_replication_setup -->|"configures replication source"| node_target_redis
node_exploit_script -->|"hosts"| node_rogue_listener
node_target_redis -->|"replication connection"| node_rogue_listener
node_module_payload -->|"served in replication stream"| node_rogue_listener
node_rogue_listener -->|"delivers module data"| node_target_redis
node_exploit_script -->|"triggers"| node_module_activation
node_module_activation -->|"loads module"| node_target_redis
node_target_redis -->|"hosts loaded module"| node_execution_capability

click node_readme "https://github.com/ridter/redis-rce/blob/master/README.md"
click node_cli "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"
click node_requirements "https://github.com/ridter/redis-rce/blob/master/requirements.txt"
click node_exploit_script "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"
click node_target_client "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"
click node_replication_setup "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"
click node_rogue_listener "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"
click node_module_activation "https://github.com/ridter/redis-rce/blob/master/redis-rce.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_readme,node_cli,node_requirements,node_operator_host toneBlue
class node_exploit_script,node_target_client,node_replication_setup,node_rogue_listener,node_module_activation toneAmber
class node_target_redis,node_module_payload,node_execution_capability toneMint
```

## Components

### Operator Inputs

- [Operational Guide](https://github.com/ridter/redis-rce/blob/master/README.md): documentation · Documents usage, scope, and external module requirement. · `README.md`
- [CLI Options](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): argument parser · Accepts target, listener, module, auth, and verbosity settings. · `redis-rce.py`
- [Python Dependencies](https://github.com/ridter/redis-rce/blob/master/requirements.txt): dependency manifest · `requirements.txt`
- **Operator Host**: runtime environment · Runs the Python exploit and hosts the rogue listener.

### Exploit Orchestration

- [Exploit Controller](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): Python entry point · Coordinates target control, replication delivery, and module activation. · `redis-rce.py`
- [Redis Target Client](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): RESP/TCP client · Connects and optionally authenticates to the target. · `redis-rce.py`
- [Replication Setup](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): Redis control flow · Directs the target to synchronize from the rogue server. · `redis-rce.py`
- [Rogue Replication Server](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): TCP listener · Emulates Redis replication and serves the payload stream. · `redis-rce.py`
- [Module Load Trigger](https://github.com/ridter/redis-rce/blob/master/redis-rce.py): Redis control flow · Loads the delivered module on the target. · `redis-rce.py`

### Target & Payload

- **Target Redis 4.x/5.x**: Redis service · Susceptible RESP/TCP endpoint, normally on port 6379.
- **Redis Module Payload**: native shared library · External exp.so artifact, or the file selected with --file.
- **Command Execution**: loaded module capability · Provided by the external RedisModules-ExecuteCommand module.

## Connections

- Operational Guide → CLI Options: documents
- Python Dependencies → Exploit Controller: supports runtime
- Operator Host → Exploit Controller: runs
- CLI Options → Exploit Controller: configures
- Exploit Controller → Redis Target Client: connects through
- Redis Target Client → Target Redis 4.x/5.x: RESP/TCP and optional AUTH
- Exploit Controller → Replication Setup: initiates
- Replication Setup → Target Redis 4.x/5.x: configures replication source
- Exploit Controller → Rogue Replication Server: hosts
- Target Redis 4.x/5.x → Rogue Replication Server: replication connection
- Redis Module Payload → Rogue Replication Server: served in replication stream
- Rogue Replication Server → Target Redis 4.x/5.x: delivers module data
- Exploit Controller → Module Load Trigger: triggers
- Module Load Trigger → Target Redis 4.x/5.x: loads module
- Target Redis 4.x/5.x → Command Execution: hosts loaded module
