- Source:
Methods
-
<static> getDomainReport(resource, callback)
-
Retrieve a domain report
Parameters:
Name Type Description resourceString Domain name
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use getDomainReport().
- Type
- String
-
-
-
You need to define a callback for getDomainReport().
-
Example
virustotal.getDomainReport('example.org', function (err, res) { if (err) { console.error(err); return; } console.log(res); }); -
<static> getFileReport(resource, callback)
-
Retrieve a file scan report
Parameters:
Name Type Description resourcemodule:virustotal~virustotalResource A VirusTotal resource. The CSV list may have up to 4 items
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use getFileReport().
-
-
-
You need to define a callback for getFileReport().
-
Example
virustotal.getFileReport( '2fc19a61b81055c199f23de35b7eb8b2827e283442965bc1898c0e044563d836', function (err, res) { if (err) { console.error(err); return; } console.log(res); } ); -
<static> getIpReport(resource, callback)
-
Retrieve IP address report
Parameters:
Name Type Description resourceString An IPv4 address
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use getIpReport().
- Type
- String
-
-
-
You need to define a callback for getIpReport().
-
Example
virustotal.getIpReport('8.8.8.8', function (err, res) { if (err) { console.error(err); return; } console.log(res); }); -
<static> getUrlReport(resource, scan, callback)
-
Retrieve an URL scan report
Parameters:
Name Type Description resourceString An URL, a scan_id returned by module:virustotal.scanUrl, or a CSV list made of URLs and scan_ids. The CSV list may have up to 4 items
scanBoolean Optional; Set this to true to scan the URL if no report is found for it in VirusTotal's database
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use getUrlReport().
- Type
- String
-
-
-
You need to define a callback for getUrlReport().
-
Example
virustotal.getUrlReport('http://example.org/', function (err, res) { if (err) { console.error(err); return; } console.log(res); }); -
<static> makeComment(resource, comment, tags, callback)
-
Creates a new comment for file/URL
Parameters:
Name Type Description resourceString A module:virustotal~virustotalResource or URL submitted via module:virustotal.scanUrl
commentString The comment
tagsArray Optional; List of tags to prepend to the comment
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use makeComment().
- Type
- String
-
-
-
You need to define a callback for makeComment().
-
Example
virustotal.makeComment( '2fc19a61b81055c199f23de35b7eb8b2827e283442965bc1898c0e044563d836', 'Yahoo! Messenger installer.', ['goodware', 'clean'], function (err, res) { if (err) { console.error(err); return; } console.log(res); } ); -
<static> rescanFile(resource, callback)
-
Rescan already submitted files
Parameters:
Name Type Description resourcemodule:virustotal~virustotalResource A VirusTotal resource. The CSV list may have up to 25 items
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use rescanFile().
-
-
-
You need to define a callback for rescanFile().
-
Example
virustotal.rescanFile( '2fc19a61b81055c199f23de35b7eb8b2827e283442965bc1898c0e044563d836', function (err, res) { if (err) { console.error(err); return; } console.log(res); } ); -
<static> scanFile(resource, callback)
-
Send and scan a file
Parameters:
Name Type Description resourceMixed a String for a disk path or a module:virustotal~streamWrapper
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use scanFile().
- Type
- Mixed
-
-
-
You need to define a callback for scanFile().
-
Example
// scan a file stored to disk virustotal.scanFile('/path/to/file', function (err, res) { if (err) { console.error(err); return; } console.log(res); }); // wrapping a ReadStream created with fs.createReadStream virustotal.scanFile({ stream: fs.createReadStream('/path/to/file') }, function (err, res) { if (err) { console.error(err); return; } console.log(res); }); // wrapping an IncomingMessage (a HTTP response) http.get('http://example.org/file.exe', function (im) { virustotal.scanFile({ stream: im, // you may specify a filename // the form-data library may detect it from the IncomingMessage // but this could produce the wrong filename // your call filename: 'file.exe' }, function (err, res) { if (err) { console.error(err); return; } console.log(res); }); }); // wrapping a generic stream // in this case you need to specify both the filename and the size of the stream virustotal.scanFile({ stream: readableStream, filename: 'filename.exe', size: 1337 }, function (err, res) { if (err) { console.error(err); return; } console.log(res); }); -
<static> scanUrl(resource, callback)
-
Submit and scan a URL
Parameters:
Name Type Description resourceString An URL or a CSV list of up to 4 URLs
callbackmodule:virustotal~callback Completion callback
- Source:
Throws:
-
-
You need to define a resource argument in order to use scanUrl().
- Type
- String
-
-
-
You need to define a callback for scanUrl().
-
Example
virustotal.scanUrl('http://example.org/', function (err, res) { if (err) { console.error(err); return; } console.log(res); }); -
<static> setKey(apiKey)
-
Sets the VirusTotal API key
Parameters:
Name Type Description apiKeyString VirusTotal API key
- Source:
Example
// it is mandatory to call this before any other remote calls to the VirusTotal API virustotal.setKey('your-virustotal-api-key');
Type Definitions
-
callback(error, result)
-
The completion callback
Parameters:
Name Type Description errormodule:virustotal~error The passed error or null on success
resultmodule:virustotal~result The VirusTotal report or confirmation for succesful action
- Source:
-
error
-
The Error instance describing what went wrong. There are three types of errors. 1. A HTTP error which may happen under the conditions described by the Response basics, handled by the http-request library's stdError object. 2. If the JSON is corrupt, then the error is defined by the exception thrown by JSON.parse. 3. The last case of error is when the response_code property of the returned JSON does not equal to 1
Type:
- Error
- Source:
Properties:
Name Type Description jsonObject Defined when the parsed JSON has the response_code property different than 1. Contains the response from the VirusTotal API describing what went wrong. error.json.verbose_msg describes the error in detail
-
result
-
The result Object which is obtained by parsing the JSON response of the VirusTotal API. The result is passed to the success case only when its response_code equals to 1
Type:
- Object
- Source:
-
streamWrapper
-
The stream wrapper for uploading a file to the VirusTotal API by using module:virustotal.scanFile
Type:
- Object
- Source:
Properties:
Name Type Description streamObject Mandatory; The Readable Stream instance
filenameString Optional; The file name of the resource. This property recommended for streams that are a http.IncommingMessage, and mandatory for generic Readable Streams
sizeNumber Optional; The size of the stream. It is mandatory to define this property for streams with unknown length. This includes a http.IncomingMessage that uses chunked transfer which does not pass a content-length header. The content-lenght header value is used only when the size property is undefined. Compressed responses with gzip or deflate provide a wrong value for the size property, therefore it is recommended to avoid using HTTP compression if you wish to use the content-length value
-
virustotalResource
-
md5/sha1/sha256 file hash, a scan_id (sha256-timestamp as returned by module:virustotal.scanFile), or a CSV list made of a combination of hashes and scan_ids
Type:
- String
- Source: