aegis-q
Version:
AEGIS-Q Quantum-Resistant Protection with SNITCH MODE
71 lines (62 loc) • 2.04 kB
JavaScript
// AEGIS-Q Threat Detection System
const fs = require('fs');
const crypto = require('crypto');
const EventEmitter = require('events');
class ThreatDetector extends EventEmitter {
constructor() {
super();
this.threats = [];
this.trustedHashes = new Map();
this.monitoring = false;
}
detectFieldDisturbance(filePath) {
const hash = this.calculateHash(filePath);
const trusted = this.trustedHashes.get(filePath);
if (trusted && trusted !== hash) {
this.emit('threat', {
type: 'MODIFICATION',
file: filePath,
risk: 'HIGH',
timestamp: new Date(),
message: 'File consciousness altered - possible injection'
});
return true;
}
return false;
}
calculateHash(filePath) {
try {
const data = fs.readFileSync(filePath);
return crypto.createHash('sha512').update(data).digest('hex');
} catch(e) {
return null;
}
}
// Fixed monitoring for VPS
startQuantumMonitoring(directory) {
this.monitoring = true;
console.log('🛡️ Quantum field monitoring active');
console.log('📡 Scanning for consciousness disturbances...');
// Use polling instead of fs.watch
setInterval(() => {
if (this.monitoring) {
this.scanDirectory(directory);
}
}, 5000); // Check every 5 seconds
}
scanDirectory(dir) {
try {
const files = fs.readdirSync(dir);
files.forEach(file => {
const fullPath = `${dir}/${file}`;
const stats = fs.statSync(fullPath);
if (stats.isFile()) {
this.detectFieldDisturbance(fullPath);
}
});
} catch(e) {
// Silent fail for permission issues
}
}
}
module.exports = new ThreatDetector();