fake_worker.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #pragma once
  2. #include <furi.h>
  3. #include "protocol.h"
  4. typedef enum {
  5. FuzzerWorkerAttackTypeDefaultDict = 0,
  6. FuzzerWorkerAttackTypeLoadFile,
  7. FuzzerWorkerAttackTypeLoadFileCustomUids,
  8. FuzzerWorkerAttackTypeMax,
  9. } FuzzerWorkerAttackType;
  10. typedef enum {
  11. FuzzerWorkerLoadKeyStateBadFile = -2,
  12. FuzzerWorkerLoadKeyStateUnsuportedProto,
  13. FuzzerWorkerLoadKeyStateOk = 0,
  14. FuzzerWorkerLoadKeyStateDifferentProto,
  15. } FuzzerWorkerLoadKeyState;
  16. typedef void (*FuzzerWorkerUidChagedCallback)(void* context);
  17. typedef void (*FuzzerWorkerEndCallback)(void* context);
  18. typedef struct FuzzerWorker FuzzerWorker;
  19. /**
  20. * Allocate FuzzerWorker
  21. *
  22. * @return FuzzerWorker* pointer to FuzzerWorker
  23. */
  24. FuzzerWorker* fuzzer_worker_alloc();
  25. /**
  26. * Free FuzzerWorker
  27. *
  28. * @param instance Pointer to a FuzzerWorker
  29. */
  30. void fuzzer_worker_free(FuzzerWorker* instance);
  31. /**
  32. * Start or continue emulation
  33. *
  34. * @param instance Pointer to a FuzzerWorker
  35. * @param idle_time Delay between emulations in tenths of a second
  36. * @param emu_time Emulation time of one UID in tenths of a second
  37. * @return bool True if emulation has started
  38. */
  39. bool fuzzer_worker_start(FuzzerWorker* instance, uint8_t idle_time, uint8_t emu_time);
  40. /**
  41. * Stop emulation and deinit worker
  42. *
  43. * @param instance Pointer to a FuzzerWorker
  44. */
  45. void fuzzer_worker_stop(FuzzerWorker* instance);
  46. void fuzzer_worker_start_emulate(FuzzerWorker* instance);
  47. /**
  48. * Suspend emulation
  49. *
  50. * @param instance Pointer to a FuzzerWorker
  51. */
  52. void fuzzer_worker_pause(FuzzerWorker* instance);
  53. /**
  54. * Init attack by default dictionary
  55. *
  56. * @param instance Pointer to a FuzzerWorker
  57. * @param protocol_index index of the selected protocol
  58. * @return bool True if initialization is successful
  59. */
  60. bool fuzzer_worker_init_attack_dict(FuzzerWorker* instance, FuzzerProtocolsID protocol_index);
  61. /**
  62. * Init attack by custom dictionary
  63. *
  64. * @param instance Pointer to a FuzzerWorker
  65. * @param protocol_index index of the selected protocol
  66. * @param file_path file path to the dictionary
  67. * @return bool True if initialization is successful
  68. */
  69. bool fuzzer_worker_init_attack_file_dict(
  70. FuzzerWorker* instance,
  71. FuzzerProtocolsID protocol_index,
  72. FuriString* file_path);
  73. /**
  74. * Init attack brute force one of byte
  75. *
  76. * @param instance Pointer to a FuzzerWorker
  77. * @param protocol_index index of the selected protocol
  78. * @param new_uid Pointer to a FuzzerPayload with UID for brute force
  79. * @param chosen index of chusen byte
  80. * @return bool True if initialization is successful
  81. */
  82. bool fuzzer_worker_init_attack_bf_byte(
  83. FuzzerWorker* instance,
  84. FuzzerProtocolsID protocol_index,
  85. const FuzzerPayload* new_uid,
  86. uint8_t chusen);
  87. /**
  88. * Get current UID
  89. *
  90. * @param instance Pointer to a FuzzerWorker
  91. * @param output_key Pointer to a FuzzerPayload
  92. */
  93. void fuzzer_worker_get_current_key(FuzzerWorker* instance, FuzzerPayload* output_key);
  94. bool fuzzer_worker_next_key(FuzzerWorker* instance);
  95. bool fuzzer_worker_previous_key(FuzzerWorker* instance);
  96. /**
  97. * Load UID from Flipper Format Key file
  98. *
  99. * @param instance Pointer to a FuzzerWorker
  100. * @param protocol_index index of the selected protocol
  101. * @param filename file path to the key file
  102. * @return bool True if loading is successful
  103. */
  104. FuzzerWorkerLoadKeyState fuzzer_worker_load_key_from_file(
  105. FuzzerWorker* instance,
  106. FuzzerProtocolsID* protocol_index,
  107. const char* filename);
  108. bool fuzzer_worker_save_key(FuzzerWorker* instance, const char* path);
  109. /**
  110. * Set callback for uid changed
  111. *
  112. * @param instance Pointer to a FuzzerWorker
  113. * @param callback Callback for uid changed
  114. * @param context Context for callback
  115. */
  116. void fuzzer_worker_set_uid_chaged_callback(
  117. FuzzerWorker* instance,
  118. FuzzerWorkerUidChagedCallback callback,
  119. void* context);
  120. /**
  121. * Set callback for end of emulation
  122. *
  123. * @param instance Pointer to a FuzzerWorker
  124. * @param callback Callback for end of emulation
  125. * @param context Context for callback
  126. */
  127. void fuzzer_worker_set_end_callback(
  128. FuzzerWorker* instance,
  129. FuzzerWorkerEndCallback callback,
  130. void* context);