Allow more custom settings for creating a .Net control
git-svn-id: file:///home/svn/framework3/trunk@13546 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
5559eec7c9
commit
4f2a0f8c6a
|
@ -1090,7 +1090,7 @@ require 'digest/sha1'
|
|||
# Creates a .NET DLL which loads data into memory
|
||||
# at a specified location with read/execute permissions
|
||||
# - the data will be loaded at: base+0x2065
|
||||
# - max size is 0x8000 (32768)
|
||||
# - default max size is 0x8000 (32768)
|
||||
def self.to_dotnetmem(base=0x12340000, data="", opts={})
|
||||
|
||||
# Allow the user to specify their own DLL template
|
||||
|
@ -1102,20 +1102,26 @@ require 'digest/sha1'
|
|||
}
|
||||
|
||||
# Configure the image base
|
||||
pe[180, 4] = [base].pack('V')
|
||||
base_offset = opts[:base_offset] || 180
|
||||
pe[base_offset, 4] = [base].pack('V')
|
||||
|
||||
# Configure the TimeDateStamp
|
||||
pe[136, 4] = [rand(0x100000000)].pack('V')
|
||||
timestamp_offset = opts[:timestamp_offset] || 136
|
||||
pe[timestamp_offset, 4] = [rand(0x100000000)].pack('V')
|
||||
|
||||
# XXX: Unfortunately we cant make this RWX only RX
|
||||
# Mark this segment as read-execute AND writable
|
||||
# pe[412,4] = [0xe0000020].pack("V")
|
||||
|
||||
# Write the data into the .text segment
|
||||
pe[0x1065, 0x8000] = [data].pack("a32768")
|
||||
text_offset = opts[:text_offset] || 0x1065
|
||||
text_max = opts[:text_max] || 0x8000
|
||||
pack = opts[:pack] || 'a32768'
|
||||
pe[text_offset, text_max] = [data].pack(pack)
|
||||
|
||||
# Generic a randomized UUID
|
||||
pe[37656,16] = Rex::Text.rand_text(16)
|
||||
uuid_offset = opts[:uuid_offset] || 37656
|
||||
pe[uuid_offset,16] = Rex::Text.rand_text(16)
|
||||
|
||||
return pe
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue