Go to the documentation of this file.
19package org.sleuthkit.autopsy.modules.hashdatabase;
21import java.sql.Connection;
22import java.sql.DriverManager;
23import java.sql.ResultSet;
24import java.sql.SQLException;
25import java.sql.Statement;
26import java.util.logging.Level;
27import org.sleuthkit.autopsy.coreutils.Logger;
28import org.sleuthkit.datamodel.HashEntry;
29import org.sleuthkit.datamodel.TskCoreException;
46 KdbHashSetParser(String
filename)
throws TskCoreException {
55 StringBuilder connectionURL =
new StringBuilder();
59 conn = DriverManager.getConnection(connectionURL.toString());
68 throw new TskCoreException(
"Error getting hash count from hash set " +
filename);
73 " (SELECT group_concat(c.comment, ' ') FROM comments c WHERE h.id = c.hash_id) as comment " +
77 }
catch (ClassNotFoundException | SQLException ex) {
78 throw new TskCoreException(
"Error opening/reading hash set " +
filename, ex);
100 byte[] hashBytes =
resultSet.getBytes(
"md5");
101 StringBuilder sb =
new StringBuilder();
102 for (
byte b : hashBytes) {
103 sb.append(String.format(
"%02x", b));
106 if (sb.toString().length() != 32) {
107 throw new TskCoreException(
"Hash has incorrect length: " + sb.toString());
110 String md5Hash = sb.toString();
111 String comment =
resultSet.getString(
"comment");
113 return new HashEntry(
null, md5Hash,
null,
null, comment);
115 throw new TskCoreException(
"Could not read expected number of hashes from hash set " +
filename);
117 }
catch (SQLException ex) {
118 throw new TskCoreException(
"Error opening/reading hash set " +
filename, ex);
150 }
catch (SQLException ex) {
151 Logger.
getLogger(KdbHashSetParser.class.getName()).log(Level.SEVERE,
"Error closing prepared statement.", ex);
158 }
catch (SQLException ex) {
159 Logger.
getLogger(KdbHashSetParser.class.getName()).log(Level.SEVERE,
"Error closing result set.", ex);
166 }
catch (SQLException ex) {
167 Logger.
getLogger(KdbHashSetParser.class.getName()).log(Level.SEVERE,
"Error closing connection.", ex);
synchronized static Logger getLogger(String name)
final String JDBC_BASE_URI
HashEntry getNextHashEntry()
long getExpectedHashCount()
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.