Class: Rex::Zip::CentralDir

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/zip/blocks.rb

Overview

This structure holds all of the information about a particular Zip Entry as it is contained within the central directory.

Constant Summary collapse

SIGNATURE =
0x2014b50

Instance Method Summary collapse

Constructor Details

#initialize(entry, offset) ⇒ CentralDir

Returns a new instance of CentralDir.



112
113
114
115
116
117
118
# File 'lib/rex/zip/blocks.rb', line 112

def initialize(entry, offset)
	@entry = entry
	@disknum_start = 0
	@attr_int = 0
	@attr_ext = 0x20
	@hdr_offset = offset
end

Instance Method Details

#packObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/rex/zip/blocks.rb', line 120

def pack
	path = @entry.relative_path

	ret = [ SIGNATURE, ZIP_VERSION ].pack('Vv')
	ret << [ ZIP_VERSION ].pack('v')
	ret << @entry.flags.pack
	ret << @entry.info.pack
	arr = []
	arr << path.length
	arr << @entry.xtra.length
	arr << @entry.comment.length
	arr << @disknum_start
	arr << @attr_int
	arr << @entry.attrs
	arr << @hdr_offset
	ret << arr.pack('vvvvvVV')
	ret << path
	ret << @entry.xtra
	ret << @entry.comment
	# digital signature not supported
	ret
end