Merge patch to fix #5271

unstable
HD Moore 2011-11-10 20:01:50 -06:00
parent d6cf3dbf9f
commit 30a86c9378
2 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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