1 | package org.greenstone.virustotal;
|
---|
2 | import com.kanishka.virustotal.dto.FileScanReport;
|
---|
3 | import com.kanishka.virustotal.dto.VirusScanInfo;
|
---|
4 | import com.kanishka.virustotal.exception.APIKeyNotFoundException;
|
---|
5 | import com.kanishka.virustotal.exception.UnauthorizedAccessException;
|
---|
6 | import com.kanishka.virustotalv2.VirusTotalConfig;
|
---|
7 | import com.kanishka.virustotalv2.VirustotalPublicV2;
|
---|
8 | import com.kanishka.virustotalv2.VirustotalPublicV2Impl;
|
---|
9 |
|
---|
10 | import java.io.*;
|
---|
11 | import java.util.*;
|
---|
12 | import java.lang.*;
|
---|
13 | import java.io.UnsupportedEncodingException;
|
---|
14 | import java.util.HashMap;
|
---|
15 | import java.util.Map;
|
---|
16 |
|
---|
17 |
|
---|
18 | public class GetFileScanReport {
|
---|
19 |
|
---|
20 |
|
---|
21 | public static void main(String[] args) {
|
---|
22 | try {
|
---|
23 | VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("09311639ef4193fc22faa35d493a5bf12dc44844a55f03812e40bd1a16fd7b6f");
|
---|
24 | VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
|
---|
25 |
|
---|
26 | String resourceID = null;
|
---|
27 | resourceID = args[0];
|
---|
28 | FileScanReport report = virusTotalRef.getScanReport(resourceID);
|
---|
29 |
|
---|
30 | System.out.println("MD5 :\t" + report.getMd5());
|
---|
31 | System.out.println("Perma link :\t" + report.getPermalink());
|
---|
32 | System.out.println("Resource :\t" + report.getResource());
|
---|
33 | System.out.println("Scan Date :\t" + report.getScanDate());
|
---|
34 | System.out.println("Scan Id :\t" + report.getScanId());
|
---|
35 | System.out.println("SHA1 :\t" + report.getSha1());
|
---|
36 | System.out.println("SHA256 :\t" + report.getSha256());
|
---|
37 | System.out.println("Verbose Msg :\t" + report.getVerboseMessage());
|
---|
38 | System.out.println("Response Code :\t" + report.getResponseCode());
|
---|
39 | System.out.println("Positives :\t" + report.getPositives());
|
---|
40 | System.out.println("Total :\t" + report.getTotal());
|
---|
41 |
|
---|
42 | Map<String, VirusScanInfo> scans = report.getScans();
|
---|
43 | for (String key : scans.keySet()) {
|
---|
44 | VirusScanInfo virusInfo = scans.get(key);
|
---|
45 | System.out.println("Scanner : " + key);
|
---|
46 | System.out.println("\t\t Resut : " + virusInfo.getResult());
|
---|
47 | System.out.println("\t\t Update : " + virusInfo.getUpdate());
|
---|
48 | System.out.println("\t\t Version :" + virusInfo.getVersion());
|
---|
49 | }
|
---|
50 |
|
---|
51 | } catch (APIKeyNotFoundException ex) {
|
---|
52 | System.err.println("API Key not found! " + ex.getMessage());
|
---|
53 | System.exit(1);
|
---|
54 | } catch (UnsupportedEncodingException ex) {
|
---|
55 | System.err.println("Unsupported Encoding Format!" + ex.getMessage());
|
---|
56 | System.exit(2);
|
---|
57 | } catch (UnauthorizedAccessException ex) {
|
---|
58 | System.err.println("Invalid API Key " + ex.getMessage());
|
---|
59 | System.exit(3);
|
---|
60 | } catch (Exception ex) {
|
---|
61 | System.err.println("Something Bad Happened! " + ex.getMessage());
|
---|
62 | System.exit(4);
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|