aboutsummaryrefslogtreecommitdiff
path: root/src/data/proto
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/proto')
-rw-r--r--src/data/proto/hostinfo_req4
-rw-r--r--src/data/proto/hostinfo_rsp20
-rw-r--r--src/data/proto/hover12
-rw-r--r--src/data/proto/nybin_head8
-rwxr-xr-xsrc/data/proto/print-raw.sh2
-rw-r--r--src/data/proto/runbin26
-rw-r--r--src/data/proto/runcmd_demux21
-rw-r--r--src/data/proto/runcmd_detached16
-rw-r--r--src/data/proto/runcmd_empty-out_ab68
-rw-r--r--src/data/proto/runcmd_outonly20
-rwxr-xr-xsrc/data/proto/txtrec-del.sh64
-rwxr-xr-xsrc/data/proto/txtrec-enc.sh19
-rwxr-xr-xsrc/data/proto/txtrec-set.sh61
13 files changed, 341 insertions, 0 deletions
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"
+ 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CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
+ 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 <head rec> <hook> <zone id>
+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 <prefix>" >&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 <head rec> <hook> <zone id> [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"