Class: VirusTotal::Client::File

Inherits:
Base
  • Object
show all
Includes:
Action::Comments, Action::Get, Action::Relationships, Action::Votes
Defined in:
lib/virustotal/clients/file.rb

Constant Summary

Constants inherited from Base

Base::BASE_URL, Base::CONVERT_TABLE, Base::HOST, Base::VERSION

Instance Attribute Summary

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods included from Action::Votes

#add_vote, #votes

Methods included from Action::Relationships

#method_missing, #respond_to_missing?

Methods included from Action::Get

#get

Methods included from Action::Comments

#add_comment, #comments

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from VirusTotal::Client::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VirusTotal::Client::Action::Relationships

Instance Method Details

#analyse(hash) ⇒ Hash

Reanalyse a file already in VirusTotal

Parameters:

  • hash (String)

    SHA-256, SHA-1 or MD5 identifying the file

Returns:

  • (Hash)

See Also:



46
47
48
# File 'lib/virustotal/clients/file.rb', line 46

def analyse(hash)
  _post("/files/#{hash}/analyse") { |json| json }
end

#download(hash) ⇒ <Type>

Download a file

Parameters:

  • SHA-256, (String)

    SHA-1 or MD5 identifying the file

Returns:

  • (<Type>)

    <description>

See Also:



72
73
74
# File 'lib/virustotal/clients/file.rb', line 72

def download(hash)
  _get("/files/#{hash}/download") { |location| location }
end

#download_url(hash) ⇒ Hash

Get a download URL for a file

Parameters:

  • hash (String)

    SHA-256, SHA-1 or MD5 identifying the file

Returns:

  • (Hash)

See Also:



59
60
61
# File 'lib/virustotal/clients/file.rb', line 59

def download_url(hash)
  _get("/files/#{hash}/download_url") { |json| json }
end

#pcap(id) ⇒ Hash

Retrieve objects related to a file

Parameters:

  • id (String)

    SHA-256, SHA-1 or MD5 identifying the file

Returns:

  • (Hash)

See Also:



85
86
87
# File 'lib/virustotal/clients/file.rb', line 85

def pcap(id)
  _get("/file_behaviours/#{id}/pcap") { |raw| raw }
end

#upload(path) ⇒ Hash

Upload and analyse a file

Parameters:

  • path (String)

    File path to be scanned

Returns:

  • (Hash)

See Also:



20
21
22
23
24
# File 'lib/virustotal/clients/file.rb', line 20

def upload(path)
  name = ::File.basename(path)
  data = ::File.read(path)
  _post_with_file("/files", file: data, filename: name) { |json| json }
end

#upload_urlHash

Get a URL for uploading files larger than 32MB



33
34
35
# File 'lib/virustotal/clients/file.rb', line 33

def upload_url
  _get("/files/upload_url") { |json| json }
end