19 package org.sleuthkit.autopsy.modules.android;
22 import java.io.FileInputStream;
23 import java.io.InputStream;
24 import java.math.BigInteger;
25 import java.nio.ByteBuffer;
26 import java.util.List;
27 import java.util.logging.Level;
29 import org.openide.util.NbBundle;
44 class CacheLocationAnalyzer {
46 private static final String moduleName = AndroidModuleFactory.getModuleName();
47 private static final Logger logger = Logger.getLogger(CacheLocationAnalyzer.class.getName());
52 public static void findGeoLocations(Content dataSource, FileManager fileManager) {
55 List<AbstractFile> abstractFiles = fileManager.findFiles(dataSource,
"cache.cell");
56 abstractFiles.addAll(fileManager.findFiles(dataSource,
"cache.wifi"));
58 for (AbstractFile abstractFile : abstractFiles) {
60 if (abstractFile.getSize() == 0) {
63 File jFile =
new File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
64 ContentUtils.writeToFile(abstractFile, jFile);
66 findGeoLocationsInFile(jFile, abstractFile);
67 }
catch (Exception e) {
68 logger.log(Level.SEVERE,
"Error parsing cached Location files", e);
71 }
catch (TskCoreException e) {
72 logger.log(Level.SEVERE,
"Error finding cached Location files", e);
76 private static void findGeoLocationsInFile(File file, AbstractFile f) {
80 InputStream inputStream =
new FileInputStream(file);
83 inputStream.read(bytes);
86 inputStream.read(bytes);
88 int iterations =
new BigInteger(bytes).intValue();
90 for (
int i = 0; i < iterations; i++) {
92 inputStream.read(bytes);
95 inputStream.read(bytes);
96 while (
new BigInteger(bytes).intValue() != 0) {
97 if (0 > inputStream.read(bytes)) {
102 inputStream.read(bytes);
103 if (
new BigInteger(bytes).intValue() <= 0) {
104 bytes =
new byte[28];
105 inputStream.read(bytes);
108 String accuracy =
"" +
new BigInteger(bytes).intValue();
111 inputStream.read(bytes);
112 String confidence =
"" +
new BigInteger(bytes).intValue();
115 inputStream.read(bytes);
116 double latitude = toDouble(bytes);
119 inputStream.read(bytes);
120 double longitude = toDouble(bytes);
123 inputStream.read(bytes);
124 Long timestamp =
new BigInteger(bytes).longValue() / 1000;
126 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
127 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(), moduleName, latitude));
128 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE.getTypeID(), moduleName, longitude));
129 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, timestamp));
130 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(), moduleName,
131 NbBundle.getMessage(CacheLocationAnalyzer.class,
132 "CacheLocationAnalyzer.bbAttribute.fileLocationHistory",
140 }
catch (Exception e) {
141 logger.log(Level.SEVERE,
"Error parsing Cached GPS locations to Blackboard", e);
145 private static double toDouble(byte[] bytes) {
146 return ByteBuffer.wrap(bytes).getDouble();