Last active
April 7, 2020 12:48
-
-
Save ashleykleynhans/a924728f6893dc78017b2013486107dd to your computer and use it in GitHub Desktop.
This file contains 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/python | |
import pyclamd | |
import sys | |
import time | |
start = time.time() | |
try: | |
if len(sys.argv) != 2: | |
print('Usage: {} <filename>'.format(sys.argv[0])) | |
print('Eg: {} out.aac'.format(sys.argv[0])) | |
raise Exeption('Invalid Arguments') | |
filename = sys.argv[1] | |
f = open(filename, 'r') | |
content = f.read() | |
f.close() | |
cd = pyclamd.ClamdNetworkSocket(host='example.com', port=3310, timeout=5) | |
print('PINGING CLAMAV SERVER...'); | |
if cd.ping(): | |
print('PING SUCCESSFUL!') | |
print('SCANNING...') | |
res = cd.scan_stream(content) | |
if res is None: | |
print('CLEAN - NO VIRUS FOUND') | |
else: | |
print('VIRUS FOUND!!!!!!') | |
else: | |
print('PING FAILED!') | |
raise Exception('Unable to ping ClamAV Server') | |
except Exception as r: | |
sys.exit(1) | |
end = time.time() | |
print('Scan performed in {} seconds'.format(end - start)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment