{"id":965,"date":"2021-09-16T08:58:49","date_gmt":"2021-09-16T13:58:49","guid":{"rendered":"https:\/\/www.brunerd.com\/blog\/?p=965"},"modified":"2021-09-16T09:08:35","modified_gmt":"2021-09-16T14:08:35","slug":"decoding-macos-automatic-login-details","status":"publish","type":"post","link":"https:\/\/www.brunerd.com\/blog\/2021\/09\/16\/decoding-macos-automatic-login-details\/","title":{"rendered":"Decoding macOS automatic login details"},"content":{"rendered":"\n<p>In my previous post, <a rel=\"noreferrer noopener\" href=\"https:\/\/www.brunerd.com\/blog\/2021\/08\/24\/automating-automatic-login-for-macos\/\" data-type=\"URL\" data-id=\"https:\/\/www.brunerd.com\/blog\/2021\/08\/24\/automating-automatic-login-for-macos\/\" target=\"_blank\">Automating automatic login<\/a>, we looked at how to create the <code>\/etc\/kcpassword<\/code> file used for automatic login by using only shell script and built-in command line tools. Why shell only? In preparation for the great <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.apple.com\/documentation\/macos-release-notes\/macos-catalina-10_15-release-notes\" data-type=\"URL\" data-id=\"https:\/\/developer.apple.com\/documentation\/macos-release-notes\/macos-catalina-10_15-release-notes\" target=\"_blank\">scripting runtime deprecation<\/a> yet to come, I say! Now it&#8217;s time to do the reverse for auto login. Let&#8217;s get those details back out! Who would need to do such a thing? Imagine a scenario where you the hapless Mac admin have inherited a bunch of Zoom Room Mac minis with auto-login enabled yet no one has documented the passwords used for them! If they are enrolled in Jamf there&#8217;s no need to guess what annoying <code>l33t sp3@k<\/code> password was used, let&#8217;s leverage our XOR&#8217;ing skills and knowledge of how kcpassword works to send those details back to Jamf.<\/p>\n\n\n\n<p>To get the password back out of <code>\/etc\/kcpassword<\/code> we XOR the password <em>again<\/em> with the <em>same<\/em> cipher used to obfuscate it originally however but instead of padding it in multiples of 12, we will <strong>stop<\/strong> when a character is the same as the current cipher character. FYI when you XOR a value with itself the result is <code>00<\/code> but that&#8217;s an unnecessary operation, we can just compare the characters. Voil\u00e1, that&#8217;s it.<\/p>\n\n\n\n<p>Here&#8217;s the gist of the <a href=\"https:\/\/gist.github.com\/brunerd\/a96265078e33a1e281f3528d1308adb9\" data-type=\"URL\" data-id=\"https:\/\/gist.github.com\/brunerd\/a96265078e33a1e281f3528d1308adb9\" target=\"_blank\" rel=\"noreferrer noopener\">kcpasswordDecode<\/a> routine:<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/brunerd\/a96265078e33a1e281f3528d1308adb9.js\"><\/script><\/p>\n\n\n\n<p>Now for something a bit more useful to those with Jamf or other management tools: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" data-type=\"URL\" data-id=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" target=\"_blank\">getAutoLogin<\/a>. It reports the auto login username, if set, and the decodes the <code>\/etc\/kcpassword<\/code> file, if present. Note that <em>until<\/em> macOS 12 Monterey <code>\/etc\/kcpassword<\/code> was <em>not<\/em> removed when Automatic Login was turned off in System Preferences! Here&#8217;s what <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" data-type=\"URL\" data-id=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" target=\"_blank\">getAutoLogin<\/a> looks in the Jamf policy logs:<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Get-Auto-Login-Details-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"440\" height=\"354\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Get-Auto-Login-Details-1.png\" alt=\"\" class=\"wp-image-970\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Get-Auto-Login-Details-1.png 440w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Get-Auto-Login-Details-1-300x241.png 300w\" sizes=\"auto, (max-width: 440px) 100vw, 440px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Plaintext passwords in your logs are probably not the best, but hey, how else you gonna figure out your dang Zoom Room passwords? After retrieving the credentials and storing somewhere more secure, like a password manager, make sure to Flush the policy logs! Thanks for reading, I hope this comes in handy or at the very least was informative and mildly entertaining. \ud83e\udd13 <\/p>\n\n\n\n<p>Gist: <a href=\"https:\/\/gist.github.com\/brunerd\/a96265078e33a1e281f3528d1308adb9\" data-type=\"URL\" data-id=\"https:\/\/gist.github.com\/brunerd\/a96265078e33a1e281f3528d1308adb9\" target=\"_blank\" rel=\"noreferrer noopener\">kcpasswordDecode<\/a><br>Github: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" data-type=\"URL\" data-id=\"https:\/\/github.com\/brunerd\/macAdminTools\/blob\/main\/Jamf\/scripts\/getAutoLogin.sh\" target=\"_blank\">getAutoLogin<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post, Automating automatic login, we looked at how to create the \/etc\/kcpassword file used for automatic login by using only shell script and built-in command line tools. Why shell only? In preparation for the great scripting runtime deprecation yet to come, I say! Now it&#8217;s time to do the reverse for auto [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,12],"tags":[27,20,47,25,33,22,24],"class_list":["post-965","post","type-post","status-publish","format-standard","hentry","category-bash","category-scripting","tag-apple","tag-bash","tag-jamf","tag-macos","tag-os-x","tag-scripting","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/comments?post=965"}],"version-history":[{"count":6,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions"}],"predecessor-version":[{"id":974,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions\/974"}],"wp:attachment":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/media?parent=965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/categories?post=965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/tags?post=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}