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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Marcin Krzysztof Porwit 2005.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_PARSE
/********************************************************************
********************************************************************/
BOOL prs_ev_open_unknown0( const char *desc, prs_struct *ps, int depth, EVENTLOG_OPEN_UNKNOWN0 *u )
{
if ( !u )
return False;
if ( !prs_uint16("", ps, depth, &u->unknown1) )
return False;
if ( !prs_uint16("", ps, depth, &u->unknown2) )
return False;
return True;
}
/********************************************************************
********************************************************************/
BOOL eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_open_eventlog");
depth++;
if(!prs_align(ps))
return False;
if ( !prs_pointer("", ps, depth, (void**)&q_u->unknown0, sizeof(EVENTLOG_OPEN_UNKNOWN0), (PRS_POINTER_CAST)prs_ev_open_unknown0))
return False;
if ( !prs_unistr4("logname", ps, depth, &q_u->logname) )
return False;
if ( !prs_align(ps) )
return False;
if ( !prs_unistr4("servername", ps, depth, &q_u->servername) )
return False;
if ( !prs_align(ps) )
return False;
if ( !prs_uint32("unknown1", ps, depth, &q_u->unknown1) )
return False;
if ( !prs_uint32("unknown2", ps, depth, &q_u->unknown2) )
return False;
return True;
}
BOOL eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u,
prs_struct *ps, int depth)
{
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_open_eventlog");
depth++;
if(!prs_align(ps))
return False;
if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth)))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
BOOL eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_get_num_records");
depth++;
if(!(prs_align(ps)))
return False;
if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
return False;
return True;
}
BOOL eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS *r_u,
prs_struct *ps, int depth)
{
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_get_num_records");
depth++;
if(!(prs_align(ps)))
return False;
if(!(prs_uint32("num records", ps, depth, &(r_u->num_records))))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
BOOL eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_get_oldest_entry");
depth++;
if(!(prs_align(ps)))
return False;
if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
return False;
return True;
}
BOOL eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTRY *r_u,
prs_struct *ps, int depth)
{
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_get_oldest_entry");
depth++;
if(!(prs_align(ps)))
return False;
if(!(prs_uint32("oldest entry", ps, depth, &(r_u->oldest_entry))))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
BOOL eventlog_io_q_close_eventlog(const char *desc, EVENTLOG_Q_CLOSE_EVENTLOG *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_close_eventlog");
depth++;
if(!(prs_align(ps)))
return False;
if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
return False;
return True;
}
BOOL eventlog_io_r_close_eventlog(const char *desc, EVENTLOG_R_CLOSE_EVENTLOG *r_u,
prs_struct *ps, int depth)
{
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_close_eventlog");
depth++;
if(!(prs_align(ps)))
return False;
if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth)))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
BOOL eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_read_eventlog");
depth++;
if(!(prs_align(ps)))
return False;
if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
return False;
if(!(prs_uint32("read flags", ps, depth, &(q_u->flags))))
return False;
if(!(prs_uint32("read offset", ps, depth, &(q_u->offset))))
return False;
if(!(prs_uint32("read buf size", ps, depth, &(q_u->max_read_size))))
return False;
return True;
}
/** Structure of response seems to be:
DWORD num_bytes_in_resp -- MUST be the same as q_u->max_read_size
for i=0..n
EVENTLOGRECORD record
DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise
DWORD real_size -- 0 if records returned, otherwise length of next record to be returned
WERROR status */
BOOL eventlog_io_r_read_eventlog(const char *desc,
EVENTLOG_Q_READ_EVENTLOG *q_u,
EVENTLOG_R_READ_EVENTLOG *r_u,
prs_struct *ps,
int depth)
{
Eventlog_entry *entry;
uint32 record_written = 0;
uint32 record_total = 0;
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_read_eventlog");
depth++;
/* First, see if we've read more logs than we can output */
if(r_u->num_bytes_in_resp > q_u->max_read_size) {
entry = r_u->entry;
/* remove the size of the last entry from the list */
while(entry->next != NULL)
entry = entry->next;
r_u->num_bytes_in_resp -= entry->record.length;
/* do not output the last log entry */
r_u->num_records--;
}
entry = r_u->entry;
record_total = r_u->num_records;
if(r_u->num_bytes_in_resp != 0)
r_u->sent_size = r_u->num_bytes_in_resp;
else
r_u->real_size = r_u->bytes_in_next_record;
if(!(prs_align(ps)))
return False;
if(!(prs_uint32("bytes in resp", ps, depth, &(q_u->max_read_size))))
return False;
while(entry != NULL && record_written < record_total)
{
DEBUG(10, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written, record_total));
/* Encode the actual eventlog record record */
if(!(prs_uint32("length", ps, depth, &(entry->record.length))))
return False;
if(!(prs_uint32("reserved", ps, depth, &(entry->record.reserved1))))
return False;
if(!(prs_uint32("record number", ps, depth, &(entry->record.record_number))))
return False;
if(!(prs_uint32("time generated", ps, depth, &(entry->record.time_generated))))
return False;
if(!(prs_uint32("time written", ps, depth, &(entry->record.time_written))))
return False;
if(!(prs_uint32("event id", ps, depth, &(entry->record.event_id))))
return False;
if(!(prs_uint16("event type", ps, depth, &(entry->record.event_type))))
return False;
if(!(prs_uint16("num strings", ps, depth, &(entry->record.num_strings))))
return False;
if(!(prs_uint16("event category", ps, depth, &(entry->record.event_category))))
return False;
if(!(prs_uint16("reserved2", ps, depth, &(entry->record.reserved2))))
return False;
if(!(prs_uint32("closing record", ps, depth, &(entry->record.closing_record_number))))
return False;
if(!(prs_uint32("string offset", ps, depth, &(entry->record.string_offset))))
return False;
if(!(prs_uint32("user sid length", ps, depth, &(entry->record.user_sid_length))))
return False;
if(!(prs_uint32("user sid offset", ps, depth, &(entry->record.user_sid_offset))))
return False;
if(!(prs_uint32("data length", ps, depth, &(entry->record.data_length))))
return False;
if(!(prs_uint32("data offset", ps, depth, &(entry->record.data_offset))))
return False;
if(!(prs_align(ps)))
return False;
/* Now encoding data */
if(!(prs_uint8s(False, "buffer", ps, depth, entry->data,
entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length))))
{
return False;
}
if(!(prs_align(ps)))
return False;
if(!(prs_uint32("length 2", ps, depth, &(entry->record.length))))
return False;
entry = entry->next;
record_written++;
} /* end of encoding EVENTLOGRECORD */
/* Now pad with whitespace until the end of the response buffer */
r_u->end_of_entries_padding =
SMB_CALLOC_ARRAY(uint8,
q_u->max_read_size - r_u->num_bytes_in_resp);
if(!(prs_uint8s(False, "end of entries padding", ps,
depth, r_u->end_of_entries_padding,
(q_u->max_read_size - r_u->num_bytes_in_resp))))
{
return False;
}
free(r_u->end_of_entries_padding);
/* We had better be DWORD aligned here */
if(!(prs_uint32("sent size", ps, depth, &(r_u->sent_size))))
return False;
if(!(prs_uint32("real size", ps, depth, &(r_u->real_size))))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
/** The windows client seems to be doing something funny with the file name
A call like
ClearEventLog(handle, "backup_file")
on the client side will result in the backup file name looking like this on the
server side:
\??\${CWD of client}\backup_file
If an absolute path gets specified, such as
ClearEventLog(handle, "C:\\temp\\backup_file")
then it is still mangled by the client into this:
\??\C:\temp\backup_file
when it is on the wire.
I'm not sure where the \?? is coming from, or why the ${CWD} of the client process
would be added in given that the backup file gets written on the server side. */
BOOL eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q_u,
prs_struct *ps, int depth)
{
if(q_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_q_clear_eventlog");
depth++;
if(!prs_align(ps))
return False;
if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
return False;
if ( !prs_unistr4("backupfile", ps, depth, &q_u->backupfile) )
return False;
return True;
}
BOOL eventlog_io_r_clear_eventlog(const char *desc, EVENTLOG_R_CLEAR_EVENTLOG *r_u,
prs_struct *ps, int depth)
{
if(r_u == NULL)
return False;
prs_debug(ps, depth, desc, "eventlog_io_r_clear_eventlog");
depth++;
if(!prs_align(ps))
return False;
if(!(prs_werror("status code", ps, depth, &(r_u->status))))
return False;
return True;
}
|