{"id":260,"date":"2024-03-15T20:11:25","date_gmt":"2024-03-15T20:11:25","guid":{"rendered":"https:\/\/www.hooskworks.com\/blog\/?p=260"},"modified":"2024-03-15T21:02:36","modified_gmt":"2024-03-15T21:02:36","slug":"reverse-engineering-the-texecom-rkp-protocol-part-3","status":"publish","type":"post","link":"https:\/\/www.hooskworks.com\/blog\/2024\/03\/reverse-engineering-the-texecom-rkp-protocol-part-3\/","title":{"rendered":"Reverse Engineering the Texecom RKP Protocol (Part 3)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Recapping from last time; with the Pi Pico flashed with the picoprobe SWD probe firmware all that&#8217;s needed is to power everything up and run the following to connect to the target.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>openocd -f interface\/picoprobe.cfg -f target\/ke0x.cfg -s tcl<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That should get you some output which looks a lot like the following<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_swd.png\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"352\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_swd.png\" alt=\"\" class=\"wp-image-284\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_swd.png 612w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_swd-300x173.png 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When you successfully connect with telenet and issue the following command to openOCD to halt the CPU core and hold it in reset.<\/p>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"wp-block-paragraph\"><code>reset init<\/code><\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Dumping the Firmware<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Over in the telenet window which is connected to openOCD it time to see what flash is discoverable and try and read it out with the following.<\/p>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"wp-block-paragraph\"><code>flash banks<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>flash probe 0<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>flash read_bank 0 output.bin<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can skip right to the last command to try and read the firmware out but I was exploring when I first connected and ran the other two to see if the flash layout was what I expected from information in the datasheet of the microcontroller.<\/p>\n<\/div>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/fw_read.png\"><img loading=\"lazy\" decoding=\"async\" width=\"854\" height=\"347\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/fw_read.png\" alt=\"\" class=\"wp-image-263\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/fw_read.png 854w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/fw_read-300x122.png 300w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/fw_read-768x312.png 768w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/a><figcaption class=\"wp-element-caption\">openOCD telnet session output after firmware read out completes<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">If all goes well then you should see output like in the above image from the telnet window and back over in the terminal where openOCD is running something along the lines of the following will be visible.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_flash.png\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"436\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_flash.png\" alt=\"\" class=\"wp-image-285\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_flash.png 608w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/openocd_flash-300x215.png 300w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/a><figcaption class=\"wp-element-caption\">openOCD terminal window during the flash reading process<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">While everything is hooked up and appears to be working it&#8217;s a good plan to do several reads of the flash so they can be compared. If they all match then there&#8217;s a good chance you&#8217;ve read it out correctly, gotten a good dump, and there aren&#8217;t any odd protection mechanisms in play.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my case I read out 3 binaries from the microcontroller and got the same 64 kB binary file 3 times which, given the microcontroller being used on has 64 kB of memory in a single bank, suggests they&#8217;re all good or all corrupted. For now, I&#8217;ll assume they&#8217;re all good and carry on!<\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/rkp_fw_hex.png\"><img loading=\"lazy\" decoding=\"async\" width=\"673\" height=\"532\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/rkp_fw_hex.png\" alt=\"\" class=\"wp-image-264\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/rkp_fw_hex.png 673w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2022\/09\/rkp_fw_hex-300x237.png 300w\" sizes=\"auto, (max-width: 673px) 100vw, 673px\" \/><\/a><figcaption class=\"wp-element-caption\">Hex view of the firmware binary reveals some sensible looking strings<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">A good first to poking at simple firmware packages like you&#8217;ll get on this kind of product and for this kind of microcontroller is to run strings against it or, as shown above, open it in a hex editor and see what you can see.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With things like, &#8220;KEYPAD LOCKED!&#8221; hiding in there I think we&#8217;re on to a winner and we know one more thing too. This is the same firmware as runs on the more expensive remote keypads which have screen on them.<\/p>\n\n\n\n<div class=\"wp-block-group is-content-justification-center is-nowrap is-layout-flex wp-container-core-group-is-layout-d05cb3ef wp-block-group-is-layout-flex\">\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/basic-rkp.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"1000\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/basic-rkp.jpg\" alt=\"\" class=\"wp-image-286\" style=\"width:276px;height:auto\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/basic-rkp.jpg 700w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/basic-rkp-210x300.jpg 210w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/lcd-rkp.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/lcd-rkp.jpg\" alt=\"\" class=\"wp-image-287\" style=\"width:392px;height:auto\" srcset=\"https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/lcd-rkp.jpg 600w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/lcd-rkp-300x300.jpg 300w, https:\/\/www.hooskworks.com\/blog\/wp-content\/uploads\/2024\/03\/lcd-rkp-150x150.jpg 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Above are the Texecom remote keypads which are probably the most applicable to this firmware. The one on the left is the one we have, the DCA-0001, and the one on the left is the keypad I believe the firmware also runs on, the DCB-0001.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This doesn&#8217;t impact anything for the time being but it&#8217;s all useful intel for things we may see later on in the disassembly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Up Next<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Disassembly of the binary we got and the Ghidra fun begins in Part 4!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the hardware ready it&#8217;s time to dump the firmware and see if it looks complete.<\/p>\n","protected":false},"author":1,"featured_media":290,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,29],"tags":[43,41,42,38,39,37,40,36],"class_list":["post-260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","category-electronics","tag-openocd","tag-pi-pico","tag-picoprobe","tag-protocol","tag-reverse-engineering","tag-rkp","tag-swd","tag-texecom","col-2"],"_links":{"self":[{"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/posts\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":5,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions\/303"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/media\/290"}],"wp:attachment":[{"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hooskworks.com\/blog\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}