This started with a simple task, send an ICMP package of type 8 and code 0 to a host in my network. Since I use my Mac for everything I installed nemesis using macports and tried the following command.

sudo nemesis icmp -i 8 -c 0 -P ./payload -D 172.16.148.133

This resulted in an error.

ERROR: Incomplete packet injection.  Only wrote -1 bytes.

ICMP Injection Failure

And ever since then I have not been able to use nemesis icmp at all from two known good mac computers, I always get this same exact error.

So my response when I noticed this was to simply compile it on a FreeBSD 8.2 system from ports, nemesis 1.4 build 26, same as on OS X.

Works just as it should, no errors, happy user. :)

But I don't want to login to a FreeBSD system everytime I want to use nemesis so what's wrong here? I've tried compiling nemesis 1.4 build 26 from the source code on sourceforge, linking to the libnet installed by macports in /opt, but it did not make a difference.

Note: I've tried running this nemesis command on both systems using a root terminal, not just through sudo that is.

link|improve this question
Just fishing here, but what if you try sudo -s and then run the command? – squircle May 1 '11 at 14:05
@squircle same issue. On FreeBSD I don't even use sudo for this, I just have a root terminal open. I've tried this on OS X too, same issue. – nocturnal May 1 '11 at 14:12
Well that's what sudo -s does; open a root terminal. So I guess it's not a permissions problem... – squircle May 1 '11 at 14:19
feedback

1 Answer

up vote 0 down vote accepted

This looks like a failing of libnet. From the source code of nemesis:

if (got_link)
    n = libnet_write_link_layer(l2, device, pkt, icmp_packetlen);
else
    n = libnet_write_ip(sockfd, pkt, icmp_packetlen);

if (verbose == 2)
    nemesis_hexdump(pkt, icmp_packetlen, HEX_ASCII_DECODE);
if (verbose == 3)
    nemesis_hexdump(pkt, icmp_packetlen, HEX_RAW_DECODE);

if (n != icmp_packetlen)
{
    fprintf(stderr, "ERROR: Incomplete packet injection.  Only wrote "
            "%d bytes.\n", n);
}

So the failure is in libnet_write_ip() or libnet_write_link_layer().

I would recommend manually recompiling libnet from source and linking nemesis against that new copy.

link|improve this answer
You read my mind, and also the source code. Thank you. – nocturnal May 1 '11 at 14:38
I haven't solved this yet because I've had shit to do today but I believe you're right. Simply because macports compile version 1.0.2a_4 and the last OLD release of libnet was 1.0.2a. If I download the source of 1.0.2a myself and try to compile it I get a lot of errors relating to a structure in the code. So clearly macports is patching the code. I've tried to find the patches but now I think I'll just try to fix the compile errors myself. – nocturnal May 1 '11 at 17:32
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.