{"id":4203,"date":"2021-10-19T16:04:55","date_gmt":"2021-10-19T21:04:55","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4203"},"modified":"2021-12-01T16:16:20","modified_gmt":"2021-12-01T22:16:20","slug":"decrypting-cambium-router-config-passwords","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/decrypting-cambium-router-config-passwords\/","title":{"rendered":"Decrypting Cambium router config passwords"},"content":{"rendered":"\n<p>In the cambium cloud you can retrieve a config from a router, modify it and reapply it or make a template from it.  All the passwords are &#8220;encrypted&#8221; so you can&#8217;t read what the WiFi password is for example.<\/p>\n\n\n\n<p>Example config line looks like<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">WPAPSK1=[c760ba8ffe65c669]<\/pre>\n\n\n\n<p>Looks like it uses some sort of des3 hex encryption.<\/p>\n\n\n\n<p>Fortunately there is a utility on the routers we can use to decrypt the encrypted string.<\/p>\n\n\n\n<p>First we need a router that we can SSH into.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Info on the encryption<\/h2>\n\n\n\n<p>The Cambium router uses the 3des_hex utility to decrypt and encrypt strings<\/p>\n\n\n\n<p>It is located \/sbin\/3des_hex<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Decrypting a password<\/h2>\n\n\n\n<p>Decrypting is super easy.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">3des_hex -d \"c760ba8ffe65c669\"<\/pre>\n\n\n\n<p>Replace the key with the key you want to decrypt.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Encrypting a password<\/h2>\n\n\n\n<p>Not really sure if this would ever be needed, but you can use the -e option to encrypt a string<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">3des_hex -e \"12345678\"<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>More info.<\/p>\n\n\n\n<p>It looks like it needs the lib file &#8220;\/lib\/libuClibc-0.9.33.2.so&#8221;<\/p>\n\n\n\n<p>\/sbin\/3des_hex is where the main file is stored though.<\/p>\n\n\n\n<p>The config_manager.sh script in \/sbin has the functions that encrypt and decrypt the config lines.<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">TMP_FILE=\"\/tmp\/tmp_cfg\"\nTMP_FILE2=\"\/tmp\/tmp_cfg2\"\nTMP_FILE_DECRYPT=\"\/tmp\/tmp_cfg_decrypt\"\nTMP_MFK_FILE=\"\/tmp\/multi_function_key.cfg\"\ndecrypt_key=\"asdfghjkl\";\nSNMP_DECRYPT_FILE=\"\/etc\/cambium\/cambium_default.decrypt\"\nDotFactoryFile=\"\/etc_ro\/DoNotFactory.name\"\n\n# when security encrypt enable , decrypt.\nhandle_file_dec()\n{\n        local enc_enable=`dev_manage_stat_get has_config_enc`\n        if [ \"$enc_enable\" != \"1\" ]; then\n                return 0\n        fi\n        SecParamListFile=\"\/etc_ro\/ConfigFileSecParam\"\n        [ -x \"\/sbin\/3des_hex\" ] || return 0\n        [ -f $SecParamListFile ] || return 0\n        [ -z \"$1\" ] &amp;&amp; return 1\n        awk -F '=' 'ARGIND==1{pname[$0]}ARGIND&gt;1&amp;&amp;($1 in pname){print $0}' $SecParamListFile $1 &gt; $1.tmp\n        awk '{if($0~\/.+\\=\\[.*\\]\/){sub(\"\\=\",\"\\|\");print $0;}else{print $0}}' $1.tmp &gt; $1.tmp1\n        rm -f $1.tmp\n        awk -F'|' '{if($2~\/\\[.*\\]\/){len=length($2);value=substr($2,2,len-2);while((\"3des_hex -d \\\"\"value\"\\\"\"|getline line)&gt;0){printf(\"%s=%s\\n\",$1,line);}close(\"3des_hex -d \\\"\"value\"\\\"\");}else{print $0}}' $1.tmp1 &gt; $1.tmp2\n        rm -f $1.tmp1\n        echo \"\" &gt;&gt; $1\n        cat $1.tmp2 &gt;&gt; $1\n        rm -f $1.tmp2\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the cambium cloud you can retrieve a config from a router, modify it and reapply it or make a template from it. All the passwords are &#8220;encrypted&#8221; so you can&#8217;t read what the WiFi password is for example. Example &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/decrypting-cambium-router-config-passwords\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[637,1266],"tags":[1253,628,795,876],"class_list":["post-4203","post","type-post","status-publish","format-standard","hentry","category-cambium","category-cnpilot","tag-3des_hex","tag-cambium","tag-decrypt","tag-router"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4203"}],"version-history":[{"count":2,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4203\/revisions"}],"predecessor-version":[{"id":4288,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4203\/revisions\/4288"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}