-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
367 lines (340 loc) · 17.4 KB
/
server.go
1
2
3
4
5
6
7
8
9
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
package iiiscertobj
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
idispatch "github.com/oiweiwei/go-msrpc/msrpc/dcom/oaut/idispatch/v0"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
_ = idispatch.GoPackage
)
// IIISCertObj server interface.
type IISCertObjectServer interface {
// IDispatch base class.
idispatch.DispatchServer
// Opnum7NotUsedOnWire operation.
// SetOpnum7NotUsedOnWire
// Opnum8NotUsedOnWire operation.
// SetOpnum8NotUsedOnWire
// Opnum9NotUsedOnWire operation.
// SetOpnum9NotUsedOnWire
// The InstanceName method sets the web server instance to be used by subsequent method
// calls.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [[MS-ERREF].
//
// +----------------------------------+------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +----------------------------------+------------------------------------+
// +----------------------------------+------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +----------------------------------+------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +----------------------------------+------------------------------------+
// | 0x000006cf RPC_S_STRING_TOO_LONG | The string is too long. |
// +----------------------------------+------------------------------------+
//
// The opnum field value for this method is 10.
SetInstanceName(context.Context, *SetInstanceNameRequest) (*SetInstanceNameResponse, error)
// Opnum11NotUsedOnWire operation.
// Opnum11NotUsedOnWire
// The IsInstalledRemote method determines if a certificate is associated with the specified
// InstanceName.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +-------------------------+------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +-------------------------+------------------------------------+
// +-------------------------+------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +-------------------------+------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +-------------------------+------------------------------------+
//
// The opnum field value for this method is 12.
IsInstalledRemote(context.Context, *IsInstalledRemoteRequest) (*IsInstalledRemoteResponse, error)
// Opnum13NotUsedOnWire operation.
// Opnum13NotUsedOnWire
// The IsExportableRemote method determines whether the server certificate associated
// with InstanceName can be exported.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +-------------------------+------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +-------------------------+------------------------------------+
// +-------------------------+------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +-------------------------+------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +-------------------------+------------------------------------+
//
// The opnum field value for this method is 14.
IsExportableRemote(context.Context, *IsExportableRemoteRequest) (*IsExportableRemoteResponse, error)
// Opnum15NotUsedOnWire operation.
// Opnum15NotUsedOnWire
// The GetCertInfoRemote method retrieves properties from a certificate associated with
// the specified InstanceName.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +-------------------------+------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +-------------------------+------------------------------------------------+
// +-------------------------+------------------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +-------------------------+------------------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +-------------------------+------------------------------------------------+
// | 0x00000001 S_FALSE | The call was successful. No data was returned. |
// +-------------------------+------------------------------------------------+
//
// The opnum field value for this method is 16.
GetCertInfoRemote(context.Context, *GetCertInfoRemoteRequest) (*GetCertInfoRemoteResponse, error)
// Opnum17NotUsedOnWire operation.
// Opnum17NotUsedOnWire
// Opnum18NotUsedOnWire operation.
// Opnum18NotUsedOnWire
// Opnum19NotUsedOnWire operation.
// Opnum19NotUsedOnWire
// Opnum20NotUsedOnWire operation.
// Opnum20NotUsedOnWire
// Opnum21NotUsedOnWire operation.
// Opnum21NotUsedOnWire
// The ImportFromBlob method imports a previously exported certificate blob on the target
// machine.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +----------------------------------+----------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +----------------------------------+----------------------------------------+
// +----------------------------------+----------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +----------------------------------+----------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +----------------------------------+----------------------------------------+
// | 0x000006cf RPC_S_STRING_TOO_LONG | The string is too long. |
// +----------------------------------+----------------------------------------+
// | 0x80092005 CRYPT_E_EXISTS | The object or property already exists. |
// +----------------------------------+----------------------------------------+
//
// The opnum field value for this method is 22.
ImportFromBlob(context.Context, *ImportFromBlobRequest) (*ImportFromBlobResponse, error)
// The ImportFromBlobGetHash method imports a previously exported certificate blob on
// the target machine. In addition to data returned by method ImportFromBlob, this method
// returns certificate hash and certificate hash buffer size in client-provided parameters
// pcbCertHashSize and pCertHash. The server MUST allocate memory for the hash buffer
// and assign this memory block to pCertHash. Size of required buffer is assigned to
// pcbCertHashSize. If client will pass pCertHash equal to NULL, hash data will not
// be returned.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +----------------------------------+----------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +----------------------------------+----------------------------------------+
// +----------------------------------+----------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +----------------------------------+----------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +----------------------------------+----------------------------------------+
// | 0x000006cf RPC_S_STRING_TOO_LONG | The string is too long. |
// +----------------------------------+----------------------------------------+
// | 0x80092005 CRYPT_E_EXISTS | The object or property already exists. |
// +----------------------------------+----------------------------------------+
//
// The opnum field value for this method is 23.
ImportFromBlobGetHash(context.Context, *ImportFromBlobGetHashRequest) (*ImportFromBlobGetHashResponse, error)
// Opnum24NotUsedOnWire operation.
// Opnum24NotUsedOnWire
// The ExportToBlob method exports the certificate referenced at InstanceName to a memory
// buffer.
//
// Return Values: A signed 32-bit value that indicates return status. If the method
// returns a negative value, it failed. If the 12-bit facility code (bits 16–27) is
// set to 0x007, the value contains a Win32 error code in the lower 16 bits. Zero or
// positive values indicate success, with the lower 16 bits in positive nonzero values
// containing warnings or flags defined in the method implementation. For more information
// about Win32 error codes and HRESULT values, see [MS-ERREF].
//
// +------------------------------------+-------------------------------------------------------+
// | RETURN | |
// | VALUE/CODE | DESCRIPTION |
// | | |
// +------------------------------------+-------------------------------------------------------+
// +------------------------------------+-------------------------------------------------------+
// | 0x00000000 S_OK | The call was successful. |
// +------------------------------------+-------------------------------------------------------+
// | 0x80070057 E_INVALIDARG | One or more arguments are invalid. |
// +------------------------------------+-------------------------------------------------------+
// | 0x000006cf RPC_S_STRING_TOO_LONG | The string is too long. |
// +------------------------------------+-------------------------------------------------------+
// | 0x800CC801 MD_ERROR_DATA_NOT_FOUND | The specified metadata was not found. |
// +------------------------------------+-------------------------------------------------------+
// | 0x80092004 CRYPT_E_NOT_FOUND | Cannot find object or property. |
// +------------------------------------+-------------------------------------------------------+
// | 0x80090349 SEC_E_CERT_WRONG_USAGE | The certificate is not valid for the requested usage. |
// +------------------------------------+-------------------------------------------------------+
//
// The opnum field value for this method is 25.
ExportToBlob(context.Context, *ExportToBlobRequest) (*ExportToBlobResponse, error)
}
func RegisterIISCertObjectServer(conn dcerpc.Conn, o IISCertObjectServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewIISCertObjectServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(IISCertObjectSyntaxV0_0))...)
}
func NewIISCertObjectServerHandle(o IISCertObjectServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return IISCertObjectServerHandle(ctx, o, opNum, r)
}
}
func IISCertObjectServerHandle(ctx context.Context, o IISCertObjectServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
if opNum < 7 {
// IDispatch base method.
return idispatch.DispatchServerHandle(ctx, o, opNum, r)
}
switch opNum {
case 7: // Opnum7NotUsedOnWire
// Opnum7NotUsedOnWire
return nil, nil
case 8: // Opnum8NotUsedOnWire
// Opnum8NotUsedOnWire
return nil, nil
case 9: // Opnum9NotUsedOnWire
// Opnum9NotUsedOnWire
return nil, nil
case 10: // InstanceName
in := &SetInstanceNameRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.SetInstanceName(ctx, in)
return resp.xxx_ToOp(ctx), err
case 11: // Opnum11NotUsedOnWire
// Opnum11NotUsedOnWire
return nil, nil
case 12: // IsInstalledRemote
in := &IsInstalledRemoteRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.IsInstalledRemote(ctx, in)
return resp.xxx_ToOp(ctx), err
case 13: // Opnum13NotUsedOnWire
// Opnum13NotUsedOnWire
return nil, nil
case 14: // IsExportableRemote
in := &IsExportableRemoteRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.IsExportableRemote(ctx, in)
return resp.xxx_ToOp(ctx), err
case 15: // Opnum15NotUsedOnWire
// Opnum15NotUsedOnWire
return nil, nil
case 16: // GetCertInfoRemote
in := &GetCertInfoRemoteRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetCertInfoRemote(ctx, in)
return resp.xxx_ToOp(ctx), err
case 17: // Opnum17NotUsedOnWire
// Opnum17NotUsedOnWire
return nil, nil
case 18: // Opnum18NotUsedOnWire
// Opnum18NotUsedOnWire
return nil, nil
case 19: // Opnum19NotUsedOnWire
// Opnum19NotUsedOnWire
return nil, nil
case 20: // Opnum20NotUsedOnWire
// Opnum20NotUsedOnWire
return nil, nil
case 21: // Opnum21NotUsedOnWire
// Opnum21NotUsedOnWire
return nil, nil
case 22: // ImportFromBlob
in := &ImportFromBlobRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ImportFromBlob(ctx, in)
return resp.xxx_ToOp(ctx), err
case 23: // ImportFromBlobGetHash
in := &ImportFromBlobGetHashRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ImportFromBlobGetHash(ctx, in)
return resp.xxx_ToOp(ctx), err
case 24: // Opnum24NotUsedOnWire
// Opnum24NotUsedOnWire
return nil, nil
case 25: // ExportToBlob
in := &ExportToBlobRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ExportToBlob(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}