Enhance packet processing to accumulate and analyze hex data from monitored peers
This commit is contained in:
@@ -139,33 +139,43 @@ class ProtocolBlockingService {
|
||||
}
|
||||
}
|
||||
|
||||
static String? _currentPeerIP;
|
||||
static final List<String> _currentPacketHex = [];
|
||||
|
||||
static Future<void> _processCapturedPacket(String packetLine) async {
|
||||
// Print all packet lines to see what we're getting
|
||||
print('📋 RAW PACKET LINE: $packetLine');
|
||||
|
||||
// Check if it's from our monitored peers first
|
||||
bool isFromPeer = false;
|
||||
String? peerIP;
|
||||
|
||||
for (final ip in _activePeerIPs) {
|
||||
if (packetLine.contains(ip)) {
|
||||
isFromPeer = true;
|
||||
peerIP = ip;
|
||||
break;
|
||||
// Check if this is a new packet header (timestamp line)
|
||||
if (packetLine.contains('IP ') && !packetLine.contains('0x')) {
|
||||
// If we have accumulated hex data from previous packet, analyze it
|
||||
if (_currentPeerIP != null && _currentPacketHex.isNotEmpty) {
|
||||
await _analyzeAccumulatedHex(_currentPeerIP!, _currentPacketHex.join('\n'));
|
||||
}
|
||||
}
|
||||
|
||||
if (isFromPeer && peerIP != null) {
|
||||
print('🎯 PEER TRAFFIC FROM $peerIP');
|
||||
|
||||
// For hex data lines, do deep payload analysis
|
||||
if (packetLine.contains('0x')) {
|
||||
print('🔍 HEX DATA DETECTED - ANALYZING PAYLOAD');
|
||||
await _analyzeFullPayload(packetLine, peerIP);
|
||||
// Reset for new packet
|
||||
_currentPacketHex.clear();
|
||||
_currentPeerIP = null;
|
||||
|
||||
// Check if new packet is from our monitored peers
|
||||
for (final ip in _activePeerIPs) {
|
||||
if (packetLine.contains(ip)) {
|
||||
_currentPeerIP = ip;
|
||||
print('🎯 NEW PACKET FROM PEER $ip');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If this is hex data and we're tracking a peer packet
|
||||
else if (packetLine.contains('0x') && _currentPeerIP != null) {
|
||||
_currentPacketHex.add(packetLine);
|
||||
print('📦 Collecting hex data for ${_currentPeerIP}: ${_currentPacketHex.length} lines');
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _analyzeAccumulatedHex(String peerIP, String hexData) async {
|
||||
print('🔍 ANALYZING COMPLETE PACKET FROM $peerIP');
|
||||
print('📊 Hex data lines: ${_currentPacketHex.length}');
|
||||
await _analyzeFullPayload(hexData, peerIP);
|
||||
}
|
||||
|
||||
static Future<void> _analyzeFullPayload(String hexPacketLine, String peerIP) async {
|
||||
print('🔍 DEEP PAYLOAD ANALYSIS for peer $peerIP');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user