From 0e35efaea2b778b1f18ae51bf6ff4fd9e5747f88 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Wed, 3 Jun 2009 03:02:42 +0000 Subject: [PATCH] Force binary string encoding in ruby 1.9.1, fix up a bad index call in x86.rb git-svn-id: file:///home/svn/framework3/trunk@6618 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/encoder.rb | 1 + lib/msf/sanity.rb | 6 ++++-- lib/rex/arch/x86.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/msf/core/encoder.rb b/lib/msf/core/encoder.rb index 80bf285935..dc128aa95c 100644 --- a/lib/msf/core/encoder.rb +++ b/lib/msf/core/encoder.rb @@ -263,6 +263,7 @@ class Encoder < Module # initialized and is ready to go. # def do_encode(state) + # Copy the decoder stub since we may need to modify it stub = decoder_stub(state).dup diff --git a/lib/msf/sanity.rb b/lib/msf/sanity.rb index c606208ac7..2a09859534 100644 --- a/lib/msf/sanity.rb +++ b/lib/msf/sanity.rb @@ -28,8 +28,10 @@ if (RUBY_VERSION =~ /^1\.9\./) puts " issues trying to use this version with the Metasploit Framework" - # Force binary encoding - # Encoding.default_external = Encoding.default_internal = "binary" + # Force binary encoding for Ruby versions that support it + if(Object.const_defined?('Encoding') and Encoding.respond_to?('default_external=')) + Encoding.default_external = Encoding.default_internal = "binary" + end end diff --git a/lib/rex/arch/x86.rb b/lib/rex/arch/x86.rb index 1b221b47e4..94535cf4d3 100644 --- a/lib/rex/arch/x86.rb +++ b/lib/rex/arch/x86.rb @@ -474,7 +474,7 @@ module X86 end pad = 0 - while (pad < (128-12) and badchars.index( (256-12-pad))) + while (pad < (128-12) and badchars.index( (256-12-pad).chr)) pad += 4 end