2022-08-19 02:59:27 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# pylint: disable=line-too-long,too-many-lines
|
|
|
|
|
|
|
|
""" buildscript """
|
|
|
|
|
|
|
|
from pprint import pprint
|
|
|
|
import time
|
2022-08-19 03:09:53 +02:00
|
|
|
import os
|
2022-08-19 02:59:27 +02:00
|
|
|
|
|
|
|
import yaml
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import PyInstaller.__main__
|
|
|
|
|
|
|
|
with open("config.yml", "r", encoding="UTF-8") as ymlfile:
|
|
|
|
cfg = yaml.load(ymlfile, Loader=yaml.Loader)
|
|
|
|
|
|
|
|
apikey = cfg['virustotal']
|
|
|
|
|
|
|
|
PyInstaller.__main__.run(['tts.py', '--onefile',])
|
|
|
|
|
2022-08-19 03:09:53 +02:00
|
|
|
os.replace("./dist/tts.exe", "./tts.exe")
|
|
|
|
|
|
|
|
print("Uploading file")
|
2022-08-19 02:59:27 +02:00
|
|
|
api_endpoint = "https://www.virustotal.com/api/v3/files" # pylint: disable=invalid-name
|
|
|
|
headers = {
|
|
|
|
"Accept": "application/json",
|
|
|
|
"X-Apikey": apikey
|
|
|
|
}
|
2022-08-19 03:09:53 +02:00
|
|
|
files = {"file": open("./tts.exe", "rb")}
|
2022-08-19 02:59:27 +02:00
|
|
|
req = requests.post(api_endpoint, headers=headers, files=files)
|
|
|
|
print(" [OK]")
|
|
|
|
|
2022-08-19 03:09:53 +02:00
|
|
|
data = {}
|
|
|
|
data['data'] = {}
|
|
|
|
data['data']['attributes'] = {}
|
|
|
|
data['data']['attributes']['status'] = "incomplete"
|
|
|
|
|
|
|
|
print("Waiting for results")
|
|
|
|
while data['data']['attributes']['status'] != "completed":
|
|
|
|
time.sleep(10)
|
|
|
|
|
2022-08-19 04:38:19 +02:00
|
|
|
print( " [CHK]")
|
2022-08-19 03:09:53 +02:00
|
|
|
data = req.json()
|
|
|
|
api_endpoint = f"https://www.virustotal.com/api/v3/analyses/{data['data']['id']}"
|
|
|
|
headers = {
|
|
|
|
'X-Apikey': apikey
|
|
|
|
}
|
|
|
|
req = requests.get(api_endpoint, headers=headers)
|
|
|
|
data = req.json()
|
|
|
|
|
2022-08-19 02:59:27 +02:00
|
|
|
print(" [OK]")
|
|
|
|
|
|
|
|
try:
|
|
|
|
pprint(data['data']['attributes']['results']['Microsoft'])
|
|
|
|
except KeyError:
|
|
|
|
pass
|
2022-08-19 03:09:53 +02:00
|
|
|
|
2022-08-19 02:59:27 +02:00
|
|
|
pprint(data['data']['attributes']['stats'])
|
|
|
|
print("https://www.virustotal.com/gui/file/"+str(data['meta']['file_info']['sha256']))
|
|
|
|
|
2022-08-19 03:09:53 +02:00
|
|
|
try:
|
|
|
|
if data['data']['attributes']['results']['Microsoft']['category'] != "undetected":
|
|
|
|
print('FILE WILL BE DETECTED AS MALICIOUS. PLEASE RECOMPILE!')
|
|
|
|
except KeyError:
|
|
|
|
pass
|