2
$\begingroup$

I am attempting to reverse engineer a motor with an unknown CRC algorithm. I've used a logic analyzer to find these bytes, and I would like to send my own bytes back to the motor. Unfortunately, I can't find the CRC algorithm used to generate the 4 bytes at the end of the packet, and I'm wondering if some of the bytes are intentionally mixed up as part of the CRC process, or there is some form of encryption. Is there a chance I will be able to decode it?

103 feee001500ffff00000020421000ff7f805ce97f14000004050000000000b02833b2
104 feee011500ffff00000020420000ff7f805ce97f140000040500000000009384f2d2
105 feee021500ffff00000020420000ff7f805ce97f14000004050000000000af2d2dac
106 feee001600070700000020421000ff7f805ce97f14000004060000000000c477131f
107 feee011600070700000020420000ff7f805ce97f14000004060000000000e7dbd27f
108 feee021600070700000020420000ff7f805ce97f14000004060000000000db720d01
109 feee001700070700000020421000ff7f805ce97f140000040700000000002815a31a
110 feee011700070700000020420000ff7f805ce97f140000040700000000000bb9627a
111 feee021700070700000020420000ff7f805ce97f140000040700000000003710bd04
112 feee001800ffff00000020421000ff7f805ce97f14000004000000000000343bc9aa
113 feee011800ffff00000020420000ff7f805ce97f14000004000000000000179708ca
114 feee021800ffff00000020420000ff7f805ce97f140000040000000000002b3ed7b4
115 feee001900070700000020421000ff7f805ce97f1400000401000000000098a1890c
116 feee011900070700000020420000ff7f805ce97f14000004010000000000bb0d486c
117 feee021900070700000020420000ff7f805ce97f1400000401000000000087a49712
118 feee001a00070700000020421000ff7f805ce97f14000004020000000000ac065902
119 feee011a00070700000020420000ff7f805ce97f140000040200000000008faa9862
120 feee021a00070700000020420000ff7f805ce97f14000004020000000000b303471c
121 feee001b00ffff00000020421000ff7f805ce97f14000004030000000000009c19a4
122 feee011b00ffff00000020420000ff7f805ce97f140000040300000000002330d8c4
123 feee021b00ffff00000020420000ff7f805ce97f140000040300000000001f9907ba
124 feee001c00070700000020421000ff7f805ce97f14000004040000000000c448f81f
125 feee011c00070700000020420000ff7f805ce97f14000004040000000000e7e4397f
126 feee021c00070700000020420000ff7f805ce97f14000004040000000000db4de601
127 feee001d00070700000020421000ff7f805ce97f14000004050000000000282a481a
128 feee011d00070700000020420000ff7f805ce97f140000040500000000000b86897a
129 feee021d00070700000020420000ff7f805ce97f14000004050000000000372f5604
130 feee001e00ffff00000020421000ff7f805ce97f140000040600000000005c7568b7
131 feee011e00ffff00000020420000ff7f805ce97f140000040600000000007fd9a9d7
132 feee021e00ffff00000020420000ff7f805ce97f14000004060000000000437076a9
133 feee001f00070700000020421000ff7f805ce97f14000004070000000000f0ef2811
134 feee011f00070700000020420000ff7f805ce97f14000004070000000000d343e971
135 feee021f00070700000020420000ff7f805ce97f14000004070000000000efea360f
136 feee002000070700000020421000ff7f805ce97f140000040000000000007c278a3b
137 feee012000070700000020420000ff7f805ce97f140000040000000000005f8b4b5b
138 feee022000070700000020420000ff7f805ce97f1400000400000000000063229425
139 feee002100ffff00000020421000ff7f805ce97f14000004010000000000d0bdca9d
140 feee012100ffff00000020420000ff7f805ce97f14000004010000000000f3110bfd
141 feee022100ffff00000020420000ff7f805ce97f14000004010000000000cfb8d483
142 feee002200070700000020421000ff7f805ce97f14000004020000000000a4e2ea30
143 feee012200070700000020420000ff7f805ce97f14000004020000000000874e2b50
144 feee022200070700000020420000ff7f805ce97f14000004020000000000bbe7f42e
145 feee002300070700000020421000ff7f805ce97f1400000403000000000048805a35
146 feee012300070700000020420000ff7f805ce97f140000040300000000006b2c9b55
147 feee022300070700000020420000ff7f805ce97f140000040300000000005785442b
148 feee002400ffff00000020421000ff7f805ce97f140000040400000000008c54bb8e
149 feee012400ffff00000020420000ff7f805ce97f14000004040000000000aff87aee
150 feee022400ffff00000020420000ff7f805ce97f140000040400000000009351a590
151 feee002500070700000020421000ff7f805ce97f1400000405000000000020cefb28
152 feee012500070700000020420000ff7f805ce97f1400000405000000000003623a48
153 feee022500070700000020420000ff7f805ce97f140000040500000000003fcbe536
154 feee002600070700000020421000ff7f805ce97f1400000406000000000014692b26
155 feee012600070700000020420000ff7f805ce97f1400000406000000000037c5ea46
156 feee022600070700000020420000ff7f805ce97f140000040600000000000b6c3538
157 feee002700ffff00000020421000ff7f805ce97f14000004070000000000b8f36b80
158 feee012700ffff00000020420000ff7f805ce97f140000040700000000009b5faae0
159 feee022700ffff00000020420000ff7f805ce97f14000004070000000000a7f6759e
160 feee002800070700000020421000ff7f805ce97f14000004000000000000a4dd0130
161 feee012800070700000020420000ff7f805ce97f140000040000000000008771c050
162 feee022800070700000020420000ff7f805ce97f14000004000000000000bbd81f2e
163 feee002900070700000020421000ff7f805ce97f1400000401000000000048bfb135
164 feee012900070700000020420000ff7f805ce97f140000040100000000006b137055
165 feee022900070700000020420000ff7f805ce97f1400000401000000000057baaf2b
166 feee002a00ffff00000020421000ff7f805ce97f140000040200000000003ce09198
167 feee012a00ffff00000020420000ff7f805ce97f140000040200000000001f4c50f8
168 feee022a00ffff00000020420000ff7f805ce97f1400000402000000000023e58f86
169 feee002b00070700000020421000ff7f805ce97f14000004030000000000907ad13e
170 feee012b00070700000020420000ff7f805ce97f14000004030000000000b3d6105e
171 feee022b00070700000020420000ff7f805ce97f140000040300000000008f7fcf20
172 feee002c00070700000020421000ff7f805ce97f140000040400000000001456c026
173 feee012c00070700000020420000ff7f805ce97f1400000404000000000037fa0146
174 feee022c00070700000020420000ff7f805ce97f140000040400000000000b53de38
175 feee002d00ffff00000020421000ff7f805ce97f14000004050000000000b8cc8080
176 feee012d00ffff00000020420000ff7f805ce97f140000040500000000009b6041e0
177 feee022d00ffff00000020420000ff7f805ce97f14000004050000000000a7c99e9e
178 feee002e00070700000020421000ff7f805ce97f14000004060000000000cc93a02d
179 feee012e00070700000020420000ff7f805ce97f14000004060000000000ef3f614d
180 feee022e00070700000020420000ff7f805ce97f14000004060000000000d396be33
181 feee002f00070700000020421000ff7f805ce97f1400000407000000000020f11028
182 feee012f00070700000020420000ff7f805ce97f14000004070000000000035dd148
183 feee022f00070700000020420000ff7f805ce97f140000040700000000003ff40e36
184 feee003000ffff00000020421000ff7f805ce97f140000040000000000008c2a6d8f
185 feee013000ffff00000020420000ff7f805ce97f14000004000000000000af86acef
186 feee023000ffff00000020420000ff7f805ce97f14000004000000000000932f7391
187 feee003100070700000020421000ff7f805ce97f1400000401000000000020b02d29
188 feee013100070700000020420000ff7f805ce97f14000004010000000000031cec49
189 feee023100070700000020420000ff7f805ce97f140000040100000000003fb53337
190 feee003200070700000020421000ff7f805ce97f140000040200000000001417fd27
191 feee013200070700000020420000ff7f805ce97f1400000402000000000037bb3c47
192 feee023200070700000020420000ff7f805ce97f140000040200000000000b12e339
193 feee003300ffff00000020421000ff7f805ce97f14000004030000000000b88dbd81
194 feee013300ffff00000020420000ff7f805ce97f140000040300000000009b217ce1
195 feee023300ffff00000020420000ff7f805ce97f14000004030000000000a788a39f
196 feee003400070700000020421000ff7f805ce97f140000040400000000007c595c3a
197 feee013400070700000020420000ff7f805ce97f140000040400000000005ff59d5a
198 feee023400070700000020420000ff7f805ce97f14000004040000000000635c4224
199 feee003500070700000020421000ff7f805ce97f14000004050000000000903bec3f
200 feee013500070700000020420000ff7f805ce97f14000004050000000000b3972d5f
201 feee023500070700000020420000ff7f805ce97f140000040500000000008f3ef221
202 feee003600ffff00000020421000ff7f805ce97f14000004060000000000e464cc92
203 feee013600ffff00000020420000ff7f805ce97f14000004060000000000c7c80df2
204 feee023600ffff00000020420000ff7f805ce97f14000004060000000000fb61d28c
205 feee003700070700000020421000ff7f805ce97f1400000407000000000048fe8c34
206 feee013700070700000020420000ff7f805ce97f140000040700000000006b524d54
207 feee023700070700000020420000ff7f805ce97f1400000407000000000057fb922a
208 feee003800070700000020421000ff7f805ce97f1400000400000000000014281627
209 feee013800070700000020420000ff7f805ce97f140000040000000000003784d747
210 feee023800070700000020420000ff7f805ce97f140000040000000000000b2d0839
211 feee003900ffff00000020421000ff7f805ce97f14000004010000000000b8b25681
212 feee013900ffff00000020420000ff7f805ce97f140000040100000000009b1e97e1
213 feee023900ffff00000020420000ff7f805ce97f14000004010000000000a7b7489f
214 feee003a00070700000020421000ff7f805ce97f14000004020000000000cced762c
215 feee013a00070700000020420000ff7f805ce97f14000004020000000000ef41b74c
216 feee023a00070700000020420000ff7f805ce97f14000004020000000000d3e86832
217 feee003b00070700000020421000ff7f805ce97f14000004030000000000208fc629
218 feee013b00070700000020420000ff7f805ce97f1400000403000000000003230749
219 feee023b00070700000020420000ff7f805ce97f140000040300000000003f8ad837
220 feee003c00ffff00000020421000ff7f805ce97f14000004040000000000e45b2792
221 feee013c00ffff00000020420000ff7f805ce97f14000004040000000000c7f7e6f2
222 feee023c00ffff00000020420000ff7f805ce97f14000004040000000000fb5e398c
223 feee003d00070700000020421000ff7f805ce97f1400000405000000000048c16734
224 feee013d00070700000020420000ff7f805ce97f140000040500000000006b6da654
225 feee023d00070700000020420000ff7f805ce97f1400000405000000000057c4792a
226 feee003e00070700000020421000ff7f805ce97f140000040600000000007c66b73a
227 feee013e00070700000020420000ff7f805ce97f140000040600000000005fca765a
228 feee023e00070700000020420000ff7f805ce97f140000040600000000006363a924
229 feee003f00ffff00000020421000ff7f805ce97f14000004070000000000d0fcf79c
230 feee013f00ffff00000020420000ff7f805ce97f14000004070000000000f35036fc
231 feee023f00ffff00000020420000ff7f805ce97f14000004070000000000cff9e982
232 feee004000070700000020421000ff7f805ce97f14000004000000000000dc1afa49
233 feee014000070700000020420000ff7f805ce97f14000004000000000000ffb63b29
234 feee024000070700000020420000ff7f805ce97f14000004000000000000c31fe457
235 feee004100070700000020421000ff7f805ce97f1400000401000000000030784a4c
236 feee014100070700000020420000ff7f805ce97f1400000401000000000013d48b2c
237 feee024100070700000020420000ff7f805ce97f140000040100000000002f7d5452
238 feee004200ffff00000020421000ff7f805ce97f1400000402000000000044276ae1
239 feee014200ffff00000020420000ff7f805ce97f14000004020000000000678bab81
240 feee024200ffff00000020420000ff7f805ce97f140000040200000000005b2274ff
241 feee004300070700000020421000ff7f805ce97f14000004030000000000e8bd2a47
242 feee014300070700000020420000ff7f805ce97f14000004030000000000cb11eb27
243 feee024300070700000020420000ff7f805ce97f14000004030000000000f7b83459
244 feee004400070700000020421000ff7f805ce97f140000040400000000006c913b5f
245 feee014400070700000020420000ff7f805ce97f140000040400000000004f3dfa3f
246 feee024400070700000020420000ff7f805ce97f1400000404000000000073942541
247 feee004500ffff00000020421000ff7f805ce97f14000004050000000000c00b7bf9
248 feee014500ffff00000020420000ff7f805ce97f14000004050000000000e3a7ba99
249 feee024500ffff00000020420000ff7f805ce97f14000004050000000000df0e65e7
250 feee004600070700000020421000ff7f805ce97f14000004060000000000b4545b54
251 feee014600070700000020420000ff7f805ce97f1400000406000000000097f89a34
252 feee024600070700000020420000ff7f805ce97f14000004060000000000ab51454a
253 feee004700070700000020421000ff7f805ce97f140000040700000000005836eb51
254 feee014700070700000020420000ff7f805ce97f140000040700000000007b9a2a31

Further packets I recorded today (I can play the packets on the bus as much as I want and the motor will respond):

packets = [
        bytes.fromhex('feee01ba0aff0000000000002300ff7ffd6a00800000e427020000000000ced7fe0f'),
        bytes.fromhex('feee01ba0aff0000000000002100ff7ffd6a00800000e427020000000000736677da'),
        bytes.fromhex('feee01ba0aff0000000000001f00ff7ffd6a00800000e4270200000000007714d424'),
        bytes.fromhex('feee01ba0aff0000000000001d00ff7ffd6a00800000e427020000000000caa55df1'),
        bytes.fromhex('feee01ba0aff0000000000001b00ff7ffd6a00800000e427020000000000ba6a068b'),
        bytes.fromhex('feee01ba0aff0000000000001900ff7ffd6a00800000e42702000000000007db8f5e'),
        bytes.fromhex('feee01ba0aff0000000000001700ff7ffd6a00800000e4270200000000005af4b17f'),
        bytes.fromhex('feee01ba0aff0000000000001500ff7ffd6a00800000e427020000000000e74538aa'),
        bytes.fromhex('feee01ba0aff0000000000001300ff7ffd6a00800000e427020000000000978a63d0'),
        bytes.fromhex('feee01ba0aff0000000000001100ff7ffd6a00800000e4270200000000002a3bea05'),
        bytes.fromhex('feee01ba0aff0000000000000f00ff7ffd6a00800000e4270200000000002dd41f92'),
        bytes.fromhex('feee01ba0aff0000000000000d00ff7ffd6a00800000e42702000000000090659647'),
        bytes.fromhex('feee01ba0aff0000000000000b00ff7ffd6a00800000e427020000000000e0aacd3d'),
        bytes.fromhex('feee01ba0aff0000000000000900ff7ffd6a00800000e4270200000000005d1b44e8'),
        bytes.fromhex('feee01ba0aff0000000000000700ff7ffd6a00800000e42702000000000000347ac9'),
        bytes.fromhex('feee01ba0aff0000000000000500ff7ffd6a00800000e427020000000000bd85f31c'),
        bytes.fromhex('feee01ba0aff0000000000000300ff7ffd6a00800000e427020000000000cd4aa866'),
        bytes.fromhex('feee01ba0aff0000000000000100ff7ffd6a00800000e42702000000000070fb21b3'),
        bytes.fromhex('feee01ba0aff0000000000000000ff7ffd6a00800000e42702000000000075ad855b'),
        bytes.fromhex('feee01ba0aff000000000000feffff7ffd6a00800000e427020000000000309d075c'),
        bytes.fromhex('feee01ba0aff000000000000fcffff7ffd6a00800000e4270200000000008d2c8e89'),
        bytes.fromhex('feee01ba0aff000000000000faffff7ffd6a00800000e427020000000000fde3d5f3'),
        bytes.fromhex('feee01ba0aff000000000000f8ffff7ffd6a00800000e42702000000000040525c26'),
        bytes.fromhex('feee01ba0aff000000000000f6ffff7ffd6a00800000e4270200000000001d7d6207'),
        bytes.fromhex('feee01ba0aff000000000000f4ffff7ffd6a00800000e427020000000000a0ccebd2'),
        bytes.fromhex('feee01ba0aff000000000000f2ffff7ffd6a00800000e427020000000000d003b0a8'),
        bytes.fromhex('feee01ba0aff000000000000f0ffff7ffd6a00800000e4270200000000006db2397d'),
        bytes.fromhex('feee01ba0aff000000000000eeffff7ffd6a00800000e4270200000000006a5dccea'),
        bytes.fromhex('feee01ba0aff000000000000ecffff7ffd6a00800000e427020000000000d7ec453f'),
        bytes.fromhex('feee01ba0aff000000000000eaffff7ffd6a00800000e427020000000000a7231e45'),
        bytes.fromhex('feee01ba0aff000000000000e8ffff7ffd6a00800000e4270200000000001a929790'),
        bytes.fromhex('feee01ba0aff000000000000e5ffff7ffd6a00800000e427020000000000ff5a848c'),
        bytes.fromhex('feee01ba0aff000000000000e3ffff7ffd6a00800000e4270200000000008f95dff6'),
        bytes.fromhex('feee01ba0aff000000000000e1ffff7ffd6a00800000e42702000000000032245623'),
        bytes.fromhex('feee01ba0aff000000000000dfffff7ffd6a00800000e4270200000000003656f5dd'),
        bytes.fromhex('feee01ba0aff000000000000ddffff7ffd6a00800000e4270200000000008be77c08'),
    ]
    
    exit_packets = [
        bytes.fromhex('feee00ba00ff00000000000000000000805ce97f000000000200000000000d209555'),
        bytes.fromhex('feee01ba00ff00000000000000000000805ce97f00000000020000000000744c9f83'),
        bytes.fromhex('feee02ba00ff00000000000000000000805ce97f0000000002000000000048e540fd')
    ]

Additional data of different length (These include the reply packet):

feee020100002400c6202c41000055004d74373b0000000000002a000000082f000000000000ffffffffffffffffffffffff00000000000000000000000000000000000062bf06000000b514b033
feee008c00ff00000000000000000000805ce97f00000000040000000000b5700c71
feee000100002500c93d2a41ffff36007d24b93b000000000000f1ff00003c24000000000000ffffffffffffffffffffffff0000000000000000000000000000000000006210070000009c034579
feee018c00ff00000000000000000000805ce97f00000000040000000000cc1c06a7
feee010100001d00b4282b4100008aff0f5bd0ba000000000000020000008218000000000000ffffffffffffffffffffffff00000000000000000000000000000000000062f60600000020f544f9
feee028c00ff00000000000000000000805ce97f00000000040000000000f0b5d9d9
feee020100002400c6202c410200f5ffa8d9e73a000000000000e9ff0000072f000000000000ffffffffffffffffffffffff00000000000000000000000000000000000062bf060000009e472426
$\endgroup$
3
  • 1
    $\begingroup$ The basic CRC algorithm is very straightforward (cf. this answer of mine on math.SE) but actual implementations have various bells and whistles included. Thus, unless you have the details of these bells and whistles, your reverse-engineering will fail. What you do have in most cases is the actual payload of the message sent available to you in the clear (no encryption) but what the motor does with the commands it has been sent, or what it sends back as an ACK or a response to the message, is something that we have no information about. $\endgroup$ Commented Oct 23 at 18:42
  • $\begingroup$ Cross-posted at stackoverflow, and closed. $\endgroup$
    – fgrieu
    Commented Oct 25 at 10:03
  • $\begingroup$ Also cross-posted on math.SE $\endgroup$ Commented Oct 26 at 0:19

1 Answer 1

4
$\begingroup$

Gaussian elimination on your sample vectors gives

000000000000000000000000010000000000000000000000000000000000 11101000101001000101011000000101
000000000000000000000000020000000000000000000000000000000000 11010101100010011011000110111101
000000000000000000000000040000000000000000000000000000000000 10101111110100100111111011001101
000000000000000000000000080000000000000000000000000000000000 01011011011001011110000000101101
000000000000000000000000100000000000000000000000000000000000 10110110110010111100000001011010
000000000000000000000000200000000000000000000000000000000000 01101001010101101001110100000011
000000000000000000000000c0ff00000000000000000000000000000000 11111001001000010100001001000001
0000000000f8f80000000000000000000000000000000000000000000000 10100011111100001111100001000000
000000000a000000000000000000ff7f7d36e9ff0000e427000000000000 11011000000110101110000100000001
000000010000000000000000000000000000000000000000010000000000 00000101101100000110001011101100
000000020000000000000000000000000000000000000000020000000000 00001011011000001100010111011000
000000040000000000000000000000000000000000000000040000000000 00010110110000011000101110110000
000000080000000000000000000000000000000000000000000000000000 00001011100010111111101011011000
000000100000000000000000000000000000000000000000000000000000 00010111000101111111010110110000
000000200000000000000000000000000000000000000000000000000000 00101110001011111110101101100000
000000400000000000000000000000000000000000000000000000000000 01011100010111111101011011000000
000000800000ff00000020420000ff7f0000000014000004000000000000 01101100110110001111010111011011
000001000000000000000000000000000000000000000000000000000000 11010110000010100110110001111001
000002000000000000000000000000000000000000000000000000000000 10101000110101011100010101000101
feee000000070700000020420000ff7f805ce97f14000004000000000000 10100011011011100000110001000110

where I wrote the last 4 bytes in binary in reverse order. From this you can see that it's a CRC with polynomial 0x104c11db7 and little-endian byte order (e.g., xor the checksums from the first two lines, shifted by 1 bit).

The bytes are fed into the CRC out of order in a strange way. Some further shifting and xoring gives

000000000000000000000000000000000000000000000000010000000000 00000100110000010001110110110111  0
000000000000000000000000010000000000000000000000000000000000 11101000101001000101011000000101 12
000000010000000000000000000000000000000000000000000000000000 00000001011100010111111101011011 27
000001000000000000000000000000000000000000000000000000000000 11010110000010100110110001111001 26

where the decimal values are the values n for which 1 << (32 + 8 * n) is congruent to the CRC, i.e., they're the byte positions, counting from the end, at which the nonzero byte in each line is fed into the CRC.

$\endgroup$
3
  • $\begingroup$ @benrg since I can't comment: Ok, that sounds like progress! I wasn't able to come up with a CRC algorithm based on your response though. I'm a bit lost on where to take it from here. Do we need more information to get the actual CRC algorithm? $\endgroup$ Commented Oct 25 at 6:47
  • $\begingroup$ [converted from deleted comment by moderator] Ok, that sounds like progress! I wasn't able to come up with a CRC algorithm based on your response though. I admit I'm a bit lost on where to take it from here. Do we need more information to find the actual CRC algorithm? $\endgroup$ Commented Oct 25 at 6:51
  • $\begingroup$ I just want to share that your work helped us finally decode the CRC on our robot dogs. Thanks a lot benrg! github.com/aatb-ch/unitree_crc/tree/main/src $\endgroup$ Commented Oct 29 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.