From: Nathaniel Wesley Filardo Date: Thu, 6 Mar 2014 18:29:33 +0000 (-0500) Subject: dnsfile for stashing a file in DNS X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=9deb9a99bde1051d578c7d3f8784d5cfe01ce18e;p=smallutils dnsfile for stashing a file in DNS --- diff --git a/dnsfile.sh b/dnsfile.sh new file mode 100755 index 0000000..c27f9c1 --- /dev/null +++ b/dnsfile.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Defines a general purpose UUENCODING-as-TXT scheme. +# Run as ./dnsfilee.sh FILE DNS-LOCATION + +if [ $# != 2 ]; then echo "Need file and dns suffix"; exit 1; fi + +FILE=$1 +DNSFILE=$2 +DNSTIME=$((24*60*60)) + +encode_counted_line() { + # DJBDNS: + sed -e 's/\\/\\134/g' -e 's/:/\\072/g' \ + | awk -e "//{ print \$1\".$1:\"\$2\":$DNSTIME\"; }" + # BIND: + # sed -e "s/\s*\([0-9][0-9]*\)\s*\(.*\)/\1.$DNSFILE $DNSTIME IN TXT \"\2\"/" +} +encode_raw_line() { + # DJBDNS: + sed -e 's/\\/\\134/g' -e 's/:/\\072/g' -e "s/\(.*\)/'$1:\1:$DNSTIME/" + # BIND: + # sed -e "s/\(.*\)/$1.$DNSFILE $DNSTIME IN TXT \"\1\"/" +} + +dosha() { + # Linux + sha1sum | cut -f 1 -d ' ' + # BSD + # sha1 | sed -e "s/.* \([0-9a-f]*\)\$/\1/" | +} + +uuencode `basename $FILE` < $FILE | cat -n | encode_counted_line "$DNSFILE" +cat $FILE | dosha | encode_raw_line "sha1.$DNSFILE"