Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2020-05-20 00:01:07

Rosco
Contributor
Registered: 2019-12-10
Posts: 43

[PATCH] Interpreting Destron Fearing LifeChip Bio-Thermo temperature

Hello,

I submit this patch against cmdlffdx.c to interpret the temperature returned by Destron Fearing LifeChip with Bio-Thermo technology FDX transponders - and also to add extended bits in the FDX simulation command.

--- cmdlffdx.c	2020-05-16 11:06:27.131127929 +0300
+++ cmdlffdx.c	2020-05-20 01:39:25.714450827 +0300
@@ -66,17 +66,18 @@
 	PrintAndLog("Enables simulation of FDX-B animal tag");
 	PrintAndLog("Simulation runs until the button is pressed or another USB command is issued.");
 	PrintAndLog("");
-	PrintAndLog("Usage:  lf fdx sim [h] <country id> <animal id>");
+	PrintAndLog("Usage:  lf fdx sim [h] <country id> <animal id> <extended>");
 	PrintAndLog("Options:");
 	PrintAndLog("      h            : This help");
 	PrintAndLog("      <country id> : Country ID");
 	PrintAndLog("      <animal id>  : Animal ID");
+	PrintAndLog("      <extended >  : Extended bits (hex)");
 	PrintAndLog("");
-	PrintAndLog("Sample: lf fdx sim 999 112233");
+	PrintAndLog("Sample: lf fdx sim 999 112233 16a");
 	return 0;
 }
 // clearing the topbit needed for the preambl detection. 
-static void verify_values(uint32_t countryid, uint64_t animalid){
+static void verify_values(uint32_t countryid, uint64_t animalid, uint32_t extended){
 	if ((animalid & 0x3FFFFFFFFF) != animalid) {
 		animalid &= 0x3FFFFFFFFF;
 		PrintAndLog("Animal ID Truncated to 38bits: %"PRIx64, animalid);
@@ -85,6 +86,10 @@
 		countryid &= 0x3ff;
 		PrintAndLog("Country ID Truncated to 10bits: %03d", countryid);
 	}
+	if ( (extended & 0xfff) != extended ) {
+		extended &= 0xfff;
+		PrintAndLog("Extended Truncated to 24bits: 0x%03X", extended);
+	}
 }
 
 int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) {
@@ -190,6 +195,17 @@
 		PrintAndLog("DEBUG: Raw ID Hex: %s", sprint_hex(raw,8));
 	}
 
+	uint8_t btParBit = (extended & 0x100) >> 8;
+	uint8_t btTemp = extended & 0xff;
+	uint8_t btTempPar = ( ((btTemp & 0x80) >> 7) + ((btTemp & 0x40) >> 6) +
+	                      ((btTemp & 0x20) >> 5) + ((btTemp & 0x10) >> 4) +
+	                      ((btTemp & 0x08) >> 3) + ((btTemp & 0x04) >> 2) +
+	                      ((btTemp & 0x02) >> 1) +  (btTemp & 0x01)
+	                    ) & 0x01 ? 0:1;
+	uint8_t isBtTemp = (btTempPar == btParBit) && !(extended & 0xe00);
+	float btTempF = 74 + btTemp * .2;
+	float btTempC = (btTempF - 32) / 1.8;
+
 	uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
 	PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found:");
 	PrintAndLog("Animal ID:     %04u-%012" PRIu64, countryCode, NationalCode);
@@ -198,6 +214,9 @@
 	PrintAndLog("Reserved Code: %u", reservedCode);
 	PrintAndLog("Animal Tag:    %s", animalBit ? "True" : "False");
 	PrintAndLog("Has Extended:  %s [0x%X]", dataBlockBit ? "True" : "False", extended);
+	if (isBtTemp) {
+		PrintAndLog("Bio-Thermo:    %.1fF / %.1fC", btTempF, btTempC);
+	}
 	PrintAndLog("CRC:           0x%04X - 0x%04X - [%s]\n", crc16, calcCrc, (calcCrc == crc16) ? "Passed" : "Failed");
 	
 	// set block 0 for later
@@ -214,6 +233,7 @@
 
 	uint32_t countryid = 0;
 	uint64_t animalid = 0;
+	uint32_t extended = 0;
 	uint32_t blocks[5] = {T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0};
 	uint8_t bits[128];
 	uint8_t *bs = bits;
@@ -224,6 +244,7 @@
 
 	countryid = param_get32ex(Cmd, 0, 0, 10);
 	animalid = param_get64ex(Cmd, 1, 0, 10);
+	extended = param_get32ex(Cmd, 2, 0, 16);
 	
 	//Q5
 	if (param_getchar(Cmd, 2) == 'Q' || param_getchar(Cmd, 2) == 'q') {
@@ -231,10 +252,10 @@
 		blocks[0] = T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | ((32-2)>>1) << T5555_BITRATE_SHIFT | 4 << T5555_MAXBLOCK_SHIFT;
 	}
 	
-	verify_values(countryid, animalid);
+	verify_values(countryid, animalid, extended);
 	
 	// getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) 
-	if ( !getFDXBits(animalid, countryid, 1, 0, 0, bs)) {
+	if ( !getFDXBits(animalid, countryid, 1, extended?1:0, extended, bs)) {
 		PrintAndLog("Error with tag bitstream generation.");
 		return 1;
 	}	
@@ -273,14 +294,16 @@
 int CmdFdxSim(const char *Cmd) {
 	uint32_t countryid = 0;
 	uint64_t animalid = 0;
+	uint32_t extended = 0;
 
 	char cmdp = param_getchar(Cmd, 0);
 	if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_sim();
 
 	countryid = param_get32ex(Cmd, 0, 0, 10);
 	animalid = param_get64ex(Cmd, 1, 0, 10);
+	extended = param_get32ex(Cmd, 2, 0, 16);
 	
-	verify_values(countryid, animalid);
+	verify_values(countryid, animalid, extended);
 
 	uint8_t clk = 32, encoding = 2, separator = 0, invert = 1;
 	uint16_t arg1, arg2;
@@ -288,12 +311,12 @@
 	arg1 = clk << 8 | encoding;
 	arg2 = invert << 8 | separator;
 
-	PrintAndLog("Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid);
+	PrintAndLog("Simulating FDX-B animal ID %04u-%"PRIu64" (extended 0x%X)", countryid, animalid, extended);
 
 	UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}};
 
 	 //getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) 
-	getFDXBits(animalid, countryid, 1, 0, 0, c.d.asBytes);
+	getFDXBits(animalid, countryid, 1, extended?1:0, extended, c.d.asBytes);
 	clearCommandBuffer();
 	SendCommand(&c);
 	return 0;

Offline

#2 2020-05-20 10:21:45

iceman
Administrator
Registered: 2013-04-25
Posts: 9,538
Website

Re: [PATCH] Interpreting Destron Fearing LifeChip Bio-Thermo temperature

Cool contribution!
I adapted and added it to RRG/Iceman repo,   contributed Rosco, since I didn't have your GH name.

Offline

#3 2020-05-20 10:55:43

Rosco
Contributor
Registered: 2019-12-10
Posts: 43

Re: [PATCH] Interpreting Destron Fearing LifeChip Bio-Thermo temperature

Neat thanks.

No worries, my GH name is similarly uninformative anyway. I'm perfectly happy to stay anonymous smile

Last edited by Rosco (2020-05-20 15:21:58)

Offline

Board footer

Powered by FluxBB