123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- /*
- Fuzzes vendor specific Information element
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <string.h>
- #include "../frameDefinitions.h"
- //Indecates whether the vendorFuzzer is running
- int vendorRunningState = 0;
- //Number of fuzzing states
- const int vendorStates = 17;
- //Steps of fuzzers for each fuzzing state
- const int vendorSteps[] = {1, 8, 2, 2, 2, 2,2,2,2,2,2,2,2,2,2,2,2};
- //Current state and step of the vendorFuzzer
- int fuzzState;
- int fuzzStep;
- void vendorPrintCurrentState()
- {
- switch (fuzzState)
- {
- case 0:
- {
- printf("\e[33mFuzzing vendor IE\e[39m\n");
- printf("Trying 255*0xFF data\n");
- break;
- }
- case 1:
- {
- printf("fuzzing low lengths\n");
- break;
- }
- case 2:
- {
- printf("fuzzing WMM/WME\n");
- break;
- }
- case 3:
- {
- printf("fuzzing WPA\n");
- break;
- }
- case 4:
- {
- printf("fuzzing WPS\n");
- break;
- }
- case 5:
- {
- printf("fuzzing WPS Version length\n");
- break;
- }
- case 6:
- {
- printf("fuzzing WPS wpss length\n");
- break;
- }
- case 7:
- {
- printf("fuzzing WPS model number length\n");
- break;
- }
- case 8:
- {
- printf("fuzzing WPS response type length\n");
- break;
- }
- case 9:
- {
- printf("fuzzing WPS uuid length\n");
- break;
- }
- case 10:
- {
- printf("fuzzing WPS manufacturer length\n");
- break;
- }
- case 11:
- {
- printf("fuzzing WPS model name length\n");
- break;
- }
- case 12:
- {
- printf("fuzzing WPS primary device type length\n");
- break;
- }
- case 13:
- {
- printf("fuzzing WPS device name length\n");
- break;
- }
- case 14:
- {
- printf("fuzzing WPS config methods length\n");
- break;
- }
- case 15:
- {
- printf("fuzzing WPS rf bands length\n");
- break;
- }
- case 16:
- {
- printf("fuzzing WPS vendor extension length\n");
- break;
- }
- case 17:
- {
- printf("\e[33mDone with fuzzing vendor\e[39m\n");
- break;
- }
- }
- }
- //Updates vendorFuzzer
- //Status 0 indicates start
- //Status 1 indicates increaseStep
- //Status 2 indicates stop
- //Returns -1 if done with fuzzing
- int vendorFuzzUpdate(int status)
- {
- switch (status)
- {
- case 0: //start fuzzer
- {
- vendorRunningState = 1;
- fuzzState = 0;
- fuzzStep = 0;
- vendorPrintCurrentState();
- break;
- }
- case 1: //update fuzzer
- {
- if (vendorRunningState == 1) //sanity check
- {
- //increase steps until all steps are done
- if (fuzzStep < vendorSteps[fuzzState]-1)
- fuzzStep = fuzzStep + 1;
- //then increase state and notify
- else
- {
- fuzzStep = 0;
- fuzzState = fuzzState + 1;
- vendorPrintCurrentState();
- }
- //when all states are done, stop
- if (fuzzState == vendorStates)
- {
- vendorRunningState = 0;
- return -1;
- }
- }
- break;
- }
- case 2: //stop fuzzer
- {
- vendorRunningState = 0;
- break;
- }
- }
- return 0;
- }
- //Returns an vendor information element
- infoElem vendorFuzz()
- {
- infoElem vendor;
- //What to return when not fuzzed
- if (vendorRunningState == 0)
- {
- vendor.id = 0;
- vendor.len = 1;
- vendor.len_data = -1;
- vendor.data = "\xab";
- }
- else
- {
- switch (fuzzState) //update this
- {
- case 0: //255*0xff
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- //create data of 255 times 0xff
- u_char *data = malloc(255);
- memset(data, 0xff, 255);
- vendor.data = data;
- break;
- }
- case 1: //short lengths
- {
- int dataSize = 0 + fuzzStep;
- vendor.id = 221;
- vendor.len = dataSize;
- vendor.len_data = dataSize;
- //create data of datasize times 0xFF
- u_char *data = malloc(dataSize);
- memset(data, 0xFF, dataSize);
- vendor.data = data;
- break;
- }
- case 2:
- {
- if (fuzzStep == 0)
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- u_char *data = malloc(255);
- memset(data, 0xFF, 255);
- data[0] = 0x00; //oui
- data[1] = 0x50; //oui
- data[2] = 0xf2; //oui
- data[3] = 0x02; //type
- vendor.data = data;
- }
- if (fuzzStep == 1)
- {
- vendor.id = 221;
- vendor.len = 4;
- vendor.len_data = 4;
- vendor.data = "\x00\x50\xf2\x02";
- }
- break;
- }
- case 3:
- {
- if (fuzzStep == 0)
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- u_char *data = malloc(255);
- memset(data, 0xFF, 255);
- data[0] = 0x00; //oui
- data[1] = 0x50; //oui
- data[2] = 0xf2; //oui
- data[3] = 0x01; //type
- vendor.data = data;
- }
- if (fuzzStep == 1)
- {
- vendor.id = 221;
- vendor.len = 4;
- vendor.len_data = 4;
- vendor.data = "\x00\x50\xf2\x01";
- }
- break;
- }
- case 4:
- {
- if (fuzzStep == 0)
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- u_char *data = malloc(255);
- memset(data, 0xFF, 255);
- data[0] = 0x00; //oui
- data[1] = 0x50; //oui
- data[2] = 0xf2; //oui
- data[3] = 0x04; //type
- vendor.data = data;
- }
- if (fuzzStep == 1)
- {
- vendor.id = 221;
- vendor.len = 4;
- vendor.len_data = 4;
- vendor.data = "\x00\x50\xf2\x04";
- }
- break;
- }
- default:
- {
- if (fuzzStep == 0)
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- u_char *data = malloc(255);
- memset(data, 0xFF, 255);
- data[0] = 0x00; //oui
- data[1] = 0x50; //oui
- data[2] = 0xf2; //oui
- data[3] = 0x04; //type
- switch (fuzzState)
- {
- case 5:{
- data[4] = 0x10; //id
- data[5] = 0x4a; //id
- break;
- }
- case 6:{
- data[4] = 0x10; //id
- data[5] = 0x44; //id
- break;
- }
- case 7:{
- data[4] = 0x10; //id
- data[5] = 0x24; //id
- break;
- }
- case 8:{
- data[4] = 0x10; //id
- data[5] = 0x3b; //id
- break;
- }
- case 9:{
- data[4] = 0x10; //id
- data[5] = 0x47; //id
- break;
- }
- case 10:{
- data[4] = 0x10; //id
- data[5] = 0x21; //id
- break;
- }
- case 11:{
- data[4] = 0x10; //id
- data[5] = 0x23; //id
- break;
- }
- case 12:{
- data[4] = 0x10; //id
- data[5] = 0x54; //id
- break;
- }
- case 13:{
- data[4] = 0x10; //id
- data[5] = 0x11; //id
- break;
- }
- case 14:{
- data[4] = 0x10; //id
- data[5] = 0x08; //id
- break;
- }
- case 15:{
- data[4] = 0x10; //id
- data[5] = 0x3c; //id
- break;
- }
- case 16:{
- data[4] = 0x10; //id
- data[5] = 0x49; //id
- break;
- }
- }
-
- data[6] = 0x00; //len
- data[7] = 247; //len
- vendor.data = data;
- }
- if (fuzzStep == 1)
- {
- vendor.id = 221;
- vendor.len = 255;
- vendor.len_data = 255;
- u_char *data = malloc(255);
- memset(data, 0xFF, 255);
- data[0] = 0x00; //oui
- data[1] = 0x50; //oui
- data[2] = 0xf2; //oui
- data[3] = 0x04; //type
- switch (fuzzState)
- {
- case 5:{
- data[4] = 0x10; //id
- data[5] = 0x4a; //id
- break;
- }
- case 6:{
- data[4] = 0x10; //id
- data[5] = 0x44; //id
- break;
- }
- case 7:{
- data[4] = 0x10; //id
- data[5] = 0x24; //id
- break;
- }
- case 8:{
- data[4] = 0x10; //id
- data[5] = 0x3b; //id
- break;
- }
- case 9:{
- data[4] = 0x10; //id
- data[5] = 0x47; //id
- break;
- }
- case 10:{
- data[4] = 0x10; //id
- data[5] = 0x21; //id
- break;
- }
- case 11:{
- data[4] = 0x10; //id
- data[5] = 0x23; //id
- break;
- }
- case 12:{
- data[4] = 0x10; //id
- data[5] = 0x54; //id
- break;
- }
- case 13:{
- data[4] = 0x10; //id
- data[5] = 0x11; //id
- break;
- }
- case 14:{
- data[4] = 0x10; //id
- data[5] = 0x08; //id
- break;
- }
- case 15:{
- data[4] = 0x10; //id
- data[5] = 0x3c; //id
- break;
- }
- case 16:{
- data[4] = 0x10; //id
- data[5] = 0x49; //id
- break;
- }
- }
- data[6] = 0xff; //len
- data[7] = 0xff; //len
- vendor.data = data;
- }
- break;
- }
- }
- }
-
- return vendor;
- }
|