init
This commit is contained in:
54
setuper/README.md
Normal file
54
setuper/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# A/D Infrastructure Setuper
|
||||
|
||||
This script automates the installation and configuration of:
|
||||
- **Packmate**: Traffic analysis tool
|
||||
- **moded_distructive_farm**: Attack/defense farm
|
||||
- **Firegex**: Flag submission tool
|
||||
|
||||
## Usage
|
||||
|
||||
### Interactive Mode
|
||||
```bash
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
### With Environment Variables
|
||||
```bash
|
||||
export BOARD_URL="http://10.60.0.1"
|
||||
export TEAM_TOKEN="your-team-token"
|
||||
export NUM_TEAMS="10"
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
### Common
|
||||
- `SERVICES_DIR`: Directory for services (default: ../services)
|
||||
- `CONTROLLER_API`: Controller API URL (default: http://localhost:8001)
|
||||
- `SECRET_TOKEN`: API authentication token
|
||||
- `BOARD_URL`: Scoreboard URL
|
||||
- `TEAM_TOKEN`: Your team token
|
||||
|
||||
### Packmate
|
||||
- `PACKMATE_DB_PASSWORD`: Database password
|
||||
- `NET_INTERFACE`: Network interface to monitor
|
||||
- `PACKMATE_LOCAL_IP`: Local IP address
|
||||
- `WEB_LOGIN`: Web interface login
|
||||
- `WEB_PASSWORD`: Web interface password
|
||||
|
||||
### Farm
|
||||
- `FARM_DB_PASS`: Database password
|
||||
- `FARM_WEB_PASSWORD`: Web interface password
|
||||
- `NUM_TEAMS`: Number of teams
|
||||
- `IP_TEAM_BASE`: IP base for teams
|
||||
- `FARM_API_TOKEN`: API token
|
||||
|
||||
### Firegex
|
||||
- `FIREGEX_PORT`: Port for Firegex (default: 5000)
|
||||
|
||||
## Post-Setup
|
||||
|
||||
After running the setup script:
|
||||
1. Review generated .env files in each service directory
|
||||
2. Start services via controller API or web dashboard
|
||||
3. Access web dashboards on configured ports
|
||||
316
setuper/setup.sh
Normal file
316
setuper/setup.sh
Normal file
@@ -0,0 +1,316 @@
|
||||
#!/bin/bash
|
||||
# Setuper script for A/D Infrastructure
|
||||
# Installs and configures: Packmate, moded_distructive_farm, Firegex
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SERVICES_DIR="${SERVICES_DIR:-$SCRIPT_DIR/../services}"
|
||||
CONTROLLER_API="${CONTROLLER_API:-http://localhost:8001}"
|
||||
SECRET_TOKEN="${SECRET_TOKEN:-change-me-in-production}"
|
||||
|
||||
echo "=== A/D Infrastructure Setuper ==="
|
||||
echo "Services directory: $SERVICES_DIR"
|
||||
echo ""
|
||||
|
||||
# Create services directory
|
||||
mkdir -p "$SERVICES_DIR"
|
||||
|
||||
# Function to call controller API
|
||||
call_api() {
|
||||
local endpoint="$1"
|
||||
local method="${2:-GET}"
|
||||
local data="${3:-}"
|
||||
|
||||
if [ "$method" = "POST" ]; then
|
||||
curl -s -X POST "$CONTROLLER_API$endpoint" \
|
||||
-H "Authorization: Bearer $SECRET_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$data"
|
||||
else
|
||||
curl -s "$CONTROLLER_API$endpoint" \
|
||||
-H "Authorization: Bearer $SECRET_TOKEN"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to setup Packmate
|
||||
setup_packmate() {
|
||||
echo "=== Setting up Packmate ==="
|
||||
|
||||
local packmate_dir="$SERVICES_DIR/packmate"
|
||||
|
||||
if [ -d "$packmate_dir" ]; then
|
||||
echo "Packmate directory already exists, updating..."
|
||||
cd "$packmate_dir"
|
||||
git pull
|
||||
git submodule update --init --recursive
|
||||
else
|
||||
echo "Cloning Packmate with submodules..."
|
||||
git clone --recursive https://gitlab.com/packmate/Packmate.git "$packmate_dir"
|
||||
cd "$packmate_dir"
|
||||
fi
|
||||
|
||||
# Create necessary directories
|
||||
mkdir -p pcaps rsa_keys Packmate_stuff
|
||||
|
||||
# Create .env file
|
||||
cat > .env <<EOF
|
||||
BUILD_TAG=latest
|
||||
PACKMATE_DB_PASSWORD=${PACKMATE_DB_PASSWORD:-K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb}
|
||||
NET_INTERFACE=${NET_INTERFACE:-eth0}
|
||||
PACKMATE_LOCAL_IP=${PACKMATE_LOCAL_IP:-10.60.0.1}
|
||||
WEB_LOGIN=${WEB_LOGIN:-admin}
|
||||
WEB_PASSWORD=${WEB_PASSWORD:-admin123}
|
||||
EOF
|
||||
|
||||
# Create PostgreSQL config
|
||||
cat > Packmate_stuff/postgresql.conf <<EOF
|
||||
port = 65001
|
||||
max_connections = 100
|
||||
shared_buffers = 128MB
|
||||
EOF
|
||||
|
||||
# Create update script
|
||||
cat > Packmate_stuff/update_db_config.sh <<'EOF'
|
||||
#!/bin/bash
|
||||
cp /tmp/postgresql.conf /var/lib/postgresql/data/postgresql.conf
|
||||
EOF
|
||||
chmod +x Packmate_stuff/update_db_config.sh
|
||||
|
||||
# Create docker-compose.yml
|
||||
cat > docker-compose.yml <<EOF
|
||||
version: '3.8'
|
||||
services:
|
||||
packmate:
|
||||
environment:
|
||||
DB_PASSWORD: \${PACKMATE_DB_PASSWORD:-K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb}
|
||||
INTERFACE: \${NET_INTERFACE:-}
|
||||
LOCAL_IP: \${PACKMATE_LOCAL_IP}
|
||||
MODE: LIVE
|
||||
WEB_LOGIN: \${WEB_LOGIN:-admin}
|
||||
WEB_PASSWORD: \${WEB_PASSWORD:-admin123}
|
||||
OLD_STREAMS_CLEANUP_ENABLED: true
|
||||
OLD_STREAMS_CLEANUP_INTERVAL: 5
|
||||
OLD_STREAMS_CLEANUP_THRESHOLD: 240
|
||||
env_file:
|
||||
- .env
|
||||
container_name: packmate-app
|
||||
network_mode: "host"
|
||||
image: registry.gitlab.com/packmate/packmate:\${BUILD_TAG:-latest}
|
||||
volumes:
|
||||
- "./pcaps/:/app/pcaps/:ro"
|
||||
- "./rsa_keys/:/app/rsa_keys/:ro"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
container_name: packmate-db
|
||||
environment:
|
||||
POSTGRES_USER: packmate
|
||||
POSTGRES_PASSWORD: \${PACKMATE_DB_PASSWORD:-K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb}
|
||||
POSTGRES_DB: packmate
|
||||
network_mode: "host"
|
||||
image: postgres:15.2
|
||||
volumes:
|
||||
- "./Packmate_stuff/postgresql.conf:/tmp/postgresql.conf:ro"
|
||||
- "./Packmate_stuff/update_db_config.sh:/docker-entrypoint-initdb.d/_update_db_config.sh:ro"
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U packmate -p 65001" ]
|
||||
interval: 2s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
EOF
|
||||
|
||||
echo "Packmate setup complete!"
|
||||
|
||||
# Register with controller
|
||||
echo "Registering Packmate with controller..."
|
||||
call_api "/services" "POST" "{\"name\": \"packmate\", \"path\": \"$packmate_dir\", \"git_url\": \"https://gitlab.com/packmate/Packmate.git\"}"
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
# Function to setup moded_distructive_farm
|
||||
setup_farm() {
|
||||
echo ""
|
||||
echo "=== Setting up moded_distructive_farm ==="
|
||||
|
||||
local farm_dir="$SERVICES_DIR/moded_distructive_farm"
|
||||
|
||||
if [ -d "$farm_dir" ]; then
|
||||
echo "Farm directory already exists, updating..."
|
||||
cd "$farm_dir"
|
||||
git pull
|
||||
else
|
||||
echo "Cloning moded_distructive_farm..."
|
||||
git clone https://github.com/ilyastar9999/moded_distructive_farm.git "$farm_dir"
|
||||
cd "$farm_dir"
|
||||
fi
|
||||
|
||||
# Create .env file
|
||||
cat > .env <<EOF
|
||||
# Database configuration
|
||||
DB_PORT=5432
|
||||
DB_HOST=postgres
|
||||
DB_USER=farm
|
||||
DB_PASS=${FARM_DB_PASS:-farmpassword123}
|
||||
DB_NAME=farm
|
||||
|
||||
# Scoreboard configuration
|
||||
BOARD_URL=${BOARD_URL:-http://10.60.0.1}
|
||||
TEAM_TOKEN=${TEAM_TOKEN:-your-team-token}
|
||||
|
||||
# Web interface
|
||||
WEB_PASSWORD=${FARM_WEB_PASSWORD:-farmadmin}
|
||||
|
||||
# Game configuration
|
||||
NUM_TEAMS=${NUM_TEAMS:-10}
|
||||
IP_TEAM_BASE=${IP_TEAM_BASE:-10.60.}
|
||||
|
||||
# API Token
|
||||
API_TOKEN=${FARM_API_TOKEN:-farm-api-token-123}
|
||||
EOF
|
||||
|
||||
# Create docker-compose.yml
|
||||
cat > docker-compose.yml <<EOF
|
||||
version: '3.8'
|
||||
services:
|
||||
farm:
|
||||
image: ghcr.io/ilyastar9999/moded_distructive_farm:latest
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DB_PORT=\${DB_PORT}
|
||||
- DB_HOST=\${DB_HOST}
|
||||
- DB_USER=\${DB_USER}
|
||||
- DB_PASS=\${DB_PASS}
|
||||
- DB_NAME=\${DB_NAME}
|
||||
- BOARD_URL=\${BOARD_URL}
|
||||
- TEAM_TOKEN=\${TEAM_TOKEN}
|
||||
- WEB_PASSWORD=\${WEB_PASSWORD}
|
||||
- NUM_TEAMS=\${NUM_TEAMS}
|
||||
- IP_TEAM_BASE=\${IP_TEAM_BASE}
|
||||
- API_TOKEN=\${API_TOKEN}
|
||||
env_file:
|
||||
- .env
|
||||
container_name: farm-app
|
||||
restart: always
|
||||
ports:
|
||||
- "3333:8000"
|
||||
|
||||
postgres:
|
||||
image: postgres:18
|
||||
environment:
|
||||
- POSTGRES_USER=\${DB_USER}
|
||||
- POSTGRES_PASSWORD=\${DB_PASS}
|
||||
- POSTGRES_DB=\${DB_NAME}
|
||||
healthcheck:
|
||||
test: pg_isready -U \${DB_USER} -d \${DB_NAME}
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
volumes:
|
||||
- farm-db:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
farm-db:
|
||||
EOF
|
||||
|
||||
echo "moded_distructive_farm setup complete!"
|
||||
|
||||
# Register with controller
|
||||
echo "Registering farm with controller..."
|
||||
call_api "/services" "POST" "{\"name\": \"farm\", \"path\": \"$farm_dir\", \"git_url\": \"https://github.com/ilyastar9999/moded_distructive_farm.git\"}"
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
# Function to setup Firegex
|
||||
setup_firegex() {
|
||||
echo ""
|
||||
echo "=== Setting up Firegex ==="
|
||||
|
||||
local firegex_dir="$SERVICES_DIR/firegex"
|
||||
|
||||
if [ -d "$firegex_dir" ]; then
|
||||
echo "Firegex directory already exists, updating..."
|
||||
cd "$firegex_dir"
|
||||
git pull
|
||||
else
|
||||
echo "Cloning Firegex..."
|
||||
git clone https://github.com/Pwnzer0tt1/firegex.git "$firegex_dir"
|
||||
cd "$firegex_dir"
|
||||
fi
|
||||
|
||||
# Create .env file
|
||||
cat > .env <<EOF
|
||||
# Firegex configuration
|
||||
TEAM_TOKEN=${TEAM_TOKEN:-your-team-token}
|
||||
SCOREBOARD_URL=${BOARD_URL:-http://10.60.0.1}
|
||||
FIREGEX_PORT=${FIREGEX_PORT:-5000}
|
||||
EOF
|
||||
|
||||
# Create docker-compose.yml if not exists
|
||||
if [ ! -f "docker-compose.yml" ]; then
|
||||
cat > docker-compose.yml <<EOF
|
||||
version: '3.8'
|
||||
services:
|
||||
firegex:
|
||||
build: .
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- TEAM_TOKEN=\${TEAM_TOKEN}
|
||||
- SCOREBOARD_URL=\${SCOREBOARD_URL}
|
||||
container_name: firegex-app
|
||||
restart: always
|
||||
ports:
|
||||
- "\${FIREGEX_PORT:-5000}:5000"
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "Firegex setup complete!"
|
||||
|
||||
# Register with controller
|
||||
echo "Registering Firegex with controller..."
|
||||
call_api "/services" "POST" "{\"name\": \"firegex\", \"path\": \"$firegex_dir\", \"git_url\": \"https://github.com/Pwnzer0tt1/firegex.git\"}"
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
# Main setup flow
|
||||
main() {
|
||||
echo "Starting setup process..."
|
||||
echo ""
|
||||
|
||||
# Read configuration
|
||||
read -p "Setup Packmate? (y/n): " setup_pm
|
||||
read -p "Setup moded_distructive_farm? (y/n): " setup_fm
|
||||
read -p "Setup Firegex? (y/n): " setup_fg
|
||||
|
||||
echo ""
|
||||
|
||||
if [ "$setup_pm" = "y" ]; then
|
||||
setup_packmate
|
||||
fi
|
||||
|
||||
if [ "$setup_fm" = "y" ]; then
|
||||
setup_farm
|
||||
fi
|
||||
|
||||
if [ "$setup_fg" = "y" ]; then
|
||||
setup_firegex
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Setup Complete! ==="
|
||||
echo "Services have been configured in: $SERVICES_DIR"
|
||||
echo "You can manage them through the controller API or web dashboard"
|
||||
}
|
||||
|
||||
# Run main if executed directly
|
||||
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
|
||||
main
|
||||
fi
|
||||
Reference in New Issue
Block a user