libnet_adv_write_raw
"Mustafa Abu Sedera" <[email protected]>
| Newsgroups | gmane.comp.security.libnet |
|---|---|
| Message-ID | <[email protected]> |
i sent this same mail before but got a delivery failure so i am sending it again. sorry if you get this mail the second time. i tested the function in a program now and it worked. Hi Mike! as you have maybe already seen in the mailing list i was asking if it was possible to send a raw ip packet in a similar way like libnet_adv_write_link() by just specifying a pointer to the packet and it's length. i looked at the source code of libnet_write() and used libnet_write_raw_ipv4() directly in my program and it worked,but having the disadvantage of libnet_t* not being updated with new statistics. so made some easy modification to libnet_write() by cutting away the code of libnet_pblock_coalesce() and free and instead let let the user supply the function with the u_int8_t* packet and u_int32_t len. the user would get an error message that adv raw mode is not enabled if libnet_t is not initialized in LIBNET_RAW4(or 6)_ADV. please take a look at it. if you like the idea and could do it in a better way it could be added to 1.1.2. P.S. please don't make fun of me if it is totally dump ;). i am still kinda noob but this function would be useful for me and i think for others too. regards, Mustaffa Abu Sedira _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
libnet_adv_write_raw3.c
(text/plain, 1.2 KB)
int
libnet_adv_write_raw(libnet_t *l, u_int8_t *packet, u_int32_t len)
{
u_int c;
if (l == NULL)
{
return (-1);
}
/* assume error */
c = -1;
switch (l->injection_type)
{
case LIBNET_RAW4_ADV:
if (len > LIBNET_MAX_PACKET)
{
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"%s(): packet is too large %d\n", __func__, len);
return (c);
}
c = libnet_write_raw_ipv4(l, packet, len);
break;
case LIBNET_RAW6_ADV:
c = libnet_write_raw_ipv6(l, packet, len);
break;
default:
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"%s(): advanced raw mode not enabled\n", __func__);
return (-1);
}
/* do statistics */
if (c == len)
{
l->stats.packets_sent++;
l->stats.bytes_written += c;
}
else
{
l->stats.packet_errors++;
/*
* XXX - we probably should have a way to retrieve the number of
* bytes actually written (since we might have written something).
*/
if (c > 0)
{
l->stats.bytes_written += c;
}
}
return (c);
}