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;
60 super(caseDb, moduleName, srcContent);
79 Collections.emptyList());
98 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
101 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
115 attributes.addAll(otherAttributesList);
116 bookMarkArtifact.addAttributes(attributes);
119 getSleuthkitCase().getBlackboard().postArtifact(bookMarkArtifact, getModuleName());
122 return bookMarkArtifact;
141 String name, String value, String programName)
throws TskCoreException,
BlackboardException {
143 return addWebCookie(url, creationTime, name, value, programName,
144 Collections.emptyList());
167 long creationTime, String name, String value, String programName,
168 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
171 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
186 attributes.addAll(otherAttributesList);
187 cookieArtifact.addAttributes(attributes);
190 getSleuthkitCase().getBlackboard().postArtifact(cookieArtifact, getModuleName());
193 return cookieArtifact;
211 return addWebDownload(path, startTime, url, programName, Collections.emptyList());
230 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
233 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
247 attributes.addAll(otherAttributesList);
248 webDownloadArtifact.addAttributes(attributes);
251 getSleuthkitCase().getBlackboard().postArtifact(webDownloadArtifact, getModuleName());
254 return webDownloadArtifact;
274 String phoneNumber, String mailingAddress,
275 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
277 mailingAddress, creationTime, accessTime, count,
278 Collections.emptyList());
299 String phoneNumber, String mailingAddress,
300 long creationTime,
long accessTime,
int count,
301 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);
339 attributes.addAll(otherAttributesList);
343 getSleuthkitCase().getBlackboard().postArtifact(webFormAddressArtifact, getModuleName());
346 return webFormAddressArtifact;
364 long creationTime,
long accessTime,
int count)
throws TskCoreException,
BlackboardException {
366 Collections.emptyList());
387 long creationTime,
long accessTime,
int count,
388 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
390 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
404 attributes.addAll(otherAttributesList);
405 webFormAutofillArtifact.addAttributes(attributes);
408 getSleuthkitCase().getBlackboard().postArtifact(webFormAutofillArtifact, getModuleName());
411 return webFormAutofillArtifact;
430 String referrer, String title, String programName)
throws TskCoreException,
BlackboardException {
431 return addWebHistory(url, accessTime, referrer, title, programName,
432 Collections.emptyList());
452 String referrer, String title, String programName,
453 Collection<BlackboardAttribute> otherAttributesList)
throws TskCoreException,
BlackboardException {
456 Collection<BlackboardAttribute> attributes =
new ArrayList<>();
472 attributes.addAll(otherAttributesList);
473 webHistoryArtifact.addAttributes(attributes);
476 getSleuthkitCase().getBlackboard().postArtifact(webHistoryArtifact, getModuleName());
479 return webHistoryArtifact;
492 private static String extractDomain(String urlString) {
493 if (urlString == null) {
499 URL url =
new URL(urlString);
500 result = url.getHost();
501 }
catch (MalformedURLException ex) {
507 if (result == null || StringUtils.isBlank(result)) {
508 return getBaseDomain(urlString);
520 private static String getBaseDomain(String url) {
524 String cleanUrl = url.replaceFirst(
".*:\\/\\/",
"");
527 String dirToks[] = cleanUrl.split(
"\\/");
528 if (dirToks.length > 0) {
535 StringTokenizer tok =
new StringTokenizer(host,
".");
536 StringBuilder hostB =
new StringBuilder();
537 int toks = tok.countTokens();
539 for (
int count = 0; count < toks; ++count) {
540 String part = tok.nextToken();
541 int diff = toks - count;
550 String base = hostB.toString();
552 if (base.matches(
".*[~`!@#$%^&\\*\\(\\)\\+={}\\[\\];:\\?<>,/ ].*")) {
557 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)
void addAttributes(Collection< BlackboardAttribute > attributes)
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 newArtifact(int artifactTypeID)
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