From dbf0fcf0f28533188f91653dae23965ce12887f9 Mon Sep 17 00:00:00 2001 From: bmc <> Date: Wed, 29 Mar 2006 20:46:29 +0000 Subject: [PATCH] * add object_id and random object_id call evasion git-svn-id: file:///home/svn/incoming/trunk@3579 4d416f70-5f16-0410-b530-b9f4589650da --- lib/rex/proto/dcerpc/client.rb | 9 ++++- lib/rex/proto/dcerpc/client.rb.ut.rb | 53 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/lib/rex/proto/dcerpc/client.rb b/lib/rex/proto/dcerpc/client.rb index b7468ca887..4a8d7e0e4a 100644 --- a/lib/rex/proto/dcerpc/client.rb +++ b/lib/rex/proto/dcerpc/client.rb @@ -188,8 +188,15 @@ require 'rex/proto/smb/exceptions' if options['frag_size'] frag_size = options['frag_size'] end + object_id = '' + if options['object_call'] + object_id = self.handle.uuid[0] + end + if options['random_object_id'] + object_id = Rex::Proto::DCERPC::UUID.uuid_unpack(Rex::Text.rand_text(16)) + end - call_packets = Rex::Proto::DCERPC::Packet.make_request(function, data, frag_size, self.context) + call_packets = Rex::Proto::DCERPC::Packet.make_request(function, data, frag_size, self.context, object_id) call_packets.each { |packet| self.write(packet) } diff --git a/lib/rex/proto/dcerpc/client.rb.ut.rb b/lib/rex/proto/dcerpc/client.rb.ut.rb index ddf21898f8..b34159d4aa 100755 --- a/lib/rex/proto/dcerpc/client.rb.ut.rb +++ b/lib/rex/proto/dcerpc/client.rb.ut.rb @@ -299,6 +299,59 @@ class Rex::Proto::DCERPC::Client::UnitTest < Test::Unit::TestCase end end + def test_ncacn_ip_tcp_objectid + write = [ + "\x05\x00\x0b\x03\x10\x00\x00\x00\x48\x00\x00\x00\x00\x00\x00\x00\xd0\x16\xd0\x16\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x08\x83\xaf\xe1\x1f\x5d\xc9\x11\x91\xa4\x08\x00\x2b\x14\xa0\xfa\x03\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00", + "\x05\x00\x00\x83\x10\x00\x00\x00\x50\x00\x00\x00\x00\x00\x00\x00\x28\x00\x00\x00\x00\x00\x02\x00\010\203\257\341\037]\311\021\221\244\010\000+\024\240\372\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00" + ] + read = [ + "\x05\x00\x0c\x03\x10\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\xd0\x16\xd0\x16\x12\x66\x00\x00\x04\x00\x31\x33\x35\x00\xec\xd7\x01\x00\x00\x00\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00", + "\x05\x00\x02\x03\x10\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc4\x49\xc2\xb8\x92\x78\x4e\x4f\xb3\xe7\xbf\x7e\x00\x2a\xd3\x39\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x4b\x00\x00\x00\x4b\x00\x00\x00\x05\x00\x13\x00\x0d\x80\xa9\x88\x10\xe5\xea\xd0\x11\x8d\x9b\x00\xa0\x24\x53\xc3\x37\x01\x00\x02\x00\x00\x00\x13\x00\x0d\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x02\x00\x00\x00\x01\x00\x0b\x02\x00\x00\x00\x01\x00\x07\x02\x00\x08\x39\x01\x00\x09\x04\x00\x0a\x04\x0a\x3a\x00\x00\x00\x00\x00" + ] + setup_test(read, write) + begin + timeout($_REX_TEST_TIMEOUT) { + s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 135) + handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135]) + assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle') + dcerpc = Rex::Proto::DCERPC::Client.new(handle, s, {'object_call' => 1}) + assert_instance_of(Rex::Proto::DCERPC::Client, dcerpc, 'bind') + + stub = "\x00" * (4 * 9) + "\x01\x00\x00\x00" + got = dcerpc.call(0x02, stub) + s.close + } + rescue Timeout::Error + flunk('timeout') + end + end + def test_ncacn_ip_tcp_objectid_random + write = [ + "\x05\x00\x0b\x03\x10\x00\x00\x00\x48\x00\x00\x00\x00\x00\x00\x00\xd0\x16\xd0\x16\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x08\x83\xaf\xe1\x1f\x5d\xc9\x11\x91\xa4\x08\x00\x2b\x14\xa0\xfa\x03\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00", + "\005\000\000\203\020\000\000\000P\000\000\000\000\000\000\000(\000\000\000\000\000\002\000\254/u\300C\373\303g\t\323\025\362$WF\330\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000" + ] + read = [ + "\x05\x00\x0c\x03\x10\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00\xd0\x16\xd0\x16\x12\x66\x00\x00\x04\x00\x31\x33\x35\x00\xec\xd7\x01\x00\x00\x00\x00\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x00\x00", + "\x05\x00\x02\x03\x10\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc4\x49\xc2\xb8\x92\x78\x4e\x4f\xb3\xe7\xbf\x7e\x00\x2a\xd3\x39\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x4b\x00\x00\x00\x4b\x00\x00\x00\x05\x00\x13\x00\x0d\x80\xa9\x88\x10\xe5\xea\xd0\x11\x8d\x9b\x00\xa0\x24\x53\xc3\x37\x01\x00\x02\x00\x00\x00\x13\x00\x0d\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00\x2b\x10\x48\x60\x02\x00\x02\x00\x00\x00\x01\x00\x0b\x02\x00\x00\x00\x01\x00\x07\x02\x00\x08\x39\x01\x00\x09\x04\x00\x0a\x04\x0a\x3a\x00\x00\x00\x00\x00" + ] + setup_test(read, write) + begin + timeout($_REX_TEST_TIMEOUT) { + s = Rex::Socket.create_tcp('PeerHost' => $_REX_TEST_SMB_HOST, 'PeerPort' => 135) + handle = Rex::Proto::DCERPC::Handle.new(['E1AF8308-5D1F-11C9-91A4-08002B14A0FA', '3.0'], 'ncacn_ip_tcp', $_REX_TEST_SMB_HOST, [135]) + assert_instance_of(Rex::Proto::DCERPC::Handle, handle, 'handle') + dcerpc = Rex::Proto::DCERPC::Client.new(handle, s, {'random_object_id' => 1}) + assert_instance_of(Rex::Proto::DCERPC::Client, dcerpc, 'bind') + + stub = "\x00" * (4 * 9) + "\x01\x00\x00\x00" + got = dcerpc.call(0x02, stub) + s.close + } + rescue Timeout::Error + flunk('timeout') + end + end + # this test is the same as test_ncanc_ip_tcp def test_setup_socket_ncacn_ip_tcp end