mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Merge pull request #1099 from sidheshenator/android_sql_query_validate
Android sql query validate
This commit is contained in:
commit
ab4523a4e0
@ -20,10 +20,12 @@ package org.sleuthkit.autopsy.modules.android;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
@ -89,6 +91,17 @@ class ContactAnalyzer {
|
||||
try {
|
||||
// get display_name, mimetype(email or phone number) and data1 (phonenumber or email address depending on mimetype)
|
||||
//sorted by name, so phonenumber/email would be consecutive for a person if they exist.
|
||||
// check if contacts.name_raw_contact_id exists. Modify the query accordingly.
|
||||
Boolean column_found = false;
|
||||
DatabaseMetaData metadata = connection.getMetaData();
|
||||
ResultSet columnListResultSet = metadata.getColumns(null, null, "contacts", null); //NON-NLS
|
||||
while (columnListResultSet.next()) {
|
||||
if (columnListResultSet.getString("COLUMN_NAME").equals("name_raw_contact_id")) { //NON-NLS
|
||||
column_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (column_found) {
|
||||
resultSet = statement.executeQuery(
|
||||
"SELECT mimetype,data1, name_raw_contact.display_name AS display_name \n" //NON-NLS
|
||||
+ "FROM raw_contacts JOIN contacts ON (raw_contacts.contact_id=contacts._id) \n" //NON-NLS
|
||||
@ -97,6 +110,15 @@ class ContactAnalyzer {
|
||||
+ "LEFT OUTER JOIN mimetypes ON (data.mimetype_id=mimetypes._id) \n" //NON-NLS
|
||||
+ "WHERE mimetype = 'vnd.android.cursor.item/phone_v2' OR mimetype = 'vnd.android.cursor.item/email_v2'\n" //NON-NLS
|
||||
+ "ORDER BY name_raw_contact.display_name ASC;"); //NON-NLS
|
||||
} else {
|
||||
resultSet = statement.executeQuery(
|
||||
"SELECT mimetype,data1, raw_contacts.display_name AS display_name \n" //NON-NLS
|
||||
+ "FROM raw_contacts JOIN contacts ON (raw_contacts.contact_id=contacts._id) \n" //NON-NLS
|
||||
+ "LEFT OUTER JOIN data ON (data.raw_contact_id=raw_contacts._id) \n" //NON-NLS
|
||||
+ "LEFT OUTER JOIN mimetypes ON (data.mimetype_id=mimetypes._id) \n" //NON-NLS
|
||||
+ "WHERE mimetype = 'vnd.android.cursor.item/phone_v2' OR mimetype = 'vnd.android.cursor.item/email_v2'\n" //NON-NLS
|
||||
+ "ORDER BY raw_contacts.display_name ASC;"); //NON-NLS
|
||||
}
|
||||
|
||||
BlackboardArtifact bba;
|
||||
bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user