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.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -89,14 +91,34 @@ class ContactAnalyzer {
|
|||||||
try {
|
try {
|
||||||
// get display_name, mimetype(email or phone number) and data1 (phonenumber or email address depending on mimetype)
|
// 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.
|
//sorted by name, so phonenumber/email would be consecutive for a person if they exist.
|
||||||
resultSet = statement.executeQuery(
|
// check if contacts.name_raw_contact_id exists. Modify the query accordingly.
|
||||||
"SELECT mimetype,data1, name_raw_contact.display_name AS display_name \n" //NON-NLS
|
Boolean column_found = false;
|
||||||
+ "FROM raw_contacts JOIN contacts ON (raw_contacts.contact_id=contacts._id) \n" //NON-NLS
|
DatabaseMetaData metadata = connection.getMetaData();
|
||||||
+ "JOIN raw_contacts AS name_raw_contact ON(name_raw_contact_id=name_raw_contact._id) " //NON-NLS
|
ResultSet columnListResultSet = metadata.getColumns(null, null, "contacts", null); //NON-NLS
|
||||||
+ "LEFT OUTER JOIN data ON (data.raw_contact_id=raw_contacts._id) \n" //NON-NLS
|
while (columnListResultSet.next()) {
|
||||||
+ "LEFT OUTER JOIN mimetypes ON (data.mimetype_id=mimetypes._id) \n" //NON-NLS
|
if (columnListResultSet.getString("COLUMN_NAME").equals("name_raw_contact_id")) { //NON-NLS
|
||||||
+ "WHERE mimetype = 'vnd.android.cursor.item/phone_v2' OR mimetype = 'vnd.android.cursor.item/email_v2'\n" //NON-NLS
|
column_found = true;
|
||||||
+ "ORDER BY name_raw_contact.display_name ASC;"); //NON-NLS
|
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
|
||||||
|
+ "JOIN raw_contacts AS name_raw_contact ON(name_raw_contact_id=name_raw_contact._id) " //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 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;
|
BlackboardArtifact bba;
|
||||||
bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT);
|
bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user