Skip to content

Commit 8cefe63

Browse files
committed
bug with testing Win2k8 correction
1 parent dc94e9f commit 8cefe63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/rex/parser/fs/ntfs.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def parse_index(index_entry)
103103
def parse_index_list(index_record, index_allocation_attribute)
104104
offset_index_entry_list = index_record[0, 4].unpack('V')[0]
105105
index_size = index_record[offset_index_entry_list + 8, 2].unpack('v')[0]
106+
index_size_in_bytes = index_size * @bytes_per_cluster
106107
index_entry = index_record[offset_index_entry_list, index_size]
107108
res = {}
108109
while index_entry[12, 4].unpack('V')[0] & 2 != 2
@@ -112,20 +113,19 @@ def parse_index_list(index_record, index_allocation_attribute)
112113
# should be 8 bytes length
113114
vcn = index_entry[-8, 4].unpack('V')[0]
114115
vcn_in_bytes = vcn * @bytes_per_cluster
115-
index_size_in_bytes = index_size * @bytes_per_cluster
116116
res_son = parse_index_list(index_allocation_attribute[vcn_in_bytes + 24, index_size_in_bytes], index_allocation_attribute)
117117
res.update(res_son)
118118
end
119119
offset_index_entry_list += index_size
120120
index_size = index_record[offset_index_entry_list + 8, 2].unpack('v')[0]
121+
index_size_in_bytes = index_size * @bytes_per_cluster
121122
index_entry = index_record [offset_index_entry_list, index_size]
122123
end
123124
# if son on the last
124125
if index_entry[12, 4].unpack('V')[0] & 1 == 1
125126
# should be 8 bytes length
126127
vcn = index_entry[-8, 4].unpack('V')[0]
127128
vcn_in_bytes = vcn * @bytes_per_cluster
128-
index_size_in_bytes = index_size * @bytes_per_cluster
129129
res_son = parse_index_list(index_allocation_attribute[vcn_in_bytes + 24, index_size_in_bytes], index_allocation_attribute)
130130
res.update(res_son)
131131
end
@@ -153,7 +153,6 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
153153
attribut = ''
154154
run_list_num = lowvcn
155155
old_offset = 0
156-
157156
while run_list_num <= highvcn
158157
first_runlist_byte = attribute[offset].ord
159158
run_offset_size = first_runlist_byte >> 4
@@ -170,11 +169,12 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
170169
run_offset += "\x00" * (8 - run_offset_size)
171170
end
172171
run_offset = run_offset.unpack('q<')[0]
172+
#offset relative to previous offset
173+
run_offset += old_offset
173174

174175
size_wanted = [run_length * @bytes_per_cluster, size_max - attribut.length].min
175-
176-
if cluster_num + (size_wanted / @bytes_per_cluster) >= run_list_num && (cluster_num < run_length + run_list_num)
177-
run_list_offset_in_cluster = run_offset + old_offset + [cluster_num - run_list_num, 0].max
176+
if cluster_num + (size_max / @bytes_per_cluster) >= run_list_num && (cluster_num < run_length + run_list_num)
177+
run_list_offset_in_cluster = run_offset + [cluster_num - run_list_num, 0].max
178178
run_list_offset = (run_list_offset_in_cluster) * @bytes_per_cluster
179179
run_list_offset = run_list_offset.to_i
180180
@file_handler.seek(run_list_offset)
@@ -183,7 +183,7 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
183183
while data.length < size_wanted
184184
data << @file_handler.read(size_wanted - data.length)
185185
end
186-
attribut += data
186+
attribut << data
187187
end
188188
offset += run_offset_size + run_length_size + 1
189189
run_list_num += run_length

0 commit comments

Comments
 (0)