{"id":158,"date":"2021-04-16T11:47:12","date_gmt":"2021-04-16T09:47:12","guid":{"rendered":"https:\/\/whatifsecu.tech\/?p=158"},"modified":"2021-04-16T11:47:12","modified_gmt":"2021-04-16T09:47:12","slug":"fortios-ipsec-pre-shared-key-psk-recovery-logic","status":"publish","type":"post","link":"https:\/\/whatifsecu.tech\/?p=158","title":{"rendered":"FortiOS IPSEC pre-shared key (PSK) recovery logic"},"content":{"rendered":"\n<p>In various scenarios, you may want to recover psk plaintext from encrypted format out of a FortiGate or from a FortiGate config backup.<\/p>\n\n\n\n<p><strong>Method 1:<\/strong><\/p>\n\n\n\n<p>&#8220;Print\nInstructions&#8221; menu through a FortiClient profile, ther are 2 alternatives\nfor recovering PSK:<\/p>\n\n\n\n<p>I don\u2019t\nremember if you need to change existing tunnel or duplicate tunnel or restore a\nfake config \u2026<\/p>\n\n\n\n<p><a href=\"https:\/\/forum.fortinet.com\/tm.aspx?m=137961\">https:\/\/forum.fortinet.com\/tm.aspx?m=137961<\/a><\/p>\n\n\n\n<p><strong>Method 2:<\/strong><\/p>\n\n\n\n<p>1) Log in\ninto the web-interface as a (super?) admin.<\/p>\n\n\n\n<p>2) Change\nyour url\/path to <a href=\"https:\/\/fortigateip\/api\/v2\/cmdb\/vpn.ipsec\/phase1-interface?plain-text-password=1\">https:\/\/fortigateip\/api\/v2\/cmdb\/vpn.ipsec\/phase1-interface?plain-text-password=1<\/a><\/p>\n\n\n\n<p>3) Firefox\nunderstands the JSON reply. I hope your browser does too. Search for the term\n&#8220;psksecret&#8221; on the page. Passwords\/secrets should be listed as plain\ntext passwords now.<\/p>\n\n\n\n<p><strong>Method 3:<\/strong><\/p>\n\n\n\n<p>You can\nalways view the Pre-Shared Key of a WiFi SSID via the GUI. But since\nFortiGate\/FortiOS uses the same algorithm for storing these passwords as for\n(say) phase1 PSK&#8217;s, you can simply:<\/p>\n\n\n\n<p>Create a\ndummy SSID via the GUI.<\/p>\n\n\n\n<p>Change the\npassword from CLI.<\/p>\n\n\n\n<p>config\nwireless-controller vap<\/p>\n\n\n\n<p>edit\n&#8220;dummy-decrypt&#8221;<\/p>\n\n\n\n<p>set\npassphrase ENC some-base64-string-from-phase1-PSK<\/p>\n\n\n\n<p>end<\/p>\n\n\n\n<p>Go back to\nthe GUI.<\/p>\n\n\n\n<p>Edit the\ndummy SSID.<\/p>\n\n\n\n<p>Push the\neye logo to reveal the SSID\/PSK\/whatever password.<\/p>\n\n\n\n<p>I conclude that the encoding method\/key must be somewhat fixed in FortiOS (since a FortiVM can decode passwords as well). <\/p>\n\n\n\n<p>By design, password can&#8217;t be be salted or they will be no way to restore a config file during RMA process from example.<\/p>\n\n\n\n<p>Note: All three methods do not all work on any FortiOS versions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In various scenarios, you may want to recover psk plaintext from encrypted format out of a FortiGate or from a FortiGate config backup. Method 1: &#8220;Print Instructions&#8221; menu through a FortiClient profile, ther are 2 alternatives for recovering PSK: I&hellip; <a href=\"https:\/\/whatifsecu.tech\/?p=158\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-fortinet"],"_links":{"self":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":1,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}