Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
GoogleMapLocationAnalyzer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.android;
20 
21 import java.io.File;
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;
29 
30 import org.openide.util.NbBundle;
41 
45 class GoogleMapLocationAnalyzer {
46 
47  private static final String moduleName = AndroidModuleFactory.getModuleName();
48  private static final Logger logger = Logger.getLogger(GoogleMapLocationAnalyzer.class.getName());
49 
50  public static void findGeoLocations(Content dataSource, FileManager fileManager) {
51  List<AbstractFile> absFiles;
52  try {
53  absFiles = fileManager.findFiles(dataSource, "da_destination_history"); //NON-NLS
54  if (absFiles.isEmpty()) {
55  return;
56  }
57  for (AbstractFile abstractFile : absFiles) {
58  try {
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); //NON-NLS
64  }
65  }
66  } catch (TskCoreException e) {
67  logger.log(Level.SEVERE, "Error finding Google map locations", e); //NON-NLS
68  }
69  }
70 
71  private static void findGeoLocationsInDB(String DatabasePath, AbstractFile f) {
72  Connection connection = null;
73  ResultSet resultSet = null;
74  Statement statement = null;
75 
76  if (DatabasePath == null || DatabasePath.isEmpty()) {
77  return;
78  }
79  try {
80  Class.forName("org.sqlite.JDBC"); //NON-NLS //load JDBC driver
81  connection = DriverManager.getConnection("jdbc:sqlite:" + DatabasePath); //NON-NLS
82  statement = connection.createStatement();
83  } catch (ClassNotFoundException | SQLException e) {
84  logger.log(Level.SEVERE, "Error opening database", e); //NON-NLS
85  return;
86  }
87 
88  try {
89  resultSet = statement.executeQuery(
90  "Select time,dest_lat,dest_lng,dest_title,dest_address,source_lat,source_lng FROM destination_history;"); //NON-NLS
91 
92  while (resultSet.next()) {
93  Long time = Long.valueOf(resultSet.getString("time")) / 1000; //NON-NLS
94  String dest_title = resultSet.getString("dest_title"); //NON-NLS
95  String dest_address = resultSet.getString("dest_address"); //NON-NLS
96 
97  double dest_lat = convertGeo(resultSet.getString("dest_lat")); //NON-NLS
98  double dest_lng = convertGeo(resultSet.getString("dest_lng")); //NON-NLS
99  double source_lat = convertGeo(resultSet.getString("source_lat")); //NON-NLS
100  double source_lng = convertGeo(resultSet.getString("source_lng")); //NON-NLS
101 
102 
103 // bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);//src
104 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY.getTypeID(), moduleName, "Source"));
105 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(), moduleName, source_lat));
106 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE.getTypeID(), moduleName, source_lng));
107 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, time));
108 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION.getTypeID(), moduleName, "Google Maps History"));
109 //
110 // bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);//dest
111 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY.getTypeID(), moduleName, "Destination"));
112 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, time));
113 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(), moduleName, dest_lat));
114 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE.getTypeID(), moduleName, dest_lng));
115 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), moduleName, dest_title));
116 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION.getTypeID(), moduleName, dest_address));
117 // bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(), moduleName, "Google Maps History"));
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")));
132 
133  }
134 
135  } catch (Exception e) {
136  logger.log(Level.SEVERE, "Error parsing Google map locations to the Blackboard", e); //NON-NLS
137  } finally {
138  try {
139  if (resultSet != null) {
140  resultSet.close();
141  }
142  statement.close();
143  connection.close();
144  } catch (Exception e) {
145  logger.log(Level.SEVERE, "Error closing the database", e); //NON-NLS
146  }
147  }
148  }
149 
150  //add periods 6 decimal places before the end.
151  private static double convertGeo(String s) {
152  if (s.length() > 6)
153  return Double.valueOf(s.substring(0, s.length() - 6) + "." + s.substring(s.length() - 6, s.length()));
154  else
155  return Double.valueOf(s);
156  }
157 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.