{"id":960,"date":"2022-06-11T12:45:20","date_gmt":"2022-06-11T11:45:20","guid":{"rendered":"https:\/\/www.labtinker.net\/?p=960"},"modified":"2022-06-11T12:45:20","modified_gmt":"2022-06-11T11:45:20","slug":"call-the-dns-doctor","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=960","title":{"rendered":"Call the DNS Doctor"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I never really knew DNS doctoring was much of a thing until I encountered it: essentially getting your firewall to alter or doctor DNS responses. One use case for this might be that you can have your internal hosts receive an internal DNS address whilst keeping them pointing to an external ISP&#8217;s DNS. I could go on but somebody already has:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.cisco.com\/c\/en\/us\/support\/docs\/security\/asa-5500-x-series-next-generation-firewalls\/115753-dns-doctoring-asa-config.html\">https:\/\/www.cisco.com\/c\/en\/us\/support\/docs\/security\/asa-5500-x-series-next-generation-firewalls\/115753-dns-doctoring-asa-config.html<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I thought I would have a tinker. This is my set up in GNS3. A Linux host connecting to the Internet through an ASA which will be doing the doctoring&#8230;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image.png\" alt=\"\" class=\"wp-image-961\" width=\"833\" height=\"167\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image.png 833w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-300x60.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-768x154.png 768w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The ASA has the following interfaces:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"152\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-1.png\" alt=\"\" class=\"wp-image-962\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-1.png 954w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-1-300x48.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-1-768x122.png 768w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The linux host (MintWeb2-1) in on the inside interface of the ASA, the Internet is on the outside interface and the following NAT statements are in place:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>nat (inside,outside) source dynamic any interface<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>nat (inside,outside) source static Loopback_127.0.0.1 Labtinker_3.8.120.91 dns<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(You can&#8217;t use addresses in the nat statement but have to use objects &#8211; thus I defined two host objects and named them with the addresses &#8211; to make it clear what&#8217;s going on)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"359\" height=\"88\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-18.png\" alt=\"\" class=\"wp-image-981\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-18.png 359w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-18-300x74.png 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This looks like this on the ASA&#8217;s ASDM GUI:<\/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\/2022\/06\/image-5-1024x109.png\" alt=\"\" class=\"wp-image-967\" width=\"802\" height=\"85\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-5-1024x109.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-5-300x32.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-5-768x82.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-5.png 1265w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The first NAT statement is to PAT traffic to the Internet but the next one does the clever stuff. Essentially, it will alter any DNS responses containing the address 3.8.120.91 and replace said address with 127.0.0.1. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Linux host is set up to get its DNS from the Internet DNS server(s) on 8.8.8.8 and so when it browses to <em>18.135.13.153\/<\/em>, the Internet DNS will respond with an address of 3.8.120.91 but the ASA will intercept this response and change it to 127.0.01 (the host&#8217;s loopback address). <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It should be noted, as mentioned in the explanatory link abov, that you need dns inspection defined on your ASA for this to work (it should be set up by default)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"106\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-6.png\" alt=\"\" class=\"wp-image-969\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-6.png 397w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-6-300x80.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And well, dear reader, it works&#8230; From the Linux host I browsed out to <em>18.135.13.153\/<\/em>  which and was re-directed to the webserver on the host&#8217;s own loopback address: (127.0.0.1).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"159\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-7.png\" alt=\"\" class=\"wp-image-970\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-7.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-7-300x79.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To see the DNS doctoring working on the ASA I did the following: Set up a capture to 8.8.8.8<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"183\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-9.png\" alt=\"\" class=\"wp-image-972\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-9.png 649w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-9-300x85.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Cleared the DNS cache:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"432\" height=\"48\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-10.png\" alt=\"\" class=\"wp-image-973\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-10.png 432w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-10-300x33.png 300w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And then browsed out again to <em>18.135.13.153\/<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are various ways to get a pcap of the capture from the ASA but one is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/www.cisco.com\/en\/US\/docs\/security\/asa\/asa80\/command\/reference\/c1.html#wp2108895\">https:\/\/&lt;ip_of_asa&gt;\/admin\/capture\/&lt;capture_name&gt;\/pcap<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Which in my case is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/192.168.140.111\/admin\/capture\/dns\/pcap\">https:\/\/192.168.140.111\/admin\/capture\/dns\/pcap<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(You have to authenticate with the ASA) <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"255\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-11.png\" alt=\"\" class=\"wp-image-974\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-11.png 738w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-11-300x104.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You may want to rename the pcap but after opening it with Wireshark we can see the traffic and begin looking out for dns address responses&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(I added a column in Wireshark for the DNS address response or you can find a DNS address response in the trace and just add it as a column)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"389\" height=\"55\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-12.png\" alt=\"\" class=\"wp-image-975\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-12.png 389w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-12-300x42.png 300w\" sizes=\"auto, (max-width: 389px) 100vw, 389px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And then sorting on this field and looking for 127.0.0.1 lo and behold:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"100\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-15.png\" alt=\"\" class=\"wp-image-978\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-15.png 980w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-15-300x31.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-15-768x78.png 768w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I repeated the capture on the outside interface where I expected the original address to seen in the DNS response and indeed it was&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"106\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-17-1024x106.png\" alt=\"\" class=\"wp-image-980\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-17-1024x106.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-17-300x31.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-17-768x80.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2022\/06\/image-17.png 1081w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The doctor is now getting himself a beer (me, not the firewall).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I never really knew DNS doctoring was much of a thing until I encountered it: essentially getting your firewall to alter or doctor DNS responses. One use case for this might be that you can have your internal hosts receive an internal DNS address whilst keeping them pointing to an external ISP&#8217;s DNS. I could [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-960","post","type-post","status-publish","format-standard","hentry","category-dns","category-firewalls"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/960","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=960"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/960\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=960"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}