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 WWFMessageAnalyzer {
47 private static final String moduleName = AndroidModuleFactory.getModuleName();
48 private static final Logger logger = Logger.getLogger(WWFMessageAnalyzer.class.getName());
50 public static void findWWFMessages(Content dataSource, FileManager fileManager) {
51 List<AbstractFile> absFiles;
53 absFiles = fileManager.findFiles(dataSource,
"WordsFramework");
55 for (AbstractFile abstractFile : absFiles) {
57 File jFile =
new File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
58 ContentUtils.writeToFile(abstractFile, jFile);
60 findWWFMessagesInDB(jFile.toString(), abstractFile);
61 }
catch (Exception e) {
62 logger.log(Level.SEVERE,
"Error parsing WWF messages", e);
65 }
catch (TskCoreException e) {
66 logger.log(Level.SEVERE,
"Error finding WWF messages", e);
70 private static void findWWFMessagesInDB(String DatabasePath, AbstractFile f) {
71 Connection connection = null;
72 ResultSet resultSet = null;
73 Statement statement = null;
75 if (DatabasePath == null || DatabasePath.isEmpty()) {
79 Class.forName(
"org.sqlite.JDBC");
80 connection = DriverManager.getConnection(
"jdbc:sqlite:" + DatabasePath);
81 statement = connection.createStatement();
82 }
catch (ClassNotFoundException | SQLException e) {
83 logger.log(Level.SEVERE,
"Error opening database", e);
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;");
95 while (resultSet.next()) {
96 message = resultSet.getString(
"message");
97 Long created_at = resultSet.getLong(
"datetime");
98 user_id = resultSet.getString(
"user_id");
99 game_id = resultSet.getString(
"game_id");
101 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE);
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")));
110 }
catch (Exception e) {
111 logger.log(Level.SEVERE,
"Error parsing WWF messages to the Blackboard", e);
114 if (resultSet != null) {
119 }
catch (Exception e) {
120 logger.log(Level.SEVERE,
"Error closing database", e);