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;
45 class GoogleMapLocationAnalyzer {
47 private static final String moduleName = AndroidModuleFactory.getModuleName();
48 private static final Logger logger = Logger.getLogger(GoogleMapLocationAnalyzer.class.getName());
50 public static void findGeoLocations(Content dataSource, FileManager fileManager) {
51 List<AbstractFile> absFiles;
53 absFiles = fileManager.findFiles(dataSource,
"da_destination_history");
54 if (absFiles.isEmpty()) {
57 for (AbstractFile abstractFile : absFiles) {
59 File jFile =
new java.io.File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
60 ContentUtils.writeToFile(abstractFile, jFile);
61 findGeoLocationsInDB(jFile.toString(), abstractFile);
62 }
catch (Exception e) {
63 logger.log(Level.SEVERE,
"Error parsing Google map locations", e);
66 }
catch (TskCoreException e) {
67 logger.log(Level.SEVERE,
"Error finding Google map locations", e);
71 private static void findGeoLocationsInDB(String DatabasePath, AbstractFile f) {
72 Connection connection = null;
73 ResultSet resultSet = null;
74 Statement statement = null;
76 if (DatabasePath == null || DatabasePath.isEmpty()) {
80 Class.forName(
"org.sqlite.JDBC");
81 connection = DriverManager.getConnection(
"jdbc:sqlite:" + DatabasePath);
82 statement = connection.createStatement();
83 }
catch (ClassNotFoundException | SQLException e) {
84 logger.log(Level.SEVERE,
"Error opening database", e);
89 resultSet = statement.executeQuery(
90 "Select time,dest_lat,dest_lng,dest_title,dest_address,source_lat,source_lng FROM destination_history;");
92 while (resultSet.next()) {
93 Long time = Long.valueOf(resultSet.getString(
"time")) / 1000;
94 String dest_title = resultSet.getString(
"dest_title");
95 String dest_address = resultSet.getString(
"dest_address");
97 double dest_lat = convertGeo(resultSet.getString(
"dest_lat"));
98 double dest_lng = convertGeo(resultSet.getString(
"dest_lng"));
99 double source_lat = convertGeo(resultSet.getString(
"source_lat"));
100 double source_lng = convertGeo(resultSet.getString(
"source_lng"));
118 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
119 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY.getTypeID(), moduleName,
120 NbBundle.getMessage(GoogleMapLocationAnalyzer.class,
121 "GoogleMapLocationAnalyzer.bbAttribute.destination")));
122 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, time));
123 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END.getTypeID(), moduleName, dest_lat));
124 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END.getTypeID(), moduleName, dest_lng));
125 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START.getTypeID(), moduleName, source_lat));
126 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START.getTypeID(), moduleName, source_lng));
127 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), moduleName, dest_title));
128 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION.getTypeID(), moduleName, dest_address));
129 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(), moduleName,
130 NbBundle.getMessage(GoogleMapLocationAnalyzer.class,
131 "GoogleMapLocationAnalyzer.bbAttribute.googleMapsHistory")));
135 }
catch (Exception e) {
136 logger.log(Level.SEVERE,
"Error parsing Google map locations to the Blackboard", e);
139 if (resultSet != null) {
144 }
catch (Exception e) {
145 logger.log(Level.SEVERE,
"Error closing the database", e);
151 private static double convertGeo(String s) {
153 return Double.valueOf(s.substring(0, s.length() - 6) +
"." + s.substring(s.length() - 6, s.length()));
155 return Double.valueOf(s);