Module: TurboRex::MSRPC::Utils

Extended by:
RPCBase
Included in:
RPCFinder::MemoryFinder
Defined in:
lib/turborex/msrpc/utils.rb

Constant Summary

Constants included from RPCBase

RPCBase::DCE_TransferSyntax, RPCBase::GUID, RPCBase::MIDL_SERVER_INFO, RPCBase::MIDL_SERVER_INFO32, RPCBase::MIDL_SERVER_INFO64, RPCBase::MIDL_STUBLESS_PROXY_INFO, RPCBase::MIDL_STUBLESS_PROXY_INFO32, RPCBase::MIDL_STUBLESS_PROXY_INFO64, RPCBase::MIDL_STUB_DESC, RPCBase::MIDL_STUB_DESC32, RPCBase::MIDL_STUB_DESC64, RPCBase::MIDL_SYNTAX_INFO, RPCBase::MIDL_SYNTAX_INFO32, RPCBase::MIDL_SYNTAX_INFO64, RPCBase::NDR64_TransferSyntax, RPCBase::RPC_DISPATCH_TABLE_T, RPCBase::RPC_DISPATCH_TABLE_T32, RPCBase::RPC_DISPATCH_TABLE_T64, RPCBase::RPC_IF_ID, RPCBase::RPC_PROTSEQ_ENDPOINT, RPCBase::RPC_PROTSEQ_ENDPOINT32, RPCBase::RPC_PROTSEQ_ENDPOINT64, RPCBase::RPC_SERVER_INTERFACE, RPCBase::RPC_SERVER_INTERFACE32, RPCBase::RPC_SERVER_INTERFACE64, RPCBase::RPC_SYNTAX_IDENTIFIER, RPCBase::RPC_SYNTAX_IDENTIFIER64, RPCBase::RPC_Struct_Mgr32, RPCBase::RPC_Struct_Mgr64, RPCBase::RPC_VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RPCBase

from_guid_str, make_transferSyntax

Methods included from CStruct

#define_structs

Class Method Details

.raw_to_guid_str(raw, upcase = true) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/turborex/msrpc/utils.rb', line 50

def self.raw_to_guid_str(raw, upcase = true)
  unpacked = raw.unpack("VvvCCa6")
  mac = unpacked[5].unpack("C*")
  unpacked[-1] = '%02x%02x%02x%02x%02x%02x' % mac
  formatted = ("%08x-%04x-%04x-%02x%02x-%s" % unpacked)
  upcase ? formatted.upcase : formatted
end

.read_cstring(isource, base = 0) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/turborex/msrpc/utils.rb', line 58

def self.read_cstring(isource, base=0)
  len=0
  cstr = ""
  until (data=isource.read(base+len, 1)) == "\x00"
    cstr << data
    len+=1
  end

  return cstr, len
end

Instance Method Details

#gen_script_rpc_client_np(opts = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/turborex/msrpc/utils.rb', line 10

def gen_script_rpc_client_np(opts = {})
  uuid = opts[:uuid]
  version = opts[:version] || '1.0'
  function = opts[:function]
  data = opts[:data]
  pipe = opts[:pipe]
  output = opts[:output] || 'my_rpc_client.rb'

  template = "    #usage: ruby your_script.rb RHOST USERNAME PASSWORD\n    require 'rex'\n    require 'rex/encoder/ndr'\n  \n    Rex::Proto::SMB::SimpleClient.class_eval do\n      attr_accessor :read_timeout\n    end\n    \n    uuid = \#{uuid}\n    version = \#{version}\n    protocol = 'ncacn_np'\n    rhost = ARGV[0]\n    opts = ['\#{pipe}']\n    handle = Rex::Proto::DCERPC::Handle.new([uuid, version], protocol, rhost, opts)\n    function = \#{function}\n    data = \#{data}\n    \n    sock = Rex::Socket::Tcp.create('PeerHost' => rhost, 'PeerPort' => 445)\n    dcerpc = Rex::Proto::DCERPC::Client.new(handle, sock, {'smb_user' => ARGV[1], 'smb_pass' => ARGV[2]})\n    res = dcerpc.call(function, data, true)\n\n    puts res\n  EOS\n\n  file = File.new(output, 'rw')\n  file.puts template\n  file.close\n\n  true\nend\n"

#get_interface_typeObject

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/turborex/msrpc/utils.rb', line 6

def get_interface_type
  raise NotImplementedError
end