From 5c86b836c472d1aa48d1be1885200c4acbed9297 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Thu, 28 Jun 2018 21:08:15 -0500 Subject: [PATCH] Add rspec for outputdebugstring and correct a few things --- .../crandomizer/code_factory/malloc.rb | 2 +- .../code_factory/int_assignments_spec.rb | 2 +- .../crandomizer/code_factory/malloc_spec.rb | 4 +-- .../code_factory/outputdebugstring_spec.rb | 26 +++++++++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/outputdebugstring_spec.rb diff --git a/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc.rb b/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc.rb index 3129a8e439..f38f57ec58 100644 --- a/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc.rb +++ b/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc.rb @@ -10,7 +10,7 @@ module Metasploit class Malloc < Base def initialize super - @dep = ['stdlib.h'] + @dep = ['malloc'] end def stub diff --git a/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/int_assignments_spec.rb b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/int_assignments_spec.rb index 9cf70993fe..7c6940a80e 100644 --- a/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/int_assignments_spec.rb +++ b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/int_assignments_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Int described_class.new end - describe '#if_stub' do + describe '#stub' do it 'is a string' do expect(subject.send(:stub).class).to be(String) end diff --git a/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc_spec.rb b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc_spec.rb index ef8704220d..22c3ae8f71 100644 --- a/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc_spec.rb +++ b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/malloc_spec.rb @@ -19,8 +19,8 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Mal expect(subject.send(:stub)).to match(/void stub()/) end - it 'depends on stdlib.h' do - expect(subject.dep).to eq(['stdlib.h']) + it 'depends on malloc' do + expect(subject.dep).to eq(['malloc']) end end end \ No newline at end of file diff --git a/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/outputdebugstring_spec.rb b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/outputdebugstring_spec.rb new file mode 100644 index 0000000000..c9aec76724 --- /dev/null +++ b/spec/lib/metasploit/framework/obfuscation/crandomizer/code_factory/outputdebugstring_spec.rb @@ -0,0 +1,26 @@ +require 'metasploit/framework/obfuscation/crandomizer/code_factory' + +RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::OutputDebugString do + + subject(:int_assignments) do + described_class.new + end + + describe '#outputdebugstring_1' do + it 'is a string' do + expect(subject.send(:outputdebugstring_1).class).to be(String) + end + + it 'has an OutputDebugString' do + expect(subject.send(:outputdebugstring_1)).to match(/OutputDebugString\(.+\)/) + end + + it 'has a stub() function' do + expect(subject.send(:outputdebugstring_1)).to match(/void stub()/) + end + + it 'depends on stdlib.h' do + expect(subject.dep).to eq(['OutputDebugString']) + end + end +end \ No newline at end of file