#!/bin/bash # Download and process REMnux documentation for offline use # This script creates a searchable database of all tools and their usage set -e DOCS_DIR="/opt/remnux-docs" TOOLS_DB="/opt/remnux-docs/tools.db" echo "📚 Downloading REMnux Documentation..." # Create documentation directory mkdir -p "$DOCS_DIR" # Download key documentation files from REMnux docs BASE_URL="https://docs.remnux.org" # Categories of tools to download CATEGORIES=( "analyze+documents/pdf" "analyze+documents/general" "analyze+documents/microsoft+office" "analyze+documents/email+messages" "examine+static+properties/general" "statically+analyze+code/general" "statically+analyze+code/scripts" "dynamically+reverse-engineer+code/general" "gather+and+analyze+data" "view+or+edit+files" "general+utilities" ) # Function to download and process a documentation page download_category() { local category="$1" local filename=$(echo "$category" | sed 's/+/_/g' | sed 's/\//_/g') echo "Downloading: $category" if curl -s "$BASE_URL/discover-the-tools/$category.md" -o "$DOCS_DIR/${filename}.md"; then echo "✓ Downloaded $filename.md" else echo "⚠ Failed to download $category" fi } # Download all categories for category in "${CATEGORIES[@]}"; do download_category "$category" done # Create a consolidated tools database echo "🔍 Creating searchable tools database..." # Function to extract tool information from markdown files create_tools_db() { echo "# REMnux Tools Database" > "$TOOLS_DB" echo "# Format: TOOL_NAME|DESCRIPTION|CATEGORY|USAGE_HINTS" >> "$TOOLS_DB" echo "" >> "$TOOLS_DB" for md_file in "$DOCS_DIR"/*.md; do if [[ -f "$md_file" ]]; then local category=$(basename "$md_file" .md | sed 's/_/ /g') # Extract tool entries (they start with ##) awk -v cat="$category" ' /^## / { if (tool_name != "") { print tool_name "|" description "|" cat "|" usage } tool_name = substr($0, 4) # Remove "## " description = "" usage = "" in_tool = 1 next } /^#/ && !/^## / { in_tool = 0; next } in_tool && /^[A-Z]/ && description == "" { description = $0 next } in_tool && /^\*\*Website/ { usage = usage $0 " " next } in_tool && /^\*\*Notes/ { usage = usage $0 " " next } END { if (tool_name != "") { print tool_name "|" description "|" cat "|" usage } } ' "$md_file" >> "$TOOLS_DB" fi done } create_tools_db # Add our custom tools to the database echo "" >> "$TOOLS_DB" echo "# Additional Tools Added to Container" >> "$TOOLS_DB" echo "capa|Malware capability detection tool from Mandiant|malware analysis|Analyze executable files to identify capabilities" >> "$TOOLS_DB" echo "box-js|JavaScript sandbox for malware analysis|malware analysis|box-js sample.js to analyze JavaScript in sandbox" >> "$TOOLS_DB" echo "visidata|Interactive data exploration tool|data analysis|vd filename.csv to explore data interactively" >> "$TOOLS_DB" echo "unfurl_cli.py|URL analysis and extraction tool|data analysis|unfurl_cli.py URL to analyze and extract components" >> "$TOOLS_DB" echo "✅ Documentation download complete!" echo "📊 Tools database created at: $TOOLS_DB" # Count tools TOOL_COUNT=$(grep -c "^[^#]" "$TOOLS_DB" | head -1) echo "🔧 Indexed $TOOL_COUNT tools" echo "" echo "Usage: Use 'find-tool' command to search through all available tools"