fuzzer.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Manages what to fuzz when.
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdint.h>
  7. #include <string.h>
  8. #include "frameDefinitions.h"
  9. #include "fuzzSSID.h"
  10. //Number of subfuzzers
  11. #define SUBFUZZERS (1)
  12. //CHANGE WHEN NEW SUBFUZZER
  13. //Array of pointers to subfuzzers update functions
  14. int (*p[SUBFUZZERS]) (int i) = {ssidFuzzUpdate};
  15. //State of sub-fuzzer
  16. //-1 = Done
  17. //0 = In progress
  18. int subFuzzState = -1;
  19. //Current sub-fuzzer
  20. //Starts with -1 to prevent skipping the first sub-fuzzer
  21. int subFuzzerIdx = -1;
  22. //Flag to indicate if the done with all subfuzzers notification has been sent
  23. int notifyDone = 0;
  24. int frameCounter = 0;
  25. //Controls state of fuzzer, and therefore what to fuzz next
  26. void increaseFuzzer()
  27. {
  28. frameCounter = frameCounter + 1;
  29. //while we still have sub-fuzzers to go
  30. if (subFuzzerIdx < SUBFUZZERS)
  31. {
  32. if (subFuzzState == -1)
  33. {
  34. subFuzzerIdx = subFuzzerIdx + 1;
  35. if (subFuzzerIdx < SUBFUZZERS)
  36. {
  37. subFuzzState = (*p[subFuzzerIdx]) (0);
  38. }
  39. }
  40. else
  41. {
  42. subFuzzState = (*p[subFuzzerIdx]) (1);
  43. }
  44. }
  45. //Done with all sub-fuzzers
  46. else
  47. {
  48. //Only do first time
  49. if (notifyDone == 0)
  50. {
  51. notifyDone = 1;
  52. printf("Done with all subfuzzers\n");
  53. printf("Sent %d different frames in total\n", frameCounter);
  54. //Optional exit
  55. exit(1);
  56. }
  57. }
  58. }