发新话题
打印

[转载]ipguard 0.04 for Linux patch

[转载]ipguard 0.04 for Linux patch

信息来源:邪恶八进制信息安全团队(www.eviloctal.com
Code Language : Diff
  1. *** packet.c.orig  2005-08-22 21:46:48.000000000 +0800
  2. --- packet.c  2007-09-23 22:46:38.000000000 +0800
  3. ***************
  4. *** 27,32 ****
  5. --- 27,34 ----
  6.  
  7.  #include <sys/types.h>
  8.  #include <sys/socket.h>
  9. + #include <time.h>
  10. + #include <netinet/ether.h>
  11.  #ifdef __OpenBSD__
  12.  # include <net/if.h>
  13.  # include <net/if_arp.h>
  14. ***************
  15. *** 302,314 ****
  16. --- 304,319 ----
  17.  
  18.    for (n = 0, p = pairs; n < pair_num; n++, p++) {
  19.      if (!memcmp(&zp_addr, &p->ip, sizeof(struct in_addr))) {
  20. +       /* wildcard IP */
  21.        if (!memcmp(&sh_addr, &p->mac, sizeof(struct ether_addr))) { zip++; if (!addr_nosubst) return; }
  22.      }
  23.      if (!memcmp(&zh_addr, &p->mac, sizeof(struct ether_addr))) {
  24. +       /* wildcard MAC */
  25.        if (!memcmp(&sp_addr, &p->ip, sizeof(struct in_addr))) { zmac++; if (!addr_nosubst) return; }
  26.      }
  27.      if (!memcmp(&sh_addr, &p->mac, sizeof(struct ether_addr))) {
  28.        if (!memcmp(&sp_addr, &p->ip, sizeof(struct in_addr))) { good++; return; }
  29. +       /* listed MAC but IP is not */
  30.        if (verbose) {
  31.          snprintf(s, 128, \"%s %-15s\", ether_ntoa(&sh_addr), inet_ntoa(sp_addr));
  32.          snprintf(s, 128, \"%s %-15s\", s, inet_ntoa(tp_addr));
  33. ***************
  34. *** 316,328 ****
  35. --- 321,338 ----
  36.        }
  37.        bip++; warn++;
  38.      } else if (!memcmp(&sp_addr, &p->ip, sizeof(struct in_addr))) {
  39. +       /* listed IP but MAC is not*/
  40.        if (verbose) {
  41.          snprintf(s, 128, \"%s %-15s\", ether_ntoa(&sh_addr), inet_ntoa(sp_addr));
  42.          snprintf(s, 128, \"%s %-15s\", s, inet_ntoa(tp_addr));
  43.          log_str(NOTICE, \"bmac:\", s);
  44.        }
  45.        bmac++; warn++;
  46. +     } else if (!memcmp(&tp_addr, &p->ip, sizeof(struct in_addr))) {
  47. +       /* weird gratuitous ARP (Linux, MacOS, Vista) */
  48. +       if (!memcmp(&zp_addr, &sp_addr, sizeof(struct in_addr))) { return; }
  49.      }
  50. +
  51.    }
  52.  
  53.    if (!warn) {
  54. ***************
  55. *** 341,348 ****
  56. --- 351,360 ----
  57.  
  58.    if (buffer_num) buffer_add();
  59.  
  60. +   /* do not block gratuitous ARP if hidden mode */
  61.    if (!memcmp(&sp_addr, &tp_addr, sizeof(struct in_addr))) { bent++; if (hidden) return; }
  62.  
  63. +   /* block evil IP */
  64.    if (!read_only) packet_sendfake();
  65.  }
  66.  
Parsed in 0.007 seconds
Libnet 1.0.2a
大隐于市

TOP

发新话题