2005-12-17 07:46:23 +01:00
|
|
|
#!/usr/bin/env ruby
|
2005-12-09 01:03:52 +01:00
|
|
|
#
|
|
|
|
# This tool provides an easy way to see what opcodes are associated with
|
|
|
|
# certain x86 instructions by making use of nasm if it is installed and
|
|
|
|
# reachable through the PATH environment variable.
|
|
|
|
#
|
2005-12-08 16:37:10 +01:00
|
|
|
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'rex/ui'
|
|
|
|
|
2005-12-09 01:03:52 +01:00
|
|
|
# Check to make sure nasm is installed and reachable through the user's PATH.
|
|
|
|
begin
|
|
|
|
Rex::Assembly::Nasm.check
|
|
|
|
rescue RuntimeError
|
|
|
|
puts "#{$!}"
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
# Start a pseudo shell and dispatch lines to be assembled and then
|
|
|
|
# disassembled.
|
2009-11-11 05:43:52 +01:00
|
|
|
shell = Rex::Ui::Text::PseudoShell.new("%bldnasm%clr")
|
2005-12-08 16:37:10 +01:00
|
|
|
|
|
|
|
shell.run { |line|
|
|
|
|
line.gsub!(/(\r|\n)/, '')
|
|
|
|
line.gsub!(/\\n/, "\n")
|
|
|
|
|
|
|
|
break if (line =~ /^(exit|quit)/i)
|
|
|
|
|
2005-12-09 05:54:37 +01:00
|
|
|
begin
|
|
|
|
puts(Rex::Assembly::Nasm.disassemble(
|
|
|
|
Rex::Assembly::Nasm.assemble(line)))
|
|
|
|
rescue RuntimeError
|
|
|
|
puts "Error: #{$!}"
|
|
|
|
end
|
2009-11-11 05:43:52 +01:00
|
|
|
}
|