19 package org.sleuthkit.autopsy.centralrepository.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.HashSet;
24 import java.util.List;
25 import java.util.Optional;
27 import java.util.logging.Level;
28 import org.openide.util.NbBundle.Messages;
36 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
38 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
42 import org.
sleuthkit.datamodel.InvalidAccountIDException;
53 private static final List<String>
domainsToSkip = Arrays.asList(
"localhost",
"127.0.0.1");
57 ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID(),
58 ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID(),
59 ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID(),
60 ARTIFACT_TYPE.TSK_WEB_HISTORY.getTypeID(),
61 ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID()
74 @Messages({
"CorrelationAttributeUtil.emailaddresses.text=Email Addresses"})
76 return Bundle.CorrelationAttributeUtil_emailaddresses_text();
87 addAll(DOMAIN_ARTIFACT_TYPE_IDS);
89 add(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getTypeID());
90 add(ARTIFACT_TYPE.TSK_WIFI_NETWORK.getTypeID());
91 add(ARTIFACT_TYPE.TSK_WIFI_NETWORK_ADAPTER.getTypeID());
92 add(ARTIFACT_TYPE.TSK_BLUETOOTH_PAIRING.getTypeID());
93 add(ARTIFACT_TYPE.TSK_BLUETOOTH_ADAPTER.getTypeID());
94 add(ARTIFACT_TYPE.TSK_DEVICE_INFO.getTypeID());
95 add(ARTIFACT_TYPE.TSK_SIM_ATTACHED.getTypeID());
96 add(ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS.getTypeID());
97 add(ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID());
98 add(ARTIFACT_TYPE.TSK_INSTALLED_PROG.getTypeID());
116 if (SOURCE_TYPES_FOR_CR_INSERT.contains(artifact.getArtifactTypeID())) {
123 return new ArrayList<>();
151 List<CorrelationAttributeInstance> correlationAttrs =
new ArrayList<>();
154 if (sourceArtifact != null) {
155 int artifactTypeID = sourceArtifact.getArtifactTypeID();
156 if (artifactTypeID == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
157 BlackboardAttribute setNameAttr = sourceArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME));
161 }
else if (DOMAIN_ARTIFACT_TYPE_IDS.contains(artifactTypeID)) {
162 BlackboardAttribute domainAttr = sourceArtifact.getAttribute(
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DOMAIN));
163 if ((domainAttr != null)
164 && !domainsToSkip.contains(domainAttr.getValueString())) {
167 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getTypeID()) {
171 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WIFI_NETWORK.getTypeID()) {
174 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WIFI_NETWORK_ADAPTER.getTypeID()
175 || artifactTypeID == ARTIFACT_TYPE.TSK_BLUETOOTH_PAIRING.getTypeID()
176 || artifactTypeID == ARTIFACT_TYPE.TSK_BLUETOOTH_ADAPTER.getTypeID()) {
179 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_DEVICE_INFO.getTypeID()) {
184 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_SIM_ATTACHED.getTypeID()) {
188 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS.getTypeID()) {
192 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
195 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_INSTALLED_PROG.getTypeID()) {
196 BlackboardAttribute setNameAttr = sourceArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH));
197 String pathAttrString = null;
198 if (setNameAttr != null) {
199 pathAttrString = setNameAttr.getValueString();
201 if (pathAttrString != null && !pathAttrString.isEmpty()) {
206 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_CONTACT.getTypeID()
207 || artifactTypeID == ARTIFACT_TYPE.TSK_CALLLOG.getTypeID()
208 || artifactTypeID == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
213 logger.log(Level.WARNING, String.format(
"Error normalizing correlation attribute (%s)", artifact), ex);
214 return correlationAttrs;
215 }
catch (InvalidAccountIDException ex) {
216 logger.log(Level.WARNING, String.format(
"Invalid account identifier (artifactID: %d)", artifact.getId()));
217 return correlationAttrs;
219 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", artifact), ex);
220 return correlationAttrs;
221 }
catch (TskCoreException ex) {
222 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", artifact), ex);
223 return correlationAttrs;
225 logger.log(Level.SEVERE,
"Error getting current case", ex);
226 return correlationAttrs;
228 return correlationAttrs;
251 if (null != artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER))) {
252 value = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER)).getValueString();
253 }
else if (null != artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM))) {
254 value = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM)).getValueString();
255 }
else if (null != artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO))) {
256 value = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO)).getValueString();
267 if (corrAttr != null) {
268 corrAttrInstances.add(corrAttr);
287 BlackboardArtifact sourceArtifact = null;
288 if (BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID() == artifact.getArtifactTypeID()) {
289 BlackboardAttribute assocArtifactAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
290 if (assocArtifactAttr != null) {
294 sourceArtifact = artifact;
296 return sourceArtifact;
312 private static void makeCorrAttrFromAcctArtifact(List<CorrelationAttributeInstance> corrAttrInstances, BlackboardArtifact acctArtifact)
throws InvalidAccountIDException, TskCoreException, CentralRepoException {
315 BlackboardAttribute accountTypeAttribute = acctArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE));
316 String accountTypeStr = accountTypeAttribute.getValueString();
320 Account.Type predefinedAccountType = Account.Type.PREDEFINED_ACCOUNT_TYPES.stream().filter(type -> type.getTypeName().equalsIgnoreCase(accountTypeStr)).findAny().orElse(null);
323 if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) ==
false && predefinedAccountType != null) {
327 if (!optCrAccountType.isPresent()) {
336 BlackboardAttribute accountIdAttribute = acctArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID));
337 String accountIdStr = accountIdAttribute.getValueString();
343 if (corrAttr != null) {
345 corrAttr.setAccountId(crAccount.
getId());
346 corrAttrInstances.add(corrAttr);
365 private static void makeCorrAttrFromArtifactAttr(List<CorrelationAttributeInstance> corrAttrInstances, BlackboardArtifact artifact, ATTRIBUTE_TYPE artAttrType,
int typeId)
throws CentralRepoException, TskCoreException {
366 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(artAttrType));
367 if (attribute != null) {
368 String value = attribute.getValueString();
369 if ((null != value) && (value.isEmpty() ==
false)) {
372 corrAttrInstances.add(inst);
398 Content sourceContent = currentCase.
getSleuthkitCase().getContentById(artifact.getObjectID());
399 if (null == sourceContent) {
400 logger.log(Level.SEVERE,
"Error creating artifact instance of type {0}. Failed to load content with ID: {1} associated with artifact with ID: {2}",
401 new Object[]{correlationType.getDisplayName(), artifact.getObjectID(), artifact.getId()});
405 Content ds = sourceContent.getDataSource();
407 logger.log(Level.SEVERE,
"Error creating artifact instance of type {0}. Failed to load data source for content with ID: {1}",
408 new Object[]{correlationType.getDisplayName(), artifact.getObjectID()});
413 if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INSTALLED_PROG.getTypeID()) {
421 TskData.FileKnown.UNKNOWN,
422 sourceContent.getId());
424 if (! (sourceContent instanceof AbstractFile)) {
425 logger.log(Level.SEVERE,
"Error creating artifact instance of type {0}. Source content of artifact with ID: {1} is not an AbstractFile",
426 new Object[]{correlationType.getDisplayName(), artifact.getId()});
429 AbstractFile bbSourceFile = (AbstractFile) sourceContent;
436 bbSourceFile.getParentPath() + bbSourceFile.
getName(),
438 TskData.FileKnown.UNKNOWN,
439 bbSourceFile.getId());
441 }
catch (TskCoreException ex) {
442 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", artifact), ex);
444 }
catch (CentralRepoException ex) {
445 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", artifact), ex);
448 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", artifact), ex);
450 }
catch (NoCurrentCaseException ex) {
451 logger.log(Level.SEVERE,
"Error getting current case", ex);
485 if (null == correlationCase) {
490 }
catch (TskCoreException ex) {
491 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", file), ex);
493 }
catch (CentralRepoException ex) {
494 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
496 }
catch (NoCurrentCaseException ex) {
497 logger.log(Level.SEVERE,
"Error getting current case", ex);
504 }
catch (CentralRepoException ex) {
505 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
508 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
518 if (correlationAttributeInstance == null && file.getMd5Hash() != null) {
519 String filePath = (file.getParentPath() + file.getName()).toLowerCase();
522 }
catch (CentralRepoException ex) {
523 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
526 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
531 return correlationAttributeInstance;
559 String md5 = file.getMd5Hash();
560 if (md5 == null || md5.isEmpty() || HashUtility.isNoDataMd5(md5)) {
573 file.getParentPath() + file.
getName(),
575 TskData.FileKnown.UNKNOWN,
578 }
catch (TskCoreException ex) {
579 logger.log(Level.SEVERE, String.format(
"Error querying case database (%s)", file), ex);
581 }
catch (CentralRepoException ex) {
582 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
585 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
587 }
catch (NoCurrentCaseException ex) {
588 logger.log(Level.SEVERE,
"Error getting current case", ex);
605 switch (file.getType()) {
618 return file.isMetaFlagSet(TskData.TSK_FS_META_FLAG_ENUM.ALLOC);
620 logger.log(Level.WARNING,
"Unexpected file type {0}", file.getType().getName());
static final int EMAIL_TYPE_ID
static final int USBID_TYPE_ID
static String getEmailAddressAttrDisplayName()
static CorrelationAttributeInstance makeCorrAttr(BlackboardArtifact artifact, CorrelationAttributeInstance.Type correlationType, String value)
static final int ICCID_TYPE_ID
CorrelationAttributeUtil()
static Set< Integer > DOMAIN_ARTIFACT_TYPE_IDS
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
static CorrelationAttributeInstance makeCorrAttrFromFile(AbstractFile file)
CorrelationCase getCase(Case autopsyCase)
static final int IMEI_TYPE_ID
static final Logger logger
Optional< CentralRepoAccountType > getAccountTypeByName(String accountTypeName)
static List< CorrelationAttributeInstance > makeCorrAttrsForCorrelation(BlackboardArtifact artifact)
static boolean isSupportedAbstractFileType(AbstractFile file)
static void makeCorrAttrsFromCommunicationArtifacts(List< CorrelationAttributeInstance > corrAttrInstances, BlackboardArtifact artifact)
static final int DOMAIN_TYPE_ID
static final int PHONE_TYPE_ID
static CorrelationAttributeInstance getCorrAttrForFile(AbstractFile file)
static final int INSTALLED_PROGS_TYPE_ID
SleuthkitCase getSleuthkitCase()
static void makeCorrAttrFromArtifactAttr(List< CorrelationAttributeInstance > corrAttrInstances, BlackboardArtifact artifact, ATTRIBUTE_TYPE artAttrType, int typeId)
CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttributeInstance.Type type, CorrelationCase correlationCase, CorrelationDataSource correlationDataSource, String value, String filePath)
static final List< String > domainsToSkip
static final int MAC_TYPE_ID
int getCorrelationTypeId()
static BlackboardArtifact getCorrAttrSourceArtifact(BlackboardArtifact artifact)
static List< CorrelationAttributeInstance > makeCorrAttrsToSave(BlackboardArtifact artifact)
static final int IMSI_TYPE_ID
synchronized static Logger getLogger(String name)
static void makeCorrAttrFromAcctArtifact(List< CorrelationAttributeInstance > corrAttrInstances, BlackboardArtifact acctArtifact)
CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId)
static Case getCurrentCaseThrows()
static final int SSID_TYPE_ID
static CentralRepository getInstance()
static final Set< Integer > SOURCE_TYPES_FOR_CR_INSERT
static final int FILES_TYPE_ID
CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID)