summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_eventlog.c
blob: 0b49ed5da79c65ecb0f4ca32a886b253bafc8c3f (plain)
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
/* 
 *  Unix SMB/Netbios implementation.
 *  Version 1.9.
 *  RPC Pipe client / server routines
 *  Copyright (C) Andrew Tridgell              1992-1999,
 *  Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
 *  Copyright (C) Jean François Micouleau      1998-1999.
 *
 *  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"

extern int DEBUGLEVEL;

/*******************************************************************
********************************************************************/  
BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, const char *journal, char *unk)
{
	int len_journal = journal != NULL ? strlen(journal) : 0;
	int len_unk = unk != NULL ? strlen(unk) : 0;

	q_u->ptr0=0x1;
	q_u->unk0=0x5c;
	q_u->unk1=0x01;

	make_uni_hdr(&(q_u->hdr_source), len_journal);
	make_unistr2(&(q_u->uni_source), journal, len_journal);
	
	make_uni_hdr(&(q_u->hdr_unk), len_unk);
	make_unistr2(&(q_u->uni_unk), unk, len_unk);
	
	q_u->unk6=0x01;
	q_u->unk7=0x01;

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_q_open(char *desc, EVENTLOG_Q_OPEN *q_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_q_open");
	depth++;

	prs_align(ps);

	prs_uint32("ptr0", ps, depth, &(q_u->ptr0));

	prs_uint16("unk0", ps, depth, &(q_u->unk0));
	prs_uint16("unk1", ps, depth, &(q_u->unk1));

	smb_io_unihdr("hdr_source", &(q_u->hdr_source), ps, depth);
	smb_io_unistr2("uni_source", &(q_u->uni_source),
		       q_u->hdr_source.buffer, ps, depth);
	prs_align(ps);

	smb_io_unihdr("hdr_unk", &(q_u->hdr_unk), ps, depth);
	smb_io_unistr2("uni_unk", &(q_u->uni_unk),
		       q_u->hdr_unk.buffer, ps, depth);
	prs_align(ps);

	prs_uint32("unk6", ps, depth, &(q_u->unk6));
	prs_uint32("unk7", ps, depth, &(q_u->unk7));

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_r_open(char *desc, EVENTLOG_R_OPEN *r_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_r_open");
	depth++;

	prs_align(ps);
	smb_io_pol_hnd("", &(r_u->pol), ps, depth);
	prs_uint32("status", ps, depth, &(r_u->status));

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL make_eventlog_q_close(EVENTLOG_Q_CLOSE *q_u, POLICY_HND *pol)
{
	memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data));

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_q_close(char *desc, EVENTLOG_Q_CLOSE *q_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_q_close");
	depth++;

	prs_align(ps);
	smb_io_pol_hnd("", &(q_u->pol), ps, depth);

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_r_close(char *desc, EVENTLOG_R_CLOSE *r_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_r_close");
	depth++;

	prs_align(ps);
	smb_io_pol_hnd("", &(r_u->pol), ps, depth);
	prs_uint32("status", ps, depth, &(r_u->status));

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL make_eventlog_q_numofeventlogrec(EVENTLOG_Q_NUMOFEVENTLOGREC *q_u, POLICY_HND *pol)
{
	memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data));


	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_q_numofeventlogrec(char *desc,EVENTLOG_Q_NUMOFEVENTLOGREC  *q_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_q_numofeventlogrec");
	depth++;

	prs_align(ps);
	smb_io_pol_hnd("", &(q_u->pol), ps, depth);


	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_r_numofeventlogrec(char *desc, EVENTLOG_R_NUMOFEVENTLOGREC *r_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_r_numofeventlogrec");
	depth++;

	prs_align(ps);
	prs_uint32("number", ps, depth, &(r_u->number));
	prs_uint32("status", ps, depth, &(r_u->status));

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL make_eventlog_q_readeventlog(EVENTLOG_Q_READEVENTLOG *q_u, POLICY_HND *pol,
                                  uint32 flags, uint32 offset, uint32 number_of_bytes)
{
	memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data));
	q_u->flags=flags;
	q_u->offset=offset;
	q_u->number_of_bytes=number_of_bytes;

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_q_readeventlog(char *desc, EVENTLOG_Q_READEVENTLOG *q_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_q_readeventlog");
	depth++;

	prs_align(ps);
	smb_io_pol_hnd("", &(q_u->pol), ps, depth);
	prs_uint32("flags",           ps, depth, &(q_u->flags));
	prs_uint32("offset",          ps, depth, &(q_u->offset));
	prs_uint32("number_of_bytes", ps, depth, &(q_u->number_of_bytes));

	return True;
}

/*******************************************************************
********************************************************************/  
static BOOL eventlog_io_eventlog(char *desc, EVENTLOGRECORD *ev, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_eventlog");
	depth++;

	prs_align(ps);
	prs_uint32("size", ps, depth, &(ev->size));	
	prs_uint32("reserved", ps, depth, &(ev->reserved));
	prs_uint32("recordnumber", ps, depth, &(ev->recordnumber));
	prs_uint32("creationtime", ps, depth, &(ev->creationtime));
	prs_uint32("writetime", ps, depth, &(ev->writetime));
	prs_uint32("eventnumber", ps, depth, &(ev->eventnumber));
	
	prs_uint16("eventtype", ps, depth, &(ev->eventtype));
	prs_uint16("num_of_strings", ps, depth, &(ev->num_of_strings));
	prs_uint16("category", ps, depth, &(ev->category));
	prs_uint16("reserved_flag", ps, depth, &(ev->reserved_flag));

	prs_uint32("closingrecord", ps, depth, &(ev->closingrecord));
	prs_uint32("stringoffset", ps, depth, &(ev->stringoffset));
	prs_uint32("sid_length", ps, depth, &(ev->sid_length));
	prs_uint32("sid_offset", ps, depth, &(ev->sid_offset));
	prs_uint32("data_length", ps, depth, &(ev->data_length));
	prs_uint32("data_offset", ps, depth, &(ev->data_offset));
	
	smb_io_unistr("", &(ev->sourcename), ps, depth);	
	smb_io_unistr("", &(ev->computername), ps, depth);
	
	if (ev->sid_length!=0)
		smb_io_unistr("", &(ev->sid), ps, depth);
	
	if (ev->num_of_strings!=0)
		smb_io_unistr("", &(ev->strings),ps, depth);
	
	if (ev->data_length)
		smb_io_unistr("", &(ev->data), ps, depth);

	prs_uint32("size2", ps, depth, &(ev->size2));	

	return True;
}

/*******************************************************************
********************************************************************/  
BOOL eventlog_io_r_readeventlog(char *desc, EVENTLOG_R_READEVENTLOG *r_u, prs_struct *ps, int depth)
{
	prs_debug(ps, depth, desc, "eventlog_io_r_readeventlog");
	depth++;

	prs_align(ps);
	prs_uint32("number_of_bytes", ps, depth, &(r_u->number_of_bytes));

	if (r_u->number_of_bytes!= 0)
		eventlog_io_eventlog("", r_u->event, ps, depth);

	prs_uint32("sent_size", ps, depth, &(r_u->sent_size));		
	prs_uint32("real_size", ps, depth, &(r_u->real_size));
	prs_uint32("status", ps, depth, &(r_u->status));	

	return True;
}