Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Morning

I was trying to use this repo for my Android project based on Java: GitHub - tushroy/virus-total: A Java API for VirusTotal[^]

The problem is that this repo is updated to 2013, and the provided link (inside Virustotal.Java) returns error 404, so VirusTotal link is outdated.

Would you please help me to make this repo working again? I'm not the owner of it, so I am trying to make it work inside my Android project, and not to edit it in GitHub.

Thanks in advance,

F.

What I have tried:

I have tried to adapt it for an Android project, so inside MainActivity.class it is:

Java
[...]


   private void getAllFilesOfDir(File directory) throws IOException {
        Log.d("get files", "Directory: " + directory.getAbsolutePath() + "\n");

        final File[] files = directory.listFiles();

        if ( files != null ) {
            for ( File file : files ) {
                if ( file != null ) {
                    if ( file.isDirectory() ) {  // it is a folder...
                        getAllFilesOfDir(file);
                    }
                    else {  // it is a file...
                        Log.d("files", "File: " + file.getAbsolutePath() + "\n");

                        System.out.println("[*] Scanning file: " + file);

                        byte[] data = FileUtils.readFileToByteArray(file);

                        String sha256Hex = DigestUtils.sha256Hex(data);

                        //The VirusTotal class allows you to search for results using various hashes
                        //and details as supported on the VirusTotal search functionality.
                        Set<Report> reports = VirusTotal.scan(sha256Hex);

                        //Output the details of each scan result from a vendor
                        for (Report report : reports) {
                            System.out.println(report.getVendor() + " - " + report.getMalwarename());
                            Log.e("report virus",report.getVendor() + " - " + report.getMalwarename());
                        }

                     
                    }
                }
            }
        }
    }
Posted
Updated 31-Aug-20 6:38am
v3
Comments
Richard MacCutchan 31-Aug-20 11:29am    
What is the problem?
Just_F 31-Aug-20 11:33am    
Hi, thanks for the help
The problem is that in this class https://github.com/tushroy/virus-total/blob/master/src/com/api/virustotal/VirusTotal.java if you check the website https://www.virustotal.com/en/file/%s/analysis/ you get a 404 error, so when you implement it in the app, you don't get results
Richard MacCutchan 31-Aug-20 11:37am    
You need to use a string formatter to replace the %s with some real data that VirusTotal can use.
Just_F 31-Aug-20 12:45pm    
Already done: String VT_URL = String.format(URL_VIRUS_TOTAL, keyword);
Richard MacCutchan 31-Aug-20 12:51pm    
What is the actual value of the URL that you are sending?

1 solution

 
Share this answer
 
Comments
Just_F 31-Aug-20 12:37pm    
Hi
I've updated the app, but the problem is that it looks as if it doesn't connect to the net.
What I've tried: instead of https://www.virustotal.com/en/file/%s/analysis/ I've updated to https://www.virustotal.com/gui/file/%s/detection/ but I don't get results: I don't retrieve errors or results. Updated code in main post. I don't get logs for "report virus" but not even for generic errors. It looks as if it cannot connect to the website, even if I have the permission to do that (via manifest)
Richard MacCutchan 31-Aug-20 12:49pm    
That URL is not valid, you must replace the %s with a value that leads to an actual page on the VirusTotal website. This is not a coding or permissions issue. You need to go to the VirusTotal website and learn how to use their service.
Just_F 31-Aug-20 12:52pm    
As written above, there's already: String VT_URL = String.format(URL_VIRUS_TOTAL, keyword); where keyword is the actual SHA256 needed. Just see an example: https://www.virustotal.com/gui/file/1cfe9f6b9b7ddc7dca8cb24eb0687c4c84693ba9cdb2ee6295833ffd25f33cc3/detection
Richard MacCutchan 31-Aug-20 14:23pm    
Well that works fine, so what is the issue?
Just_F 3-Sep-20 10:23am    
The issue is that the app with this integration (as shown in GitHub, but with the updated link) receives neither data nor errors, even if I set all the permissions correctly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900