Skip to content

Commit

Permalink
Improve architecture validation
Browse files Browse the repository at this point in the history
  • Loading branch information
smcintyre-r7 committed Sep 8, 2022
1 parent 5b2f3eb commit 5f4dba4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ def cmd_bof_cmd(*args)
end

bof_data = ::File.binread(filename)
parsed = Metasm::COFF.decode(bof_data)
parsed = Metasm::COFF.decode_header(bof_data[0...20])
bof_arch = { # map of metasm to metasploit architectures
'AMD64' => ARCH_X64,
'I386' => ARCH_X86
}.fetch(parsed.header.machine, nil)

unless bof_arch
print_error('Unable to determine the file architecture.')
return
end
unless bof_arch == client.arch
print_error("The file architecture is incompatible with the current session (file: #{bof_arch} session: #{client.arch})")
return
Expand Down

0 comments on commit 5f4dba4

Please sign in to comment.