19 package org.sleuthkit.autopsy.modules.android;
22 import java.sql.Connection;
23 import java.sql.DriverManager;
24 import java.sql.ResultSet;
25 import java.sql.SQLException;
26 import java.sql.Statement;
27 import java.util.List;
28 import java.util.logging.Level;
30 import org.openide.util.NbBundle;
46 class GoogleMapLocationAnalyzer {
48 private static final String moduleName = AndroidModuleFactory.getModuleName();
49 private static final Logger logger = Logger.getLogger(GoogleMapLocationAnalyzer.class.getName());
50 private static Blackboard blackboard;
52 public static void findGeoLocations(Content dataSource, FileManager fileManager) {
53 List<AbstractFile> absFiles;
54 blackboard = Case.getCurrentCase().getServices().getBlackboard();
56 absFiles = fileManager.findFiles(dataSource,
"da_destination_history");
57 if (absFiles.isEmpty()) {
60 for (AbstractFile abstractFile : absFiles) {
62 File jFile =
new java.io.File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
63 ContentUtils.writeToFile(abstractFile, jFile);
64 findGeoLocationsInDB(jFile.toString(), abstractFile);
65 }
catch (Exception e) {
66 logger.log(Level.SEVERE,
"Error parsing Google map locations", e);
69 }
catch (TskCoreException e) {
70 logger.log(Level.SEVERE,
"Error finding Google map locations", e);
74 private static void findGeoLocationsInDB(String DatabasePath, AbstractFile f) {
75 Connection connection = null;
76 ResultSet resultSet = null;
77 Statement statement = null;
79 if (DatabasePath == null || DatabasePath.isEmpty()) {
83 Class.forName(
"org.sqlite.JDBC");
84 connection = DriverManager.getConnection(
"jdbc:sqlite:" + DatabasePath);
85 statement = connection.createStatement();
86 }
catch (ClassNotFoundException | SQLException e) {
87 logger.log(Level.SEVERE,
"Error opening database", e);
92 resultSet = statement.executeQuery(
93 "SELECT time,dest_lat,dest_lng,dest_title,dest_address,source_lat,source_lng FROM destination_history;");
95 while (resultSet.next()) {
96 Long time = Long.valueOf(resultSet.getString(
"time")) / 1000;
97 String dest_title = resultSet.getString(
"dest_title");
98 String dest_address = resultSet.getString(
"dest_address");
100 double dest_lat = convertGeo(resultSet.getString(
"dest_lat"));
101 double dest_lng = convertGeo(resultSet.getString(
"dest_lng"));
102 double source_lat = convertGeo(resultSet.getString(
"source_lat"));
103 double source_lng = convertGeo(resultSet.getString(
"source_lng"));
120 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
121 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, moduleName,
122 NbBundle.getMessage(GoogleMapLocationAnalyzer.class,
123 "GoogleMapLocationAnalyzer.bbAttribute.destination")));
124 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, moduleName, time));
125 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END, moduleName, dest_lat));
126 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END, moduleName, dest_lng));
127 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START, moduleName, source_lat));
128 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START, moduleName, source_lng));
129 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, moduleName, dest_title));
130 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION, moduleName, dest_address));
131 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, moduleName,
132 NbBundle.getMessage(GoogleMapLocationAnalyzer.class,
133 "GoogleMapLocationAnalyzer.bbAttribute.googleMapsHistory")));
137 blackboard.indexArtifact(bba);
138 }
catch (Blackboard.BlackboardException ex) {
139 logger.log(Level.SEVERE, NbBundle.getMessage(Blackboard.class,
"Blackboard.unableToIndexArtifact.error.msg", bba.getDisplayName()), ex);
140 MessageNotifyUtil.Notify.error(
141 NbBundle.getMessage(Blackboard.class,
"Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName());
144 }
catch (Exception e) {
145 logger.log(Level.SEVERE,
"Error parsing Google map locations to the Blackboard", e);
148 if (resultSet != null) {
153 }
catch (Exception e) {
154 logger.log(Level.SEVERE,
"Error closing the database", e);
160 private static double convertGeo(String s) {
161 if (s.length() > 6) {
162 return Double.valueOf(s.substring(0, s.length() - 6) +
"." + s.substring(s.length() - 6, s.length()));
164 return Double.valueOf(s);