diff -ur dsniff-2.4/arpspoof.c dsniff-2.4-mine/arpspoof.c
old
|
new
|
|
21 | 21 | #include <err.h> |
22 | 22 | #include <libnet.h> |
23 | 23 | #include <pcap.h> |
24 | | |
| 24 | #ifdef HAVE_NET_ETHERNET_H |
| 25 | #include <net/ethernet.h> |
| 26 | #else |
| 27 | extern char *ether_ntoa(struct ether_addr *); |
| 28 | #endif |
25 | 29 | #include "arp.h" |
26 | 30 | #include "version.h" |
27 | 31 | |
28 | | extern char *ether_ntoa(struct ether_addr *); |
29 | | |
30 | | static struct libnet_link_int *llif; |
| 32 | static libnet_t *l; |
31 | 33 | static struct ether_addr spoof_mac, target_mac; |
32 | 34 | static in_addr_t spoof_ip, target_ip; |
33 | 35 | static char *intf; |
… |
… |
|
41 | 43 | } |
42 | 44 | |
43 | 45 | static int |
44 | | arp_send(struct libnet_link_int *llif, char *dev, |
45 | | int op, u_char *sha, in_addr_t spa, u_char *tha, in_addr_t tpa) |
| 46 | arp_send(libnet_t *l, int op, u_int8_t *sha, |
| 47 | in_addr_t spa, u_int8_t *tha, in_addr_t tpa) |
46 | 48 | { |
47 | | char ebuf[128]; |
48 | | u_char pkt[60]; |
49 | | |
| 49 | int retval; |
| 50 | |
50 | 51 | if (sha == NULL && |
51 | | (sha = (u_char *)libnet_get_hwaddr(llif, dev, ebuf)) == NULL) { |
| 52 | (sha = (u_int8_t *)libnet_get_hwaddr(l)) == NULL) { |
52 | 53 | return (-1); |
53 | 54 | } |
54 | 55 | if (spa == 0) { |
55 | | if ((spa = libnet_get_ipaddr(llif, dev, ebuf)) == 0) |
| 56 | if ((spa = libnet_get_ipaddr4(l)) == -1) |
56 | 57 | return (-1); |
57 | | spa = htonl(spa); /* XXX */ |
58 | 58 | } |
59 | 59 | if (tha == NULL) |
60 | 60 | tha = "\xff\xff\xff\xff\xff\xff"; |
61 | 61 | |
62 | | libnet_build_ethernet(tha, sha, ETHERTYPE_ARP, NULL, 0, pkt); |
| 62 | libnet_autobuild_arp(op, sha, (u_int8_t *)&spa, |
| 63 | tha, (u_int8_t *)&tpa, l); |
| 64 | libnet_build_ethernet(tha, sha, ETHERTYPE_ARP, NULL, 0, l, 0); |
63 | 65 | |
64 | | libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP, ETHER_ADDR_LEN, 4, |
65 | | op, sha, (u_char *)&spa, tha, (u_char *)&tpa, |
66 | | NULL, 0, pkt + ETH_H); |
67 | | |
68 | 66 | fprintf(stderr, "%s ", |
69 | 67 | ether_ntoa((struct ether_addr *)sha)); |
70 | 68 | |
71 | 69 | if (op == ARPOP_REQUEST) { |
72 | 70 | fprintf(stderr, "%s 0806 42: arp who-has %s tell %s\n", |
73 | 71 | ether_ntoa((struct ether_addr *)tha), |
74 | | libnet_host_lookup(tpa, 0), |
75 | | libnet_host_lookup(spa, 0)); |
| 72 | libnet_addr2name4(tpa, LIBNET_DONT_RESOLVE), |
| 73 | libnet_addr2name4(spa, LIBNET_DONT_RESOLVE)); |
76 | 74 | } |
77 | 75 | else { |
78 | 76 | fprintf(stderr, "%s 0806 42: arp reply %s is-at ", |
79 | 77 | ether_ntoa((struct ether_addr *)tha), |
80 | | libnet_host_lookup(spa, 0)); |
| 78 | libnet_addr2name4(spa, LIBNET_DONT_RESOLVE)); |
81 | 79 | fprintf(stderr, "%s\n", |
82 | 80 | ether_ntoa((struct ether_addr *)sha)); |
83 | 81 | } |
84 | | return (libnet_write_link_layer(llif, dev, pkt, sizeof(pkt)) == sizeof(pkt)); |
| 82 | retval = libnet_write(l); |
| 83 | if (retval) |
| 84 | fprintf(stderr, "%s", libnet_geterror(l)); |
| 85 | |
| 86 | libnet_clear_packet(l); |
| 87 | |
| 88 | return retval; |
85 | 89 | } |
86 | 90 | |
87 | 91 | #ifdef __linux__ |
… |
… |
|
119 | 123 | /* XXX - force the kernel to arp. feh. */ |
120 | 124 | arp_force(ip); |
121 | 125 | #else |
122 | | arp_send(llif, intf, ARPOP_REQUEST, NULL, 0, NULL, ip); |
| 126 | arp_send(l, ARPOP_REQUEST, NULL, 0, NULL, ip); |
123 | 127 | #endif |
124 | 128 | sleep(1); |
125 | 129 | } |
… |
… |
|
136 | 140 | if (arp_find(spoof_ip, &spoof_mac)) { |
137 | 141 | for (i = 0; i < 3; i++) { |
138 | 142 | /* XXX - on BSD, requires ETHERSPOOF kernel. */ |
139 | | arp_send(llif, intf, ARPOP_REPLY, |
140 | | (u_char *)&spoof_mac, spoof_ip, |
141 | | (target_ip ? (u_char *)&target_mac : NULL), |
| 143 | arp_send(l, ARPOP_REPLY, |
| 144 | (u_int8_t *)&spoof_mac, spoof_ip, |
| 145 | (target_ip ? (u_int8_t *)&target_mac : NULL), |
142 | 146 | target_ip); |
143 | 147 | sleep(1); |
144 | 148 | } |
… |
… |
|
151 | 155 | { |
152 | 156 | extern char *optarg; |
153 | 157 | extern int optind; |
154 | | char ebuf[PCAP_ERRBUF_SIZE]; |
| 158 | char pcap_ebuf[PCAP_ERRBUF_SIZE]; |
| 159 | char libnet_ebuf[LIBNET_ERRBUF_SIZE]; |
155 | 160 | int c; |
156 | 161 | |
157 | 162 | intf = NULL; |
… |
… |
|
163 | 168 | intf = optarg; |
164 | 169 | break; |
165 | 170 | case 't': |
166 | | if ((target_ip = libnet_name_resolve(optarg, 1)) == -1) |
| 171 | if ((target_ip = libnet_name2addr4(l, optarg, LIBNET_RESOLVE)) == -1) |
167 | 172 | usage(); |
168 | 173 | break; |
169 | 174 | default: |
… |
… |
|
176 | 181 | if (argc != 1) |
177 | 182 | usage(); |
178 | 183 | |
179 | | if ((spoof_ip = libnet_name_resolve(argv[0], 1)) == -1) |
| 184 | if ((spoof_ip = libnet_name2addr4(l, argv[0], LIBNET_RESOLVE)) == -1) |
180 | 185 | usage(); |
181 | 186 | |
182 | | if (intf == NULL && (intf = pcap_lookupdev(ebuf)) == NULL) |
183 | | errx(1, "%s", ebuf); |
| 187 | if (intf == NULL && (intf = pcap_lookupdev(pcap_ebuf)) == NULL) |
| 188 | errx(1, "%s", pcap_ebuf); |
184 | 189 | |
185 | | if ((llif = libnet_open_link_interface(intf, ebuf)) == 0) |
186 | | errx(1, "%s", ebuf); |
| 190 | if ((l = libnet_init(LIBNET_LINK, intf, libnet_ebuf)) == NULL) |
| 191 | errx(1, "%s", libnet_ebuf); |
187 | 192 | |
188 | 193 | if (target_ip != 0 && !arp_find(target_ip, &target_mac)) |
189 | 194 | errx(1, "couldn't arp for host %s", |
190 | | libnet_host_lookup(target_ip, 0)); |
| 195 | libnet_addr2name4(target_ip, LIBNET_DONT_RESOLVE)); |
191 | 196 | |
192 | 197 | signal(SIGHUP, cleanup); |
193 | 198 | signal(SIGINT, cleanup); |
194 | 199 | signal(SIGTERM, cleanup); |
195 | 200 | |
196 | 201 | for (;;) { |
197 | | arp_send(llif, intf, ARPOP_REPLY, NULL, spoof_ip, |
198 | | (target_ip ? (u_char *)&target_mac : NULL), |
| 202 | arp_send(l, ARPOP_REPLY, NULL, spoof_ip, |
| 203 | (target_ip ? (u_int8_t *)&target_mac : NULL), |
199 | 204 | target_ip); |
200 | 205 | sleep(2); |
201 | 206 | } |
diff -ur dsniff-2.4/configure.in dsniff-2.4-mine/configure.in
old
|
new
|
|
21 | 21 | dnl Checks for header files. |
22 | 22 | AC_PATH_XTRA |
23 | 23 | AC_HEADER_STDC |
24 | | AC_CHECK_HEADERS(err.h fcntl.h sys/ioctl.h sys/queue.h unistd.h libgen.h net/if_tun.h) |
| 24 | AC_CHECK_HEADERS(err.h fcntl.h sys/ioctl.h sys/queue.h unistd.h libgen.h net/if_tun.h net/ethernet.h) |
25 | 25 | dnl XXX - Solaris sux. |
26 | 26 | AC_MSG_CHECKING(for MIN and MAX in sys/param.h) |
27 | 27 | AC_EGREP_CPP(yes, [ |
… |
… |
|
43 | 43 | AC_CHECK_TYPE(u_int64_t, uint64_t) |
44 | 44 | dnl XXX - Linux sux. |
45 | 45 | AC_CHECK_TYPE(in_addr_t, u_int32_t) |
46 | | CFLAGS="$CFLAGS -D_BSD_SOURCE" |
| 46 | CFLAGS="$CFLAGS -D_BSD_SOURCE -DBIND_8_COMPAT" |
47 | 47 | |
48 | 48 | dnl Checks for library functions. |
49 | 49 | AC_PROG_GCC_TRADITIONAL |
diff -ur dsniff-2.4/dnsspoof.c dsniff-2.4-mine/dnsspoof.c
old
|
new
|
|
38 | 38 | |
39 | 39 | pcap_t *pcap_pd = NULL; |
40 | 40 | int pcap_off = -1; |
41 | | int lnet_sock = -1; |
| 41 | libnet_t *l; |
42 | 42 | u_long lnet_ip = -1; |
43 | 43 | |
44 | 44 | static void |
… |
… |
|
90 | 90 | dns_init(char *dev, char *filename) |
91 | 91 | { |
92 | 92 | FILE *f; |
93 | | struct libnet_link_int *llif; |
| 93 | libnet_t *l; |
| 94 | char libnet_ebuf[LIBNET_ERRBUF_SIZE]; |
94 | 95 | struct dnsent *de; |
95 | 96 | char *ip, *name, buf[1024]; |
96 | 97 | |
97 | | if ((llif = libnet_open_link_interface(dev, buf)) == NULL) |
98 | | errx(1, "%s", buf); |
| 98 | if ((l = libnet_init(LIBNET_LINK, dev, libnet_ebuf)) == NULL) |
| 99 | errx(1, "%s", libnet_ebuf); |
99 | 100 | |
100 | | if ((lnet_ip = libnet_get_ipaddr(llif, dev, buf)) == -1) |
101 | | errx(1, "%s", buf); |
| 101 | if ((lnet_ip = libnet_get_ipaddr4(l)) == -1) |
| 102 | errx(1, "%s", libnet_geterror(l)); |
102 | 103 | |
103 | | lnet_ip = htonl(lnet_ip); |
104 | | |
105 | | libnet_close_link_interface(llif); |
| 104 | libnet_destroy(l); |
106 | 105 | |
107 | 106 | SLIST_INIT(&dns_entries); |
108 | 107 | |
… |
… |
|
180 | 179 | static void |
181 | 180 | dns_spoof(u_char *u, const struct pcap_pkthdr *pkthdr, const u_char *pkt) |
182 | 181 | { |
183 | | struct libnet_ip_hdr *ip; |
| 182 | struct libnet_ipv4_hdr *ip; |
184 | 183 | struct libnet_udp_hdr *udp; |
185 | 184 | HEADER *dns; |
186 | 185 | char name[MAXHOSTNAMELEN]; |
… |
… |
|
189 | 188 | in_addr_t dst; |
190 | 189 | u_short type, class; |
191 | 190 | |
192 | | ip = (struct libnet_ip_hdr *)(pkt + pcap_off); |
| 191 | ip = (struct libnet_ipv4_hdr *)(pkt + pcap_off); |
193 | 192 | udp = (struct libnet_udp_hdr *)(pkt + pcap_off + (ip->ip_hl * 4)); |
194 | 193 | dns = (HEADER *)(udp + 1); |
195 | 194 | p = (u_char *)(dns + 1); |
… |
… |
|
212 | 211 | if (class != C_IN) |
213 | 212 | return; |
214 | 213 | |
215 | | p = buf + IP_H + UDP_H + dnslen; |
| 214 | p = buf + dnslen; |
216 | 215 | |
217 | 216 | if (type == T_A) { |
218 | 217 | if ((dst = dns_lookup_a(name)) == -1) |
… |
… |
|
234 | 233 | anslen += 12; |
235 | 234 | } |
236 | 235 | else return; |
237 | | |
238 | | libnet_build_ip(UDP_H + dnslen + anslen, 0, libnet_get_prand(PRu16), |
239 | | 0, 64, IPPROTO_UDP, ip->ip_dst.s_addr, |
240 | | ip->ip_src.s_addr, NULL, 0, buf); |
241 | | |
242 | | libnet_build_udp(ntohs(udp->uh_dport), ntohs(udp->uh_sport), |
243 | | NULL, dnslen + anslen, buf + IP_H); |
244 | 236 | |
245 | | memcpy(buf + IP_H + UDP_H, (u_char *)dns, dnslen); |
| 237 | memcpy(buf, (u_char *)dns, dnslen); |
246 | 238 | |
247 | | dns = (HEADER *)(buf + IP_H + UDP_H); |
| 239 | dns = (HEADER *)buf; |
248 | 240 | dns->qr = dns->ra = 1; |
249 | 241 | if (type == T_PTR) dns->aa = 1; |
250 | 242 | dns->ancount = htons(1); |
251 | 243 | |
252 | 244 | dnslen += anslen; |
| 245 | |
| 246 | libnet_clear_packet(l); |
| 247 | libnet_build_udp(ntohs(udp->uh_dport), ntohs(udp->uh_sport), |
| 248 | LIBNET_UDP_H + dnslen, 0, |
| 249 | (u_int8_t *)buf, dnslen, l, 0); |
| 250 | |
| 251 | libnet_build_ipv4(LIBNET_IPV4_H + LIBNET_UDP_H + dnslen, 0, |
| 252 | libnet_get_prand(LIBNET_PRu16), 0, 64, IPPROTO_UDP, 0, |
| 253 | ip->ip_dst.s_addr, ip->ip_src.s_addr, NULL, 0, l, 0); |
253 | 254 | |
254 | | libnet_do_checksum(buf, IPPROTO_UDP, UDP_H + dnslen); |
255 | | |
256 | | if (libnet_write_ip(lnet_sock, buf, IP_H + UDP_H + dnslen) < 0) |
| 255 | if (libnet_write(l) < 0) |
257 | 256 | warn("write"); |
258 | 257 | |
259 | 258 | fprintf(stderr, "%s.%d > %s.%d: %d+ %s? %s\n", |
260 | | libnet_host_lookup(ip->ip_src.s_addr, 0), ntohs(udp->uh_sport), |
261 | | libnet_host_lookup(ip->ip_dst.s_addr, 0), ntohs(udp->uh_dport), |
| 259 | libnet_addr2name4(ip->ip_src.s_addr, 0), ntohs(udp->uh_sport), |
| 260 | libnet_addr2name4(ip->ip_dst.s_addr, 0), ntohs(udp->uh_dport), |
262 | 261 | ntohs(dns->id), type == T_A ? "A" : "PTR", name); |
263 | 262 | } |
264 | 263 | |
265 | 264 | static void |
266 | 265 | cleanup(int sig) |
267 | 266 | { |
268 | | libnet_close_raw_sock(lnet_sock); |
| 267 | libnet_destroy(l); |
269 | 268 | pcap_close(pcap_pd); |
270 | 269 | exit(0); |
271 | 270 | } |
… |
… |
|
276 | 275 | extern char *optarg; |
277 | 276 | extern int optind; |
278 | 277 | char *p, *dev, *hosts, buf[1024]; |
| 278 | char ebuf[LIBNET_ERRBUF_SIZE]; |
279 | 279 | int i; |
280 | 280 | |
281 | 281 | dev = hosts = NULL; |
… |
… |
|
306 | 306 | strlcpy(buf, p, sizeof(buf)); |
307 | 307 | } |
308 | 308 | else snprintf(buf, sizeof(buf), "udp dst port 53 and not src %s", |
309 | | libnet_host_lookup(lnet_ip, 0)); |
| 309 | libnet_addr2name4(lnet_ip, LIBNET_DONT_RESOLVE)); |
310 | 310 | |
311 | 311 | if ((pcap_pd = pcap_init(dev, buf, 128)) == NULL) |
312 | 312 | errx(1, "couldn't initialize sniffing"); |
… |
… |
|
314 | 314 | if ((pcap_off = pcap_dloff(pcap_pd)) < 0) |
315 | 315 | errx(1, "couldn't determine link layer offset"); |
316 | 316 | |
317 | | if ((lnet_sock = libnet_open_raw_sock(IPPROTO_RAW)) == -1) |
| 317 | if ((l = libnet_init(LIBNET_RAW4, dev, ebuf)) == NULL) |
318 | 318 | errx(1, "couldn't initialize sending"); |
319 | 319 | |
320 | | libnet_seed_prand(); |
| 320 | libnet_seed_prand(l); |
321 | 321 | |
322 | 322 | signal(SIGHUP, cleanup); |
323 | 323 | signal(SIGINT, cleanup); |
diff -ur dsniff-2.4/filesnarf.c dsniff-2.4-mine/filesnarf.c
old
|
new
|
|
134 | 134 | int fd; |
135 | 135 | |
136 | 136 | warnx("%s.%d > %s.%d: %s (%d@%d)", |
137 | | libnet_host_lookup(addr->daddr, 0), addr->dest, |
138 | | libnet_host_lookup(addr->saddr, 0), addr->source, |
| 137 | libnet_addr2name4(addr->daddr, LIBNET_DONT_RESOLVE), addr->dest, |
| 138 | libnet_addr2name4(addr->saddr, LIBNET_DONT_RESOLVE), addr->source, |
139 | 139 | ma->filename, len, ma->offset); |
140 | 140 | |
141 | 141 | if ((fd = open(ma->filename, O_WRONLY|O_CREAT, 0644)) >= 0) { |
… |
… |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | static void |
356 | | decode_udp_nfs(struct libnet_ip_hdr *ip) |
| 356 | decode_udp_nfs(struct libnet_ipv4_hdr *ip) |
357 | 357 | { |
358 | 358 | static struct tuple4 addr; |
359 | 359 | struct libnet_udp_hdr *udp; |
diff -ur dsniff-2.4/macof.c dsniff-2.4-mine/macof.c
old
|
new
|
|
48 | 48 | static void |
49 | 49 | gen_mac(u_char *mac) |
50 | 50 | { |
51 | | *((in_addr_t *)mac) = libnet_get_prand(PRu32); |
52 | | *((u_short *)(mac + 4)) = libnet_get_prand(PRu16); |
| 51 | *((in_addr_t *)mac) = libnet_get_prand(LIBNET_PRu32); |
| 52 | *((u_short *)(mac + 4)) = libnet_get_prand(LIBNET_PRu16); |
53 | 53 | } |
54 | 54 | |
55 | 55 | int |
… |
… |
|
59 | 59 | extern int optind; |
60 | 60 | int c, i; |
61 | 61 | struct libnet_link_int *llif; |
62 | | char ebuf[PCAP_ERRBUF_SIZE]; |
| 62 | char pcap_ebuf[PCAP_ERRBUF_SIZE]; |
| 63 | char libnet_ebuf[LIBNET_ERRBUF_SIZE]; |
63 | 64 | u_char sha[ETHER_ADDR_LEN], tha[ETHER_ADDR_LEN]; |
64 | 65 | in_addr_t src, dst; |
65 | 66 | u_short sport, dport; |
66 | 67 | u_int32_t seq; |
67 | | u_char pkt[ETH_H + IP_H + TCP_H]; |
| 68 | libnet_t *l; |
68 | 69 | |
69 | 70 | while ((c = getopt(argc, argv, "vs:d:e:x:y:i:n:h?V")) != -1) { |
70 | 71 | switch (c) { |
71 | 72 | case 'v': |
72 | 73 | break; |
73 | 74 | case 's': |
74 | | Src = libnet_name_resolve(optarg, 0); |
| 75 | Src = libnet_name2addr4(l, optarg, 0); |
75 | 76 | break; |
76 | 77 | case 'd': |
77 | | Dst = libnet_name_resolve(optarg, 0); |
| 78 | Dst = libnet_name2addr4(l, optarg, 0); |
78 | 79 | break; |
79 | 80 | case 'e': |
80 | 81 | Tha = (u_char *)ether_aton(optarg); |
… |
… |
|
101 | 102 | if (argc != 0) |
102 | 103 | usage(); |
103 | 104 | |
104 | | if (!Intf && (Intf = pcap_lookupdev(ebuf)) == NULL) |
105 | | errx(1, "%s", ebuf); |
| 105 | if (!Intf && (Intf = pcap_lookupdev(pcap_ebuf)) == NULL) |
| 106 | errx(1, "%s", pcap_ebuf); |
106 | 107 | |
107 | | if ((llif = libnet_open_link_interface(Intf, ebuf)) == 0) |
108 | | errx(1, "%s", ebuf); |
| 108 | if ((l = libnet_init(LIBNET_LINK, Intf, libnet_ebuf)) == NULL) |
| 109 | errx(1, "%s", libnet_ebuf); |
109 | 110 | |
110 | | libnet_seed_prand(); |
| 111 | libnet_seed_prand(l); |
111 | 112 | |
112 | 113 | for (i = 0; i != Repeat; i++) { |
113 | 114 | |
… |
… |
|
117 | 118 | else memcpy(tha, Tha, sizeof(tha)); |
118 | 119 | |
119 | 120 | if (Src != 0) src = Src; |
120 | | else src = libnet_get_prand(PRu32); |
| 121 | else src = libnet_get_prand(LIBNET_PRu32); |
121 | 122 | |
122 | 123 | if (Dst != 0) dst = Dst; |
123 | | else dst = libnet_get_prand(PRu32); |
| 124 | else dst = libnet_get_prand(LIBNET_PRu32); |
124 | 125 | |
125 | 126 | if (Sport != 0) sport = Sport; |
126 | | else sport = libnet_get_prand(PRu16); |
| 127 | else sport = libnet_get_prand(LIBNET_PRu16); |
127 | 128 | |
128 | 129 | if (Dport != 0) dport = Dport; |
129 | | else dport = libnet_get_prand(PRu16); |
| 130 | else dport = libnet_get_prand(LIBNET_PRu16); |
130 | 131 | |
131 | | seq = libnet_get_prand(PRu32); |
132 | | |
133 | | libnet_build_ethernet(tha, sha, ETHERTYPE_IP, NULL, 0, pkt); |
134 | | |
135 | | libnet_build_ip(TCP_H, 0, libnet_get_prand(PRu16), 0, 64, |
136 | | IPPROTO_TCP, src, dst, NULL, 0, pkt + ETH_H); |
| 132 | seq = libnet_get_prand(LIBNET_PRu32); |
137 | 133 | |
138 | 134 | libnet_build_tcp(sport, dport, seq, 0, TH_SYN, 512, |
139 | | 0, NULL, 0, pkt + ETH_H + IP_H); |
| 135 | 0, 0, LIBNET_TCP_H, NULL, 0, l, 0); |
140 | 136 | |
141 | | libnet_do_checksum(pkt + ETH_H, IPPROTO_IP, IP_H); |
142 | | libnet_do_checksum(pkt + ETH_H, IPPROTO_TCP, TCP_H); |
| 137 | libnet_build_ipv4(LIBNET_TCP_H, 0, |
| 138 | libnet_get_prand(LIBNET_PRu16), 0, 64, |
| 139 | IPPROTO_TCP, 0, src, dst, NULL, 0, l, 0); |
143 | 140 | |
144 | | if (libnet_write_link_layer(llif, Intf, pkt, sizeof(pkt)) < 0) |
| 141 | libnet_build_ethernet(tha, sha, ETHERTYPE_IP, NULL, 0, l, 0); |
| 142 | |
| 143 | if (libnet_write(l) < 0) |
145 | 144 | errx(1, "write"); |
146 | 145 | |
| 146 | libnet_clear_packet(l); |
| 147 | |
147 | 148 | fprintf(stderr, "%s ", |
148 | 149 | ether_ntoa((struct ether_addr *)sha)); |
149 | 150 | fprintf(stderr, "%s %s.%d > %s.%d: S %u:%u(0) win 512\n", |
150 | 151 | ether_ntoa((struct ether_addr *)tha), |
151 | | libnet_host_lookup(Src, 0), sport, |
152 | | libnet_host_lookup(Dst, 0), dport, seq, seq); |
| 152 | libnet_addr2name4(Src, 0), sport, |
| 153 | libnet_addr2name4(Dst, 0), dport, seq, seq); |
153 | 154 | } |
154 | 155 | exit(0); |
155 | 156 | } |
diff -ur dsniff-2.4/pcaputil.c dsniff-2.4-mine/pcaputil.c
old
|
new
|
|
17 | 17 | #include <string.h> |
18 | 18 | #include <err.h> |
19 | 19 | #include <pcap.h> |
| 20 | #ifdef __APPLE__ |
| 21 | #undef BSD |
| 22 | #endif |
20 | 23 | #ifdef BSD |
21 | 24 | #include <pcap-int.h> |
22 | 25 | #endif |
diff -ur dsniff-2.4/record.c dsniff-2.4-mine/record.c
old
|
new
|
|
65 | 65 | tm = localtime(&rec->time); |
66 | 66 | strftime(tstr, sizeof(tstr), "%x %X", tm); |
67 | 67 | |
68 | | srcp = libnet_host_lookup(rec->src, Opt_dns); |
69 | | dstp = libnet_host_lookup(rec->dst, Opt_dns); |
| 68 | srcp = libnet_addr2name4(rec->src, Opt_dns); |
| 69 | dstp = libnet_addr2name4(rec->dst, Opt_dns); |
70 | 70 | |
71 | 71 | if ((pr = getprotobynumber(rec->proto)) == NULL) |
72 | 72 | protop = "unknown"; |
diff -ur dsniff-2.4/sshcrypto.c dsniff-2.4-mine/sshcrypto.c
old
|
new
|
|
14 | 14 | |
15 | 15 | #include <sys/types.h> |
16 | 16 | #include <openssl/ssl.h> |
| 17 | #ifndef BF_ENCRYPT |
| 18 | #include <openssl/blowfish.h> |
| 19 | #endif |
| 20 | #ifndef DES_DECRYPT |
| 21 | #include <openssl/des.h> |
| 22 | #endif |
17 | 23 | |
18 | 24 | #include <err.h> |
19 | 25 | #include <stdio.h> |
diff -ur dsniff-2.4/sshmitm.c dsniff-2.4-mine/sshmitm.c
old
|
new
|
|
389 | 389 | if (argc < 1) |
390 | 390 | usage(); |
391 | 391 | |
392 | | if ((ip = libnet_name_resolve(argv[0], 1)) == -1) |
| 392 | if ((ip = libnet_name2addr4(NULL, argv[0], LIBNET_RESOLVE)) == -1) |
393 | 393 | usage(); |
394 | 394 | |
395 | 395 | if (argc == 2 && (rport = atoi(argv[1])) == 0) |
diff -ur dsniff-2.4/sshow.c dsniff-2.4-mine/sshow.c
old
|
new
|
|
15 | 15 | |
16 | 16 | #include <sys/types.h> |
17 | 17 | #include <sys/times.h> |
| 18 | #include <machine/limits.h> |
18 | 19 | |
19 | 20 | #include <netinet/in_systm.h> |
20 | 21 | #include <netinet/in.h> |
diff -ur dsniff-2.4/tcp_raw.c dsniff-2.4-mine/tcp_raw.c
old
|
new
|
|
119 | 119 | } |
120 | 120 | |
121 | 121 | struct iovec * |
122 | | tcp_raw_input(struct libnet_ip_hdr *ip, struct libnet_tcp_hdr *tcp, int len) |
| 122 | tcp_raw_input(struct libnet_ipv4_hdr *ip, struct libnet_tcp_hdr *tcp, int len) |
123 | 123 | { |
124 | 124 | struct tha tha; |
125 | 125 | struct tcp_conn *conn; |
… |
… |
|
131 | 131 | |
132 | 132 | /* Verify TCP checksum. */ |
133 | 133 | cksum = tcp->th_sum; |
134 | | libnet_do_checksum((u_char *) ip, IPPROTO_TCP, len); |
| 134 | libnet_do_checksum(NULL, (u_char *) ip, IPPROTO_TCP, len); |
135 | 135 | |
136 | 136 | if (cksum != tcp->th_sum) |
137 | 137 | return (NULL); |
diff -ur dsniff-2.4/tcp_raw.h dsniff-2.4-mine/tcp_raw.h
old
|
new
|
|
15 | 15 | u_short sport, u_short dport, |
16 | 16 | u_char *buf, int len); |
17 | 17 | |
18 | | struct iovec *tcp_raw_input(struct libnet_ip_hdr *ip, |
| 18 | struct iovec *tcp_raw_input(struct libnet_ipv4_hdr *ip, |
19 | 19 | struct libnet_tcp_hdr *tcp, int len); |
20 | 20 | |
21 | 21 | void tcp_raw_timeout(int timeout, tcp_raw_callback_t callback); |
diff -ur dsniff-2.4/tcpkill.c dsniff-2.4-mine/tcpkill.c
old
|
new
|
|
39 | 39 | static void |
40 | 40 | tcp_kill_cb(u_char *user, const struct pcap_pkthdr *pcap, const u_char *pkt) |
41 | 41 | { |
42 | | struct libnet_ip_hdr *ip; |
| 42 | struct libnet_ipv4_hdr *ip; |
43 | 43 | struct libnet_tcp_hdr *tcp; |
44 | | u_char ctext[64], buf[IP_H + TCP_H]; |
| 44 | u_char ctext[64]; |
45 | 45 | u_int32_t seq, win; |
46 | | int i, *sock, len; |
| 46 | int i, len; |
| 47 | libnet_t *l; |
47 | 48 | |
48 | | sock = (int *)user; |
| 49 | l = (libnet_t *)user; |
49 | 50 | pkt += pcap_off; |
50 | 51 | len = pcap->caplen - pcap_off; |
51 | 52 | |
52 | | ip = (struct libnet_ip_hdr *)pkt; |
| 53 | ip = (struct libnet_ipv4_hdr *)pkt; |
53 | 54 | if (ip->ip_p != IPPROTO_TCP) |
54 | 55 | return; |
55 | 56 | |
… |
… |
|
57 | 58 | if (tcp->th_flags & (TH_SYN|TH_FIN|TH_RST)) |
58 | 59 | return; |
59 | 60 | |
60 | | libnet_build_ip(TCP_H, 0, 0, 0, 64, IPPROTO_TCP, |
61 | | ip->ip_dst.s_addr, ip->ip_src.s_addr, |
62 | | NULL, 0, buf); |
63 | | |
64 | | libnet_build_tcp(ntohs(tcp->th_dport), ntohs(tcp->th_sport), |
65 | | 0, 0, TH_RST, 0, 0, NULL, 0, buf + IP_H); |
66 | | |
67 | 61 | seq = ntohl(tcp->th_ack); |
68 | 62 | win = ntohs(tcp->th_win); |
69 | 63 | |
70 | 64 | snprintf(ctext, sizeof(ctext), "%s:%d > %s:%d:", |
71 | | libnet_host_lookup(ip->ip_src.s_addr, 0), |
| 65 | libnet_addr2name4(ip->ip_src.s_addr, LIBNET_DONT_RESOLVE), |
72 | 66 | ntohs(tcp->th_sport), |
73 | | libnet_host_lookup(ip->ip_dst.s_addr, 0), |
| 67 | libnet_addr2name4(ip->ip_dst.s_addr, LIBNET_DONT_RESOLVE), |
74 | 68 | ntohs(tcp->th_dport)); |
75 | 69 | |
76 | | ip = (struct libnet_ip_hdr *)buf; |
77 | | tcp = (struct libnet_tcp_hdr *)(ip + 1); |
78 | | |
79 | 70 | for (i = 0; i < Opt_severity; i++) { |
80 | | ip->ip_id = libnet_get_prand(PRu16); |
81 | 71 | seq += (i * win); |
82 | | tcp->th_seq = htonl(seq); |
83 | 72 | |
84 | | libnet_do_checksum(buf, IPPROTO_TCP, TCP_H); |
| 73 | libnet_clear_packet(l); |
| 74 | |
| 75 | libnet_build_tcp(ntohs(tcp->th_dport), ntohs(tcp->th_sport), |
| 76 | seq, 0, TH_RST, 0, 0, 0, LIBNET_TCP_H, |
| 77 | NULL, 0, l, 0); |
| 78 | |
| 79 | libnet_build_ipv4(LIBNET_IPV4_H + LIBNET_TCP_H, 0, |
| 80 | libnet_get_prand(LIBNET_PRu16), 0, 64, |
| 81 | IPPROTO_TCP, 0, ip->ip_dst.s_addr, |
| 82 | ip->ip_src.s_addr, NULL, 0, l, 0); |
85 | 83 | |
86 | | if (libnet_write_ip(*sock, buf, sizeof(buf)) < 0) |
87 | | warn("write_ip"); |
| 84 | if (libnet_write(l) < 0) |
| 85 | warn("write"); |
88 | 86 | |
89 | 87 | fprintf(stderr, "%s R %lu:%lu(0) win 0\n", ctext, seq, seq); |
90 | 88 | } |
… |
… |
|
95 | 93 | { |
96 | 94 | extern char *optarg; |
97 | 95 | extern int optind; |
98 | | int c, sock; |
| 96 | int c; |
99 | 97 | char *p, *intf, *filter, ebuf[PCAP_ERRBUF_SIZE]; |
| 98 | char libnet_ebuf[LIBNET_ERRBUF_SIZE]; |
| 99 | libnet_t *l; |
100 | 100 | pcap_t *pd; |
101 | 101 | |
102 | 102 | intf = NULL; |
… |
… |
|
136 | 136 | if ((pcap_off = pcap_dloff(pd)) < 0) |
137 | 137 | errx(1, "couldn't determine link layer offset"); |
138 | 138 | |
139 | | if ((sock = libnet_open_raw_sock(IPPROTO_RAW)) == -1) |
| 139 | if ((l = libnet_init(LIBNET_RAW4, intf, libnet_ebuf)) == NULL) |
140 | 140 | errx(1, "couldn't initialize sending"); |
141 | 141 | |
142 | | libnet_seed_prand(); |
| 142 | libnet_seed_prand(l); |
143 | 143 | |
144 | 144 | warnx("listening on %s [%s]", intf, filter); |
145 | 145 | |
146 | | pcap_loop(pd, -1, tcp_kill_cb, (u_char *)&sock); |
| 146 | pcap_loop(pd, -1, tcp_kill_cb, (u_char *)l); |
147 | 147 | |
148 | 148 | /* NOTREACHED */ |
149 | 149 | |
diff -ur dsniff-2.4/tcpnice.c dsniff-2.4-mine/tcpnice.c
old
|
new
|
|
41 | 41 | } |
42 | 42 | |
43 | 43 | static void |
44 | | send_tcp_window_advertisement(int sock, struct libnet_ip_hdr *ip, |
| 44 | send_tcp_window_advertisement(libnet_t *l, struct libnet_ipv4_hdr *ip, |
45 | 45 | struct libnet_tcp_hdr *tcp) |
46 | 46 | { |
47 | 47 | int len; |
48 | 48 | |
49 | 49 | ip->ip_hl = 5; |
50 | | ip->ip_len = htons(IP_H + TCP_H); |
51 | | ip->ip_id = libnet_get_prand(PRu16); |
52 | | memcpy(buf, (u_char *)ip, IP_H); |
| 50 | ip->ip_len = htons(LIBNET_IPV4_H + LIBNET_TCP_H); |
| 51 | ip->ip_id = libnet_get_prand(LIBNET_PRu16); |
| 52 | memcpy(buf, (u_char *)ip, LIBNET_IPV4_H); |
53 | 53 | |
54 | 54 | tcp->th_off = 5; |
55 | 55 | tcp->th_win = htons(MIN_WIN); |
56 | | memcpy(buf + IP_H, (u_char *)tcp, TCP_H); |
| 56 | memcpy(buf + LIBNET_IPV4_H, (u_char *)tcp, LIBNET_TCP_H); |
57 | 57 | |
58 | | libnet_do_checksum(buf, IPPROTO_TCP, TCP_H); |
| 58 | libnet_do_checksum(l, buf, IPPROTO_TCP, LIBNET_TCP_H); |
59 | 59 | |
60 | | len = IP_H + TCP_H; |
| 60 | len = LIBNET_IPV4_H + LIBNET_TCP_H; |
61 | 61 | |
62 | | if (libnet_write_ip(sock, buf, len) != len) |
| 62 | if (libnet_write_raw_ipv4(l, buf, len) != len) |
63 | 63 | warn("write"); |
64 | 64 | |
65 | 65 | fprintf(stderr, "%s:%d > %s:%d: . ack %lu win %d\n", |
66 | | libnet_host_lookup(ip->ip_src.s_addr, 0), ntohs(tcp->th_sport), |
67 | | libnet_host_lookup(ip->ip_dst.s_addr, 0), ntohs(tcp->th_dport), |
| 66 | libnet_addr2name4(ip->ip_src.s_addr, 0), ntohs(tcp->th_sport), |
| 67 | libnet_addr2name4(ip->ip_dst.s_addr, 0), ntohs(tcp->th_dport), |
68 | 68 | ntohl(tcp->th_ack), 1); |
69 | 69 | } |
70 | 70 | |
71 | 71 | static void |
72 | | send_icmp_source_quench(int sock, struct libnet_ip_hdr *ip) |
| 72 | send_icmp_source_quench(libnet_t *l, struct libnet_ipv4_hdr *ip) |
73 | 73 | { |
74 | | struct libnet_icmp_hdr *icmp; |
| 74 | struct libnet_icmpv4_hdr *icmp; |
75 | 75 | int len; |
76 | 76 | |
77 | 77 | len = (ip->ip_hl * 4) + 8; |
78 | 78 | |
79 | | libnet_build_ip(ICMP_ECHO_H + len, 0, libnet_get_prand(PRu16), |
80 | | 0, 64, IPPROTO_ICMP, ip->ip_dst.s_addr, |
81 | | ip->ip_src.s_addr, NULL, 0, buf); |
82 | | |
83 | | icmp = (struct libnet_icmp_hdr *)(buf + IP_H); |
| 79 | icmp = (struct libnet_icmpv4_hdr *)(buf + LIBNET_IPV4_H); |
84 | 80 | icmp->icmp_type = ICMP_SOURCEQUENCH; |
85 | 81 | icmp->icmp_code = 0; |
86 | | memcpy((u_char *)icmp + ICMP_ECHO_H, (u_char *)ip, len); |
| 82 | memcpy((u_char *)icmp + LIBNET_ICMPV4_ECHO_H, (u_char *)ip, len); |
87 | 83 | |
88 | | libnet_do_checksum(buf, IPPROTO_ICMP, ICMP_ECHO_H + len); |
| 84 | len += LIBNET_ICMPV4_ECHO_H; |
89 | 85 | |
90 | | len += (IP_H + ICMP_ECHO_H); |
| 86 | libnet_build_ipv4(LIBNET_IPV4_H + len, 0, |
| 87 | libnet_get_prand(LIBNET_PRu16), 0, 64, IPPROTO_ICMP, |
| 88 | 0, ip->ip_dst.s_addr, ip->ip_src.s_addr, |
| 89 | (u_int8_t *) icmp, len, l, 0); |
91 | 90 | |
92 | | if (libnet_write_ip(sock, buf, len) != len) |
| 91 | if (libnet_write(l) != len) |
93 | 92 | warn("write"); |
94 | 93 | |
95 | 94 | fprintf(stderr, "%s > %s: icmp: source quench\n", |
96 | | libnet_host_lookup(ip->ip_dst.s_addr, 0), |
97 | | libnet_host_lookup(ip->ip_src.s_addr, 0)); |
| 95 | libnet_addr2name4(ip->ip_dst.s_addr, 0), |
| 96 | libnet_addr2name4(ip->ip_src.s_addr, 0)); |
98 | 97 | } |
99 | 98 | |
100 | 99 | static void |
101 | | send_icmp_frag_needed(int sock, struct libnet_ip_hdr *ip) |
| 100 | send_icmp_frag_needed(libnet_t *l, struct libnet_ipv4_hdr *ip) |
102 | 101 | { |
103 | | struct libnet_icmp_hdr *icmp; |
| 102 | struct libnet_icmpv4_hdr *icmp; |
104 | 103 | int len; |
105 | 104 | |
106 | 105 | len = (ip->ip_hl * 4) + 8; |
107 | 106 | |
108 | | libnet_build_ip(ICMP_MASK_H + len, 4, libnet_get_prand(PRu16), |
109 | | 0, 64, IPPROTO_ICMP, ip->ip_dst.s_addr, |
110 | | ip->ip_src.s_addr, NULL, 0, buf); |
111 | | |
112 | | icmp = (struct libnet_icmp_hdr *)(buf + IP_H); |
| 107 | icmp = (struct libnet_icmpv4_hdr *)(buf + LIBNET_IPV4_H); |
113 | 108 | icmp->icmp_type = ICMP_UNREACH; |
114 | 109 | icmp->icmp_code = ICMP_UNREACH_NEEDFRAG; |
115 | 110 | icmp->hun.frag.pad = 0; |
116 | 111 | icmp->hun.frag.mtu = htons(MIN_MTU); |
117 | | memcpy((u_char *)icmp + ICMP_MASK_H, (u_char *)ip, len); |
| 112 | memcpy((u_char *)icmp + LIBNET_ICMPV4_MASK_H, (u_char *)ip, len); |
118 | 113 | |
119 | | libnet_do_checksum(buf, IPPROTO_ICMP, ICMP_MASK_H + len); |
120 | | |
121 | | len += (IP_H + ICMP_MASK_H); |
| 114 | len += LIBNET_ICMPV4_MASK_H; |
| 115 | |
| 116 | libnet_build_ipv4(LIBNET_IPV4_H + len, 4, |
| 117 | libnet_get_prand(LIBNET_PRu16), 0, 64, IPPROTO_ICMP, |
| 118 | 0, ip->ip_dst.s_addr, ip->ip_src.s_addr, |
| 119 | (u_int8_t *) icmp, len, l, 0); |
122 | 120 | |
123 | | if (libnet_write_ip(sock, buf, len) != len) |
| 121 | if (libnet_write(l) != len) |
124 | 122 | warn("write"); |
125 | 123 | |
126 | 124 | fprintf(stderr, "%s > %s: icmp: ", |
127 | | libnet_host_lookup(ip->ip_dst.s_addr, 0), |
128 | | libnet_host_lookup(ip->ip_src.s_addr, 0)); |
| 125 | libnet_addr2name4(ip->ip_dst.s_addr, 0), |
| 126 | libnet_addr2name4(ip->ip_src.s_addr, 0)); |
129 | 127 | fprintf(stderr, "%s unreachable - need to frag (mtu %d)\n", |
130 | | libnet_host_lookup(ip->ip_src.s_addr, 0), MIN_MTU); |
| 128 | libnet_addr2name4(ip->ip_src.s_addr, 0), MIN_MTU); |
131 | 129 | } |
132 | 130 | |
133 | 131 | static void |
134 | 132 | tcp_nice_cb(u_char *user, const struct pcap_pkthdr *pcap, const u_char *pkt) |
135 | 133 | { |
136 | | struct libnet_ip_hdr *ip; |
| 134 | struct libnet_ipv4_hdr *ip; |
137 | 135 | struct libnet_tcp_hdr *tcp; |
138 | | int *sock, len; |
| 136 | int len; |
| 137 | libnet_t *l; |
139 | 138 | |
140 | | sock = (int *)user; |
| 139 | l = (libnet_t *)user; |
141 | 140 | pkt += pcap_off; |
142 | 141 | len = pcap->caplen - pcap_off; |
143 | 142 | |
144 | | ip = (struct libnet_ip_hdr *)pkt; |
| 143 | ip = (struct libnet_ipv4_hdr *)pkt; |
145 | 144 | if (ip->ip_p != IPPROTO_TCP) |
146 | 145 | return; |
147 | 146 | |
… |
… |
|
151 | 150 | |
152 | 151 | if (ntohs(ip->ip_len) > (ip->ip_hl << 2) + (tcp->th_off << 2)) { |
153 | 152 | if (Opt_icmp) |
154 | | send_icmp_source_quench(*sock, ip); |
| 153 | send_icmp_source_quench(l, ip); |
155 | 154 | if (Opt_win) |
156 | | send_tcp_window_advertisement(*sock, ip, tcp); |
| 155 | send_tcp_window_advertisement(l, ip, tcp); |
157 | 156 | if (Opt_pmtu) |
158 | | send_icmp_frag_needed(*sock, ip); |
| 157 | send_icmp_frag_needed(l, ip); |
159 | 158 | } |
160 | 159 | } |
161 | 160 | |
… |
… |
|
164 | 163 | { |
165 | 164 | extern char *optarg; |
166 | 165 | extern int optind; |
167 | | int c, sock; |
| 166 | int c; |
168 | 167 | char *intf, *filter, ebuf[PCAP_ERRBUF_SIZE]; |
| 168 | char libnet_ebuf[LIBNET_ERRBUF_SIZE]; |
| 169 | libnet_t *l; |
169 | 170 | pcap_t *pd; |
170 | 171 | |
171 | 172 | intf = NULL; |
… |
… |
|
209 | 210 | if ((pcap_off = pcap_dloff(pd)) < 0) |
210 | 211 | errx(1, "couldn't determine link layer offset"); |
211 | 212 | |
212 | | if ((sock = libnet_open_raw_sock(IPPROTO_RAW)) == -1) |
| 213 | if ((l = libnet_init(LIBNET_RAW4, intf, libnet_ebuf)) == NULL) |
213 | 214 | errx(1, "couldn't initialize sending"); |
214 | 215 | |
215 | | libnet_seed_prand(); |
| 216 | libnet_seed_prand(l); |
216 | 217 | |
217 | 218 | warnx("listening on %s [%s]", intf, filter); |
218 | 219 | |
219 | | pcap_loop(pd, -1, tcp_nice_cb, (u_char *)&sock); |
| 220 | pcap_loop(pd, -1, tcp_nice_cb, (u_char *)l); |
220 | 221 | |
221 | 222 | /* NOTREACHED */ |
222 | 223 | |
diff -ur dsniff-2.4/trigger.c dsniff-2.4-mine/trigger.c
old
|
new
|
|
276 | 276 | } |
277 | 277 | |
278 | 278 | void |
279 | | trigger_ip(struct libnet_ip_hdr *ip) |
| 279 | trigger_ip(struct libnet_ipv4_hdr *ip) |
280 | 280 | { |
281 | 281 | struct trigger *t, tr; |
282 | 282 | u_char *buf; |
… |
… |
|
305 | 305 | |
306 | 306 | /* libnids needs a nids_register_udp()... */ |
307 | 307 | void |
308 | | trigger_udp(struct libnet_ip_hdr *ip) |
| 308 | trigger_udp(struct libnet_ipv4_hdr *ip) |
309 | 309 | { |
310 | 310 | struct trigger *t, tr; |
311 | 311 | struct libnet_udp_hdr *udp; |
… |
… |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | void |
440 | | trigger_tcp_raw(struct libnet_ip_hdr *ip) |
| 440 | trigger_tcp_raw(struct libnet_ipv4_hdr *ip) |
441 | 441 | { |
442 | 442 | struct trigger *t, tr; |
443 | 443 | struct libnet_tcp_hdr *tcp; |
diff -ur dsniff-2.4/trigger.h dsniff-2.4-mine/trigger.h
old
|
new
|
|
24 | 24 | int trigger_set_tcp(int port, char *name); |
25 | 25 | int trigger_set_rpc(int program, char *name); |
26 | 26 | |
27 | | void trigger_ip(struct libnet_ip_hdr *ip); |
28 | | void trigger_udp(struct libnet_ip_hdr *ip); |
| 27 | void trigger_ip(struct libnet_ipv4_hdr *ip); |
| 28 | void trigger_udp(struct libnet_ipv4_hdr *ip); |
29 | 29 | void trigger_tcp(struct tcp_stream *ts, void **conn_save); |
30 | | void trigger_tcp_raw(struct libnet_ip_hdr *ip); |
| 30 | void trigger_tcp_raw(struct libnet_ipv4_hdr *ip); |
31 | 31 | void trigger_tcp_raw_timeout(int signal); |
32 | 32 | void trigger_rpc(int program, int proto, int port); |
33 | 33 | |
diff -ur dsniff-2.4/urlsnarf.c dsniff-2.4-mine/urlsnarf.c
old
|
new
|
|
145 | 145 | if (user == NULL) |
146 | 146 | user = "-"; |
147 | 147 | if (vhost == NULL) |
148 | | vhost = libnet_host_lookup(addr->daddr, Opt_dns); |
| 148 | vhost = libnet_addr2name4(addr->daddr, Opt_dns); |
149 | 149 | if (referer == NULL) |
150 | 150 | referer = "-"; |
151 | 151 | if (agent == NULL) |
152 | 152 | agent = "-"; |
153 | 153 | |
154 | 154 | printf("%s - %s [%s] \"%s http://%s%s\" - - \"%s\" \"%s\"\n", |
155 | | libnet_host_lookup(addr->saddr, Opt_dns), |
| 155 | libnet_addr2name4(addr->saddr, Opt_dns), |
156 | 156 | user, timestamp(), req, vhost, uri, referer, agent); |
157 | 157 | } |
158 | 158 | fflush(stdout); |
diff -ur dsniff-2.4/webmitm.c dsniff-2.4-mine/webmitm.c
old
|
new
|
|
242 | 242 | word = buf_tok(&msg, "/", 1); |
243 | 243 | vhost = buf_strdup(word); |
244 | 244 | } |
245 | | ssin.sin_addr.s_addr = libnet_name_resolve(vhost, 1); |
| 245 | ssin.sin_addr.s_addr = libnet_name2addr4(NULL, vhost, 1); |
246 | 246 | free(vhost); |
247 | 247 | |
248 | 248 | if (ssin.sin_addr.s_addr == ntohl(INADDR_LOOPBACK) || |
… |
… |
|
510 | 510 | argv += optind; |
511 | 511 | |
512 | 512 | if (argc == 1) { |
513 | | if ((static_host = libnet_name_resolve(argv[0], 1)) == -1) |
| 513 | if ((static_host = libnet_name2addr4(NULL, argv[0], 1)) == -1) |
514 | 514 | usage(); |
515 | 515 | } |
516 | 516 | else if (argc != 0) usage(); |
diff -ur dsniff-2.4/webspy.c dsniff-2.4-mine/webspy.c
old
|
new
|
|
126 | 126 | if (auth == NULL) |
127 | 127 | auth = ""; |
128 | 128 | if (vhost == NULL) |
129 | | vhost = libnet_host_lookup(addr->daddr, 0); |
| 129 | vhost = libnet_addr2name4(addr->daddr, 0); |
130 | 130 | |
131 | 131 | snprintf(cmd, sizeof(cmd), "openURL(http://%s%s%s%s)", |
132 | 132 | auth, *auth ? "@" : "", vhost, uri); |
… |
… |
|
202 | 202 | cmdtab[0] = cmd; |
203 | 203 | cmdtab[1] = NULL; |
204 | 204 | |
205 | | if ((host = libnet_name_resolve(argv[0], 1)) == -1) |
| 205 | if ((host = libnet_name2addr4(NULL, argv[0], 1)) == -1) |
206 | 206 | errx(1, "unknown host"); |
207 | 207 | |
208 | 208 | if ((dpy = XOpenDisplay(NULL)) == NULL) |