fake_worker.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. /**
  41. * Suspend emulation
  42. *
  43. * @param instance Pointer to a FuzzerWorker
  44. */
  45. void fuzzer_worker_pause(FuzzerWorker* instance);
  46. /**
  47. * Init attack by default dictionary
  48. *
  49. * @param instance Pointer to a FuzzerWorker
  50. * @param protocol_index index of the selected protocol
  51. * @return bool True if initialization is successful
  52. */
  53. bool fuzzer_worker_init_attack_dict(FuzzerWorker* instance, FuzzerProtocolsID protocol_index);
  54. /**
  55. * Init attack by custom dictionary
  56. *
  57. * @param instance Pointer to a FuzzerWorker
  58. * @param protocol_index index of the selected protocol
  59. * @param file_path file path to the dictionary
  60. * @return bool True if initialization is successful
  61. */
  62. bool fuzzer_worker_init_attack_file_dict(
  63. FuzzerWorker* instance,
  64. FuzzerProtocolsID protocol_index,
  65. FuriString* file_path);
  66. /**
  67. * Init attack brute force one of byte
  68. *
  69. * @param instance Pointer to a FuzzerWorker
  70. * @param protocol_index index of the selected protocol
  71. * @param new_uid Pointer to a FuzzerPayload with UID for brute force
  72. * @param chosen index of chusen byte
  73. * @return bool True if initialization is successful
  74. */
  75. bool fuzzer_worker_init_attack_bf_byte(
  76. FuzzerWorker* instance,
  77. FuzzerProtocolsID protocol_index,
  78. const FuzzerPayload* new_uid,
  79. uint8_t chusen);
  80. /**
  81. * Get current UID
  82. *
  83. * @param instance Pointer to a FuzzerWorker
  84. * @param output_key Pointer to a FuzzerPayload
  85. */
  86. void fuzzer_worker_get_current_key(FuzzerWorker* instance, FuzzerPayload* output_key);
  87. /**
  88. * Load UID from Flipper Format Key file
  89. *
  90. * @param instance Pointer to a FuzzerWorker
  91. * @param protocol_index index of the selected protocol
  92. * @param filename file path to the key file
  93. * @return bool True if loading is successful
  94. */
  95. bool fuzzer_worker_load_key_from_file(
  96. FuzzerWorker* instance,
  97. FuzzerProtocolsID protocol_index,
  98. const char* filename);
  99. /**
  100. * Set callback for uid changed
  101. *
  102. * @param instance Pointer to a FuzzerWorker
  103. * @param callback Callback for uid changed
  104. * @param context Context for callback
  105. */
  106. void fuzzer_worker_set_uid_chaged_callback(
  107. FuzzerWorker* instance,
  108. FuzzerWorkerUidChagedCallback callback,
  109. void* context);
  110. /**
  111. * Set callback for end of emulation
  112. *
  113. * @param instance Pointer to a FuzzerWorker
  114. * @param callback Callback for end of emulation
  115. * @param context Context for callback
  116. */
  117. void fuzzer_worker_set_end_callback(
  118. FuzzerWorker* instance,
  119. FuzzerWorkerEndCallback callback,
  120. void* context);