CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/msf/base/sessions/mssql_spec.rb
Views: 11766
1
# frozen_string_literal: true
2
3
require 'spec_helper'
4
require 'rex/post/mssql'
5
6
RSpec.describe Msf::Sessions::MSSQL do
7
let(:client) { instance_double(Rex::Proto::MSSQL::Client) }
8
let(:opts) { { client: client, platform: Msf::Platform::Linux.realname, arch: ARCH_X86_64 } }
9
let(:console_class) { Rex::Post::MSSQL::Ui::Console }
10
let(:user_input) { instance_double(Rex::Ui::Text::Input::Readline) }
11
let(:user_output) { instance_double(Rex::Ui::Text::Output::Stdio) }
12
let(:name) { 'mssql' }
13
let(:log_source) { "session_#{name}" }
14
let(:type) { 'mssql' }
15
let(:description) { 'MSSQL' }
16
let(:can_cleanup_files) { false }
17
let(:address) { '192.0.2.1' }
18
let(:port) { 1433 }
19
let(:peer_info) { "#{address}:#{port}" }
20
let(:console) do
21
console = Rex::Post::MSSQL::Ui::Console.new(session)
22
console.disable_output = true
23
console
24
end
25
let(:envchange_result) { { type: 1, old: 'master', new: 'master' } }
26
27
before(:each) do
28
allow(user_input).to receive(:intrinsic_shell?).and_return(true)
29
allow(user_input).to receive(:output=)
30
allow(client).to receive(:initial_info_for_envchange).with({ envchange: 1 }).and_return(envchange_result)
31
allow(client).to receive(:peerinfo).and_return(peer_info)
32
allow(client).to receive(:peerport).and_return(port)
33
allow(client).to receive(:peerhost).and_return(address)
34
end
35
36
it_behaves_like 'client session'
37
end
38
39