@@ 157-168 (lines=12) @@ | ||
154 | vt_urls = vtapi3.VirusTotalAPIUrls(api_key) |
|
155 | try: |
|
156 | result = vt_urls.upload(url) |
|
157 | if vt_urls.get_last_http_error() == vt_urls.HTTP_OK: |
|
158 | result = json.loads(result) |
|
159 | url_id = result['data']['id'] |
|
160 | vt_analyses = vtapi3.VirusTotalAPIAnalyses(api_key) |
|
161 | result = vt_analyses.get_report(url_id) |
|
162 | if vt_analyses.get_last_http_error() == vt_analyses.HTTP_OK: |
|
163 | result = json.loads(result) |
|
164 | result = 'Analysis report:\n' + json.dumps(result, sort_keys=False, indent=4) |
|
165 | else: |
|
166 | result = 'HTTP error ' + str(vt_analyses.get_last_http_error()) |
|
167 | else: |
|
168 | result = 'HTTP error ' + str(vt_urls.get_last_http_error()) |
|
169 | return result |
|
170 | except vtapi3.VirusTotalAPIError as err: |
|
171 | return err |
|
@@ 60-71 (lines=12) @@ | ||
57 | vt_files = vtapi3.VirusTotalAPIFiles(api_key) |
|
58 | try: |
|
59 | result = vt_files.upload(file_path) |
|
60 | if vt_files.get_last_http_error() == vt_files.HTTP_OK: |
|
61 | result = json.loads(result) |
|
62 | file_id = str(result['data']['id']) |
|
63 | vt_analyses = vtapi3.VirusTotalAPIAnalyses(api_key) |
|
64 | result = vt_analyses.get_report(file_id) |
|
65 | if vt_analyses.get_last_http_error() == vt_analyses.HTTP_OK: |
|
66 | result = json.loads(result) |
|
67 | result = 'Analysis report:\n' + json.dumps(result, sort_keys=False, indent=4) |
|
68 | else: |
|
69 | result = 'HTTP error ' + str(vt_analyses.get_last_http_error()) |
|
70 | else: |
|
71 | result = 'HTTP error ' + str(vt_files.get_last_http_error()) |
|
72 | return result |
|
73 | except vtapi3.VirusTotalAPIError as err: |
|
74 | return err |