How toxichome-whoami/binary_alive works
Purpose and Deployment Model
Secure Binary Alive System is a PHP 7.4+ / SQLite control plane for keeping Linux executables alive on cPanel/WHM hosts. It manages arbitrary binaries (bots, Node applications, compiled programs), exposes browser and token APIs, and relies on a host cron invocation rather than a persistent PHP daemon.
Core deployment/security boundaries are Apache access rules in .htaccess, db/.htaccess, includes/.htaccess, and components/.htaccess; cron must execute cron.php once per minute.
Web Application Entry Points
index.php is the dashboard and likely primary process-management surface. Authentication lifecycle is handled through login.php, logout.php, and initial TOTP enrollment in setup_2fa.php.
Administrative pages include settings.php for system/security configuration, users.php for role-managed accounts, logs.php for audit-log viewing, and terminal.php for the admin browser shell. Shared UI composition is centralized in components/header.php, components/navbar.php, and components/footer.php.
Process Supervision Stage
cron.php is the autonomous supervision entry point. Each minute it evaluates configured monitored processes, detects stopped binaries or reboot-related loss, and restarts them. This is the critical boundary between the PHP application and operating-system process execution.
Interactive UI management and remote control can initiate start, stop, restart, creation, editing, deletion, and grouping of monitored processes; cron converges actual process state with the stored desired configuration.
Persistence and Configuration
SQLite access and schema/runtime persistence are centralized in includes/database.php, with the database protected beneath db/. Persistent records support users/roles, process definitions, audit events, API tokens, and application state.
config.json supplies deployment-level settings, notably IP allowlisting. This file is intentionally web-blocked by root .htaccess; it is a filesystem configuration boundary rather than an API-facing resource.
Identity, Authorization, and Security
includes/auth.php implements session authentication and RBAC, including the permanent first-account Master Admin hierarchy. Admin privileges gate sensitive operations such as account administration and terminal access.
includes/security.php provides request/security controls such as IP restrictions and headers. CAPTCHA is a separate challenge/check flow in captcha.php and captcha_check.php. TOTP/2FA behavior is supported by includes/totp_helper.php and exposed through setup_2fa.php.
API and External Control Boundary
api.php is the machine-facing entry point for remote process monitoring and control using API tokens. Its contract is documented in API.md. API actions share the same persistence, authorization/token validation, process-control, and audit pathways as browser actions.
There are no required external application services: runtime dependencies are PHP, SQLite, Apache/cPanel, Linux shell/process facilities, and cPanel cron.
Auditability and Shell Access
includes/logger.php records security- and operations-relevant events: authentication attempts, process lifecycle actions, terminal commands, and API key generation. logs.php exposes paginated audit history.
terminal.php is a high-risk administrative boundary: it runs server shell commands with a session-persistent working directory, command history, and a 30-second timeout guard. It must remain constrained by admin RBAC and audited through the logging layer.
Main entry points: auth.php Session auth & RBAC · settings.php Admin pages · api.php Token API · logger.php Audit logger
Components 16
Web & API
- Dashboard · Primary process-management surface.
index.php - Auth lifecycle · Login, logout, and initial 2FA enrollment.
login.php - Admin pages · Settings, users, logs, and terminal access.
settings.php - Token API · Remote process monitoring and control entry point.
api.php - API contract
API.md - Apache access rules · Blocks protected application, database, and configuration resources.
.htaccess
Application Core
- Session auth & RBAC · Enforces roles, including the Master Admin hierarchy.
includes/auth.php - Request security · Applies IP restrictions and security headers.
includes/security.php - TOTP support
includes/totp_helper.php - CAPTCHA flow
captcha.php - Process control · Changes desired state for monitored binaries.
- Audit logger · Records authentication, process, terminal, and API events.
includes/logger.php - SQLite persistence · Stores users, process definitions, tokens, audit events, and state.
includes/database.php - Deployment config · Provides settings including IP allowlisting.
config.json
Host Runtime
- Minute supervisor · Converges configured process state and restarts stopped binaries.
cron.php - Linux processes · Executes and hosts monitored binaries and terminal commands.
Connections 22
- Dashboard → Session auth & RBAC: session auth
- Dashboard → Request security: protected requests
- Dashboard → Process control: manage processes
- Auth lifecycle → Session auth & RBAC: authenticate
- Auth lifecycle → TOTP support: enroll 2FA
- Auth lifecycle → CAPTCHA flow: challenge
- Admin pages → Session auth & RBAC: admin RBAC
- Admin pages → Audit logger: view audit history
- Admin pages → Linux processes: admin shell commands
- Token API → Session auth & RBAC: validate API token
- Token API → Process control: remote control
- Token API → Audit logger: audit actions
- API contract → Token API: documents
- Request security → Deployment config: IP allowlist
- Session auth & RBAC → SQLite persistence: users and tokens
- Process control → SQLite persistence: desired definitions
- Process control → Linux processes: start / stop / restart
- Audit logger → SQLite persistence: audit events
- Minute supervisor → SQLite persistence: read desired state
- Minute supervisor → Linux processes: detect and restart
- Admin pages → Audit logger: terminal audit
- Apache access rules → Deployment config: web-blocked