COTAG readers analysis and COTAG tag simulation improvements
published:
Summary
This article describes my analysis of 2 additional COTAG reader models -- their slight variations of activation sequences and how they read out tags, which led me to implement passive mode for proxmark COTAG simulation: load modulation with an fc/2 subcarrier locked to the reader carrier. This mode has several advantages:
- phase-coherent response;
- it can detect a reader field drop mid-frame "transmission" and restart immediately. This matters with some readers that may drop the field early and send a re-activation shortly afterwards, expecting the tag to respond there as well.
ELATEC TWN4 MultiTech
The lf cotag sim implementation I did in Reverse-engineering COTAG and COTAG tag simulation implementation was based on "active tx" (on/off keying with our own field) and it worked pretty well with the ancient COTAG reader (controller 3361). But when I tried it on an ELATEC TWN4 MultiTech, which supports COTAG, it just didn't work.
For a start, the activation sequence was not detected:
- which made me think it must be a bit different;
- so I did some quick Proxmark sniffs, but this was a bit more challenging as this reader is multi-tech: it round-robins from LF to HF, and within each it round-robins over multiple technologies. Within LF it keeps the carrier on at 125 kHz for a while, then switches to 132 kHz for a very short time, then to 134 kHz, then repeats. And a proxmark LF sniff of course captures all of those.
An SDR sniff helps to visualize things:
But I finally got it figured out:
-
The middle signal, at 132 kHz, is the COTAG activation signal.
-
The activation signal sequences are spaced approx. 1.5 s apart; their duration is very short.
-
The 132 kHz COTAG activation signal is followed by a 134 kHz signal for approx. 500 ms, then by a 125 kHz signal which is mostly constant carrier on for approx. 1 s (or maybe 900 ms), then back to the COTAG activation signal at 132 kHz.
-
Within the 132 kHz signal, what the ELATEC reader sends turned out to be:
132 kHz: ON ~86 ms, OFF 20.0 ms, ON 1.50 ms, OFF 1.90 ms, ON 16.9 ms -
Funny, it initially keeps 132 kHz ON for about 86 ms. Maybe that has nothing to do with COTAG, but with some other RFID tech? I don't know, especially because it then goes OFF for 20.0 ms.
-
It then goes on to ON 1.50 ms, OFF 1.90 ms, followed by a pretty long ON period, which clearly looked like something that could be an activation sequence, and it turned out it was.
So: ON(1500), OFF(1900), then field on (the window in which the tag is expected to respond).
And yes, it varies a tiny bit from the currently known activation sequence: ON 800 µs, OFF 2200 µs.
Focusing on that: proxmark sniff of ELATEC 1 COTAG activation sequence:
-
So I tried widening the rise-to-rise window threshold for activation detection in the Proxmark code to include 1500 + 1900 = 3400 µs.
-
It still didn't work. Later it turned out I was now properly detecting the right activation sequence, but the ELATEC reader "was not detecting me", i.e. it did not respond by extending the carrier at 132 kHz.
-
Which made me think of what I had of course suspected before: such a reader might need a phase-coherent response (locked to the reader carrier).
-
After implementing that (load modulation with fc/2 subcarrier generation), the ELATEC reader started to extend the carrier at 132 kHz for a while, but it was dropping the field after 83 half bits and not decoding the simulated tag.
-
Analysing further, it turned out that with no tag in the field, the ELATEC reader sends only one activation:
ON(1500), OFF(1900), ON(16900).- But if a tag is in the field and responds to the activation, the reader drops the field after 83 half bits (41 bits, including the 2 leading 0s), then pauses for 20 ms, then sends another
ON(1500), OFF(1900)activation and expects the tag to respond again. My code was not correctly detecting the field drop (it just blindly kept "transmitting"/modulating all of the 64 data bits) and did not catch the second reader activation.
- But if a tag is in the field and responds to the activation, the reader drops the field after 83 half bits (41 bits, including the 2 leading 0s), then pauses for 20 ms, then sends another
-
Once I had the code properly responding to the field drop and going back to activation sequence detection afterwards, it started working: the ELATEC reader was decoding my Proxmark-simulated tag.
So, summary: the ELATEC reader always drops the field early, almost consistently at 83 half bits ((83 − 4) / 2 = 39 data bits, enough to read the 32 LSB data bits), then does one additional activation sequence, and then reads out all the half bits (whether I send 64 or 128 data bits). My guess is that it double-validates the tag code.
Note: the ELATEC reader always prints (over USB, emulating a keyboard) just the 32 LSB bits in hex.
So, with some COTAG readers (those having separate TX and RX coils) we can actively TX 66 kHz on/off keying and just make sure the timing is correct (make sure we respond right after the activation sequence and send the leading zero bits), but our response does not need to be derived from (synced to) the reader signal.
But I guess ELATEC is not the only COTAG reader that may need a tag response locked to its carrier. It also might not be (and it later turned out it is not) the only one that may drop the field early at the first activation and then require another tag activation shortly afterwards, i.e. require the (simulated) tag to detect and respond to a reader field drop. The version of COTAG tag simulation where we actively TX with our own field of course cannot detect the reader field drop mid our own transmission. Passive mode that generates an fc/2 subcarrier on the other hand can.
- Thus, since this passive mode works with more readers, and the active TX mode may not work with all COTAG readers, I made the former the default in the proxmark
lf cotag sim. I also widened the rise-to-rise threshold window for activation sequence detection, hopefully covering other COTAG readers.
HD500 COTAG reader
Then I had a chance to try my new COTAG passive simulation code with an HD500 COTAG reader.
First of all, I sniffed the activation sequence. My results:
- ON 114 samples == 863 us
- OFF 290 samples == 2197 us
- ON 486 samples == 3681 us
- OFF 292 samples == 2219 us (pause)
then again
- ON(863),
- OFF(2197),
- ON(3681),
- then OFF 2147 samples == 16265 us (longer pause if no response from tag)
So:
ON(850), OFF(2200),
ON(3600), OFF(2200),
ON(850), OFF(2200),
ON(3600),
OFF PAUSE ~16300
This turns out to be very similar to (the same as) the very first activation sequence we had documented in the code (and on the Proxmark forum) ages ago, just with slight variance in timings.
- So it is actually two
ON(X), OFF(Y), ON(Z)in a row, with a short gap in between, and only then a longer reader pause.
Findings:
- The rise-to-rise threshold for activation detection in the code was thus already OK and the activation was detected.
- But in passive simulation mode the reader was not accepting my simulated card and was consistently dropping the field after only 1 half bit sent (i.e. it did not extend the first
ON(3600)).- It turned out the code was responding to the first activation, then detected the field drop, but due to various delays then missed the second activation.
- When I fixed those delays, it started working: the reader accepted my simulated tag. That is, this reader does not listen to the tag after the first activation; it only listens to the tag after the second activation.
- It turned out the code was responding to the first activation, then detected the field drop, but due to various delays then missed the second activation.
Now, to understand and confirm things further, I sniffed a real active COTAG card responding to the HD500 COTAG reader. Results of a sniff with a hand demod:
Data bits of the active COTAG tag used in the test:
00000000000000000000000000000000000000000000000000000000000000101000001001001110000000000000000010000000000001011110001100011000
Thus, the expected reverse order of data bits:
00011000110001111010000000000001000000000000000001110010010000010100000000000000000000000000000000000000000000000000000000000000
We can see:
- A spike of a very short duration: 100 samples = 757 µs (in the picture, between the yellow and purple lines).
- This is the tag responding to the first
ON(850), OFF(2200)activation sequence at the rising edge of the firstON(3600), attempting to send the first 0 sync bit: the first half bit is low for 2900 µs, then it would be high for 2900 µs, but the reader dropped the field approx. 700 µs into the second (high) half bit. Hence the spike of only around 757 µs.
- This is the tag responding to the first
- The reader dropped the field, so the card got reset.
- Then there are 698 samples to the start of the actual first leading 0 sync bit (marked in red in the picture), which is 5290 µs ~
OFF(2200) + ON(850) + OFF(2200): gap + second activation sequence, so the math adds up. - Then the 2 leading 0 bits.
- Then the Manchester-demodulated data bits (in blue): the expected first-to-be-seen data bits.
What we can confirm from the sniff:
- The activation sequence is indeed
ON(X), OFF(Y)(not the wholeON(X), OFF(Y), ON(Z), OFF(Y), ON(X), OFF(Y), ON(Z)), as the tags respond to both activation sequences: a short spike is seen for the first activation sequence as well -- proving the tag tried to respond, but shortly afterwards (~750 µs) the reader dropped the field, so the tag went silent. - After a short pause (2200 µs) the reader repeated the activation sequence
ON(X), OFF(Y)and the tag responded, this time with the reader actually listening: extending the field and not dropping it until it had read 64 data bits from the tag.
So far known COTAG reader activation sequence variants
To summarize, the currently known variants of a COTAG reader's tag activation sequence:
a) 3361 COTAG controller
ON 800 us, OFF 2200 us
ON ~5800 us // the tag is expected to respond in this window
OFF ~16500 us // reader's pause if no tag detected, then repeat
b) HD500 COTAG reader
ON(850), OFF(2200) // 1st activation
ON(3600) // tags can (will) respond, but the reader will not listen
OFF(2200)
ON(850), OFF(2200) // 2nd activation
ON(3600) // tags expected to respond, the reader will listen (extend the field)
OFF PAUSE ~16300
c) ELATEC TWN4 MultiTech
ON(1500), OFF(1900)
ON(Z)
// if a tag responds, the field is dropped early - OFF(20000), and additionally:
ON(1500), OFF(1900)
ON(Z)
So the existing simple and effective rise-to-rise method of activation detection works for all of these variants, but some COTAG readers need the Proxmark's passive simulation mode, where we can detect a field drop and immediately go back into activation sequence detection.
As a result of this analysis I thus implemented passive mode for proxmark COTAG simulation (lf cotag sim) with field drop and activation sequence detection improvements (most but not all text/info from this article duplicates on that pull request)