dns spoofing attack dr. neminath hubballi iit indore © neminath hubballi

25
DNS Spoofing Attack DNS Spoofing Attack Dr. Neminath Hubballi Dr. Neminath Hubballi IIT Indore © Neminath Hubballi IIT Indore © Neminath Hubballi

Upload: reynold-mcdonald

Post on 26-Dec-2015

247 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Spoofing AttackDNS Spoofing AttackDr. Neminath HubballiDr. Neminath Hubballi

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 2: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS BasicsDNS Basics

We are not good at remembering numbersWe are not good at remembering numbers Computers work with numbersComputers work with numbers Mapping between IP addresses and URLs is maintained Mapping between IP addresses and URLs is maintained

as a serviceas a service DNS servers does this job of transforming between DNS servers does this job of transforming between

these twothese two Historically the work done by DNS servers was done with Historically the work done by DNS servers was done with

hosts.txt hosts.txt Every host maintains a list of mapping IP addresses and Every host maintains a list of mapping IP addresses and

computer names computer names Was feasible in ARPANET timeWas feasible in ARPANET time Scalability became an issueScalability became an issue

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 3: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNSDNS

DNS runs on port 53DNS runs on port 53 Runs on UDP Runs on UDP UDP is a connectionless protocolUDP is a connectionless protocol

Makes it easy for spoofingMakes it easy for spoofing DNS is a distributed database maintained in a DNS is a distributed database maintained in a

hierarchical tree structurehierarchical tree structure DNS Cache DNS Cache

To improve operational efficiency DNS servers To improve operational efficiency DNS servers caches the resource recordscaches the resource records

Positive cachingPositive caching Negative caching Negative caching

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 4: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS WorkingDNS Working

What is IP of www.google.com

What is IP of www.google.com

Try at .com its IP is 1.1.1.1

What is IP of www.google.com

Try at google.com authoritative DNS it IP is 2.2.2.2

What is IP of www.google.com

Its IP is 3.3.3.3

Its IP is 3.3.3.3

Root DNS

TLD DNS

Authoritative DNS

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

1.1.1.1

2.2.2.2

Page 5: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS ComponentsDNS Components Resource RecordsResource Records Internet Domain NamespaceInternet Domain Namespace

Organizational Organizational Geographical Geographical Reverse domainReverse domain

Root DNS is at the top Root DNS is at the top Root DNS is managed by Internet Name Registration AuthorityRoot DNS is managed by Internet Name Registration Authority Top Level Domain (TLD)Top Level Domain (TLD)

Bellow root DNSBellow root DNS

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 6: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Record Types in DNSRecord Types in DNS

Important ones as there are many A –Address record name to 32 bit address AAAA – Address Record name to 128 bit IPV6

address CNAME – Canonical name after receiving this reply

host will query with this new request NAME TYPE VALUE bar.example.com. CNAME foo.example.com.

foo.example.com. A 92.0.2.23

NS Records – Contain IP address of authoritative name server

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 7: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Zones in DNSZones in DNS

.com is domain.com is domain Microsoft.com is a zoneMicrosoft.com is a zone Zone starts as a database of single Zone starts as a database of single

domaindomain If other domains are added below the If other domains are added below the

domain used to create the zonedomain used to create the zone Subdomains can be part of same zone Subdomains can be part of same zone

Dev.microsoft.comDev.microsoft.com

Belong to another zone Belong to another zone Example.microsoft.comExample.microsoft.com

Zone is a subset of domainZone is a subset of domain

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 8: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Zone TransferZone Transfer

When a new DNS server is addedWhen a new DNS server is added For high availability and fault tolerance For high availability and fault tolerance

reasonsreasons

It starts as a secondary DNS serverIt starts as a secondary DNS server All zones hosted in primary are copied to All zones hosted in primary are copied to

secondarysecondary

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 9: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS VulnerabilityDNS Vulnerability

Getting a wrong answer from the serverGetting a wrong answer from the server

What is IP of www.google.com

Its IP is 4.4.4.4

Root DNS

TLD DNS

Authoritative DNS

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 10: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS VulnerabilityDNS Vulnerability

Someone else answers to a DNS query Someone else answers to a DNS query before the one supposed to answer before the one supposed to answer

What is IP of www.google.com

Its IP is 3.3.3.3

Its IP is 4.4.4.4

DNS Server

Malicious guy

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Root DNS

TLD DNS

Authoritative DNS

Page 11: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Packet Structure

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 12: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Packet Structure

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 13: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi
Page 14: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi
Page 15: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Poisoning with Host.txtDNS Poisoning with Host.txt

On a windows machine On a windows machine Open C:\windows\system32\drivers\etc\host.txtOpen C:\windows\system32\drivers\etc\host.txt Add a line likeAdd a line like

10.10.10.10 www.iiti.ac.in10.10.10.10 www.iiti.ac.in

Open a webpage and type www.iiti.ac.in it will go Open a webpage and type www.iiti.ac.in it will go elsewhereelsewhere

Alternatively create a .bat file with Alternatively create a .bat file with @echo off@echo off echo 10.10.10.10 www.iiti.ac.in >> C:\windows\system32\echo 10.10.10.10 www.iiti.ac.in >> C:\windows\system32\

drivers\etc\host.txtdrivers\etc\host.txt exist exist

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 16: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Spoofing ToolsDNS Spoofing Tools

DsniffDsniff dnsspoofdnsspoof Example

abc.com IP address is 10.0.0.1 Make it spoof to respond 100.0.1.1 In the text file dnssniff.txt write 100.0.1.1 abc.com [gateway]# dnsspoof -i eth0 -f /etc/dnssniff.txt [bash]# host abc.com abc.com has address of 100.0.1.1

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 17: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNS Spoofing in RealityDNS Spoofing in Reality

DNS Replies are verified forDNS Replies are verified for Coming from same IP addressComing from same IP address Coming to the same port from which request was sentComing to the same port from which request was sent Reply is for the same record as was asked in the Reply is for the same record as was asked in the

previous questionprevious question Transaction ID match Transaction ID match

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 18: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

How these Verifications are Overcome

Coming from same IP addressComing from same IP addressBecause authorative DNS server IP address can be Because authorative DNS server IP address can be

discovered by offline queriesdiscovered by offline queriesComing on the same port from which request Coming on the same port from which request

was sentwas sentMany DNS servers used static port numbers Many DNS servers used static port numbers

Answer is the same question that was askedAnswer is the same question that was askedThis is easy if attacker herself initiates a requestThis is easy if attacker herself initiates a request

Transaction ID match Transaction ID match Guess it Guess it

Page 19: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Dan Kamnisky Attack

Kamnisky AttackKamnisky AttackFlood the recursive name server with many Flood the recursive name server with many

answersanswersOne of them have to be right and it works !One of them have to be right and it works !The identifier is not fully random so one can The identifier is not fully random so one can

predictpredict

Page 20: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Dan Kaminisky Attack

Ask a recursive DNS server a question which is most likely not in its cache Pick a non existing domain like rnd.india.microsoft.com

With high probability name sever will contact the authorative name server of microsoft.com domain

Attacker send a reply with canonical name

rnd.india.microsoft.com CNAME IN www.microsoft.com

www.microsoft.com A IN 68.177.102.22

Page 21: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Defending DNS Spoofing Defending DNS Spoofing

Many solutions focus on increasing the Many solutions focus on increasing the entropy of DNS query component entropy of DNS query component Transaction IDTransaction ID Port numberPort number

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 22: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

DNSSECDNSSEC

Security extension to DNS protocol Security extension to DNS protocol It uses public key infrastructure to give a It uses public key infrastructure to give a

guarantee on who is sending the replyguarantee on who is sending the reply Use private key to digitally sign the messageUse private key to digitally sign the message Use public key to verify the messageUse public key to verify the message Works fine as long as recipient believes in public-Works fine as long as recipient believes in public-

private key pair of senderprivate key pair of sender What stops from someone generating her own key What stops from someone generating her own key

pair and replying pair and replying Chain of trust relationshipChain of trust relationship

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 23: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

How DNSSEC Works

Each DNSSEC zone creates one or more pairs of public/private key(s)Public portion put in DNSSEC record type DNSKEY

Zones sign all RRsets with private key(s) and resolvers use DNSKEY(s) to verify RRsetsEach RRset has a signature attached to it: RRSIG

So, if a resolver has a zone’s DNSKEY(s) it can verify that RRsets are intact by verifying their RRSIGs

Page 24: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Chain of Trust in DNSSECChain of Trust in DNSSEC Introduces 3 new resource recordsIntroduces 3 new resource records

RRSIG Signature over RR set using private key RRSIG Signature over RR set using private key DNSKEY Public key, needed for verifying a RRSIGDNSKEY Public key, needed for verifying a RRSIG DS Delegation Signer; ‘Pointer’ for building chains of authenticationDS Delegation Signer; ‘Pointer’ for building chains of authentication

Authoritative DNS server sends the following with replyAuthoritative DNS server sends the following with reply RR containing IP URL mappingRR containing IP URL mapping RRSIGRRSIG DNSKEY and DNSKEY and DSDS

Verification can proceed one level higher the hierarchyVerification can proceed one level higher the hierarchy At no point a DNS server gives a DS which is bellow itAt no point a DNS server gives a DS which is bellow it Problem is effectively addressed if Root Server becomes the highest signature Problem is effectively addressed if Root Server becomes the highest signature

verifier verifier As of July 2010 there is one signed root server up and running (http://www.root-As of July 2010 there is one signed root server up and running (http://www.root-

dnssec.org/)dnssec.org/)

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi

Page 25: DNS Spoofing Attack Dr. Neminath Hubballi IIT Indore © Neminath Hubballi

Key References for DNSSECKey References for DNSSEC

http://www.internetsociety.org/deploy360/http://www.internetsociety.org/deploy360/dnssec/basics/dnssec/basics/

http://www.root-dnssec.org/http://www.root-dnssec.org/ http://en.wikipedia.org/wiki/http://en.wikipedia.org/wiki/

Domain_Name_System_Security_ExtensiDomain_Name_System_Security_Extensionsons

IIT Indore © Neminath HubballiIIT Indore © Neminath Hubballi