1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-10-16 01:21:15 +02:00

update metasm_shell to use super rex/ui readline fu

git-svn-id: file:///home/svn/framework3/trunk@8473 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Joshua Drake 2010-02-13 06:10:37 +00:00
parent 0e48287310
commit 3557cf2879

View File

@ -11,6 +11,8 @@
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rex'
require 'rex/ui'
require 'metasm'
@ -53,25 +55,26 @@ class String
end
end
# get in interactive assembler mode
def asm
puts 'type "exit" or "quit" to quit', 'use ";" for newline', ''
while (print "asm> " ; $stdout.flush ; l = gets)
break if %w[quit exit].include? l.chomp
begin
data = l.gsub(';', "\n")
next if data.strip.empty?
data = data.encode
puts '"' + data.unpack('C*').map { |c| '\\x%02x' % c }.join + '"'
rescue Metasm::Exception => e
puts "Error: #{e.class} #{e.message}"
end
# Start a pseudo shell and dispatch lines to be assembled and then
# disassembled.
shell = Rex::Ui::Text::PseudoShell.new("%bldmetasm%clr")
puts 'type "exit" or "quit" to quit', 'use ";" or "\\n" for newline', ''
shell.run { |l|
l.gsub!(/(\r|\n)/, '')
l.gsub!(/\\n/, "\n")
l.gsub!(';', "\n")
break if %w[quit exit].include? l.chomp
next if l.strip.empty?
begin
l = l.encode
puts '"' + l.unpack('C*').map { |c| '\\x%02x' % c }.join + '"'
rescue Metasm::Exception => e
puts "Error: #{e.class} #{e.message}"
end
puts
end
if __FILE__ == $0
asm
end
}