Skip to content

Commit

Permalink
improved reading of data for very large .7z files
Browse files Browse the repository at this point in the history
  • Loading branch information
philsmd committed Jun 20, 2015
1 parent 120e447 commit 7e0177a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions 7z2hashcat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# philsmd (for hashcat)

# version:
# 0.3
# 0.4

# date released:
# april 2015

# date last updated:
# 1st May 2015
# 20th June 2015

# dependencies:
# Compress::Raw::Lzma
Expand Down Expand Up @@ -706,10 +706,6 @@ sub extract_hash_from_archive

seek $fp, $current_seek_position, 0;

my $data = my_read ($fp, $data_len);

return undef unless (length ($data) == $data_len);

# get remaining hash info (iv, number cycles power)

my $digest = get_digest ($digests_index, $unpack_info, $substreams_info);
Expand All @@ -724,6 +720,8 @@ sub extract_hash_from_archive

# special case: we can truncate the data_len and use 32 bytes in total for both iv + data (last 32 bytes of data)

my $data;

if ($has_encrypted_header == 0)
{
my $length_difference = $data_len - $unpack_size;
Expand All @@ -732,17 +730,26 @@ sub extract_hash_from_archive
{
if ($data_len >= 32)
{
$iv_buf = substr ($data, $data_len - 32, 16);
seek $fp, $data_len - 32, 1;

$iv_buf = my_read ($fp, 16);
$iv_len = 16;

$data = substr ($data, $data_len - 16, 16);
$data = my_read ($fp, 16);
$data_len = 16;

$unpack_size %= 16;
}
}
}

if (! defined ($data))
{
$data = my_read ($fp, $data_len);
}

return undef unless (length ($data) == $data_len);

if ($data_len > $SEVEN_ZIP_HASHCAT_MAX_DATA)
{
print STDERR "WARNING: the file '". $file_path . "' unfortunately can't be used with oclHashcat ";
Expand Down

0 comments on commit 7e0177a

Please sign in to comment.