~ubuntu-branches/debian/experimental/ettercap/experimental

« back to all changes in this revision

Viewing changes to src/mitm/ec_dhcp_spoofing.c

  • Committer: Package Import Robot
  • Author(s): Barak A. Pearlmutter
  • Date: 2013-03-27 11:55:24 UTC
  • mfrom: (25.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130327115524-ahjhvuh03ejcfuui
Tags: 1:0.7.6-2~exp1
Experimental release with IPv6 support

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
         if (inet_aton(p, &ipaddr) == 0)
107
107
            break;
108
108
         /* get the netmask */
109
 
         ip_addr_init(&dhcp_netmask, AF_INET, (char *)&ipaddr);
 
109
         ip_addr_init(&dhcp_netmask, AF_INET, (u_char *)&ipaddr);
110
110
         
111
111
      /* third parameter (the dns server) */
112
112
      } else if (i == 3) {
116
116
         if (inet_aton(p, &ipaddr) == 0)
117
117
            break;
118
118
         /* get the netmask */
119
 
         ip_addr_init(&dhcp_dns, AF_INET, (char *)&ipaddr);
 
119
         ip_addr_init(&dhcp_dns, AF_INET, (u_char *)&ipaddr);
120
120
         
121
121
         /* all the parameters were parsed correctly... */
122
122
         USER_MSG("DHCP spoofing: using specified ip_pool, netmask %s", ip_addr_ntoa(&dhcp_netmask, tmp));
214
214
   else {
215
215
      /* search if the client already has the ip address */
216
216
      if (dhcp->dhcp_cip != 0) {
217
 
         ip_addr_init(&client, AF_INET, (char *)&dhcp->dhcp_cip);
 
217
         ip_addr_init(&client, AF_INET, (u_char *)&dhcp->dhcp_cip);
218
218
      } else
219
219
         return;
220
220
   }
237
237
      dhcp->dhcp_sip = ip_addr_to_int32(&server.addr);
238
238
 
239
239
      /* set it in the options */
240
 
      ip_addr_cpy(dhcp_options + 5, &server);
 
240
      ip_addr_cpy((u_char*)dhcp_options + 5, &server);
241
241
   
242
 
      send_dhcp_reply(&server, dhcp_addr_reply(&po->L3.src), po->L2.src, dhcp_hdr, dhcp_options, dhcp_optlen);
 
242
      send_dhcp_reply(&server, dhcp_addr_reply(&po->L3.src), po->L2.src, (u_char*)dhcp_hdr, (u_char*)dhcp_options, dhcp_optlen);
243
243
      
244
244
   } else {
245
245
      /* 
249
249
      dhcp->dhcp_sip = ip_addr_to_int32(&GBL_IFACE->ip.addr);
250
250
      
251
251
      /* set it in the options */
252
 
      ip_addr_cpy(dhcp_options + 5, &GBL_IFACE->ip);
 
252
      ip_addr_cpy((u_char*)dhcp_options + 5, &GBL_IFACE->ip);
253
253
   
254
 
      send_dhcp_reply(&GBL_IFACE->ip, dhcp_addr_reply(&po->L3.src), po->L2.src, dhcp_hdr, dhcp_options, dhcp_optlen);
 
254
      send_dhcp_reply(&GBL_IFACE->ip, dhcp_addr_reply(&po->L3.src), po->L2.src, (u_char*)dhcp_hdr, (u_char*)dhcp_options, dhcp_optlen);
255
255
   }
256
256
 
257
257
   USER_MSG("DHCP spoofing: fake ACK [%s] ", mac_addr_ntoa(po->L2.src, tmp));
291
291
   dhcp->dhcp_sip = ip_addr_to_int32(&GBL_IFACE->ip.addr);
292
292
 
293
293
   /* set it in the options */
294
 
   ip_addr_cpy(dhcp_options + 5, &GBL_IFACE->ip);
 
294
   ip_addr_cpy((u_char*)dhcp_options + 5, &GBL_IFACE->ip);
295
295
   
296
296
   /* send the packet */
297
 
   send_dhcp_reply(&GBL_IFACE->ip, dhcp_addr_reply(&po->L3.src), po->L2.src, dhcp_hdr, dhcp_options, dhcp_optlen);
 
297
   send_dhcp_reply(&GBL_IFACE->ip, dhcp_addr_reply(&po->L3.src), po->L2.src, (u_char*)dhcp_hdr, (u_char*)dhcp_options, dhcp_optlen);
298
298
   
299
299
   USER_MSG("DHCP spoofing: fake OFFER [%s] ", mac_addr_ntoa(po->L2.src, tmp));
300
300
   USER_MSG("offering %s \n", ip_addr_ntoa(&dhcp_free_ip->ip, tmp));
310
310
static void dhcp_setup_options(void)
311
311
{
312
312
   int time;
313
 
   u_int8 *p = dhcp_options;
 
313
   u_int8 *p = (u_int8*)dhcp_options;
314
314
 
315
315
   DEBUG_MSG("dhcp_setup_options");
316
316