From: Daniel Lenski
Date: Mon, 17 Dec 2018 00:49:58 +0000 (-0800)
Subject: make csd-post.sh continue with a warning without xmlstarlet (using Poor Man's vary...
X-Git-Tag: v8.00~13^2
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=959ef959b6064c26e76db958d0d6be098787cbd1;p=users%2Fdwmw2%2Fopenconnect.git
make csd-post.sh continue with a warning without xmlstarlet (using Poor Man's vary speshul XML parsing)
---
diff --git a/trojans/csd-post.sh b/trojans/csd-post.sh
index f8f61264..df3ea34d 100755
--- a/trojans/csd-post.sh
+++ b/trojans/csd-post.sh
@@ -12,9 +12,13 @@
# server's security policy with lies. This script exists as an example
# to work from.
-if ! xmlstarlet --version > /dev/null; then
- echo "No xmlstarlet found"
- exit 1;
+if ! xmlstarlet --version > /dev/null 2>&1; then
+ echo "************************************************************************" >&2
+ echo "WARNING: xmlstarlet not found in path; CSD token extraction may not work" >&2
+ echo "************************************************************************" >&2
+ unset XMLSTARLET
+else
+ XMLSTARLET=true
fi
DATA='endpoint.os.version="Linux";
@@ -64,7 +68,12 @@ done
PINNEDPUBKEY="-s ${CSD_SHA256:+"-k --pinnedpubkey sha256//$CSD_SHA256"}"
URL="https://$CSD_HOSTNAME/+CSCOE+/sdesktop/token.xml?ticket=$TICKET&stub=$STUB"
-COOKIE_HEADER="Cookie: sdesktop="$(curl $PINNEDPUBKEY -s "$URL" | xmlstarlet sel -t -v /hostscan/token)
+if [ -n "$XMLSTARLET" ]; then
+ TOKEN=$(curl $PINNEDPUBKEY -s "$URL" | xmlstarlet sel -t -v /hostscan/token)
+else
+ TOKEN=$(curl $PINNEDPUBKEY -s "$URL" | sed -n '//s^.*\(.*\)^\1^p' )
+fi
+COOKIE_HEADER="Cookie: sdesktop=$TOKEN"
CONTENT_HEADER="Content-Type: text/xml"
URL="https://$CSD_HOSTNAME/+CSCOE+/sdesktop/scan.xml?reusebrowser=1"
curl $PINNEDPUBKEY -H "$CONTENT_HEADER" -H "$COOKIE_HEADER" --data "$DATA;type=text/xml" "$URL"
diff --git a/www/csd.xml b/www/csd.xml
index b551a9ed..f7082c68 100644
--- a/www/csd.xml
+++ b/www/csd.xml
@@ -54,8 +54,7 @@ the trojans/ subdirectory:
csd-post.sh: This script does not actually run the CSD trojan binary. Instead, it emulates
the behaviour of the CSD trojan, creating a plaintext report similar to the one that the CSD trojans build, and
- uploading it to the server sent by the VPN gateway. It requires the xmlstarlet tool for parsing XML
- sent by the server, to extract a token value. The report may need to be customized in order to be accepted by some
+ uploading it to the server sent by the VPN gateway. The report may need to be customized in order to be accepted by some
servers; the hostscan-bypass tool may help with this.
Because this script does not actually execute a trojan binary, and because its complete output is easily visible
in the script, the security concerns are greatly alleviated.