settings.tsā¢3.28 kB
export interface PentestConfig {
timeouts: {
nmap: number;
nuclei: number;
nikto: number;
sqlmap: number;
default: number;
};
rateLimiting: {
requestsPerSecond: number;
burstLimit: number;
};
security: {
maxTargets: number;
allowedPorts: number[];
blockedNetworks: string[];
requireAuthorization: boolean;
};
reporting: {
defaultFormat: 'html' | 'pdf' | 'json' | 'markdown';
includeRawOutput: boolean;
maxReportSize: number;
};
tools: {
nmapPath: string;
nucleiPath: string;
niktoPath: string;
sqlmapPath: string;
metasploitPath: string;
};
}
export const DEFAULT_CONFIG: PentestConfig = {
timeouts: {
nmap: 300000, // 5 minutes
nuclei: 600000, // 10 minutes
nikto: 600000, // 10 minutes
sqlmap: 600000, // 10 minutes
default: 60000 // 1 minute
},
rateLimiting: {
requestsPerSecond: 10,
burstLimit: 20
},
security: {
maxTargets: 1,
allowedPorts: [21, 22, 23, 25, 53, 80, 110, 143, 443, 993, 995, 3389, 5432, 3306],
blockedNetworks: [
'10.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16',
'127.0.0.0/8',
'169.254.0.0/16'
],
requireAuthorization: true
},
reporting: {
defaultFormat: 'html',
includeRawOutput: false,
maxReportSize: 10485760 // 10MB
},
tools: {
nmapPath: 'nmap',
nucleiPath: 'nuclei',
niktoPath: 'nikto',
sqlmapPath: 'sqlmap',
metasploitPath: 'msfconsole'
}
};
export class ConfigManager {
private config: PentestConfig;
constructor(customConfig?: Partial<PentestConfig>) {
this.config = {
...DEFAULT_CONFIG,
...customConfig
};
}
getConfig(): PentestConfig {
return { ...this.config };
}
updateConfig(updates: Partial<PentestConfig>): void {
this.config = {
...this.config,
...updates
};
}
isTargetAllowed(target: string): boolean {
// Check if target is in blocked networks
for (const network of this.config.security.blockedNetworks) {
if (this.isInNetwork(target, network)) {
return false;
}
}
return true;
}
private isInNetwork(ip: string, network: string): boolean {
// Simple network check - in production, use proper CIDR checking
const [networkAddr, prefixLength] = network.split('/');
// Basic check for common private networks
if (network === '10.0.0.0/8' && ip.startsWith('10.')) return true;
if (network === '172.16.0.0/12' && ip.match(/^172\.(1[6-9]|2[0-9]|3[01])\./)) return true;
if (network === '192.168.0.0/16' && ip.startsWith('192.168.')) return true;
if (network === '127.0.0.0/8' && ip.startsWith('127.')) return true;
if (network === '169.254.0.0/16' && ip.startsWith('169.254.')) return true;
return false;
}
getTimeout(tool: string): number {
const toolKey = tool as keyof PentestConfig['timeouts'];
return this.config.timeouts[toolKey] || this.config.timeouts.default;
}
getRateLimit(): { requestsPerSecond: number; burstLimit: number } {
return this.config.rateLimiting;
}
getToolPath(tool: string): string {
const toolKey = tool as keyof PentestConfig['tools'];
return this.config.tools[toolKey] || tool;
}
}