def check_dhcp_on_eth(iface, timeout): """Check if there is roque dhcp server in network on given iface @iface - name of the ethernet interface @timeout - scapy timeout for waiting on response >>> check_dhcp_on_eth('eth1') """ scapy.conf.iface = iface scapy.conf.checkIPaddr = False dhcp_options = [("message-type", "discover"), ("param_req_list", utils.format_options( [1, 2, 3, 4, 5, 6, 11, 12, 13, 15, 16, 17, 18, 22, 23, 28, 40, 41, 42, 43, 50, 51, 54, 58, 59, 60, 66, 67])), "end"] fam, hw = scapy.get_if_raw_hwaddr(iface) dhcp_discover = ( scapy.Ether(src=hw, dst="ff:ff:ff:ff:ff:ff") / scapy.IP(src="0.0.0.0", dst="255.255.255.255") / scapy.UDP(sport=68, dport=67) / scapy.BOOTP(chaddr=hw) / scapy.DHCP(options=dhcp_options)) ans, unans = scapy.srp(dhcp_discover, multi=True, nofilter=1, timeout=timeout, verbose=0) return ans
def check_dhcp_on_eth(iface, timeout): """Check if there is roque dhcp server in network on given iface @iface - name of the ethernet interface @timeout - scapy timeout for waiting on response >>> check_dhcp_on_eth('eth1') """ conf.iface = iface conf.checkIPaddr = False dhcp_options = [("message-type", "discover"), ("param_req_list", utils.format_options([ 1, 2, 3, 4, 5, 6, 11, 12, 13, 15, 16, 17, 18, 22, 23, 28, 40, 41, 42, 43, 50, 51, 54, 58, 59, 60, 66, 67 ])), "end"] fam, hw = get_if_raw_hwaddr(iface) dhcp_discover = (Ether(src=hw, dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst="255.255.255.255") / UDP(sport=68, dport=67) / BOOTP(chaddr=hw) / DHCP(options=dhcp_options)) ans, unans = srp(dhcp_discover, multi=True, nofilter=1, timeout=timeout, verbose=0) return ans
def _get_dhcp_discover_message(iface): dhcp_options = [("message-type", "discover"), ("param_req_list", utils.format_options([ 1, 2, 3, 4, 5, 6, 11, 12, 13, 15, 16, 17, 18, 22, 23, 28, 40, 41, 42, 43, 50, 51, 54, 58, 59, 60, 66, 67 ])), "end"] fam, hw = scapy.get_if_raw_hwaddr(iface) dhcp_discover = (scapy.Ether(src=hw, dst="ff:ff:ff:ff:ff:ff") / scapy.IP(src="0.0.0.0", dst="255.255.255.255") / scapy.UDP(sport=68, dport=67) / scapy.BOOTP(chaddr=hw) / scapy.DHCP(options=dhcp_options)) return dhcp_discover
def _get_dhcp_discover_message(iface): dhcp_options = [("message-type", "discover"), ("param_req_list", utils.format_options( [1, 2, 3, 4, 5, 6, 11, 12, 13, 15, 16, 17, 18, 22, 23, 28, 40, 41, 42, 43, 50, 51, 54, 58, 59, 60, 66, 67])), "end"] fam, hw = scapy.get_if_raw_hwaddr(iface) dhcp_discover = ( scapy.Ether(src=hw, dst="ff:ff:ff:ff:ff:ff") / scapy.IP(src="0.0.0.0", dst="255.255.255.255") / scapy.UDP(sport=68, dport=67) / scapy.BOOTP(chaddr=hw) / scapy.DHCP(options=dhcp_options)) return dhcp_discover