From da9ff0cc66929401f82cd6db2536288a187f8021 Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Sun, 14 May 2017 19:27:14 +1000 Subject: [PATCH 1/4] Tricorder: Insecure Opt-out * Check to see if Tricorder is being called directly * Provide opt-out for insecure transmission of debug log * Remove mention of internal function from help menu --- pihole | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index f24461d3..8cffb5b2 100755 --- a/pihole +++ b/pihole @@ -269,10 +269,24 @@ piholeCheckoutFunc() { } tricorderFunc() { + if [ ! -p "/dev/stdin" ]; then + echo "Please do not call Tricorder directly." + exit 1 + fi + if command -v openssl &> /dev/null; then openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin else - nc tricorder.pi-hole.net 9999 < /dev/stdin + echo "The debug log will be transmitted insecurely via plain-text" + echo "If you wish to cancel, press Ctrl-C to exit within 10 seconds" + secs="10" + while [ "$secs" -gt 0 ]; do + echo -ne "." + sleep 1 + : $((secs--)) + done + echo " " + nc tricorder.pi-hole.net 9999 < /dev/stdin < /dev/stdin fi } @@ -310,7 +324,6 @@ helpFunc() { ::: 'pihole disable 5m' - will disable blocking for 5 minutes ::: restartdns Restart dnsmasq ::: checkout Check out different branches -::: tricorder Upload log to Pi-hole's medical tricorder (uses SSL when possible) EOM exit 0 } From b9f2ba07173663d011f0bd4a2c2e7dea548ffac3 Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Tue, 16 May 2017 09:48:46 +1000 Subject: [PATCH 2/4] Wording changes and bug fix --- pihole | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 8cffb5b2..a630d67d 100755 --- a/pihole +++ b/pihole @@ -277,7 +277,8 @@ tricorderFunc() { if command -v openssl &> /dev/null; then openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin else - echo "The debug log will be transmitted insecurely via plain-text" + echo "Your debug log will be transmitted unencrypted via plain-text" + echo "There is a possibility that this could be intercepted by a third party" echo "If you wish to cancel, press Ctrl-C to exit within 10 seconds" secs="10" while [ "$secs" -gt 0 ]; do @@ -286,7 +287,7 @@ tricorderFunc() { : $((secs--)) done echo " " - nc tricorder.pi-hole.net 9999 < /dev/stdin < /dev/stdin + nc tricorder.pi-hole.net 9999 < /dev/stdin fi } From 1f3db8b6025e6f81b41d7d134ac07559ea6d8ead Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Thu, 18 May 2017 12:43:17 +1000 Subject: [PATCH 3/4] Confirm Tricorder is online * Scan port 9998 to confirm the availability of "tricorder.pi-hole.net" * Exit codes for upload process --- pihole | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pihole b/pihole index 11369ae1..3db64172 100755 --- a/pihole +++ b/pihole @@ -305,9 +305,15 @@ tricorderFunc() { echo "Please do not call Tricorder directly." exit 1 fi + + if ! timeout 2 nc -z tricorder.pi-hole.net 9998 &> /dev/null; then + echo "Unable to connect to Pi-hole's Tricorder server." + exit 1 + fi if command -v openssl &> /dev/null; then openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin + exit "$?" else echo "Your debug log will be transmitted unencrypted via plain-text" echo "There is a possibility that this could be intercepted by a third party" @@ -320,6 +326,7 @@ tricorderFunc() { done echo " " nc tricorder.pi-hole.net 9999 < /dev/stdin + exit "$?" fi } From a620a5c430f34e0c4bcd4ae906ee60aa982520bd Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Thu, 18 May 2017 12:53:32 +1000 Subject: [PATCH 4/4] Formatting consistency --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 3db64172..869db5ba 100755 --- a/pihole +++ b/pihole @@ -301,7 +301,7 @@ Branches: } tricorderFunc() { - if [ ! -p "/dev/stdin" ]; then + if [[ ! -p "/dev/stdin" ]]; then echo "Please do not call Tricorder directly." exit 1 fi @@ -319,7 +319,7 @@ tricorderFunc() { echo "There is a possibility that this could be intercepted by a third party" echo "If you wish to cancel, press Ctrl-C to exit within 10 seconds" secs="10" - while [ "$secs" -gt 0 ]; do + while [[ "$secs" -gt "0" ]]; do echo -ne "." sleep 1 : $((secs--))