Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AccountSummary.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2019-2020 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.autopsy.communications.relationships;
20
21import java.util.Collection;
22import java.util.List;
23import java.util.Set;
24import java.util.logging.Level;
25import org.sleuthkit.autopsy.coreutils.ImageUtils;
26import org.sleuthkit.autopsy.coreutils.Logger;
27import org.sleuthkit.datamodel.AbstractFile;
28import org.sleuthkit.datamodel.Account;
29import org.sleuthkit.datamodel.BlackboardArtifact;
30import org.sleuthkit.datamodel.BlackboardAttribute;
31import org.sleuthkit.datamodel.Content;
32import org.sleuthkit.datamodel.TskCoreException;
33import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
34import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
35import org.sleuthkit.datamodel.CommunicationsUtils;
36import org.sleuthkit.datamodel.InvalidAccountIDException;
37import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
38
43class AccountSummary {
44
45 private int attachmentCnt;
46 private int messagesCnt;
47 private int emailCnt;
48 private int callLogCnt;
49 private int contactsCnt;
50 private int mediaCnt;
51 private int referenceCnt;
52
53 private final Account selectedAccount;
54 private final Set<BlackboardArtifact> artifacts;
55
56 private static final Logger logger = Logger.getLogger(AccountSummary.class.getName());
57
64 AccountSummary(Account selectedAccount, Set<BlackboardArtifact> artifacts) {
65 this.selectedAccount = selectedAccount;
66 this.artifacts = artifacts;
67 initCounts();
68 }
69
73 private void initCounts() {
74 for (BlackboardArtifact artifact : artifacts) {
75 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
76 if (null != fromID) {
77 switch (fromID) {
78 case TSK_EMAIL_MSG:
79 emailCnt++;
80 break;
81 case TSK_CALLLOG:
82 callLogCnt++;
83 break;
84 case TSK_MESSAGE:
85 messagesCnt++;
86 break;
87 case TSK_CONTACT:
88 if (selectedAccount.getAccountType() != Account.Type.DEVICE) {
89 String typeSpecificID = selectedAccount.getTypeSpecificID();
90
91 List<BlackboardAttribute> attributes = null;
92
93 try{
94 attributes = artifact.getAttributes();
95 } catch(TskCoreException ex) {
96 logger.log(Level.WARNING, String.format("Unable to getAttributes for artifact: %d", artifact.getArtifactID()), ex);
97 break;
98 }
99
100 boolean isReference = false;
101
102 for (BlackboardAttribute attribute : attributes) {
103
104 String attributeTypeName = attribute.getAttributeType().getTypeName();
105 String attributeValue = attribute.getValueString();
106 try {
107 if (attributeTypeName.contains("PHONE")) {
108 attributeValue = CommunicationsUtils.normalizePhoneNum(attributeValue);
109 } else if (attributeTypeName.contains("EMAIL")) {
110 attributeValue = CommunicationsUtils.normalizeEmailAddress(attributeValue);
111 }
112
113 if (typeSpecificID.equals(attributeValue)) {
114 isReference = true;
115 break;
116 }
117 } catch (InvalidAccountIDException ex) {
118 logger.log(Level.WARNING, String.format("Exception thrown "
119 + "in trying to normalize attribute value: %s",
120 attributeValue), ex); //NON-NLS
121 }
122
123 }
124 if (isReference) {
125 referenceCnt++;
126 } else {
127 contactsCnt++;
128 }
129 } else {
130 contactsCnt++;
131 }
132 break;
133 default:
134 break;
135 }
136 }
137 try {
138 // count the attachments from the TSK_ATTACHMENTS attribute.
139 BlackboardAttribute attachmentsAttr = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
140 if (attachmentsAttr != null) {
141 try {
142 MessageAttachments msgAttachments = BlackboardJsonAttrUtil.fromAttribute(attachmentsAttr, MessageAttachments.class);
143 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
144 for (FileAttachment fileAttachment : fileAttachments) {
145 attachmentCnt++;
146 long attachedFileObjId = fileAttachment.getObjectId();
147 if (attachedFileObjId >= 0) {
148 AbstractFile attachedFile = artifact.getSleuthkitCase().getAbstractFileById(attachedFileObjId);
149 if (ImageUtils.thumbnailSupported(attachedFile)) {
150 mediaCnt++;
151 }
152 }
153 }
154 }
155 catch (BlackboardJsonAttrUtil.InvalidJsonException ex) {
156 logger.log(Level.WARNING, String.format("Unable to parse json for MessageAttachments object in artifact: %s", artifact.getName()), ex);
157 }
158 } else { // backward compatibility - email message attachments are derived files, children of the message.
159 attachmentCnt += artifact.getChildrenCount();
160 for (Content childContent : artifact.getChildren()) {
161 if (ImageUtils.thumbnailSupported(childContent)) {
162 mediaCnt++;
163 }
164 }
165 }
166 } catch (TskCoreException ex) {
167 logger.log(Level.WARNING, String.format("Exception thrown "
168 + "from getChildrenCount artifactID: %d",
169 artifact.getArtifactID()), ex); //NON-NLS
170 }
171 }
172 }
173
179 public int getAttachmentCnt() {
180 return attachmentCnt;
181 }
182
188 public int getMessagesCnt() {
189 return messagesCnt;
190 }
191
197 public int getEmailCnt() {
198 return emailCnt;
199 }
200
206 public int getCallLogCnt() {
207 return callLogCnt;
208 }
209
215 public int getContactsCnt() {
216 return contactsCnt;
217 }
218
224 public int getThumbnailCnt() {
225 return mediaCnt;
226 }
227
233 public int getReferenceCnt() {
234 return referenceCnt;
235 }
236}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.