Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cat-DNS: a DNS server that resolves everything to cats

Cat-DNS: a DNS server that resolves everything to cats

The internet needs more cats. DNS servers are the authority on all things internet. Therefore, the best DNS server is the one that resolves everything to cats. This talk is about that.

Do you think DNS is scary/arcane/confusing? Nope! I'll show you how you can write your own DNS server in less than 200 lines of JavaScript. With cats. We're going to walk through the basics and find out how DNS servers work, how you can talk to a DNS server if you're a browser, and how to talk back to a browser if you are a DNS server.

By the end, you'll know how to what a static IP is, why dig is a hilarious tool if you want to mess around with the internet, how you can write your own DNS server and perhaps most importantly, why you probably shouldn't. And have I mentioned the cats? There will definitely be cats.

Videos of this talk:
https://www.youtube.com/watch?v=qDPhW9P44fI
https://www.youtube.com/watch?v=kvwAIiledvo

Monica Dinculescu

August 01, 2014
Tweet

More Decks by Monica Dinculescu

Other Decks in Programming

Transcript

  1. MORE CATS
    THE INTERNET
    needs

    View full-size slide

  2. I’M MONICA
    @notwaldorf

    View full-size slide

  3. DNS
    domeow name system

    View full-size slide

  4. DNS
    GOOGLE.COM ☛ 74.125.226.134

    View full-size slide

  5. CAT-DNS
    GOOGLE.COM ☛ cats? cats!!

    View full-size slide

  6. EVEN?
    HOW DOES
    it

    View full-size slide

  7. UDP
    USER DATAMEOW PROTOCOL

    View full-size slide

  8. UDP
    it’s the honey badger

    View full-size slide

  9. 8.8.8.8
    800,000 rEq/sec

    View full-size slide

  10. 8.8.8.8
    70 billion rEq/day

    View full-size slide

  11. 8.8.8.8
    avg: 45 ms

    View full-size slide

  12. CAT-DNS
    avg: 7 ms

    View full-size slide

  13. CAT-DNS
    but only knows cats

    View full-size slide

  14. so basically

    View full-size slide

  15. www.images.google.com?
    YOU DNS

    View full-size slide

  16. www.images.google.com?
    YOU DNS
    images.google.com
    TTL: 5 minutes
    ip: 74.125.226.104

    View full-size slide

  17. DOMAIN Name Server
    RNS
    www.images.google.com?
    YOU

    View full-size slide

  18. Recursive Name Server
    RNS
    www.images.google.com?
    YOU

    View full-size slide

  19. RNS
    www.images.google.com? I DON’T KNOW BUT I CAN ASK
    YOU

    View full-size slide

  20. ROOT
    RNS
    images.google.com?
    ROOT NAME SERVER
    YOU

    View full-size slide

  21. ROOT
    RNS
    .com .org .biz
    I KNOW THE TLDS
    YOU
    images.google.com?

    View full-size slide

  22. ROOT
    RNS
    .com
    ASK THE .COM SERVER
    YOU
    images.google.com?

    View full-size slide

  23. ROOT
    RNS
    .COM
    YOU
    images.google.com?

    View full-size slide

  24. ROOT
    RNS
    .COM
    I’M GETTING HUNGRY
    YOU

    View full-size slide

  25. ROOT
    RNS
    .COM
    google yahoo imgur
    YOU
    images.google.com?

    View full-size slide

  26. ROOT
    RNS
    .COM GOOGLE
    YOU
    images.google.com?

    View full-size slide

  27. ROOT
    RNS
    .COM GOOGLE
    authoritative
    YOU
    images.google.com?

    View full-size slide

  28. ROOT
    RNS
    .COM GOOGLE
    74.125.226.135
    YOU
    images.google.com?

    View full-size slide

  29. 74.125.226.135
    ROOT
    RNS
    .COM GOOGLE
    YOU

    View full-size slide

  30. ROOT
    RNS
    .COM GOOGLE
    YOU
    yay !

    View full-size slide

  31. CACHING
    ain’t no one got time

    View full-size slide

  32. TTL
    time to live

    View full-size slide

  33. browser cache
    chrome://net-internals/#dns

    View full-size slide

  34. WORKS FOR ME
    BUT not for you…wat?!

    View full-size slide

  35. www.whatsmydns.net

    View full-size slide

  36. DANGER ZONE
    what can go wrong?

    View full-size slide

  37. DANGER ZONE
    cache poisoning

    View full-size slide

  38. ROOT
    RNS
    .COM
    images.google.com?
    YOU

    View full-size slide

  39. ROOT
    RNS
    .COM ☢
    YOU
    images.google.com
    TTL: 10000 minutes
    ip: 66.000.000.66
    images.google.com?

    View full-size slide

  40. ROOT
    RNS
    .COM ☢
    YOU
    trololololololol
    images.google.com?

    View full-size slide

  41. THE RFC?
    DID YOU EVEN
    read

    View full-size slide

  42. REALTALK
    1987 RFCS ARE PAINFUL RFCS

    View full-size slide

  43. your cat *
    how to spy
    on
    * if your cat is a DNS server

    View full-size slide

  44. NSLOOKUP
    use: nslookup google.com

    View full-size slide

  45. DIG
    use: dig google.com

    View full-size slide

  46. 9:30 am
    yay, code!
    because

    View full-size slide

  47. “I'LL OFTEN DROP
    DOWN TO NODE.JS IF I
    REALLY NEED TO BE
    CLOSE TO THE METAL”
    - SOMEONE ON HACKER NEWS

    View full-size slide

  48. require(‘node-bitarray’)
    !
    require(‘buffer’).Buffer
    !
    require(‘dgram’)
    !
    require(‘ip’)

    View full-size slide

  49. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  50. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  51. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  52. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  53. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  54. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  55. var dnsServer = dgram.createSocket('udp4');
    dnsServer.bind(53,'localhost');
    !
    dnsServer.on('message', function (msg, rinfo) {
    // Parse message.
    // Transmogrify into response.
    // Resolve to cat-service OR imgur.
    // Giggle.
    !
    dnsServer.send(=^_^=);
    }

    View full-size slide

  56. imgur
    how to be a cat authority

    View full-size slide

  57. NO lessons
    some lessons
    are better than

    View full-size slide

  58. what now?
    slow dns means less cats

    View full-size slide

  59. what now?
    pick a faster one

    View full-size slide

  60. what now?
    host your own? bind!

    View full-size slide

  61. what now?
    get around geolocation

    View full-size slide

  62. what now?
    https:// /notwaldorf/cat-dns

    View full-size slide

  63. what now?
    STEALING WIFI JUST GOT WEIRD

    View full-size slide

  64. @notwaldorf

    View full-size slide