Find the answer to your Linux question:
Results 1 to 4 of 4
Hello network programmers, For a student project i'm going to use libnet to write a link dropper experimental tools which stands at gateway and drop the session which matchs against ...
  1. #1
    Just Joined!
    Join Date
    Aug 2006
    Posts
    2

    programming with LIBNET

    Hello network programmers,
    For a student project i'm going to use libnet to write a link dropper experimental tools which stands at gateway and drop the session which matchs against my filtering criteria. It is not kind of firewall but similar!

    Who can give me a clue how can i jump into libnet programming.
    by the way i download the source but there is a bit problems in compiling. i know it's my fault.
    Cheers!

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Posts
    2
    Using Libnet is simple and straightforward. The below piece of code put a single icmp hello on the wire:

    char errbuf[LIBNET_ERRBUF_SIZE];

    libnet_t *l; // Libnet context buffer. you always init at-least one of them in this library.
    char *device = NULL; // In this case we select default network card to put in use
    char *dst = "192.168.100.1"; // Suppose it is ip address of the server
    char *src = "192.168.100.100";

    u_long src_ip = 0, dst_ip = 0;
    libnet_ptag_t t;
    char *payload = NULL; // we have no payload
    u_short payload_s = 0;



    l = libnet_init(
    LIBNET_RAW4, /* injection type */
    device, /* network interface */
    errbuf); /* errbuf */

    dst_ip = libnet_name2addr4(l, pDst, LIBNET_RESOLVE); // Resolve dst ip address to a network byte ordered IPv4 address
    src_ip = libnet_name2addr4(l, pSrc, LIBNET_RESOLVE);

    t = libnet_build_icmpv4_echo(
    ICMP_ECHO, /* type */
    0, /* code */
    0, /* checksum */
    0x42, /* id */
    0x42, /* sequence number */
    NULL, /* payload */
    0, /* payload size */
    l, /* libnet handle */
    0);

    t = libnet_build_ipv4(
    LIBNET_IPV4_H + LIBNET_ICMPV4_ECHO_H + payload_s, /* length */
    0, /* TOS */
    0x42, /* IP ID */
    0, /* IP Frag */
    64, /* TTL */
    IPPROTO_ICMP, /* protocol */
    0, /* checksum */
    src_ip, /* source IP */
    dst_ip, /* destination IP */
    payload, /* payload */
    payload_s, /* payload size */
    l, /* libnet handle */
    0);


    libnet_write(l); // put the packet on the wire
    libnet_destroy(l); // destroy the context buffer

    Meanwhile for a whole tutorial search the web or visit here:
    network programming with libnet

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    2
    For resources regarding to network security and so on take a look at the following blogspots:
    low level network programming
    and
    network security vulnerabilities and exploits

  4. #4
    Just Joined!
    Join Date
    Mar 2009
    Posts
    3
    Hi All
    I am using Libnet.
    Can any one help me with IP Fragmentation? Which value should i use so my packet get fragmneted? can you quote any exmpale of Payload and IP Frag flag value?
    Regards
    Aamir

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...