Git Product home page Git Product logo

dnsfs-1's Introduction

dnsfs

This is a script for hosting and downloading a static set of files over DNS without using a custom DNS server. If you give dnsfs.rb a path to a directory, it will create BIND-compatible TXT entries for hosting the files inside. If you give dnsfs.rb a domain name, it will show you the list of hosted files and ask which one you want to download.

How fast is it? I downloaded a 568K file from my nameserver in 293 seconds... so about 1981 bytes/second. Of course it depends on the RTT, and it can probably be sped up a lot by sending requests in parallel (this script doesn't).

NOTE: I'm pretty sure something like this has been done before... I just wanted to write it myself and couldn't find the reference. Please let me know of similar things!

Related Work

Examples

Downloading

Note: Intermediate nameservers may cache your requests. Please be respectful and query the authoratative nameserver directly using the --nameserver option!

$ ruby dnsfs.rb --download --nameserver dnsfs.defuse.ca dnsfs.defuse.ca
1. manifesto.txt (size: 3880 bytes)
2. longcat.jpg (size: 580516 bytes)
Which one?
1
.....................
File written to /tmp/manifesto.txt.

Generating

$ ruby dnsfs.rb --generate test
f1info.dnsfs IN TXT "Name: foo.txt / Size: 31"
f1p1.dnsfs IN TXT "VGhpcyBpcyAKYSBmaWxlCm5hbWVkCmZvby50eHQhCg=="
f1p2.dnsfs IN TXT "~EOF~"
f2info.dnsfs IN TXT "Name: bar.txt / Size: 558"
f2p1.dnsfs IN TXT "VGhpcyBpcyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEKVGhpcyBpcyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEKVGhp"
f2p2.dnsfs IN TXT "cyBpcyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEKVGhpcyBpcyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEKVGhpcyBp"
f2p3.dnsfs IN TXT "cyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEKVGhpcyBpcyAKYSBmaWxlCm5hbWVkCmJhci50eHQhClRoaXMgaXMgCmEgZmlsZQpuYW1lZApiYXIudHh0IQpUaGlzIGlzIAphIGZpbGUKbmFtZWQKYmFyLnR4dCEK"
f2p4.dnsfs IN TXT "~EOF~"
f3info.dnsfs IN TXT "~EOL~"

Downloading Without Ruby

The naming convention makes it easy to download a file with a standard /bin/sh command:

for i in `seq 21`; do host -t TXT f1p$i.dnsfs.defuse.ca|cut -d '"' -f 2|base64 --decode; done|less

Alternatively, using dig:

for i in `seq 21`; do dig f1p$i.dnsfs.defuse.ca TXT|grep TXT|grep '"'|cut -d '"' -f 2|base64 --decode; done|less

All you have to do is replace f1 with the file number you want and seq 21 with the number of parts in the file (the ceiling of the file size divided by 189).

How It Works

For each file K in 1..N, there are a set of TXT entries:

  • fKinfo: File K's name and size.
  • fN+1info: End of list marker: ~EOL~
  • fKpP: Part P of file K base64-encoded. Last one is ~EOF~.

dnsfs-1's People

Contributors

defuse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.