{"id":127,"date":"2020-06-05T21:39:59","date_gmt":"2020-06-05T20:39:59","guid":{"rendered":"http:\/\/www.labtinker.net\/?p=127"},"modified":"2020-06-05T21:39:59","modified_gmt":"2020-06-05T20:39:59","slug":"fortigate-and-non-std-ssh","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=127","title":{"rendered":"Fortigate and non-std SSH"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In the previous post we saw how a Palo Alto fared in blocking applications running on non-standard ports and in this one we&#8217;re going to try the same exercise with a Fortigate firewall.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once again, I don&#8217;t have a physical Fortigate firewall to hand so used one in the AWS Marketplace:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"102\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image.png\" alt=\"\" class=\"wp-image-128\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image-300x51.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 1: AWS Marketplace&#8217;s Fortigate firewall<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On the following firmware version:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"341\" height=\"232\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-version.png\" alt=\"\" class=\"wp-image-130\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-version.png 341w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-version-300x204.png 300w\" sizes=\"auto, (max-width: 341px) 100vw, 341px\" \/><figcaption>Figure 2: OS version<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I used the same topology as I did with the Palo Alto; namely:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Fortigate-Lab.png\" alt=\"\" class=\"wp-image-129\" width=\"630\" height=\"472\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Fortigate-Lab.png 686w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Fortigate-Lab-300x225.png 300w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><figcaption>Figure 2: Our topology<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I also followed the same apporoach as with the Palo Alto in that I did the minimum to set up the firewall to allow the Windows host to browse out to the Internet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The interfaces were set up like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"288\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Interfaces-1-1024x288.png\" alt=\"\" class=\"wp-image-132\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Interfaces-1-1024x288.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Interfaces-1-300x84.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Interfaces-1-768x216.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Interfaces-1.png 1058w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Figure 3: Interface addresses<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I set up a rule to allow the source, Windows_DMZ on 172.31.200.10, access to any (or all) destinations for http, https and dns only. I configured &#8216;hide&#8217; NAT behind the outgoing interface. On a Fortigate this is all done on the same rule which looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"541\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Rule-Take-One.png\" alt=\"\" class=\"wp-image-133\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Rule-Take-One.png 686w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-Rule-Take-One-300x237.png 300w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><figcaption>Figure 4: Fortigate Rule to allow the Windows host to browse out to the Internet.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And having done this I was able to browse out happily to the Internet as these firewall logs show:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"113\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-browsing-log-2.png\" alt=\"\" class=\"wp-image-136\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-browsing-log-2.png 493w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Forti-browsing-log-2-300x69.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><figcaption>Figure 5: The Windows host browses the Internet<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And so once again using the elementary yet fiendish plan of setting up a linux host (linux.labtinker.net) to run ssh on port 80 and then trying to connect to through the above rule which is set up to only allow http,https and dns.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"282\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Putty-out-to-Linux.png\" alt=\"\" class=\"wp-image-138\"\/><figcaption>Figure 6: Running up putty on the Windows box to linux.labtinker.net on port 80<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And&#8230; it allowed me through the firewall. Below shows the Windows host (confusingly called fwext.labtinker.net because I&#8217;m RDP-ing through the external firewall interface on a static nat) ssh-ing successfully to our linux.labtinker.net.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"360\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Windows-SSH-to-Linux-through-Forti.png\" alt=\"\" class=\"wp-image-139\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Windows-SSH-to-Linux-through-Forti.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Windows-SSH-to-Linux-through-Forti-300x179.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 7: Successful conection<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And the log confirms this&#8230;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"69\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Log-through-Forti-of-ssh-on-port-80-1.png\" alt=\"\" class=\"wp-image-160\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Log-through-Forti-of-ssh-on-port-80-1.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Log-through-Forti-of-ssh-on-port-80-1-300x34.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 8: Log showing ssh through Fortigate on port 80<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">OK, so we don&#8217;t get applications running on non-standard ports blocked by default as we more or less did on the Palo. So let&#8217;s delve a little deeper. Each rule on the Forti gives us many more options such as: AntiVirus, Web Filter and Application Control&#8230;. and that last one sounds promising for what we&#8217;re trying to achieve&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"153\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control.png\" alt=\"\" class=\"wp-image-142\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control.png 493w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control-300x93.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><figcaption>Figure 9: Some more buttons!<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So let&#8217;s turn on application control:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"113\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control-enabled.png\" alt=\"\" class=\"wp-image-143\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control-enabled.png 493w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control-enabled-300x69.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><figcaption>Figure 10: Turn on app control.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now some firealls can be set to enforce rule changes for new sessions rather than run existing sessions through the rule base again so for good measure I am doing the following from the firewall&#8217;s CLI after each policy change to ensure my session starts afresh with the new rulebase:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>diagnose sys session clear<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As this killed my RDP session to the Windows box ,also going through the firewall as previously stated, I had some confidence the above command cleared existing sessions. (I think this is probably overkill but it&#8217;s easy enough to do in a lab environment)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the application control turned on I was still able to ssh out to my Linux box on port 80 but the firewall at least now recognised I&#8217;m running SSH as seen by the application column  in the logs:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/firewall-log-seeing-ssh-on-port-80.png\" alt=\"\" class=\"wp-image-144\" width=\"602\" height=\"113\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/firewall-log-seeing-ssh-on-port-80.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/firewall-log-seeing-ssh-on-port-80-300x56.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 11: That looks like ssh on port 80 &#8211; come right through.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The application profile is designed to let you allow (or more probably block) traffic based on its application category as we can see if we delve into the default Application Control profile under the Security Profiles menu:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"154\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/app-control-menu.png\" alt=\"\" class=\"wp-image-145\"\/><figcaption>Figure 12: Application control menu<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The default settting for all profiles is monitor (the eye!) but you could block any applications as well as by altering the drop down box setting:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Appliation-Profile-1.png\" alt=\"\" class=\"wp-image-161\" width=\"630\" height=\"296\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Appliation-Profile-1.png 939w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Appliation-Profile-1-300x141.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Appliation-Profile-1-768x362.png 768w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><figcaption>Figure 13: Applicaton profile page<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OK, interesting but not probably not we want at the moment. But lo, just below this, look at this button&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"517\" height=\"155\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/network-protocol-enforcement.png\" alt=\"\" class=\"wp-image-147\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/network-protocol-enforcement.png 517w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/network-protocol-enforcement-300x90.png 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><figcaption>Figure 14: Looks promising&#8230;<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So, like all good engineers let&#8217;s turn it on and see what happens.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And, dear reader, still I sailed through the firewall with ssh on port  80. I have actually missed the allow\/deny column from the next log insert so you&#8217;re going to have to take this one on trust:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"68\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Another-forti-log-1.png\" alt=\"\" class=\"wp-image-162\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Another-forti-log-1.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Another-forti-log-1-300x34.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 15: Another Forti Log<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Is it time to RTFM? (here if you&#8217;re interested&#8230;) <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.fortinet.com\/document\/fortigate\/6.4.0\/administration-guide\/410638\/protocol-enforcement\">https:\/\/docs.fortinet.com\/document\/fortigate\/6.4.0\/administration-guide\/410638\/protocol-enforcement<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course not, we just have to go a little further down the applicaton control page and&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"81\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Block-apps-on-non-std-ports-1.png\" alt=\"\" class=\"wp-image-163\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Block-apps-on-non-std-ports-1.png 469w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/Block-apps-on-non-std-ports-1-300x52.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><figcaption>Figure 16: This has got to be it!<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Our troubles are over, I thought as I enabled this. However, they weren&#8217;t . This didn&#8217;t work.  Eventually,  I admitted defeat and RTFM&#8217;d. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OK, how does this look? Defining a port, what protocol to allow on it and what to do if there&#8217;s a violation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"230\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/for-non-std-app-paydirt.png\" alt=\"\" class=\"wp-image-150\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/for-non-std-app-paydirt.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/for-non-std-app-paydirt-300x115.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 17: Or maybe this.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, this did the trick and the log in Figure 18 shows this traffic being blocked. Interestingly, the logs stopped identifying the traffic as SSH &#8211; I guess all the Forti needed to know was that it wasn&#8217;t http and thus not coming through.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"49\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image-3.png\" alt=\"\" class=\"wp-image-151\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image-3.png 601w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/06\/image-3-300x24.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><figcaption>Figure 18: Not http on port 80 &#8211; not so fast, sunshine.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So to summarise, we had to enable application control, and on the application control profile we enabled &#8216;Block applicatons on non-standard ports&#8217; and then told the Forti what the standard apps on those ports were.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my opinion the Fortigate is a very capable Next Gen firewall with lots of great features but for the very specific use case of blocking applications running on non-standard ports it&#8217;s easier to do on the Palo Alto where it&#8217;s almost harder not to do than to do. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous post we saw how a Palo Alto fared in blocking applications running on non-standard ports and in this one we&#8217;re going to try the same exercise with a Fortigate firewall. Once again, I don&#8217;t have a physical Fortigate firewall to hand so used one in the AWS Marketplace: On the following firmware [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-firewalls"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}