Package: packit Version: 1.0-2 Severity: important The upstream source is erroneously sending RARP packages with the ethernet type ETHERTYPE_ARP (=0x0806), instead of the correct ETHERTYPE_REVARP (=0x8035). In fact, no detection or manipulation is correct for RARP.
The following patch amends this omission. The functionality has successfully been tested with "RARP request", with and without enabled debug mode, against a running rarpd(8). This test was fully unsuccessful before my modification. Best regards, Mats Erik Andersson, DM
Description: Incorrect ethertype for RARP. The upstream source uses ethertype 0x0806 for ARP as well as RARP. This is incorrect. . The code must distinguish between ETHERTYPE_ARP and ETHERTYPE_REVARP (= 0x8035). This can only be done once the optype code (stated with -A) has been chosen as 3 or 4. Detecting this code, the injection type is altered, and the remaining changes only concernes the capture of this new state. . The call to libnet, for autobuilding the ethernet header, must be passed the correct ether type, so a slight modification of shape_ethernet_hdr_auto() is unavoidable. . The resulting code has been checked against rarpd(8). Author: Mats Erik Andersson <[email protected]> Forwarded: no Last-Update: 2011-12-18 --- packit-1.0/src/main.c.orig +++ packit-1.0/src/main.c @@ -212,6 +212,8 @@ case 'A': ahdr_o.op_type = (u_int16_t)atoi(optarg); + if (ahdr_o.op_type == 3 || ahdr_o.op_type == 4) + injection_type = ETHERTYPE_REVARP; break; case 'b': --- packit-1.0/src/print_capture.c.orig +++ packit-1.0/src/print_capture.c @@ -96,10 +96,12 @@ } } else - if(ehdr->ether_type == htons(ETHERTYPE_ARP)) + if(ehdr->ether_type == htons(ETHERTYPE_ARP) + || ehdr->ether_type == htons(ETHERTYPE_REVARP)) { #ifdef DEBUG - fprintf(stdout, "DEBUG: ether_type: ARP\n"); + fprintf(stdout, "DEBUG: ether_type: %s\n", + (ehdr->ether_type == ETHERTYPE_REVARP) ? "RARP" : "ARP"); #endif if(p_mode == M_CAPTURE) --- packit-1.0/src/print_injection.c.orig +++ packit-1.0/src/print_injection.c @@ -170,10 +170,12 @@ ehdr_o.dhw_addr); } else - if(injection_type == ETHERTYPE_ARP) + if(injection_type == ETHERTYPE_ARP + || injection_type == ETHERTYPE_REVARP) { #ifdef DEBUG - fprintf(stdout, "DEBUG: ETHERTYPE_ARP\n"); + fprintf(stdout, "DEBUG: %s\n", + (injection_type == ETHERTYPE_REVARP) ? "ETHERTYPE_REVARP" : "ETHERTYPE_ARP"); #endif arp_t = retrieve_arp_type(ahdr_o.op_type); --- packit-1.0/src/shape_ethernet_hdr.h.orig +++ packit-1.0/src/shape_ethernet_hdr.h @@ -28,6 +28,6 @@ #include "utils.h" libnet_t *shape_ethernet_hdr(libnet_t *pkt_d); -libnet_t *shape_ethernet_hdr_auto(libnet_t *pkt_d); +libnet_t *shape_ethernet_hdr_auto(libnet_t *pkt_d, u_int16_t); #endif /* __SHAPE_ETHERNET_H */ --- packit-1.0/src/shape_ethernet_hdr.c.orig +++ packit-1.0/src/shape_ethernet_hdr.c @@ -59,7 +59,8 @@ snprintf(ehdr_o.shw_addr, 18, "%0X:%0X:%0X:%0X:%0X:%0X", us_addr[0], us_addr[1], us_addr[2], us_addr[3], us_addr[4], us_addr[5]); - if(ehdr_o.d_addr == NULL && injection_type == ETHERTYPE_ARP) + if(ehdr_o.d_addr == NULL + && (injection_type == ETHERTYPE_ARP || injection_type == ETHERTYPE_REVARP)) ehdr_o.d_addr = ETH_BROADCAST; else if(ehdr_o.d_addr == NULL) @@ -90,7 +91,7 @@ } libnet_t * -shape_ethernet_hdr_auto(libnet_t *pkt_d) +shape_ethernet_hdr_auto(libnet_t *pkt_d, u_int16_t type) { u_int8_t d_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -100,7 +101,7 @@ if(libnet_autobuild_ethernet( d_addr, - ETHERTYPE_ARP, + type, pkt_d) == -1) { fatal_error("Unable to auto-build ethernet header"); --- packit-1.0/src/shape_packet.c.orig +++ packit-1.0/src/shape_packet.c @@ -62,6 +62,7 @@ break; case ETHERTYPE_ARP: + case ETHERTYPE_REVARP: if((pkt_d = shape_arp_hdr(pkt_d)) == NULL) return pkt_d; @@ -74,8 +75,8 @@ return pkt_d; } else - if(injection_type == ETHERTYPE_ARP) - if((pkt_d = shape_ethernet_hdr_auto(pkt_d)) == NULL) + if(injection_type == ETHERTYPE_ARP || injection_type == ETHERTYPE_REVARP) + if((pkt_d = shape_ethernet_hdr_auto(pkt_d, injection_type)) == NULL) return pkt_d; #ifdef DEBUG

