# biielfont/genexis-pure-ed500 architecture

> Architecture diagram of the GitHub repository biielfont/genexis-pure-ed500, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/biielfont/genexis-pure-ed500
- Repository: https://github.com/biielfont/genexis-pure-ed500

## Overview

##### Project type and purpose
- This is not a conventional web or mobile app. It is a firmware–hacking documentation project for the Genexis Pure-ED500 router (Adamo).
- The goal is to explain how to gain persistent root, override bootloader arguments, hook into startup (preinit), manage passwords, and remove the TR-069 backdoor.

##### File structure
Top-level:
- README.md, extended.md, recovery.md, backdoor-removal.md – documentation of each hacking phase
- firmwares/ – collection of firmware images for various hardware revisions and custom ISPs
- scripts/ – cleanup and persistence helper scripts (e.g., cleanscript_persistant.sh)
- uboot/ – U-Boot images and UART console instructions
Key patterns:
- Two root banks: /rom (read-only factory image) vs / (overlayfs active root)
- Bootloader stage (U-Boot) → kernel & rootfs mount → preinit hook → init scripts (password sync, services) → JUCI web UI, SSH, TR-069 daemon
- The project documents how to intercept at bootloader (UART), modify bootargs, mount read-write root, and inject an exec /bin/sh in /etc/preinit for persistence.

##### README for additional insights
- Describes the two-bank overlayfs, password sync logic in /etc/init.d/passwords, and the TR-069 services (icwmp, icwmpd, icwmp_stund).
- Outlines sequence: UART→U-Boot interrupt→ altered bootargs to get shell → mount overlayfs → modify root passwords → add post-preinit hook → remove backdoor binaries and DHCP ACS settings.

a. Main components
1. Hardware: Genexis Pure-ED500 router with UART interface
2. Bootloader: U-Boot (serial console, bootargs)
3. Kernel & root filesystem
– /rom: factory, read-only
– overlayfs → /: active, read-write
4. Init system
– /etc/preinit hook (exec /bin/sh)
– /etc/init.d/passwords (credential sync)
– JUCI web UI (LUCI derivative)
– SSH daemon (port 22666)
– TR-069 client daemons (icwmp, icwmpd, icwmp_stund)
5. External ACS server (acs.adamo.es)
b. Relationships & interactions
- UART console connects to U-Boot → allows bootargs override
- U-Boot loads kernel → mounts /rom + overlayfs → executes /etc/preinit hook → yields root shell
- Once root shell available, scripts modify /etc/shadow and /etc/passwd in overlayfs root.
- Init scripts run: password sync, network services, web UI, SSH, TR-069 daemons.
- TR-069 daemons communicate with external ACS server.
- Hack removes/renames TR-069 binaries and disables ACS DHCP discover in JUCI to break remote management.
c. Architectural patterns & principles
- Layered boot stages: Bootloader → Kernel init → preinit hook → init scripts → services
- Overlay filesystem dual-bank strategy for persistence vs factory reset fallback
- Hooking startup scripts for shell persistence (exec /bin/sh at end of preinit)
d. Technologies, frameworks, libraries
- OpenWrt variant (Iopsys)
- JUCI web interface (based on uhttpd, uci)
- BusyBox shell tools
- UBI/UBIFS for firmware partitions
- U-Boot serial console

##### Detail
- Both banks (factory vs active), the injection points (bootargs, preinit), and the service startup flow
- Do not omit any stage of the boot-to-shell sequence or the password synchronization logic
- How firmware images stored in the project (firmwares/) map to the hardware’s UBI partitions but are external references

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Documentation and Scripts
    subgraph "Documentation & Resources"
        DOC1["README.md"]:::doc
        DOC2["extended.md"]:::doc
        DOC3["recovery.md"]:::doc
        DOC4["backdoor-removal.md"]:::doc
        FIRMWARES["firmwares/"]:::storage
        ISPFW["firmwares/Others ISP (more ISP customization)/"]:::storage
        STOCKFW["firmwares/PURE-ED500-GNX-*.y3"]:::storage
        ADGUARD["firmwares/adguardhome_0.107.69-2_mips_24kc_nomips16.ipk"]:::storage
        SCRIPT["scripts/cleanscript_persistant.sh"]:::hack
    end

    %% Hardware & Bootloader
    subgraph "Boot Stages" 
        HW["Hardware UART Interface"]:::boot
        UBOOT["U-Boot Bootloader"]:::boot
        KERNEL["Kernel"]:::boot
    end

    %% Filesystem Layers
    subgraph "Filesystem Layers"
        ROM["/rom (Factory, read-only)"]:::storage
        OVERLAY["/ (OverlayFS Active, read-write)"]:::storage
    end

    %% Preinit Hook
    subgraph "Preinit Stage"
        PREINIT["/etc/preinit (exec /bin/sh hook)"]:::hack
        SHELL["Root Shell Injected"]:::hack
    end

    %% Init and Services
    subgraph "Init & Services"
        PASS["/etc/init.d/passwords (Credential Sync)"]:::service
        JUCI["JUCI Web UI"]:::service
        SSHD["SSH Daemon (port 22666)"]:::service
        TR069["TR-069 Daemons\n(icwmp, icwmpd, icwmp_stund)"]:::service
        ACS["External ACS Server\n(acs.adamo.es)"]:::external
    end

    %% Connections
    HW -->|"UART interrupt"| UBOOT
    UBOOT -->|"Load Kernel"| KERNEL
    KERNEL -->|"Mount"| ROM
    KERNEL -->|"Mount"| OVERLAY
    OVERLAY -->|"Execute"| PREINIT
    PREINIT -->|"Spawn"| SHELL
    SHELL -->|"Modify FS"| OVERLAY
    OVERLAY -->|"Run Init Scripts"| PASS
    PASS -->|"Sync Credentials"| OVERLAY
    OVERLAY -->|"Start Services"| JUCI
    OVERLAY -->|"Start Services"| SSHD
    OVERLAY -->|"Start Services"| TR069
    TR069 -->|"Connect to"| ACS

    %% Scripts & firmware reference in workflow
    SHELL -->|"Uses scripts"| SCRIPT
    UBOOT -->|"References images"| STOCKFW
    UBOOT -->|"Instructions"| ISPFW
    UBOOT -->|"UART docs"| ADGUARD

    %% Click events
    click DOC1 "https://github.com/biielfont/genexis-pure-ed500/blob/main/README.md"
    click DOC2 "https://github.com/biielfont/genexis-pure-ed500/blob/main/extended.md"
    click DOC3 "https://github.com/biielfont/genexis-pure-ed500/blob/main/recovery.md"
    click DOC4 "https://github.com/biielfont/genexis-pure-ed500/blob/main/backdoor-removal.md"
    click FIRMWARES "https://github.com/biielfont/genexis-pure-ed500/tree/main/firmwares/"
    click ISPFW "https://github.com/biielfont/genexis-pure-ed500/tree/main/firmwares/Others ISP (more ISP customization)/"
    click STOCKFW "https://github.com/biielfont/genexis-pure-ed500/blob/main/firmwares/PURE-ED500-GNX-*.y3"
    click ADGUARD "https://github.com/biielfont/genexis-pure-ed500/blob/main/firmwares/adguardhome_0.107.69-2_mips_24kc_nomips16.ipk"
    click SCRIPT "https://github.com/biielfont/genexis-pure-ed500/blob/main/scripts/cleanscript_persistant.sh"
    click UBOOT "https://github.com/biielfont/genexis-pure-ed500/blob/main/uboot/uboot.img"
    click HW "https://github.com/biielfont/genexis-pure-ed500/blob/main/uboot/u-boot.uart.txt"

    %% Styles
    classDef boot fill:#d0e7ff,stroke:#1f78b4
    classDef storage fill:#e6ffe6,stroke:#33a02c
    classDef service fill:#ffe0b3,stroke:#ff7f00
    classDef hack fill:#ffd6d6,stroke:#e31a1c
    classDef doc fill:#f0e6ff,stroke:#6a3d9a
    classDef external fill:#f5f5f5,stroke:#636363,stroke-dasharray: 5 5
```
