Skip to content
Snippets Groups Projects
Commit 99f0c81b authored by alexjacks92's avatar alexjacks92
Browse files

Closer to full build process working.

parent 23d81d20
No related branches found
No related tags found
No related merge requests found
......@@ -95,8 +95,4 @@
<!-- depends targets take care of the actual copying since the file differs on OS X and Linux -->
<!-- This assumes that TSK, libewf, and zlib have been installed on the system and those libraries will be with normal loading approaches -->
</target>
<target name="setupEnvPath" />
</project>
......@@ -79,10 +79,4 @@
<copy file="${tsk.jni.32}" todir="${i586}/win" overwrite="true"/>
<copy file="${tsk.jni.32}" todir="${i686}/win" overwrite="true"/>
</target>
<target name="setupEnvPath">
<!-- Add both of these to env path:
"${basedir}/../../win32/x64/${tsk.config}/libtsk_jni.dll" />
"${basedir}/../../win32/${tsk.config}/libtsk_jni.dll" /> -->
</target>
</project>
......@@ -15,6 +15,7 @@
<property name="sample" location="src/org/sleuthkit/datamodel/Examples"/>
<property name="build" location="build/"/>
<property name="dist" location="dist"/>
<property environment="env" upcase="yes"/>
<property name="lib" location="lib"/>
<property name="test" location="test"/>
<property name="test-standards" location="test/output/gold"/>
......@@ -183,8 +184,14 @@ pattern="lib/[artifact]-[revision](-[classifier]).[ext]" />
</javac>
</target>
<target name="run-sample" depends="setupEnvPath"
description="run the sample" >
<target name="run-sample" depends="compile-sample, copyLibs"
description="run the sample">
<java classname="org.sleuthkit.datamodel.Examples.Sample"
fork="true"
failonerror="true">
<env key="PATH" path="${basedir}/../../win32/x64/${tsk.config}/libtsk_jni.dll:${basedir}/../../win32/${tsk.config}/libtsk_jni.dll:${env.LIBEWF_HOME}"/>
<classpath refid="libraries"/>
</java>
</target>
......
......@@ -5,43 +5,65 @@
*/
package org.sleuthkit.datamodel.Examples;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.Image;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.SleuthkitJNI.CaseDbHandle.AddImageProcess;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskDataException;
/**
*
*/
public class Sample {
public static void run(String imagePath) {
try {
SleuthkitCase sk = SleuthkitCase.newCase(imagePath + ".db");
String timezone = "";
sk.makeAddImageProcess(timezone, true, false);
List<Image> images = sk.getImages();
for (Image image : images) {
for (Content content : image.getChildren()) {
System.out.println(content.getName());
}
}
List<AbstractFile> files = sk.findFiles(null, "*.txt");
for (AbstractFile file : files) {
System.out.println(file.getLocalAbsPath());
SleuthkitCase sk = SleuthkitCase.newCase(imagePath + ".db");
String timezone = "";
AddImageProcess process = sk.makeAddImageProcess(timezone, true, false);
ArrayList<String> paths = new ArrayList<String>();
paths.add(imagePath);
try {
process.run(paths.toArray(new String[paths.size()]));
} catch (TskDataException ex) {
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
}
process.commit();
List<Image> images = sk.getImages();
System.out.println("images size is " + images.size());
for (Image image : images) {
System.out.println("Found image: " + image.getName());
for (Content content : image.getChildren()) {
System.out.println(content.getName());
}
}
List<AbstractFile> files;
files = sk.findAllFilesWhere("name like '%.txt'");
for (AbstractFile file : files) {
System.out.println(file.getName());
}
} catch (TskCoreException e) {
System.out.println("Exception caught: " + e.getMessage());
}
}
}
public static void main(String[] args) {
Sample.run("C:\\Users\\ajacks\\TSK\\xp-sp3-v4\\xp-sp3-v4.001");
Sample.run("C:\\Users\\ajacks\\TSK\\nps-2008-jean\\nps-2008-jean.E01");
}
}
......@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Map;
/**
* Collection of methods to load libraries embedded in the TSK Datamodel Jar file.
......@@ -155,7 +156,7 @@ private static boolean loadNativeLibFromTskJar(Lib library) {
// copy library to temp folder and load it
try {
java.io.File tempFolder = new java.io.File(System.getProperty("java.io.tmpdir") + java.io.File.separator);
java.io.File tempLibFile = new java.io.File(tempFolder + libName + libExt);
java.io.File tempLibFile = new java.io.File(tempFolder + "/" + libName + libExt);
System.out.println("Temp Folder for Libraries: " + tempFolder.toString());
// cycle through the libraries and delete them.
......@@ -199,6 +200,15 @@ private static boolean loadNativeLibFromTskJar(Lib library) {
in.close();
out.close();
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
if(envName.equals("Path")) {
System.out.format("%s=%s%n",
envName,
env.get(envName));
}
}
// load it
System.load(tempLibFile.getAbsolutePath());
} catch (IOException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment