mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-02-28 21:38:21 +03:00
Invert the fileHashes* HashMaps
This fixes scan detection of multiple files with the same hashes. Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
parent
b90dbf1579
commit
fe49d06902
5 changed files with 22 additions and 29 deletions
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
|
@ -5,7 +5,7 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="delegatedBuild" value="false" />
|
<option name="delegatedBuild" value="false" />
|
||||||
<option name="testRunner" value="PLATFORM" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -15,7 +15,6 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="useQualifiedModuleNames" value="true" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
|
@ -1,5 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="DesignSurface">
|
||||||
|
<option name="filePathToZoomLevelMap">
|
||||||
|
<map>
|
||||||
|
<entry key="app/src/main/res/layout/activity_main.xml" value="0.9348958333333334" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="NullableNotNullManager">
|
<component name="NullableNotNullManager">
|
||||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
|
@ -26,7 +33,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="14">
|
<list size="15">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
@ -41,6 +48,7 @@
|
||||||
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||||
<item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
<item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
||||||
<item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
<item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="lombok.NonNull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
|
|
13
.idea/runConfigurations.xml
generated
13
.idea/runConfigurations.xml
generated
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -6,7 +6,7 @@ android {
|
||||||
applicationId "us.spotco.malwarescanner"
|
applicationId "us.spotco.malwarescanner"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 74
|
versionCode 75
|
||||||
versionName "2.21"
|
versionName "2.21"
|
||||||
resConfigs "en", "de", "es", "fr", "it", "pt", "ru"
|
resConfigs "en", "de", "es", "fr", "it", "pt", "ru"
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ class MalwareScanner extends AsyncTask<Set<File>, Object, String> {
|
||||||
private boolean userFacing = false;
|
private boolean userFacing = false;
|
||||||
private NotificationManager notificationManager = null;
|
private NotificationManager notificationManager = null;
|
||||||
private long scanStartTime = 0;
|
private long scanStartTime = 0;
|
||||||
private final HashMap<String, File> fileHashesMD5 = new HashMap<>();
|
private final HashMap<File, String> fileHashesMD5 = new HashMap<>();
|
||||||
private final HashMap<String, File> fileHashesSHA1 = new HashMap<>();
|
private final HashMap<File, String> fileHashesSHA1 = new HashMap<>();
|
||||||
private final HashMap<String, File> fileHashesSHA256 = new HashMap<>();
|
private final HashMap<File, String> fileHashesSHA256 = new HashMap<>();
|
||||||
public boolean running = false;
|
public boolean running = false;
|
||||||
|
|
||||||
public MalwareScanner(Activity activity, Context context, boolean userFacing) {
|
public MalwareScanner(Activity activity, Context context, boolean userFacing) {
|
||||||
|
@ -191,13 +191,12 @@ class MalwareScanner extends AsyncTask<Set<File>, Object, String> {
|
||||||
logResult((String) objects[0], (boolean) objects[1]);
|
logResult((String) objects[0], (boolean) objects[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSignature(String hashType, HashMap<String, File> signaturesToCheck, HashMap<String, String> signatureDatabase) {
|
private void checkSignature(String hashType, HashMap<File, String> signaturesToCheck, HashMap<String, String> signatureDatabase) {
|
||||||
//XXX: TODO: This is a map with hash,file meaning multiple files with the same hashes will only match once!
|
|
||||||
if (signatureDatabase.size() > 0) {
|
if (signatureDatabase.size() > 0) {
|
||||||
for (Map.Entry<String, File> file : signaturesToCheck.entrySet()) {
|
for (Map.Entry<File, String> file : signaturesToCheck.entrySet()) {
|
||||||
if (signatureDatabase.containsKey(file.getKey())) {
|
if (signatureDatabase.containsKey(file.getValue())) {
|
||||||
String result = signatureDatabase.get(file.getKey());
|
String result = signatureDatabase.get(file.getValue());
|
||||||
publishProgress(result + " in " + file.getValue().toString().replaceAll(Environment.getExternalStorageDirectory().toString(), "~"), false);
|
publishProgress(result + " in " + file.getKey().toString().replaceAll(Environment.getExternalStorageDirectory().toString(), "~"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
publishProgress("\t" + context.getString(R.string.main_hash_scan_done, hashType) + "\n", true);
|
publishProgress("\t" + context.getString(R.string.main_hash_scan_done, hashType) + "\n", true);
|
||||||
|
@ -228,9 +227,9 @@ class MalwareScanner extends AsyncTask<Set<File>, Object, String> {
|
||||||
|
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
fileHashesMD5.put(String.format("%032x", new BigInteger(1, digestMD5.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
fileHashesMD5.put(file, String.format("%032x", new BigInteger(1, digestMD5.digest())).substring(0, Utils.MAX_HASH_LENGTH));
|
||||||
fileHashesSHA1.put(String.format("%032x", new BigInteger(1, digestSHA1.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
fileHashesSHA1.put(file, String.format("%032x", new BigInteger(1, digestSHA1.digest())).substring(0, Utils.MAX_HASH_LENGTH));
|
||||||
fileHashesSHA256.put(String.format("%064x", new BigInteger(1, digestSHA256.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
fileHashesSHA256.put(file, String.format("%064x", new BigInteger(1, digestSHA256.digest())).substring(0, Utils.MAX_HASH_LENGTH));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue