|
@@ -1,44 +1,27 @@
|
|
package de.tudarmstadt.informatik.hostage.ui.fragment;
|
|
package de.tudarmstadt.informatik.hostage.ui.fragment;
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
-import android.content.pm.PackageInfo;
|
|
|
|
-import android.content.pm.PackageManager;
|
|
|
|
-import android.net.Uri;
|
|
|
|
-import android.os.Bundle;
|
|
|
|
import android.app.Fragment;
|
|
import android.app.Fragment;
|
|
-import android.text.method.LinkMovementMethod;
|
|
+import android.os.Bundle;
|
|
|
|
+import android.os.StrictMode;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.kanishka.virustotal.dto.FileScanReport;
|
|
+import java.io.IOException;
|
|
-import com.kanishka.virustotal.dto.ScanInfo;
|
|
+import java.util.Set;
|
|
-import com.kanishka.virustotal.dto.VirusScanInfo;
|
|
|
|
-import com.kanishka.virustotal.exception.APIKeyNotFoundException;
|
|
|
|
-import com.kanishka.virustotal.exception.UnauthorizedAccessException;
|
|
|
|
-import com.kanishka.virustotalv2.VirusTotalConfig;
|
|
|
|
-import com.kanishka.virustotalv2.VirustotalPublicV2;
|
|
|
|
-import com.kanishka.virustotalv2.VirustotalPublicV2Impl;
|
|
|
|
-
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
|
|
|
-import de.tudarmstadt.informatik.hostage.Hostage;
|
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
-import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity;
|
|
+import virustotalapi.ReportScan;
|
|
-
|
|
+import virustotalapi.VirusTotal;
|
|
-
|
|
+
|
|
- * A simple {@link Fragment} subclass.
|
|
+
|
|
- * Activities that contain this fragment must implement the
|
|
|
|
- * {@link ScanFileFragment.OnFragmentInteractionListener} interface
|
|
|
|
- * to handle interaction events.
|
|
|
|
- * Use the {@link ScanFileFragment#newInstance} factory method to
|
|
|
|
- * create an instance of this fragment.
|
|
|
|
- */
|
|
|
|
public class ScanFileFragment extends Fragment {
|
|
public class ScanFileFragment extends Fragment {
|
|
|
|
+ public static String filePath;
|
|
|
|
+ public String result;
|
|
|
|
+
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
@@ -58,8 +41,21 @@ public class ScanFileFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
TextView scanResult = (TextView) rootView.findViewById(R.id.scanResult);
|
|
TextView scanResult = (TextView) rootView.findViewById(R.id.scanResult);
|
|
- scanfile(path);
|
|
+
|
|
- scanResult.setText(getFileScanReport());
|
|
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
|
|
|
+ StrictMode.setThreadPolicy(policy);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ scanResult.setText(scanFile());
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -74,18 +70,67 @@ public class ScanFileFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public String result;
|
|
+
|
|
- public String scanner;
|
|
+
|
|
- public String path= HelperUtils.getFilePath();
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public String scanFile() throws IOException {
|
|
|
|
+
|
|
|
|
+ VirusTotal VT = new VirusTotal("111c226204f5de7228563bbca91c5860e4965fbe936307dffa8f2f2d575ff292");
|
|
|
|
+
|
|
|
|
+ Set<ReportScan> Report = VT.ReportScan(HelperUtils.fileMD5);
|
|
|
|
+
|
|
|
|
+ for (ReportScan report : Report) {
|
|
|
|
+
|
|
|
|
+ result=("AV: " + report.getVendor() + " Detected: " + report.getDetected() + " Update: " + report.getUpdate() + " Malware Name: " + report.getMalwarename());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
- public void scanfile(String path){
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String result ="";
|
|
|
|
|
|
try {
|
|
try {
|
|
VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("111c226204f5de7228563bbca91c5860e4965fbe936307dffa8f2f2d575ff292");
|
|
VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("111c226204f5de7228563bbca91c5860e4965fbe936307dffa8f2f2d575ff292");
|
|
VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
|
|
VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
|
|
|
|
|
|
- ScanInfo scanInformation = virusTotalRef.scanFile(new File(path));
|
|
+ ScanInfo scanInformation = virusTotalRef.scanFile(new File(HelperUtils.filePath));
|
|
|
|
|
|
System.out.println("___SCAN INFORMATION___");
|
|
System.out.println("___SCAN INFORMATION___");
|
|
System.out.println("MD5 :\t" + scanInformation.getMd5());
|
|
System.out.println("MD5 :\t" + scanInformation.getMd5());
|
|
@@ -97,7 +142,10 @@ public class ScanFileFragment extends Fragment {
|
|
System.out.println("SHA256 :\t" + scanInformation.getSha256());
|
|
System.out.println("SHA256 :\t" + scanInformation.getSha256());
|
|
System.out.println("Verbose Msg :\t" + scanInformation.getVerboseMessage());
|
|
System.out.println("Verbose Msg :\t" + scanInformation.getVerboseMessage());
|
|
System.out.println("Response Code :\t" + scanInformation.getResponseCode());
|
|
System.out.println("Response Code :\t" + scanInformation.getResponseCode());
|
|
|
|
+ result = String.valueOf(scanInformation.getResponseCode());
|
|
|
|
+
|
|
System.out.println("done.");
|
|
System.out.println("done.");
|
|
|
|
+
|
|
} catch (APIKeyNotFoundException ex) {
|
|
} catch (APIKeyNotFoundException ex) {
|
|
System.err.println("API Key not found! " + ex.getMessage());
|
|
System.err.println("API Key not found! " + ex.getMessage());
|
|
} catch (UnsupportedEncodingException ex) {
|
|
} catch (UnsupportedEncodingException ex) {
|
|
@@ -107,16 +155,18 @@ public class ScanFileFragment extends Fragment {
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
System.err.println("Something Bad Happened! " + ex.getMessage());
|
|
System.err.println("Something Bad Happened! " + ex.getMessage());
|
|
}
|
|
}
|
|
|
|
+ return result;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getFileScanReport() {
|
|
public String getFileScanReport() {
|
|
try {
|
|
try {
|
|
- VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("APIKEY");
|
|
+ VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("111c226204f5de7228563bbca91c5860e4965fbe936307dffa8f2f2d575ff292");
|
|
VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
|
|
VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
|
|
|
|
|
|
- String resource=(HelperUtils.getFileMD5());
|
|
+ String resource=(HelperUtils.fileMD5);
|
|
FileScanReport report = virusTotalRef.getScanReport(resource);
|
|
FileScanReport report = virusTotalRef.getScanReport(resource);
|
|
|
|
|
|
System.out.println("MD5 :\t" + report.getMd5());
|
|
System.out.println("MD5 :\t" + report.getMd5());
|
|
@@ -138,7 +188,7 @@ public class ScanFileFragment extends Fragment {
|
|
System.out.println("\t\t Result : " + virusInfo.getResult());
|
|
System.out.println("\t\t Result : " + virusInfo.getResult());
|
|
System.out.println("\t\t Update : " + virusInfo.getUpdate());
|
|
System.out.println("\t\t Update : " + virusInfo.getUpdate());
|
|
System.out.println("\t\t Version :" + virusInfo.getVersion());
|
|
System.out.println("\t\t Version :" + virusInfo.getVersion());
|
|
- result = virusInfo.getResult();
|
|
+ result = report.getPermalink();
|
|
scanner = key;
|
|
scanner = key;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -153,9 +203,8 @@ public class ScanFileFragment extends Fragment {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-}
|
|
|