Merge patch to fix #5271
parent
d6cf3dbf9f
commit
30a86c9378
|
@ -37,7 +37,7 @@ class Nasm
|
|||
#
|
||||
# Assembles the supplied assembly and returns the raw opcodes.
|
||||
#
|
||||
def self.assemble(assembly)
|
||||
def self.assemble(assembly, bits=32)
|
||||
check
|
||||
|
||||
# Open the temporary file
|
||||
|
@ -48,7 +48,7 @@ class Nasm
|
|||
opath = tmp.path + '.out'
|
||||
|
||||
# Write the assembly data to a file
|
||||
tmp.write("BITS 32\n" + assembly)
|
||||
tmp.write("BITS #{bits}\n" + assembly)
|
||||
tmp.flush()
|
||||
tmp.seek(0)
|
||||
|
||||
|
@ -70,7 +70,7 @@ class Nasm
|
|||
#
|
||||
# Disassembles the supplied raw opcodes
|
||||
#
|
||||
def self.disassemble(raw)
|
||||
def self.disassemble(raw, bits=32)
|
||||
check
|
||||
|
||||
tmp = Tempfile.new('nasmout')
|
||||
|
@ -82,7 +82,7 @@ class Nasm
|
|||
tfd.flush()
|
||||
tfd.close
|
||||
|
||||
p = ::IO.popen("\"#{@@ndisasm_path}\" -u \"#{tmp.path}\"")
|
||||
p = ::IO.popen("\"#{@@ndisasm_path}\" -b #{bits} \"#{tmp.path}\"")
|
||||
o = ''
|
||||
|
||||
begin
|
||||
|
|
|
@ -22,6 +22,12 @@ rescue RuntimeError
|
|||
exit
|
||||
end
|
||||
|
||||
bits = ARGV.length > 0 ? ARGV[0].to_i : 32
|
||||
if ! [16, 32, 64].include?(bits) then
|
||||
puts "#{bits} bits not supported"
|
||||
exit 1
|
||||
end
|
||||
|
||||
# Start a pseudo shell and dispatch lines to be assembled and then
|
||||
# disassembled.
|
||||
shell = Rex::Ui::Text::PseudoShell.new("%bldnasm%clr")
|
||||
|
@ -35,7 +41,7 @@ shell.run { |line|
|
|||
|
||||
begin
|
||||
puts(Rex::Assembly::Nasm.disassemble(
|
||||
Rex::Assembly::Nasm.assemble(line)))
|
||||
Rex::Assembly::Nasm.assemble(line, bits), bits))
|
||||
rescue RuntimeError
|
||||
puts "Error: #{$!}"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue