Test::Unit::TestCase
# File lib/rex/proto/smb/client.rb.ut.rb, line 149 def test_smb_session_request begin Timeout.timeout($_REX_TEST_TIMEOUT) { s = Rex::Socket.create_tcp( 'PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 139 ) c = Klass.new(s) # Request a SMB session over NetBIOS # puts "[*] Requesting a SMB session over NetBIOS..." ok = c.session_request() assert_kind_of(Rex::Struct2::CStruct, ok) # Check for a positive session response # A negative response is 0x83 assert_equal(ok.v['Type'], 0x82) # puts "[*] Negotiating SMB dialects..." ok = c.negotiate() assert_kind_of(Rex::Struct2::CStruct, ok) # puts "[*] Authenticating with NTLMv2..." ok = c.session_setup_with_ntlmssp assert_kind_of(Rex::Struct2::CStruct, ok) # puts "[*] Authenticating with NTLMv1..." ok = c.session_setup_no_ntlmssp assert_kind_of(Rex::Struct2::CStruct, ok) # puts "[*] Authenticating with clear text passwords..." begin ok = c.session_setup_clear assert_kind_of(Rex::Struct2::CStruct, ok) rescue Rex::Proto::SMB::Exceptions::ErrorCode if ($!.error_code != 0x00010002) raise $! end end # puts "[*] Connecting to IPC$..." ok = c.tree_connect assert_kind_of(Rex::Struct2::CStruct, ok) # puts "[*] Opening the \BROWSER pipe..." ok = c.create_pipe('\BROWSER') assert_kind_of(Rex::Struct2::CStruct, ok) vers = DCERPCUUID.vers_by_name('SRVSVC') uuid = DCERPCUUID.uuid_by_name('SRVSVC') bind, ctx = DCERPCPacket.make_bind_fake_multi(uuid, vers) # puts "[*] Binding to the Server Service..." ok = c.trans_named_pipe(c.last_file_id, bind) assert_kind_of(Rex::Struct2::CStruct, ok) data = ok.to_s.slice( ok['Payload'].v['DataOffset'] + 4, ok['Payload'].v['DataCount'] ) assert_not_equal(data, nil) resp = DCERPCResponse.new(data) assert_equal(resp.type, 12) } rescue Timeout::Error flunk('timeout') end end
Generated with the Darkfish Rdoc Generator 2.