19 package org.sleuthkit.autopsy.modules.e01verify;
21 import java.security.MessageDigest;
22 import java.security.NoSuchAlgorithmException;
23 import java.util.logging.Level;
24 import javax.xml.bind.DatatypeConverter;
25 import org.openide.util.NbBundle;
67 messageDigest = MessageDigest.getInstance(
"MD5");
68 }
catch (NoSuchAlgorithmException ex) {
69 logger.log(Level.WARNING,
"Error getting md5 algorithm", ex);
70 throw new RuntimeException(
71 NbBundle.getMessage(
this.getClass(),
"EwfVerifyIngestModule.startUp.exception.failGetMd5"));
77 String imgName = dataSource.
getName();
78 if (!(dataSource instanceof
Image)) {
79 logger.log(Level.INFO,
"Skipping disk image image {0}", imgName);
81 NbBundle.getMessage(this.getClass(),
82 "EwfVerifyIngestModule.process.skipNonEwf",
86 Image img = (Image)dataSource;
90 logger.log(Level.INFO,
"Skipping non-ewf image {0}", imgName);
92 NbBundle.getMessage(this.getClass(),
93 "EwfVerifyIngestModule.process.skipNonEwf",
99 storedHash = img.
getMd5().toLowerCase();
100 logger.log(Level.INFO,
"Hash value stored in {0}: {1}",
new Object[]{imgName, storedHash});
103 NbBundle.getMessage(this.getClass(),
104 "EwfVerifyIngestModule.process.noStoredHash",
109 logger.log(Level.INFO,
"Starting hash verification of {0}", img.
getName());
111 NbBundle.getMessage(this.getClass(),
112 "EwfVerifyIngestModule.process.startingImg",
117 logger.log(Level.WARNING,
"Size of image {0} was 0 when queried.", imgName);
119 NbBundle.getMessage(this.getClass(),
120 "EwfVerifyIngestModule.process.errGetSizeOfImg",
126 long chunkSize = 64 * img.
getSsize();
127 chunkSize = (chunkSize == 0) ? DEFAULT_CHUNK_SIZE : chunkSize;
129 int totalChunks = (int) Math.ceil(size / chunkSize);
130 logger.log(Level.INFO,
"Total chunks = {0}", totalChunks);
137 for (
int i = 0; i < totalChunks; i++) {
141 data =
new byte[(int) chunkSize];
143 read = img.
read(data, i * chunkSize, chunkSize);
145 String msg = NbBundle.getMessage(this.getClass(),
146 "EwfVerifyIngestModule.process.errReadImgAtChunk", imgName, i);
148 logger.log(Level.SEVERE, msg, ex);
151 messageDigest.update(data);
156 calculatedHash = DatatypeConverter.printHexBinary(messageDigest.digest()).toLowerCase();
157 verified = calculatedHash.equals(storedHash);
158 logger.log(Level.INFO,
"Hash calculated from {0}: {1}",
new Object[]{imgName, calculatedHash});
163 msg = NbBundle.getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.verified");
165 msg = NbBundle.getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.notVerified");
167 String extra = NbBundle
168 .getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.verifyResultsHeader", imgName);
169 extra += NbBundle.getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.resultLi", msg);
170 extra += NbBundle.getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.calcHashLi", calculatedHash);
171 extra += NbBundle.getMessage(this.getClass(),
"EwfVerifyIngestModule.shutDown.storedHashLi", storedHash);
173 logger.log(Level.INFO,
"{0}{1}",
new Object[]{imgName, msg});
static final IngestServices services
TskData.TSK_IMG_TYPE_ENUM getType()
static IngestMessage createMessage(MessageType messageType, String source, String subject, String detailsHtml)
int read(byte[] buf, long offset, long len)
MessageDigest messageDigest
static final Logger logger
void startUp(IngestJobContext context)
void postMessage(final IngestMessage message)
ProcessResult process(Content dataSource, DataSourceIngestModuleProgress statusHelper)
static final long DEFAULT_CHUNK_SIZE
boolean dataSourceIngestIsCancelled()
void switchToDeterminate(int workUnits)
void progress(int workUnits)
static Logger getLogger(String name)
static synchronized IngestServices getInstance()