fixed nop handler n stuff

git-svn-id: file:///home/svn/incoming/trunk@2795 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-07-18 14:39:00 +00:00
parent 429041cf7f
commit b14a626ad1
4 changed files with 22 additions and 8 deletions

View File

@ -10,9 +10,10 @@ class Nop
include Msf::Ui::Console::ModuleCommandDispatcher
@@generate_opts = Rex::Parser::Arguments.new(
"-b" => [ true, "The list of characters to avoid: '\\x00\\xff'" ],
"-h" => [ false, "Help banner." ],
"-t" => [ true, "The output type: ruby, perl, c, or raw." ])
"-b" => [ true, "The list of characters to avoid: '\\x00\\xff'" ],
"-h" => [ false, "Help banner." ],
"-s" => [ true, "The comma separated list of registers to save." ],
"-t" => [ true, "The output type: ruby, perl, c, or raw." ])
def commands
{
@ -27,7 +28,7 @@ class Nop
#
# Generates a NOP sled
#
def cmd_generate(args)
def cmd_generate(*args)
# No arguments? Tell them how to use it.
if (args.length == 0)
@ -36,6 +37,7 @@ class Nop
# Parse the arguments
badchars = nil
saveregs = nil
type = "ruby"
length = 200
@ -45,6 +47,8 @@ class Nop
length = val.to_i
when '-b'
badchars = Rex::Text.hex_to_raw(val)
when "-c"
saveregs = val.split(/,\s?/)
when '-t'
type = val
when '-h'
@ -60,8 +64,9 @@ class Nop
begin
sled = mod.generate_simple(
length,
'BadChars' => badchars,
'Format' => type)
'BadChars' => badchars,
'SaveRegisters' => saveregs,
'Format' => type)
rescue
log_error("Sled generation failed: #{$!}.")
return false

View File

@ -42,7 +42,14 @@ class Arguments
# Parses the supplied arguments into a set of options
#
def parse(args, &block)
skip_next = false
args.each_with_index { |arg, idx|
if (skip_next == true)
skip_next = false
next
end
if (arg.match(/^-/))
cfs = arg[0..2]
@ -55,6 +62,8 @@ class Arguments
param = args[idx+1]
end
skip_next = true
yield fmtspec, idx, param
}
else

View File

@ -102,7 +102,7 @@ class Console::CommandDispatcher::Core
add_extension_client(md)
end
rescue
log_error("failure: #{$!}")
log_error("\nfailure: #{$!}\n#{$@.join("\n")}")
next
end

View File

@ -73,7 +73,7 @@ module Text
# Converts a hex string to a raw string
#
def self.hex_to_raw(str)
[ str.downcase.gsub(/'/,'').gsub(/\\x([a-f0-9][a-f0-9])/, '\1') ].pack("H*")
[ str.downcase.gsub(/'/,'').gsub(/\\?x([a-f0-9][a-f0-9])/, '\1') ].pack("H*")
end
#