mirror of
				https://gitlab.com/gpvkt/twitchtts.git
				synced 2025-10-31 17:17:35 +01:00 
			
		
		
		
	Check until results are in completed state
This commit is contained in:
		
							parent
							
								
									f11b03507b
								
							
						
					
					
						commit
						9fd8c17889
					
				
					 1 changed files with 29 additions and 14 deletions
				
			
		
							
								
								
									
										43
									
								
								build.py
									
										
									
									
									
								
							
							
						
						
									
										43
									
								
								build.py
									
										
									
									
									
								
							|  | @ -6,6 +6,7 @@ | ||||||
| 
 | 
 | ||||||
| from pprint import pprint | from pprint import pprint | ||||||
| import time | import time | ||||||
|  | import os | ||||||
| 
 | 
 | ||||||
| import yaml | import yaml | ||||||
| import requests | import requests | ||||||
|  | @ -19,34 +20,48 @@ apikey = cfg['virustotal'] | ||||||
| 
 | 
 | ||||||
| PyInstaller.__main__.run(['tts.py', '--onefile',]) | PyInstaller.__main__.run(['tts.py', '--onefile',]) | ||||||
| 
 | 
 | ||||||
| print("Uploading file", end="") | os.replace("./dist/tts.exe", "./tts.exe") | ||||||
|  | 
 | ||||||
|  | print("Uploading file") | ||||||
| api_endpoint = "https://www.virustotal.com/api/v3/files" # pylint: disable=invalid-name | api_endpoint = "https://www.virustotal.com/api/v3/files" # pylint: disable=invalid-name | ||||||
| headers = { | headers = { | ||||||
|     "Accept": "application/json", |     "Accept": "application/json", | ||||||
|     "X-Apikey": apikey |     "X-Apikey": apikey | ||||||
| } | } | ||||||
| files = {"file": open("./dist/tts.exe", "rb")} | files = {"file": open("./tts.exe", "rb")} | ||||||
| req = requests.post(api_endpoint, headers=headers, files=files) | req = requests.post(api_endpoint, headers=headers, files=files) | ||||||
| print(" [OK]") | print(" [OK]") | ||||||
| 
 | 
 | ||||||
| print("Waiting for results", end="") | data = {} | ||||||
| time.sleep(30) | data['data'] = {} | ||||||
|  | data['data']['attributes'] = {} | ||||||
|  | data['data']['attributes']['status'] = "incomplete" | ||||||
|  | 
 | ||||||
|  | print("Waiting for results") | ||||||
|  | while data['data']['attributes']['status'] != "completed": | ||||||
|  |     time.sleep(10) | ||||||
|  | 
 | ||||||
|  |     print( "[CHK]") | ||||||
|  |     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() | ||||||
|  | 
 | ||||||
| print(" [OK]") | print(" [OK]") | ||||||
| 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() |  | ||||||
| 
 | 
 | ||||||
| try: | try: | ||||||
|     pprint(data['data']['attributes']['results']['Microsoft']) |     pprint(data['data']['attributes']['results']['Microsoft']) | ||||||
| except KeyError: | except KeyError: | ||||||
|     pass |     pass | ||||||
|  | 
 | ||||||
| pprint(data['data']['attributes']['stats']) | pprint(data['data']['attributes']['stats']) | ||||||
| print(data['data']['attributes']['status']) |  | ||||||
| print("https://www.virustotal.com/gui/file/"+str(data['meta']['file_info']['sha256'])) | print("https://www.virustotal.com/gui/file/"+str(data['meta']['file_info']['sha256'])) | ||||||
| 
 | 
 | ||||||
| if data['data']['attributes']['results']['Microsoft']['category'] != "undetected": | try: | ||||||
|     print('FILE WILL BE DETECTED AS MALICIOUS. PLEASE RECOMPILE!') |     if data['data']['attributes']['results']['Microsoft']['category'] != "undetected": | ||||||
|  |         print('FILE WILL BE DETECTED AS MALICIOUS. PLEASE RECOMPILE!') | ||||||
|  | except KeyError: | ||||||
|  |     pass | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue