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/lib/rex/proto/dcerpc/exceptions.rb
Views: 11704
1
# -*- coding: binary -*-
2
module Rex
3
module Proto
4
module DCERPC
5
module Exceptions
6
7
class Error < ::RuntimeError
8
9
@@errors = {
10
0x00000000 => "stub-defined",
11
0x00000001 => "nca_s_fault_other",
12
0x00000005 => "nca_s_fault_access_denied",
13
0x000006d8 => "nca_s_fault_cant_perform",
14
0x000006f7 => "nca_s_fault_ndr",
15
0x16c9a001 => "rpc_s_op_rng_error",
16
0x16c9a006 => "rpc_s_wrong_boot_time",
17
0x16c9a012 => "rpc_s_no_memory",
18
0x16c9a016 => "rpc_s_comm_failure",
19
0x16c9a01b => "rpc_s_fault_object_not_found",
20
0x16c9a02c => "rpc_s_unknown_if",
21
0x16c9a02d => "rpc_s_unsupported_type",
22
0x16c9a030 => "rpc_s_cancel_timeout",
23
0x16c9a031 => "rpc_s_call_cancelled",
24
0x16c9a036 => "rpc_s_connection_closed",
25
0x16c9a041 => "rpc_s_connect_timed_out",
26
0x16c9a042 => "rpc_s_connect_rejected",
27
0x16c9a043 => "rpc_s_network_unreachable",
28
0x16c9a044 => "rpc_s_connect_no_resources",
29
0x16c9a045 => "rpc_s_rem_network_shutdown",
30
0x16c9a046 => "rpc_s_too_many_rem_connects",
31
0x16c9a047 => "rpc_s_no_rem_endpoint",
32
0x16c9a048 => "rpc_s_rem_host_down",
33
0x16c9a049 => "rpc_s_host_unreachable",
34
0x16c9a04a => "rpc_s_access_control_info_inv",
35
0x16c9a04b => "rpc_s_loc_connect_aborted",
36
0x16c9a04c => "rpc_s_connect_closed_by_rem",
37
0x16c9a04d => "rpc_s_rem_host_crashed",
38
0x16c9a074 => "rpc_s_fault_addr_error",
39
0x16c9a075 => "rpc_s_fault_context_mismatch",
40
0x16c9a076 => "rpc_s_fault_fp_div_by_zero",
41
0x16c9a077 => "rpc_s_fault_fp_error",
42
0x16c9a078 => "rpc_s_fault_fp_overflow",
43
0x16c9a079 => "rpc_s_fault_fp_underflow",
44
0x16c9a07a => "rpc_s_fault_ill_inst",
45
0x16c9a07b => "rpc_s_fault_int_div_by_zero",
46
0x16c9a07c => "rpc_s_fault_int_overflow",
47
0x16c9a07d => "rpc_s_fault_invalid_bound",
48
0x16c9a07e => "rpc_s_fault_invalid_tag",
49
0x16c9a07f => "rpc_s_fault_pipe_closed",
50
0x16c9a080 => "rpc_s_fault_pipe_comm_error",
51
0x16c9a081 => "rpc_s_fault_pipe_discipline",
52
0x16c9a082 => "rpc_s_fault_pipe_empty",
53
0x16c9a083 => "rpc_s_fault_pipe_memory",
54
0x16c9a084 => "rpc_s_fault_pipe_order",
55
0x16c9a085 => "rpc_s_fault_remote_comm_failure",
56
0x16c9a086 => "rpc_s_fault_remote_no_memory",
57
0x16c9a087 => "rpc_s_fault_unspec",
58
0x16c9a0a8 => "rpc_s_no_ns_permission",
59
0x16c9a0b5 => "rpc_s_no_more_bindings",
60
0x16c9a113 => "rpc_s_fault_user_defined",
61
0x16c9a116 => "rpc_s_fault_tx_open_failed",
62
0x16c9a16e => "rpc_s_fault_codeset_conv_error",
63
0x16c9a170 => "rpc_s_fault_no_client_stub",
64
0x1c000001 => "nca_s_fault_int_div_by_zero",
65
0x1c000002 => "nca_s_fault_addr_error",
66
0x1c000003 => "nca_s_fault_fp_div_zero",
67
0x1c000004 => "nca_s_fault_fp_underflow",
68
0x1c000005 => "nca_s_fault_fp_overflow",
69
0x1c000006 => "nca_s_fault_invalid_tag",
70
0x1c000007 => "nca_s_fault_invalid_bound",
71
0x1c000008 => "nca_rpc_version_mismatch",
72
0x1c000009 => "nca_unspec_reject",
73
0x1c00000a => "nca_s_bad_actid",
74
0x1c00000b => "nca_who_are_you_failed",
75
0x1c00000c => "nca_manager_not_entered",
76
0x1c00000d => "nca_s_fault_cancel",
77
0x1c00000e => "nca_s_fault_ill_inst",
78
0x1c00000f => "nca_s_fault_fp_error",
79
0x1c000010 => "nca_s_fault_int_overflow",
80
0x1c000014 => "nca_s_fault_pipe_empty",
81
0x1c000015 => "nca_s_fault_pipe_closed",
82
0x1c000016 => "nca_s_fault_pipe_order",
83
0x1c000017 => "nca_s_fault_pipe_discipline",
84
0x1c000018 => "nca_s_fault_pipe_comm_error",
85
0x1c000019 => "nca_s_fault_pipe_memory",
86
0x1c00001a => "nca_s_fault_context_mismatch",
87
0x1c00001b => "nca_s_fault_remote_no_memory",
88
0x1c00001c => "nca_invalid_pres_context_id",
89
0x1c00001d => "nca_unsupported_authn_level",
90
0x1c00001f => "nca_invalid_checksum",
91
0x1c000020 => "nca_invalid_crc",
92
0x1c000021 => "ncs_s_fault_user_defined",
93
0x1c000022 => "nca_s_fault_tx_open_failed",
94
0x1c000023 => "nca_s_fault_codeset_conv_error",
95
0x1c000024 => "nca_s_fault_object_not_found",
96
0x1c000025 => "nca_s_fault_no_client_stub",
97
0x1c010002 => "nca_op_rng_error",
98
0x1c010003 => "nca_unk_if",
99
0x1c010006 => "nca_wrong_boot_time",
100
0x1c010009 => "nca_s_you_crashed",
101
0x1c01000b => "nca_proto_error",
102
0x1c010013 => "nca_out_args_too_big",
103
0x1c010014 => "nca_server_too_busy",
104
0x1c010017 => "nca_unsupported_type"
105
}
106
107
def initialize(*args)
108
super(*args)
109
end
110
111
# returns an error string if it exists, otherwise just the error code
112
def get_error(error)
113
string = ''
114
if @@errors[error]
115
string = @@errors[error]
116
else
117
string = sprintf('0x%.8x',error)
118
end
119
end
120
end
121
122
class Fault < Error
123
attr_accessor :fault
124
def to_s
125
'DCERPC FAULT => ' + get_error(self.fault)
126
end
127
end
128
129
class NoResponse < Error
130
def to_s
131
'no response from dcerpc service'
132
end
133
end
134
135
class BindError < Error
136
def initialize(message=nil)
137
@message = message
138
end
139
140
def to_s
141
str = 'Failed to bind.'
142
if @message
143
str += " #{@message}"
144
end
145
end
146
end
147
148
class InvalidSocket < Error
149
def initialize(message=nil)
150
@message = message
151
end
152
153
def to_s
154
str = 'Invalid Socket.'
155
if @message
156
str += " #{@message}"
157
end
158
end
159
end
160
161
class InvalidPacket < Error
162
def initialize(message = nil)
163
@message = message
164
end
165
166
def to_s
167
str = 'Invalid packet.'
168
if (@message)
169
str += " #{@message}"
170
end
171
end
172
end
173
174
end
175
end
176
end
177
end
178
179