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 {
|
static Future<void> _processCapturedPacket(String packetLine) async {
|
||||||
// Print all packet lines to see what we're getting
|
// Check if this is a new packet header (timestamp line)
|
||||||
print('📋 RAW PACKET LINE: $packetLine');
|
if (packetLine.contains('IP ') && !packetLine.contains('0x')) {
|
||||||
|
// If we have accumulated hex data from previous packet, analyze it
|
||||||
// Check if it's from our monitored peers first
|
if (_currentPeerIP != null && _currentPacketHex.isNotEmpty) {
|
||||||
bool isFromPeer = false;
|
await _analyzeAccumulatedHex(_currentPeerIP!, _currentPacketHex.join('\n'));
|
||||||
String? peerIP;
|
|
||||||
|
|
||||||
for (final ip in _activePeerIPs) {
|
|
||||||
if (packetLine.contains(ip)) {
|
|
||||||
isFromPeer = true;
|
|
||||||
peerIP = ip;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (isFromPeer && peerIP != null) {
|
|
||||||
print('🎯 PEER TRAFFIC FROM $peerIP');
|
|
||||||
|
|
||||||
// For hex data lines, do deep payload analysis
|
// Reset for new packet
|
||||||
if (packetLine.contains('0x')) {
|
_currentPacketHex.clear();
|
||||||
print('🔍 HEX DATA DETECTED - ANALYZING PAYLOAD');
|
_currentPeerIP = null;
|
||||||
await _analyzeFullPayload(packetLine, peerIP);
|
|
||||||
|
// 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 {
|
static Future<void> _analyzeFullPayload(String hexPacketLine, String peerIP) async {
|
||||||
print('🔍 DEEP PAYLOAD ANALYSIS for peer $peerIP');
|
print('🔍 DEEP PAYLOAD ANALYSIS for peer $peerIP');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user