mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Finished OsAccountContentViewer changes
This commit is contained in:
parent
386e9e8cef
commit
c0b9d5f49c
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.contentviewers.osaccount;
|
package org.sleuthkit.autopsy.contentviewers.osaccount;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@ -31,19 +32,20 @@ import static java.util.Locale.US;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.contentviewers.osaccount.SectionData.RowData;
|
import org.sleuthkit.autopsy.contentviewers.osaccount.SectionData.RowData;
|
||||||
import org.sleuthkit.datamodel.DataSource;
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
import org.sleuthkit.datamodel.Host;
|
import org.sleuthkit.datamodel.Host;
|
||||||
import org.sleuthkit.datamodel.HostManager;
|
|
||||||
import org.sleuthkit.datamodel.OsAccount;
|
import org.sleuthkit.datamodel.OsAccount;
|
||||||
import org.sleuthkit.datamodel.OsAccountAttribute;
|
import org.sleuthkit.datamodel.OsAccountAttribute;
|
||||||
|
import org.sleuthkit.datamodel.OsAccountInstance;
|
||||||
import org.sleuthkit.datamodel.OsAccountManager;
|
import org.sleuthkit.datamodel.OsAccountManager;
|
||||||
import org.sleuthkit.datamodel.OsAccountRealm;
|
import org.sleuthkit.datamodel.OsAccountRealm;
|
||||||
|
|
||||||
@ -53,12 +55,15 @@ import org.sleuthkit.datamodel.OsAccountRealm;
|
|||||||
public class OsAccountDataPanel extends JPanel {
|
public class OsAccountDataPanel extends JPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
final private static Logger logger = Logger.getLogger(OsAccountDataPanel.class.getName());
|
||||||
|
|
||||||
private static final int KEY_COLUMN = 0;
|
private static final int KEY_COLUMN = 0;
|
||||||
private static final int VALUE_COLUMN = 1;
|
private static final int VALUE_COLUMN = 1;
|
||||||
|
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MMM dd yyyy", US);
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MMM dd yyyy", US);
|
||||||
|
|
||||||
|
private PanelDataFetcher dataFetcher = null;
|
||||||
|
|
||||||
// Panel constructor.
|
// Panel constructor.
|
||||||
OsAccountDataPanel() {
|
OsAccountDataPanel() {
|
||||||
initialize();
|
initialize();
|
||||||
@ -79,19 +84,19 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
void setOsAccount(OsAccount account) {
|
void setOsAccount(OsAccount account) {
|
||||||
removeAll();
|
removeAll();
|
||||||
|
revalidate();
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
List<SectionData> data = new ArrayList<>();
|
setLayout(new BorderLayout());
|
||||||
data.add(buildBasicProperties(account));
|
add(new JLabel("Loading OsAccount Data..."), BorderLayout.NORTH);
|
||||||
|
|
||||||
OsAccountRealm realm = account.getRealm();
|
if (dataFetcher != null && !dataFetcher.isDone()) {
|
||||||
if (realm != null) {
|
dataFetcher.cancel(true);
|
||||||
data.add(buildRealmProperties(realm));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addDataComponents(data);
|
dataFetcher = new PanelDataFetcher(account);
|
||||||
|
dataFetcher.execute();
|
||||||
}
|
}
|
||||||
revalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,8 +138,7 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
"OsAccountDataPanel_basic_address=Address",
|
"OsAccountDataPanel_basic_address=Address",
|
||||||
"OsAccountDataPanel_basic_admin=Administrator",
|
"OsAccountDataPanel_basic_admin=Administrator",
|
||||||
"OsAccountDataPanel_basic_type=Type",
|
"OsAccountDataPanel_basic_type=Type",
|
||||||
"OsAccountDataPanel_basic_creationDate=Creation Date",
|
"OsAccountDataPanel_basic_creationDate=Creation Date",})
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data for the Basic Properties section of the panel.
|
* Returns the data for the Basic Properties section of the panel.
|
||||||
@ -162,10 +166,9 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
data.addData(Bundle.OsAccountDataPanel_basic_type(), account.getOsAccountType().getName());
|
data.addData(Bundle.OsAccountDataPanel_basic_type(), account.getOsAccountType().getName());
|
||||||
|
|
||||||
Optional<Long> crTime = account.getCreationTime();
|
Optional<Long> crTime = account.getCreationTime();
|
||||||
if(crTime.isPresent()) {
|
if (crTime.isPresent()) {
|
||||||
data.addData(Bundle.OsAccountDataPanel_basic_creationDate(), DATE_FORMAT.format(new Date(crTime.get() * 1000)));
|
data.addData(Bundle.OsAccountDataPanel_basic_creationDate(), DATE_FORMAT.format(new Date(crTime.get() * 1000)));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
data.addData(Bundle.OsAccountDataPanel_basic_creationDate(), "");
|
data.addData(Bundle.OsAccountDataPanel_basic_creationDate(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +202,7 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
optional.isPresent() ? optional.get() : "");
|
optional.isPresent() ? optional.get() : "");
|
||||||
|
|
||||||
data.addData(Bundle.OsAccountDataPanel_realm_scope(),
|
data.addData(Bundle.OsAccountDataPanel_realm_scope(),
|
||||||
realm.getScope().getName());
|
realm.getScope().getName());
|
||||||
|
|
||||||
data.addData(Bundle.OsAccountDataPanel_realm_confidence(),
|
data.addData(Bundle.OsAccountDataPanel_realm_confidence(),
|
||||||
realm.getScopeConfidence().getName());
|
realm.getScopeConfidence().getName());
|
||||||
@ -209,7 +212,7 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
|
|
||||||
private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) {
|
private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) {
|
||||||
SectionData data = new SectionData(host.getName());
|
SectionData data = new SectionData(host.getName());
|
||||||
for(OsAccountAttribute attribute: attributeList) {
|
for (OsAccountAttribute attribute : attributeList) {
|
||||||
data.addData(attribute.getAttributeType().getDisplayName(), attribute.getDisplayString());
|
data.addData(attribute.getAttributeType().getDisplayName(), attribute.getDisplayString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,11 +340,19 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HostFetcher extends SwingWorker<WorkerResults, Void> {
|
/**
|
||||||
|
* A SwingWorker to gather the data for the content panel.
|
||||||
|
*/
|
||||||
|
private class PanelDataFetcher extends SwingWorker<WorkerResults, Void> {
|
||||||
|
|
||||||
private final OsAccount account;
|
private final OsAccount account;
|
||||||
|
|
||||||
HostFetcher(OsAccount account) {
|
/**
|
||||||
|
* Construct a new worker for the given account.
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
*/
|
||||||
|
PanelDataFetcher(OsAccount account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,21 +364,21 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
List<Host> hosts = osAccountManager.getHosts(account);
|
List<Host> hosts = osAccountManager.getHosts(account);
|
||||||
List<OsAccountAttribute> attributeList = account.getOsAccountAttributes();
|
List<OsAccountAttribute> attributeList = account.getOsAccountAttributes();
|
||||||
|
|
||||||
if(attributeList != null) {
|
if (attributeList != null) {
|
||||||
if(hosts != null) {
|
if (hosts != null) {
|
||||||
// Organize the attributes by hostId
|
// Organize the attributes by hostId
|
||||||
Map<Long, List<OsAccountAttribute>> idMap = new HashMap<>();
|
Map<Long, List<OsAccountAttribute>> idMap = new HashMap<>();
|
||||||
for(OsAccountAttribute attribute: attributeList) {
|
for (OsAccountAttribute attribute : attributeList) {
|
||||||
List<OsAccountAttribute> atList = null;
|
List<OsAccountAttribute> atList = null;
|
||||||
Optional<Long> optionalId = attribute.getHostId();
|
Optional<Long> optionalId = attribute.getHostId();
|
||||||
Long key = null;
|
Long key = null;
|
||||||
if(optionalId.isPresent()) {
|
if (optionalId.isPresent()) {
|
||||||
key = optionalId.get();
|
key = optionalId.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
atList = idMap.get(key);
|
atList = idMap.get(key);
|
||||||
|
|
||||||
if(atList == null) {
|
if (atList == null) {
|
||||||
atList = new ArrayList<>();
|
atList = new ArrayList<>();
|
||||||
idMap.put(key, atList);
|
idMap.put(key, atList);
|
||||||
}
|
}
|
||||||
@ -375,19 +386,25 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
atList.add(attribute);
|
atList.add(attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
HostManager hostManager = Case.getCurrentCase().getSleuthkitCase().getHostManager();
|
|
||||||
// Add attribute lists to the hostMap
|
// Add attribute lists to the hostMap
|
||||||
for(Host host: hosts) {
|
for (Host host : hosts) {
|
||||||
List<OsAccountAttribute> atList = idMap.get(host.getId());
|
List<OsAccountAttribute> atList = idMap.get(host.getId());
|
||||||
if(atList != null) {
|
if (atList != null) {
|
||||||
hostMap.put(host, atList);
|
hostMap.put(host, atList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
List<OsAccountAttribute> atList = idMap.get(null);
|
List<OsAccountAttribute> atList = idMap.get(null);
|
||||||
if(atList != null) {
|
if (atList != null) {
|
||||||
hostMap.put(null, atList);
|
hostMap.put(null, atList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store both the host and the dataSource so that we get
|
||||||
|
// all of the calls to the db done in the thread.
|
||||||
|
for (OsAccountInstance instance : account.getOsAccountInstances()) {
|
||||||
|
instanceMap.put(instance.getDataSource().getHost(), instance.getDataSource());
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
hostMap.put(null, attributeList);
|
hostMap.put(null, attributeList);
|
||||||
}
|
}
|
||||||
@ -401,19 +418,24 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
WorkerResults results = null;
|
WorkerResults results = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
results = get();
|
if (this.isCancelled()) {
|
||||||
} catch (InterruptedException ex) {
|
return;
|
||||||
Exceptions.printStackTrace(ex);
|
} else {
|
||||||
} catch (ExecutionException ex) {
|
results = get();
|
||||||
Exceptions.printStackTrace(ex);
|
}
|
||||||
|
} catch (ExecutionException | InterruptedException ex) {
|
||||||
|
logger.log(Level.SEVERE, String.format("Failed to retrieve data for OsAccount (%d)", account.getId()), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(results != null) {
|
if (results != null) {
|
||||||
|
removeAll();
|
||||||
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
List<SectionData> data = new ArrayList<>();
|
List<SectionData> data = new ArrayList<>();
|
||||||
data.add(buildBasicProperties(account));
|
data.add(buildBasicProperties(account));
|
||||||
Map<Host, List<OsAccountAttribute>> hostDataMap = results.getAttributeMap();
|
Map<Host, List<OsAccountAttribute>> hostDataMap = results.getAttributeMap();
|
||||||
if(hostDataMap != null && !hostDataMap.isEmpty()) {
|
if (hostDataMap != null && !hostDataMap.isEmpty()) {
|
||||||
hostDataMap.forEach((K,V)-> data.add(buildHostData(K,V)));
|
hostDataMap.forEach((K, V) -> data.add(buildHostData(K, V)));
|
||||||
}
|
}
|
||||||
|
|
||||||
OsAccountRealm realm = account.getRealm();
|
OsAccountRealm realm = account.getRealm();
|
||||||
@ -421,24 +443,60 @@ public class OsAccountDataPanel extends JPanel {
|
|||||||
data.add(buildRealmProperties(realm));
|
data.add(buildRealmProperties(realm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<Host, DataSource> instanceMap = results.getDataSourceMap();
|
||||||
|
if (!instanceMap.isEmpty()) {
|
||||||
|
SectionData instanceSection = new SectionData("Instances");
|
||||||
|
instanceMap.forEach((K, V) -> instanceSection.addData(K.getName(), V.getName()));
|
||||||
|
|
||||||
|
data.add(instanceSection);
|
||||||
|
}
|
||||||
|
|
||||||
addDataComponents(data);
|
addDataComponents(data);
|
||||||
|
|
||||||
|
revalidate();
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class for PanelDataFetcher that wraps the returned data needed for
|
||||||
|
* the panel.
|
||||||
|
*/
|
||||||
private final class WorkerResults {
|
private final class WorkerResults {
|
||||||
|
|
||||||
private final Map<Host, List<OsAccountAttribute>> attributeMap;
|
private final Map<Host, List<OsAccountAttribute>> attributeMap;
|
||||||
private final Map<Host, DataSource> instanceMap;
|
private final Map<Host, DataSource> instanceMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new WorkerResult object.
|
||||||
|
*
|
||||||
|
* @param attributeMap Maps the OsAccountAttributes to the host they
|
||||||
|
* belong with.
|
||||||
|
* @param instanceMap A map of data to display OsAccount instance
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
WorkerResults(Map<Host, List<OsAccountAttribute>> attributeMap, Map<Host, DataSource> instanceMap) {
|
WorkerResults(Map<Host, List<OsAccountAttribute>> attributeMap, Map<Host, DataSource> instanceMap) {
|
||||||
this.attributeMap = attributeMap;
|
this.attributeMap = attributeMap;
|
||||||
this.instanceMap = instanceMap;
|
this.instanceMap = instanceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of OsAccountAttributes that belong to a specific Host.
|
||||||
|
* There maybe a null key in the map which represents properties that
|
||||||
|
* are not host specific.
|
||||||
|
*
|
||||||
|
* @return OsAccountAttribute map.
|
||||||
|
*/
|
||||||
Map<Host, List<OsAccountAttribute>> getAttributeMap() {
|
Map<Host, List<OsAccountAttribute>> getAttributeMap() {
|
||||||
return attributeMap;
|
return attributeMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of the instance data for the OsAccount.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Map<Host, DataSource> getDataSourceMap() {
|
Map<Host, DataSource> getDataSourceMap() {
|
||||||
return instanceMap;
|
return instanceMap;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ import org.sleuthkit.datamodel.Host;
|
|||||||
import org.sleuthkit.datamodel.HostManager;
|
import org.sleuthkit.datamodel.HostManager;
|
||||||
import org.sleuthkit.datamodel.OsAccount;
|
import org.sleuthkit.datamodel.OsAccount;
|
||||||
import org.sleuthkit.datamodel.OsAccountAttribute;
|
import org.sleuthkit.datamodel.OsAccountAttribute;
|
||||||
|
import org.sleuthkit.datamodel.OsAccountInstance;
|
||||||
import org.sleuthkit.datamodel.OsAccountManager;
|
import org.sleuthkit.datamodel.OsAccountManager;
|
||||||
import org.sleuthkit.datamodel.OsAccountRealm;
|
import org.sleuthkit.datamodel.OsAccountRealm;
|
||||||
import org.sleuthkit.datamodel.ReadContentInputStream.ReadContentInputStreamException;
|
import org.sleuthkit.datamodel.ReadContentInputStream.ReadContentInputStreamException;
|
||||||
@ -1166,6 +1167,7 @@ class ExtractRegistry extends Extract {
|
|||||||
//add remaining userinfos as accounts;
|
//add remaining userinfos as accounts;
|
||||||
for (Map<String, String> userInfo : userInfoMap.values()) {
|
for (Map<String, String> userInfo : userInfoMap.values()) {
|
||||||
OsAccount osAccount = accountMgr.createWindowsAccount(userInfo.get(SID_KEY), null, null, host, OsAccountRealm.RealmScope.UNKNOWN);
|
OsAccount osAccount = accountMgr.createWindowsAccount(userInfo.get(SID_KEY), null, null, host, OsAccountRealm.RealmScope.UNKNOWN);
|
||||||
|
accountMgr.createOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.PERFORMED_ACTION_ON);
|
||||||
updateOsAccount(osAccount, userInfo, groupMap.get(userInfo.get(SID_KEY)), regAbstractFile);
|
updateOsAccount(osAccount, userInfo, groupMap.get(userInfo.get(SID_KEY)), regAbstractFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2214,6 +2216,7 @@ class ExtractRegistry extends Extract {
|
|||||||
OsAccount osAccount;
|
OsAccount osAccount;
|
||||||
if (!optional.isPresent()) {
|
if (!optional.isPresent()) {
|
||||||
osAccount = accountMgr.createWindowsAccount(sid, userName != null && userName.isEmpty() ? null : userName, null, host, OsAccountRealm.RealmScope.UNKNOWN);
|
osAccount = accountMgr.createWindowsAccount(sid, userName != null && userName.isEmpty() ? null : userName, null, host, OsAccountRealm.RealmScope.UNKNOWN);
|
||||||
|
accountMgr.createOsAccountInstance(osAccount, (DataSource)dataSource, OsAccountInstance.OsAccountInstanceType.PERFORMED_ACTION_ON);
|
||||||
} else {
|
} else {
|
||||||
osAccount = optional.get();
|
osAccount = optional.get();
|
||||||
if (userName != null && !userName.isEmpty()) {
|
if (userName != null && !userName.isEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user