spec/exploits/exploit_spec.rb in ronin-exploits-0.2.0 vs spec/exploits/exploit_spec.rb in ronin-exploits-0.2.1
- old
+ new
@@ -4,11 +4,10 @@
require 'helpers/objects'
describe Exploits::Exploit do
before(:each) do
@exploit = load_exploit('test')
- @payload = load_payload('example')
end
it "should require a name attribute" do
exp2 = Exploits::Exploit.new
exp2.should_not be_valid
@@ -40,13 +39,16 @@
it "should not have any allowances by default" do
@exploit.allows.should be_empty
end
it "should specify the behaviors allowed by the exploit" do
- @exploit.allowing :memory_read
+ @exploit.allowing :memory_read, :memory_write
- @exploit.behaviors.first.should == Vuln::Behavior[:memory_read]
+ @exploit.behaviors.should == [
+ Vuln::Behavior[:memory_read],
+ Vuln::Behavior[:memory_write]
+ ]
end
it "should allow for the extending of Helper modules" do
@exploit.instance_eval { helper :padding }.should == true
end
@@ -61,12 +63,12 @@
@exploit.targeted_archs.should == [Arch.i686, Arch.i386]
end
it "should have targeted OSes" do
@exploit.targeted_oses.should == [
- OS.linux_version('2.6.23'),
- OS.windows_version('7.1')
+ OS.linux('2.6.23'),
+ OS.windows('7.1')
]
end
it "should have targeted products" do
@exploit.targeted_products.all? { |product|
@@ -92,42 +94,18 @@
it "should have a default targeted Arch" do
@exploit.arch.should == Arch.i686
end
it "should have a default targeted OS" do
- @exploit.os.should == OS.linux_version('2.6.23')
+ @exploit.os.should == OS.linux('2.6.23')
end
it "should have a default targeted Product" do
@exploit.product.name.should == 'ExampleWare'
@exploit.product.version.should == '1.5'
end
- it "should be able to switch between payloads" do
- @exploit.payload = @payload
-
- @exploit.switch_payload('other_payload') do
- @exploit.payload.should == 'other_payload'
- end
-
- @exploit.payload.should == @payload
- end
-
- it "should build the payload if it is a kind of Payloads::Payload" do
- @exploit.payload = @payload
- @exploit.encode_payload!
-
- @exploit.payload.should be_built
- end
-
- it "should share parameters with the payload if it is a kind of Payloads::Payload" do
- @exploit.payload = @payload
- @exploit.encode_payload!
-
- @payload.var.should == @exploit.var
- end
-
it "should encode a String payload" do
@exploit.payload = 'data'
@exploit.encode_payload!
@exploit.encoded_payload.should == 'data'
@@ -171,7 +149,11 @@
end
end
it "should return the name and the version when calling to_s" do
@exploit.to_s.should == 'test 0.2'
+ end
+
+ it "should have a custom inspect method" do
+ @exploit.inspect.should == '#<Ronin::Exploits::Exploit: test 0.2>'
end
end