19 package org.sleuthkit.datamodel;
21 import java.io.Serializable;
22 import java.io.UnsupportedEncodingException;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
30 import java.util.Objects;
31 import java.util.ResourceBundle;
50 private static final ResourceBundle bundle = ResourceBundle.getBundle(
"org.sleuthkit.datamodel.Bundle");
51 private final long artifactId;
52 private final long sourceObjId;
53 private final long artifactObjId;
54 private final long dataSourceObjId;
55 private final int artifactTypeId;
56 private final String artifactTypeName;
57 private final String displayName;
60 private final List<BlackboardAttribute> attrsCache =
new ArrayList<BlackboardAttribute>();
61 private boolean loadedCacheFromDb =
false;
63 private String uniquePath;
65 private byte[] contentBytes = null;
67 private volatile boolean checkedHasChildren;
69 private volatile int childrenCount;
91 BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long sourceObjId,
long artifactObjId,
long dataSourceObjId,
int artifactTypeID, String artifactTypeName, String displayName,
ReviewStatus reviewStatus) {
93 this.sleuthkitCase = sleuthkitCase;
94 this.artifactId = artifactID;
95 this.sourceObjId = sourceObjId;
96 this.artifactObjId = artifactObjId;
97 this.artifactTypeId = artifactTypeID;
98 this.dataSourceObjId = dataSourceObjId;
99 this.artifactTypeName = artifactTypeName;
100 this.displayName = displayName;
101 this.reviewStatus = reviewStatus;
103 this.checkedHasChildren =
false;
104 this.hasChildren =
false;
105 this.childrenCount = -1;
128 BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long sourceObjId,
long artifactObjID,
long dataSourceObjID,
int artifactTypeID, String artifactTypeName, String displayName,
ReviewStatus reviewStatus,
boolean isNew) {
129 this(sleuthkitCase, artifactID, sourceObjId, artifactObjID, dataSourceObjID, artifactTypeID, artifactTypeName, displayName, reviewStatus);
136 this.loadedCacheFromDb =
true;
147 return sleuthkitCase;
156 return this.artifactId;
166 return this.sourceObjId;
174 long getDataSourceObjectID() {
175 return this.dataSourceObjId;
184 return this.artifactTypeId;
193 return this.artifactTypeName;
202 return this.displayName;
214 StringBuilder shortDescription =
new StringBuilder(
"");
216 case TSK_WEB_BOOKMARK:
218 case TSK_WEB_DOWNLOAD:
219 case TSK_WEB_HISTORY:
222 case TSK_KEYWORD_HIT:
225 case TSK_DEVICE_ATTACHED:
272 shortDescription.append(
" ");
273 shortDescription.append(MessageFormat.format(bundle.getString(
"BlackboardArtifact.shortDescriptionDate.text"), date.
getDisplayString()));
300 reviewStatus = newStatus;
315 attribute.setArtifactId(artifactId);
318 attrsCache.add(attribute);
330 ArrayList<BlackboardAttribute> attributes;
331 if (
false == loadedCacheFromDb) {
334 attrsCache.addAll(attributes);
335 loadedCacheFromDb =
true;
337 attributes =
new ArrayList<BlackboardAttribute>(attrsCache);
359 if (attribute.getAttributeType().equals(attributeType)) {
376 if (attributes.isEmpty()) {
380 attribute.setArtifactId(artifactId);
384 attrsCache.addAll(attributes);
397 if (uniquePath == null) {
400 if (myParent != null) {
409 if (parent == null) {
410 ObjectInfo parentInfo;
412 if (parentInfo == null) {
431 return new ArrayList<BlackboardArtifact>();
447 return new ArrayList<BlackboardArtifact>();
463 return new ArrayList<BlackboardArtifact>();
478 return new ArrayList<BlackboardArtifact>();
592 return new ArrayList<>();
605 return new HashSet<String>();
621 throw new TskCoreException(
"Cannot create artifact of an artifact. Not supported.");
636 throw new TskCoreException(
"Cannot create artifact of an artifact. Not supported.");
649 return visitor.
visit(
this);
661 if (
object == null) {
664 if (getClass() !=
object.getClass()) {
679 hash = 41 * hash + (int) (this.artifactId ^ (this.artifactId >>> 32));
690 return "BlackboardArtifact{" +
"artifactID=" + artifactId +
", objID=" +
getObjectID() +
", artifactObjID=" + artifactObjId +
", artifactTypeID=" + artifactTypeId +
", artifactTypeName=" + artifactTypeName +
", displayName=" + displayName +
", Case=" +
getSleuthkitCase() +
'}';
705 return visitor.
visit(
this);
717 if (contentBytes == null) {
719 loadArtifactContent();
725 return contentBytes.length;
752 if (contentBytes == null) {
753 loadArtifactContent();
756 if (0 == contentBytes.length) {
761 long readLen = Math.min(contentBytes.length - offset, len);
762 System.arraycopy(contentBytes, 0, buf, 0, (
int) readLen);
764 return (
int) readLen;
784 StringBuilder artifactContents =
new StringBuilder();
789 }
catch (TskCoreException ex) {
790 throw new TskCoreException(
"Unable to get datasource for artifact: " + this.
toString(), ex);
792 if (dataSource == null) {
793 throw new TskCoreException(
"Datasource was null for artifact: " + this.
toString());
798 artifactContents.append(attribute.getAttributeType().getDisplayName());
799 artifactContents.append(
" : ");
800 artifactContents.append(attribute.getDisplayString());
801 artifactContents.append(System.lineSeparator());
803 }
catch (TskCoreException ex) {
804 throw new TskCoreException(
"Unable to get attributes for artifact: " + this.
toString(), ex);
808 contentBytes = artifactContents.toString().getBytes(
"UTF-8");
809 }
catch (UnsupportedEncodingException ex) {
810 throw new TskCoreException(
"Failed to convert artifact string to bytes for artifact: " + this.
toString(), ex);
818 public static final class Type implements Serializable {
820 private static final long serialVersionUID = 1L;
821 private final String typeName;
822 private final int typeID;
823 private final String displayName;
832 public Type(
int typeID, String typeName, String displayName) {
833 this.typeID = typeID;
834 this.typeName = typeName;
835 this.displayName = displayName;
853 return this.typeName;
871 return this.displayName;
885 }
else if (!(that instanceof
Type)) {
888 return ((Type) that).sameType(
this);
899 private boolean sameType(
Type that) {
913 hash = 83 * hash + Objects.hashCode(this.typeID);
914 hash = 83 * hash + Objects.hashCode(this.displayName);
915 hash = 83 * hash + Objects.hashCode(this.typeName);
930 TSK_GEN_INFO(1,
"TSK_GEN_INFO",
931 bundle.getString(
"BlackboardArtifact.tskGenInfo.text")),
937 TSK_WEB_BOOKMARK(2,
"TSK_WEB_BOOKMARK",
938 bundle.getString(
"BlackboardArtifact.tskWebBookmark.text")),
944 TSK_WEB_COOKIE(3,
"TSK_WEB_COOKIE",
945 bundle.getString(
"BlackboardArtifact.tskWebCookie.text")),
951 TSK_WEB_HISTORY(4,
"TSK_WEB_HISTORY",
952 bundle.getString(
"BlackboardArtifact.tskWebHistory.text")),
958 TSK_WEB_DOWNLOAD(5,
"TSK_WEB_DOWNLOAD",
959 bundle.getString(
"BlackboardArtifact.tskWebDownload.text")),
963 TSK_RECENT_OBJECT(6,
"TSK_RECENT_OBJ",
964 bundle.getString(
"BlackboardArtifact.tsk.recentObject.text")),
971 TSK_GPS_TRACKPOINT(7,
"TSK_GPS_TRACKPOINT",
972 bundle.getString(
"BlackboardArtifact.tskGpsTrackpoint.text")),
976 TSK_INSTALLED_PROG(8,
"TSK_INSTALLED_PROG",
977 bundle.getString(
"BlackboardArtifact.tskInstalledProg.text")),
981 TSK_KEYWORD_HIT(9,
"TSK_KEYWORD_HIT",
982 bundle.getString(
"BlackboardArtifact.tskKeywordHits.text")),
986 TSK_HASHSET_HIT(10,
"TSK_HASHSET_HIT",
987 bundle.getString(
"BlackboardArtifact.tskHashsetHit.text")),
991 TSK_DEVICE_ATTACHED(11,
"TSK_DEVICE_ATTACHED",
992 bundle.getString(
"BlackboardArtifact.tskDeviceAttached.text")),
997 TSK_INTERESTING_FILE_HIT(12,
"TSK_INTERESTING_FILE_HIT",
998 bundle.getString(
"BlackboardArtifact.tskInterestingFileHit.text")),
1002 TSK_EMAIL_MSG(13,
"TSK_EMAIL_MSG",
1003 bundle.getString(
"BlackboardArtifact.tskEmailMsg.text")),
1007 TSK_EXTRACTED_TEXT(14,
"TSK_EXTRACTED_TEXT",
1008 bundle.getString(
"BlackboardArtifact.tskExtractedText.text")),
1012 TSK_WEB_SEARCH_QUERY(15,
"TSK_WEB_SEARCH_QUERY",
1013 bundle.getString(
"BlackboardArtifact.tskWebSearchQuery.text")),
1017 TSK_METADATA_EXIF(16,
"TSK_METADATA_EXIF",
1018 bundle.getString(
"BlackboardArtifact.tskMetadataExif.text")),
1025 TSK_TAG_FILE(17,
"TSK_TAG_FILE",
1026 bundle.getString(
"BlackboardArtifact.tagFile.text")),
1033 TSK_TAG_ARTIFACT(18,
"TSK_TAG_ARTIFACT",
1034 bundle.getString(
"BlackboardArtifact.tskTagArtifact.text")),
1038 TSK_OS_INFO(19,
"TSK_OS_INFO",
1039 bundle.getString(
"BlackboardArtifact.tskOsInfo.text")),
1043 TSK_OS_ACCOUNT(20,
"TSK_OS_ACCOUNT",
1044 bundle.getString(
"BlackboardArtifact.tskOsAccount.text")),
1048 TSK_SERVICE_ACCOUNT(21,
"TSK_SERVICE_ACCOUNT",
1049 bundle.getString(
"BlackboardArtifact.tskServiceAccount.text")),
1056 TSK_TOOL_OUTPUT(22,
"TSK_TOOL_OUTPUT",
1057 bundle.getString(
"BlackboardArtifact.tskToolOutput.text")),
1064 TSK_CONTACT(23,
"TSK_CONTACT",
1065 bundle.getString(
"BlackboardArtifact.tskContact.text")),
1072 TSK_MESSAGE(24,
"TSK_MESSAGE",
1073 bundle.getString(
"BlackboardArtifact.tskMessage.text")),
1079 TSK_CALLLOG(25,
"TSK_CALLLOG",
1080 bundle.getString(
"BlackboardArtifact.tskCalllog.text")),
1084 TSK_CALENDAR_ENTRY(26,
"TSK_CALENDAR_ENTRY",
1085 bundle.getString(
"BlackboardArtifact.tskCalendarEntry.text")),
1089 TSK_SPEED_DIAL_ENTRY(27,
"TSK_SPEED_DIAL_ENTRY",
1090 bundle.getString(
"BlackboardArtifact.tskSpeedDialEntry.text")),
1094 TSK_BLUETOOTH_PAIRING(28,
"TSK_BLUETOOTH_PAIRING",
1095 bundle.getString(
"BlackboardArtifact.tskBluetoothPairing.text")),
1099 TSK_GPS_BOOKMARK(29,
"TSK_GPS_BOOKMARK",
1100 bundle.getString(
"BlackboardArtifact.tskGpsBookmark.text")),
1104 TSK_GPS_LAST_KNOWN_LOCATION(30,
"TSK_GPS_LAST_KNOWN_LOCATION",
1105 bundle.getString(
"BlackboardArtifact.tskGpsLastKnownLocation.text")),
1109 TSK_GPS_SEARCH(31,
"TSK_GPS_SEARCH",
1110 bundle.getString(
"BlackboardArtifact.tskGpsSearch.text")),
1114 TSK_PROG_RUN(32,
"TSK_PROG_RUN",
1115 bundle.getString(
"BlackboardArtifact.tskProgRun.text")),
1119 TSK_ENCRYPTION_DETECTED(33,
"TSK_ENCRYPTION_DETECTED",
1120 bundle.getString(
"BlackboardArtifact.tskEncryptionDetected.text")),
1124 TSK_EXT_MISMATCH_DETECTED(34,
"TSK_EXT_MISMATCH_DETECTED",
1125 bundle.getString(
"BlackboardArtifact.tskExtMismatchDetected.text")),
1130 TSK_INTERESTING_ARTIFACT_HIT(35,
"TSK_INTERESTING_ARTIFACT_HIT",
1131 bundle.getString(
"BlackboardArtifact.tskInterestingArtifactHit.text")),
1137 TSK_GPS_ROUTE(36,
"TSK_GPS_ROUTE",
1138 bundle.getString(
"BlackboardArtifact.tskGpsRoute.text")),
1142 TSK_REMOTE_DRIVE(37,
"TSK_REMOTE_DRIVE",
1143 bundle.getString(
"BlackboardArtifact.tskRemoteDrive.text")),
1147 TSK_FACE_DETECTED(38,
"TSK_FACE_DETECTED",
1148 bundle.getString(
"BlackboardArtifact.tskFaceDetected.text")),
1152 TSK_ACCOUNT(39,
"TSK_ACCOUNT",
1153 bundle.getString(
"BlackboardArtifact.tskAccount.text")),
1157 TSK_ENCRYPTION_SUSPECTED(40,
"TSK_ENCRYPTION_SUSPECTED",
1158 bundle.getString(
"BlackboardArtifact.tskEncryptionSuspected.text")),
1162 TSK_OBJECT_DETECTED(41,
"TSK_OBJECT_DETECTED",
1163 bundle.getString(
"BlackboardArtifact.tskObjectDetected.text")),
1167 TSK_WIFI_NETWORK(42,
"TSK_WIFI_NETWORK",
1168 bundle.getString(
"BlackboardArtifact.tskWIFINetwork.text")),
1172 TSK_DEVICE_INFO(43,
"TSK_DEVICE_INFO",
1173 bundle.getString(
"BlackboardArtifact.tskDeviceInfo.text")),
1177 TSK_SIM_ATTACHED(44,
"TSK_SIM_ATTACHED",
1178 bundle.getString(
"BlackboardArtifact.tskSimAttached.text")),
1182 TSK_BLUETOOTH_ADAPTER(45,
"TSK_BLUETOOTH_ADAPTER",
1183 bundle.getString(
"BlackboardArtifact.tskBluetoothAdapter.text")),
1187 TSK_WIFI_NETWORK_ADAPTER(46,
"TSK_WIFI_NETWORK_ADAPTER",
1188 bundle.getString(
"BlackboardArtifact.tskWIFINetworkAdapter.text")),
1192 TSK_VERIFICATION_FAILED(47,
"TSK_VERIFICATION_FAILED",
1193 bundle.getString(
"BlackboardArtifact.tskVerificationFailed.text")),
1197 TSK_DATA_SOURCE_USAGE(48,
"TSK_DATA_SOURCE_USAGE",
1198 bundle.getString(
"BlackboardArtifact.tskDataSourceUsage.text")),
1204 TSK_WEB_FORM_AUTOFILL(49,
"TSK_WEB_FORM_AUTOFILL",
1205 bundle.getString(
"BlackboardArtifact.tskWebFormAutofill.text")),
1211 TSK_WEB_FORM_ADDRESS(50,
"TSK_WEB_FORM_ADDRESSES ",
1212 bundle.getString(
"BlackboardArtifact.tskWebFormAddresses.text")),
1220 TSK_DOWNLOAD_SOURCE(51,
"TSK_DOWNLOAD_SOURCE",
1221 bundle.getString(
"BlackboardArtifact.tskDownloadSource.text")),
1225 TSK_WEB_CACHE(52,
"TSK_WEB_CACHE",
1226 bundle.getString(
"BlackboardArtifact.tskWebCache.text")),
1230 TSK_TL_EVENT(53,
"TSK_TL_EVENT",
1231 bundle.getString(
"BlackboardArtifact.tskTLEvent.text")),
1235 TSK_CLIPBOARD_CONTENT(54,
"TSK_CLIPBOARD_CONTENT",
1236 bundle.getString(
"BlackboardArtifact.tskClipboardContent.text")),
1240 TSK_ASSOCIATED_OBJECT(55,
"TSK_ASSOCIATED_OBJECT",
1241 bundle.getString(
"BlackboardArtifact.tskAssociatedObject.text")),
1245 TSK_USER_CONTENT_SUSPECTED(56,
"TSK_USER_CONTENT_SUSPECTED",
1246 bundle.getString(
"BlackboardArtifact.tskUserContentSuspected.text")),
1250 TSK_METADATA(57,
"TSK_METADATA",
1251 bundle.getString(
"BlackboardArtifact.tskMetadata.text")),
1257 TSK_GPS_TRACK(58,
"TSK_GPS_TRACK",
1258 bundle.getString(
"BlackboardArtifact.tskTrack.text"));
1266 private final String label;
1267 private final int typeId;
1268 private final String displayName;
1277 private ARTIFACT_TYPE(
int typeId, String label, String displayName) {
1278 this.typeId = typeId;
1280 this.displayName = displayName;
1311 if (value.getLabel().equals(label)) {
1315 throw new IllegalArgumentException(
"No ARTIFACT_TYPE matching type: " + label);
1330 if (value.getTypeID() == id) {
1334 throw new IllegalArgumentException(
"No ARTIFACT_TYPE matching type: " +
id);
1359 return visitor.
visit(
this);
1373 private final Integer id;
1374 private final String name;
1375 private final String displayName;
1376 private final static Map<Integer, ReviewStatus> idToStatus =
new HashMap<Integer, ReviewStatus>();
1380 idToStatus.put(status.getID(), status);
1392 private ReviewStatus(Integer
id, String name, String displayNameKey) {
1395 this.displayName = ResourceBundle.getBundle(
"org.sleuthkit.datamodel.Bundle").getString(displayNameKey);
1406 return idToStatus.get(
id);
1459 protected BlackboardArtifact(
SleuthkitCase sleuthkitCase,
long artifactID,
long objID,
long artifactObjID,
long dataSourceObjId,
int artifactTypeID, String artifactTypeName, String displayName) {
1460 this(sleuthkitCase, artifactID, objID, artifactObjID, dataSourceObjId, artifactTypeID, artifactTypeName, displayName,
ReviewStatus.
UNDECIDED);
1479 if (loadedCacheFromDb ==
false) {
1482 attrsCache.addAll(attrs);
1483 loadedCacheFromDb =
true;
1485 ArrayList<BlackboardAttribute> filteredAttributes =
new ArrayList<BlackboardAttribute>();
1487 if (attr.getAttributeType().getTypeID() == attributeType.getTypeID()) {
1488 filteredAttributes.add(attr);
1491 return filteredAttributes;
1496 return this.artifactObjId;
1509 List<Long> childrenIDs =
new ArrayList<Long>();
1511 childrenIDs.addAll(
getSleuthkitCase().getBlackboardArtifactChildrenIds(
this));
1518 if (childrenCount != -1) {
1519 return childrenCount;
1524 hasChildren = childrenCount > 0;
1525 checkedHasChildren =
true;
1527 return childrenCount;
1532 if (checkedHasChildren ==
true) {
1538 hasChildren = childrenCount > 0;
1539 checkedHasChildren =
true;
1554 List<Content> children =
new ArrayList<>();
static ARTIFACT_TYPE fromID(int id)
synchronized String getUniquePath()
long getAllArtifactsCount()
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
ArrayList< BlackboardAttribute > getBlackboardAttributes(final BlackboardArtifact artifact)
static ARTIFACT_TYPE fromLabel(String label)
void addBlackboardAttributes(Collection< BlackboardAttribute > attributes, int artifactTypeId)
Type(int typeID, String typeName, String displayName)
String getArtifactTypeName()
void addAttributes(Collection< BlackboardAttribute > attributes)
void addBlackboardAttribute(BlackboardAttribute attr, int artifactTypeId)
List< BlackboardAttribute > getAttributes(final BlackboardAttribute.ATTRIBUTE_TYPE attributeType)
long getArtifactsCount(int artifactTypeID)
Content getContentById(long id)
BlackboardArtifact getGenInfoArtifact()
final int read(byte[] buf, long offset, long len)
String getShortDescription()
SleuthkitCase getSleuthkitCase()
void addAttribute(BlackboardAttribute attribute)
boolean equals(Object object)
ReviewStatus getReviewStatus()
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
Set< String > getHashSetNames()
public< T > T accept(SleuthkitItemVisitor< T > visitor)
String getDisplayString()
BlackboardArtifact newArtifact(int artifactTypeID)
BlackboardAttribute getAttribute(BlackboardAttribute.Type attributeType)
List< Long > getChildrenIds()
long getArtifactsCount(String artifactTypeName)
BlackboardArtifact getGenInfoArtifact(boolean create)
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
BlackboardAttribute.Type getAttributeType()
List< BlackboardAttribute > getAttributes()
BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long objID, long artifactObjID, long dataSourceObjId, int artifactTypeID, String artifactTypeName, String displayName)
List< Content > getChildren()
synchronized Content getParent()
boolean equals(Object that)
ArrayList< BlackboardArtifact > getAllArtifacts()
void setReviewStatus(ReviewStatus newStatus)
long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardAttribute > getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type)
static ReviewStatus withID(int id)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)
void setReviewStatus(BlackboardArtifact artifact, BlackboardArtifact.ReviewStatus newStatus)