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;
47 class WWFMessageAnalyzer {
49 private static final String moduleName = AndroidModuleFactory.getModuleName();
50 private static final Logger logger = Logger.getLogger(WWFMessageAnalyzer.class.getName());
51 private static Blackboard blackboard;
53 public static void findWWFMessages(Content dataSource, FileManager fileManager) {
54 List<AbstractFile> absFiles;
55 blackboard = Case.getCurrentCase().getServices().getBlackboard();
57 absFiles = fileManager.findFiles(dataSource,
"WordsFramework");
59 for (AbstractFile abstractFile : absFiles) {
61 File jFile =
new File(Case.getCurrentCase().getTempDirectory(), abstractFile.getName());
62 ContentUtils.writeToFile(abstractFile, jFile);
64 findWWFMessagesInDB(jFile.toString(), abstractFile);
65 }
catch (Exception e) {
66 logger.log(Level.SEVERE,
"Error parsing WWF messages", e);
69 }
catch (TskCoreException e) {
70 logger.log(Level.SEVERE,
"Error finding WWF messages", e);
74 private static void findWWFMessagesInDB(String DatabasePath, AbstractFile f) {
75 Connection connection = null;
76 ResultSet resultSet = null;
77 Statement statement = null;
79 if (DatabasePath == null || DatabasePath.isEmpty()) {
83 Class.forName(
"org.sqlite.JDBC");
84 connection = DriverManager.getConnection(
"jdbc:sqlite:" + DatabasePath);
85 statement = connection.createStatement();
86 }
catch (ClassNotFoundException | SQLException e) {
87 logger.log(Level.SEVERE,
"Error opening database", e);
92 resultSet = statement.executeQuery(
93 "SELECT message,strftime('%s' ,created_at) as datetime,user_id,game_id FROM chat_messages ORDER BY game_id DESC, created_at DESC;");
99 while (resultSet.next()) {
100 message = resultSet.getString(
"message");
101 Long created_at = resultSet.getLong(
"datetime");
102 user_id = resultSet.getString(
"user_id");
103 game_id = resultSet.getString(
"game_id");
105 BlackboardArtifact bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE);
106 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, moduleName, created_at));
107 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, moduleName, user_id));
108 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_MSG_ID, moduleName, game_id));
109 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT, moduleName, message));
110 bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE, moduleName,
111 NbBundle.getMessage(WWFMessageAnalyzer.class,
112 "WWFMessageAnalyzer.bbAttribute.wordsWithFriendsMsg")));
116 blackboard.indexArtifact(bba);
117 }
catch (Blackboard.BlackboardException ex) {
118 logger.log(Level.SEVERE, NbBundle.getMessage(Blackboard.class,
"Blackboard.unableToIndexArtifact.error.msg", bba.getDisplayName()), ex);
119 MessageNotifyUtil.Notify.error(
120 NbBundle.getMessage(Blackboard.class,
"Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName());
123 }
catch (Exception e) {
124 logger.log(Level.SEVERE,
"Error parsing WWF messages to the Blackboard", e);
127 if (resultSet != null) {
132 }
catch (Exception e) {
133 logger.log(Level.SEVERE,
"Error closing database", e);