+void BruteForcePCF7931(uint64_t password, uint8_t tries, uint16_t init_delay, int32_t l, int32_t p) {
+ uint8_t i = 0;
+ uint8_t pass_array[7];
+
+ while (password < 0x00FFFFFFFFFFFFFF) {
+ if (BUTTON_PRESS()) {
+ Dbprintf("Button pressed, stopping bruteforce ...");
+ return;
+ }
+
+ pass_array[0] = password & 0xFF;
+ pass_array[1] = (password >> 8) & 0xFF;
+ pass_array[2] = (password >> 16) & 0xFF;
+ pass_array[3] = (password >> 24) & 0xFF;
+ pass_array[4] = (password >> 32) & 0xFF;
+ pass_array[5] = (password >> 40) & 0xFF;
+ pass_array[6] = (password >> 48) & 0xFF;
+
+ Dbprintf("Trying: %02x %02x %02x %02x %02x %02x %02x ...",
+ pass_array[0],
+ pass_array[1],
+ pass_array[2],
+ pass_array[3],
+ pass_array[4],
+ pass_array[5],
+ pass_array[6]);
+
+ for (i = 0; i < tries; ++i)
+ RealWritePCF7931
+ (
+ pass_array,
+ init_delay,
+ l,
+ p,
+ 0,
+ 7,
+ 0x01
+ );
+
+ ++password;
+ }
+}
+
+/* Write on a byte of a PCF7931 tag
+ * @param address : address of the block to write
+ @param byte : address of the byte to write
+ @param data : data to write
+ */
+void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
+ Dbprintf("Initialization delay : %d us", init_delay);
+ Dbprintf("Offsets : %d us on the low pulses width, %d us on the low pulses positions", l, p);
+ Dbprintf("Password (LSB first on each byte): %02x %02x %02x %02x %02x %02x %02x", pass1, pass2, pass3, pass4, pass5, pass6, pass7);
+ Dbprintf("Block address : %02x", address);
+ Dbprintf("Byte address : %02x", byte);
+ Dbprintf("Data : %02x", data);
+
+ uint8_t password[7] = {pass1, pass2, pass3, pass4, pass5, pass6, pass7};
+
+ RealWritePCF7931 (password, init_delay, l, p, address, byte, data);
+}
+