Add specs for Msf::Exploit::Remote::SMB::Server::Share::Command::Close

bug/bundler_fix
jvazquez-r7 2015-03-02 16:00:02 -06:00
parent b0bc69b832
commit 50f5baa7c6
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
# -*- coding:binary -*-
require 'spec_helper'
require 'msf/core'
require 'msf/core/exploit/smb/server/share'
describe Msf::Exploit::Remote::SMB::Server::Share do
subject(:mod) do
mod = Msf::Exploit.new
mod.extend described_class
mod.send(:initialize)
mod
end
let(:client_string) { '' }
let(:client) { StringIO.new(client_string) }
let(:response_length) { 39 }
let(:valid_response) do
"\x00\x00\x00\x23\xff\x53\x4d\x42" +
"\x04\x00\x00\x00\x00\x88\x01\xc8" +
"\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x48\x47" +
"\x00\x00\x44\x43\x00\x00\x00"
end
before(:each) do
mod.instance_variable_set('@state', {
client => {
:multiplex_id => 0x41424344,
:process_id => 0x45464748,
:file_id => 0xdead,
:dir_id => 0xbeef
}
})
allow_any_instance_of(::StringIO).to receive(:put) do |io, data|
io.write(data)
end
end
describe "#send_close_res" do
it "returns the number of bytes sent" do
expect(mod.send_close_res(client)).to eq(response_length)
end
it "sends a valid SMB_COM_CLOSE response to the client" do
mod.send_close_res(client)
client.seek(0)
res = client.read
expect(res).to eq(valid_response)
end
end
end