Module: Uirusu::VTComment

Defined in:
lib/uirusu/vtcomment.rb

Overview

Module for submiting comments to Virustotal.com resources using the Virustotal.com public API

Constant Summary collapse

POST_URL =
"https://www.virustotal.com/vtapi/v2/comments/put"

Class Method Summary collapse

Class Method Details

.post_comment(api_key, resource, comment) ⇒ JSON

Submits a comment to Virustotal.com for a specific resource

Parameters:

  • api_key (String)

    Virustotal.com API key

  • resource (String)

    MD5/sha1/sha256/scan_id to search for

  • comment (String)

    Comment to post to the resource

Returns:

  • (JSON)

    Parsed response



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/uirusu/vtcomment.rb', line 14

def self.post_comment(api_key, resource, comment)
	if api_key == nil
		raise "Invalid API Key"
	end
	
	if resource == nil
		raise "Invalid resource, must be a valid url"
	end
	
	if comment == nil
		raise "You must provide a comment to submit."
	end
	
	response = RestClient.post POST_URL, :apikey => api_key, :resource => resource, :comment => comment
	
	case response.code
		when 429
			raise "Virustotal limit reached. Try again later."
		when 403
			raise "Invalid privileges, please check your API key."
		when 200
			JSON.parse(response)
		else
			raise "Unknown Server error."
	end
end