#!/bin/bash
# ===============================================
# NoctisAI Setup Script
# ===============================================
#
# This script sets up NoctisAI for malware development
# and threat intelligence operations.
#
# Usage: ./setup_noctis.sh
#
# ===============================================
set -e # Exit on any error
# Change to the script's directory (NoctisAI root)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"
echo "🌙 NoctisAI - Malware Development & Threat Intelligence MCP"
echo "=========================================================="
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if user is root
check_root() {
if [[ $EUID -eq 0 ]]; then
print_error "This script should not be run as root"
print_warning "Please run as a regular user with sudo privileges"
exit 1
fi
}
# Function to check sudo access
check_sudo() {
if ! sudo -n true 2>/dev/null; then
print_warning "This script requires sudo privileges for system package installation"
print_status "You may be prompted for your password"
fi
}
# Function to detect OS
detect_os() {
if [[ -f /etc/os-release ]]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
else
print_error "Cannot detect operating system"
exit 1
fi
print_status "Detected OS: $OS $VER"
}
# Function to install system packages
install_system_packages() {
print_status "Installing system packages for NoctisAI..."
# Update package lists
print_status "Updating package lists..."
sudo apt update
# Install essential packages for malware development and forensics
print_status "Installing essential packages..."
sudo apt install -y \
curl \
wget \
git \
unzip \
build-essential \
python3 \
python3-dev \
python3-pip \
python3-venv \
software-properties-common \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release \
gcc \
g++ \
make \
cmake \
pkg-config \
libssl-dev \
libffi-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
liblcms2-dev \
libwebp-dev \
libharfbuzz-dev \
libfribidi-dev \
libxcb1-dev \
nasm \
yasm \
pkg-config \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libatlas-base-dev \
gfortran \
libhdf5-dev \
pkg-config \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libatlas-base-dev \
gfortran \
libhdf5-dev
print_success "System packages installed"
}
# Function to install forensic tools
install_forensic_tools() {
print_status "Installing forensic analysis tools..."
# Install Volatility3
if ! command_exists vol.py; then
print_status "Installing Volatility3..."
git clone https://github.com/volatilityfoundation/volatility3.git /tmp/volatility3
cd /tmp/volatility3
pip3 install -e .
cd "$PROJECT_ROOT"
print_success "Volatility3 installed"
else
print_success "Volatility3 already installed"
fi
# Install Rekall
if ! command_exists rekall; then
print_status "Installing Rekall..."
pip3 install rekall-core
print_success "Rekall installed"
else
print_success "Rekall already installed"
fi
# Install Plaso
if ! command_exists log2timeline.py; then
print_status "Installing Plaso..."
sudo apt install -y plaso-tools
print_success "Plaso installed"
else
print_success "Plaso already installed"
fi
# Install TSK (The Sleuth Kit)
if ! command_exists tsk_gettimes; then
print_status "Installing The Sleuth Kit..."
sudo apt install -y sleuthkit
print_success "The Sleuth Kit installed"
else
print_success "The Sleuth Kit already installed"
fi
# Install YARA
if ! command_exists yara; then
print_status "Installing YARA..."
sudo apt install -y yara
print_success "YARA installed"
else
print_success "YARA already installed"
fi
# Install Radare2
if ! command_exists r2; then
print_status "Installing Radare2..."
git clone https://github.com/radareorg/radare2.git /tmp/radare2
cd /tmp/radare2
./sys/install.sh
cd "$PROJECT_ROOT"
print_success "Radare2 installed"
else
print_success "Radare2 already installed"
fi
}
# Function to setup Python environment
setup_python_environment() {
print_status "Setting up Python environment for NoctisAI..."
# Create virtual environment
if [ ! -d "noctis-env" ]; then
print_status "Creating virtual environment..."
python3 -m venv noctis-env
fi
# Activate virtual environment
print_status "Activating virtual environment..."
source noctis-env/bin/activate
# Upgrade pip
print_status "Upgrading pip..."
pip install --upgrade pip
# Install Python dependencies
print_status "Installing Python dependencies..."
pip install -r requirements.txt
print_success "Python environment setup complete"
}
# Function to setup TheSilencer integration
setup_thesilencer_integration() {
print_status "Setting up TheSilencer integration..."
# Check if TheSilencer exists
if [ ! -d "/home/yenn/TheSilencer" ]; then
print_warning "TheSilencer not found at /home/yenn/TheSilencer"
print_status "Please clone TheSilencer to /home/yenn/TheSilencer"
print_status "git clone https://github.com/Yenn503/TheSilencer.git /home/yenn/TheSilencer"
else
print_success "TheSilencer found at /home/yenn/TheSilencer"
fi
# Create symlink for easy access
if [ ! -L "tools/thesilencer" ]; then
ln -s /home/yenn/TheSilencer tools/thesilencer
print_success "TheSilencer symlink created"
fi
}
# Function to create output directories
create_output_directories() {
print_status "Creating output directories..."
mkdir -p output/{malware,threat_intel,osint,forensics,thesilencer}
mkdir -p logs
mkdir -p tools/{forensics,malware,osint}
print_success "Output directories created"
}
# Function to setup MCP configuration
setup_mcp_configuration() {
print_status "Setting up MCP configuration..."
# Create MCP configuration file
cat > noctis-mcp.json << EOF
{
"mcpServers": {
"noctis-ai": {
"command": "$(pwd)/noctis-env/bin/python3",
"args": [
"$(pwd)/src/noctis_ai/mcp/noctis_mcp.py",
"--debug"
],
"description": "NoctisAI - Malware Development & Threat Intelligence MCP",
"timeout": 300,
"alwaysAllow": [],
"env": {
"PYTHONUNBUFFERED": "1",
"PYTHONPATH": "$(pwd)",
"NOCTIS_ENV": "production"
}
}
}
}
EOF
print_success "MCP configuration created: noctis-mcp.json"
}
# Function to run tests
run_tests() {
print_status "Running tests to verify installation..."
# Activate virtual environment
source noctis-env/bin/activate
# Run basic tests
python -c "
import sys
sys.path.insert(0, 'src')
from noctis_ai.mcp.noctis_mcp import NoctisMCP
print('✅ NoctisAI MCP import successful')
"
print_success "Tests completed"
}
# Function to display final instructions
display_final_instructions() {
echo ""
echo "🌙 NoctisAI Setup Complete!"
echo "=========================="
echo ""
echo "✅ All system dependencies installed"
echo "✅ Python environment configured"
echo "✅ Forensic tools installed"
echo "✅ TheSilencer integration ready"
echo ""
echo "🌐 Service URLs:"
echo " • NoctisAI Server: http://localhost:8081"
echo " • Villager AI: http://localhost:37695"
echo " • HexStrike AI: http://localhost:8000"
echo ""
echo "📚 Next Steps:"
echo " 1. Start NoctisAI: ./scripts/start_noctis.sh"
echo " 2. Configure MCP: Add noctis-mcp.json to your MCP config"
echo " 3. Test integration: Use NoctisAI tools in Cursor"
echo ""
echo "🔗 Integration with Villager AI:"
echo " • NoctisAI works alongside Villager AI and HexStrike AI"
echo " • Intelligent tool selection based on task complexity"
echo " • Specialized malware development and threat intelligence"
echo ""
echo "🛠️ Available Tools:"
echo " • Malware Development (Python, C/C++, Rust, Assembly)"
echo " • Threat Intelligence (IOC analysis, MITRE ATT&CK)"
echo " • OSINT & Reconnaissance (Domain intel, social engineering)"
echo " • Forensic Analysis (Memory, disk, network forensics)"
echo " • TheSilencer Integration (Enhanced C/C++ malware framework)"
echo ""
echo "⚠️ Important Notes:"
echo " • Use responsibly for authorized security testing only"
echo " • Ensure compliance with applicable laws and regulations"
echo " • All operations are logged for audit purposes"
echo ""
echo "🔧 Troubleshooting:"
echo " • Check logs: tail -f logs/noctis.log"
echo " • Restart services: ./scripts/start_noctis.sh"
echo " • Run tests: python -m pytest tests/"
echo ""
}
# Main execution
main() {
echo "Starting NoctisAI setup..."
echo ""
# Pre-flight checks
check_root
check_sudo
detect_os
# Installation steps
install_system_packages
install_forensic_tools
setup_python_environment
setup_thesilencer_integration
create_output_directories
setup_mcp_configuration
# Run tests
run_tests
# Display final instructions
display_final_instructions
}
# Run main function
main "$@"