{"id":600,"date":"2021-06-21T21:00:22","date_gmt":"2021-06-21T20:00:22","guid":{"rendered":"https:\/\/www.labtinker.net\/?p=600"},"modified":"2021-06-21T21:00:22","modified_gmt":"2021-06-21T20:00:22","slug":"i-can-see-clearly-now","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=600","title":{"rendered":"I Can See Clearly Now&#8230;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Wireshark is a powerful tool which captures no end of network protocols but 90% of the time you\u2019re probably working with TCP and 90% of that TCP is probably http and 90% of that is probably encased in TLS encryption making it  https. The problem here is that sometimes you need to see what&#8217;s inside those packets. The good news is you can using the method described here: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/support.f5.com\/csp\/article\/K50557518\">https:\/\/support.f5.com\/csp\/article\/K50557518<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, I&#8217;d variously heard this only worked with certain browsers and not at all with APIs and non-browser traffic so I decided to test it for myself. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To this end I am using a simple website I stood up in my lab on http:\/\/test.labtinker.net and also https:\/\/test.labtinker.net showing a picture of two Scandinoir enthusiasts before their trip to Copenhagnen: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"771\" height=\"582\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/The-boy-1.png\" alt=\"\" class=\"wp-image-602\" style=\"width:771px;height:582px\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/The-boy-1.png 771w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/The-boy-1-300x226.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/The-boy-1-768x580.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><figcaption class=\"wp-element-caption\">There is a further element to be aware of which is the fact the decryption won&#8217;t work with key exchange protocols which give perfect secrecy, namely Diffie Helman. That is why in the latter section where the private key is imported into Wireshark &#8211; the option only mentions RSA  keys. If you&#8217;re using Ephemeral Diffie Helman key exchange then you won&#8217;t be able to decrypt. You can tell what key exchange protocol you&#8217;re using by seeing what record is chosen in the TLS Server Hello, so RSA is good (for decryption purposes):<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"28\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image.png\" alt=\"\" class=\"wp-image-678\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image.png 550w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image-300x15.png 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Whereas Diffie Helman Ephermal (DHE) isn&#8217;t:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"30\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image-1.png\" alt=\"\" class=\"wp-image-680\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image-1.png 612w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/10\/image-1-300x15.png 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;but really for security reasons you want DHE over RSA as perfect secrecy is very desirable because er&#8230; people can&#8217;t decrypt historic captures &#8211; like we&#8217;re trying to do here.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I neglected to check what cipher suite the various browsers  in this lab had negotiated which would have been pertinent and useful to the post but this paragraph was added with the benefit of hindsight. Now on with the lab&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When we browse to above website using http, because nothing is encrypted we are able to see this image file from the packets we\u2019ve caught in Wireshark using File\/Export Objects\/HTTP<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"385\" height=\"117\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image.png\" alt=\"\" class=\"wp-image-603\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image.png 385w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-300x91.png 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The image file is called &#8216;boys.png&#8217; and is visible for download:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"498\" height=\"172\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-1.png\" alt=\"\" class=\"wp-image-604\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-1.png 498w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-1-300x104.png 300w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So to test the decryption method descripted in the link  above I&#8217;ll browse to the https version of the website and capture the output in Wireshark and see if the image is available. (Doing this without decryption there are no http objects that can be exported because they are all encrypted)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Essentially, the method in the link above involves defining a system variable which will capture pre-master secrets in a file and then pointing Wireshark at this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"144\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-2.png\" alt=\"\" class=\"wp-image-605\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-2.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-2-300x72.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When this is working you should see the file being filled up with Pre-Secrets<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"111\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-3.png\" alt=\"\" class=\"wp-image-606\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-3.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-3-300x55.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On Windows 10, this was one of those rare occasions when everything worked as expected and I could both see and export the image file from the Wireshark trace when browsing over https  uisng  Chrome, Mozilla and Edge (after making sure all caches were empty and the trace was restarted.). So far, so good&#8230; so what about a non-browser connection&#8230;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I used the Powershell Invoke-WebRequest command below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"294\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-5.png\" alt=\"\" class=\"wp-image-610\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-5.png 829w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-5-300x106.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-5-768x272.png 768w\" sizes=\"auto, (max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I tried a &#8216;http&#8217; request as a baseline and was able to see the &#8216;png&#8217; file. However, when I tried with &#8216;https&#8217; I was unable to see it which supports the theory that this method can only be used with browsers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is another method available: if you have the webserver&#8217;s private certificate (which I did) you can input it within Wireshark&#8217;s Protocol Preferences under &#8216;RSA keys list&#8217;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"611\" height=\"441\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-7.png\" alt=\"\" class=\"wp-image-612\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-7.png 611w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-7-300x217.png 300w\" sizes=\"auto, (max-width: 611px) 100vw, 611px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;you can add the RSA file. I specified the ip address the website was on, the port (443) and the protocol (http). <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"134\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-8.png\" alt=\"\" class=\"wp-image-613\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-8.png 577w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-8-300x70.png 300w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I tried this with a both a pfx and a pem file to no effect. There are apparently some limitations on this method, (TLS1.3 doesn&#8217;t work I seem to remember reading nor do certain ciphers) but I couldn&#8217;t find a great deal of information on this.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Linux<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On Linux (Mint 21), I used Chrome and Firefox.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I firstly confirmed I could download the image file when using http.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As described in the method above I exported the SSLKEYLOGFILE whose location I pointed Wireshark at within TLS protocols and opened the browser from the same terminal window:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"135\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-9.png\" alt=\"\" class=\"wp-image-617\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-9.png 661w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-9-300x61.png 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I also started Wireshark from this same terminal window&#8230; <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"48\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-10.png\" alt=\"\" class=\"wp-image-618\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-10.png 667w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-10-300x22.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">this seemed to be necessary&#8230;. forgive the lack of clarity but with Linux I struggled to pin down consistent behaviour. Certainly, when I did the above with Chrome I saw the following in the http display within Wireshark&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"99\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-11-1024x99.png\" alt=\"\" class=\"wp-image-619\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-11-1024x99.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-11-300x29.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-11-768x74.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-11.png 1189w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So decryption was happening but within http objects I did not see the image file&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"756\" height=\"131\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-12.png\" alt=\"\" class=\"wp-image-620\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-12.png 756w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-12-300x52.png 300w\" sizes=\"auto, (max-width: 756px) 100vw, 756px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">However, the text file confirmed decryption was happening (to some extent) as it contained the text below the picture&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"149\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-13-1024x149.png\" alt=\"\" class=\"wp-image-621\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-13-1024x149.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-13-300x44.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-13-768x112.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-13.png 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;and to be honest you&#8217;re probably going to be more interested in text than pictures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Firefox was less predictable and I although I was sure I had previoulsy had some success with https decryption I couldn&#8217;t reproduce it using the method described above when I re-tried<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To try a non browser access method I used curl:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"185\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-14.png\" alt=\"\" class=\"wp-image-623\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-14.png 656w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/06\/image-14-300x85.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">and the above method didn&#8217;t work for this nor did the the &#8216;private key&#8217; method which had failed on Windows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wireshark is a powerful tool which captures no end of network protocols but 90% of the time you\u2019re probably working with TCP and 90% of that TCP is probably http and 90% of that is probably encased in TLS encryption making it https. The problem here is that sometimes you need to see what&#8217;s inside [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[],"class_list":["post-600","post","type-post","status-publish","format-standard","hentry","category-encryption","category-networking"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/600","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=600"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=600"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}