{"componentChunkName":"component---src-components-mark-down-block-js","path":"/docs/dns-data-exfiltration/","result":{"data":{"markdownRemark":{"html":"<h2 id=\"introduction-dns\" style=\"position:relative;\"><a href=\"#introduction-dns\" aria-label=\"introduction dns permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction DNS</h2>\n<p>DNS (Domain Name System) is a fundamental internet protocol responsible for translating domain names into IP addresses. DNS is intended to take on the role of a phone book for the internet; therefore, it is a universally used and trusted worldwide protocol. DNS uses port 53, which is almost always open on systems and are not be blocked to prevent DNS traffic from firewalls. Many organizations do not decide to monitor DNS traffic for malicious activity. The lack of monitoring and restrictions of the DNS protocol is the reason why attackers often abuse DNS as a way of performing cyberattacks against victim machines. This oversight can have dramatic consequences.</p>\n<p>Here is the overview of the attack vector using DNS :</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/edd66bb4c9d5f876a965676a8cd691e2/da20e/dns-tunnel.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 34%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAABVUlEQVQoz21Ry26DMBDk/z+mUs+9Ro16aaomKjQPCHFIIGDeT9swXTuh6qErrXa9Ho/HY0uqEUIqSCmglISS0lRJdZomqHHENCoIMZjZSL0+M6j7npAPrO6FgNXkHJF/gH8KwPMGaVEg5Bnqusb1cgFPEngswOWWwA0ipBlHGhHGvqIqK4CEDH2POI7Rti2sKkuQ3RiuYYyIF2BhiNXWw26/x8vzEy7shLe1jfXew/LzC57vI3ZdhIsFas4hiYjRzLYdlGUJCxSOfYZ39NF3LYq8wIkxY0FBapumoWzheh54mqLrOriHA742G7Oe6PxI1ryvPkhUeCd8Xa5gf+90S/4pIspNrz0ZhsH0nCfk32hSP60fBATt+dstguMRPqnMsgyWNtRxbARBgP9iJpxD43+DlDFSeybCWYCln1BVtfkEffOceq7rTKh/fCb8i2s17oHV9vwAutUWZxaJ2coAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Dns tunnel\"\n        title=\"Dns tunnel\"\n        src=\"/static/edd66bb4c9d5f876a965676a8cd691e2/5a190/dns-tunnel.png\"\n        srcset=\"/static/edd66bb4c9d5f876a965676a8cd691e2/772e8/dns-tunnel.png 200w,\n/static/edd66bb4c9d5f876a965676a8cd691e2/e17e5/dns-tunnel.png 400w,\n/static/edd66bb4c9d5f876a965676a8cd691e2/5a190/dns-tunnel.png 800w,\n/static/edd66bb4c9d5f876a965676a8cd691e2/c1b63/dns-tunnel.png 1200w,\n/static/edd66bb4c9d5f876a965676a8cd691e2/da20e/dns-tunnel.png 1397w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p>Examples of these attacks are:</p>\n<ul>\n<li>DNS data exfiltration: This involves transmitting sensitive or unauthorized data from a compromised network to an external destination using DNS queries and responses. For example, we can break up a large amount of sensitive data, encrypt it, split it into small chunks, send it through DNS, and reassemble it on the other side.</li>\n<li>DNS tunneling to establish C2 (command and control): This allows attackers to bypass network security restrictions and establish a channel for command and control between two endpoints using DNS traffic.</li>\n</ul>\n<p>There are several <a href=\"https://pubmed.ncbi.nlm.nih.gov/36904959/\">methods</a> that can be employed to detect DNS annomalies.</p>\n<p>This post will show how AppScope can detect DNS anomalies and send a notification using a Slack channel.</p>\n<h3 id=\"prerequisites\" style=\"position:relative;\"><a href=\"#prerequisites\" aria-label=\"prerequisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prerequisites</h3>\n<p>You will need:</p>\n<ul>\n<li>Create a Slack application with an API token (Bot) using <a href=\"https://api.slack.com/start/quickstart\">Slack API</a></li>\n<li>the API token should have following scope <a href=\"https://api.slack.com/scopes/chat:write\"><code>chat_write</code></a>, <a href=\"https://api.slack.com/scopes/chat:write.public\"><code>chart_write_public</code></a> to allow push notifications</li>\n<li>Retrieve the channel id where bot should post the notifications</li>\n<li>Deploy the Slack application</li>\n</ul>\n<h3 id=\"investigating-the-dns-data\" style=\"position:relative;\"><a href=\"#investigating-the-dns-data\" aria-label=\"investigating the dns data permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating the DNS data</h3>\n<p>Here is the overview of the solution:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 634px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/71369a5a1d681017ba18193b1c851414/374ac/dns-arch.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.99999999999999%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAABZElEQVQ4y6WT2U6DQBSGef+X6K0PoN54o6Ze0ISmWyC0ahpKKcsgDFtZOvzOUKWo7QX2JCczzPLxn2Uk9LS6rhsXlkUR9iEFS1OUSQxWVZCuAb7PZ3h6uMXNYIDH+zvklF4HpBsDG3WOxWgEU9dRcKW9gQ30SD7OGUNVlu2e1EdZV2H3m/g+giBAnueQugf+48IMw8B0OkWSJP1C/gb8Vlx2Qz7wHORFhYrVfDwg2+fwPA+EELiuC8dxmrnwphBpADe08REThEkAJ7CRZEkLl8Iog2ERjGcq1qYDc+e3EE3ToPPq+TxH4icpr6LlbaGtNH5+jMligo1tIErpCUjjPV7XFp5fZOhvBhyfng1PeMUb1/Z3UFcqhvIQsiJj65pcdXgCMh5qdWDNghhFCs71XNt7SQiLmCDUa8IWwDiNT8DO7T+gS1UlxMNquYSiKG1K2JcQ6dKlc+q6a6KyEX/LRVH82PsE5qvzv+mFT34AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Dns arch\"\n        title=\"Dns arch\"\n        src=\"/static/71369a5a1d681017ba18193b1c851414/374ac/dns-arch.png\"\n        srcset=\"/static/71369a5a1d681017ba18193b1c851414/772e8/dns-arch.png 200w,\n/static/71369a5a1d681017ba18193b1c851414/e17e5/dns-arch.png 400w,\n/static/71369a5a1d681017ba18193b1c851414/374ac/dns-arch.png 634w\"\n        sizes=\"(max-width: 634px) 100vw, 634px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<h4 id=\"setting-up-the-appscope-configuration\" style=\"position:relative;\"><a href=\"#setting-up-the-appscope-configuration\" aria-label=\"setting up the appscope configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting Up the AppScope configuration</h4>\n<p>Here is the example content of AppScope configuration file <code>SCOPE_CONFIGURATION_FILE</code> which will be used in this example:</p>\n<pre><code class=\"language-yml\">metric:\n  enable: false\nevent:\n  enable: true\n  format:\n    type: ndjson\n    maxeventpersec: 10000\n    enhancefs: false\n  watch:\n    - type: dns\n      name: .*\n      field: .*\n      value: .*\n  transport:\n    type: tcp\n    host: 127.0.0.1\n    port: 9999\n    tls:\n      enable: false\ncribl:\n  enable: false\n</code></pre>\n<p>As you can see we intend to scope <code>dns</code> events and send data to <code>127.0.0.1:9999</code> using TCP.</p>\n<h4 id=\"scope-the-application\" style=\"position:relative;\"><a href=\"#scope-the-application\" aria-label=\"scope the application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Scope the application</h4>\n<p>The below command allows us to run and scope a specific application <code>APP_TO_SCOPE</code> with the <code>SCOPE_CONFIGURATION_FILE</code> defined above</p>\n<pre><code class=\"language-bash\">scope run --userconfig &#x3C;SCOPE_CONFIGURATION_FILE> -- &#x3C;APP_TO_SCOPE>\n</code></pre>\n<h4 id=\"start-the-listener\" style=\"position:relative;\"><a href=\"#start-the-listener\" aria-label=\"start the listener permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Start the listener</h4>\n<p>The command below allows you to start the Scope listener/Slack sender, which enables you to:</p>\n<ul>\n<li>Listen for AppScope event data on <code>127.0.0.1:9999</code>.</li>\n<li>Process the DNS events to identify potential vulnerabilities in DNS requests/responses.</li>\n<li>Send notifications to Slack using the API token <code>SLAC_API_TOKEN</code> to a specific <code>CHANNEL_ID</code>.</li>\n</ul>\n<pre><code class=\"language-bash\">scope listener --addr 127.0.0.1:9999 --notifytoken &#x3C;SLAC_API_TOKEN> --channelid &#x3C;CHANNEL_ID>\n</code></pre>\n<p>To determine suspicious DNS activity, the 'scope listener' looks in DNS queries/responses for the following:</p>\n<ul>\n<li>Unexpectedly long domain names</li>\n<li>Unexpected characters in domain names (non-ASCII and capital letters)</li>\n<li>Unexpectedly high Shannon Entropy value of specific domains</li>\n</ul>\n<h4 id=\"demo\" style=\"position:relative;\"><a href=\"#demo\" aria-label=\"demo permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Demo</h4>\n<p>Here is the example detection of DNS tunneling which is used by <a href=\"https://code.kryo.se/iodine/\">iodine</a> project</p>\n<p><img src=\"/c25aac1f4e813140b667febb0a3737d7/dns-demo.gif\" alt=\"Dns-demo\"></p>\n<h4 id=\"example-notification\" style=\"position:relative;\"><a href=\"#example-notification\" aria-label=\"example notification permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example notification</h4>\n<p>Here is the overview of example alert notification which can be seen in Slack:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/720f161572e622605d9a5d0b1d66ae18/d9ed0/slack-event.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 53%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAB2HAAAdhwGP5fFlAAABE0lEQVQoz5VTS26EMBTL/Q/AihULVixYVVUvg/h/B0gCgiEBNwltVUYgDU+ynjcxfrYgUZIhjiKkWYa+7zFNE/Rs22Zwd0hZVWiaBpRSjOOIeZ4PgndFiXaVZznqugbnHEKIg9iv4LvCpOs6I6Zx9eiOS9K2LTzPg2VZcF0XjuPA930TwTAMWNf1nsNKZRiGoXFYliWKojCZLsvy73y87J2ffYhoES363mwHfubaOKSUYRES8yLw1FB8EauB4XLfUr3PixJBEFw7HFSznA9gk/hDPz5BFfTuhtnwlk+YJPDx+QXbtq8FG5WdzvDxaMAZA2P05bSbJ+uWw1D9KWmKOE6QJKmJQKozjyXsRUgpf8o6d/gNSRBZEDX0EhYAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Slack event\"\n        title=\"Slack event\"\n        src=\"/static/720f161572e622605d9a5d0b1d66ae18/5a190/slack-event.png\"\n        srcset=\"/static/720f161572e622605d9a5d0b1d66ae18/772e8/slack-event.png 200w,\n/static/720f161572e622605d9a5d0b1d66ae18/e17e5/slack-event.png 400w,\n/static/720f161572e622605d9a5d0b1d66ae18/5a190/slack-event.png 800w,\n/static/720f161572e622605d9a5d0b1d66ae18/c1b63/slack-event.png 1200w,\n/static/720f161572e622605d9a5d0b1d66ae18/d9ed0/slack-event.png 1415w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<h4 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h4>\n<p>The following solution was tested with the <code>iodine</code> project but give it a shot on your own! Test it out thoroughly! Explore the documentation! Did the blog effectively cover the topic you were interested in? Was the content engaging and easy to understand? We want to know what stood out to you and if there's anything you wish we had included. Your feedback plays a crucial role in shaping the future of AppScope solution. It helps us understand what works well and what we can improve upon to better serve you, our valued readers.\nFeel free to join our #AppScope channel in the <a href=\"https://cribl.io/community/\">Cribl Community Slack</a>, where you can share your experiences using AppScope and the exciting things you uncover with it.</p>","frontmatter":{"title":"Detecting DNS Data Exfiltration"}}},"pageContext":{"slug":"/dns-data-exfiltration/","id":"afdb36aa-ab25-54ae-9fc4-048f5a726b2f"}},"staticQueryHashes":["2787008656","306729481","625673991","640077088"]}