Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
WWFMessageAnalyzer.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 WWFMessageAnalyzer {
46 
47  private static final String moduleName = AndroidModuleFactory.getModuleName();
48  private static final Logger logger = Logger.getLogger(WWFMessageAnalyzer.class.getName());
49 
50  public static void findWWFMessages(Content dataSource, FileManager fileManager) {
51  List<AbstractFile> absFiles;
52  try {
53  absFiles = fileManager.findFiles(dataSource, "WordsFramework"); //NON-NLS
54 
55  for (AbstractFile abstractFile : absFiles) {
56  try {
57  File jFile = new File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
58  ContentUtils.writeToFile(abstractFile, jFile);
59 
60  findWWFMessagesInDB(jFile.toString(), abstractFile);
61  } catch (Exception e) {
62  logger.log(Level.SEVERE, "Error parsing WWF messages", e); //NON-NLS
63  }
64  }
65  } catch (TskCoreException e) {
66  logger.log(Level.SEVERE, "Error finding WWF messages", e); //NON-NLS
67  }
68  }
69 
70  private static void findWWFMessagesInDB(String DatabasePath, AbstractFile f) {
71  Connection connection = null;
72  ResultSet resultSet = null;
73  Statement statement = null;
74 
75  if (DatabasePath == null || DatabasePath.isEmpty()) {
76  return;
77  }
78  try {
79  Class.forName("org.sqlite.JDBC"); //load JDBC driver
80  connection = DriverManager.getConnection("jdbc:sqlite:" + DatabasePath); //NON-NLS
81  statement = connection.createStatement();
82  } catch (ClassNotFoundException | SQLException e) {
83  logger.log(Level.SEVERE, "Error opening database", e); //NON-NLS
84  return;
85  }
86 
87  try {
88  resultSet = statement.executeQuery(
89  "SELECT message,strftime('%s' ,created_at) as datetime,user_id,game_id FROM chat_messages ORDER BY game_id DESC, created_at DESC;"); //NON-NLS
90 
91  String message; // WWF Message
92  String user_id; // the ID of the user who sent the message.
93  String game_id; // ID of the game which the the message was sent.
94 
95  while (resultSet.next()) {
96  message = resultSet.getString("message"); //NON-NLS
97  Long created_at = resultSet.getLong("datetime"); //NON-NLS
98  user_id = resultSet.getString("user_id"); //NON-NLS
99  game_id = resultSet.getString("game_id"); //NON-NLS
100 
101  BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE); //create a call log and then add attributes from result set.
102  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), moduleName, created_at));
103  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), moduleName, user_id));
104  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_MSG_ID.getTypeID(), moduleName, game_id));
105  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT.getTypeID(), moduleName, message));
106  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE.getTypeID(), moduleName,
107  NbBundle.getMessage(WWFMessageAnalyzer.class,
108  "WWFMessageAnalyzer.bbAttribute.wordsWithFriendsMsg")));
109  }
110  } catch (Exception e) {
111  logger.log(Level.SEVERE, "Error parsing WWF messages to the Blackboard", e); //NON-NLS
112  } finally {
113  try {
114  if (resultSet != null) {
115  resultSet.close();
116  }
117  statement.close();
118  connection.close();
119  } catch (Exception e) {
120  logger.log(Level.SEVERE, "Error closing database", e); //NON-NLS
121  }
122  }
123  }
124 }

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.