From 2b2f42200e381ec7b889219bec6da224f8921faf Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 1 May 2012 19:09:58 +0000 Subject: [PATCH] Applied patch to ip-forwarding.nse from Daniel Miller that fixes bug that would incorrectly detect hosts as having IP forwarding enabled, allthough they did not. [Daniel Miller] --- scripts/ip-forwarding.nse | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/ip-forwarding.nse b/scripts/ip-forwarding.nse index 5376a2f1d..d1912cf9a 100644 --- a/scripts/ip-forwarding.nse +++ b/scripts/ip-forwarding.nse @@ -43,12 +43,23 @@ local ipops = require('ipOps') local tab = require('tab') local packet = require('packet') +local function format_mac(mac) + local octets + + octets = {} + for _, v in ipairs({ string.byte(mac, 1, #mac) }) do + octets[#octets + 1] = string.format("%02x", v) + end + + return stdnse.strjoin(":", octets) +end + icmpEchoRequest = function(ifname, host, addr) local iface = nmap.get_interface_info(ifname) local dnet, pcap = nmap.new_dnet(), nmap.new_socket() pcap:set_timeout(5000) - pcap:pcap_open(iface.device, 128, false, ("icmp and ( icmp[0] = 0 or icmp[0] = 5 ) and dst %s"):format(iface.address)) + pcap:pcap_open(iface.device, 128, false, ("ether src %s and icmp and ( icmp[0] = 0 or icmp[0] = 5 ) and dst %s"):format(format_mac(host.mac_addr), iface.address)) dnet:ethernet_open(iface.device) local probe = packet.Frame:new()