node/lib/metasm/metasm/os/windows.rb
# Injects a shellcode into the memory space of targetproc
# target is a WinOS::Process
# shellcode may be a String (raw shellcode) or an EncodedData
# With an EncodedData, unresolved relocations are solved using
# exports of modules from the target address space ; also the
# shellcode need not be position-independant.
Injects a shellcode into the memory space of targetproc
target is a WinOS::Process
shellcode may be a String (raw shellcode) or an EncodedData
With an EncodedData, unresolved relocations are solved using
exports of modules from the target address space ; also the
shellcode need not be position-independant.
Injects a shellcode into the memory space of targetproc target is a WinOS :: Process shellcode may be a String ( raw shellcode ) or an EncodedData With an EncodedData unresolved relocations are solved using exports of modules from the target address space ; also the shellcode need not be position - independant .
def inject_shellcode(target, shellcode)
		raise 'cannot open target memory' if not remote_mem = target.memory
		return if not injectaddr = WinAPI.virtualallocex(target.handle, 0, shellcode.length,
				WinAPI::MEM_COMMIT | WinAPI::MEM_RESERVE, WinAPI::PAGE_EXECUTE_READWRITE)
		puts 'remote buffer at %x' % injectaddr if $VERBOSE
		if shellcode.kind_of? EncodedData
			fixup_shellcode_relocs(shellcode, target, remote_mem)
			shellcode.fixup! shellcode.binding(injectaddr)
			r = shellcode.reloc.values.map { |r_| r_.target }
			raise "unresolved shellcode relocs #{r.join(', ')}" if not r.empty?
			shellcode = shellcode.data
		end
		remote_mem[injectaddr, shellcode.length] = shellcode
		injectaddr
	end
def inject_shellcode ( target , shellcode ) raise 'cannot open target memory' if not remote_mem = target . memory return if not injectaddr = WinAPI . virtualallocex ( target . handle , 0 , shellcode . length , WinAPI :: MEM_COMMIT | WinAPI :: MEM_RESERVE , WinAPI :: PAGE_EXECUTE_READWRITE ) puts 'remote buffer at %x' % injectaddr if $VERBOSE if shellcode . kind_of? EncodedData fixup_shellcode_relocs ( shellcode , target , remote_mem ) shellcode . fixup! shellcode . binding ( injectaddr ) r = shellcode . reloc . values . map { | r_ | r_ . target } raise "unresolved shellcode relocs #{r.join(', ')}" if not r . empty? shellcode = shellcode . data end remote_mem [ injectaddr , shellcode . length ] = shellcode injectaddr end
Injects a shellcode into the memory space of targetproc
target is a WinOS::Process
shellcode may be a String (raw shellcode) or an EncodedData
With an EncodedData, unresolved relocations are solved using
exports of modules from the target address space ; also the
shellcode need not be position-independant.
Injects a shellcode into the memory space of targetproc target is a WinOS :: Process shellcode may be a String ( raw shellcode ) or an EncodedData With an EncodedData unresolved relocations are solved using exports of modules from the target address space ; also the shellcode need not be position - independant .
# inject the shellcode
target
shellcode