diff --git a/PROBLEMS.md b/PROBLEMS.md new file mode 100644 index 0000000..3b2e989 --- /dev/null +++ b/PROBLEMS.md @@ -0,0 +1,172 @@ +# AetherForge — Problem Audit + +Read-only audit of the repo. Findings grouped by severity for systematic fixes. + +**Last verified:** run `go build` in `server/` and `agent/`, `npm run build` in `server/web/`, then double-click `run.bat`. + +--- + +## Fixed in latest pass (run.bat should work) + +| ID | Fix | +|----|-----| +| C1 | Restored `BroadcastServerLog` on `WSHub` | +| C2 | `EncodeToString` in agent download handler | +| C3 | `AgentRemoteActions` accepts legacy `agent` + `compact` props again | +| C4 | Partial — `useWebSocket` exposes `latestMessage`; Agents detail wired | +| C5 | Partial — agent handlers for `ps`, `netstat`, `users`, `software`, `screenshot` | +| C6 | `NewMeshNode(c)` initialized in `NewAgentClient` | +| H13 | `run.bat` exits on frontend build failure | + +**Still open:** C7/C8 auth, H1–H12, M1–M11, L1–L6 — see below. + +--- + +## Critical — blocks builds or core functionality + +### C1. Server does not compile (`BroadcastServerLog` missing) +- **File:** `server/main.go:27` +- **Issue:** `wsLogWriter` calls `w.hub.BroadcastServerLog()`, but that method was removed from `server/internal/api/websocket.go`. +- **Impact:** `go build` fails; `run.bat` cannot produce `bin/miner-server.exe`. + +### C2. Agent does not compile (`EncodeString` typo) +- **File:** `agent/client/client.go:295` +- **Issue:** Uses `base64.StdEncoding.EncodeString(...)` — Go API is `EncodeToString(...)`. +- **Impact:** Forged worker builds fail at compile time. + +### C3. Frontend TypeScript build broken (remote actions props) +- **Files:** `server/web/src/pages/DashboardPage.tsx:253`, `AgentsPage.tsx:123,222-224` +- **Issue:** `AgentRemoteActions` expects `agentId`, `agentName`, `latestWsMessage`. Pages still pass `agent`, `compact`, `onCommandSent`. +- **Impact:** `npm run build` fails (`tsc && vite build`). + +### C4. Remote control UI non-functional end-to-end +- Wrong props → `agentId` undefined → `/api/v1/agents/undefined/command` +- `useWebSocket.ts` does not handle `command_result` +- No page passes `latestWsMessage` to `AgentRemoteActions` + +### C5. Five UI recon actions missing on agent +- **UI:** `screenshot`, `ps`, `netstat`, `users`, `software` in `AgentRemoteActions.tsx` +- **Agent:** only `sysinfo` implemented; others return `"unknown action"` + +### C6. Mesh P2P → nil pointer if enabled in forge +- **Files:** `agent/client/client.go:65-68`, `376-378`; `NewAgentClient` never sets `c.mesh` +- Builder can bake `MeshP2P: true` but mesh node is never initialized. + +### C7. No authentication on control plane +- **Files:** `server/internal/api/router.go`, `websocket.go` +- Open: config PUT, builder, fleet commands, downloads, agent/dashboard WS, AI endpoints +- Anyone on LAN/tunnel can forge, reconfigure, run remote PowerShell, impersonate agents. + +### C8. Unauthenticated remote code execution +- **Files:** `fleet_handler.go` → agent `exec`, `powershell`, `upload` +- No auth, no action whitelist, upload accepts arbitrary paths. + +--- + +## High — major runtime bugs or security risk + +### H1. Agent reconnect marks fleet offline incorrectly +- **File:** `websocket.go` — defer on disconnect always `SetAgentOffline`; reconnect overwrites map without closing old conn. + +### H2. WebSocket messages processed before auth +- `stats`, `submit_share`, etc. use `agentID` with no guard when empty. + +### H3. Share submission blocks WebSocket read loop +- **File:** `websocket.go:381-459` — synchronous pool submit on read loop (was async). + +### H4. Fleet broadcast always reports success +- `id == "all"` returns `{success: true}` even with zero connected agents. + +### H5. AI `reinstall_miner` uses agent ID instead of build ID +- **File:** `agent/client/ai.go` — download URL 404s. + +### H6. AI decide ignores HTTP errors +- No `resp.StatusCode` or `"error"` field check in `callDecide`. + +### H7. AI state wrong (uptime ~0, shares hardcoded 0) +- **File:** `agent/client/ai.go:212-221` — `time.Since(time.Now())` bug. + +### H8. AI `sleep` tool parsing broken +- `Sscanf` into `time.Duration` with wrong units. + +### H9. `upload_log` AI tool does not upload to server +- Reads local file only; Ollama prompt still advertises upload. + +### H10. Download command corrupts binary data +- `EncodeString(string(b))` instead of `EncodeToString(b)`. + +### H11. Auto-spread active when baked (`AutoSpread`) +- **Files:** `agent/deploy/autospread.go`, `agent/main.go:59` — SMB/SCM lateral deployment on /24 sweep. + +### H12. Process hollowing in agent main when baked +- **Files:** `agent/main.go:73-86`, `deploy/hollow_windows.go` + +### H13. `run.bat` pipeline fails when server/agent/web do not compile +- Steps 3–4 depend on fixes for C1–C3. + +--- + +## Medium — incomplete features, UX regressions + +### M1. Full tactical panel embedded in agent list cards (no compact mode) +- Dashboard and Agents list render huge remote panel per row. + +### M2. `onCommandSent` / `get_log` flow removed from remote UI +- Agents detail log refresh broken; `get_log` button removed. + +### M3. Live dashboard stats incomplete over WebSocket +- Memory, uptime, shares not in `stats_update` broadcast or hook merge. + +### M4. Forge schema mismatch (backend vs frontend types) +- Backend: `process_hollowing`, `mesh_p2p`, `auto_spread` in `handler.go` +- Frontend `BuildRequest` and Builder UI omit them; help/rules still reference them. + +### M5. Agent log fetch uses fixed 800ms sleep +- **File:** `fleet_handler.go` — blocks handler; often stale. + +### M6. No online/offline guard in new remote UI + +### M7. Click bubbling in agent list (buttons re-select row) + +### M8. `GetEngine` fragile lock pattern in `ai_handler.go` + +### M9. Fusion icon needs network for `go-winres` at forge time + +### M10. CORS `AllowedOrigins: *` with `AllowCredentials: true` + +### M11. Blueprint delete returns `"success": "true"` string + +--- + +## Low — polish and test gaps + +### L1. Dead CSS (`.agent-actions` in `FleetPanels.css`) +### L2. Duplicate CSS imports on Dashboard/Agents pages +### L3. Weak typing on WS payloads (`any`) +### L4. No tests for remote actions or page integration +### L5. `mesh_p2p.go` vs stub; mesh never initialized anyway +### L6. Server log streaming half-removed (`BroadcastServerLog`) + +--- + +## Suggested fix order + +1. C1, C2, C3 — restore compilable server, agent, web +2. C4, C5 — wire remote actions + implement or remove dead buttons +3. C6 — init mesh stub in `NewAgentClient` +4. H3, H1, H2 — async shares, reconnect, pre-auth guard +5. C7, C8 — auth on control plane +6. H5–H10 — AI and download bugs +7. M1–M7 — UX cleanup +8. M4, H11, H12 — align or remove hollowing/spread/mesh + +--- + +## Verification commands + +| Command | Expected after fixes | +|---------|---------------------| +| `cd server && go build .` | PASS | +| `cd agent && go build .` | PASS | +| `cd server/web && npm run build` | PASS | +| `run.bat` | Builds + starts `bin/miner-server.exe` | diff --git a/README.md b/README.md index 8247549..d2f94b2 100644 --- a/README.md +++ b/README.md @@ -1,155 +1,228 @@ -# Private Miner Command Deck +# AetherForge -Private Monero (XMR) fleet control server for your own network. Run the control server on one Windows machine, configure pool/wallet/defaults in the web dashboard, build per-machine worker `.exe` files, and deploy them across your LAN. +**Private Monero fleet command deck for machines you own.** + +One Windows control PC. One dashboard. Forge a worker installer per machine — or fuse it inside your own prep tool — and watch your entire LAN hash from a single steampunk-neon command deck. + +No pool hopping through third-party dashboards. No per-rig SSH babysitting. You run the server, you bake the binaries, you own the fleet. + +--- + +``` + ┌─────────────────────────────────────────────────────────────┐ + │ CALIBRATE (Settings) pool · wallet · alerts · limits │ + │ │ │ + │ ▼ │ + │ FORGE (Builder) per-worker .exe baked at compile │ + │ │ │ + │ ├──► Fusion? embed worker inside your prep.exe │ + │ │ │ + │ ▼ │ + │ WORKER PC RandomX on CPU · WebSocket home │ + │ │ │ + │ ▼ │ + │ COMMAND DECK live stats · remote ops · shares │ + └─────────────────────────────────────────────────────────────┘ +``` + +--- + +## What This Is + +AetherForge is a **self-hosted mining control plane** — not a cloud pool UI, not a generic miner wrapper. + +| Layer | What it does | +|-------|----------------| +| **Control server** | Go backend on port **8989** — REST API, WebSocket hub, SQLite fleet DB, Stratum proxy to your pool | +| **Command deck** | React dashboard — fleet overview, agent roster, forge builder, calibrate settings, field guide | +| **Worker agent** | Windows binary compiled on demand — mines RandomX, phones home, accepts remote commands | +| **Fusion** | Optional bundler — hides the worker inside **your** uploaded `prep.exe`, same icon, single deliverable | +| **Forge** | Compile-time config — wallet, pool, threads, stealth, persistence, firewall rules, AI autonomy flags | + +You configure defaults once in **Calibrate**. You forge once per machine in **Forge**. You run the output once on each worker. The agent installs, persists, connects, and shows up on the dashboard. + +--- + +## What You Get + +### Command Deck (Dashboard) +- Live fleet hashrate, CPU/RAM gauges, share feed +- Per-agent cards with pause / resume / stop / uninstall +- Fleet alerts (offline, hashrate drop, rejection spikes) +- Pool connection status, earnings estimate, AI activity panel + +### Fleet Roster (Agents) +- Every connected worker — hostname, IP, cores, memory, uptime +- Hashrate history charts +- Remote control panel — mining ops, recon commands, PowerShell terminal, file upload +- Agent log viewer (when file logging is enabled) + +### Forge (Miner Builder) +- Preflight cross-check before compile — wallet, server URL, pool, fusion, AI +- Blueprint save/load — re-forge the same profile across machines +- Build manager — download, paths, LAN QR for worker URL +- **Fusion mode** — upload prep, pick run order (`parallel` / `prep_first` / `worker_first`), output lands in **project root** with prep's icon when icon extraction succeeds +- Baked settings: thread mode, idle/scheduled mining, install path, stealth, self-healing watchdog, firewall exclusion + +### Calibrate (Settings) +- Server port, public URL, data retention, max agents +- Default pool + wallet for new forge forms +- Alert thresholds + Telegram / email notifications +- Open Windows Firewall for dashboard port on startup + +### Under the Hood +- **Stratum proxy** — workers submit through your server; one upstream pool connection per wallet/host +- **WebSocket hub** — agents and dashboard get live stats, jobs, alerts +- **Ollama AI autonomy** (optional) — server-side LLM decides restart / persistence / tunnel actions; workers call `/api/v1/agent/decide` +- **Retention jobs** — auto-purge old hashrate samples and stale build artifacts + +--- ## Quick Start -1. Install [Go 1.21+](https://go.dev/dl/) and [Node.js 20+](https://nodejs.org/) (or let `run.bat` install them). -2. Double-click **`run.bat`** on your control PC. -3. Open **http://YOUR-LOCAL-IP:8989** (shown when the server starts). -4. Go to **Settings** and set your wallet + pool. -5. Go to **Miner Builder**, enter a worker name, click **Build Installer .exe**. -6. Copy `install-{worker}.exe` to each Windows machine on your LAN and **run it once**. +**Requirements:** Windows 10/11 on control PC and workers. Outbound internet to your Monero pool. -Each installer: +1. Double-click **`run.bat`** in the project root. + It installs Go/Node if missing, builds the dashboard, compiles `bin\miner-server.exe`, copies web assets, and starts the server. -- Copies the miner to `%LOCALAPPDATA%\CryptoMiner\{worker}-{build}\miner.exe` -- Registers Windows auto-start (and optional scheduled task) -- Connects back to your dashboard at your **LAN IP:8989** -- Appears on the **Agents** and **Dashboard** pages automatically +2. Browser opens **http://localhost:8989** -## End Result +3. **Calibrate** → set your Monero wallet + pool + (optional) public URL for remote workers -| Piece | What it does | -|-------|----------------| -| Control PC | Runs the web dashboard on local IP + port **8989** | -| Dashboard | Configure pool/wallet/defaults, build installers, track all miners | -| `install-{name}.exe` | Single file you run once on each worker PC to install + start mining | +4. **Forge** → worker name + server URL (`http://YOUR-LAN-IP:8989` or your tunnel URL) → **Forge Installer** -| Component | Purpose | -|-----------|---------| -| `server/` | Go control server (REST API, WebSocket hub, pool proxy, builder) | -| `server/web/` | React dashboard (Dashboard, Agents, Builder, Settings) | -| `agent/` | Windows worker source compiled on demand by the builder | -| `data/` | SQLite DB, config, build output, logs | -| `run.bat` | One-click build + launch script | +5. Run the forged `.exe` **once** on each worker PC -## Workflow +6. Watch them appear on **Command Deck** and **Fleet Roster** + +### Output locations + +| Artifact | Where | +|----------|--------| +| Fused / forged exe (primary) | Project root — e.g. `G:\crypto miner\prep.exe` or `install-worker.exe` | +| Archive copy | `data\builds\{build-id}\` | +| Uninstall script | Same build folder + download API | +| Server config | `data\config.json` | +| Fleet database | `data\miner.db` | + +--- + +## Network Deployment + +| Scenario | Server URL in Forge | +|----------|---------------------| +| Same LAN | `http://192.168.x.x:8989` | +| Cloudflare / reverse tunnel | `https://your-domain.com` | + +Workers auto-convert `http(s)://` → `ws(s)://.../ws/agent`. Workers only need **outbound** access to your control URL — not inbound ports on each worker. + +--- + +## Project Layout ``` -Settings (dashboard) - -> data/config.json -Miner Builder (dashboard) - -> POST /api/v1/builder/build - -> compiles agent/ with baked-in config/builtin.go - -> writes data/builds/{build-id}/xmr-worker-{name}.exe -Worker .exe (target PC) - -> WebSocket ws://your-server:8989/ws/agent - -> receives jobs, mines with RandomX, submits shares -Control server - -> Stratum proxy to your configured pool - -> aggregates stats in dashboard +crypto miner/ +├── run.bat ← one-click build + launch +├── bin/ +│ └── miner-server.exe +├── data/ ← config, DB, builds, preps, logs +├── server/ ← Go control server +│ └── web/ ← React command deck (Vite) +├── agent/ ← Windows worker source (compiled by Forge) +├── fusion/ ← prep + worker bundler +├── PROBLEMS.md ← known issues audit (severity-ranked) +└── README.md ← you are here ``` -## Configuration +--- -All server settings are edited in the dashboard **Settings** page and saved to: +## API Surface (summary) -``` -data/config.json -``` - -The **Miner Builder** loads those values as defaults. Per-worker overrides (name, threads, silent mode, etc.) are baked into each `.exe` at compile time. - -### Built worker settings - -Each generated agent includes: - -- Server URL -- Wallet address -- Pool host/port/TLS/password -- Thread count, CPU priority, mining mode -- Max CPU %, minimum free RAM -- Idle/scheduled mining windows -- Silent mode, auto-start, run-as mode - -## Build Output Location - -After a successful build, the dashboard shows: - -- **Absolute path** — full Windows path to the `.exe` -- **Relative path** — path from the project root -- **Download link** — `/api/v1/builds/{id}/download` - -Example: - -``` -G:\crypto miner\data\builds\abc123...\xmr-worker-office-pc-1.exe -``` - -## API Endpoints - -| Method | Path | Description | -|--------|------|-------------| +| Method | Path | Purpose | +|--------|------|---------| | GET | `/api/v1/health` | Health check | -| GET/PUT | `/api/v1/config` | Server settings | -| POST | `/api/v1/builder/build` | Build worker `.exe` (returns JSON with file path) | -| GET | `/api/v1/builds` | List recent builds | -| GET | `/api/v1/builds/{id}/download` | Download a built `.exe` | -| GET | `/api/v1/agents` | List connected workers | -| GET | `/api/v1/dashboard/stats` | Fleet stats | +| GET/PUT | `/api/v1/config` | Calibrate settings | +| POST | `/api/v1/builder/build` | Forge worker (multipart if Fusion) | +| GET | `/api/v1/builds/{id}/download` | Download forged exe | +| GET | `/api/v1/agents` | Fleet list | +| POST | `/api/v1/agents/{id}/command` | Remote action (pause, powershell, …) | | WS | `/ws/agent` | Worker connection | -| WS | `/ws/dashboard` | Live dashboard updates | +| WS | `/ws/dashboard` | Live dashboard feed | -## Manual Commands +Full route list: `server/internal/api/router.go` + +--- + +## Manual Build (if you skip run.bat) ```bat -cd server -go build -o ..\bin\miner-server.exe . - cd server\web npm install npm run build -cd agent -go build -o xmr-worker-test.exe . -``` +cd ..\.. +cd server +go build -o ..\bin\miner-server.exe . -Run server manually: - -```bat bin\miner-server.exe -port 8989 -data .\data ``` -## Network Deployment +--- -- **Same LAN:** set Server URL in Builder to `http://YOUR-PC-IP:8989` -- **Remote access:** put the server behind Cloudflare Tunnel or similar and use your HTTPS domain as Server URL (`https://pool.example.com`) +## Known Issues -Workers convert `http(s)://...` to `ws(s)://.../ws/agent` automatically. +See **[PROBLEMS.md](PROBLEMS.md)** for a severity-ranked audit (build blockers, auth gaps, AI bugs, open items). Check there before production use on a large fleet. -## Data Files +--- -| Path | Contents | -|------|----------| -| `data/miner.db` | Agents, shares, hashrate history, build records | -| `data/config.json` | Server + default agent settings | -| `data/builds/` | Generated worker executables | -| `data/logs/` | Server logs (if enabled) | +# ⚠ LEGAL & FAIR USE WARNING -## Security Notes +**Read this before you deploy anything.** -- This project is intended for **your own machines on your own network**. -- Windows Defender may flag freshly compiled mining executables. Code-signing and Defender exclusions on managed machines are the legitimate mitigation paths. -- Do not expose the dashboard to the public internet without authentication. +### Authorized use only -## Requirements +AetherForge is designed and intended for **computers and networks you own or explicitly administer** — your home lab, your office fleet, machines where **you** have authority to install software and consume CPU resources. -- Windows 10/11 (control server and workers) -- Go 1.21+ -- Node.js 20+ (for dashboard build only) -- Outbound internet to your chosen Monero pool +By using this software you agree that: + +1. **You will only deploy workers on systems you control** or have **written permission** to manage. +2. **You will not** install, fuse, or distribute forged binaries on third-party machines, public terminals, shared computers, or any system without the owner's informed consent. +3. **You will not** use Fusion, stealth modes, persistence, remote execution, or spread-related features to deceive users about what software is running on their hardware. +4. **You are solely responsible** for compliance with local laws, employment policies, ISP terms, pool rules, and tax obligations related to cryptocurrency mining. + +### What this is NOT + +- **Not** a tool for unauthorized access, lateral movement, or deployment on machines you do not own. +- **Not** malware — but **misuse can make it indistinguishable from malware** under law and antivirus heuristics. Freshly compiled miners and fused executables **will** trigger Defender and AV products on unmanaged systems. +- **Not** anonymous or untraceable. Mining connects to pools, leaves logs, and generates network traffic attributable to you. + +### Pool & earnings + +- Use a **valid Monero wallet address you control**. +- Pool operators set their own terms — hashrate, rejected shares, and payout policies are between you and the pool. +- This project does not guarantee profitability, uptime, or pool compatibility. + +### Security responsibility + +- The dashboard and API **ship without authentication** by default. **Do not** expose port 8989 to the public internet without adding your own access controls (VPN, firewall allowlist, reverse proxy auth). +- Remote command features (`powershell`, `exec`, file upload) are **full control** of a worker. Treat your control server like root access to every machine in the fleet. +- Code signing, Defender exclusions, and network segmentation on **your** infrastructure are **your** job. + +### Disclaimer + +THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. THE AUTHORS AND CONTRIBUTORS ARE NOT LIABLE FOR ANY DAMAGES, LEGAL ACTION, POOL BANS, DATA LOSS, HARDWARE DAMAGE, OR MISUSE BY YOU OR ANY THIRD PARTY. + +**If you cannot accept these terms, do not run AetherForge.** + +--- ## License Private use. Monero mining uses the RandomX algorithm (BSD-3-Clause) via `git.gammaspectra.live/P2Pool/go-randomx`. + +--- + +
+ AetherForge — LAN MINING COMMAND
+ Calibrate · Forge · Deploy · Command
+
Drag & Drop payload here
- Silently uploads to C:\Windows\Temp\ +Drag & Drop file here
+ Uploads to C:\Windows\Temp\