From 75a94be77bb33a4a6d55f180b64256e6b35a5226 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Fri, 27 Sep 2019 14:31:22 -0400 Subject: [PATCH] inital commit --- .../RelationshipsNodeUtilities.java | 35 ++++++ .../relationships/SelectionSummary.java | 119 ++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100755 Core/src/org/sleuthkit/autopsy/communications/relationships/SelectionSummary.java diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/RelationshipsNodeUtilities.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/RelationshipsNodeUtilities.java index db2f6f6ebd..523d1d8ceb 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/RelationshipsNodeUtilities.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/RelationshipsNodeUtilities.java @@ -68,4 +68,39 @@ final class RelationshipsNodeUtilities { return ""; } } + + /** + * Normalize the phone number by removing all non numeric characters, except + * for leading +. + * + * @param phoneNum The phone number to normalize + * + * @return The normalized phone number. + */ + static String normalizePhoneNum(String phoneNum) { + String normailzedPhoneNum = phoneNum.replaceAll("\\D", ""); + + if (phoneNum.startsWith("+")) { + normailzedPhoneNum = "+" + normailzedPhoneNum; + } + + if (normailzedPhoneNum.isEmpty()) { + normailzedPhoneNum = phoneNum; + } + + return normailzedPhoneNum; + } + + /** + * Normalize the given email address by converting it to lowercase. + * + * @param emailAddress The email address tot normalize + * + * @return The normalized email address. + */ + static String normalizeEmailAddress(String emailAddress) { + String normailzedEmailAddr = emailAddress.toLowerCase(); + + return normailzedEmailAddr; + } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/SelectionSummary.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/SelectionSummary.java new file mode 100755 index 0000000000..9f29e30d11 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/SelectionSummary.java @@ -0,0 +1,119 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.communications.relationships; + +import java.util.List; +import java.util.logging.Level; +import org.sleuthkit.autopsy.coreutils.ImageUtils; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.datamodel.Account; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.BlackboardAttribute; +import org.sleuthkit.datamodel.Content; +import org.sleuthkit.datamodel.TskCoreException; + +class SelectionSummary { + + private int attachmentCnt; + private int messagesCnt; + private int emailCnt; + private int callLogCnt; + private int contactsCnt; + private int mediaCnt; + private int referenceCnt; + + private final Account selectedAccount; + private final List artifacts; + + private static final Logger logger = Logger.getLogger(SelectionSummary.class.getName()); + + SelectionSummary(Account selectedAccount, List artifacts) { + this.selectedAccount = selectedAccount; + this.artifacts = artifacts; + initCounts(); + } + + private void initCounts() { + for (BlackboardArtifact artifact : artifacts) { + BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID()); + if (null != fromID) { + switch (fromID) { + case TSK_EMAIL_MSG: + emailCnt++; + break; + case TSK_CALLLOG: + callLogCnt++; + break; + case TSK_MESSAGE: + messagesCnt++; + break; + case TSK_CONTACT: + if (selectedAccount.getAccountType() != Account.Type.DEVICE) { + String typeSpecificID = selectedAccount.getTypeSpecificID(); + + String name = RelationshipsNodeUtilities.getAttributeDisplayString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME); + String phoneNumber = RelationshipsNodeUtilities.getAttributeDisplayString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER); + String email = RelationshipsNodeUtilities.getAttributeDisplayString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL); + + if(typeSpecificID.equals(name) || + (RelationshipsNodeUtilities.normalizeEmailAddress(typeSpecificID).equals(RelationshipsNodeUtilities.normalizeEmailAddress(email))) || + (RelationshipsNodeUtilities.normalizePhoneNum(typeSpecificID).equals(RelationshipsNodeUtilities.normalizePhoneNum(phoneNumber)))) { + referenceCnt++; + } else { + contactsCnt++; + } + + } else { + contactsCnt++; + } + break; + default: + break; + } + } + try { + attachmentCnt += artifact.getChildrenCount(); + for (Content childContent : artifact.getChildren()) { + if (ImageUtils.thumbnailSupported(childContent)) { + mediaCnt++; + } + } + } catch (TskCoreException ex) { + logger.log(Level.WARNING, String.format("Exception thrown " + + "from getChildrenCount artifactID: %d", + artifact.getArtifactID()), ex); //NON-NLS + } + } + } + + public int getAttachmentCnt() { + return attachmentCnt; + } + + public int getMessagesCnt() { + return messagesCnt; + } + + public int getEmailCnt() { + return emailCnt; + } + + public int getCallLogCnt() { + return callLogCnt; + } + + public int getContactsCnt() { + return contactsCnt; + } + + public int getThumbnailCnt() { + return mediaCnt; + } + + public int getReferenceCnt() { + return referenceCnt; + } +}