Last active
June 29, 2021 09:56
-
-
Save trietptm/bcac72ff9f74baadc2a1 to your computer and use it in GitHub Desktop.
Shell script to check files quickly using VirusTotal service (https://www.virustotal.com) https://bbs.archlinux.org/viewtopic.php?id=56646&p=81 http://www.linuxac.org/forum/threads/59924-%D9%81%D8%AD%D8%B5-%D8%A7%D9%84%D9%85%D9%84%D9%81%D8%A7%D8%AA-%D8%A8%D8%A7%D9%84%D8%A5%D8%B3%D8%AA%D8%B9%D8%A7%D9%86%D8%A9-%D8%A8%D8%AE%D8%AF%D9%85%D8%A9-VirusT…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Shell script to scan files using VirusTotal service (https://www.virustotal.com) | |
# | |
# Author : saf1 | |
# Home : http://www.linuxac.org | |
# Date : Mon Aug 20 2012 | |
# Dependencies : md5sum, curl, And don't forget to be connected | |
help(){ | |
echo -e "\nThis is a Shell-Script that help you to scan your files" | |
echo -e "using VirusTotal service (https://www.virustotal.com)\n" | |
echo -e "Usage : ./${0##*/} [OPTION] [File][Directory]" | |
echo -e " Available Options:" | |
echo -e " -f [file] Scan file" | |
echo -e " -d [directory] Scan all the contents of the directory" | |
echo -e " -h Show this help\n" | |
} | |
scan(){ | |
file="$1" | |
md5="$(md5sum "$file" | awk '{print $1}')" | |
url="https://www.virustotal.com/file/${md5}/analysis/" | |
result="$(curl -s --head --connect-timeout 3 --retry 1 $url | awk '/HTTP/ {print $2}')" | |
if [ "$result" == "200" ]; then | |
ratio="$(curl -s $url | grep '<td class=\" text-.*</td>' | cut -d'>' -f2 | cut -d'<' -f1)" | |
if [ "${ratio:0:1}" == "0" ];then | |
status="\033[1;32mClean\033[0m" | |
else | |
status="\033[1;31mInfected\033[0m" | |
fi | |
echo -e "\nFile : $file" | |
echo -e "MD5 : $md5" | |
echo -e "Status : $status" | |
echo -e "Detection ratio : $ratio" | |
echo -e "Raport : $url\n" | |
else | |
echo -e "\nFile : $file" | |
echo -e "MD5 : $md5" | |
echo -e "Status : \033[36mSuspected\033[0m\n" | |
fi | |
} | |
case "$1" in | |
-d) | |
if [ ! -d "$2" ]; then | |
echo -e "\n[!] cannot access $2: No such directory\n" | |
exit 1 | |
else | |
export -f scan | |
find "$2" -type f -exec bash -c "scan \"{}\"" \; | |
fi | |
;; | |
-f) | |
if [ ! -f "$2" ] ; then | |
echo -e "\n[!] cannot access $2: No such file\n" | |
exit 1 | |
else | |
scan "$2" | |
fi | |
;; | |
*) | |
help | |
;; | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Shell script to scan files using VirusTotal service (https://www.virustotal.com) | |
# | |
# Author : saf1 | |
# Home : http://www.linuxac.org | |
# Date : Mon Aug 20 04:00:52 WEST 2012 | |
# Dependencies : md5sum, curl, And don't forget to be connected | |
help(){ | |
echo "This is a Shell-Script that help you to scan your files using VirusTotal service" | |
echo "(https://www.virustotal.com)" | |
echo | |
echo "Usage : ./${0##*/} [OPTION] {COMMAND}" | |
echo " Available Options:" | |
echo " -f [file] Scan file" | |
echo " -d [directory] Scan all the contents of the directory" | |
echo " -h Show this help" | |
echo | |
} | |
scan(){ | |
file="$1" | |
md5="$(md5sum $file | awk '{print $1}')" | |
url="https://www.virustotal.com/file/${md5}/analysis/" | |
result="$(curl -s --head --connect-timeout 3 --retry 1 $url | awk '/HTTP/ {print $2}')" | |
if [ "$result" == "200" ]; then | |
ratio="$(curl -s $url | grep '<td class=\" text-.*</td>' | cut -d'>' -f2 | cut -d'<' -f1)" | |
if [ "${ratio:0:1}" == "0" ];then | |
status="\033[1;32mClean\033[0m" | |
else | |
status="\033[1;31mInfected\033[0m" | |
fi | |
echo -e "File : $file" | |
echo -e "MD5 : $md5" | |
echo -e "Status : $status" | |
echo -e "Detection ratio : $ratio" | |
echo -e "Raport : $url" | |
echo | |
else | |
echo -e "File : $file" | |
echo -e "MD5 : $md5" | |
echo -e "Status : \033[36mSuspected\033[0m" | |
echo | |
fi | |
} | |
case "$1" in | |
-d) | |
if [ ! -d "$2" ]; then | |
echo "[!] cannot access $2: No such directory" | |
echo | |
exit 1 | |
else | |
export -f scan | |
find "$2" -type f -exec bash -c 'scan "{}"' \; | |
fi | |
;; | |
-f) | |
if [ ! -f "$2" ] ; then | |
echo "[!] cannot access $2: No such file" | |
echo | |
exit 1 | |
else | |
scan "$2" | |
fi | |
;; | |
*) | |
help | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: bash virustotal-scan.txt -f c99.php