···11+# Mini-Hack Quick Start Guide
22+33+## Network Topology
44+55+```
66+External Network (172.20.0.0/16)
77+├── Kali External: 172.20.2
88+├── Router External: 172.20.<team>.1
99+└── Scoring Server: 172.20.1
1010+1111+Internal Network (192.168.<team>.0/24)
1212+├── Router Internal: 192.168.<team>.1
1313+├── Ubuntu Web Server: 192.168.<team>.2
1414+└── Kali Internal: 192.168.<team>.100
1515+```
1616+1717+**Your team number** is randomly assigned on each deployment (e.g., 213, 195, etc.)
1818+1919+## Objectives (Turn Lights Green)
2020+2121+1. ✅ Router online - responds to ping on external IP
2222+2. ✅ Web server accessible - HTTP traffic routes through router to internal server
2323+3. ✅ Service running - Apache returns content from internal web server
2424+2525+## Step-by-Step Checklist
2626+2727+### 1. Find Your Team Number
2828+2929+**On Kali External**:
3030+```bash
3131+ip addr show # Look for 172.20.X
3232+# If you see 172.20.2, your team number is 2
3333+# Check scoreboard at http://172.20.1 for confirmation
3434+```
3535+3636+### 2. Configure Router
3737+3838+**Login to MikroTik** (via ProxMox console or SSH):
3939+```bash
4040+# Default login
4141+admin
4242+<press Enter for blank password>
4343+4444+# Set a password when prompted
4545+<choose password>
4646+```
4747+4848+**Assign IP addresses**:
4949+```bash
5050+# External interface
5151+/ip address add address=172.20.<team>.1/16 interface=ether3
5252+5353+# Internal interface
5454+/ip address add address=192.168.<team>.1/24 interface=ether4
5555+5656+# Verify
5757+/ip address print
5858+```
5959+6060+**Or use Web GUI**: `http://172.20.<team>.1:8080`
6161+- Login: `admin` / `<your password>`
6262+- Go to **Quick Set**
6363+- Enter external IP: `172.20.<team>.1/16`
6464+- Enter internal IP: `192.168.<team>.1/24`
6565+- ✅ **Check "Enable NAT"** (required!)
6666+- Click **Apply Configuration**
6767+6868+### 3. Configure Ubuntu Web Server
6969+7070+**Assign static IP**:
7171+```bash
7272+sudo nano /etc/netplan/01-network-manager-all.yaml
7373+```
7474+7575+```yaml
7676+network:
7777+ version: 2
7878+ ethernets:
7979+ ens18:
8080+ addresses:
8181+ - 192.168.<team>.2/24
8282+ routes:
8383+ - to: default
8484+ via: 192.168.<team>.1
8585+```
8686+8787+```bash
8888+sudo netplan apply
8989+ip addr show # Verify IP
9090+ping 192.168.<team>.1 # Test router connectivity
9191+```
9292+9393+**Start Apache**:
9494+```bash
9595+sudo systemctl restart apache2
9696+sudo systemctl status apache2 # Should show "active (running)"
9797+```
9898+9999+**Test locally**:
100100+```bash
101101+curl http://192.168.<team>.2 # Should return HTML
102102+```
103103+104104+### 4. Configure Port Forwarding (Router)
105105+106106+**Web GUI Method** (recommended):
107107+```
108108+http://172.20.<team>.1:8080
109109+```
110110+111111+1. Go to **Quick Set** → **Port Mapping**
112112+2. Click **New**
113113+ - Name: `www-tcp`
114114+ - Protocol: `TCP`
115115+ - Port: `80`
116116+ - Forward To: `192.168.<team>.2`
117117+ - Port: `80`
118118+3. Click **OK**
119119+4. Repeat for UDP:
120120+ - Name: `www-udp`
121121+ - Protocol: `UDP`
122122+ - Port: `80`
123123+ - Forward To: `192.168.<team>.2`
124124+ - Port: `80`
125125+126126+### 5. Test From External Network
127127+128128+**On Kali External**:
129129+```bash
130130+ping 172.20.<team>.1 # Router should respond
131131+curl http://172.20.<team>.1 # Should show web content from internal server
132132+```
133133+134134+**Check scoreboard**: `http://172.20.1`
135135+136136+All lights should be green!
137137+138138+## Quick Troubleshooting
139139+140140+| Problem | Check |
141141+|---------|-------|
142142+| Router not pingable | Verify IP on ether3: `/ip address print` |
143143+| Web not accessible | 1. Is Apache running? 2. Did you enable NAT? 3. Port forwarding rules exist? |
144144+| Internal server can't reach router | Check internal IP on ether4, verify gateway in netplan |
145145+| Lights still red | Wait 30 seconds for scoring refresh, check exact IPs match topology |
146146+147147+## Configuration Files Reference
148148+149149+**Router**: Web GUI at `http://172.20.<team>.1:8080` or CLI via console
150150+151151+**Ubuntu Web Server**:
152152+- Network: `/etc/netplan/01-network-manager-all.yaml`
153153+- Apache: `sudo systemctl restart apache2`
154154+- Website content: `/var/www/html/`
155155+156156+**Kali Machines**: For testing only, no configuration needed
157157+158158+## Common Mistakes
159159+160160+❌ Forgot to enable NAT on router
161161+❌ Port forwarding only has TCP rule (need UDP too)
162162+❌ Wrong team number in IP addresses
163163+❌ Apache not started on Ubuntu
164164+❌ Netplan syntax error (YAML is whitespace-sensitive)
165165+❌ Router interface names wrong (check with `interface print`)
166166+167167+## Time-Saving Tips
168168+169169+1. Use **web GUI for router** - faster than CLI for NAT/port forwarding
170170+2. Copy/paste team number once you know it - avoid typos
171171+3. Test each step before moving on (ping, curl, status checks)
172172+4. If stuck, verify each light's requirement on scoreboard
+59
01-services-overview.md
···11+# Linux Services - General Approach
22+33+## Service Configuration Checklist
44+55+When encountering any new service:
66+77+1. **Understand what it does** - Don't rush into clicking buttons. Read documentation first. Even 5 minutes of research saves time later.
88+99+2. **Locate configuration files** - Services usually have config files in `/etc`. Files can be singular or multiple across different locations (main config + user-specific).
1010+1111+3. **Backup before changes** - Always copy config files before modifying:
1212+ ```bash
1313+ sudo cp /etc/service/config /etc/service/config.bak
1414+ ```
1515+1616+4. **Restart after changes** - Most services require restart for changes to take effect:
1717+ ```bash
1818+ sudo systemctl restart <service-name>
1919+ ```
2020+ Don't restart the entire computer - restart just the service.
2121+2222+5. **Check service status** - Verify if service is running:
2323+ ```bash
2424+ systemctl status <service-name>
2525+ ```
2626+2727+6. **Dependencies matter** - Some services rely on others. Changing one may require restarting dependent services.
2828+2929+## Service Management Commands
3030+3131+Check service status (no sudo needed):
3232+```bash
3333+systemctl status <service-name>
3434+```
3535+3636+Start a service:
3737+```bash
3838+sudo systemctl start <service-name>
3939+```
4040+4141+Stop a service:
4242+```bash
4343+sudo systemctl stop <service-name>
4444+```
4545+4646+Restart a service:
4747+```bash
4848+sudo systemctl restart <service-name>
4949+```
5050+5151+Enable service to start on boot:
5252+```bash
5353+sudo systemctl enable <service-name>
5454+```
5555+5656+Check if service is enabled:
5757+```bash
5858+systemctl is-enabled <service-name>
5959+```
+78
02-apache-web-service.md
···11+# Apache Web Service
22+33+## Service Name
44+- `apache2` (Ubuntu/Debian)
55+- `httpd` (CentOS/RHEL)
66+77+## Check Service Status
88+```bash
99+systemctl status apache2 # Ubuntu
1010+systemctl status httpd # CentOS
1111+```
1212+1313+## Configuration Locations
1414+1515+Main config: `/etc/apache2/` (Ubuntu) or `/etc/httpd/` (CentOS)
1616+1717+Key files:
1818+- `/etc/apache2/apache2.conf` - Main configuration
1919+- `/etc/apache2/sites-available/` - Available site configs
2020+- `/etc/apache2/sites-enabled/` - Active site configs (usually symlinks)
2121+2222+## Default Site Configuration
2323+2424+File: `/etc/apache2/sites-available/000-default.conf`
2525+2626+Key directives:
2727+```apache
2828+<VirtualHost *:80>
2929+ DocumentRoot /var/www/html
3030+ # ... other settings
3131+</VirtualHost>
3232+```
3333+3434+- **Listen port**: Default is `*:80` (any IP, port 80)
3535+- **DocumentRoot**: `/var/www/html` - where website files live
3636+3737+## Website File Location
3838+3939+Website files go in: `/var/www/html`
4040+4141+Default file: `index.html` (or `index.php`)
4242+4343+The web server automatically serves `index.html` when you visit the root URL.
4444+4545+## Start/Restart Service
4646+4747+```bash
4848+sudo systemctl start apache2
4949+sudo systemctl restart apache2
5050+```
5151+5252+## Creating Website Content
5353+5454+Make directories:
5555+```bash
5656+sudo mkdir /var/www/html/newfolder
5757+```
5858+5959+Create files:
6060+```bash
6161+sudo touch /var/www/html/newfile.html
6262+```
6363+6464+**Permission Requirements**: Web server needs read permissions to serve files.
6565+6666+## Security Considerations
6767+6868+- Don't put sensitive files (like `/etc/shadow`) in `/var/www/html`
6969+- Check permissions - files need to be readable by web server
7070+- Backup config files before making changes
7171+- The website displays actual files from the server's filesystem
7272+7373+## Common Issues
7474+7575+1. **Service not starting**: Check config file syntax
7676+2. **Can't access website**: Verify service is running, check IP/port
7777+3. **404 errors**: Check DocumentRoot path and file permissions
7878+4. **Permission denied**: Files need world-readable permissions for web server access
+164
03-ssh-service.md
···11+# SSH Service
22+33+## Service Name
44+- `ssh` or `sshd` (works on most distributions)
55+66+## Check Service Status
77+```bash
88+systemctl status ssh
99+systemctl status sshd # Also works
1010+```
1111+1212+## Configuration Location
1313+1414+Main directory: `/etc/ssh/`
1515+1616+Key files:
1717+- `/etc/ssh/sshd_config` - Server configuration (most important)
1818+- `/etc/ssh/ssh_config` - Client configuration
1919+- `/etc/ssh/ssh_host_*_key` - Server private keys (multiple algorithms)
2020+- `/etc/ssh/ssh_host_*_key.pub` - Server public keys
2121+2222+## Important sshd_config Options
2323+2424+```bash
2525+Port 22 # Default SSH port
2626+ListenAddress 0.0.0.0 # Listen on all IPs (or specify one)
2727+PermitRootLogin prohibit-password # Or "yes" or "no"
2828+```
2929+3030+### Port
3131+Default is 22. Can change to non-standard port for security.
3232+3333+### ListenAddress
3434+- `0.0.0.0` = listen on all IP addresses
3535+- Or specify a single IP to restrict access
3636+3737+### PermitRootLogin
3838+- `no` - root cannot SSH in at all
3939+- `yes` - root can SSH in with password
4040+- `prohibit-password` - root must use key authentication
4141+4242+## Connecting to SSH Server
4343+4444+Basic syntax:
4545+```bash
4646+ssh username@ip_address
4747+ssh username@hostname.com
4848+```
4949+5050+Example:
5151+```bash
5252+ssh sandbox@192.168.1.100
5353+```
5454+5555+First connection prompts to accept server's fingerprint (say yes).
5656+5757+## Host Keys (Server-Side)
5858+5959+SSH server has multiple key pairs in `/etc/ssh/`:
6060+- RSA keys: `ssh_host_rsa_key` and `ssh_host_rsa_key.pub`
6161+- ECDSA keys: `ssh_host_ecdsa_key` and `ssh_host_ecdsa_key.pub`
6262+- ED25519 keys: `ssh_host_ed25519_key` and `ssh_host_ed25519_key.pub`
6363+6464+These are **asymmetric key pairs**:
6565+- Private key stays on server (read-only to root)
6666+- Public key shared with clients
6767+- Data encrypted with one key only decrypts with the other
6868+6969+## Regenerating Host Keys
7070+7171+If keys are compromised (or cloned VMs have identical keys):
7272+7373+```bash
7474+sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
7575+```
7676+7777+Options:
7878+- `-t ecdsa` - key type (also: rsa, ed25519)
7979+- `-f /path/to/key` - where to save
8080+- Will prompt to overwrite existing key
8181+- Can add passphrase or leave blank
8282+8383+## Client-Side Known Hosts
8484+8585+Location: `~/.ssh/known_hosts`
8686+8787+Contains public keys of servers you've connected to before.
8888+8989+If server key changes, you'll get a warning. To fix:
9090+```bash
9191+# Remove old entry for that IP
9292+ssh-keygen -R 192.168.1.100
9393+9494+# Or delete the entire file and re-accept connections
9595+rm ~/.ssh/known_hosts
9696+```
9797+9898+## Passwordless Authentication
9999+100100+Allows login without password using key pairs.
101101+102102+**Setup process:**
103103+104104+1. Generate key pair on client (or server acting as admin):
105105+```bash
106106+ssh-keygen -t ecdsa -f ~/id_bob_key
107107+```
108108+109109+2. Create `.ssh` directory for user:
110110+```bash
111111+sudo mkdir /home/bob/.ssh
112112+sudo chmod 700 /home/bob/.ssh
113113+sudo chown bob:bob /home/bob/.ssh
114114+```
115115+116116+3. Copy public key to authorized_keys:
117117+```bash
118118+sudo cp id_bob_key.pub /home/bob/.ssh/authorized_keys
119119+sudo chmod 644 /home/bob/.ssh/authorized_keys
120120+sudo chown bob:bob /home/bob/.ssh/authorized_keys
121121+```
122122+123123+4. Transfer private key to client using SCP:
124124+```bash
125125+scp sandbox@192.168.1.100:/path/to/id_bob_key .
126126+```
127127+128128+5. Connect using the key:
129129+```bash
130130+ssh -i id_bob_key bob@192.168.1.100
131131+```
132132+133133+**Critical permissions:**
134134+- `.ssh/` directory: `700` (drwx------)
135135+- `authorized_keys` file: `644` (-rw-r--r--)
136136+- Private keys: `600` (-rw-------)
137137+- Public keys: `644` (-rw-r--r--)
138138+139139+## SCP (Secure Copy)
140140+141141+Copy files over SSH:
142142+143143+```bash
144144+# Copy from remote to local
145145+scp user@remote:/path/to/file .
146146+147147+# Copy from local to remote
148148+scp localfile user@remote:/path/
149149+150150+# Use sudo on remote side
151151+sudo scp user@remote:/root/file .
152152+```
153153+154154+## Exit SSH Session
155155+156156+```bash
157157+exit
158158+```
159159+160160+## Restart After Config Changes
161161+162162+```bash
163163+sudo systemctl restart ssh
164164+```
+137
04-network-configuration.md
···11+# Network Configuration by Distribution
22+33+## Viewing Current Configuration
44+55+Show IP addresses:
66+```bash
77+ip a
88+# or
99+ip addr show
1010+```
1111+1212+Show specific interface:
1313+```bash
1414+ip a show eth0
1515+```
1616+1717+## Kali/Debian - /etc/network/interfaces
1818+1919+**File**: `/etc/network/interfaces`
2020+2121+Basic static configuration:
2222+```bash
2323+auto eth0
2424+iface eth0 inet static
2525+ address 172.20.118.100
2626+ netmask 255.255.255.0
2727+ gateway 172.20.118.1
2828+```
2929+3030+**Key components:**
3131+- `auto eth0` - Bring up interface automatically on boot
3232+- `iface eth0 inet static` - Configure static IP (not DHCP)
3333+- `address` - IP address
3434+- `netmask` - Subnet mask
3535+- `gateway` - Default gateway (router)
3636+3737+**Restart networking:**
3838+```bash
3939+sudo systemctl restart networking
4040+# or
4141+sudo ifdown eth0 && sudo ifup eth0
4242+```
4343+4444+## CentOS/RHEL - ifcfg Files
4545+4646+**Directory**: `/etc/sysconfig/network-scripts/`
4747+4848+**Files**: One per interface (e.g., `ifcfg-eth0`, `ifcfg-eth1`)
4949+5050+Example `ifcfg-eth0`:
5151+```bash
5252+DEVICE=eth0
5353+BOOTPROTO=static
5454+ONBOOT=yes
5555+IPADDR=172.20.118.1
5656+NETMASK=255.255.255.0
5757+GATEWAY=172.20.118.254
5858+```
5959+6060+**Key settings:**
6161+- `DEVICE` - Interface name
6262+- `BOOTPROTO` - `static` or `dhcp`
6363+- `ONBOOT` - `yes` to auto-start on boot
6464+- `IPADDR` - IP address
6565+- `NETMASK` - Subnet mask
6666+- `GATEWAY` - Default gateway
6767+6868+**Restart networking:**
6969+```bash
7070+sudo systemctl restart network
7171+# or per-interface:
7272+sudo ifdown eth0 && sudo ifup eth0
7373+```
7474+7575+## Ubuntu - Netplan (YAML)
7676+7777+**Directory**: `/etc/netplan/`
7878+7979+**File**: Usually `01-network-manager-all.yaml` (or similar `.yaml` file)
8080+8181+**IMPORTANT**: YAML is whitespace-sensitive. Use 2-space indentation consistently.
8282+8383+Example configuration:
8484+```yaml
8585+network:
8686+ version: 2
8787+ renderer: NetworkManager
8888+ ethernets:
8989+ ens18:
9090+ addresses:
9191+ - 192.168.195.2/24
9292+ gateway4: 192.168.195.1
9393+```
9494+9595+**Key elements:**
9696+- `ethernets:` - Section for ethernet interfaces
9797+- `ens18:` - Interface name (not eth0 on modern Ubuntu)
9898+- `addresses:` - List of IPs (note the dash and `/24` CIDR notation)
9999+- `gateway4:` - Default gateway for IPv4
100100+101101+**Apply changes:**
102102+```bash
103103+sudo netplan apply
104104+```
105105+106106+**Test configuration (doesn't persist):**
107107+```bash
108108+sudo netplan try
109109+```
110110+111111+**CIDR notation:** `/24` equals `255.255.255.0`
112112+113113+## Temporary IP Configuration
114114+115115+Set IP temporarily (lost on reboot):
116116+```bash
117117+sudo ip addr add 192.168.1.100/24 dev eth0
118118+```
119119+120120+Flush (remove) all IPs from interface:
121121+```bash
122122+sudo ip addr flush dev eth0
123123+```
124124+125125+## Common Network Issues
126126+127127+1. **Wrong interface name**: Check with `ip a` first
128128+2. **Typo in config file**: Double-check spelling and syntax
129129+3. **Forgotten gateway**: Can't reach beyond local network
130130+4. **Netplan spacing**: YAML requires exact indentation
131131+5. **Wrong subnet**: Devices must be on same subnet to communicate
132132+133133+## Interface Naming
134134+135135+- **Old style**: `eth0`, `eth1`, `lo` (loopback)
136136+- **New style**: `ens18`, `enp0s3`, etc. (Ubuntu/modern systems)
137137+- Always check actual names with `ip a` before configuring
+210
05-dns-rsync-cron.md
···11+# DNS, Rsync, and Cron Services
22+33+## DNS Service (BIND)
44+55+### Service Name
66+- `named` (most distributions)
77+88+### Configuration Location
99+- Ubuntu: `/etc/bind/`
1010+- CentOS: May be in different location
1111+1212+### Check Service
1313+```bash
1414+systemctl status named
1515+```
1616+1717+### Basic Concept
1818+DNS translates domain names to IP addresses (forward lookup) and IP addresses to domain names (reverse lookup).
1919+2020+**Forward lookup**: `example.com` → `192.168.1.100`
2121+**Reverse lookup**: `192.168.1.100` → `example.com`
2222+2323+### Key Files (Bind)
2424+- `named.conf` - Main configuration
2525+- Zone files - Define DNS records for domains
2626+2727+**This is a complex service** - requires understanding of:
2828+- Zone files
2929+- DNS record types (A, PTR, CNAME, MX, etc.)
3030+- Forward vs reverse zones
3131+- DNS hierarchy
3232+3333+---
3434+3535+## Rsync - File Synchronization/Backup
3636+3737+### Basic Syntax
3838+```bash
3939+rsync [options] source destination
4040+```
4141+4242+### Common Options
4343+```bash
4444+-a # Archive mode (preserves permissions, timestamps, etc.)
4545+-v # Verbose (show what's being copied)
4646+-z # Compress during transfer
4747+-r # Recursive (copy directories)
4848+-h # Human-readable output
4949+--delete # Delete files in dest that don't exist in source
5050+```
5151+5252+### Local Backup Example
5353+```bash
5454+rsync -av /home/user/stuff/ /home/user/backups/
5555+```
5656+5757+**Note the trailing slash** on source - affects behavior:
5858+- `/source/` - copy contents of source
5959+- `/source` - copy source directory itself
6060+6161+### Remote Backup via SSH
6262+```bash
6363+rsync -avz /local/path/ user@remote:/remote/path/
6464+```
6565+6666+### Consistency vs. Accumulation
6767+6868+**Consistency** (mirror - deletes old files):
6969+```bash
7070+rsync -av --delete /source/ /backup/
7171+```
7272+7373+**Accumulation** (keeps all files):
7474+```bash
7575+rsync -av /source/ /backup/
7676+```
7777+7878+### Check Installed
7979+```bash
8080+rsync --version
8181+# or just run rsync to see options
8282+```
8383+8484+---
8585+8686+## Cron - Task Automation
8787+8888+### Service Name
8989+- `cron` (Ubuntu/Debian)
9090+- `crond` (CentOS/RHEL)
9191+9292+### Check Service
9393+```bash
9494+systemctl status cron
9595+systemctl status crond # CentOS
9696+```
9797+9898+### Edit Crontab
9999+```bash
100100+crontab -e # Edit current user's crontab
101101+```
102102+103103+First time will ask which editor (nano recommended for beginners).
104104+105105+### Crontab Syntax
106106+107107+Five time fields + command:
108108+```
109109+* * * * * command
110110+│ │ │ │ │
111111+│ │ │ │ └─ Day of week (0-7, 0/7 = Sunday)
112112+│ │ │ └─── Month (1-12)
113113+│ │ └───── Day of month (1-31)
114114+│ └─────── Hour (0-23)
115115+└───────── Minute (0-59)
116116+```
117117+118118+**Asterisk (*) means "every"**
119119+120120+### Examples
121121+122122+Every minute:
123123+```bash
124124+* * * * * /path/to/command
125125+```
126126+127127+Every 5 minutes:
128128+```bash
129129+*/5 * * * * /path/to/command
130130+```
131131+132132+Every day at 2:30 AM:
133133+```bash
134134+30 2 * * * /path/to/command
135135+```
136136+137137+Every Monday at 5:00 PM:
138138+```bash
139139+0 17 * * 1 /path/to/command
140140+```
141141+142142+First day of every month at midnight:
143143+```bash
144144+0 0 1 * * /path/to/command
145145+```
146146+147147+### Automated Backup Example
148148+149149+Run rsync backup every night at 2 AM:
150150+```bash
151151+0 2 * * * rsync -av --delete /var/www/html/ /backups/website/
152152+```
153153+154154+### Redirect Output
155155+156156+Send output to file:
157157+```bash
158158+* * * * * /path/to/command > /path/to/logfile.txt
159159+```
160160+161161+Append to file:
162162+```bash
163163+* * * * * /path/to/command >> /path/to/logfile.txt
164164+```
165165+166166+Suppress output:
167167+```bash
168168+* * * * * /path/to/command > /dev/null 2>&1
169169+```
170170+171171+### View Crontab
172172+```bash
173173+crontab -l # List current user's crontab
174174+```
175175+176176+### Remove Crontab
177177+```bash
178178+crontab -r # Remove current user's crontab
179179+```
180180+181181+### System-Wide Cron
182182+183183+User-specific: Managed via `crontab -e`
184184+185185+System-wide cron directories:
186186+- `/etc/cron.daily/` - Scripts run daily
187187+- `/etc/cron.hourly/` - Scripts run hourly
188188+- `/etc/cron.weekly/` - Scripts run weekly
189189+- `/etc/cron.monthly/` - Scripts run monthly
190190+191191+Place executable scripts in these directories for automatic execution.
192192+193193+### Important Notes
194194+195195+1. Cron uses absolute paths - always specify full path to commands
196196+2. Cron runs in minimal environment - may need to set PATH, etc.
197197+3. Test commands manually first before adding to cron
198198+4. Cron jobs run as the user who owns the crontab
199199+5. `sudo crontab -e` edits root's crontab (for privileged tasks)
200200+201201+### Combining Rsync + Cron
202202+203203+Automated nightly backups:
204204+```bash
205205+# In crontab -e:
206206+0 2 * * * rsync -avz /var/www/html/ /backups/website/
207207+0 3 * * * rsync -avz /etc/ /backups/configs/
208208+```
209209+210210+This creates automated, scheduled backups without manual intervention.
+183
06-ufw-firewall.md
···11+# UFW Firewall Configuration
22+33+## Overview
44+UFW (Uncomplicated Firewall) sits on top of iptables and provides a more user-friendly interface for managing firewall rules on Ubuntu systems.
55+66+## Distribution Differences
77+88+| Distribution | Firewall Tool |
99+|--------------|---------------|
1010+| Ubuntu | UFW (built-in) |
1111+| Kali | iptables (UFW not installed by default) |
1212+| CentOS/RHEL | firewall-cmd (firewalld) |
1313+1414+## Basic Commands
1515+1616+### Check Status
1717+```bash
1818+sudo ufw status # Basic status
1919+sudo ufw status verbose # Detailed status with default policies
2020+sudo ufw status numbered # Show rule numbers
2121+```
2222+2323+### Enable/Disable
2424+```bash
2525+sudo ufw enable # Turn on firewall (persists after reboot)
2626+sudo ufw disable # Turn off firewall
2727+```
2828+2929+## Default Policies
3030+When you enable UFW, default behavior is:
3131+- **Incoming**: DENY (block all incoming traffic by default)
3232+- **Outgoing**: ALLOW (allow all outgoing traffic)
3333+- **Routed**: DENY (no routing/forwarding)
3434+3535+This means services won't be accessible until you explicitly allow them.
3636+3737+## Creating Rules
3838+3939+### Allow Rules - By Service Name
4040+```bash
4141+sudo ufw allow ssh # Allow SSH (port 22, IPv4 and IPv6)
4242+sudo ufw allow http # Allow HTTP (port 80)
4343+sudo ufw allow https # Allow HTTPS (port 443)
4444+```
4545+4646+### Allow Rules - By Port
4747+```bash
4848+sudo ufw allow 22/tcp # Allow TCP port 22
4949+sudo ufw allow 80/tcp # Allow TCP port 80
5050+sudo ufw allow 53/udp # Allow UDP port 53 (DNS)
5151+```
5252+5353+### Allow Rules - By IP Address
5454+```bash
5555+sudo ufw allow from 192.168.1.100 # Allow all traffic from specific IP
5656+sudo ufw allow from 192.168.1.0/24 # Allow from entire subnet
5757+```
5858+5959+### Deny Rules
6060+```bash
6161+sudo ufw deny from 192.168.195.0/24 # Block entire subnet
6262+sudo ufw deny 23/tcp # Block telnet
6363+```
6464+6565+## Rule Processing Order
6666+6767+**Critical**: UFW processes rules in the order they were added.
6868+6969+```bash
7070+# Example 1 - This works (allow processed first)
7171+sudo ufw allow from 192.168.195.100
7272+sudo ufw deny from 192.168.195.0/24
7373+# Result: .100 is allowed, rest of subnet blocked
7474+7575+# Example 2 - This doesn't work as intended (deny processed first)
7676+sudo ufw deny from 192.168.195.0/24
7777+sudo ufw allow from 192.168.195.100
7878+# Result: .100 is also blocked (caught by first deny rule)
7979+```
8080+8181+## Deleting Rules
8282+8383+### By Rule Number
8484+```bash
8585+sudo ufw status numbered # See rule numbers
8686+sudo ufw delete 4 # Delete rule #4
8787+```
8888+8989+**Warning**: After deleting a rule, all rules are renumbered. Delete one at a time and re-check numbers.
9090+9191+### By Specification
9292+```bash
9393+sudo ufw delete allow ssh
9494+sudo ufw delete allow from 192.168.1.100
9595+```
9696+9797+## IPv6 Considerations
9898+9999+Many UFW commands automatically create both IPv4 and IPv6 rules:
100100+101101+```bash
102102+sudo ufw allow ssh
103103+# Creates BOTH:
104104+# - Port 22 (IPv4)
105105+# - Port 22 (IPv6)
106106+```
107107+108108+**Security Tip**: If you're not using IPv6, consider deleting those rules to reduce attack surface:
109109+```bash
110110+sudo ufw status numbered
111111+sudo ufw delete 4 # Delete the IPv6 rule
112112+```
113113+114114+## Before/After Rules
115115+116116+UFW has built-in rules that process **before** and **after** your user-defined rules. These are stored in:
117117+- `/etc/ufw/before.rules` - Processed before user rules
118118+- `/etc/ufw/after.rules` - Processed after user rules
119119+120120+Example before-rules:
121121+- Allow DHCP client (so you can get an IP)
122122+- Allow established connections
123123+- Allow loopback traffic
124124+125125+You can edit these files if needed, but typically user rules are sufficient.
126126+127127+## Common Service Configurations
128128+129129+### SSH Server
130130+```bash
131131+sudo ufw allow ssh
132132+# or
133133+sudo ufw allow 22/tcp
134134+```
135135+136136+### Web Server (Apache/Nginx)
137137+```bash
138138+sudo ufw allow http
139139+sudo ufw allow https
140140+# or
141141+sudo ufw allow 80/tcp
142142+sudo ufw allow 443/tcp
143143+```
144144+145145+### DNS Server
146146+```bash
147147+sudo ufw allow 53/tcp
148148+sudo ufw allow 53/udp
149149+```
150150+151151+## Competition Tips
152152+153153+1. **Start by enabling it**: `sudo ufw enable` - even basic defaults improve security
154154+2. **Allow services incrementally**: Only open ports for services you're actually running
155155+3. **Check after each change**: `sudo ufw status verbose`
156156+4. **Don't lock yourself out**: If configuring SSH remotely, make sure you allow SSH before enabling the firewall
157157+5. **Monitor conflicts**: If a service stops working after enabling UFW, you likely forgot to allow its port
158158+159159+## Troubleshooting
160160+161161+### Service not accessible after enabling firewall
162162+```bash
163163+sudo ufw status numbered # Check if port is allowed
164164+sudo ufw allow <port>/tcp # Add the missing rule
165165+```
166166+167167+### Locked out of SSH
168168+- If you have console access: `sudo ufw allow ssh` then `sudo ufw enable`
169169+- Always add SSH rule before enabling firewall on remote systems
170170+171171+### Rule not working as expected
172172+- Check rule order with `sudo ufw status numbered`
173173+- More specific rules should come before general deny rules
174174+- Remember: first match wins
175175+176176+## Integration with System Services
177177+178178+UFW rules persist across reboots once enabled. The firewall starts automatically on boot if you've run `sudo ufw enable`.
179179+180180+To disable automatic start:
181181+```bash
182182+sudo ufw disable
183183+```
+293
07-active-connection-defense.md
···11+# Active Connection Defense
22+33+## Overview
44+Monitoring and managing active network connections is critical during competitions. This guide covers tools for identifying who's connected to your system and how to terminate malicious connections.
55+66+## Core Monitoring Tools
77+88+### netstat - Network Statistics
99+1010+**Most useful form**:
1111+```bash
1212+sudo netstat -tunap
1313+```
1414+1515+**Breakdown**:
1616+- `-t` = TCP connections
1717+- `-u` = UDP connections
1818+- `-n` = Show numeric ports (22 instead of "ssh")
1919+- `-a` = Show listening and established connections
2020+- `-p` = Show process IDs (requires sudo)
2121+2222+**Output columns**:
2323+```
2424+Proto Local Address Foreign Address State PID/Program
2525+tcp 192.168.195.100:22 192.168.195.2:51736 ESTABLISHED 265408/sshd
2626+```
2727+2828+**Common filters**:
2929+```bash
3030+netstat -tunap | grep ESTABLISHED # Only active connections
3131+netstat -tunap | grep :22 # Only SSH connections
3232+netstat -tunap | less # Scroll through output
3333+```
3434+3535+### ss - Socket Statistics
3636+3737+Modern replacement for netstat. Similar syntax:
3838+3939+```bash
4040+ss # Basic output (lots of info)
4141+ss | grep ESTAB # Only established connections
4242+ss -tunap # Same flags as netstat
4343+```
4444+4545+**Advantage**: ss is installed on more modern systems by default.
4646+4747+### w - Who is logged in
4848+4949+```bash
5050+w
5151+```
5252+5353+**Shows**:
5454+- Username
5555+- From where (IP address or `:0` for local console)
5656+- Login time
5757+- What they're doing
5858+5959+**Example output**:
6060+```
6161+USER FROM WHAT
6262+sandbox :0 -bash
6363+bob 192.168.195.2 -bash
6464+jenny 192.168.195.2 -bash
6565+```
6666+6767+**Key indicator**:
6868+- `:0` = Local console (physically at the machine)
6969+- IP address = Remote connection (SSH, etc.)
7070+7171+## Finding Process Information
7272+7373+### top - Interactive Process Viewer
7474+7575+```bash
7676+top
7777+```
7878+7979+- Shows CPU/memory usage
8080+- Lists running processes
8181+- Press `q` to quit
8282+8383+### htop - Enhanced Process Viewer
8484+8585+```bash
8686+htop # If installed (not always available)
8787+```
8888+8989+More colorful and interactive than `top`.
9090+9191+### ps - Process Status
9292+9393+```bash
9494+ps aux # All processes, all users
9595+ps aux | grep ssh # Find SSH processes
9696+```
9797+9898+## Killing Connections
9999+100100+### Kill by Process ID (PID)
101101+102102+1. **Find the PID**:
103103+```bash
104104+sudo netstat -tunap
105105+# Example output shows PID 265465 for jenny's SSH connection
106106+```
107107+108108+2. **Kill the process**:
109109+```bash
110110+sudo kill 265465
111111+```
112112+113113+**From the user's perspective**: Connection closes immediately
114114+```
115115+Connection to 192.168.195.100 closed by remote host.
116116+```
117117+118118+### Kill by Username (pkill)
119119+120120+```bash
121121+sudo pkill -kill -u jenny # Kill all processes for user jenny
122122+sudo pkill -kill -u bob # Kill all processes for user bob
123123+```
124124+125125+**Warning**: This kills ALL processes for that user, including:
126126+- Active SSH sessions
127127+- Running programs
128128+- Background jobs
129129+130130+### Kill Signal Types
131131+132132+```bash
133133+sudo kill PID # SIGTERM (graceful shutdown, default)
134134+sudo kill -9 PID # SIGKILL (force kill immediately)
135135+sudo pkill -kill -u user # -kill = SIGKILL
136136+```
137137+138138+## Competition Workflow
139139+140140+### Active Defense Pattern
141141+142142+1. **Someone monitors connections**:
143143+```bash
144144+# Run periodically or in a loop
145145+sudo netstat -tunap
146146+```
147147+148148+2. **Identify suspicious connections**:
149149+- Unknown IP addresses
150150+- Unexpected users logged in
151151+- Unusual ports
152152+153153+3. **Kill immediately**:
154154+```bash
155155+sudo pkill -kill -u <suspicious_user>
156156+# or
157157+sudo kill <PID>
158158+```
159159+160160+4. **Someone else hardens the system**:
161161+- Change passwords
162162+- Disable accounts
163163+- Configure firewall
164164+- Close unnecessary services
165165+166166+### Example Monitoring Script
167167+168168+```bash
169169+#!/bin/bash
170170+# Quick connection checker
171171+while true; do
172172+ clear
173173+ echo "=== Active SSH Connections ==="
174174+ sudo netstat -tunap | grep :22 | grep ESTABLISHED
175175+ sleep 5
176176+done
177177+```
178178+179179+## Common Scenarios
180180+181181+### Scenario 1: Unknown SSH Connection
182182+183183+```bash
184184+# See who's connected
185185+w
186186+187187+# Find their process ID
188188+sudo netstat -tunap | grep ESTABLISHED
189189+190190+# Kill by PID
191191+sudo kill 265465
192192+```
193193+194194+### Scenario 2: Brute Force Attempts
195195+196196+```bash
197197+# See all connection attempts
198198+sudo netstat -tunap | grep :22
199199+200200+# Check auth logs
201201+sudo tail -f /var/log/auth.log
202202+203203+# Block the source IP with firewall
204204+sudo ufw deny from <attacker_ip>
205205+```
206206+207207+### Scenario 3: Multiple Sessions from Same User
208208+209209+```bash
210210+# Kill all sessions for a user
211211+sudo pkill -kill -u jenny
212212+213213+# Disable the account
214214+sudo passwd -l jenny # Lock password
215215+sudo usermod -s /bin/false jenny # Disable shell
216216+```
217217+218218+## Warnings and Gotchas
219219+220220+### Don't Kill Yourself
221221+222222+```bash
223223+# BAD - if you're logged in as sandbox:
224224+sudo pkill -kill -u sandbox
225225+# This kills YOUR session too!
226226+```
227227+228228+**Better approach**: Kill by specific PID if you're using the same username.
229229+230230+### Don't Kill Teammates
231231+232232+- Check with team before killing connections
233233+- Look at FROM addresses to identify internal vs external
234234+- Local (`:0`) connections are usually teammates at the console
235235+236236+### Shared Accounts
237237+238238+If red team is using the same account as you:
239239+- Kill by PID (specific to their connection)
240240+- Don't kill by username (you'll disconnect yourself)
241241+242242+## Process Information Fields
243243+244244+**Understanding PID in netstat**:
245245+```bash
246246+sudo netstat -tunap
247247+```
248248+249249+Output:
250250+```
251251+PID/Program name
252252+265408/sshd: sandbox
253253+265465/sshd: jenny
254254+```
255255+256256+- PID: Process ID (unique number)
257257+- Program: Which service (sshd, apache2, etc.)
258258+- User context: Which user owns the process
259259+260260+## Monitoring vs. Hardening
261261+262262+**Active monitoring** (short-term):
263263+- Running netstat/ss repeatedly
264264+- Killing suspicious connections as they appear
265265+- Playing "whack-a-mole"
266266+267267+**Hardening** (long-term):
268268+- Change passwords
269269+- Disable unused accounts
270270+- Configure firewall rules
271271+- Close unnecessary services
272272+- Update vulnerable software
273273+274274+**Best practice**: Use monitoring to buy time while someone else hardens the system. You can't watch connections for 6 hours straight.
275275+276276+## Tool Availability
277277+278278+| Tool | Typical Availability |
279279+|------|---------------------|
280280+| netstat | Most systems (may need `net-tools` package) |
281281+| ss | Modern systems (usually pre-installed) |
282282+| w | All Unix/Linux systems |
283283+| top | All Unix/Linux systems |
284284+| htop | Optional (install with apt/yum) |
285285+| ps | All Unix/Linux systems |
286286+287287+**If netstat is missing**:
288288+```bash
289289+sudo apt install net-tools # Debian/Ubuntu
290290+sudo yum install net-tools # CentOS/RHEL
291291+```
292292+293293+Or just use `ss` instead.
+294
08-mikrotik-router.md
···11+# MikroTik Router Configuration
22+33+## Overview
44+Starting 2025, the NCAE competition replaced CentOS routers with MikroTik routers. MikroTik provides both a CLI and web GUI for configuration.
55+66+## Why MikroTik?
77+- CentOS is end-of-life
88+- MikroTik is a commercial router OS used in real networks
99+- Provides both CLI and web interface
1010+- More intuitive than raw iptables
1111+1212+## Access Methods
1313+1414+### CLI Access (Console/Terminal)
1515+- Through ProxMox VNC console
1616+- Direct terminal access
1717+- No browser required
1818+1919+### Web GUI Access
2020+```
2121+http://<router-ip>:8080
2222+```
2323+2424+**Example**: `http://172.20.213.1:8080` (from external side)
2525+2626+**Port 8080** is the management interface, not the standard web port.
2727+2828+## Initial Login
2929+3030+### Default Credentials
3131+- **Username**: `admin`
3232+- **Password**: (blank - just press Enter)
3333+3434+### First Login
3535+1. Login with blank password
3636+2. System will prompt you to set a new password
3737+3. **IMPORTANT**: Choose a strong password for competition
3838+ - For testing/practice: can use something simple like `password`
3939+ - For competition: red team will own you with weak passwords
4040+4141+### License Prompt
4242+- Will ask if you want to view license
4343+- Can say "no" unless interested
4444+4545+## Basic CLI Commands
4646+4747+### Check IP Addresses
4848+```bash
4949+/ip address print
5050+```
5151+5252+Shows all configured IP addresses on all interfaces.
5353+5454+### Check Interfaces (Hardware)
5555+```bash
5656+interface print
5757+```
5858+5959+Shows network adapters:
6060+- `ether3` = First interface (usually external)
6161+- `ether4` = Second interface (usually internal)
6262+- Names may vary depending on hardware/cloning
6363+6464+### Assign an IP Address
6565+```bash
6666+/ip address add address=172.20.213.1/16 interface=ether3
6767+```
6868+6969+**Breakdown**:
7070+- `address=` - IP and subnet mask in CIDR notation
7171+- `interface=` - Which network adapter (ether3, ether4, etc.)
7272+7373+**Example for internal side**:
7474+```bash
7575+/ip address add address=192.168.213.1/24 interface=ether4
7676+```
7777+7878+### Test Connectivity
7979+```bash
8080+/ping 172.20.2
8181+/ping 192.168.213.2
8282+```
8383+8484+**Keyboard shortcuts**:
8585+- Up/Down arrows = Command history
8686+- Ctrl+C = Stop ping
8787+8888+### Check Configuration
8989+Use the print command for any section:
9090+```bash
9191+/ip address print
9292+/ip route print
9393+/ip firewall nat print
9494+```
9595+9696+## Web GUI Configuration
9797+9898+### Accessing the GUI
9999+100100+From external network:
101101+```
102102+http://172.20.213.1:8080
103103+```
104104+105105+Login: `admin` / `<your-password>`
106106+107107+### GUI Navigation
108108+109109+**Top-right buttons**:
110110+- **Quick Set** - Main configuration page (most common tasks)
111111+- **Advanced** - Detailed/expert settings
112112+- **Terminal** - CLI access from web browser
113113+114114+**Most tasks can be done from Quick Set.**
115115+116116+### Quick Set Configuration
117117+118118+**Scrolling tips**:
119119+- Mouse wheel only works when cursor is in the CENTER of the page
120120+- If scrolling doesn't work, move mouse to the left side
121121+- Scroll bar appears in the middle column
122122+123123+#### Internet/External Configuration
124124+125125+**Gateway** (where traffic goes to reach internet):
126126+```
127127+172.20.1.1 # Or whatever your competition topology specifies
128128+```
129129+130130+**DNS Servers**:
131131+- Click the `+` button to add DNS servers
132132+- Add all DNS servers from your topology document
133133+134134+#### LAN/Internal Configuration
135135+136136+Should show your configured internal IP:
137137+```
138138+192.168.213.1/24
139139+```
140140+141141+#### Critical Checkboxes
142142+143143+✅ **Bridge LAN Ports** - Check this
144144+- Allows multiple LAN ports to work as one network
145145+146146+✅ **Enable NAT** - Check this
147147+- **Network Address Translation**
148148+- Allows internal 192.168.x.x addresses to route through external 172.20.x.x
149149+- **Required for routing to work**
150150+151151+#### Apply Changes
152152+153153+Click **Apply Configuration** button at bottom.
154154+155155+Changes apply immediately - you'll see a "Saved" notification in the bottom-right.
156156+157157+### Port Forwarding (Port Mapping)
158158+159159+**Purpose**: Route external traffic to internal servers
160160+161161+**Example**: Route external HTTP requests to internal web server
162162+163163+1. Click **Port Mapping** (in Quick Set view)
164164+165165+2. Click **New** button
166166+167167+3. Configure the rule:
168168+169169+**TCP Rule**:
170170+```
171171+Name: www-tcp
172172+Protocol: TCP
173173+Port: 80
174174+Forward To: 192.168.213.2
175175+Port: 80
176176+```
177177+178178+**UDP Rule**:
179179+```
180180+Name: www-udp
181181+Protocol: UDP
182182+Port: 80
183183+Forward To: 192.168.213.2
184184+Port: 80
185185+```
186186+187187+4. Click **OK** to save each rule
188188+189189+### Testing Port Forwarding
190190+191191+From external machine:
192192+```
193193+http://172.20.213.1
194194+```
195195+196196+Should display website hosted on 192.168.213.2 (internal server).
197197+198198+## Mini-Hack Context
199199+200200+### External Network
201201+```
202202+Network: 172.20.0.0/16
203203+Router IP: 172.20.213.1 (example team 213)
204204+Kali External: 172.20.2
205205+```
206206+207207+### Internal Network
208208+```
209209+Network: 192.168.213.0/24 (team number in 3rd octet)
210210+Router IP: 192.168.213.1
211211+Web Server: 192.168.213.2
212212+Kali Internal: 192.168.213.100
213213+```
214214+215215+### Required Configuration
216216+217217+1. **Assign external IP**: `172.20.<team>.1/16` to ether3
218218+2. **Assign internal IP**: `192.168.<team>.1/24` to ether4
219219+3. **Enable NAT** in Quick Set
220220+4. **Port forward 80** (TCP & UDP) to internal web server at `.2`
221221+222222+## Common Issues
223223+224224+### Can't access web GUI
225225+- Verify router IP is correct
226226+- Must use port 8080: `http://<ip>:8080`
227227+- Check you're on the same network as router
228228+229229+### Port forwarding not working
230230+- Did you enable NAT? (checkbox in Quick Set)
231231+- Did you create BOTH TCP and UDP rules?
232232+- Verify internal server is actually running the service
233233+- Check internal server IP is correct
234234+235235+### Changes not saving
236236+- Look for "Saved" notification bottom-right
237237+- If using Quick Set, click "Apply Configuration"
238238+- Changes are immediate (no reboot needed)
239239+240240+## CLI vs Web GUI
241241+242242+**Use CLI for**:
243243+- Quick IP configuration
244244+- Checking current status
245245+- When GUI is not accessible
246246+247247+**Use Web GUI for**:
248248+- Port forwarding / NAT rules
249249+- Complex firewall rules
250250+- Overview of configuration
251251+- When you want visual confirmation
252252+253253+Both methods work and changes sync between them.
254254+255255+## Advanced Topics (Beyond Basics)
256256+257257+**Firewall Rules** - More complex than just port forwarding
258258+- Can create allow/deny rules
259259+- Similar concept to UFW but different syntax
260260+261261+**DHCP Server** - Assign IPs to internal network automatically
262262+- Not needed for mini-hack (static IPs used)
263263+264264+**Routing Tables** - Custom routes
265265+- Can add static routes for complex topologies
266266+267267+**VLANs** - Virtual network segmentation
268268+- Competition may use in advanced scenarios
269269+270270+These are covered in MikroTik documentation but not required for basic mini-hack completion.
271271+272272+## Competition Day Checklist
273273+274274+1. ✅ Login and set a **strong** password
275275+2. ✅ Assign external IP address to ether3
276276+3. ✅ Assign internal IP address to ether4
277277+4. ✅ Configure gateway (from topology doc)
278278+5. ✅ Add DNS servers (from topology doc)
279279+6. ✅ Enable NAT checkbox
280280+7. ✅ Create port forwarding rules for required services
281281+8. ✅ Test connectivity from external network
282282+283283+## Resources
284284+285285+**Official Documentation**:
286286+- [MikroTik Wiki](https://wiki.mikrotik.com/)
287287+- [Getting Started Guide](https://wiki.mikrotik.com/wiki/Manual:First_time_startup)
288288+289289+**Search Tips**:
290290+- "mikrotik quick set"
291291+- "mikrotik port forwarding"
292292+- "mikrotik NAT configuration"
293293+294294+Most common tasks are well-documented with examples.
+129
README.md
···11+# Linux Service Configuration Writeups
22+33+Quick reference guides for configuring services in Linux competitions. Assumes basic Linux knowledge (filesystem navigation, systemctl, ssh, etc.).
44+55+## Writeups
66+77+0. **[Mini-Hack Quick Start](00-mini-hack-overview.md)** - Complete mini-hack walkthrough checklist
88+1. **[Services Overview](01-services-overview.md)** - General approach to any service
99+2. **[Apache Web Service](02-apache-web-service.md)** - HTTP/HTTPS server configuration
1010+3. **[SSH Service](03-ssh-service.md)** - Remote access, keys, security
1111+4. **[Network Configuration](04-network-configuration.md)** - Static IPs across different distros
1212+5. **[DNS, Rsync, Cron](05-dns-rsync-cron.md)** - Name resolution and automated backups
1313+6. **[UFW Firewall](06-ufw-firewall.md)** - Ubuntu firewall configuration
1414+7. **[Active Connection Defense](07-active-connection-defense.md)** - Monitor and kill malicious connections
1515+8. **[MikroTik Router](08-mikrotik-router.md)** - Router configuration (2025 competition)
1616+1717+## Service-Specific Quick Reference
1818+1919+### Apache Service Names
2020+```bash
2121+apache2 # Ubuntu/Debian/Kali
2222+httpd # CentOS/RHEL
2323+```
2424+2525+### Network Configuration Files
2626+2727+| Distribution | Config Location |
2828+|--------------|----------------|
2929+| Kali/Debian | `/etc/network/interfaces` |
3030+| Ubuntu | `/etc/netplan/*.yaml` |
3131+| CentOS/RHEL | `/etc/sysconfig/network-scripts/ifcfg-*` |
3232+3333+### SSH Key Permissions
3434+```bash
3535+chmod 700 ~/.ssh/
3636+chmod 600 ~/.ssh/id_rsa # Private key
3737+chmod 644 ~/.ssh/id_rsa.pub # Public key
3838+chmod 644 ~/.ssh/authorized_keys
3939+```
4040+4141+Regenerate host keys on cloned VMs:
4242+```bash
4343+sudo ssh-keygen -A
4444+sudo systemctl restart sshd
4545+```
4646+4747+### UFW Firewall
4848+```bash
4949+sudo ufw enable
5050+sudo ufw allow ssh
5151+sudo ufw allow http
5252+sudo ufw allow from 192.168.1.100 # Specific IP
5353+sudo ufw deny from 192.168.1.0/24 # Entire subnet
5454+sudo ufw status numbered # See rule numbers
5555+sudo ufw delete 4 # Delete rule by number
5656+```
5757+5858+### Active Connection Monitoring
5959+```bash
6060+sudo netstat -tunap # All connections with PIDs
6161+sudo netstat -tunap | grep ESTABLISHED # Only active
6262+w # Who is logged in
6363+sudo kill <PID> # Kill by process ID
6464+sudo pkill -kill -u username # Kill all user processes
6565+```
6666+6767+### MikroTik Router
6868+**CLI**:
6969+```bash
7070+/ip address print
7171+/ip address add address=192.168.1.1/24 interface=ether3
7272+/ping 192.168.1.2
7373+interface print
7474+```
7575+7676+**Web GUI**: `http://<router-ip>:8080`
7777+Default login: `admin` / (blank password)
7878+7979+### Rsync + Cron
8080+**Rsync common patterns**:
8181+```bash
8282+rsync -av source/ dest/ # Basic sync
8383+rsync -av --delete source/ dest/ # Mirror (delete extra files in dest)
8484+rsync -avz local/ user@host:remote/ # Remote backup (z=compress)
8585+rsync -av --exclude='*.log' source/ dest/ # Exclude files
8686+rsync -av source/ dest/ --dry-run # Test without changes
8787+```
8888+8989+**Cron syntax**: `minute hour day month weekday command`
9090+```
9191+0 2 * * * /path/to/backup.sh # Daily at 2 AM
9292+*/15 * * * * /path/to/script.sh # Every 15 minutes
9393+0 */6 * * * rsync -av /data/ /backup/ # Every 6 hours
9494+```
9595+9696+## Distribution Differences
9797+9898+| Feature | Ubuntu | Kali | CentOS/RHEL |
9999+|---------|--------|------|-------------|
100100+| Apache service | `apache2` | `apache2` | `httpd` |
101101+| Network config | netplan YAML | interfaces | ifcfg-* scripts |
102102+| Firewall | UFW | iptables | firewall-cmd |
103103+| Cron service | `cron` | `cron` | `crond` |
104104+105105+**Router (2025)**: All distributions use MikroTik (replaces CentOS router)
106106+107107+## Competition Tips
108108+109109+1. **Network config varies by distro** - check which one first
110110+2. **SSH keys**: Regenerate on cloned VMs, fix permissions (700/.ssh, 600/private)
111111+3. **Enable firewall early** - UFW even with defaults improves security
112112+4. **Monitor active connections** - assign someone to watch `netstat -tunap`
113113+5. **Router (2025)**: MikroTik web GUI on port 8080, must enable NAT checkbox
114114+6. **Port forwarding**: Create both TCP and UDP rules for most services
115115+7. **Kill by PID not username** if you share accounts with red team
116116+8. **Backup configs before changes** - especially network configs (can lock yourself out)
117117+118118+## Critical Configuration Locations
119119+120120+| Service | Config File(s) |
121121+|---------|---------------|
122122+| SSH | `/etc/ssh/sshd_config` |
123123+| Apache (Ubuntu) | `/etc/apache2/apache2.conf`, `/etc/apache2/sites-available/` |
124124+| Apache (CentOS) | `/etc/httpd/conf/httpd.conf`, `/etc/httpd/conf.d/` |
125125+| Network (Kali) | `/etc/network/interfaces` |
126126+| Network (Ubuntu) | `/etc/netplan/*.yaml` |
127127+| Network (CentOS) | `/etc/sysconfig/network-scripts/ifcfg-*` |
128128+| DNS resolution | `/etc/resolv.conf` |
129129+| Cron jobs | `crontab -e` (per-user), `/etc/crontab` (system-wide) |