use jp on path (and get/build it if not available)

This commit is contained in:
Justin Bastress 2019-01-18 13:33:23 -05:00
parent 65a215407a
commit 108ce0a0ab
6 changed files with 21 additions and 16 deletions

View File

@ -17,9 +17,9 @@ function test_cups() {
CONTAINER_NAME="zgrab_ipp_cups" $ZGRAB_ROOT/docker-runner/docker-run.sh ipp --timeout 3s --verbose > "$OUTPUT_ROOT/cups.json"
# FIXME: No good reason to use a tmp file & saved file, b/c I'm not testing any failure states yet
#CONTAINER_NAME="zgrab_ipp_cups" $ZGRAB_ROOT/docker-runner/docker-run.sh ipp --timeout 3 --verbose > out.tmp
major=$($ZGRAB_ROOT/jp -u data.ipp.result.version_major < "$OUTPUT_ROOT/cups.json")
minor=$($ZGRAB_ROOT/jp -u data.ipp.result.version_minor < "$OUTPUT_ROOT/cups.json")
cups=$($ZGRAB_ROOT/jp -u data.ipp.result.cups_version < "$OUTPUT_ROOT/cups.json")
major=$(jp -u data.ipp.result.version_major < "$OUTPUT_ROOT/cups.json")
minor=$(jp -u data.ipp.result.version_minor < "$OUTPUT_ROOT/cups.json")
cups=$(jp -u data.ipp.result.cups_version < "$OUTPUT_ROOT/cups.json")
rm -f out.tmp
if ! [ $major = "2" ]; then
echo "ipp/test: Incorrect major version. Expected 2, got $major"
@ -41,12 +41,12 @@ function test_cups_tls() {
CONTAINER_NAME="zgrab_ipp_cups-tls" $ZGRAB_ROOT/docker-runner/docker-run.sh ipp --timeout 3s --ipps --verbose > "$OUTPUT_ROOT/cups-tls.json"
# FIXME: No good reason to use a tmp file & saved file, b/c I'm not testing any failure states yet
#CONTAINER_NAME="zgrab_ipp_cups-tls" $ZGRAB_ROOT/docker-runner/docker-run.sh ipp --timeout 3 --ipps --verbose > out.tmp
major=$($ZGRAB_ROOT/jp -u data.ipp.result.version_major < "$OUTPUT_ROOT/cups-tls.json")
minor=$($ZGRAB_ROOT/jp -u data.ipp.result.version_minor < "$OUTPUT_ROOT/cups-tls.json")
response=$($ZGRAB_ROOT/jp -u data.ipp.result.response < "$OUTPUT_ROOT/cups-tls.json")
cups=$($ZGRAB_ROOT/jp -u data.ipp.result.cups_version < "$OUTPUT_ROOT/cups-tls.json")
major=$(jp -u data.ipp.result.version_major < "$OUTPUT_ROOT/cups-tls.json")
minor=$(jp -u data.ipp.result.version_minor < "$OUTPUT_ROOT/cups-tls.json")
response=$(jp -u data.ipp.result.response < "$OUTPUT_ROOT/cups-tls.json")
cups=$(jp -u data.ipp.result.cups_version < "$OUTPUT_ROOT/cups-tls.json")
# TODO: Check for a particular field in the tls object, since it may be safer
tls=$($ZGRAB_ROOT/jp -u data.ipp.result.tls < "$OUTPUT_ROOT/cups-tls.json")
tls=$(jp -u data.ipp.result.tls < "$OUTPUT_ROOT/cups-tls.json")
#rm -f out.tmp
if ! [ $major = "2" ]; then
echo "ipp/test: Incorrect major version. Expected 2, got $major"

View File

@ -20,7 +20,7 @@ function doTest() {
OUTPUT_FILE="$ZGRAB_OUTPUT/mysql/$MYSQL_VERSION.json"
echo "mysql/test: Testing MySQL Version $MYSQL_VERSION..."
CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh mysql --timeout 10s > $OUTPUT_FILE
SERVER_VERSION=$($ZGRAB_ROOT/jp -u data.mysql.result.server_version < $OUTPUT_FILE)
SERVER_VERSION=$(jp -u data.mysql.result.server_version < $OUTPUT_FILE)
if [[ "$SERVER_VERSION" == "$MYSQL_VERSION."* ]]; then
echo "mysql/test: Server version matches expected version: $SERVER_VERSION == $MYSQL_VERSION.*"
else

View File

@ -19,8 +19,8 @@ function test_openntp() {
# Don't drop this in the standard output root, since it will not have status = success
CONTAINER_NAME="zgrab_ntp_openntp" $ZGRAB_ROOT/docker-runner/docker-run.sh ntp --timeout 3s --monlist > out.tmp
time=$($ZGRAB_ROOT/jp -u data.ntp.result.time < out.tmp)
version=$($ZGRAB_ROOT/jp -u data.ntp.result.version < out.tmp)
time=$(jp -u data.ntp.result.time < out.tmp)
version=$(jp -u data.ntp.result.version < out.tmp)
rm -f out.tmp
if [ $time = "null" ]; then
echo "ntp/test: Failed to get partial result from monlist on openntp (time = null)"
@ -36,8 +36,8 @@ function test_bad_req() {
code=$1
expected_error=$2
CONTAINER_NAME="zgrab_ntp_4.2.6" $ZGRAB_ROOT/docker-runner/docker-run.sh ntp --timeout 3s --monlist --request-code $code --skip-get-time > out.tmp
status=$($ZGRAB_ROOT/jp -u data.ntp.status < out.tmp)
error=$($ZGRAB_ROOT/jp -u data.ntp.error < out.tmp)
status=$(jp -u data.ntp.status < out.tmp)
error=$(jp -u data.ntp.error < out.tmp)
rm -f out.tmp
if ! [ $status = "application-error" ]; then
echo "ntp/test: Got error '$error', expected '$expected_error' on $code"

View File

@ -25,7 +25,7 @@ status=0
for field in $FIELDS; do
for file in $(find $OUTPUT_ROOT -iname "*$field*.json"); do
echo "check $file for $field"
RESULT=$($ZGRAB_ROOT/jp data.pop3.result.$field < $file)
RESULT=$(jp data.pop3.result.$field < $file)
if [ "$RESULT" = "null" ]; then
echo "Did not find $field in $file [["
cat $file

View File

@ -26,7 +26,7 @@ status=0
for field in $FIELDS; do
for file in $(find $OUTPUT_ROOT -iname "*$field*.json"); do
echo "check $file for $field"
RESULT=$($ZGRAB_ROOT/jp data.smtp.result.$field < $file)
RESULT=$(jp data.smtp.result.$field < $file)
if [ "$RESULT" = "null" ]; then
echo "Did not find $field in $file [["
cat $file

View File

@ -33,6 +33,11 @@ cd "$ZGRAB_ROOT"
ZGRAB_OUTPUT="zgrab-output"
if ! which jp; then
go get github.com/jmespath/jp && go build github.com/jmespath/jp
export PATH=$PATH:$GOPATH/bin
fi
pushd integration_tests
for mod in $(ls); do
if [ ".template" != "$mod" ] && [ -d "$mod" ] && ( [ -z $TEST_MODULES ] || [ $mod = *"$TEST_MODULES"* ]); then
@ -79,7 +84,7 @@ for protocol in $(ls $ZGRAB_OUTPUT); do
fi
status=1
else
scan_status=$(./jp -u data.${protocol}.status < $target)
scan_status=$(jp -u data.${protocol}.status < $target)
if ! [ $scan_status = "success" ]; then
echo "Scan returned success=$scan_status for $protocol/$outfile"
err="scan failure(${scan_status})@$protocol/$outfile"