Update Chromium.java

Add base directory to profile.  Fix NPE in bookmarks
This commit is contained in:
Mark McKinnon 2024-04-16 21:10:04 -04:00
parent bf041ab06c
commit c913237966

View File

@ -320,6 +320,8 @@ class Chromium extends Extract {
jProfile = jElement.get("profile").getAsJsonObject(); //NON-NLS jProfile = jElement.get("profile").getAsJsonObject(); //NON-NLS
jInfoCache = jProfile.get("info_cache").getAsJsonObject(); jInfoCache = jProfile.get("info_cache").getAsJsonObject();
} else { } else {
userProfiles.put(browserLocation, "Default");
browserLocations.put(browserLocation, browser);
continue; continue;
} }
} catch (JsonIOException | JsonSyntaxException | IllegalStateException ex) { } catch (JsonIOException | JsonSyntaxException | IllegalStateException ex) {
@ -854,60 +856,62 @@ class Chromium extends Extract {
Set<String> bookmarkKeys = jRoot.keySet(); Set<String> bookmarkKeys = jRoot.keySet();
for (String bookmarkKey : bookmarkKeys) { for (String bookmarkKey : bookmarkKeys) {
JsonObject jBookmark = jRoot.get(bookmarkKey).getAsJsonObject(); //NON-NLS JsonObject jBookmark = jRoot.get(bookmarkKey).getAsJsonObject(); //NON-NLS
JsonArray jBookmarkArray = jBookmark.getAsJsonArray("children"); //NON-NLS if (jBookmark.has("children")) {
for (JsonElement result : jBookmarkArray) { JsonArray jBookmarkArray = jBookmark.getAsJsonArray("children"); //NON-NLS
JsonObject address = result.getAsJsonObject(); for (JsonElement result : jBookmarkArray) {
if (address == null) { JsonObject address = result.getAsJsonObject();
continue; if (address == null) {
} continue;
JsonElement urlEl = address.get("url"); //NON-NLS }
String url; JsonElement urlEl = address.get("url"); //NON-NLS
if (urlEl != null) { String url;
url = urlEl.getAsString(); if (urlEl != null) {
} else { url = urlEl.getAsString();
url = ""; } else {
} url = "";
String name; }
JsonElement nameEl = address.get("name"); //NON-NLS String name;
if (nameEl != null) { JsonElement nameEl = address.get("name"); //NON-NLS
name = nameEl.getAsString(); if (nameEl != null) {
} else { name = nameEl.getAsString();
name = ""; } else {
} name = "";
Long date; }
JsonElement dateEl = address.get("date_added"); //NON-NLS Long date;
if (dateEl != null) { JsonElement dateEl = address.get("date_added"); //NON-NLS
date = dateEl.getAsLong(); if (dateEl != null) {
} else { date = dateEl.getAsLong();
date = Long.valueOf(0); } else {
} date = Long.valueOf(0);
String domain = NetworkUtils.extractDomain(url); }
Collection<BlackboardAttribute> bbattributes = new ArrayList<>(); String domain = NetworkUtils.extractDomain(url);
//TODO Revisit usage of deprecated constructor as per TSK-583 Collection<BlackboardAttribute> bbattributes = new ArrayList<>();
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_URL, //TODO Revisit usage of deprecated constructor as per TSK-583
RecentActivityExtracterModuleFactory.getModuleName(), url)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_URL,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_TITLE, RecentActivityExtracterModuleFactory.getModuleName(), url));
RecentActivityExtracterModuleFactory.getModuleName(), name)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_TITLE,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_CREATED, RecentActivityExtracterModuleFactory.getModuleName(), name));
RecentActivityExtracterModuleFactory.getModuleName(), (date / 1000000) - Long.valueOf("11644473600"))); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME_CREATED,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME, RecentActivityExtracterModuleFactory.getModuleName(), (date / 1000000) - Long.valueOf("11644473600")));
RecentActivityExtracterModuleFactory.getModuleName(), browserName)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DOMAIN, RecentActivityExtracterModuleFactory.getModuleName(), browserName));
RecentActivityExtracterModuleFactory.getModuleName(), domain)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DOMAIN,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_USER_NAME, RecentActivityExtracterModuleFactory.getModuleName(), domain));
RecentActivityExtracterModuleFactory.getModuleName(), userName)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_USER_NAME,
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_COMMENT, RecentActivityExtracterModuleFactory.getModuleName(), userName));
RecentActivityExtracterModuleFactory.getModuleName(), bookmarkKey)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_COMMENT,
RecentActivityExtracterModuleFactory.getModuleName(), bookmarkKey));
try { try {
bbartifacts.add(createArtifactWithAttributes(BlackboardArtifact.Type.TSK_WEB_BOOKMARK, bookmarkFile, bbattributes)); bbartifacts.add(createArtifactWithAttributes(BlackboardArtifact.Type.TSK_WEB_BOOKMARK, bookmarkFile, bbattributes));
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Failed to create bookmark artifact for file (%d)", bookmarkFile.getId()), ex); logger.log(Level.SEVERE, String.format("Failed to create bookmark artifact for file (%d)", bookmarkFile.getId()), ex);
} }
}
} }
} }
if (!context.dataSourceIngestIsCancelled()) { if (!context.dataSourceIngestIsCancelled()) {
postArtifacts(bbartifacts); postArtifacts(bbartifacts);