@@ -67,8 +67,9 @@ def valid?(value, check_empty: nil)
6767 module Payload ::Windows ::PEInject
6868 def initialize ( info = { } )
6969 super
70+
7071 register_options ( [
71- OptInjectablePE . new ( 'PE' , [ true , 'The local path to the PE file to upload' ] , arch : arch . first )
72+ OptInjectablePE . new ( 'PE' , [ true , 'The local path to the PE file to upload' ] , arch : info . fetch ( 'AdaptedArch' , arch . first ) )
7273 ] , self . class )
7374 end
7475
@@ -83,7 +84,7 @@ def pe_path
8384 # Transmits the reflective PE payload to the remote
8485 # computer so that it can be loaded into memory.
8586 #
86- def handle_connection ( conn , _opts = { } )
87+ def handle_connection ( conn , opts = { } )
8788 data = ''
8889 begin
8990 File . open ( pe_path , 'rb' ) do |f |
@@ -96,7 +97,7 @@ def handle_connection(conn, _opts = {})
9697 end
9798
9899 print_status ( 'Premapping PE file...' )
99- pe_map = create_pe_memory_map ( data )
100+ pe_map = create_pe_memory_map ( data , opts )
100101 print_status ( "Mapped PE size #{ pe_map [ :bytes ] . length } " )
101102 opts = { }
102103 opts [ :is_dll ] = pe_map [ :is_dll ]
@@ -113,10 +114,10 @@ def handle_connection(conn, _opts = {})
113114 conn . close
114115 end
115116
116- def create_pe_memory_map ( file )
117+ def create_pe_memory_map ( file , opts = { } )
117118 pe = Rex ::PeParsey ::Pe . new ( Rex ::ImageSource ::Memory . new ( file ) )
118119 begin
119- OptInjectablePE . assert_compatible ( pe , arch . first )
120+ OptInjectablePE . assert_compatible ( pe , opts . fetch ( : arch, arch . first ) )
120121 rescue Msf ::ValidationError => e
121122 print_error ( "PE validation error: #{ e . message } " )
122123 raise
0 commit comments