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.StringTokenizer;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import org.apache.commons.lang3.StringUtils;
67 super(caseDb, moduleName, srcContent);
86 Collections.emptyList());
105 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
107 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
118 attributes.addAll(otherAttributesList);
120 Content content = getContent();
124 getSleuthkitCase().getBlackboard().postArtifact(bookMarkArtifact, getModuleName());
127 return bookMarkArtifact;
146 String name, String value, String programName)
throws TskCoreException,
BlackboardException {
148 return addWebCookie(url, creationTime, name, value, programName,
149 Collections.emptyList());
172 long creationTime, String name, String value, String programName,
173 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
175 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
187 attributes.addAll(otherAttributesList);
189 Content content = getContent();
193 getSleuthkitCase().getBlackboard().postArtifact(cookieArtifact, getModuleName());
196 return cookieArtifact;
214 return addWebDownload(path, startTime, url, programName, Collections.emptyList());
233 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
235 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
246 attributes.addAll(otherAttributesList);
248 Content content = getContent();
252 getSleuthkitCase().getBlackboard().postArtifact(webDownloadArtifact, getModuleName());
255 return webDownloadArtifact;
275 String phoneNumber, String mailingAddress,
276 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
278 mailingAddress, creationTime, accessTime, count,
279 Collections.emptyList());
300 String phoneNumber, String mailingAddress,
301 long creationTime,
long accessTime,
int count,
302 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
304 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
308 if (StringUtils.isNotEmpty(email)) {
312 LOGGER.log(Level.WARNING, String.format(
"Invalid account identifier %s", email), ex);
316 if(StringUtils.isNotEmpty(phoneNumber)) {
318 commManager.createAccountFileInstance(
Account.
Type.
PHONE, phoneNumber,
this.getModuleName(), this.getContent());
320 LOGGER.log(Level.WARNING, String.format(
"Invalid account identifier %s", phoneNumber), ex);
336 Content content = getContent();
340 getSleuthkitCase().getBlackboard().postArtifact(webFormAddressArtifact, getModuleName());
343 return webFormAddressArtifact;
361 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
363 Collections.emptyList());
384 long creationTime,
long accessTime,
int count,
385 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
387 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
398 attributes.addAll(otherAttributesList);
400 Content content = getContent();
404 getSleuthkitCase().getBlackboard().postArtifact(webFormAutofillArtifact, getModuleName());
407 return webFormAutofillArtifact;
426 String referrer, String title, String programName)
throws TskCoreException,
BlackboardException {
427 return addWebHistory(url, accessTime, referrer, title, programName,
428 Collections.emptyList());
448 String referrer, String title, String programName,
449 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
451 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
464 attributes.addAll(otherAttributesList);
466 Content content = getContent();
470 getSleuthkitCase().getBlackboard().postArtifact(webHistoryArtifact, getModuleName());
473 return webHistoryArtifact;
486 private static String extractDomain(String urlString) {
487 if (urlString == null) {
493 URL url =
new URL(urlString);
494 result = url.getHost();
495 }
catch (MalformedURLException ex) {
501 if (result == null || StringUtils.isBlank(result)) {
502 return getBaseDomain(urlString);
514 private static String getBaseDomain(String url) {
518 String cleanUrl = url.replaceFirst(
".*:\\/\\/",
"");
521 String dirToks[] = cleanUrl.split(
"\\/");
522 if (dirToks.length > 0) {
529 StringTokenizer tok =
new StringTokenizer(host,
".");
530 StringBuilder hostB =
new StringBuilder();
531 int toks = tok.countTokens();
533 for (
int count = 0; count < toks; ++count) {
534 String part = tok.nextToken();
535 int diff = toks - count;
544 String base = hostB.toString();
546 if (base.matches(
".*[~`!@#$%^&\\*\\(\\)\\+={}\\[\\];:\\?<>,/ ].*")) {
551 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)
AccountFileInstance createAccountFileInstance(org.sleuthkit.datamodel.Account.Type accountType, String accountUniqueID, String moduleName, Content sourceFile)
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)
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