Commit 92cca900 authored by Adam Greene's avatar Adam Greene
Browse files

Add SYN/ACK style deduplication to ICMP replies

parent 9962c791
Loading
Loading
Loading
Loading
+11
Changes for src/proto-icmp.c: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include "output.h"
#include "masscan-status.h"
#include "templ-port.h"
#include "main-dedup.h"


/***************************************************************************
@@ -65,6 +66,13 @@ handle_icmp(struct Output *out, time_t timestamp,
    unsigned ip_them;
    unsigned cookie;

    /* dedup ICMP echo replies as well as SYN/ACK replies */
    static struct DedupTable *echo_reply_dedup = NULL;


    if (!echo_reply_dedup)
        echo_reply_dedup = dedup_create();

    ip_me = parsed->ip_dst[0]<<24 | parsed->ip_dst[1]<<16
            | parsed->ip_dst[2]<< 8 | parsed->ip_dst[3]<<0;
    ip_them = parsed->ip_src[0]<<24 | parsed->ip_src[1]<<16
@@ -81,6 +89,9 @@ handle_icmp(struct Output *out, time_t timestamp,
        if ((cookie & 0xFFFFFFFF) != seqno_me)
            return; /* not my response */

        if (dedup_is_duplicate(echo_reply_dedup, ip_them, 0, ip_me, 0))
            break;

        //if (syn_hash(ip_them, Templ_ICMP_echo) != seqno_me)
        //    return; /* not my response */