wifi_marauder_script.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * ----------------------------------------------------------------------------------------------------
  3. * STEPS TO ADD A NEW STAGE:
  4. *
  5. * wifi_marauder_script.h
  6. * - Complement WifiMarauderScriptStageType enum with new stage
  7. * - Create struct WifiMarauderScriptStage???? for the new stage
  8. *
  9. * wifi_marauder_script.c
  10. * - Create function "WifiMarauderScriptStage????* _wifi_marauder_script_get_stage_????(cJSON *stages)"
  11. * - Change _wifi_marauder_script_load_stages() to load new stage
  12. * - Add case to free memory in wifi_marauder_script_free()
  13. *
  14. * wifi_marauder_script_executor.c
  15. * - Create function "void _wifi_marauder_script_execute_????(WifiMarauderScriptStage????* stage)"
  16. * - Add case in wifi_marauder_script_execute_stage()
  17. *
  18. * ----------------------------------------------------------------------------------------------------
  19. * IMPLEMENTED STAGES (In order of execution):
  20. * - Scan
  21. * - Select
  22. * - Deauth
  23. * - Probe
  24. * - Sniff beacon
  25. * - Sniff PMKID
  26. * - Beacon List
  27. * ----------------------------------------------------------------------------------------------------
  28. * SCRIPT SYNTAX:
  29. * {
  30. * "meta": {
  31. * "description": "My script",
  32. * "repeat": times the script will repeat (default 1),
  33. * "enableLed": true (default) | false,
  34. * "savePcap": true (default) | false
  35. * },
  36. * "stages": {
  37. * "scan": {
  38. * "type": "ap" | "station",
  39. * "timeout": seconds,
  40. * "channel": 1-11
  41. * },
  42. * "select": {
  43. * "type": "ap" | "station" | "ssid",
  44. * "filter": "all" | "contains \"{SSID fragment}\" or equals \"{SSID}\" or ..." (Not implemented yet on Marauder firmware)
  45. * },
  46. * "deauth": {
  47. * "timeout": seconds
  48. * },
  49. * "probe": {
  50. * "timeout": seconds
  51. * },
  52. * "sniffBeacon": {
  53. * "timeout": seconds
  54. * },
  55. * "sniffPmkid": {
  56. * "forceDeauth": true (default) | false,
  57. * "channel": 1-11,
  58. * "timeout": seconds
  59. * },
  60. * "beaconlist": {
  61. * "ssids": [
  62. * "SSID 1",
  63. * "SSID 2",
  64. * "SSID 3"
  65. * ],
  66. * "timeout": seconds
  67. * }
  68. * }
  69. * }
  70. * ----------------------------------------------------------------------------------------------------
  71. */
  72. #pragma once
  73. #include <storage/storage.h>
  74. #include "cJSON.h"
  75. typedef enum {
  76. WifiMarauderScriptStageTypeScan,
  77. WifiMarauderScriptStageTypeSelect,
  78. WifiMarauderScriptStageTypeDeauth,
  79. WifiMarauderScriptStageTypeProbe,
  80. WifiMarauderScriptStageTypeSniffBeacon,
  81. WifiMarauderScriptStageTypeSniffPmkid,
  82. WifiMarauderScriptStageTypeBeaconList,
  83. } WifiMarauderScriptStageType;
  84. typedef enum {
  85. WifiMarauderScriptScanTypeAp,
  86. WifiMarauderScriptScanTypeStation
  87. } WifiMarauderScriptScanType;
  88. typedef enum {
  89. WifiMarauderScriptSelectTypeAp,
  90. WifiMarauderScriptSelectTypeStation,
  91. WifiMarauderScriptSelectTypeSsid
  92. } WifiMarauderScriptSelectType;
  93. // Stages
  94. typedef struct WifiMarauderScriptStage {
  95. WifiMarauderScriptStageType type;
  96. void* stage;
  97. struct WifiMarauderScriptStage *next_stage;
  98. } WifiMarauderScriptStage;
  99. typedef struct WifiMarauderScriptStageScan {
  100. WifiMarauderScriptScanType type;
  101. int channel;
  102. int timeout;
  103. } WifiMarauderScriptStageScan;
  104. typedef struct WifiMarauderScriptStageSelect {
  105. WifiMarauderScriptSelectType type;
  106. char* filter;
  107. // TODO: Implement a feature to not select the same items in the next iteration of the script
  108. bool allow_repeat;
  109. } WifiMarauderScriptStageSelect;
  110. typedef struct WifiMarauderScriptStageDeauth {
  111. int timeout;
  112. } WifiMarauderScriptStageDeauth;
  113. typedef struct WifiMarauderScriptStageProbe {
  114. int timeout;
  115. } WifiMarauderScriptStageProbe;
  116. typedef struct WifiMarauderScriptStageSniffBeacon {
  117. int timeout;
  118. } WifiMarauderScriptStageSniffBeacon;
  119. typedef struct WifiMarauderScriptStageSniffPmkid {
  120. bool force_deauth;
  121. int channel;
  122. int timeout;
  123. } WifiMarauderScriptStageSniffPmkid;
  124. typedef struct WifiMarauderScriptStageBeaconList {
  125. char **ssids;
  126. int ssid_count;
  127. int timeout;
  128. } WifiMarauderScriptStageBeaconList;
  129. // Script
  130. typedef struct WifiMarauderScript {
  131. char* name;
  132. char* description;
  133. WifiMarauderScriptStage *first_stage;
  134. // TODO: Think of a way to not change the settings if they are not informed in the JSON
  135. bool enable_led;
  136. bool save_pcap;
  137. int repeat;
  138. } WifiMarauderScript;
  139. WifiMarauderScript* wifi_marauder_script_alloc();
  140. WifiMarauderScript* wifi_marauder_script_parse_raw(const char* script_raw);
  141. WifiMarauderScript* wifi_marauder_script_parse_file(const char* file_path, Storage* storage);
  142. WifiMarauderScriptStage* wifi_marauder_script_get_stage(WifiMarauderScript* script, WifiMarauderScriptStageType stage_type);
  143. void wifi_marauder_script_free(WifiMarauderScript *script);