Skip to content

SpecTrace is an advanced cybersecurity platform that combines cutting-edge AI algorithms with Ghidra's powerful binary analysis capabilities to provide comprehensive firmware security analysis, vulnerability detection, and compliance validation.

Notifications You must be signed in to change notification settings

peres84/specTrace

Repository files navigation

πŸ›‘οΈ SpecTrace

AI-Powered Firmware Security Analysis Platform with Binary Decompilation

SpecTrace is an advanced cybersecurity platform that combines cutting-edge AI algorithms with Ghidra's powerful binary analysis capabilities to provide comprehensive firmware security analysis, vulnerability detection, and compliance validation.

SpecTrace Banner


🎯 Overview

SpecTrace revolutionizes firmware security analysis by offering both text-based and binary-based analysis workflows. Upload source code or binary firmware files, and get detailed security insights powered by OpenAI's GPT-4 and NSA's Ghidra decompiler.

πŸ”₯ Key Capabilities

  • πŸ”§ Binary Decompilation: Convert firmware binaries to readable assembly/C code using Ghidra
  • πŸ€– AI Security Analysis: GPT-4 powered vulnerability detection and risk assessment
  • πŸ“Š Compliance Validation: Automated security compliance checking
  • πŸ“ˆ Change Analysis: Compare firmware versions and track modifications
  • 🎨 Modern Interface: Intuitive React dashboard with real-time progress tracking

πŸš€ Features

Binary Analysis

  • Multi-Format Support: ELF, PE, Mach-O, Intel HEX, raw binaries
  • Architecture Detection: Automatic CPU architecture identification
  • Decompilation: Assembly disassembly and high-level C code generation
  • Metadata Extraction: Compiler info, build details, and binary characteristics

Security Analysis

  • Vulnerability Detection: Buffer overflows, hardcoded credentials, memory issues
  • Risk Assessment: CRITICAL, HIGH, MEDIUM, LOW severity classification
  • Pattern Recognition: Common attack vectors and security anti-patterns
  • Compliance Checking: Industry standard security requirement validation

Analysis Workflows

  • Text Mode: Direct source code analysis (.asm, .c, .h files)
  • Binary Mode: Automatic decompilation + analysis workflow
  • Dual Comparison: Compare old vs new firmware versions
  • Specification Validation: Ensure code matches documentation

User Experience

  • Drag & Drop Upload: Intuitive file handling
  • Real-Time Progress: Live analysis status with detailed steps
  • Comprehensive Reports: Detailed findings with actionable recommendations
  • Debug Panel: Development insights and API call monitoring

πŸ“ Architecture

spectrace/
β”œβ”€β”€ πŸ“ api/                     # FastAPI Backend
β”‚   β”œβ”€β”€ πŸ“ services/            # Core analysis services
β”‚   β”‚   β”œβ”€β”€ ghidra_service.py   # Binary decompilation
β”‚   β”‚   β”œβ”€β”€ code_analyzer.py    # AI code analysis
β”‚   β”‚   β”œβ”€β”€ spec_analyzer.py    # Specification analysis
β”‚   β”‚   └── compliance_analyzer.py # Compliance validation
β”‚   β”œβ”€β”€ πŸ“ routes/              # API endpoints
β”‚   β”œβ”€β”€ πŸ“ middleware/          # Error handling & logging
β”‚   β”œβ”€β”€ πŸ“ tests/              # Automated tests
β”‚   └── πŸ“„ main.py             # Application entry point
β”œβ”€β”€ πŸ“ dashboard/               # React Frontend
β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   β”œβ”€β”€ πŸ“ pages/          # Main application pages
β”‚   β”‚   β”œβ”€β”€ πŸ“ components/     # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ πŸ“ lib/           # Utility functions
β”‚   β”‚   └── πŸ“ hooks/         # Custom React hooks
β”œβ”€β”€ πŸ“ features/               # Feature documentation
β”œβ”€β”€ πŸ“ docs/                  # Installation & setup guides
β”œβ”€β”€ πŸ“ files/                 # Sample test files
β”œβ”€β”€ πŸ“ images/                # Screenshots & assets
β”œβ”€β”€ 🐳 Dockerfile             # Container configuration
β”œβ”€β”€ 🐳 docker-compose.yml     # Multi-service orchestration
└── πŸ“„ README.md              # This file

πŸ› οΈ Technology Stack

Backend (API)

Component Technology Purpose
Framework FastAPI High-performance async API
Language Python 3.11+ Core application logic
AI Engine OpenAI GPT-4 Security analysis & insights
Binary Analysis Ghidra 11.0.3+ Firmware decompilation
Database In-memory Session state management
Testing pytest Automated testing

Frontend (Dashboard)

Component Technology Purpose
Framework React 18 + TypeScript User interface
Build Tool Vite Fast development & building
Styling Tailwind CSS Responsive design
Components shadcn/ui + Radix UI Accessible components
State Management React Hooks Application state
HTTP Client Fetch API Backend communication

Infrastructure

Component Technology Purpose
Containerization Docker + Docker Compose Deployment & development
Web Server Uvicorn ASGI server
Reverse Proxy Built-in CORS Cross-origin requests
File Storage Local filesystem Temporary file handling

πŸ“‹ Prerequisites

For All Platforms

  • OpenAI API Key (required for AI analysis)
  • Internet Connection (for AI API calls and package downloads)
  • 4GB+ RAM (for Ghidra binary analysis)
  • 2GB+ Disk Space (for Ghidra installation and temporary files)

Platform-Specific Requirements

Platform Requirements Installation Guide
πŸͺŸ Windows Python 3.11+, Node.js 18+, Java 17+, Git πŸ“– Windows Setup
🍎 macOS Python 3.11+, Node.js 18+, Java 17+, Homebrew πŸ“– macOS Setup
🐧 Linux Python 3.11+, Node.js 18+, Java 17+, wget/curl πŸ“– Linux Setup
🐳 Docker Docker Desktop or Docker Engine πŸ“– Docker Setup

πŸš€ Quick Start

🐳 Docker Installation (Recommended)

Fastest way to get started with zero configuration:

# 1. Clone the repository
git clone https://github.com/your-repo/spectrace.git
cd spectrace

# 2. Create environment configuration
echo "OPENAI_API_KEY=your_openai_api_key_here" > .env

# 3. Launch the platform
docker-compose up --build

πŸŽ‰ Access the application:

πŸ’» Manual Installation

Choose your platform-specific guide:


🎯 Usage Guide

Step 1: Choose Analysis Mode

Analysis Mode Selection

πŸ“„ Text Mode: Upload source code files directly

  • Supported: .asm, .c, .h, .txt files
  • Use case: When you have firmware source code

πŸ”§ Binary Mode: Upload firmware binaries for decompilation

  • Supported: .bin, .elf, .exe, .hex files
  • Use case: When you only have compiled firmware

Step 2: Upload Files

File Upload Interface

Required Files:

  • Firmware Files: 2 versions (original + updated)
  • Specifications: 2 versions (original + updated documentation)

File Size Limits:

  • Text files: 50MB max
  • Binary files: 100MB max
  • Specifications: 10MB max

Step 3: Analysis Process

Analysis Progress

The platform automatically:

  1. πŸ” Prepares Analysis: Validates files and sets up environment
  2. πŸ”§ Decompiles Binaries: Converts binaries to readable code (if binary mode)
  3. πŸ“Š Analyzes Code: AI-powered security analysis and comparison
  4. πŸ“ Processes Specs: Documentation analysis and change detection
  5. βœ… Validates Compliance: Checks code-to-spec alignment
  6. πŸ“‹ Generates Report: Comprehensive results with recommendations

Step 4: Review Results

Analysis Results

Report Sections:

  • 🚨 Security Findings: Vulnerabilities with severity ratings
  • πŸ“ˆ Risk Assessment: Overall security posture
  • πŸ”„ Change Analysis: Code modifications and their impact
  • πŸ“‹ Compliance Status: Documentation alignment score
  • πŸ’‘ Recommendations: Actionable security improvements

πŸ“Š API Reference

Binary Analysis Endpoints

POST /api/v1/decompile
Content-Type: multipart/form-data

# Upload binary file for decompilation
# Returns: Assembly code + decompiled C code

Code Analysis Endpoints

POST /api/v1/compare-code
Content-Type: application/json

# Compare two firmware code versions
# Returns: Security findings + risk assessment

Specification Analysis Endpoints

POST /api/v1/compare-specs
Content-Type: application/json

# Compare two specification versions
# Returns: Feature changes + behavioral analysis

Compliance Validation Endpoints

POST /api/v1/validate-compliance
Content-Type: application/json

# Validate code-to-specification alignment
# Returns: Compliance score + mismatches

πŸ“š Full API Documentation: http://localhost:8000/docs


πŸ”§ Supported Binary Formats

Format Extension Architecture Use Case
ELF .elf Linux/Embedded Linux executables, IoT firmware
PE .exe, .dll Windows Windows programs, drivers
Mach-O .app, .dylib macOS macOS applications
Intel HEX .hex, .ihex Embedded Microcontroller firmware
Raw Binary .bin, .img Various Custom firmware images
S-Record .s19, .srec Embedded Motorola S-record format

πŸ§ͺ Testing

Run Backend Tests

cd api
pytest -v                    # Run all tests
pytest tests/test_ghidra*    # Test Ghidra integration
python run_tests.py          # Custom test configuration

Run Frontend Tests

cd dashboard
npm test                     # Run React tests
npm run lint                 # Check code quality
npm run type-check          # TypeScript validation

Integration Testing

# Test complete workflow with sample files
cd api
python -c "
import asyncio
from services.ghidra_service import GhidraDecompiler

async def test():
    decompiler = GhidraDecompiler()
    print('βœ… Ghidra integration ready!')

asyncio.run(test())
"

πŸ› οΈ Development

Development Setup

# 1. Clone and setup
git clone https://github.com/your-repo/spectrace.git
cd spectrace

# 2. Backend development
cd api
pip install -r requirements.txt
python main.py

# 3. Frontend development
cd dashboard
npm install
npm run dev

Available Scripts

Backend (API)

python main.py              # Start development server
pytest                      # Run tests
python run_tests.py         # Custom test runner
uvicorn main:app --reload   # Alternative server start

Frontend (Dashboard)

npm run dev                 # Development server
npm run build              # Production build
npm run preview            # Preview production build
npm run lint               # Code linting
npm run type-check         # TypeScript checking

Environment Variables

# Required
OPENAI_API_KEY=sk-...       # Your OpenAI API key

# Optional
GHIDRA_INSTALL_DIR=/opt/ghidra    # Ghidra installation path
JAVA_HOME=/usr/lib/jvm/java-17    # Java installation path
DEBUG=true                        # Enable debug logging

πŸ‘₯ Team

SpecTrace was developed by the following team for the AI Cybersecurity Hackathon - Sponsored by SAP & KPMG:

  • Richard Meinsen
  • Joseph Chris Adrian
  • Javier Peres
  • Julian Stosse

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright Β© 2025 SpecTrace Team Hackathon


πŸ›‘οΈ SpecTrace - Revolutionizing Firmware Security with AI

Built with ❀️ for the cybersecurity community

GitHub Stars Docker Pulls License: MIT

🌐 Website β€’ πŸ“– Documentation β€’ πŸ’¬ Community β€’ 🐦 Twitter

About

SpecTrace is an advanced cybersecurity platform that combines cutting-edge AI algorithms with Ghidra's powerful binary analysis capabilities to provide comprehensive firmware security analysis, vulnerability detection, and compliance validation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published