Skip to content

Quick Start Guide

Get up and running with TrojanHorse.js in minutes. This guide covers the fastest path to threat detection.

5-Minute Setup

1. Installation

npm install trojanhorse-js
yarn add trojanhorse-js
<script src="https://unpkg.com/trojanhorse-js@latest/dist/trojanhorse.browser.min.js"></script>

2. Basic Usage

Node.js Application

import { TrojanHorse } from 'trojanhorse-js';

// Initialize with URLhaus (no API key required)
const trojan = new TrojanHorse({
  sources: ['urlhaus'],
  strategy: 'defensive'
});

// Check for threats
const threats = await trojan.scout('suspicious-domain.com');
console.log(`Found ${threats.length} threats`);

// Export data
const jsonData = await trojan.plunder('json');
console.log(`Exported ${Object.keys(jsonData).length} threat indicators`);

Browser Usage

<!DOCTYPE html>
<html>
<head>
    <title>Threat Check Demo</title>
</head>
<body>
    <script src="https://unpkg.com/trojanhorse-js@latest/dist/trojanhorse.browser.min.js"></script>
    <script>
        // Simple threat lookup (demo mode)
        const lookup = TrojanHorse.createLookup({ demoMode: true });

        async function checkDomain() {
            const isMalicious = await lookup.checkDomain('test-malware.com');
            console.log(isMalicious ? '🚨 Threat detected!' : '✅ Domain appears safe');
        }

        checkDomain();
    </script>
</body>
</html>

Create a secure vault for your API keys:

import { TrojanHorse } from 'trojanhorse-js';

// Create encrypted vault
const { trojan, vault } = await TrojanHorse.createVault('your-secure-password', {
  alienVault: 'your-alienvault-api-key',
  abuseipdb: 'your-abuseipdb-api-key',
  virustotal: 'your-virustotal-api-key'
});

// Enable multiple threat feeds
const result = await trojan.scout('suspicious-domain.com');
console.log('Threat analysis:', result);

Interactive Setup

For guided configuration, run the setup wizard:

node setup.js

This creates: - trojanhorse.config.js - Main configuration - quick-start.mjs - Ready-to-run example - Browser examples with your settings

Next Steps

Learn Core Concepts

Production Deployment

Advanced Usage

Common Use Cases

Security Monitoring

const trojan = new TrojanHorse({
  sources: ['urlhaus', 'alienvault', 'abuseipdb'],
  strategy: 'aggressive',
  events: {
    threatFound: (threat) => {
      console.log(`🚨 Threat detected: ${threat.indicator}`);
      // Send alert, log to SIEM, etc.
    }
  }
});

// Monitor specific targets
await trojan.scout('company-domain.com');

Batch Processing

const domains = ['site1.com', 'site2.com', 'site3.com'];

for (const domain of domains) {
  const threats = await trojan.scout(domain);
  if (threats.length > 0) {
    console.log(`${domain}: ${threats.length} threats found`);
  }
}

API Integration

// Express.js endpoint
app.post('/api/threat-check', async (req, res) => {
  try {
    const threats = await trojan.scout(req.body.target);
    res.json({
      safe: threats.length === 0,
      threatCount: threats.length,
      threats: threats.slice(0, 5) // Limit response size
    });
  } catch (error) {
    res.status(500).json({ error: 'Threat check failed' });
  }
});

Troubleshooting

Common Issues

Build Errors

# Clear cache and reinstall
npm cache clean --force
rm -rf node_modules package-lock.json
npm install

Browser CORS Issues - Use demo mode for development: demoMode: true - Set up CORS proxy for production - Consider backend API approach

API Rate Limits - Enable caching: caching: { enabled: true } - Use circuit breakers: resilience: { enabled: true } - Implement request throttling

Getting Help


Ready to dive deeper? Check out our Configuration Guide for advanced settings and optimization.