19 package org.sleuthkit.autopsy.modules.hashdatabase;
 
   21 import java.io.IOException;
 
   22 import java.util.ArrayList;
 
   23 import java.util.Collections;
 
   24 import java.util.HashMap;
 
   25 import java.util.List;
 
   26 import java.util.concurrent.atomic.AtomicLong;
 
   27 import java.util.logging.Level;
 
   28 import org.openide.util.NbBundle;
 
   55     private final HashLookupModuleSettings 
settings;
 
   72             totalsForIngestJobs.put(ingestJobId, totals);
 
   83         jobId = context.getJobId();  
 
   90             if (knownBadHashSets.isEmpty()) {
 
   93                     NbBundle.getMessage(this.getClass(),
 
   94                         "HashDbIngestModule.noKnownBadHashDbSetMsg"),
 
   95                     NbBundle.getMessage(this.getClass(),
 
   96                         "HashDbIngestModule.knownBadFileSearchWillNotExecuteWarn")));
 
   99             if (knownHashSets.isEmpty()) {
 
  102                     NbBundle.getMessage(this.getClass(),
 
  103                         "HashDbIngestModule.noKnownHashDbSetMsg"),
 
  104                     NbBundle.getMessage(this.getClass(),
 
  105                         "HashDbIngestModule.knownFileSearchWillNotExecuteWarn")));
 
  116         enabledHashSets.clear();
 
  117         for (
HashDb db : allHashSets) {
 
  118             if (settings.isHashSetEnabled(db.getHashSetName())) {
 
  121                         enabledHashSets.add(db);
 
  125                     logger.log(Level.WARNING, 
"Error getting index status for " + db.getHashSetName() +
" hash database", ex); 
 
  148         if ((knownHashSets.isEmpty()) && (knownBadHashSets.isEmpty()) && (!settings.shouldCalculateHashes())) {
 
  158         if (md5Hash == null || md5Hash.isEmpty()) {
 
  160                 long calcstart = System.currentTimeMillis();
 
  162                 long delta = (System.currentTimeMillis() - calcstart);
 
  165             } 
catch (IOException ex) {
 
  166                 logger.log(Level.WARNING, 
"Error calculating hash of file " + name, ex); 
 
  169                                       NbBundle.getMessage(this.getClass(),
 
  170                                                           "HashDbIngestModule.fileReadErrorMsg",
 
  172                                       NbBundle.getMessage(this.getClass(),
 
  173                                                           "HashDbIngestModule.calcHashValueErr",
 
  180         boolean foundBad = 
false;
 
  182         for (
HashDb db : knownBadHashSets) {
 
  184                 long lookupstart = System.currentTimeMillis();
 
  186                 if (null != hashInfo) {
 
  193                         logger.log(Level.WARNING, 
"Couldn't set known bad state for file " + name + 
" - see sleuthkit log for details", ex); 
 
  196                                               NbBundle.getMessage(this.getClass(),
 
  197                                                                   "HashDbIngestModule.hashLookupErrorMsg",
 
  199                                               NbBundle.getMessage(this.getClass(),
 
  200                                                                   "HashDbIngestModule.settingKnownBadStateErr",
 
  204                     String hashSetName = db.getHashSetName();
 
  207                     ArrayList<String> comments = hashInfo.
getComments();
 
  209                     for (String c : comments) {
 
  215                             comment = comment.substring(0, MAX_COMMENT_SIZE) + 
"...";
 
  222                 long delta = (System.currentTimeMillis() - lookupstart);
 
  226                 logger.log(Level.WARNING, 
"Couldn't lookup known bad hash for file " + name + 
" - see sleuthkit log for details", ex); 
 
  229                                       NbBundle.getMessage(this.getClass(),
 
  230                                                           "HashDbIngestModule.hashLookupErrorMsg",
 
  232                                       NbBundle.getMessage(this.getClass(),
 
  233                                                           "HashDbIngestModule.lookingUpKnownBadHashValueErr",
 
  243             for (
HashDb db : knownHashSets) {
 
  245                     long lookupstart = System.currentTimeMillis();
 
  246                     if (db.lookupMD5Quick(file)) {
 
  251                             logger.log(Level.WARNING, 
"Couldn't set known state for file " + name + 
" - see sleuthkit log for details", ex); 
 
  255                     long delta = (System.currentTimeMillis() - lookupstart);
 
  259                     logger.log(Level.WARNING, 
"Couldn't lookup known hash for file " + name + 
" - see sleuthkit log for details", ex); 
 
  262                                           NbBundle.getMessage(this.getClass(),
 
  263                                                               "HashDbIngestModule.hashLookupErrorMsg",
 
  265                                           NbBundle.getMessage(this.getClass(),
 
  266                                                               "HashDbIngestModule.lookingUpKnownHashValueErr",
 
  278             String MODULE_NAME = NbBundle.getMessage(
HashDbIngestModule.class, 
"HashDbIngestModule.moduleName");
 
  290             if (showInboxMessage) {
 
  291                 StringBuilder detailsSb = 
new StringBuilder();
 
  293                 detailsSb.append(
"<table border='0' cellpadding='4' width='280'>"); 
 
  295                 detailsSb.append(
"<tr>"); 
 
  296                 detailsSb.append(
"<th>") 
 
  297                          .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.postToBB.fileName"))
 
  299                 detailsSb.append(
"<td>") 
 
  300                          .append(abstractFile.
getName())
 
  302                 detailsSb.append(
"</tr>"); 
 
  304                 detailsSb.append(
"<tr>"); 
 
  305                 detailsSb.append(
"<th>") 
 
  306                          .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.postToBB.md5Hash"))
 
  308                 detailsSb.append(
"<td>").append(md5Hash).append(
"</td>"); 
 
  309                 detailsSb.append(
"</tr>"); 
 
  311                 detailsSb.append(
"<tr>"); 
 
  312                 detailsSb.append(
"<th>") 
 
  313                          .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.postToBB.hashsetName"))
 
  315                 detailsSb.append(
"<td>").append(hashSetName).append(
"</td>"); 
 
  316                 detailsSb.append(
"</tr>"); 
 
  318                 detailsSb.append(
"</table>"); 
 
  321                          NbBundle.getMessage(this.getClass(),
 
  322                                              "HashDbIngestModule.postToBB.knownBadMsg",
 
  324                          detailsSb.toString(),
 
  325                          abstractFile.
getName() + md5Hash,
 
  330             logger.log(Level.WARNING, 
"Error creating blackboard artifact", ex); 
 
  337         if ((!knownBadHashSets.isEmpty()) || (!knownHashSets.isEmpty())) {
 
  338             StringBuilder detailsSb = 
new StringBuilder();
 
  340             detailsSb.append(
"<table border='0' cellpadding='4' width='280'>"); 
 
  342             detailsSb.append(
"<tr><td>") 
 
  343                      .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.complete.knownBadsFound"))
 
  345             detailsSb.append(
"<td>").append(jobTotals.
totalKnownBadCount.get()).append(
"</td></tr>"); 
 
  347             detailsSb.append(
"<tr><td>") 
 
  348                      .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.complete.totalCalcTime"))
 
  349                      .append(
"</td><td>").append(jobTotals.
totalCalctime.get()).append(
"</td></tr>\n"); 
 
  350             detailsSb.append(
"<tr><td>") 
 
  351                      .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.complete.totalLookupTime"))
 
  352                      .append(
"</td><td>").append(jobTotals.
totalLookuptime.get()).append(
"</td></tr>\n"); 
 
  353             detailsSb.append(
"</table>"); 
 
  355             detailsSb.append(
"<p>") 
 
  356                      .append(NbBundle.getMessage(
this.getClass(), 
"HashDbIngestModule.complete.databasesUsed"))
 
  357                      .append(
"</p>\n<ul>"); 
 
  358             for (
HashDb db : knownBadHashSets) {
 
  359                 detailsSb.append(
"<li>").append(db.getHashSetName()).append(
"</li>\n"); 
 
  362             detailsSb.append(
"</ul>"); 
 
  367                 NbBundle.getMessage(this.getClass(),
 
  368                                     "HashDbIngestModule.complete.hashLookupResults"),
 
  369                 detailsSb.toString()));
 
static String calculateMd5(AbstractFile file)
 
synchronized long decrementAndGet(long jobId)
 
ProcessResult process(AbstractFile file)
 
List< HashDb > knownHashSets
 
static IngestMessage createDataMessage(String source, String subject, String detailsHtml, String uniqueKey, BlackboardArtifact data)
 
final HashLookupModuleSettings settings
 
static IngestMessage createErrorMessage(String source, String subject, String detailsHtml)
 
AtomicLong totalKnownBadCount
 
TskData.TSK_DB_FILES_TYPE_ENUM getType()
 
static final IngestModuleReferenceCounter refCounter
 
AtomicLong totalLookuptime
 
void startUp(org.sleuthkit.autopsy.ingest.IngestJobContext context)
 
synchronized long incrementAndGet(long jobId)
 
static IngestMessage createMessage(MessageType messageType, String source, String subject, String detailsHtml)
 
static synchronized IngestJobTotals getTotalsForIngestJobs(long ingestJobId)
 
static final int MAX_COMMENT_SIZE
 
void updateEnabledHashSets(List< HashDb > allHashSets, List< HashDb > enabledHashSets)
 
List< HashDb > knownBadHashSets
 
void postHashSetHitToBlackboard(AbstractFile abstractFile, String md5Hash, String hashSetName, String comment, boolean showInboxMessage)
 
final SleuthkitCase skCase
 
synchronized List< HashDb > getKnownBadFileHashSets()
 
static final HashMap< Long, IngestJobTotals > totalsForIngestJobs
 
void addAttribute(BlackboardAttribute attr)
 
static synchronized HashDbManager getInstance()
 
void postMessage(final IngestMessage message)
 
void fireModuleDataEvent(ModuleDataEvent moduleDataEvent)
 
ArrayList< String > getComments()
 
SleuthkitCase getSleuthkitCase()
 
BlackboardArtifact newArtifact(int artifactTypeID)
 
boolean setKnown(AbstractFile file, FileKnown fileKnown)
 
static Case getCurrentCase()
 
static IngestMessage createWarningMessage(String source, String subject, String detailsHtml)
 
synchronized void postSummary()
 
final IngestServices services
 
synchronized List< HashDb > getKnownFileHashSets()
 
static Logger getLogger(String name)
 
static final Logger logger
 
final HashDbManager hashDbManager
 
static synchronized IngestServices getInstance()