Nmap Development mailing list archives

Re: "dnet: Failed to open device" errors on AIX, as root


From: David Fifield <david () bamsoftware com>
Date: Mon, 10 Dec 2012 12:07:13 -0800

On Sat, Dec 08, 2012 at 11:43:43AM -0500, Ben Lentz wrote:
It might help if you can try to compile and run this example code from
IBM. If its bind works, but that of eth-ndd.c doesn't, then we can
identify what the important differences are.

http://pic.dhe.ibm.com/infocenter/aix/v6r1/topic/com.ibm.aix.progcomm/doc/progcomc/skt_sndother_ex.htm

I was able to compile the "Sending Packets Over Ethernet Example
Program" and I was able to get it to run (I'm not totally clear on
what it's supposed to do) against both my local MAC address and the
MAC address of another system on the same network (10.0.17.0/24) so
long as I specified the ethernet type as 0x0, and not 0x800. As with
the problem that Peter reported, if 0x800 is used on AIX, it gives the
bind EEXIST error.

$ sudo ./sample en2 7e:ef:bb:08:f1:0c 0x800 10 10
src addr = 7EEFBB08F10C
dst addr = 7EEFBB08F10C
Ethertype: 800
Count: 10
Size: 60
bind: File exists

$ sudo ./sample en2 7e:ef:bb:08:f1:0c 0x0 10 10
src addr = 7EEFBB08F10C
dst addr = 7EEFBB08F10C
Ethertype: 0
Count: 10
Size: 60
$ sudo ./sample en2 9e:8b:f7:e6:00:0b 0x0 10 10
src addr = 7EEFBB08F10C
dst addr = 9E8BF7E6000B
Ethertype: 0
Count: 10
Size: 60

If I update libdnet-stripped/src/eth-ndd.c as follows:

$ /opt/local/diffutils/bin/diff -u libdnet-stripped/src/eth-ndd.c.orig
libdnet-stripped/src/eth-ndd.c
--- libdnet-stripped/src/eth-ndd.c.orig 2012-12-08 11:41:06.000000000 -0500
+++ libdnet-stripped/src/eth-ndd.c      2012-12-08 11:41:29.000000000 -0500
@@ -42,9 +42,9 @@
        sa.sndd_8022_family = AF_NDD;
         sa.sndd_8022_len = sizeof(sa);
        sa.sndd_8022_filtertype = NS_ETHERTYPE;
-       sa.sndd_8022_ethertype = ETH_TYPE_IP;
+       sa.sndd_8022_ethertype = 0;
        sa.sndd_8022_filterlen = sizeof(struct ns_8022);
-       strlcpy(sa.sndd_8022_nddname, device, sizeof(sa.sndd_8022_nddname));
+       strlcpy(e->device, device, sizeof(e->device));

        if (bind(e->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0)
                return (eth_close(e));

Did you also try this patch without the second change? I think it's
wrong not to assign sndd_8022_nddname. It is probably also wrong not to
assign e->device, but I don't think that would actually have an effect.

The only other thing I can think of is that maybe the payload needs to
be padded to 60 bytes, as reported here:
        http://seclists.org/nmap-dev/2012/q1/96
You could try setting the --data-length option to test if this is the
case. I think it is unlikely, though, as the earlier report had EMSGSIZE
for this error. I think it's more likely that you need to restore the
assignment to sndd_8022_nddname.

David Fifield
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


Current thread: