1
0

patch-macof_c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --- dsniff-2.4.orig/macof.c 2001-03-15 09:33:04.000000000 +0100
  2. +++ dsniff-2.4/macof.c 2009-12-11 12:56:13.000000000 +0100
  3. @@ -48,8 +48,8 @@ usage(void)
  4. static void
  5. gen_mac(u_char *mac)
  6. {
  7. - *((in_addr_t *)mac) = libnet_get_prand(PRu32);
  8. - *((u_short *)(mac + 4)) = libnet_get_prand(PRu16);
  9. + *((in_addr_t *)mac) = libnet_get_prand(LIBNET_PRu32);
  10. + *((u_short *)(mac + 4)) = libnet_get_prand(LIBNET_PRu16);
  11. }
  12. int
  13. @@ -59,22 +59,23 @@ main(int argc, char *argv[])
  14. extern int optind;
  15. int c, i;
  16. struct libnet_link_int *llif;
  17. - char ebuf[PCAP_ERRBUF_SIZE];
  18. + char pcap_ebuf[PCAP_ERRBUF_SIZE];
  19. + char libnet_ebuf[LIBNET_ERRBUF_SIZE];
  20. u_char sha[ETHER_ADDR_LEN], tha[ETHER_ADDR_LEN];
  21. in_addr_t src, dst;
  22. u_short sport, dport;
  23. u_int32_t seq;
  24. - u_char pkt[ETH_H + IP_H + TCP_H];
  25. + libnet_t *l;
  26. while ((c = getopt(argc, argv, "vs:d:e:x:y:i:n:h?V")) != -1) {
  27. switch (c) {
  28. case 'v':
  29. break;
  30. case 's':
  31. - Src = libnet_name_resolve(optarg, 0);
  32. + Src = libnet_name2addr4(l, optarg, 0);
  33. break;
  34. case 'd':
  35. - Dst = libnet_name_resolve(optarg, 0);
  36. + Dst = libnet_name2addr4(l, optarg, 0);
  37. break;
  38. case 'e':
  39. Tha = (u_char *)ether_aton(optarg);
  40. @@ -101,13 +102,13 @@ main(int argc, char *argv[])
  41. if (argc != 0)
  42. usage();
  43. - if (!Intf && (Intf = pcap_lookupdev(ebuf)) == NULL)
  44. - errx(1, "%s", ebuf);
  45. + if (!Intf && (Intf = pcap_lookupdev(pcap_ebuf)) == NULL)
  46. + errx(1, "%s", pcap_ebuf);
  47. - if ((llif = libnet_open_link_interface(Intf, ebuf)) == 0)
  48. - errx(1, "%s", ebuf);
  49. + if ((l = libnet_init(LIBNET_LINK, Intf, libnet_ebuf)) == NULL)
  50. + errx(1, "%s", libnet_ebuf);
  51. - libnet_seed_prand();
  52. + libnet_seed_prand(l);
  53. for (i = 0; i != Repeat; i++) {
  54. @@ -117,39 +118,39 @@ main(int argc, char *argv[])
  55. else memcpy(tha, Tha, sizeof(tha));
  56. if (Src != 0) src = Src;
  57. - else src = libnet_get_prand(PRu32);
  58. + else src = libnet_get_prand(LIBNET_PRu32);
  59. if (Dst != 0) dst = Dst;
  60. - else dst = libnet_get_prand(PRu32);
  61. + else dst = libnet_get_prand(LIBNET_PRu32);
  62. if (Sport != 0) sport = Sport;
  63. - else sport = libnet_get_prand(PRu16);
  64. + else sport = libnet_get_prand(LIBNET_PRu16);
  65. if (Dport != 0) dport = Dport;
  66. - else dport = libnet_get_prand(PRu16);
  67. + else dport = libnet_get_prand(LIBNET_PRu16);
  68. - seq = libnet_get_prand(PRu32);
  69. -
  70. - libnet_build_ethernet(tha, sha, ETHERTYPE_IP, NULL, 0, pkt);
  71. -
  72. - libnet_build_ip(TCP_H, 0, libnet_get_prand(PRu16), 0, 64,
  73. - IPPROTO_TCP, src, dst, NULL, 0, pkt + ETH_H);
  74. + seq = libnet_get_prand(LIBNET_PRu32);
  75. libnet_build_tcp(sport, dport, seq, 0, TH_SYN, 512,
  76. - 0, NULL, 0, pkt + ETH_H + IP_H);
  77. + 0, 0, LIBNET_TCP_H, NULL, 0, l, 0);
  78. - libnet_do_checksum(pkt + ETH_H, IPPROTO_IP, IP_H);
  79. - libnet_do_checksum(pkt + ETH_H, IPPROTO_TCP, TCP_H);
  80. + libnet_build_ipv4(LIBNET_TCP_H, 0,
  81. + libnet_get_prand(LIBNET_PRu16), 0, 64,
  82. + IPPROTO_TCP, 0, src, dst, NULL, 0, l, 0);
  83. - if (libnet_write_link_layer(llif, Intf, pkt, sizeof(pkt)) < 0)
  84. + libnet_build_ethernet(tha, sha, ETHERTYPE_IP, NULL, 0, l, 0);
  85. +
  86. + if (libnet_write(l) < 0)
  87. errx(1, "write");
  88. + libnet_clear_packet(l);
  89. +
  90. fprintf(stderr, "%s ",
  91. ether_ntoa((struct ether_addr *)sha));
  92. fprintf(stderr, "%s %s.%d > %s.%d: S %u:%u(0) win 512\n",
  93. ether_ntoa((struct ether_addr *)tha),
  94. - libnet_host_lookup(Src, 0), sport,
  95. - libnet_host_lookup(Dst, 0), dport, seq, seq);
  96. + libnet_addr2name4(Src, 0), sport,
  97. + libnet_addr2name4(Dst, 0), dport, seq, seq);
  98. }
  99. exit(0);
  100. }