19package org.sleuthkit.datamodel.blackboardutils;
21import java.net.MalformedURLException;
23import java.util.ArrayList;
24import java.util.Collection;
25import java.util.Collections;
26import java.util.Optional;
27import java.util.StringTokenizer;
28import java.util.logging.Level;
29import java.util.logging.Logger;
30import org.apache.commons.lang3.StringUtils;
31import org.sleuthkit.datamodel.Account;
32import org.sleuthkit.datamodel.Blackboard.BlackboardException;
33import org.sleuthkit.datamodel.BlackboardArtifact;
34import org.sleuthkit.datamodel.BlackboardAttribute;
35import org.sleuthkit.datamodel.CommunicationsManager;
36import org.sleuthkit.datamodel.Content;
37import org.sleuthkit.datamodel.InvalidAccountIDException;
38import org.sleuthkit.datamodel.SleuthkitCase;
39import org.sleuthkit.datamodel.TskCoreException;
67 super(caseDb, moduleName, srcContent, ingestJobId);
84 this(caseDb, moduleName, srcContent,
null);
103 Collections.emptyList());
124 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
137 Content content = getContent();
141 Optional<Long> ingestJobId = getIngestJobId();
142 getSleuthkitCase().getBlackboard().postArtifact(bookMarkArtifact, getModuleName(), ingestJobId.orElse(
null));
145 return bookMarkArtifact;
166 return addWebCookie(url, creationTime, name, value, programName,
167 Collections.emptyList());
190 long creationTime, String name, String value, String programName,
193 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
207 Content content = getContent();
211 Optional<Long> ingestJobId = getIngestJobId();
212 getSleuthkitCase().getBlackboard().postArtifact(cookieArtifact, getModuleName(), ingestJobId.orElse(
null));
215 return cookieArtifact;
233 return addWebDownload(path, startTime, url, programName, Collections.emptyList());
254 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
267 Content content = getContent();
271 Optional<Long> ingestJobId = getIngestJobId();
272 getSleuthkitCase().getBlackboard().postArtifact(webDownloadArtifact, getModuleName(), ingestJobId.orElse(
null));
275 return webDownloadArtifact;
295 String phoneNumber, String mailingAddress,
298 mailingAddress, creationTime, accessTime, count,
299 Collections.emptyList());
320 String phoneNumber, String mailingAddress,
321 long creationTime,
long accessTime,
int count,
324 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
328 Optional<Long> ingestJobId = getIngestJobId();
329 if (StringUtils.isNotEmpty(email)) {
333 LOGGER.log(Level.WARNING, String.format(
"Invalid account identifier %s", email), ex);
337 if (StringUtils.isNotEmpty(phoneNumber)) {
341 LOGGER.log(Level.WARNING, String.format(
"Invalid account identifier %s", phoneNumber), ex);
357 Content content = getContent();
361 getSleuthkitCase().getBlackboard().postArtifact(webFormAddressArtifact, getModuleName(), ingestJobId.orElse(
null));
364 return webFormAddressArtifact;
384 Collections.emptyList());
405 long creationTime,
long accessTime,
int count,
408 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
421 Content content = getContent();
425 Optional<Long> ingestJobId = getIngestJobId();
426 getSleuthkitCase().getBlackboard().postArtifact(webFormAutofillArtifact, getModuleName(), ingestJobId.orElse(
null));
429 return webFormAutofillArtifact;
449 return addWebHistory(url, accessTime, referrer, title, programName,
450 Collections.emptyList());
470 String referrer, String title, String programName,
473 Collection<BlackboardAttribute>
attributes =
new ArrayList<>();
488 Content content = getContent();
492 Optional<Long> ingestJobId = getIngestJobId();
493 getSleuthkitCase().getBlackboard().postArtifact(webHistoryArtifact, getModuleName(), ingestJobId.orElse(
null));
496 return webHistoryArtifact;
509 private static String extractDomain(String urlString) {
510 if (urlString ==
null) {
516 URL url =
new URL(urlString);
517 result = url.getHost();
518 }
catch (MalformedURLException ex) {
524 if (result ==
null || StringUtils.isBlank(result)) {
525 return getBaseDomain(urlString);
537 private static String getBaseDomain(String url) {
541 String cleanUrl = url.replaceFirst(
".*:\\/\\/",
"");
544 String dirToks[] = cleanUrl.split(
"\\/");
545 if (dirToks.length > 0) {
552 StringTokenizer tok =
new StringTokenizer(host,
".");
553 StringBuilder hostB =
new StringBuilder();
554 int toks = tok.countTokens();
556 for (
int count = 0; count < toks; ++count) {
557 String part = tok.nextToken();
558 int diff = toks - count;
567 String base = hostB.toString();
569 if (base.matches(
".*[~`!@#$%^&\\*\\(\\)\\+={}\\[\\];:\\?<>,/ ].*")) {
574 if (!base.contains(
".")) {
static final Account.Type PHONE
static final Account.Type EMAIL
AccountFileInstance createAccountFileInstance(org.sleuthkit.datamodel.Account.Type accountType, String accountUniqueID, String moduleName, Content sourceFile, List< BlackboardAttribute > attributes, Long ingestJobId)
BlackboardArtifact addWebCookie(String url, long creationTime, String name, String value, String programName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebDownload(String url, long startTime, String path, String programName)
BlackboardArtifact addWebBookmark(String url, String title, long creationTime, String progName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebHistory(String url, long accessTime, String referrer, String title, String programName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebHistory(String url, long accessTime, String referrer, String title, String programName)
WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent)
BlackboardArtifact addWebFormAutofill(String name, String value, long creationTime, long accessTime, int count)
BlackboardArtifact addWebBookmark(String url, String title, long creationTime, String progName)
BlackboardArtifact addWebFormAddress(String personName, String email, String phoneNumber, String mailingAddress, long creationTime, long accessTime, int count, Collection< BlackboardAttribute > otherAttributesList)
WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent, Long ingestJobId)
BlackboardArtifact addWebCookie(String url, long creationTime, String name, String value, String programName)
BlackboardArtifact addWebFormAutofill(String name, String value, long creationTime, long accessTime, int count, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebDownload(String url, long startTime, String path, String programName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebFormAddress(String personName, String email, String phoneNumber, String mailingAddress, long creationTime, long accessTime, int count)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList)