This commit is contained in:
adam-m 2012-05-02 00:13:32 -04:00
parent 0f394c6a15
commit a38d546ecb
5 changed files with 307 additions and 0 deletions

View File

@ -0,0 +1,53 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.sleuthkit.autopsy.report;
/**
*
* @author Alex
*/
import java.lang.reflect.Method;
public class BrowserControl {
/**
* Method to Open the Browser with Given URL
*
* @param url
*/
public static void openUrl(String url) {
String os = System.getProperty("os.name");
Runtime runtime = Runtime.getRuntime();
try {
// Block for Windows Platform
if (os.startsWith("Windows")) {
String cmd = "rundll32 url.dll,FileProtocolHandler " + url;
Process p = runtime.exec(cmd);
} //Block for Mac OS
else if (os.startsWith("Mac OS")) {
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[]{String.class});
openURL.invoke(null, new Object[]{url});
} //Block for UNIX Platform
else {
String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"};
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++) {
if (runtime.exec(new String[]{"which", browsers[count]}).waitFor() == 0) {
browser = browsers[count];
}
}
if (browser == null) {
throw new Exception("Could not find web browser");
} else {
runtime.exec(new String[]{browser, url});
}
}
} catch (Exception x) {
System.err.println("Exception occurd while invoking Browser!");
x.printStackTrace();
}
}
}

View File

@ -0,0 +1,108 @@
/*
*
* Autopsy Forensic Browser
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
* Project Contact/Architect: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.report;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.SleuthkitCase;
/**
* Configures which parts of report were requested e.g. based on user input Some
* specialized reporting modules may choose not to generate all requested
* sections and some modules may generate additional, specialized sections
*
*/
class ReportConfiguration {
//base data structure
Map<BlackboardArtifact.ARTIFACT_TYPE, Boolean> config = new EnumMap<BlackboardArtifact.ARTIFACT_TYPE, Boolean>(BlackboardArtifact.ARTIFACT_TYPE.class);
private final Logger logger = Logger.getLogger(this.getClass().getName());
ReportConfiguration() {
//clear the config just incase before we get the list from the db again
config.clear();
//now lets get the list from the tsk and current case
Case currentCase = Case.getCurrentCase(); // get the most updated case
SleuthkitCase skCase = currentCase.getSleuthkitCase();
try {
ArrayList<BlackboardArtifact.ARTIFACT_TYPE> arttypes = skCase.getBlackboardArtifactTypes();
for (BlackboardArtifact.ARTIFACT_TYPE type : arttypes) {
config.put(type, Boolean.FALSE);
}
} catch (Exception ex) {
logger.log(Level.WARNING, "Error while trying to retrieve list of artifact types from the TSK case .", ex);
}
}
;
//setters for generally supported report parts
public void setGenArtifactType(BlackboardArtifact.ARTIFACT_TYPE type, Boolean value) throws ReportModuleException {
if (config.containsKey(type)) {
config.put(type, value);
} else {
throw new ReportModuleException("The following artifact type is not present:" + type);
}
}
;
//This allows all that setting to happen in groups
public void setGenArtifactType(ArrayList<BlackboardArtifact.ARTIFACT_TYPE> typeList, boolean value) throws ReportModuleException {
for (BlackboardArtifact.ARTIFACT_TYPE type : typeList) {
if (config.containsKey(type)) {
config.put(type, value);
} else {
throw new ReportModuleException("The following artifact type is not present:" + type);
}
}
}
;
//getters for generally supported report parts
public boolean getGenArtifactType(BlackboardArtifact.ARTIFACT_TYPE type) throws ReportModuleException {
boolean value = false;
if (config.containsKey(type)) {
value = config.get(type);
} else {
throw new ReportModuleException("The following artifact type is not present:" + type);
}
return value;
}
public void resetGenArtifactTypes() {
for (Map.Entry<BlackboardArtifact.ARTIFACT_TYPE, Boolean> entry : config.entrySet()) {
config.put(entry.getKey(), Boolean.FALSE);
}
}
}

View File

@ -0,0 +1,49 @@
/*
*
* Autopsy Forensic Browser
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
* Project Contact/Architect: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.report;
import java.util.ArrayList;
import java.util.HashMap;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
/**
*
* This class is the 'default' way to get artifacts/attributes from the
* blackboard using a reportconfiguration object.
*/
public class ReportGen {
HashMap<BlackboardArtifact, ArrayList<BlackboardAttribute>> Results = new HashMap<BlackboardArtifact, ArrayList<BlackboardAttribute>>();
ReportGen() {
}
public void flushReport() {
Results.clear();
}
public void populateReport(ReportConfiguration config) {
flushReport();
report bbreport = new report();
Results = bbreport.getAllTypes(config);
}
}

View File

@ -0,0 +1,64 @@
/*
*
* Autopsy Forensic Browser
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
* Project Contact/Architect: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.report;
//interface every reporting module should implement
public interface ReportModule {
/**
* Generates a report on the current case Reporting module should traverse
* the blackboard, extract needed information as specified in the config and
* generate a report file
*
* @param config specifiying parts that should be generated
* @return absolute file path to the report generated
* @throws ReportModuleException if report generation failed
*/
public String generateReport() throws ReportModuleException;
/**
* This saves a copy of the report (current one) to another place specified
* by the user. Takes the input of where the path needs to be saved, include
* filename and extention.
*/
public void save(String Path) throws ReportModuleException;
/**
* Returns a short description of report type/file format this module
* generates for instance, "XML", "Excel"
*
* @return
*/
public String getReportType();
/**
* Returns the reportconfiguration object that was created
*
* @return
*/
public ReportConfiguration getReportConfiguration();
/**
* Returns a one line human readable description of the type of report this
* module generates
*/
public String getReportTypeDescription();
}

View File

@ -0,0 +1,33 @@
/*
*
* Autopsy Forensic Browser
*
* Copyright 2012 42six Solutions.
* Contact: aebadirad <at> 42six <dot> com
* Project Contact/Architect: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.report;
//exception thrown by a reporting module when report generation failed
class ReportModuleException extends Exception {
public ReportModuleException(String msg) {
super(msg);
}
public ReportModuleException(String msg, Exception ex) {
super(msg, ex);
}
}