Quick Start

Get Running in Minutes

One command. Interactive feature selection. Onion address generated in under 90 seconds on a clean Debian 13 system.

bash โ€” install
$ git clone https://github.com/ashardian/OnionSite-Aegis.git
$ cd OnionSite-Aegis
$ chmod +x install.sh
$ sudo ./install.sh
bash โ€” get onion address
$ sudo cat /var/lib/tor/hidden_service/hostname
Cloud VPS users: When the installer asks "Allow SSH Access? [y/N]" โ€” answer y. If you answer no, nftables will drop all inbound connections including your SSH session and you will be locked out.
Back up your keys immediately after install. Losing /var/lib/tor/hidden_service/ means losing your onion address permanently โ€” there is no recovery. Run sudo ./SAVE_MY_ONION.sh now.
Requirements

System Requirements

Aegis v10.0 is a bare-metal-only tool. Docker support was permanently removed because it conflicts with kernel-level sysctl hardening, NFTables management, Tor Sandbox mode, and tmpfs RAM logging.

Operating System
Debian 13 Trixie
Also Parrot OS, Debian 11+
Privileges
root required
Modifies kernel, systemd, and firewall
Disk Space
500MB minimum
Logs stay in RAM โ€” disk mainly for packages
RAM
512MB+
10MB reserved for tmpfs log disk
Network
Internet access
WAF config + unicode.mapping downloaded from GitHub
Tor Service Unit
tor@default
Auto-detected on Debian 13. Classic tor also supported.
Deployment Type
Dedicated machine or VM
Do not share host with other services
bash โ€” verify your system
cat /etc/os-release    # Check distro
df -h /               # Check disk space
free -h               # Check RAM
whoami                # Must be root or sudo capable
Installation

Full Installation Guide

The Architect Installer is fully interactive. Every feature can be toggled independently. Here is what happens at each step.

Download the repository

Clone from GitHub or unzip the release archive into any directory.

bash
git clone https://github.com/ashardian/OnionSite-Aegis.git && cd OnionSite-Aegis

Run the installer as root

The installer will auto-detect your Tor service unit (tor or tor@default) and your system's nginx module paths before doing anything.

bash
chmod +x install.sh && sudo ./install.sh

Answer the interactive prompts

Press Enter to accept the default (Yes) for each module, or type n to disable. All defaults are production-recommended.

ModSecurity WAF
Y (default)
Disable only if RAM < 256MB
Lua Response Padding
Y (default)
Always recommended
Neural Sentry IPS
Y (default)
Disable if Python unavailable
Privacy Monitor
Y (default)
Never disable
Traffic Analysis Protection
Y (default)
Never disable
SSH Access
N (default)
Enable only on Cloud VPS

Identity wipe decision

If a previous hidden service exists, the installer prompts you to type wipe for a new address or press Enter to preserve the existing one.

Wait for onion address generation

The installer waits up to 60 seconds for Tor to generate /var/lib/tor/hidden_service/hostname. Your address is printed on success.

What the installer does internally

  • Sanitize โ€” Stops all services, removes all Nginx configs, moves old module symlinks to a backup dir, optionally wipes hidden service keys.
  • Dependencies โ€” Installs tor, nginx, nftables, python3-stem, python3-inotify, libmodsecurity3, libnginx-mod-http-modsecurity, libnginx-mod-http-lua via apt.
  • RAM Logging โ€” Mounts a 10MB tmpfs at /var/log/tor with mode 0700, owned by debian-tor. No logs ever touch disk.
  • Tor hardening โ€” Writes a hardened /etc/tor/torrc with SafeLogging, AvoidDiskWrites, V3 hidden service, cookie auth on control port.
  • Nginx architecture โ€” Links modules in correct load order (NDK โ†’ Lua โ†’ WAF), builds site config with WAF and Lua directives, downloads unicode.mapping, rewrites SecUnicodeMapFile to absolute path, validates with nginx -t before firewall applies.
  • Firewall โ€” Deploys balanced NFTables ruleset, optionally uncomments SSH rule, validates with nft -c before applying.
  • Services โ€” Deploys neural-sentry.service, privacy-monitor.timer, traffic-protection.service as systemd units with correct dependencies.
  • Bootstrap โ€” Restarts Tor and nginx, waits for onion address, prints result.
Post-Installation

After the Install Completes

Verify services, add your content, and back up your keys.

bash โ€” verify all services
sudo systemctl status tor@default    # Real Tor process on Debian 13
sudo systemctl status nginx
sudo systemctl status neural-sentry
sudo systemctl status privacy-monitor.timer
sudo systemctl status traffic-protection.service

sudo mount | grep tmpfs | grep tor   # Confirm RAM logging active
sudo ls -la /var/lib/tor/hidden_service/  # Keys + hostname
sudo nginx -t                         # Confirm WAF config OK
bash โ€” add your website content
sudo aegis-edit                      # Built-in nano editor + auto-reload

# Or copy a full site manually:
sudo cp -r /path/to/your/site/* /var/www/onion_site/
sudo chown -R www-data:www-data /var/www/onion_site
sudo systemctl reload nginx
bash โ€” backup keys (do this now)
sudo ./SAVE_MY_ONION.sh              # Built-in backup tool

# Manual alternative:
sudo tar -czf onion-backup-$(date +%Y%m%d).tar.gz /var/lib/tor/hidden_service/
Neural Sentry

Neural Sentry IPS

An active-defense Python daemon that monitors your Tor control port in real time and kills circuits the moment an attack signature is detected.

How it works

  • Connects to the Tor control port at 127.0.0.1:9051 using cookie authentication via python3-stem.
  • Monitors the rate of new circuit creation. A sudden spike is the primary signature of a DDoS or circuit-flooding attack.
  • On detection, sends a NEWNYM signal โ€” forcing Tor to rotate all circuits and sever the attacker's connection path instantly.
  • Uses python3-inotify for file integrity monitoring โ€” any unexpected change to the web root or config files triggers an alert.
  • All sentry events logged to /var/log/tor/sentry.log โ€” inside the RAM disk, wiped on reboot.
ParameterValue
Systemd unitneural-sentry.service
Control interface127.0.0.1:9051
Auth methodCookie (CookieAuthentication 1)
Log file/var/log/tor/sentry.log (RAM)
Restart policyalways
Runs asroot
bash โ€” manage neural sentry
sudo systemctl status neural-sentry
sudo journalctl -u neural-sentry -f
sudo tail -f /var/log/tor/sentry.log
ModSecurity WAF

ModSecurity Web Application Firewall

Full ModSecurity v3 integrated into nginx. Blocks SQLi, XSS, shell uploads, and other application-layer attacks before they reach Tor.

unicode.mapping fix: modsecurity.conf-recommended references unicode.mapping via a relative path. Aegis downloads it automatically and rewrites SecUnicodeMapFile to an absolute path โ€” fixing the nginx startup crash that affected older installs.

Installation details

  • Package: libnginx-mod-http-modsecurity + libmodsecurity3
  • Config downloaded from SpiderLabs/ModSecurity GitHub (v3 master branch)
  • unicode.mapping downloaded to /etc/nginx/modsec/ alongside the conf
  • SecRuleEngine DetectionOnly rewritten to SecRuleEngine On (blocking mode)
  • Main rules file: /etc/nginx/modsec/main.conf โ†’ includes modsecurity.conf
  • Nginx site config includes modsecurity on and modsecurity_rules_file directives
bash โ€” verify WAF
nginx -t                             # Config test โ€” must pass
ls /etc/nginx/modsec/               # Should show modsecurity.conf + unicode.mapping
grep "SecRuleEngine" /etc/nginx/modsec/modsecurity.conf  # Should say "On"
bash โ€” if unicode.mapping is missing (older installs)
sudo wget https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v3/master/unicode.mapping \
    -O /etc/nginx/modsec/unicode.mapping
sudo sed -i "s|SecUnicodeMapFile unicode.mapping|SecUnicodeMapFile /etc/nginx/modsec/unicode.mapping|g" \
    /etc/nginx/modsec/modsecurity.conf
sudo nginx -t && sudo systemctl reload nginx
NFTables Firewall

Balanced NFTables Firewall

Previous versions used aggressive rate limiting that blocked Tor's own directory fetches, causing "Onion Site Not Found" on first launch. v10.0 uses stateful tracking โ€” Tor sees everything it needs, attackers see nothing.

Ruleset logic

  • Loopback always accepted โ€” nginx and Tor communicate over localhost. This chain must never be blocked.
  • ct state established,related accept โ€” Replies to Tor's outbound connections are always allowed. This is what broke in old versions.
  • ct state invalid drop โ€” Malformed packets dropped before they consume resources.
  • ICMP rate limited โ€” 5 packets/second. Ping works but ICMP flood does not.
  • Default: DROP โ€” All unsolicited inbound connections dropped. Port scanners see nothing.
  • Forward: DROP โ€” The server cannot be used as a router or relay.
  • Output: ACCEPT โ€” Tor needs unrestricted outbound to reach the network.
nftables โ€” current ruleset structure
table inet filter {
    chain input {
        type filter hook input priority 0; policy drop;
        iifname "lo" accept                           # loopback
        ct state established,related accept           # Tor replies
        ct state invalid drop                         # malformed
        ip protocol icmp ... limit rate 5/second accept
        # tcp dport 22 accept  โ† SSH Safety Valve (disabled by default)
        log prefix "FIREWALL-DROP: " drop
    }
    chain forward { policy drop; }
    chain output  { policy accept; }
}
bash โ€” inspect live rules
sudo nft list ruleset
sudo nft list table inet filter
sudo journalctl -k | grep "FIREWALL-DROP"  # See what's being dropped
Emergency firewall reset โ€” if you are locked out on a VPS, use your provider's web console and run sudo nft flush ruleset, then re-run the installer with SSH enabled.
Anti-Forensics

Amnesic Logging Architecture

Every log is stored in volatile RAM. Power loss or reboot is a full forensic wipe. No persistent evidence of traffic ever exists on disk.

RAM disk setup

  • /var/log/tor mounted as tmpfs โ€” 10MB, mode 0700, owned by debian-tor
  • Tor configured with AvoidDiskWrites 1 โ€” minimizes state written to persistent storage
  • SafeLogging 1 in torrc โ€” IPs replaced with safe placeholders at Tor level
  • privacy_log_sanitizer.py runs via Privacy Monitor โ€” scrubs any remaining IPs or hostnames from RAM logs
Reboot caveat: The tmpfs mount is not written to /etc/fstab. After a reboot, /var/log/tor reverts to disk-backed storage. For persistent RAM-only logging, add an fstab entry or create a systemd .mount unit manually.
bash โ€” persistent tmpfs via fstab (optional)
# Add to /etc/fstab for persistence across reboots:
tmpfs /var/log/tor tmpfs size=10M,mode=0700,uid=debian-tor,gid=debian-tor 0 0
bash โ€” verify RAM logging is active
sudo mount | grep tmpfs | grep tor    # Should show the tmpfs mount
sudo df -h /var/log/tor              # Should show tmpfs filesystem
Anti-Tracking

Traffic Analysis & Tracking Protection

Multiple independent layers defeat every known traffic correlation and fingerprinting technique. Even an observer watching both ends of the Tor circuit cannot correlate requests to your server.

Response Size Padding

A Lua script at the nginx body_filter_by_lua_file phase pads all HTTP responses to random block sizes using null bytes. An observer monitoring response sizes cannot distinguish page content from padding โ€” all responses look similar.

Timing Randomization

10โ€“50ms random delay is injected per response. Timing-correlation attacks that rely on consistent server latency โ€” even inside encrypted Tor circuits โ€” are defeated at the application layer before the response is sent.

Header Scrubbing

The following headers are removed entirely: Server, X-Powered-By, ETag, Last-Modified, X-Request-ID, X-Forwarded-For, Via. server_tokens off provides a second layer of version concealment. Fingerprinting the nginx version or platform from response headers is impossible.

Cache Prevention

Cache-Control: no-store, no-cache and Clear-Site-Data headers prevent browser-side caching that could be used for tracking across sessions.

Protection Matrix

Attack VectorProtectionStatus
Response size correlationLua response paddingโœ“ Blocked
Timing correlation10โ€“50ms jitterโœ“ Blocked
DNS leaksDNS blocked via firewallโœ“ Blocked
Server fingerprintingHeader removalโœ“ Blocked
ETag trackingETag removedโœ“ Blocked
Cache-based trackingCache-Control headersโœ“ Blocked
Log analysisRAM logs + sanitizerโœ“ Blocked
Memory dumpsCore dumps disabledโœ“ Blocked
Client-side JS fingerprintingN/A โ€” client-sideOut of scope
Tor guard node compromiseN/A โ€” Tor network levelOut of scope
bash โ€” test response padding
# Response sizes should vary (random padding)
for i in {1..5}; do
    curl -s -o /dev/null -w "%{size_download}\n" http://127.0.0.1/
done

# No identifying headers should appear:
curl -I http://127.0.0.1/ | grep -i "server\|etag\|last-modified\|x-powered"
Privacy Monitor

Automated Privacy Compliance Monitor

A systemd timer that continuously verifies your privacy posture โ€” not just at install time, but throughout the life of the service.

ParameterValue
Timer unitprivacy-monitor.timer
Service unitprivacy-monitor.service (Type=oneshot)
IntervalEvery 10 minutes
Boot delay2 minutes after boot
Script/usr/local/bin/privacy_monitor.sh

What it checks

  • tmpfs RAM disk is still mounted at /var/log/tor
  • nginx is not leaking Server or version identifiers in responses
  • Disk-backed log files that should not exist are flagged and removed
  • Runs privacy_log_sanitizer.py to scrub IPs and hostnames from RAM log entries
bash โ€” manage privacy monitor
sudo systemctl status privacy-monitor.timer
sudo systemctl list-timers | grep privacy       # See next run time
sudo /usr/local/bin/privacy_monitor.sh          # Run manually
sudo journalctl -u privacy-monitor.service      # View last run output
Maintenance

Maintenance Commands

Day-to-day commands for operating a live Aegis deployment.

bash โ€” edit website
sudo aegis-edit          # Opens nano, fixes ownership, reloads nginx on save
bash โ€” monitor system (live HUD)
sudo ./aegis_monitor.sh  # Real-time threat and health dashboard
bash โ€” view logs
sudo journalctl -u tor@default -f       # Live Tor log
sudo tail -f /var/log/tor/notices.log  # Tor notices (RAM)
sudo tail -f /var/log/tor/sentry.log   # Neural Sentry events
sudo journalctl -u nginx -f            # nginx
bash โ€” update nginx config
sudo nano /etc/nginx/sites-available/onion_site
sudo nginx -t                        # Always validate first
sudo systemctl reload nginx
bash โ€” update tor config
sudo nano /etc/tor/torrc
sudo systemctl restart tor@default
bash โ€” full backup
sudo tar -czf aegis-backup-$(date +%Y%m%d).tar.gz \
    /var/lib/tor/hidden_service/ \
    /etc/tor/torrc \
    /etc/nginx/sites-available/onion_site \
    /var/www/onion_site
bash โ€” uninstall
sudo ./uninstall.sh
Troubleshooting

Common Issues & Fixes

Solutions to every known installation and runtime issue.

nginx fails โ€” unicode.mapping not found

Error: Failed to locate the unicode map file from: unicode.mapping

fix
sudo wget https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v3/master/unicode.mapping \
    -O /etc/nginx/modsec/unicode.mapping
sudo sed -i "s|SecUnicodeMapFile unicode.mapping|SecUnicodeMapFile /etc/nginx/modsec/unicode.mapping|g" \
    /etc/nginx/modsec/modsecurity.conf
sudo nginx -t && sudo systemctl restart nginx

Tor shows "active (exited)" on Debian 13

On Debian 13, tor.service is a dummy master unit (ExecStart=/bin/true). The real process is tor@default.service.

fix
sudo systemctl status tor@default    # Check the real unit
sudo systemctl restart tor@default
sudo cat /var/lib/tor/hidden_service/hostname

"Onion Site Not Found" in Tor Browser

Brand-new v3 addresses take 2โ€“5 minutes to propagate to HSDir nodes. This is normal.

check
sudo systemctl status tor@default nginx
sudo cat /var/lib/tor/hidden_service/hostname   # Verify address
curl -v http://127.0.0.1/                       # nginx responding locally?

SSH lockout after install

You answered No to SSH access on a VPS. Use your provider's web console (VNC/KVM), then:

emergency fix
sudo nft flush ruleset               # Remove all firewall rules
sudo ./install.sh                    # Re-run, answer Y to SSH

nginx fails โ€” Lua "undefined symbol: ndk_set_var_value"

Module load order issue. NDK must load before Lua.

fix
sudo ln -sf /usr/share/nginx/modules-available/mod-http-ndk.conf \
    /etc/nginx/modules-enabled/10-ndk.conf
sudo ln -sf /usr/share/nginx/modules-available/mod-http-lua.conf \
    /etc/nginx/modules-enabled/20-lua.conf
sudo systemctl restart nginx

Hidden service not created after 60 seconds

fix
sudo chown -R debian-tor:debian-tor /var/lib/tor/hidden_service
sudo chmod 700 /var/lib/tor/hidden_service
sudo systemctl restart tor@default
sleep 15 && sudo cat /var/lib/tor/hidden_service/hostname
File Locations

Important File Locations

Quick reference for every file path used by the Aegis stack.

/var/lib/tor/hidden_service/hostnameYour .onion address
/var/lib/tor/hidden_service/Tor keys โ€” back these up
/var/www/onion_site/Web root โ€” your site content
/var/log/tor/Logs โ€” tmpfs RAM disk (wiped on reboot)
/etc/tor/torrcTor configuration
/etc/nginx/sites-available/onion_siteNginx site config
/etc/nginx/nginx.confNginx base config
/etc/nginx/modsec/modsecurity.confModSecurity rules config
/etc/nginx/modsec/unicode.mappingModSecurity unicode map (required)
/etc/nginx/lua/response_padding.luaLua response padding script
/etc/nftables.confNFTables firewall ruleset
/usr/local/bin/neural_sentry.pyNeural Sentry daemon
/usr/local/bin/privacy_monitor.shPrivacy compliance checker
/usr/local/bin/traffic_analysis_protection.shTraffic analysis countermeasures
/usr/local/bin/aegis-editBuilt-in content editor
/var/log/aegis_install.logFull installer log
Changelog

Version History

Every significant change across the Aegis release history.

v10.0 Bare Metal Edition Current

  • Docker removed permanently โ€” incompatible with sysctl hardening, NFTables, Tor Sandbox mode, and tmpfs RAM logging.
  • detect_tor_service() โ€” reads ExecStart property to distinguish Debian 13's dummy tor.service from the real tor@default.service.
  • INSTALL_DIR fix โ€” changed from $(pwd) to BASH_SOURCE-based resolution. Works when called from any directory.
  • set -E โ€” ERR trap now fires inside functions and subshells. No silent failures.
  • Privacy monitor systemd timer โ€” runs automatically every 10 minutes. No manual execution needed.
  • Uninstaller updated โ€” removes all systemd units including privacy-monitor.timer, traffic-protection.service.
  • unicode.mapping auto-download โ€” fixes nginx startup crash from missing SecUnicodeMapFile.
  • Pre-firewall nginx validation โ€” nginx config verified before nftables applied, preventing lockout on bad config.

v9.0 Architect Edition

  • Balanced NFTables โ€” replaced aggressive rate limiting with stateful ct state established,related. Fixed "Onion Site Not Found" at launch.
  • SSH Safety Valve โ€” interactive prompt prevents VPS lockout during installation.
  • Session HUD โ€” aegis_monitor.sh v5.0 with live CPU/RAM for Tor and nginx, real-time threat feed.
  • Variable initialization โ€” fixed unary operator expected crashes on strict bash installs.

v7/v8 Early Versions

  • Dual Docker + bare metal deployment. Docker later removed due to fundamental incompatibilities.
  • Neural Sentry v1โ€“v4. Basic NFTables with aggressive rate limiting that caused Tor blockages.
  • Manual privacy monitor โ€” users had to remember to run it.

Version Comparison

Feature
v7/v8
v9.0
v10.0
Docker support
โœ“
โœ“
Removed
Tor service auto-detect
โœ—
โœ—
โœ“
BASH_SOURCE path fix
โœ—
โœ—
โœ“
set -E error propagation
โœ—
โœ—
โœ“
Privacy monitor auto-run
โœ—
โœ—
โœ“ timer
unicode.mapping auto-deploy
โœ—
โœ—
โœ“
Pre-firewall nginx check
โœ—
โœ—
โœ“
SSH Safety Valve
โœ—
โœ“
โœ“
Balanced NFTables
โœ—
โœ“
โœ“
Amnesic RAM logging
โœ“
โœ“
โœ“
Neural Sentry
โœ“
โœ“
โœ“
Threat Model

What Aegis Protects Against

Aegis is designed around a specific, realistic threat model. Understanding it helps you know exactly what is and is not protected.

Protected โ€” Server Side

  • Traffic analysis via response size correlation
  • Timing correlation attacks
  • DNS leakage outside Tor
  • Server fingerprinting via response headers
  • Application-layer attacks (SQLi, XSS) via ModSecurity WAF
  • DDoS / circuit flooding via Neural Sentry NEWNYM
  • Forensic log analysis โ€” RAM-only logging, IP sanitization
  • Memory dumps โ€” core dumps disabled
  • Port scanning โ€” default DROP policy
  • Cache-based tracking via cache-control headers

Out of Scope โ€” Client Side & Physical

  • Browser fingerprinting โ€” JavaScript and client-side tracking are outside server control
  • User behaviour โ€” typing patterns, mouse movements, session habits
  • Tor guard node compromise โ€” a global adversary who controls the first hop
  • Physical seizure โ€” hardware attacks, cold boot (mitigated but not eliminated by RAM logs)
  • OPSEC failures โ€” publishing your address publicly, reusing identities, poor key management
Verification

Verification Report โ€” v10.0

Live deployment verified on Debian 13 Trixie. All components confirmed operational.

Status: STABLE โ€” VERIFIED ON LIVE DEBIAN 13 TRIXIE DEPLOYMENT
nginx active ยท tor@default active ยท ModSecurity WAF blocking ยท Onion address generated ยท Privacy Monitor running
install.sh
โœ“ Valid
bash -n syntax clean, all 6 bugs fixed
nginx + ModSecurity WAF
โœ“ Verified
Blocking mode, unicode.mapping resolved
tor@default.service
โœ“ Verified
Auto-detected on Debian 13
Onion address generation
โœ“ Verified
V3 address generated within 60s
tmpfs RAM logging
โœ“ Verified
/var/log/tor mounted as tmpfs
NFTables firewall
โœ“ Verified
Balanced ruleset, Tor unrestricted
neural-sentry.service
โœ“ Valid
Deploys if neural_sentry.py present
privacy-monitor.timer
โœ“ Valid
10-minute interval, 2min boot delay
traffic-protection.service
โœ“ Valid
RemainAfterExit, after nftables
uninstall.sh
โœ“ Valid
Removes all systemd units
OnionSite-Aegis
Created by ashardian
Released under MIT License.
v10.0 Bare Metal Edition ยท Debian 13 Trixie Verified