Pedro Bento commited on
Commit
5278818
·
1 Parent(s): b1ceeff

Added Virus total interface

Browse files
Files changed (1) hide show
  1. tdagent/tools/virus_total.py +54 -0
tdagent/tools/virus_total.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import vt
3
+ import os
4
+ from datetime import datetime
5
+
6
+ # Get API key from environment variable
7
+ API_KEY = os.getenv('VT_API_KEY')
8
+
9
+
10
+ def get_url_info(url):
11
+ try:
12
+ # Initialize the client
13
+ client = vt.Client(API_KEY)
14
+
15
+ # URL ID is created by computing the base64-encoded SHA-256 of the URL
16
+ url_id = vt.url_id(url)
17
+
18
+ # Get the URL analysis
19
+ url_analysis = client.get_object(f"/urls/{url_id}")
20
+
21
+ # Format the results
22
+ last_analysis_stats = url_analysis.last_analysis_stats
23
+ last_analysis_date = datetime.utcfromtimestamp(url_analysis.last_analysis_date).strftime(
24
+ '%Y-%m-%d %H:%M:%S UTC')
25
+
26
+ result = f"""
27
+ URL: {url}
28
+ Last Analysis Date: {last_analysis_date}
29
+
30
+ Analysis Statistics:
31
+ - Harmless: {last_analysis_stats['harmless']}
32
+ - Malicious: {last_analysis_stats['malicious']}
33
+ - Suspicious: {last_analysis_stats['suspicious']}
34
+ - Undetected: {last_analysis_stats['undetected']}
35
+ - Timeout: {last_analysis_stats['timeout']}
36
+
37
+ Reputation Score: {url_analysis.reputation}
38
+ Times Submitted: {url_analysis.times_submitted}
39
+ """
40
+
41
+ client.close()
42
+ return result
43
+
44
+ except Exception as e:
45
+ return f"Error: {str(e)}"
46
+
47
+
48
+ gr_query_abuseipdb = gr.Interface(
49
+ fn=get_url_info,
50
+ inputs=["text"],
51
+ outputs="text",
52
+ title="VirusTotal URL Scanner",
53
+ description="Get URL Info from VirusTotal URL Scanner. Scan URL is not available",
54
+ )