Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] scoop-virustotal is not working #4965

Closed
ClassicDarkChocolate opened this issue Jun 4, 2022 · 5 comments · Fixed by #4988
Closed

[Bug] scoop-virustotal is not working #4965

ClassicDarkChocolate opened this issue Jun 4, 2022 · 5 comments · Fixed by #4988
Labels

Comments

@ClassicDarkChocolate
Copy link
Contributor

ClassicDarkChocolate commented Jun 4, 2022

Bug Report

Current Behavior

It seems that this exists for a long time.

> scoop virustotal imageglass
imageglass: VirusTotal request failed: The remote server returned an error: (429) Too Many Requests. 4

Expected Behavior

> scoop virustotal imageglass
imageglass: 0/, see https://www.virustotal.com/#/file/8ee32ec15d2135e3a69ba4916d01908bc450cce5/detection

Additional context/output

Possible Solution

System details

Windows version: [e.g. 7, 8, 10]

OS architecture: [e.g. 32bit, 64bit]

PowerShell version: [output of "$($PSVersionTable.PSVersion)"]

Additional software: [(optional) e.g. ConEmu, Git]

Scoop Configuration

//# Your configuration here
@rashil2000
Copy link
Member

Good catch! Can you make a PR?

@ClassicDarkChocolate
Copy link
Contributor Author

After some investigations, Web api is now protected by a 'X-VT-Anti-Abuse-Header' headder.

So even getting a simple scan result now requires a api key too.

diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1
index b7d16cfe..9ab7dd7b 100644
--- a/libexec/scoop-virustotal.ps1
+++ b/libexec/scoop-virustotal.ps1
@@ -81,10 +81,12 @@ $explained_rate_limit_sleeping = $False
 $requests = 0

 Function Get-VirusTotalResult($hash, $app) {
+    $api_key = get_config virustotal_api_key
     $hash = $hash.ToLower()
-    $url = "https://www.virustotal.com/ui/files/$hash"
+    $url = "https://www.virustotal.com/api/v3/files/$hash"
     $wc = New-Object Net.Webclient
     $wc.Headers.Add('User-Agent', (Get-UserAgent))
+    $wc.Headers.Add('x-apikey', $api_key)
     $result = $wc.downloadstring($url)
     $stats = json_path $result '$.data.attributes.last_analysis_stats'
     $malicious = json_path $stats '$.malicious'

@rashil2000
Copy link
Member

Can you give an example of package that asks for API key? I can still use the /gui link without errors.

@ClassicDarkChocolate
Copy link
Contributor Author

Can you give an example of package that asks for API key? I can still use the /gui link without errors.

It's embarrassing that the link I provided is not even valid. It's just that the scoop code consumes the invalid url and does not throw errors.

ClassicDarkChocolate pushed a commit to ClassicDarkChocolate/scoop that referenced this issue Jun 7, 2022
@ClassicDarkChocolate
Copy link
Contributor Author

I have had a tested fix done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants