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 BrowserLocationAnalyzer {
47 private static final String moduleName = AndroidModuleFactory.getModuleName();
48 private static final Logger logger = Logger.getLogger(BrowserLocationAnalyzer.class.getName());
50 public static void findGeoLocations(Content dataSource, FileManager fileManager) {
52 List<AbstractFile> abstractFiles = fileManager.findFiles(dataSource,
"CachedGeoposition%.db");
54 for (AbstractFile abstractFile : abstractFiles) {
56 if (abstractFile.getSize() == 0) {
59 File jFile =
new 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 Browser Location files", e);
66 }
catch (TskCoreException e) {
67 logger.log(Level.SEVERE,
"Error finding Browser Location files", e);
72 private static void findGeoLocationsInDB(String DatabasePath, AbstractFile f) {
73 Connection connection = null;
74 ResultSet resultSet = null;
75 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 connecting to sql database", e);
89 resultSet = statement.executeQuery(
90 "Select timestamp, latitude, longitude, accuracy FROM CachedPosition;");
92 while (resultSet.next()) {
93 Long timestamp = Long.valueOf(resultSet.getString(
"timestamp")) / 1000;
94 double latitude = Double.valueOf(resultSet.getString(
"latitude"));
95 double longitude = Double.valueOf(resultSet.getString(
"longitude"));
97 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
98 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(), moduleName, latitude));
99 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE.getTypeID(), moduleName, longitude));
100 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, timestamp));
101 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(), moduleName,
102 NbBundle.getMessage(BrowserLocationAnalyzer.class,
103 "BrowserLocationAnalyzer.bbAttribute.browserLocationHistory")));
106 }
catch (Exception e) {
107 logger.log(Level.SEVERE,
"Error Putting artifacts to Blackboard", e);
110 if (resultSet != null) {
115 }
catch (Exception e) {
116 logger.log(Level.SEVERE,
"Error closing database", e);