19 package org.sleuthkit.datamodel.blackboardutils;
21 import java.net.MalformedURLException;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.Optional;
27 import java.util.StringTokenizer;
28 import java.util.logging.Level;
29 import java.util.logging.Logger;
30 import org.apache.commons.lang3.StringUtils;
67 super(caseDb, moduleName, srcContent, ingestJobId);
84 this(caseDb, moduleName, srcContent, null);
103 Collections.emptyList());
122 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
124 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
135 attributes.addAll(otherAttributesList);
137 Content content = getContent();
141 Optional<Long> ingestJobId = getIngestJobId();
142 getSleuthkitCase().getBlackboard().postArtifact(bookMarkArtifact, getModuleName(), ingestJobId.orElse(null));
145 return bookMarkArtifact;
164 String name, String value, String programName)
throws TskCoreException,
BlackboardException {
166 return addWebCookie(url, creationTime, name, value, programName,
167 Collections.emptyList());
190 long creationTime, String name, String value, String programName,
191 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
193 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
205 attributes.addAll(otherAttributesList);
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());
252 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
254 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
265 attributes.addAll(otherAttributesList);
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,
296 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
298 mailingAddress, creationTime, accessTime, count,
299 Collections.emptyList());
320 String phoneNumber, String mailingAddress,
321 long creationTime,
long accessTime,
int count,
322 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
324 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
328 Optional<Long> ingestJobId = getIngestJobId();
329 if (StringUtils.isNotEmpty(email)) {
331 commManager.createAccountFileInstance(
Account.
Type.
EMAIL, email,
this.getModuleName(), this.getContent(), null, ingestJobId.orElse(null));
333 LOGGER.log(Level.WARNING, String.format(
"Invalid account identifier %s", email), ex);
337 if (StringUtils.isNotEmpty(phoneNumber)) {
339 commManager.createAccountFileInstance(
Account.
Type.
PHONE, phoneNumber,
this.getModuleName(), this.getContent(), null, ingestJobId.orElse(null));
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;
382 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
384 Collections.emptyList());
405 long creationTime,
long accessTime,
int count,
406 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
408 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
419 attributes.addAll(otherAttributesList);
421 Content content = getContent();
425 Optional<Long> ingestJobId = getIngestJobId();
426 getSleuthkitCase().getBlackboard().postArtifact(webFormAutofillArtifact, getModuleName(), ingestJobId.orElse(null));
429 return webFormAutofillArtifact;
448 String referrer, String title, String programName)
throws TskCoreException,
BlackboardException {
449 return addWebHistory(url, accessTime, referrer, title, programName,
450 Collections.emptyList());
470 String referrer, String title, String programName,
471 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
473 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
486 attributes.addAll(otherAttributesList);
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(
".")) {
BlackboardArtifact addWebDownload(String url, long startTime, String path, String programName)
BlackboardArtifact addWebBookmark(String url, String title, long creationTime, String progName)
BlackboardArtifact addWebDownload(String url, long startTime, String path, String programName, Collection< BlackboardAttribute > otherAttributesList)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList)
BlackboardArtifact addWebFormAddress(String personName, String email, String phoneNumber, String mailingAddress, long creationTime, long accessTime, int count)
BlackboardArtifact addWebHistory(String url, long accessTime, String referrer, String title, String programName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebCookie(String url, long creationTime, String name, String value, String programName, Collection< BlackboardAttribute > otherAttributesList)
static final Account.Type PHONE
BlackboardArtifact addWebHistory(String url, long accessTime, String referrer, String title, String programName)
BlackboardArtifact addWebFormAutofill(String name, String value, long creationTime, long accessTime, int count)
BlackboardArtifact addWebFormAutofill(String name, String value, long creationTime, long accessTime, int count, Collection< BlackboardAttribute > otherAttributesList)
WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent, Long ingestJobId)
BlackboardArtifact addWebBookmark(String url, String title, long creationTime, String progName, Collection< BlackboardAttribute > otherAttributesList)
BlackboardArtifact addWebCookie(String url, long creationTime, String name, String value, String programName)
WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent)
BlackboardArtifact addWebFormAddress(String personName, String email, String phoneNumber, String mailingAddress, long creationTime, long accessTime, int count, Collection< BlackboardAttribute > otherAttributesList)
static final Account.Type EMAIL