Call Trap and Trace System
A comprehensive VoIP security monitoring and analysis system designed for security analysts and managed service providers. This system captures extensive metadata from SIP traffic, performs advanced threat analysis, and generates detailed forensic reports for incident response and security investigations.
- SIP Protocol Analysis: Complete header parsing, call flow tracking, authentication analysis
- Media Intelligence: Codec identification, SDP parsing, quality metrics (jitter, packet loss, MOS)
- Device Fingerprinting: User-Agent analysis, OS detection, SIP stack identification
- Network Forensics: Packet analysis, fragmentation detection, protocol inspection
- Geographic Intelligence: Country/city identification, ISP tracking, ASN analysis
- Security Metadata: TLS detection, certificate analysis, encryption tracking
- Real-time risk scoring with 15+ detection algorithms
- Pattern matching for known attack vectors (toll-free abuse, premium rate fraud)
- Authentication failure tracking and brute-force detection
- Rapid call pattern analysis
- Geographic anomaly detection
- Header manipulation and spoofing detection
- Device inconsistency analysis
- Comprehensive security reports with 60+ metadata fields
- Threat intelligence generation with IOC extraction
- Call-specific forensic analysis
- Temporal pattern analysis
- Export capabilities (JSON, CSV) for SIEM integration
- Automated alert generation for high-risk calls
- Severity-based classification (HIGH/MEDIUM/LOW)
- Integration-ready alert format for security orchestration
# Python 3.8 or higher
python3 --version
# Required packages
pip install sqlite3 ipaddress hashlib# Clone or download the call trace system
wget call_trap_trace.py
# Make executable
chmod +x call_trap_trace.py
# Initialize database (automatic on first run)
python3 call_trap_trace.py --help# Monitor SIP traffic on default port 5060
python3 call_trap_trace.py --monitor
# Monitor on specific interface/port
python3 call_trap_trace.py --monitor --host 192.168.1.100 --port 5060# Generate 24-hour summary report
python3 call_trap_trace.py --report
# Generate report for specific time period
python3 call_trap_trace.py --report --hours 168# Export to JSON
python3 call_trap_trace.py --export security_report.json
# Export to CSV for spreadsheet analysis
python3 call_trap_trace.py --export call_data.csv --export-format csv# Start SIP monitoring
--monitor # Start real-time SIP traffic monitoring
--host <ip> # Bind to specific IP (default: 0.0.0.0)
--port <port> # Listen on specific port (default: 5060)--report # Generate comprehensive summary report
--threat-intel # Generate threat intelligence report
--forensic <call_id> # Detailed forensic analysis of specific call
--hours <n> # Time period for reports (default: 24)--analyze-ip <ip> # Analyze all calls from specific IP
--search-caller <number> # Search call history for specific caller
--list-alerts # Show recent security alerts--export <filename> # Export report to file
--export-format <format> # Export format: json or csv (default: json)--test <caller,dest,duration> # Add test call for system validationLaunch interactive mode for dynamic analysis:
python3 call_trap_trace.pyAvailable Commands:
monitor- Start enhanced monitoringreport- Generate comprehensive reportthreat-intel- Generate threat intelligenceforensic <call_id>- Detailed call analysisexport- Export dataanalyze-ip <ip>- Analyze IP addresssearch <caller>- Search caller historyalerts- Show recent alertstest <caller,dest>- Add test callquit- Exit
The system uses SQLite for data storage. Database files are created automatically:
call_trace.db- Main call recordscall_trace.log- System logs
# Modify trusted networks in ThreatAnalyzer class
self.trusted_networks = [
'192.168.', '10.', '172.16.' # Add your trusted IP ranges
]
# Customize high-risk countries
self.high_risk_countries = [
'+234', '+91', '+86', '+7' # Add country codes to monitor
]- Fraud Detection: Identify premium rate fraud, toll-free abuse
- Intrusion Detection: Detect SIP scanning, brute-force attacks
- Anomaly Detection: Identify unusual call patterns, geographic anomalies
- Forensic Analysis: Detailed call-by-call investigation
- Threat Hunting: Proactive search for IOCs and attack patterns
- Timeline Analysis: Reconstruct attack sequences
- Regulatory Compliance: Maintain detailed call records
- Quality Monitoring: Track call quality metrics
- Capacity Planning: Analyze traffic patterns
# Generate 7-day threat intelligence report
python3 call_trap_trace.py --threat-intel --hours 168
# Extract IOCs for external systems
python3 call_trap_trace.py --export iocs.json --threat-intel# Analyze specific suspicious call
python3 call_trap_trace.py --forensic abc123def456
# Investigate IP address activity
python3 call_trap_trace.py --analyze-ip 203.0.113.42Export data in formats compatible with security tools:
# Splunk-ready JSON export
python3 call_trap_trace.py --export splunk_data.json
# ELK Stack CSV import
python3 call_trap_trace.py --export elk_data.csv --export-format csv- Via headers, Contact headers, Route/Record-Route
- CSeq tracking, Branch analysis, Max-Forwards
- Content-Type, Content-Length, Expires
- Authorization methods, WWW-Authenticate
- Realm and nonce analysis, TLS version detection
- Certificate information, Encryption status
- SDP body parsing, Audio/video codecs
- Media IP and ports, Quality metrics
- Jitter, packet loss, latency, MOS scores
- User-Agent parsing, Device type classification
- OS fingerprinting, SIP stack identification
- Hardware vendor detection
- Source/destination analysis, Protocol detection
- Packet size analysis, Fragmentation detection
- TTL analysis, TCP flags
- Country and city identification, ISP information
- ASN tracking, Geographic anomaly detection
Permission Denied on Port 5060
# Run with appropriate privileges
sudo python3 call_trap_trace.py --monitor
# Or use non-privileged port
python3 call_trap_trace.py --monitor --port 15060Database Lock Errors
# Check for running instances
ps aux | grep call_trap_trace
# Kill existing processes if needed
pkill -f call_trap_trace.pyMissing Dependencies
# Install required packages
pip3 install ipaddress sqlite3# View system logs
tail -f call_trace.log
# Search for specific errors
grep ERROR call_trace.log- Monitor from dedicated security segment
- Use network taps or mirror ports for passive monitoring
- Implement proper access controls for database files
- Encrypt database files containing call records
- Implement log rotation for long-term storage
- Follow data retention policies
- Monitor system resources during high-volume periods
- Implement database maintenance routines
- Consider distributed deployment for large networks
# Daily export for Splunk ingestion
0 0 * * * /usr/bin/python3 /opt/call_trace/call_trap_trace.py --export /var/log/splunk/call_trace_$(date +\%Y\%m\%d).json --hours 24# Logstash-compatible CSV export
python3 call_trap_trace.py --export elk_import.csv --export-format csv --hours 24# Custom alert handler
def send_to_siem(alert):
# Integrate with your SIEM platform
pass# Vacuum database for performance
sqlite3 call_trace.db "VACUUM;"
# Clean old records (optional)
sqlite3 call_trace.db "DELETE FROM calls WHERE timestamp < datetime('now', '-30 days');"# Backup database
cp call_trace.db call_trace_backup_$(date +%Y%m%d).db
# Export all data
python3 call_trap_trace.py --export full_backup.json --hours 8760This system is designed for security professionals and can be extended with:
- Additional threat detection algorithms
- Integration with threat intelligence feeds
- Custom export formats
- Enhanced geographic databases
- Machine learning-based anomaly detection
This tool is provided for security analysis and monitoring purposes. Ensure compliance with local telecommunications monitoring regulations and privacy laws.
- Added comprehensive metadata capture (60+ fields)
- Enhanced threat detection with 15+ algorithms
- Geographic intelligence integration
- Device fingerprinting capabilities
- Forensic analysis features
- Threat intelligence reporting
- Multiple export formats
- Basic SIP monitoring
- Simple risk scoring
- JSON reporting
- SQLite storage
For MSP Security Teams: This tool provides enterprise-grade VoIP security monitoring with the detailed metadata capture needed for compliance, forensic analysis, and threat hunting in managed service environments.