19 package org.sleuthkit.autopsy.modules.iOS;
 
   21 import java.sql.Connection;
 
   22 import java.sql.DriverManager;
 
   23 import java.sql.ResultSet;
 
   24 import java.sql.SQLException;
 
   25 import java.sql.Statement;
 
   26 import java.util.List;
 
   27 import java.util.logging.Level;
 
   28 import org.openide.util.NbBundle.Messages;
 
   41 class CallLogAnalyzer {
 
   43     private Connection connection = null;
 
   44     private ResultSet resultSet = null;
 
   45     private Statement statement = null;
 
   46     private String dbPath = 
"";
 
   47     private long fileId = 0;
 
   48     private java.io.File jFile = null;
 
   55         List<AbstractFile> absFiles;
 
   58             absFiles = skCase.findAllFilesWhere(
"name ='contacts2.db' OR name ='contacts.db'"); 
 
   59             if (absFiles.isEmpty()) {
 
   62             for (AbstractFile AF : absFiles) {
 
   66                     dbPath = jFile.toString(); 
 
   68                     findCallLogsInDB(dbPath, fileId);
 
   69                 } 
catch (Exception e) {
 
   70                     logger.log(Level.SEVERE, 
"Error parsing Call logs", e); 
 
   73         } 
catch (TskCoreException e) {
 
   74             logger.log(Level.SEVERE, 
"Error finding Call logs", e); 
 
   78     @Messages({
"CallLogAnalyzer.indexError.message=Failed to index call log artifact for keyword search."})
 
   79     private void findCallLogsInDB(String DatabasePath, 
long fId) {
 
   80         if (DatabasePath == null || DatabasePath.isEmpty()) {
 
   84             Class.forName(
"org.sqlite.JDBC"); 
 
   85             connection = DriverManager.getConnection(
"jdbc:sqlite:" + DatabasePath); 
 
   86             statement = connection.createStatement();
 
   87         } 
catch (ClassNotFoundException | SQLException e) {
 
   88             logger.log(Level.SEVERE, 
"Error opening database", e); 
 
   94             AbstractFile f = skCase.getAbstractFileById(fId);
 
   96                 logger.log(Level.SEVERE, 
"Error getting abstract file " + fId); 
 
  101                 resultSet = statement.executeQuery(
 
  102                         "SELECT number,date,duration,type, name FROM calls ORDER BY date DESC;"); 
 
  104                 BlackboardArtifact bba;
 
  111                 while (resultSet.next()) {
 
  112                     name = resultSet.getString(
"name"); 
 
  113                     number = resultSet.getString(
"number"); 
 
  114                     duration = resultSet.getString(
"duration"); 
 
  115                     date = resultSet.getString(
"date"); 
 
  116                     type = resultSet.getString(
"type"); 
 
  118                     bba = f.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG); 
 
  119                     if (type.equalsIgnoreCase(
"outgoing")) { 
 
  120                         bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO, moduleName, number));
 
  122                         bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM, moduleName, number));
 
  124                     bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START, moduleName, date)); 
 
  125                     bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END, moduleName, duration + date)); 
 
  126                     bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION, moduleName, type));
 
  127                     bba.addAttribute(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, moduleName, name));
 
  133                         logger.log(Level.SEVERE, 
"Unable to index blackboard artifact " + bba.getArtifactID(), ex); 
 
  135                                 Bundle.CallLogAnalyzer_indexError_message(), bba.getDisplayName());
 
  138             } 
catch (Exception e) {
 
  139                 logger.log(Level.SEVERE, 
"Error parsing Call logs to the Blackboard", e); 
 
  145                 } 
catch (Exception e) {
 
  146                     logger.log(Level.SEVERE, 
"Error closing the database", e); 
 
  149         } 
catch (Exception e) {
 
  150             logger.log(Level.SEVERE, 
"Error parsing Call logs to the Blackboard", e); 
 
String getTempDirectory()
static< T > long writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, Future< T > worker, boolean source)
SleuthkitCase getSleuthkitCase()
Blackboard getBlackboard()
static void error(String title, String message)
synchronized void indexArtifact(BlackboardArtifact artifact)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)