20 package org.sleuthkit.autopsy.geolocation.datamodel;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.List;
27 import java.util.logging.Level;
30 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
46 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(),
47 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID());
50 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(),
51 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START.getTypeID(),
52 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_WAYPOINTS.getTypeID());
57 =
"SELECT artifact_id, artifact_type_id "
58 +
"FROM blackboard_attributes "
59 +
"WHERE attribute_type_id IN (%s) ";
63 =
"SELECT artifact_id "
64 +
"FROM blackboard_attributes "
65 +
"WHERE attribute_type_id IN (%s) ";
69 =
"SELECT blackboard_attributes.artifact_id "
70 +
"FROM blackboard_attributes, blackboard_artifacts "
71 +
"WHERE blackboard_attributes.artifact_id = blackboard_artifacts.artifact_id "
72 +
"AND blackboard_attributes.attribute_type_id IN(%s) "
73 +
"AND data_source_obj_id IN (%s)";
77 =
"SELECT MAX(value_int64) - (%d * 86400)"
78 +
"FROM blackboard_attributes "
79 +
"WHERE attribute_type_id IN(%s) "
87 =
"SELECT DISTINCT artifact_id, artifact_type_id "
88 +
"FROM blackboard_attributes "
89 +
"WHERE artifact_id NOT IN (%s) "
90 +
"AND artifact_id IN (%s)";
127 List<Waypoint> points =
new ArrayList<>();
145 public static List<Route>
getRoutes(List<Waypoint> waypoints) {
146 List<Route> routeList =
new ArrayList<>();
148 GeoPath path = point.getParentGeoPath();
149 if (path instanceof
Route) {
150 Route route = (Route) path;
151 if (!routeList.contains(route)) {
152 routeList.add(route);
167 public static List<Track>
getTracks(List<Waypoint> waypoints) {
168 List<Track> trackList =
new ArrayList<>();
170 GeoPath path = point.getParentGeoPath();
171 if (path instanceof
Track) {
172 Track route = (Track) path;
173 if (!trackList.contains(route)) {
174 trackList.add(route);
191 @SuppressWarnings(
"deprecation")
193 List<BlackboardArtifact> artifacts = null;
195 artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
196 }
catch (TskCoreException ex) {
197 throw new GeoLocationDataException(
"Unable to get artifacts for type: TSK_GPS_TRACKPOINT", ex);
200 List<Waypoint> points =
new ArrayList<>();
201 for (BlackboardArtifact artifact : artifacts) {
203 Waypoint point =
new TrackpointWaypoint(artifact);
205 }
catch (GeoLocationDataException ex) {
206 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_TRACKPOINT artifactID: %d", artifact.getArtifactID()));
220 List<Waypoint> specificPoints =
new ArrayList<>();
223 if (point instanceof TrackpointWaypoint) {
224 specificPoints.add(point);
228 return specificPoints;
241 List<BlackboardArtifact> artifacts = null;
243 artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_METADATA_EXIF);
244 }
catch (TskCoreException ex) {
248 List<Waypoint> points =
new ArrayList<>();
249 if (artifacts != null) {
250 for (BlackboardArtifact artifact : artifacts) {
252 Waypoint point =
new EXIFWaypoint(artifact);
272 List<Waypoint> specificPoints =
new ArrayList<>();
275 if (point instanceof EXIFWaypoint) {
276 specificPoints.add(point);
280 return specificPoints;
293 List<BlackboardArtifact> artifacts = null;
295 artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_SEARCH);
296 }
catch (TskCoreException ex) {
300 List<Waypoint> points =
new ArrayList<>();
301 if (artifacts != null) {
302 for (BlackboardArtifact artifact : artifacts) {
304 Waypoint point =
new SearchWaypoint(artifact);
307 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_SEARCH artifactID: %d", artifact.getArtifactID()));
322 List<Waypoint> specificPoints =
new ArrayList<>();
325 if (point instanceof SearchWaypoint) {
326 specificPoints.add(point);
330 return specificPoints;
343 List<BlackboardArtifact> artifacts = null;
345 artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION);
346 }
catch (TskCoreException ex) {
350 List<Waypoint> points =
new ArrayList<>();
351 if (artifacts != null) {
352 for (BlackboardArtifact artifact : artifacts) {
354 Waypoint point =
new LastKnownWaypoint(artifact);
357 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_LAST_KNOWN_LOCATION artifactID: %d", artifact.getArtifactID()));
373 List<Waypoint> specificPoints =
new ArrayList<>();
376 if (point instanceof LastKnownWaypoint) {
377 specificPoints.add(point);
381 return specificPoints;
394 List<BlackboardArtifact> artifacts = null;
396 artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_BOOKMARK);
397 }
catch (TskCoreException ex) {
401 List<Waypoint> points =
new ArrayList<>();
402 if (artifacts != null) {
403 for (BlackboardArtifact artifact : artifacts) {
405 Waypoint point =
new BookmarkWaypoint(artifact);
408 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_BOOKMARK artifactID: %d", artifact.getArtifactID()), ex);
424 List<Waypoint> specificPoints =
new ArrayList<>();
427 if (point instanceof BookmarkWaypoint) {
428 specificPoints.add(point);
432 return specificPoints;
469 String query =
buildQuery(dataSources, showAll, cntDaysFromRecent, noTimeStamp);
471 logger.log(Level.INFO, query);
476 if (query.startsWith(
"SELECT")) {
477 query = query.replaceFirst(
"SELECT",
"");
480 skCase.getCaseDbAccessManager().select(query,
new CaseDbAccessManager.CaseDbAccessQueryCallback() {
482 public void process(ResultSet rs) {
486 int artifact_type_id = rs.getInt(
"artifact_type_id");
487 long artifact_id = rs.getLong(
"artifact_id");
489 ARTIFACT_TYPE type = ARTIFACT_TYPE.fromID(artifact_type_id);
490 if (artifactTypes.contains(type)) {
496 queryCallBack.process(waypointResults);
497 }
catch (SQLException | TskCoreException ex) {
498 logger.log(Level.WARNING,
"Failed to filter waypoint.", ex);
503 }
catch (TskCoreException ex) {
504 logger.log(Level.WARNING,
"Failed to filter waypoint.", ex);
554 static private String
buildQuery(List<DataSource> dataSources,
boolean showAll,
int cntDaysFromRecent,
boolean noTimeStamp) {
555 String mostRecentQuery =
"";
557 if (!showAll && cntDaysFromRecent > 0) {
565 mostRecentQuery = String.format(
"AND value_int64 > (%s)",
567 cntDaysFromRecent, TIME_TYPE_IDS,
580 query += mostRecentQuery;
582 if (showAll || noTimeStamp) {
603 if (dataSources == null || dataSources.isEmpty()) {
611 String dataSourceList =
"";
612 for (DataSource source : dataSources) {
613 dataSourceList += Long.toString(source.getId()) +
",";
616 if (!dataSourceList.isEmpty()) {
618 dataSourceList = dataSourceList.substring(0, dataSourceList.length() - 1);
681 case TSK_METADATA_EXIF:
684 case TSK_GPS_BOOKMARK:
687 case TSK_GPS_TRACKPOINT:
696 case TSK_GPS_LAST_KNOWN_LOCATION:
static List< Waypoint > getLastKnownWaypoints(List< Waypoint > waypoints)
static final String TIME_TYPE_IDS
static String buildQuery(List< DataSource > dataSources, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp)
static final Logger logger
static List< Waypoint > getBookmarkWaypoints(SleuthkitCase skCase)
void process(GeoLocationParseResult< Waypoint > waypoints)
static List< Waypoint > getBookmarkWaypoints(List< Waypoint > waypoints)
static void getAllWaypoints(SleuthkitCase skCase, List< DataSource > dataSources, List< ARTIFACT_TYPE > artifactTypes, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp, WaypointFilterQueryCallBack queryCallBack)
static GeoLocationParseResult< Waypoint > parseWaypoints(ParserWithError< List< Waypoint >> parser, BlackboardArtifact artifact)
static GeoLocationParseResult< Waypoint > getWaypointForArtifact(BlackboardArtifact artifact, ARTIFACT_TYPE type)
static List< Waypoint > getSearchWaypoints(SleuthkitCase skCase)
void add(GeoLocationParseResult< T > toAdd)
static final String GEO_ATTRIBUTE_TYPE_IDS
static List< Waypoint > getSearchWaypoints(List< Waypoint > waypoints)
static List< Track > getTracks(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(SleuthkitCase skCase)
static final String GEO_ARTIFACT_QUERY_ID_ONLY
static final String GEO_ARTIFACT_WITH_DATA_SOURCES_QUERY
T parse(BlackboardArtifact artifact)
static List< Route > getRoutes(List< Waypoint > waypoints)
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
static String getWaypointListQuery(List< DataSource > dataSources)
static final String MOST_RECENT_TIME
static GeoLocationParseResult< Waypoint > parseWaypoint(ParserWithError< Waypoint > parser, BlackboardArtifact artifact)
static List< Waypoint > getEXIFWaypoints(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(List< Waypoint > waypoints)
static String buildQueryForWaypointsWOTimeStamps(List< DataSource > dataSources)
static final String GEO_ARTIFACT_QUERY
static final String SELECT_WO_TIMESTAMP
synchronized static Logger getLogger(String name)
static List< Waypoint > getLastKnownWaypoints(SleuthkitCase skCase)
static List< Waypoint > getEXIFWaypoints(SleuthkitCase skCase)