Results 1 to 4 of 4

Thread: Wireless Libraries Help

  1. #1
    Junior Member SBerry's Avatar
    Join Date
    Dec 2007
    Posts
    94

    Default Wireless Libraries Help

    Guys for a little project I want to implement a wireless network monitor with similar data detail that Airodump and Kismet display. I plan to write this in C or C++. I have already used the windows wireless api to write a windows network monitor similar to wireless zero. What api's or libraries should I be looking at for linux networking dev. Should I be looking at libpcap and libnet etc..??

    I would really appreciate some guidance here

    Thanks in advance

  2. #2
    Member
    Join Date
    Mar 2008
    Posts
    114

    Default

    Hello!!
    To develop your soft, have a look to libnet, libnids, and libpcap. you should also find some interesting things in the netinet folder. There is a lot of librairy for IP, ethernet and TCP developping.

    Bye

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    44

    Default

    i'm interested in this too.

    it would be really helpful if someone would post an example of C program that lists all of the networks essids/bssids/channels in range.

    (dont blame me for no effort, i just dont have time to mess with these things, and it would be really nice if someone has an example to show )

  4. #4
    Junior Member SBerry's Avatar
    Join Date
    Dec 2007
    Posts
    94

    Default

    I have code using libpcap that will capture yourself a beacon packet. From that you can get the ssid.

    Have a look at this. Using bit field for frame control struct. By the way have a look at the source code for airodump-ng. That might also clear up a few things

    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<pcap.h>
    #include<errno.h>
    #include<arpa/inet.h>
    #include<net/ethernet.h>
    #include<linux/wireless.h>
    #include<netinet/if_ether.h>

    typedef struct mac_header{
    unsigned char fc[2];
    unsigned char id[2];
    unsigned char add1[6];
    unsigned char add2[6];
    unsigned char add3[6];
    unsigned char sc[2];
    }mac_header;

    typedef struct frame_control{
    unsigned protocol:2;
    unsigned type:2;
    unsigned subtype:4;
    unsigned to_ds:1;
    unsigned from_ds:1;
    unsigned more_frag:1;
    unsigned retry:1;
    unsigned pwr_mgt:1;
    unsigned more_data:1;
    unsigned wep:1;
    unsigned order:1;
    }frame_control;

    typedef struct beacon_header{
    unsigned char timestamp[8];
    unsigned char beacon_interval[2];
    unsigned char cap_info[2];
    }beacon_header;


    void packet_decoder (u_char * useless, const struct pcap_pkthdr *pkthdr, const u_char * packet)
    {
    printf("Got Packet");
    char ssid[32], *temp;
    struct mac_header *p = (struct mac_header *) packet;
    struct frame_control *control = (struct frame_control *) p->fc;
    temp = (char *) (packet + sizeof (struct mac_header) +
    sizeof (struct beacon_header));
    memset (ssid, '\0', 32);
    // check if frame is beacon frame
    if ((control->protocol == 0) && (control->type == 0)
    && (control->subtype == 8))
    {
    //temp[1] contains the size of the ssid field and temp[2] the beginning of
    //the ssid string .
    memcpy (ssid, &temp[2], temp[1]);
    printf ("\n\nFound SSID : \n");
    printf ("Destination Add : %s\n", ether_ntoa (p->add1));
    printf ("Source Add : %s\n", ether_ntoa (p->add2));
    printf ("BSSID : %s\n", ether_ntoa (p->add3));
    printf ("ssid = %s\n", ssid);
    }
    }
    int main (int argc, char **argv)
    {
    char *dev = argv[1];
    char errbuf[PCAP_ERRBUF_SIZE];
    pcap_t *handle;
    if (argc < 2)
    {
    printf ("usage : %s capture_device \n", argv[0]);
    exit (1);
    }
    printf ("Initialising capture interface..");
    //pcap initialisation
    handle = pcap_open_live (dev, BUFSIZ, 1, -1, errbuf);
    if (handle == NULL)
    {
    printf ("pcap_open_live : %s\n", errbuf);
    exit (1);
    }
    printf ("\nStarting Capture ...........\n");
    // tell pcap to pass on captures frames to our packet_decoder fn
    pcap_loop (handle, -1, packet_decoder, NULL);
    return (0);
    }

Posting Permissions

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