|
| 1 | +# Debug Tracing Guide |
| 2 | + |
| 3 | +## 🐛 Debug Features Added |
| 4 | + |
| 5 | +This version includes comprehensive debug logging with **conditional compilation** support. Debug logging is automatically enabled/disabled based on build mode: |
| 6 | + |
| 7 | +- **Development Build** (`mvn package -P dev`): Debug logging enabled |
| 8 | +- **Production Build** (`mvn package -P prod`): Debug logging disabled |
| 9 | +- **Runtime Override**: Use `-Dinteractsh.debug=true` to enable debug in production builds |
| 10 | + |
| 11 | +## 📊 Debug Log Categories |
| 12 | + |
| 13 | +### **1. Response Processing (`InteractshClient.poll()`)** |
| 14 | +``` |
| 15 | +[DEBUG] Received response body length: X |
| 16 | +[DEBUG] Response body preview: {...} |
| 17 | +[DEBUG] Response JSON parsed successfully, keys: aes_key, data, ... |
| 18 | +[DEBUG] AES key extracted, length: X |
| 19 | +``` |
| 20 | + |
| 21 | +### **2. AES Key Decryption (`decryptAesKey()`)** |
| 22 | +``` |
| 23 | +[DEBUG] Decrypting AES key - Encrypted length: X |
| 24 | +[DEBUG] AES key Base64 decoded - CipherText length: X |
| 25 | +[DEBUG] AES key decryption successful - Key length: X |
| 26 | +``` |
| 27 | + |
| 28 | +### **3. Data Array Processing** |
| 29 | +``` |
| 30 | +[DEBUG] Received data array with X items |
| 31 | +[DEBUG] Processing item 1/X, encrypted length: X |
| 32 | +``` |
| 33 | + |
| 34 | +### **4. Data Decryption (`decryptData()`)** |
| 35 | +``` |
| 36 | +[DEBUG] Decrypting data - Input length: X, Key length: X |
| 37 | +[DEBUG] Base64 decoded - CipherText length: X |
| 38 | +[DEBUG] IV length: 16, CipherText length: X |
| 39 | +[DEBUG] Decryption successful - Result length: X |
| 40 | +``` |
| 41 | + |
| 42 | +### **5. Entry Creation (`InteractshEntry`)** |
| 43 | +``` |
| 44 | +[DEBUG] Creating InteractshEntry from event: {"protocol":"http",...} |
| 45 | +[DEBUG] JSON parsed successfully, keys: protocol, unique-id, remote-address, timestamp, raw-request, raw-response |
| 46 | +[DEBUG] Entry parsed - Protocol: http, UID: abc123, Address: 1.2.3.4, RawReq length: X, RawResp length: Y |
| 47 | +``` |
| 48 | + |
| 49 | +### **6. Protocol-Specific Processing** |
| 50 | +``` |
| 51 | +[DEBUG] Processing details for protocol: http |
| 52 | +[DEBUG] Processing HTTP entry |
| 53 | +[DEBUG] Details processed successfully, length: X |
| 54 | +``` |
| 55 | + |
| 56 | +### **7. Table Integration** |
| 57 | +``` |
| 58 | +[DEBUG] Entry added to table successfully |
| 59 | +``` |
| 60 | + |
| 61 | +### **8. Error Handling** |
| 62 | +``` |
| 63 | +[DEBUG] Exception in polling: JSONException - Unexpected character... |
| 64 | +``` |
| 65 | + |
| 66 | +## 🔍 Common Issues & Debug Patterns |
| 67 | + |
| 68 | +### **Issue 1: Empty Data Array** |
| 69 | +**Pattern:** |
| 70 | +``` |
| 71 | +[DEBUG] Received data array with 0 items |
| 72 | +``` |
| 73 | +**Possible Causes:** |
| 74 | +- No interactions received from server |
| 75 | +- Server polling interval too frequent |
| 76 | +- Authentication issues |
| 77 | + |
| 78 | +### **Issue 2: Decryption Failures** |
| 79 | +**Pattern:** |
| 80 | +``` |
| 81 | +[DEBUG] Exception in polling: BadPaddingException - ... |
| 82 | +``` |
| 83 | +**Possible Causes:** |
| 84 | +- Wrong private key |
| 85 | +- Corrupted encrypted data |
| 86 | +- Base64 encoding issues |
| 87 | + |
| 88 | +### **Issue 3: JSON Parsing Errors** |
| 89 | +**Pattern:** |
| 90 | +``` |
| 91 | +[DEBUG] Exception in polling: JSONException - Unexpected character at position X |
| 92 | +``` |
| 93 | +**Possible Causes:** |
| 94 | +- Invalid response from server |
| 95 | +- Malformed decrypted data |
| 96 | +- Character encoding issues |
| 97 | + |
| 98 | +### **Issue 4: Missing Fields** |
| 99 | +**Pattern:** |
| 100 | +``` |
| 101 | +[DEBUG] JSON parsed successfully, keys: protocol, unique-id |
| 102 | +# Missing: raw-request, raw-response |
| 103 | +``` |
| 104 | +**Possible Causes:** |
| 105 | +- Server returning partial data |
| 106 | +- Different API version |
| 107 | +- Protocol-specific field variations |
| 108 | + |
| 109 | +## 🛠 Debugging Workflow |
| 110 | + |
| 111 | +### **Step 1: Enable Burp Suite Output** |
| 112 | +1. Open Burp Suite |
| 113 | +2. Go to **Extensions** → **Installed** → **RequestBin Collaborator** |
| 114 | +3. Check **Output** tab for debug messages |
| 115 | + |
| 116 | +### **Step 2: Monitor Polling Cycle** |
| 117 | +Watch for this sequence in logs: |
| 118 | +``` |
| 119 | +[DEBUG] Received response body length: X |
| 120 | +[DEBUG] Response JSON parsed successfully |
| 121 | +[DEBUG] Received data array with X items |
| 122 | +[DEBUG] Processing item 1/X |
| 123 | +[DEBUG] Decryption successful |
| 124 | +[DEBUG] Entry added to table successfully |
| 125 | +``` |
| 126 | + |
| 127 | +### **Step 3: Identify Break Points** |
| 128 | +- **No response**: Check network connectivity |
| 129 | +- **JSON parse fail**: Check server response format |
| 130 | +- **Decryption fail**: Check keys and encryption parameters |
| 131 | +- **Entry creation fail**: Check required JSON fields |
| 132 | + |
| 133 | +### **Step 4: Analyze Data Content** |
| 134 | +Look for: |
| 135 | +- **Data preview**: First 500 characters of decrypted data |
| 136 | +- **Field lengths**: Ensure raw-request/raw-response are populated |
| 137 | +- **Protocol types**: DNS, HTTP, SMTP, etc. |
| 138 | + |
| 139 | +## 🔧 Advanced Debugging |
| 140 | + |
| 141 | +### **Custom Log Filtering** |
| 142 | +Search Burp Output for specific patterns: |
| 143 | +- `[DEBUG] Decrypted data preview:` - See actual interaction data |
| 144 | +- `[DEBUG] Entry parsed -` - Verify field extraction |
| 145 | +- `[DEBUG] Exception in polling:` - Find errors |
| 146 | + |
| 147 | +### **Performance Monitoring** |
| 148 | +Track these metrics: |
| 149 | +- Response body length (should be > 0) |
| 150 | +- Data array length (interactions count) |
| 151 | +- Decryption success rate |
| 152 | +- Entry processing time |
| 153 | + |
| 154 | +### **Manual Testing** |
| 155 | +1. **Trigger interactions**: Use `curl http://[subdomain].interact.sh` |
| 156 | +2. **Check polling**: Look for data array > 0 |
| 157 | +3. **Verify decryption**: Check for valid JSON in preview |
| 158 | +4. **Confirm display**: Ensure entries appear in table |
| 159 | + |
| 160 | +## 📝 Debug Log Analysis Examples |
| 161 | + |
| 162 | +### **Successful Interaction** |
| 163 | +``` |
| 164 | +[DEBUG] Received response body length: 1247 |
| 165 | +[DEBUG] Response JSON parsed successfully, keys: aes_key, data |
| 166 | +[DEBUG] AES key extracted, length: 256 |
| 167 | +[DEBUG] AES key decryption successful - Key length: 32 |
| 168 | +[DEBUG] Received data array with 1 items |
| 169 | +[DEBUG] Processing item 1/1, encrypted length: 892 |
| 170 | +[DEBUG] Decryption successful - Result length: 654 |
| 171 | +[DEBUG] Creating InteractshEntry from event: {"protocol":"http","unique-id":"abc123"...} |
| 172 | +[DEBUG] Entry parsed - Protocol: http, UID: abc123, Address: 1.2.3.4, RawReq length: 156, RawResp length: 287 |
| 173 | +[DEBUG] Processing HTTP entry |
| 174 | +[DEBUG] Entry added to table successfully |
| 175 | +``` |
| 176 | + |
| 177 | +### **Empty Response** |
| 178 | +``` |
| 179 | +[DEBUG] Received response body length: 67 |
| 180 | +[DEBUG] Response body preview: {"aes_key":"...", "data":[]} |
| 181 | +[DEBUG] Received data array with 0 items |
| 182 | +``` |
| 183 | + |
| 184 | +### **Decryption Error** |
| 185 | +``` |
| 186 | +[DEBUG] Decrypting data - Input length: 892, Key length: 32 |
| 187 | +[DEBUG] Exception in polling: BadPaddingException - Decryption error |
| 188 | +``` |
| 189 | + |
| 190 | +## 🎯 Performance Optimization |
| 191 | + |
| 192 | +Based on debug logs, you can: |
| 193 | +1. **Adjust polling interval** if too many empty responses |
| 194 | +2. **Optimize key caching** if decryption is slow |
| 195 | +3. **Batch process entries** if high volume |
| 196 | +4. **Filter protocols** if only specific types needed |
| 197 | + |
| 198 | +## 🎛 Debug Mode Control |
| 199 | + |
| 200 | +### **Build-time Configuration:** |
| 201 | +```bash |
| 202 | +# Development build (debug enabled) |
| 203 | +mvn clean package -P dev |
| 204 | + |
| 205 | +# Production build (debug disabled) |
| 206 | +mvn clean package -P prod |
| 207 | +``` |
| 208 | + |
| 209 | +### **Runtime Configuration:** |
| 210 | +```bash |
| 211 | +# Enable debug in production build |
| 212 | +java -Dinteractsh.debug=true -jar burpsuite.jar |
| 213 | +``` |
| 214 | + |
| 215 | +### **Programmatic Check:** |
| 216 | +```java |
| 217 | +// Check if debug mode is active |
| 218 | +boolean isDebug = DebugLogger.isDebugMode(); |
| 219 | + |
| 220 | +// Get current mode status |
| 221 | +String status = DebugLogger.getDebugStatus(); |
| 222 | +``` |
| 223 | + |
| 224 | +--- |
| 225 | + |
| 226 | +**Note:** Debug logging is automatically managed through build profiles. Production builds exclude debug infrastructure entirely for optimal performance and smaller file size. |
0 commit comments