19 package org.sleuthkit.autopsy.centralrepository.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Optional;
28 import java.util.logging.Level;
29 import org.openide.util.NbBundle.Messages;
38 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
40 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
45 import org.
sleuthkit.datamodel.InvalidAccountIDException;
58 private static final List<String>
domainsToSkip = Arrays.asList(
"localhost",
"127.0.0.1");
62 ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID(),
63 ARTIFACT_TYPE.TSK_WEB_COOKIE.getTypeID(),
64 ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID(),
65 ARTIFACT_TYPE.TSK_WEB_HISTORY.getTypeID(),
66 ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID()
79 @Messages({
"CorrelationAttributeUtil.emailaddresses.text=Email Addresses"})
81 return Bundle.CorrelationAttributeUtil_emailaddresses_text();
85 int artifactTypeID = artifact.getArtifactTypeID();
87 if (artifactTypeID == ARTIFACT_TYPE.TSK_CALLLOG.getTypeID()
88 || artifactTypeID == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()
89 || artifactTypeID == ARTIFACT_TYPE.TSK_CONTACT.getTypeID()) {
90 return Collections.emptyList();
113 return Collections.emptyList();
116 public static List<CorrelationAttributeInstance>
makeCorrAttrsToSave(OsAccountInstance osAccountInstance) {
139 List<CorrelationAttributeInstance> correlationAttrs =
new ArrayList<>();
141 int artifactTypeID = analysisResult.getArtifactTypeID();
142 if (artifactTypeID == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
143 BlackboardAttribute assocArtifactAttr = analysisResult.getAttribute(BlackboardAttribute.Type.TSK_ASSOCIATED_ARTIFACT);
144 if (assocArtifactAttr != null) {
146 if (sourceArtifact instanceof DataArtifact) {
148 }
else if (sourceArtifact instanceof AnalysisResult) {
151 String sourceName = sourceArtifact != null ?
"SourceArtifact display name: " + sourceArtifact.getDisplayName() :
"SourceArtifact was null";
152 logger.log(Level.WARNING,
"Source artifact found through TSK_ASSOCIATED_ARTIFACT attribute was not a DataArtifact or "
153 +
"an Analysis Result. AssociateArtifactAttr Value: {0} {1}",
154 new Object[]{assocArtifactAttr.getValueString(), sourceName});
159 if (artifactTypeID == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
160 BlackboardAttribute setNameAttr = analysisResult.getAttribute(BlackboardAttribute.Type.TSK_SET_NAME);
165 Content parent = analysisResult.getParent();
166 if (parent instanceof AbstractFile) {
168 }
else if (parent instanceof AnalysisResult) {
170 }
else if (parent instanceof DataArtifact) {
172 }
else if (parent instanceof OsAccount) {
173 for (OsAccountInstance osAccountInst : ((OsAccount) parent).getOsAccountInstances()) {
174 if (osAccountInst.getDataSource().equals(analysisResult.getDataSource())) {
182 }
catch (TskCoreException ex) {
183 logger.log(Level.SEVERE,
"Failed to get information regarding correlation attributes from AnalysisResult", ex);
185 logger.log(Level.SEVERE,
"Attempted to retrieve correlation attributes for search with no currently open case.", ex);
187 logger.log(Level.SEVERE,
"Failed to get correlation type from central repository.", ex);
189 return correlationAttrs;
211 List<CorrelationAttributeInstance> correlationAttrs =
new ArrayList<>();
214 List<BlackboardAttribute> attributes = artifact.getAttributes();
216 int artifactTypeID = artifact.getArtifactTypeID();
217 if (DOMAIN_ARTIFACT_TYPE_IDS.contains(artifactTypeID)) {
218 BlackboardAttribute domainAttr =
getAttribute(attributes,
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DOMAIN));
219 if ((domainAttr != null)
220 && !domainsToSkip.contains(domainAttr.getValueString())) {
223 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getTypeID()) {
226 Content dataSource = sourceContent.getDataSource();
228 attributes, sourceContent, dataSource));
230 attributes, sourceContent, dataSource));
231 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WIFI_NETWORK.getTypeID()) {
233 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WIFI_NETWORK_ADAPTER.getTypeID()
234 || artifactTypeID == ARTIFACT_TYPE.TSK_BLUETOOTH_PAIRING.getTypeID()
235 || artifactTypeID == ARTIFACT_TYPE.TSK_BLUETOOTH_ADAPTER.getTypeID()) {
237 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_DEVICE_INFO.getTypeID()) {
240 Content dataSource = sourceContent.getDataSource();
242 attributes, sourceContent, dataSource));
244 attributes, sourceContent, dataSource));
246 attributes, sourceContent, dataSource));
248 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_SIM_ATTACHED.getTypeID()) {
251 Content dataSource = sourceContent.getDataSource();
253 attributes, sourceContent, dataSource));
255 attributes, sourceContent, dataSource));
257 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS.getTypeID()) {
260 Content dataSource = sourceContent.getDataSource();
262 attributes, sourceContent, dataSource));
264 attributes, sourceContent, dataSource));
266 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
269 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_INSTALLED_PROG.getTypeID()) {
270 BlackboardAttribute setNameAttr =
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH));
271 String pathAttrString = null;
272 if (setNameAttr != null) {
273 pathAttrString = setNameAttr.getValueString();
275 if (pathAttrString != null && !pathAttrString.isEmpty()) {
280 }
else if (artifactTypeID == ARTIFACT_TYPE.TSK_CONTACT.getTypeID()
281 || artifactTypeID == ARTIFACT_TYPE.TSK_CALLLOG.getTypeID()
282 || artifactTypeID == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
286 logger.log(Level.WARNING, String.format(
"Error normalizing correlation attribute (%s)", artifact), ex);
287 return correlationAttrs;
288 }
catch (InvalidAccountIDException ex) {
289 logger.log(Level.WARNING, String.format(
"Invalid account identifier (artifactID: %d)", artifact.getId()));
290 return correlationAttrs;
292 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", artifact), ex);
293 return correlationAttrs;
294 }
catch (TskCoreException ex) {
295 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", artifact), ex);
296 return correlationAttrs;
298 logger.log(Level.SEVERE,
"Error getting current case", ex);
299 return correlationAttrs;
301 return correlationAttrs;
314 private static BlackboardAttribute
getAttribute(List<BlackboardAttribute> attributes, BlackboardAttribute.Type attributeType) throws TskCoreException {
315 for (BlackboardAttribute attribute : attributes) {
316 if (attribute.getAttributeType().equals(attributeType)) {
347 if (null !=
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER))) {
348 value =
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER)).getValueString();
349 }
else if (null !=
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM))) {
350 value =
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM)).getValueString();
351 }
else if (null !=
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO))) {
352 value =
getAttribute(attributes,
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO)).getValueString();
357 List<CorrelationAttributeInstance> corrAttrInstances = Collections.emptyList();
362 if (corrAttr != null) {
363 corrAttrInstances.add(corrAttr);
366 return corrAttrInstances;
382 private static void makeCorrAttrFromAcctArtifact(List<CorrelationAttributeInstance> corrAttrInstances, BlackboardArtifact acctArtifact)
throws InvalidAccountIDException, TskCoreException, CentralRepoException {
385 BlackboardAttribute accountTypeAttribute = acctArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE));
386 String accountTypeStr = accountTypeAttribute.getValueString();
390 Account.Type predefinedAccountType = Account.Type.PREDEFINED_ACCOUNT_TYPES.stream().filter(type -> type.getTypeName().equalsIgnoreCase(accountTypeStr)).findAny().orElse(null);
393 if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) ==
false && predefinedAccountType != null) {
397 if (!optCrAccountType.isPresent()) {
406 BlackboardAttribute accountIdAttribute = acctArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID));
407 String accountIdStr = accountIdAttribute.getValueString();
413 if (corrAttr != null) {
415 corrAttr.setAccountId(crAccount.
getId());
416 corrAttrInstances.add(corrAttr);
441 List<BlackboardAttribute> attributes, Content sourceContent, Content dataSource)
throws CentralRepoException, TskCoreException {
442 List<CorrelationAttributeInstance> corrAttrInstances =
new ArrayList<>();
443 BlackboardAttribute attribute =
getAttribute(attributes,
new BlackboardAttribute.Type(artAttrType));
444 if (attribute != null) {
445 String value = attribute.getValueString();
446 if ((null != value) && (value.isEmpty() ==
false)) {
449 corrAttrInstances.add(inst);
453 return corrAttrInstances;
474 List<BlackboardAttribute> attributes)
throws CentralRepoException, TskCoreException {
497 return makeCorrAttr(artifact, correlationType, value, null, null);
520 Content sourceContent, Content dataSource) {
521 Content srcContent = sourceContent;
522 Content dataSrc = dataSource;
524 if (srcContent == null) {
527 if (null == srcContent) {
528 logger.log(Level.SEVERE,
"Error creating artifact instance of type {0}. Failed to load content with ID: {1} associated with artifact with ID: {2}",
529 new Object[]{correlationType.getDisplayName(), artifact.getObjectID(), artifact.getId()});
532 if (dataSrc == null) {
533 dataSrc = srcContent.getDataSource();
535 if (dataSrc == null) {
536 logger.log(Level.SEVERE,
"Error creating artifact instance of type {0}. Failed to load data source for content with ID: {1}",
537 new Object[]{correlationType.getDisplayName(), artifact.getObjectID()});
542 if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INSTALLED_PROG.getTypeID()
543 || ! (srcContent instanceof AbstractFile)) {
551 TskData.FileKnown.UNKNOWN,
554 AbstractFile bbSourceFile = (AbstractFile) srcContent;
561 bbSourceFile.getParentPath() + bbSourceFile.
getName(),
563 TskData.FileKnown.UNKNOWN,
564 bbSourceFile.getId());
566 }
catch (TskCoreException ex) {
567 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", artifact), ex);
569 }
catch (CentralRepoException ex) {
570 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", artifact), ex);
573 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", artifact), ex);
576 logger.log(Level.SEVERE,
"Error getting current case", ex);
614 if (null == correlationCase) {
619 }
catch (TskCoreException ex) {
620 logger.log(Level.SEVERE, String.format(
"Error getting querying case database (%s)", file), ex);
622 }
catch (CentralRepoException ex) {
623 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
626 logger.log(Level.SEVERE,
"Error getting current case", ex);
633 }
catch (CentralRepoException ex) {
634 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
637 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
647 if (correlationAttributeInstance == null && file.getMd5Hash() != null) {
648 String filePath = (file.getParentPath() + file.getName()).toLowerCase();
651 }
catch (CentralRepoException ex) {
652 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
655 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
660 return correlationAttributeInstance;
684 List<CorrelationAttributeInstance> fileTypeList =
new ArrayList<>();
690 String md5 = file.getMd5Hash();
691 if (md5 == null || md5.isEmpty() || HashUtility.isNoDataMd5(md5)) {
704 file.getParentPath() + file.
getName(),
706 TskData.FileKnown.UNKNOWN,
708 }
catch (TskCoreException ex) {
709 logger.log(Level.SEVERE, String.format(
"Error querying case database (%s)", file), ex);
710 }
catch (CentralRepoException ex) {
711 logger.log(Level.SEVERE, String.format(
"Error querying central repository (%s)", file), ex);
713 logger.log(Level.WARNING, String.format(
"Error creating correlation attribute instance (%s)", file), ex);
715 logger.log(Level.SEVERE,
"Error getting current case", ex);
732 switch (file.getType()) {
745 return file.isMetaFlagSet(TskData.TSK_FS_META_FLAG_ENUM.ALLOC);
747 logger.log(Level.WARNING,
"Unexpected file type {0}", file.getType().getName());
753 List<CorrelationAttributeInstance> correlationAttrs =
new ArrayList<>();
754 OsAccount account = null;
755 DataSource dataSource = null;
756 if (osAccountInst != null) {
758 account = osAccountInst.getOsAccount();
759 dataSource = osAccountInst.getDataSource();
760 }
catch (TskCoreException ex) {
761 logger.log(Level.SEVERE,
"Error getting information from OsAccountInstance.", ex);
764 if (account != null && dataSource != null) {
765 Optional<String> accountAddr = account.getAddr();
768 if (accountAddr.isPresent() && !accountAddr.get().equals(
"S-1-5-18") && !accountAddr.get().equals(
"S-1-5-19") && !accountAddr.get().equals(
"S-1-5-20")) {
779 TskData.FileKnown.KNOWN,
781 correlationAttrs.add(correlationAttributeInstance);
782 }
catch (CentralRepoException ex) {
783 logger.log(Level.SEVERE, String.format(
"Cannot get central repository for OsAccount: %s.", accountAddr.get()), ex);
785 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
787 logger.log(Level.SEVERE,
"Exception with Correlation Attribute Normalization.", ex);
791 return correlationAttrs;
static List< CorrelationAttributeInstance > makeCorrAttrsToSave(OsAccountInstance osAccountInstance)
static final int EMAIL_TYPE_ID
static CorrelationAttributeInstance makeCorrAttr(BlackboardArtifact artifact, CorrelationAttributeInstance.Type correlationType, String value, Content sourceContent, Content dataSource)
static final int USBID_TYPE_ID
static List< CorrelationAttributeInstance > makeCorrAttrsFromCommunicationArtifact(BlackboardArtifact artifact, List< BlackboardAttribute > attributes)
static String getEmailAddressAttrDisplayName()
static List< CorrelationAttributeInstance > makeCorrAttrsForSearch(OsAccountInstance osAccountInst)
static CorrelationAttributeInstance makeCorrAttr(BlackboardArtifact artifact, CorrelationAttributeInstance.Type correlationType, String value)
static final int ICCID_TYPE_ID
CorrelationAttributeUtil()
static List< CorrelationAttributeInstance > makeCorrAttrsForSearch(AbstractFile file)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
CorrelationCase getCase(Case autopsyCase)
static List< CorrelationAttributeInstance > makeCorrAttrFromArtifactAttr(BlackboardArtifact artifact, ATTRIBUTE_TYPE artAttrType, int typeId, List< BlackboardAttribute > attributes, Content sourceContent, Content dataSource)
static final int IMEI_TYPE_ID
static final Logger logger
Optional< CentralRepoAccountType > getAccountTypeByName(String accountTypeName)
static List< CorrelationAttributeInstance > makeCorrAttrsForSearch(DataArtifact artifact)
static List< CorrelationAttributeInstance > makeCorrAttrsToSave(AbstractFile file)
static boolean isSupportedAbstractFileType(AbstractFile file)
static List< CorrelationAttributeInstance > makeCorrAttrsForSearch(AnalysisResult analysisResult)
static BlackboardAttribute getAttribute(List< BlackboardAttribute > attributes, BlackboardAttribute.Type attributeType)
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 List< CorrelationAttributeInstance > makeCorrAttrsToSave(AnalysisResult file)
static List< CorrelationAttributeInstance > makeCorrAttrFromArtifactAttr(BlackboardArtifact artifact, ATTRIBUTE_TYPE artAttrType, int typeId, List< BlackboardAttribute > attributes)
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 final int IMSI_TYPE_ID
static List< CorrelationAttributeInstance > makeCorrAttrsToSave(DataArtifact artifact)
synchronized static Logger getLogger(String name)
static void makeCorrAttrFromAcctArtifact(List< CorrelationAttributeInstance > corrAttrInstances, BlackboardArtifact acctArtifact)
static final int OSACCOUNT_TYPE_ID
CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId)
static Case getCurrentCaseThrows()
static final int SSID_TYPE_ID
static CentralRepository getInstance()
static final int FILES_TYPE_ID
CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID)
static boolean isEnabled()
static final Set< Integer > DOMAIN_ARTIFACT_TYPE_IDS