The Dark Side of the DNS Jaeson Schultz.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
PHP I.
Enabling Secure Internet Access with ISA Server
CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
1 Computer Networks: A Systems Approach, 5e Larry L. Peterson and Bruce S. Davie Chapter 8 Network Security Copyright © 2010, Elsevier Inc. All rights.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
 Firewalls and Application Level Gateways (ALGs)  Usually configured to protect from at least two types of attack ▪ Control sites which local users.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Application Layer Functionality and Protocols Network Fundamentals – Chapter.
PhishNet: Predictive Blacklisting to Detect Phishing Attacks Pawan Prakash Manish Kumar Ramana Rao Kompella Minaxi Gupta Purdue University, Indiana University.
Chapter 16 – DNS. DNS Domain Name Service This service allows client machines to resolve computer names (domain names) to IP addresses DNS works at the.
 Collection of connected programs communicating with similar programs to perform tasks  Legal  IRC bots to moderate/administer channels  Origin of.
Server-side Scripting Powering the webs favourite services.
Firewall and Internet Access Mechanism that control (1)Internet access, (2)Handle the problem of screening a particular network or an organization from.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 21 - Web Servers (IIS, PWS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Botnet behavior and detection October RONOG Silviu Sofronie – a Head of Forensics.
Christopher Kruegel University of California Engin Kirda Institute Eurecom Clemens Kolbitsch Thorsten Holz Secure Systems Lab Vienna University of Technology.
1 Network Administration Module 3 ARP/RARP. 2 Address Resolution The problem Physical networks use physical addresses, not IP addresses Need the physical.
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
Staff addresses Availability tradeoffs December 13, 2012.
THE LARGEST NAME SERVICE ACTING AS A PHONE BOOK FOR THE INTERNET The Domain Name System click here to next page 1.
System Administration(SAD622S) Name of Presenter: Shadreck Chitauro Lecturer 18 July 2016 Faculty of Computing and Informatics.
1 Design and Implementation of a High-Performance Distributed Web Crawler Polytechnic University Vladislav Shkapenyuk, Torsten Suel 06/13/2006 석사 2 학기.
Internet Vulnerabilities & Criminal Activity Internet Forensics 12.1 April 26, 2010 Internet Forensics 12.1 April 26, 2010.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Database and Cloud Security
Network security Vlasov Illia
COMP2322 Lab 4 Socket Programming
Understand Names Resolution
BUILD SECURE PRODUCTS AND SERVICES
Web fundamentals: Clients, Servers, and Communication
CSCE 548 Student Presentation Ryan Labrador
IS1500: Introduction to Web Development
CS 330 Class 7 Comments on Exam Programming plan for today:
Section 6.3 Server-side Scripting
HTTP AND ABSTRACTION ON THE INTERNET
WWW and HTTP King Fahd University of Petroleum & Minerals
A lustrum of malware network communication: Evolution & insights
Web Development Web Servers.
DNS Tunneling.
Using MIS 2e Chapter 6 Appendix
Web Caching? Web Caching:.
CHAPTER 3 Architectures for Distributed Systems
Introduction to Computers
Whether you decide to use hidden frames or XMLHttp, there are several things you'll need to consider when building an Ajax application. Expanding the role.
TCP/IP Networking An Example
Internet Networking recitation #12
Intro to PHP & Variables
Net 323: NETWORK Protocols
Net 323 D: Networks Protocols
How Data Flows through the Internet
CS222 Web Programming Course Outline
CS4622: Computer Networking
Unit 27 - Web Server Scripting
Threat Analtics Data Exfiltration by DNS lookup
TCP/IP Networking An Example
Application layer Lecture 7.
NET 536 Network Security Lecture 8: DNS Security
Fundamentals of Python: First Programs
This is the Sign In page for the Dashboard
World Wide Web Uniform Resource Locator hostname [:port]/path
Domain Name System Refs: Chapter 9 RFC 1034 RFC 1035.
Internet Control Message Protocol
Applications Layer Functionality & Protocols
COMPUTER NETWORKS PRESENTATION
Computer Networks Primary, Secondary and Root Servers
Unit 32 Every class minute counts! 2 assignments 3 tasks/assignment
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Web Servers (IIS and Apache)
Presentation transcript:

The Dark Side of the DNS Jaeson Schultz

Who Am I? Jaeson Schultz – jaeson@cisco.com @jaesonschultz (Twitter) Technical Leader with Cisco Talos Over 20 years specializing in thwarting abuse of Internet protocols like SMTP, HTTP, and DNS Former manager of the SpamCop DNSBL – An IP address-based blacklist which has taking the fight to the spammers for over a decade Assisted in design and development of the Cisco IronPort Anti-Spam content scanner, and Cisco’s Web Security Appliance, Cloud Web Security & Next Generation Firewall products

DNS Data Exfiltration This presentation concerns the abuse of DNS, and the first topic we will cover is Data Exfiltration.

Let’s go Hunting Lets look for ‘long’ domain names. Oh great there are 100 million!

Observed length distribution Best fit curve e-λx If we take a hostname from a DNS lookup and exclude the registered 2nd (or 3rd) level domain name we are left with a “combined subdomain”. The orange line shows the distribution of combined subdomain lengths from single up to 65 characters. Although it is obviously not an exact fit, this distribution approximates to the smooth exponential curve shown in yellow. We can use this curve as our model of normality and compare our observed values to this curve in order to spot anomalies. Immediately we can see that subdomains of three characters in length are far more common than we would expect. Understandably, this corresponds to the length ‘www’, a very common subdomain string. To measure how more frequent this observation is than we would expect, we can divide the observed value by that predicted from our curve in order to calculate a metric of how unusual this observation is. Combined Subdomain Length

Observed data ÷ expected value anomalies Observed data ÷ expected value (best fit curve) Continuing this calculation for all the combined subdomain length values and plotting this gives a graph showing how much reality diverges from our expectations of normality for each subdomain length. Combined Subdomain Length Divergence

Multigrain Domain Names log.nu6timjqgq4dimbuhe.3ikfsb---redacted---cg3.7s3bnxqmavqy7sec.dojfgj.com log.nu6timjqgq4dimbuhe.otlz5y---redacted---ivc.v55pgwcschs3cbee.dojfgj.com lll.nu6toobygq3dsnjrgm.snksjg---redacted---dth.ejitjtk4g4lwvbos.amouc.com lll.nu6timrshe4timrxhe4a.7vmq---redacted---hit.w6nwon3hnifbe4hy.amouc.com ooo.nu6tcnbug4ytkobxhe4q.zrk2---redacted---hxw.tdl2jg64pl5roeek.beevish.com ooo.nu6tgnzvgm2tmmbzgq4a.rkgo---redacted---tw5.5z5i6fjnugmxfowy.beevish.com Multigrain is a Point of Sale malware that was uncovered back in April 2016. Multigrain scrapes RAM for bank card data. The financial data is then exfiltrated using base-32 encoded DNS queries. In contrast to base-64 encoding, base-32 encoding ensures that no characters that may be illegal in a host name are present. Here are a few examples of hostnames found in passive DNS that were used by Multigrain to exfiltrate financial information.

Active Exfiltration Known Multigrain POS malware domain log.nu6timjqgq4dimbuhe.3ikfsb---redacted---cg3.7s3bnxqmavqy7sec.dojfgj.com lll.nu6toobygq3dsnjrgm.snksjg---redacted---dth.ejitjtk4g4lwvbos.amouc.com ooo.nu6tgnzvgm2tmmbzgq4a.rkgo---redacted---tw5.5z5i6fjnugmxfowy.beevish.com Previously unknown domains Base32 encoded machine identifier m=3753560948 Base32 encoded & RSA 1024 encrypted credit card information

DNS Command & Control Malware has also recently been observed using DNS as a C2 channel

DNSMessenger What initially drew our interest to this particular malware sample was a tweet published by security researcher on Twitter (thanks simpo!) regarding a Powershell script that he was analyzing that contained the base64 encoded string 'SourceFireSux'. Interestingly enough, Sourcefire was the only security vendor directly referenced in the Powershell script. We searched for the base64 encoded value 'UwBvAHUAcgBjAGUARgBpAHIAZQBTAHUAeAA=' which was referenced in the tweet, and were able to identify a sample that had been uploaded to the public malware analysis sandbox, Hybrid Analysis.

DNSMessenger This Maldoc from DNSMessenger contains a malicious macro. The macro contains code that is passed to Powershell via the command line. This allows the code to be executed without ever requiring it to be written to the filesystem of the infected system.

The code reaches out and obtains additional code to run via a TXT query. In this case a variable $e is being loaded up with the next stage of malware.

One the malware is decoded an ran, it establishes a command and control channel, also using TXT records. This is one of the messages it sends.

Decoded Message If we take the DNS request query and run it through a decoding function, we can clearly see that it is the output of the Windows Command Line Processor being sent to the C2 server.

DNS What isn’t being detected? All of this malware using the DNS got me thinking about other ways DNS might be abused…

One potential channel for data exfiltration or even rudimentary bidirectional communication exists in DNS 0x20 encoding of DNS labels

DNS 0x20 at Google Public DNS For some name servers, the response does not match the exact case of the name in the request. Other name servers respond handle equivalent names differently depending on case in the request, either failing to reply at all or returning incorrect NXDOMAIN responses that match the exact case of the name in the request. 70% of DNS traffic at Google Public DNS is to “whitelisted” servers that honor DNS 0x20. Some nameservers will not respect 0x20 encoded queries, but the majority do. According to Google, 70% of their DNS traffic involves DNS 0x20 compliant DNS servers. https://developers.google.com/speed/public-dns/docs/security

encoding SECRET DATA IBm.Com This is the proposed algorithm for the 0x20 encoding of a DNS query name. In the proposed algorithm the requested name is converted to lowercase, and then encrypted, perhaps with AES, using some key (or keys) shared between DNS requests. The cyphertext bits are read and used to encode the query name. If the bit is 0, a capital letter is produced, and a bit of 1 results in a lowercase character. If an attacker was somehow able to manipulate the input for the 0x20 encoding process, then they could replace the original cyphertext with a cyphertext/plaintext of their own. Fortunately DNS 0x20 is usually not implemented at the client level, so mixed-case queries originating here may arouse additional suspicion.

Extended Query ID (XQID) Extends the DNS query ID with 24 to 63 alpha-numeric [a-z0-9] characters into the query/response question name (QNAME) making the range of possible transactions IDs so extremely large that any brute force "guessing" or birthday attack attempts are futile. Ex. QNAME: xqid—q.ml6ah36sk9jlznx1jswibslu.www.example.com At Google’s Public DNS, “such requests make up less than 3% of outgoing requests, assuming normal traffic” Exfiltrating data using 0x20 bits is going to be somewhat slow only 255 bits at most can be transmitted per DNS query name. Attackers could instead use XQID format queries to increase the bandwidth of their communications. However, this extra bandwidth would come at the expense of greater visibility with respect to network defenders. It seems that XQID queries are somewhat rare, making up less than 3% of outgoing requests at Google’s Public DNS. https://developers.google.com/speed/public-dns/docs/security

Passive DNS Dead Drops According to Wikipedia, a dead drop is a method used to pass items or information between two individuals using a secret location, thus not requiring them to meet directly and thereby maintaining operational security. Why take the chance of registering your own domain when you can borrow others’ domains to conduct your data exfiltration? Any wildcarded domain has the potential to be used as a passive DNS dead drop. Also, as you can see in this example, passive DNS databases will often normalize the names that are requested. Thus if we were using 0x20 encoding in our names, it would NOT appear in the normal passive DNS interfaces used by most security analysts. The case (0x20) of the QNAMEs can only be viewed using the raw passive DNS data.

DNS Malware In-The-Wild The idea of manipulating DNS traffic to accomplish nefarious goals has been around for many years... Dan Kaminsky’s Dark Ops of DNS was presented 13 years ago. Since then we have seen examples of malware using DNS as a means to tunnel traffic from one location to another.

Data Set Analyzed the previous 6 months of samples run through the Talos malware sandbox Samples that scored between 65-100 (those considered malicious) were further analyzed by extracting the hostnames and IP addresses they contacted. ~1 Million malware samples in total

Malware: Contacted Domains 1,699,712 com 330,704 net 108,543 org 106,291 eu 65,524 pl 57,274 top 53,924 cn 53,482 ru 52,726 info 49,397 la 25,635 pw 21,479 io 19,742 de 17,569 biz 12,869 br 12,001 nu 9,484 su 9,477 cc 8,949 work 8,638 to Here is the distribution of TLDs in the domain names that were contacted. There were 3.5 million hostnames in the dataset.

Malware: Contacted Domains I went through 6 months of malware sandbox samples at Talos, paying specific attention to the samples that scored between 65-90 (were considered malicious by the sandbox). During that time the malware we analyzed had reached out to more than 3.5 million hostnames. Only 0.1% of those hostnames had mixed case. There were zero XQID queries in the set (0.1%)

Malware: Contacted Domains Only 0.03% of those hostnames involved .bit domain names. When I went and looked at the individual samples, the DNS queries for .bit domains were issued to DNS servers that were enhanced to be able to resolve .bit domains. Enforcing that DNS requests are made to the assigned DNS server would prevent these from resolving. I also downloaded a copy of the namecoin blockchain, and extracted the approximately 3400 IP addresses in it, and cross referenced that with the IP addresses contacted by malware. Of the samples we found reaching out to IPs hosting .bit domains, there was no evidence that the malware was in any way working off of a copy of the namecoin blockchain and thereby evading DNS. (0.03%)

Malware: Contacted Domains 0.5% of the hostnames contacted by malware involved Tor-related domain names. The vast majority of these were using Tor2Web whereby they can append a TLD like .to to an onion link. That will resolve to the IP address of a server which, when contacted, will fetch the .onion link over Tor and relay the content back to the victim. (0.5%)

Malware: Contacted Domains Looking deeper at the Tor2Web domains, the vast majority of the samples using this technique were witnessed in April 2017, when they absolutely exploded in use relative to other months.

Tor2Web TLDs 11,844 onion.nu 8,458 onion.to 12 onion.link 3 onion.pw 3 onion.cab 1 onion.rip

Internationalized Domain Names Only 0.002% of malware from the Talos sandbox was observed reaching out to IDN domains. However, by decoding IDN domains witnessed in passive DNS we found hostnames masquerading as Punycode such as the following, which were involved in a blog comment URL spamming operation: xn--------------------------------gmbr539ysay4291w.awelder.info xn--------onqu75bcvap11j.centralyp.info It is certainly also possible to abuse IDN domain names, besides homographs. Since many of the tools commonly used in the DNS security world do not decode Punycode we normally see only the encoded version. Even if tools did decode the Punycode, many security analysts would not be able to read the multiple foreign languages that would result. Of course the IDN portion could also be potentially used to exfiltrate data, using the characters appearing after the “xn--” in the hostname. This would not necessarily arouse any suspicion if encountered in most DNS logs.