# yyax13/anakinrk architecture

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

- Interactive diagram: https://gitdiagram.com/yyax13/anakinrk
- Repository: https://github.com/yyax13/anakinrk

## Overview

AnakinRK is an educational Linux kernel rootkit module. Its main workflow is a user sending a magic signal and command-encoded PID; the hooked kill path dispatches a command to privilege escalation, module visibility toggling, port hiding, or help output. Module initialization installs the ftrace hooks, which intercept module loading and TCP proc-table display as separate capabilities. The excerpts show the TCP filtering and command table; other behavior and some wiring are documented or referenced by the SOURCE INDEX, so those links cite that evidence.

Main entry points: [`src/hooks/tcp_seq_show.c`](https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c) (TCP display hooks), [`src/modules/menu.c`](https://github.com/yyax13/anakinrk/blob/main/src/modules/menu.c) (Command dispatcher), [`src/main.c`](https://github.com/yyax13/anakinrk/blob/main/src/main.c) (Module lifecycle), [`src/hooks/insmod.c`](https://github.com/yyax13/anakinrk/blob/main/src/hooks/insmod.c) (Module-load hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Control and lifecycle"]
  node_module["Module lifecycle<br/>[main.c]"]
  node_ftrace["ftrace helper<br/>[ftrace_helper.c]"]
end

subgraph group_hooks["Kernel hooks"]
  node_killhook["Signal hook<br/>[kill.c]"]
  node_insmodhook["Module-load hook<br/>[insmod.c]"]
  node_tcphook["TCP display hooks<br/>[tcp_seq_show.c]"]
end

subgraph group_commands["Command actions"]
  node_dispatcher["Command dispatcher<br/>[menu.c]"]
  node_root["Privilege escalation<br/>[get_root.c]"]
  node_selfhide["Module visibility toggle<br/>[hide.c]"]
  node_porttoggle["Port toggle<br/>[hide_port.c]"]
  node_help["Help output<br/>[menu.c]"]
end

subgraph group_state["Kernel state"]
  node_portstate[("Hidden-port list<br/>[tcp_seq_show.c]")]
  node_tcpviews["TCP proc views<br/>[tcp_seq_show.c]"]
end

node_user(("User"))
node_kernel["Linux kernel"]

node_user -->|"sends command signal"| node_killhook
node_module -->|"installs and removes"| node_insmodhook
node_module -->|"installs and removes"| node_tcphook
node_module -->|"installs and removes"| node_killhook
node_insmodhook -.->|"uses"| node_ftrace
node_tcphook -->|"installs hooks"| node_ftrace
node_killhook -->|"dispatches to"| node_dispatcher
node_dispatcher -->|"invokes"| node_root
node_dispatcher -->|"invokes"| node_selfhide
node_dispatcher -->|"invokes"| node_porttoggle
node_dispatcher -->|"invokes"| node_help
node_porttoggle -->|"updates"| node_portstate
node_tcphook -->|"checks"| node_portstate
node_tcphook -->|"filters display"| node_tcpviews
node_insmodhook -->|"intercepts module loading"| node_kernel
node_root -->|"changes credentials"| node_kernel
node_selfhide -->|"toggles visibility"| node_kernel
node_tcphook -->|"hooks TCP display"| node_kernel

click node_module "https://github.com/yyax13/anakinrk/blob/main/src/main.c"
click node_ftrace "https://github.com/yyax13/anakinrk/blob/main/src/ftrace/ftrace_helper.c"
click node_killhook "https://github.com/yyax13/anakinrk/blob/main/src/hooks/kill.c"
click node_insmodhook "https://github.com/yyax13/anakinrk/blob/main/src/hooks/insmod.c"
click node_tcphook "https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c"
click node_dispatcher "https://github.com/yyax13/anakinrk/blob/main/src/modules/menu.c"
click node_root "https://github.com/yyax13/anakinrk/blob/main/src/modules/get_root.c"
click node_selfhide "https://github.com/yyax13/anakinrk/blob/main/src/modules/hide.c"
click node_porttoggle "https://github.com/yyax13/anakinrk/blob/main/src/modules/hide_port.c"
click node_help "https://github.com/yyax13/anakinrk/blob/main/src/modules/menu.c"
click node_portstate "https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c"
click node_tcpviews "https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c"

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_module,node_ftrace,node_user toneBlue
class node_killhook,node_insmodhook,node_tcphook toneAmber
class node_dispatcher,node_root,node_selfhide,node_porttoggle,node_help toneMint
class node_portstate,node_tcpviews toneRose
class node_kernel toneIndigo
```

## Components

### Control and lifecycle

- [Module lifecycle](https://github.com/yyax13/anakinrk/blob/main/src/main.c): `src/main.c`
- [ftrace helper](https://github.com/yyax13/anakinrk/blob/main/src/ftrace/ftrace_helper.c): `src/ftrace/ftrace_helper.c`

### Kernel hooks

- [Signal hook](https://github.com/yyax13/anakinrk/blob/main/src/hooks/kill.c): `src/hooks/kill.c`
- [Module-load hook](https://github.com/yyax13/anakinrk/blob/main/src/hooks/insmod.c): `src/hooks/insmod.c`
- [TCP display hooks](https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c): `src/hooks/tcp_seq_show.c`

### Command actions

- [Command dispatcher](https://github.com/yyax13/anakinrk/blob/main/src/modules/menu.c): `src/modules/menu.c`
- [Privilege escalation](https://github.com/yyax13/anakinrk/blob/main/src/modules/get_root.c): `src/modules/get_root.c`
- [Module visibility toggle](https://github.com/yyax13/anakinrk/blob/main/src/modules/hide.c): `src/modules/hide.c`
- [Port toggle](https://github.com/yyax13/anakinrk/blob/main/src/modules/hide_port.c): `src/modules/hide_port.c`
- [Help output](https://github.com/yyax13/anakinrk/blob/main/src/modules/menu.c): `src/modules/menu.c`

### Kernel state

- [Hidden-port list](https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c): `src/hooks/tcp_seq_show.c`
- [TCP proc views](https://github.com/yyax13/anakinrk/blob/main/src/hooks/tcp_seq_show.c): `src/hooks/tcp_seq_show.c`

### Other components

- **User**
- **Linux kernel**

## Connections

- User → Signal hook: sends command signal (evidence: `README.md`)
- Module lifecycle → Module-load hook: installs and removes (evidence: `src/main.c`)
- Module lifecycle → TCP display hooks: installs and removes (evidence: `src/main.c`)
- Module lifecycle → Signal hook: installs and removes (evidence: `src/main.c`)
- Module-load hook → ftrace helper: uses
- TCP display hooks → ftrace helper: installs hooks (evidence: `src/hooks/tcp_seq_show.c`)
- Signal hook → Command dispatcher: dispatches to (evidence: `src/hooks/kill.c`)
- Command dispatcher → Privilege escalation: invokes
- Command dispatcher → Module visibility toggle: invokes
- Command dispatcher → Port toggle: invokes
- Command dispatcher → Help output: invokes (evidence: `src/modules/menu.c`)
- Port toggle → Hidden-port list: updates (evidence: `src/modules/hide_port.c`)
- TCP display hooks → Hidden-port list: checks (evidence: `src/hooks/tcp_seq_show.c`)
- TCP display hooks → TCP proc views: filters display (evidence: `src/hooks/tcp_seq_show.c`)
- Module-load hook → Linux kernel: intercepts module loading (evidence: `README.md`)
- Privilege escalation → Linux kernel: changes credentials (evidence: `README.md`)
- Module visibility toggle → Linux kernel: toggles visibility (evidence: `README.md`)
- TCP display hooks → Linux kernel: hooks TCP display (evidence: `src/hooks/tcp_seq_show.c`)
