Path: blob/master/spec/modules/auxiliary/scanner/ipmi/ipmi_dumphashes_spec.rb
74576 views
require 'rspec'1require 'stringio'23RSpec.describe 'IPMI Dump Hashes Scanner' do4include_context 'Msf::Simple::Framework#modules loading'56subject do7load_and_create_module(8module_type: 'auxiliary',9reference_name: 'scanner/ipmi/ipmi_dumphashes'10)11end1213let(:udp_sock) do14instance_double(Rex::Socket::Udp)15end1617before do18subject.datastore['USER_FILE'] = 'users.txt'19subject.datastore['PASS_FILE'] = 'passwords.txt'20subject.datastore['CRACK_COMMON'] = false21subject.datastore['SESSION_MAX_ATTEMPTS'] = 122subject.datastore['SESSION_RETRY_DELAY'] = 023subject.datastore['RHOST'] = '192.0.2.1'24subject.datastore['RPORT'] = 6232526allow(File).to receive(:open).with('users.txt', 'rb').and_yield(StringIO.new("admin\nroot\n"))27allow(File).to receive(:open).with('passwords.txt', 'rb').and_yield(StringIO.new("password\n"))28allow(Rex::Socket::Udp).to receive(:create).and_return(udp_sock)29allow(subject).to receive(:add_socket)30allow(subject).to receive(:ipmi_status)31allow(subject).to receive(:ipmi_error)32allow(subject).to receive(:ipmi_good)33allow(subject).to receive(:report_hash).and_return(1)34allow(subject).to receive(:report_vuln)35allow(subject).to receive(:report_cracked_cred)36allow(subject).to receive(:write_output_files)37allow(subject).to receive(:sleep)38allow(Rex).to receive(:sleep)39end4041describe '#run_host' do42it 'stops username enumeration when the host never answers the first open-session probe' do43allow(udp_sock).to receive(:sendto)44allow(udp_sock).to receive(:recvfrom).and_return([nil, nil, nil])4546expect(udp_sock).to receive(:sendto).exactly(3).times4748subject.run_host('192.0.2.1')49end50end51end525354