fake_worker.h 3.7 KB

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