Commit f81c370
committed
Fix ICMP false positives by validating response type
The socket_icmp() method treated any ICMP response as host detection,
causing false positives when firewalls sent ICMP Type 3 errors.
Code only validated packet_id match, not ICMP response type.
RFC 792 specifies only Type 0 (Echo Reply) indicates host is alive.
1. Initialize delay/type/code to None (prevents UnboundLocalError)
2. Capture ICMP type and code from response packet
3. Validate type before declaring host alive
4. Only ICMP Echo Reply (type 0) = host alive
5. ICMP Type 3 errors = host unreachable
6. No response (timeout) = filtered/blocked
- Modified socket_icmp() to extract ICMP type/code
- Added validation: status = 'alive' only if type == 0
- Updated return to include icmp_type, icmp_code, status fields
- Modified response_conditions_matched() to validate status field
- Added 4 comprehensive unit tests
- Unit tests: 4 new tests cover all scenarios
* Echo Reply (type 0) = match
* Destination Unreachable (type 3) = no match
* Network Unreachable (type 3, code 0) = no match
* No response (timeout) = no match
- Integration tests: Validated with real hosts
- RFC 792 compliance: Only type 0 marked as alive
- Eliminates false positives from firewall error responses
- More accurate ICMP scanning results
- Better error diagnostics with type/code fields
Fixes #11861 parent 9b5ef1c commit f81c370
2 files changed
+111
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
221 | 225 | | |
222 | 226 | | |
223 | 227 | | |
| 228 | + | |
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
228 | 236 | | |
229 | 237 | | |
230 | 238 | | |
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
234 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
235 | 264 | | |
236 | 265 | | |
237 | 266 | | |
| |||
288 | 317 | | |
289 | 318 | | |
290 | 319 | | |
291 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
292 | 336 | | |
293 | 337 | | |
294 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
10 | 49 | | |
11 | 50 | | |
12 | 51 | | |
| |||
153 | 192 | | |
154 | 193 | | |
155 | 194 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
161 | 220 | | |
162 | 221 | | |
163 | 222 | | |
| |||
0 commit comments