19 package org.sleuthkit.autopsy.recentactivity;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.List;
26 import java.util.logging.Level;
27 import org.apache.commons.io.FilenameUtils;
28 import org.openide.util.NbBundle.Messages;
43 @Messages({
"ExtractOs.parentModuleName=Recent Activity",
44 "ExtractOS_progressMessage=Checking for OS"})
45 class ExtractOs extends Extract {
47 private static final Logger logger = Logger.getLogger(ExtractOs.class.getName());
49 private static final String WINDOWS_VOLUME_PATH =
"/windows/system32";
50 private static final String OSX_VOLUME_PATH =
"/System/Library/CoreServices/SystemVersion.plist";
51 private static final String ANDROID_VOLUME_PATH =
"/data/com.android.providers.settings/databases/settings.db";
53 private static final String LINUX_RED_HAT_PATHS[] = {
"/etc/redhat-release",
"/etc/redhat_version"};
54 private static final String LINUX_NOVELL_SUSE_PATH =
"/etc/SUSE-release";
55 private static final String LINUX_FEDORA_PATH =
"/etc/fedora-release";
56 private static final String LINUX_SLACKWARE_PATHS[] = {
"/etc/slackware-release",
"/etc/slackware-version"};
57 private static final String LINUX_DEBIAN_PATHS[] = {
"/etc/debian_release",
"/etc/debian_version"};
58 private static final String LINUX_MANDRAKE_PATH =
"/etc/mandrake-release";
59 private static final String LINUX_YELLOW_DOG_PATH =
"/etc/yellowdog-release";
60 private static final String LINUX_SUN_JDS_PATH =
"/etc/sun-release";
61 private static final String LINUX_SOLARIS_SPARC_PATH =
"/etc/release";
62 private static final String LINUX_GENTOO_PATH =
"/etc/gentoo-release";
63 private static final String LINUX_UNITED_LINUX_PATH =
"/etc/UnitedLinux-release";
64 private static final String LINUX_UBUNTU_PATH =
"/etc/lsb-release";
66 private Content dataSource;
69 void process(Content dataSource, IngestJobContext context, DataSourceIngestModuleProgress progressBar) {
70 this.dataSource = dataSource;
72 progressBar.progress(Bundle.ExtractOS_progressMessage());
73 for (OS_TYPE value : OS_TYPE.values()) {
74 if (context.dataSourceIngestIsCancelled()) {
78 checkForOSFiles(value);
80 }
catch (TskCoreException ex) {
81 logger.log(Level.WARNING,
"Failed to check if datasource contained a volume with operating system specific files", ex);
92 private void checkForOSFiles(OS_TYPE osType)
throws TskCoreException {
93 if (osType.getOsInfoLabel().isEmpty()) {
97 AbstractFile file = getFirstFileFound(osType.getFilePaths());
99 if (file != null && tskCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_INFO, file.getId()).isEmpty()) {
101 Collection<BlackboardAttribute> bbattributes =
new ArrayList<>();
102 bbattributes.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME,
103 Bundle.ExtractOs_parentModuleName(),
104 osType.getOsInfoLabel()));
105 postArtifact(createArtifactWithAttributes(BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_INFO, file, bbattributes));
119 private AbstractFile getFirstFileFound(List<String> pathsToSearchFor)
throws TskCoreException{
120 for (String filePath : pathsToSearchFor) {
121 List<AbstractFile> files = currentCase.getSleuthkitCase().getFileManager().findFilesExactNameExactPath(dataSource, FilenameUtils.getName(filePath), FilenameUtils.getPath(filePath));
122 if (!files.isEmpty()) {
130 "ExtractOs.osx.label=Mac OS X",
131 "ExtractOs.androidOs.label=Android",
132 "ExtractOs.redhatLinuxOs.label=Linux (Redhat)",
133 "ExtractOs.novellSUSEOs.label=Linux (Novell SUSE)",
134 "ExtractOs.fedoraLinuxOs.label=Linux (Fedora)",
135 "ExtractOs.slackwareLinuxOs.label=Linux (Slackware)",
136 "ExtractOs.debianLinuxOs.label=Linux (Debian)",
137 "ExtractOs.mandrakeLinuxOs.label=Linux (Mandrake)",
138 "ExtractOs.yellowDogLinuxOs.label=Linux (Yellow Dog)",
139 "ExtractOs.sunJDSLinuxOs.label=Linux (Sun JDS)",
140 "ExtractOs.solarisSparcOs.label=Linux (Solaris/Sparc)",
141 "ExtractOs.gentooLinuxOs.label=Linux (Gentoo)",
142 "ExtractOs.unitedLinuxOs.label=Linux (United Linux)",
143 "ExtractOs.ubuntuLinuxOs.label=Linux (Ubuntu)",
144 "ExtractOs.windowsVolume.label=OS Drive (Windows)",
145 "ExtractOs.osxVolume.label=OS Drive (OS X)",
146 "ExtractOs.androidVolume.label=OS Drive (Android)",
147 "ExtractOs.redhatLinuxVolume.label=OS Drive (Linux Redhat)",
148 "ExtractOs.novellSUSEVolume.label=OS Drive (Linux Novell SUSE)",
149 "ExtractOs.fedoraLinuxVolume.label=OS Drive (Linux Fedora)",
150 "ExtractOs.slackwareLinuxVolume.label=OS Drive (Linux Slackware)",
151 "ExtractOs.debianLinuxVolume.label=OS Drive (Linux Debian)",
152 "ExtractOs.mandrakeLinuxVolume.label=OS Drive (Linux Mandrake)",
153 "ExtractOs.yellowDogLinuxVolume.label=OS Drive (Linux Yellow Dog)",
154 "ExtractOs.sunJDSLinuxVolume.label=OS Drive (Linux Sun JDS)",
155 "ExtractOs.solarisSparcVolume.label=OS Drive (Linux Solaris/Sparc)",
156 "ExtractOs.gentooLinuxVolume.label=OS Drive (Linux Gentoo)",
157 "ExtractOs.unitedLinuxVolume.label=OS Drive (Linux United Linux)",
158 "ExtractOs.ubuntuLinuxVolume.label=OS Drive (Linux Ubuntu)"})
164 WINDOWS(
"", Bundle.ExtractOs_windowsVolume_label(), Arrays.asList(WINDOWS_VOLUME_PATH)),
165 MAC_OS_X(Bundle.ExtractOs_osx_label(), Bundle.ExtractOs_osxVolume_label(), Arrays.asList(OSX_VOLUME_PATH)),
166 ANDROID(Bundle.ExtractOs_androidOs_label(), Bundle.ExtractOs_androidVolume_label(), Arrays.asList(ANDROID_VOLUME_PATH)),
167 LINUX_REDHAT(Bundle.ExtractOs_redhatLinuxOs_label(), Bundle.ExtractOs_redhatLinuxVolume_label(), Arrays.asList(LINUX_RED_HAT_PATHS)),
168 LINUX_NOVELL_SUSE(Bundle.ExtractOs_novellSUSEOs_label(), Bundle.ExtractOs_novellSUSEVolume_label(), Arrays.asList(LINUX_NOVELL_SUSE_PATH)),
169 LINUX_FEDORA(Bundle.ExtractOs_fedoraLinuxOs_label(), Bundle.ExtractOs_fedoraLinuxVolume_label(), Arrays.asList(LINUX_FEDORA_PATH)),
170 LINUX_SLACKWARE(Bundle.ExtractOs_slackwareLinuxOs_label(), Bundle.ExtractOs_slackwareLinuxVolume_label(), Arrays.asList(LINUX_SLACKWARE_PATHS)),
171 LINUX_DEBIAN(Bundle.ExtractOs_debianLinuxOs_label(), Bundle.ExtractOs_debianLinuxVolume_label(), Arrays.asList(LINUX_DEBIAN_PATHS)),
172 LINUX_MANDRAKE(Bundle.ExtractOs_mandrakeLinuxOs_label(), Bundle.ExtractOs_mandrakeLinuxVolume_label(), Arrays.asList(LINUX_MANDRAKE_PATH)),
173 LINUX_YELLOW_DOG(Bundle.ExtractOs_yellowDogLinuxOs_label(), Bundle.ExtractOs_yellowDogLinuxVolume_label(), Arrays.asList(LINUX_YELLOW_DOG_PATH)),
174 LINUX_SUN_JDS(Bundle.ExtractOs_sunJDSLinuxOs_label(), Bundle.ExtractOs_sunJDSLinuxVolume_label(), Arrays.asList(LINUX_SUN_JDS_PATH)),
175 LINUX_SOLARIS_SPARC(Bundle.ExtractOs_solarisSparcOs_label(), Bundle.ExtractOs_solarisSparcVolume_label(), Arrays.asList(LINUX_SOLARIS_SPARC_PATH)),
176 LINUX_GENTOO(Bundle.ExtractOs_gentooLinuxOs_label(), Bundle.ExtractOs_gentooLinuxVolume_label(), Arrays.asList(LINUX_GENTOO_PATH)),
177 LINUX_UNITED_LINUX(Bundle.ExtractOs_unitedLinuxOs_label(), Bundle.ExtractOs_unitedLinuxVolume_label(), Arrays.asList(LINUX_UNITED_LINUX_PATH)),
178 LINUX_UBUNTU(Bundle.ExtractOs_ubuntuLinuxOs_label(), Bundle.ExtractOs_ubuntuLinuxVolume_label(), Arrays.asList(LINUX_UBUNTU_PATH));
180 private final String osInfoLabel;
181 private final String dsUsageLabel;
182 private final List<String> filePaths;
194 private OS_TYPE(String osInfoText, String dsUsageText, List<String> filePathList) {
195 this.osInfoLabel = osInfoText;
196 this.dsUsageLabel = dsUsageText;
197 this.filePaths = filePathList;
206 String getOsInfoLabel() {
216 String getDsUsageLabel() {
226 List<String> getFilePaths() {
227 return Collections.unmodifiableList(filePaths);
240 static public OS_TYPE fromDsUsageLabel(String dsUsageLabel) {
241 for (OS_TYPE value : OS_TYPE.values()) {
242 if (value.getDsUsageLabel().equals(dsUsageLabel)) {
258 static public OS_TYPE fromOsInfoLabel(String osInfoLabel) {
259 for (OS_TYPE value : OS_TYPE.values()) {
260 if (value.getOsInfoLabel().equals(osInfoLabel)) {