Last active
August 29, 2015 13:57
-
-
Save stqism/9923240 to your computer and use it in GitHub Desktop.
Tox DNS Discovery scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#Compile other/fun/sign.c from ProjectTox-Core and put it here named sign | |
#generate a keypair with ./sign g | |
#sh dns2key.sh v=tox1;etc {signing key} | |
DNS=$1 | |
TOXVER=`echo -n $DNS | tr ';:"\\\/' '\n' | grep tox | tr '=' ' ' | awk '{print $NF}'` | |
case $TOXVER in | |
tox1) | |
ID=`echo -n $DNS | tr ';:"\\\/' '\n' | grep id | tr '=' ' ' | awk '{print $NF}'` | |
echo $ID > .tox | |
./sign s $2 .tox .toxsign | |
SIGN=`cat .toxsign | tail -n 1 | base64 -w0 | tr -d '='` | |
rm .tox .toxsign | |
LOOKUP="v=tox1;id=$ID;sign=$SIGN" | |
;; | |
tox2) | |
PUB=`echo -n $DNS | tr ';:"\\\/' '\n' | grep pub | tr '=' ' ' | awk '{print $NF}'` | |
CHECK=`echo -n $DNS | tr ';:"\\\/' '\n' | grep check | tr '=' ' ' | awk '{print $NF}'` | |
ID=$PUB$CHECK | |
echo $ID > .tox | |
./sign s $2 .tox .toxsign | |
SIGN=`cat .toxsign | tail -n 1 | base64 -w0 | tr -d '='` | |
rm .tox .toxsign | |
LOOKUP="v=tox2;pub=$PUB;check=$CHECK;sign=$SIGN" | |
;; | |
*) | |
echo "Invalid DNS record" | |
exit 1 | |
;; | |
esac | |
echo $LOOKUP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#For tox1 entries it expects just the email like ID | |
#sh dns2tox.sh steve@toxusers.com | |
#for tox2 entries it expects the email like ID and pin | |
#sh dns2tox.sh steve@toxusers.com 2ky9f+ | |
case $1 in | |
*@*) | |
ID=`echo $1 | tr ':/' ' ' | sed 's/@/._tox./' | awk '{print $NF}'` | |
DNS=`dig TXT $ID +short` | |
TOXVER=`echo -n $DNS | tr ';:"\\\/' '\n' | grep tox | tr '=' ' ' | awk '{print $NF}'` | |
case $TOXVER in | |
tox1) | |
LOOKUP=`echo -n $DNS | tr ';:"\\\/' '\n' | grep id | tr '=' ' ' | awk '{print $NF}'` | |
;; | |
tox2) | |
PUB=`echo -n $DNS | tr ';:"\\\/' '\n' | grep pub | tr '=' ' ' | awk '{print $NF}'` | |
CHECK=`echo -n $DNS | tr ';:"\\\/' '\n' | grep check | tr '=' ' ' | awk '{print $NF}'` | |
NOSPAM=`echo -n "$2==" | base64 -d | xxd -p | tr '[:lower:]' '[:upper:]'` | |
LOOKUP=$PUB$NOSPAM$CHECK | |
;; | |
*) | |
echo "Invalid DNS record" | |
exit 1 | |
;; | |
esac | |
;; | |
*) | |
ID=`echo $1 | tr ':/' ' ' | awk '{print $NF}'` | |
LOOKUP=$ID | |
;; | |
esac | |
echo $LOOKUP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#turns a Tox ID in to a dns record and pin | |
#sh tox2dns.sh DF157E229E5A6446E58F30F7281D69E0A9F952DA644D5A86DC7D16DE35B5395FADBFE61A87AA | |
if [ ${#1} != 76 ]; | |
then | |
echo "Invalid ID! Tox IDs are 76 characters, not ${#1}" | |
exit 1 | |
else | |
TEMP=`echo $1 | fold -w64` | |
PUB=`echo $TEMP | cut -d ' ' -f 1` | |
NOSUM=`echo $TEMP | cut -d ' ' -f 2 | fold -w8` | |
PIN=`echo $NOSUM | cut -d ' ' -f 1 | xxd -p -r | base64 | tr -d '='` | |
CHECKSUM=`echo $NOSUM | cut -d ' ' -f 2` | |
echo "Your DNS discovery record is 'v=tox2;pub=$PUB;check=$CHECKSUM'" | |
echo "Your PIN is $PIN" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#sh vanitypin.sh 000000 path/to/tox/data | |
if [ ${#1} != 6 ]; | |
then | |
echo "A pin is 6 characters" | |
exit 1 | |
else | |
CALC=`echo -n "$1==" | base64 -d | dd of=$2 bs=1 seek=16 count=8 conv=notrunc` | |
echo Patched your data file! | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python-fork for tox2dns and dns2tox.. singing not included yet..
https://gist.github.com/skamster/9963661