#!/bin/bash
TOKEN=$(curl -k https://clamav-ui.com/api/v1/auth -X GET --silent | python -c "import json, sys; print json.load(sys.stdin)['data']['token']")
echo $1
echo $TOKEN
for FILE in $1/*; do
JSON=$(curl -k https://clamav-ui.com/api/v1/scan -H"Authorization":"$TOKEN" -X POST -F "Content-Disposition:form-data:name='file'" -F "file=@$FILE" --silent)
ISINF=$(echo $JSON | python -c "import json, sys; print json.load(sys.stdin)['data']['files'][0]['infected']")
MD5=$(echo $JSON | python -c "import json, sys; print json.load(sys.stdin)['data']['files'][0]['md5']")
FILENAME=$(echo $JSON | python -c "import json, sys; print json.load(sys.stdin)['data']['files'][0]['fileName']")
if [ "$ISINF" == "True" ] ; then
echo $FILENAME $ISINF $MD5
fi
done