Add switch_spec
This commit is contained in:
parent
0d55412e80
commit
52047a6c59
|
@ -18,23 +18,17 @@ module Metasploit
|
|||
private
|
||||
|
||||
def switch_1
|
||||
var_name_1 = "x#{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int}"
|
||||
var_name_2 = "y#{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int}"
|
||||
var_name_3 = "delta#{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int}"
|
||||
|
||||
var_name = "rndnum#{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int}"
|
||||
%Q|
|
||||
int GetTickCount();
|
||||
|
||||
void stub() {
|
||||
int #{var_name_1} = GetTickCount();
|
||||
int #{var_name_2} = GetTickCount();
|
||||
int #{var_name_3} = #{var_name_2} - #{var_name_1};
|
||||
switch(#{var_name_3}) {
|
||||
int #{var_name} = #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int};
|
||||
switch (#{var_name}) {
|
||||
case #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int}:
|
||||
#{var_name_2} = #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int};
|
||||
#{var_name} = #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int};
|
||||
break;
|
||||
default:
|
||||
#{var_name_1} = #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int};
|
||||
#{var_name} = #{Metasploit::Framework::Obfuscation::CRandomizer::Utility.rand_int};
|
||||
break;
|
||||
}
|
||||
}|
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'metasploit/framework/obfuscation/crandomizer/code_factory'
|
|||
|
||||
RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::OutputDebugString do
|
||||
|
||||
subject(:int_assignments) do
|
||||
subject(:outputdebugstring) do
|
||||
described_class.new
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Out
|
|||
expect(subject.send(:outputdebugstring_2)).to match(/void stub()/)
|
||||
end
|
||||
|
||||
it 'depends on stdlib.h' do
|
||||
it 'depends on OutputDebugString' do
|
||||
expect(subject.dep).to eq(['OutputDebugString'])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,15 +8,15 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Pri
|
|||
|
||||
describe '#stub' do
|
||||
it 'is a string' do
|
||||
expect(subject.send(:stub).class).to be(String)
|
||||
expect(subject.stub.class).to be(String)
|
||||
end
|
||||
|
||||
it 'has a printf' do
|
||||
expect(subject.send(:stub)).to match(/printf\(.+\)/)
|
||||
expect(subject.stub).to match(/printf\(.+\)/)
|
||||
end
|
||||
|
||||
it 'has a stub() function' do
|
||||
expect(subject.send(:stub)).to match(/void stub()/)
|
||||
expect(subject.stub).to match(/void stub()/)
|
||||
end
|
||||
|
||||
it 'depends on printf' do
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Str
|
|||
|
||||
describe '#stub' do
|
||||
it 'is a string' do
|
||||
expect(subject.send(:stub).class).to be(String)
|
||||
expect(subject.stub.class).to be(String)
|
||||
end
|
||||
|
||||
it 'assigns a string' do
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Str
|
|||
end
|
||||
|
||||
it 'has a stub() function' do
|
||||
expect(subject.send(:stub)).to match(/void stub()/)
|
||||
expect(subject.stub).to match(/void stub()/)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
require 'metasploit/framework/obfuscation/crandomizer/code_factory'
|
||||
|
||||
RSpec.describe Metasploit::Framework::Obfuscation::CRandomizer::CodeFactory::Switch do
|
||||
|
||||
subject(:switch) do
|
||||
described_class.new
|
||||
end
|
||||
|
||||
describe '#switch_1' do
|
||||
it 'is a string' do
|
||||
expect(subject.send(:switch_1).class).to be(String)
|
||||
end
|
||||
|
||||
it 'has a switch' do
|
||||
expect(subject.send(:switch_1)).to match(/switch(.+)/)
|
||||
end
|
||||
|
||||
it 'has a default' do
|
||||
expect(subject.send(:switch_1)).to match(/default:/)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#switch_2' do
|
||||
it 'is a string' do
|
||||
expect(subject.send(:switch_2).class).to be(String)
|
||||
end
|
||||
|
||||
it 'has a switch' do
|
||||
expect(subject.send(:switch_2)).to match(/switch(.+)/)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue