0

I am trying to fetch the json response using the VirusTotal API. To fetch the results as a response I have created a python script which is as shown below : Then error show like this : [Winerror]:10054 An existing connection was forcibly closed by the remote host

import requests

url = "https://www.virustotal.com/vtapi/v2/file/scan"

api_key = "MyApiKey"

params = {"apikey": api_key}

files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb")} 
try:
    response = requests.post(url, files=files, params=params)
    print(response.json())

except Exception as e:
    print(e)

enter image description here

Akshay Mewada
  • 181
  • 2
  • 9

2 Answers2

0

To provide more information, please try the following:

import requests

url = "https://www.virustotal.com/vtapi/v2/file/scan"

api_key = "MyApiKey"

params = {"apikey": api_key}

files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb"))} 
try:
    response = requests.post(url, files=files, params=params)
    print(response.json())

except Exception as e:
    print(e)

And post the error response you receive from the updated code.

  • Please find the screenshot – Akshay Mewada Jun 30 '21 at 06:01
  • I am not sure if this has anything to do with it, but you are missing a closing parens in your original post, and I somehow overlooked it in my response. Try the updated version of my answer. Sorry that I am not able to test before uploading my answer. Hopefully, it is just the silly typo that is breaking your code. Odd that your IDE did not catch it? – riskRewarded Jun 30 '21 at 07:45
  • Thanks for your reply. After hour of searching I have found out that the issue was not in the code actually. The issue was in the application that I tried to scan. I tried another application to fetch the scan report and it works well with same code. – Akshay Mewada Jul 01 '21 at 08:37
  • Glad to hear you solved the issue. Please consider posting or linking to the functional code that solved the problem for future searchers. I am also interested, as the example you posted is taken directly from the VirusTotal.com docs. Was it as simple as moving to the V3 API (which I suppose would mean v2 is deprecated?) – riskRewarded Jul 01 '21 at 19:56
0

This issue is resolved, The issue was encountered only for the skype.exe file. while scanning using malware machine learning.

Akshay Mewada
  • 181
  • 2
  • 9