1 | /* REXX Function Library for RPC calls */
|
---|
2 |
|
---|
3 | /* Currently implemented functions:
|
---|
4 | _rpcenumdomgroups(server,username,password)
|
---|
5 | _rpcenumdomusers(server,username,password)
|
---|
6 | _rpcenumprinters(server,username,password)
|
---|
7 | _rpcnetshareenum(server,username,password)
|
---|
8 | _rpcnetsharegetinfo(server,username,password,share)
|
---|
9 | _rpcquerygroupmem(server,username,password,grouprid)
|
---|
10 | _rpcqueryuser(server,username,password,userrid)
|
---|
11 | */
|
---|
12 |
|
---|
13 | /*:VRX _rpcenumdomgroups
|
---|
14 | */
|
---|
15 | _rpcenumdomgroups: procedure expose rpc. samba. options.
|
---|
16 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() started"
|
---|
17 | server = arg(1)
|
---|
18 | username = arg(2)
|
---|
19 | password = arg(3)
|
---|
20 |
|
---|
21 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups"'
|
---|
22 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups" >'samba.!msg
|
---|
23 |
|
---|
24 | rpc.enumdomgroups. = ""
|
---|
25 |
|
---|
26 | Failure = 0
|
---|
27 |
|
---|
28 | count = 0
|
---|
29 | do until lines(samba.!msg) = 0
|
---|
30 | rpcline = linein(samba.!msg)
|
---|
31 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
32 |
|
---|
33 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
34 | Failure = 1
|
---|
35 | leave
|
---|
36 | end
|
---|
37 | parse var rpcline 'group:['tuser'] rid:['trid']'
|
---|
38 |
|
---|
39 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
40 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
41 | count = count + 1
|
---|
42 |
|
---|
43 | dyn = 'rpc.enumdomgroups.'count'.GROUP = "'Tuser'"'
|
---|
44 | say " "dyn
|
---|
45 | interpret dyn
|
---|
46 |
|
---|
47 | dyn = 'rpc.enumdomgroups.'count'.RID = "'Trid'"'
|
---|
48 | say " "dyn
|
---|
49 | interpret dyn
|
---|
50 |
|
---|
51 | end
|
---|
52 | ok = stream(samba.!msg,'c','close')
|
---|
53 | ok = SysFileDelete(samba.!msg)
|
---|
54 | rpc.enumdomgroups.0 = count
|
---|
55 |
|
---|
56 | if Failure = 0 then do
|
---|
57 | retval = 1
|
---|
58 | rpc.enumdomgroups.LOGONSTATUS="OK"
|
---|
59 | end
|
---|
60 | else do
|
---|
61 | retval = 0
|
---|
62 | rpc.enumdomgroups.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
63 | end
|
---|
64 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() done, "retval" "rpc.enumdomgroups.LOGONSTATUS
|
---|
65 | return retval
|
---|
66 | /*:VRX _rpcenumdomusers
|
---|
67 | */
|
---|
68 | _rpcenumdomusers: procedure expose rpc. samba. options.
|
---|
69 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() started"
|
---|
70 | server = arg(1)
|
---|
71 | username = arg(2)
|
---|
72 | password = arg(3)
|
---|
73 |
|
---|
74 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers"'
|
---|
75 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers" >'samba.!msg
|
---|
76 |
|
---|
77 | rpc.enumdomusers. = ""
|
---|
78 |
|
---|
79 | Failure = 0
|
---|
80 |
|
---|
81 | count = 0
|
---|
82 | do until lines(samba.!msg) = 0
|
---|
83 | rpcline = linein(samba.!msg)
|
---|
84 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
85 |
|
---|
86 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
87 | Failure = 1
|
---|
88 | leave
|
---|
89 | end
|
---|
90 | parse var rpcline 'user:['tuser'] rid:['trid']'
|
---|
91 |
|
---|
92 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
93 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
94 | count = count + 1
|
---|
95 |
|
---|
96 | dyn = 'rpc.enumdomusers.'count'.USER = "'Tuser'"'
|
---|
97 | say " "dyn
|
---|
98 | interpret dyn
|
---|
99 |
|
---|
100 | dyn = 'rpc.enumdomusers.'count'.RID = "'Trid'"'
|
---|
101 | say " "dyn
|
---|
102 | interpret dyn
|
---|
103 |
|
---|
104 | end
|
---|
105 | ok = stream(samba.!msg,'c','close')
|
---|
106 | ok = SysFileDelete(samba.!msg)
|
---|
107 | rpc.enumdomusers.0 = count
|
---|
108 |
|
---|
109 | if Failure = 0 then do
|
---|
110 | retval = 1
|
---|
111 | rpc.enumdomusers.LOGONSTATUS="OK"
|
---|
112 | end
|
---|
113 | else do
|
---|
114 | retval = 0
|
---|
115 | rpc.enumdomusers.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
116 | end
|
---|
117 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() done, "retval" "rpc.enumdomusers.LOGONSTATUS
|
---|
118 | return retval
|
---|
119 |
|
---|
120 | /*:VRX _rpcenumprinters
|
---|
121 | */
|
---|
122 | _rpcenumprinters: procedure expose rpc. samba. options.
|
---|
123 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() started"
|
---|
124 | server = arg(1)
|
---|
125 | username = arg(2)
|
---|
126 | password = arg(3)
|
---|
127 |
|
---|
128 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumprinters"'
|
---|
129 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumprinters" >'samba.!msg
|
---|
130 |
|
---|
131 | rpc.enumprinters. = ""
|
---|
132 |
|
---|
133 | Failure = 0
|
---|
134 |
|
---|
135 | count = 0
|
---|
136 | do until lines(samba.!msg) = 0
|
---|
137 | rpcline = linein(samba.!msg)
|
---|
138 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
139 |
|
---|
140 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
141 | Failure = 1
|
---|
142 | leave
|
---|
143 | end
|
---|
144 | parse var rpcline token ':[' tvalue']' .
|
---|
145 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
146 | if Token = "FLAGS" then count = count + 1
|
---|
147 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
148 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
149 | dyn = 'rpc.enumprinters.'count'.'Token' = "'Tvalue'"'
|
---|
150 | say " "dyn
|
---|
151 | interpret dyn
|
---|
152 | end
|
---|
153 | end
|
---|
154 | ok = stream(samba.!msg,'c','close')
|
---|
155 | ok = SysFileDelete(samba.!msg)
|
---|
156 | rpc.enumprinters.0 = count
|
---|
157 |
|
---|
158 | if Failure = 0 then do
|
---|
159 | retval = 1
|
---|
160 | rpc.enumprinters.LOGONSTATUS="OK"
|
---|
161 | end
|
---|
162 | else do
|
---|
163 | retval = 0
|
---|
164 | rpc.enumprinters.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
165 | end
|
---|
166 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() done, "retval" "rpc.enumprinters.LOGONSTATUS
|
---|
167 | return retval
|
---|
168 | /*:VRX _rpcnetshareenum
|
---|
169 | */
|
---|
170 | _rpcnetshareenum: procedure expose rpc. samba. options.
|
---|
171 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() started"
|
---|
172 | server = arg(1)
|
---|
173 | username = arg(2)
|
---|
174 | password = arg(3)
|
---|
175 |
|
---|
176 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum"'
|
---|
177 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum" >'samba.!msg
|
---|
178 |
|
---|
179 | rpc.netshareenum. = ""
|
---|
180 |
|
---|
181 | Failure = 0
|
---|
182 |
|
---|
183 | count = 0
|
---|
184 | do until lines(samba.!msg) = 0
|
---|
185 | rpcline = linein(samba.!msg)
|
---|
186 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
187 |
|
---|
188 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
189 | Failure = 1
|
---|
190 | leave
|
---|
191 | end
|
---|
192 | parse var rpcline token ':' tvalue
|
---|
193 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
194 | if Token = "NETNAME" then count = count + 1
|
---|
195 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
196 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
197 | dyn = 'rpc.netshareenum.'count'.'Token' = "'Tvalue'"'
|
---|
198 | say " "dyn
|
---|
199 | interpret dyn
|
---|
200 | end
|
---|
201 | end
|
---|
202 | ok = stream(samba.!msg,'c','close')
|
---|
203 | ok = SysFileDelete(samba.!msg)
|
---|
204 | rpc.netshareenum.0 = count
|
---|
205 |
|
---|
206 | if Failure = 0 then do
|
---|
207 | retval = 1
|
---|
208 | rpc.netshareenum.LOGONSTATUS="OK"
|
---|
209 | end
|
---|
210 | else do
|
---|
211 | retval = 0
|
---|
212 | rpc.netshareenum.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
213 | end
|
---|
214 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() done, "retval" "rpc.netshareenum.LOGONSTATUS
|
---|
215 | return retval
|
---|
216 |
|
---|
217 | /*:VRX _rpcnetsharegetinfo
|
---|
218 | */
|
---|
219 | _rpcnetsharegetinfo: procedure expose rpc. samba. options.
|
---|
220 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() started"
|
---|
221 | server = arg(1)
|
---|
222 | username = arg(2)
|
---|
223 | password = arg(3)
|
---|
224 | share = arg(4)
|
---|
225 |
|
---|
226 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'"'
|
---|
227 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'" >'samba.!msg
|
---|
228 |
|
---|
229 | rpc.netsharegetinfo. = ""
|
---|
230 |
|
---|
231 | Failure = 0
|
---|
232 |
|
---|
233 | do until lines(samba.!msg) = 0
|
---|
234 | rpcline = linein(samba.!msg)
|
---|
235 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
236 |
|
---|
237 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
238 | Failure = 1
|
---|
239 | leave
|
---|
240 | end
|
---|
241 | parse var rpcline token ':' tvalue
|
---|
242 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
243 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
244 | if pos('ACL',Token) = 0 & pos('ACE',Token) = 0 & pos('---',Token) = 0 & Token <> "" then do
|
---|
245 |
|
---|
246 | if Token = "TYPE" & left(Tvalue,2) = "0x" & length(Tvalue) = 3 then Token = "SHARETYPE"
|
---|
247 | if Token = "TYPE" & pos("SEC",Tvalue) > 1 then Token = "SECTYPE"
|
---|
248 |
|
---|
249 | dyn = 'rpc.netsharegetinfo.'Token' = "'Tvalue'"'
|
---|
250 | say " "dyn
|
---|
251 | interpret dyn
|
---|
252 | end
|
---|
253 | end
|
---|
254 | ok = stream(samba.!msg,'c','close')
|
---|
255 | ok = SysFileDelete(samba.!msg)
|
---|
256 |
|
---|
257 | if Failure = 0 then do
|
---|
258 | retval = '1'
|
---|
259 | rpc.netsharegetinfo.LOGONSTATUS="OK"
|
---|
260 | end
|
---|
261 | else do
|
---|
262 | retval = '0 '
|
---|
263 | rpc.netsharegetinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
264 | end
|
---|
265 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() done, "retval" "rpc.netsharegetinfo.LOGONSTATUS
|
---|
266 | return retval
|
---|
267 |
|
---|
268 | /*:VRX _rpcquerygroupmem
|
---|
269 | */
|
---|
270 | _rpcquerygroupmem: procedure expose rpc. samba. options.
|
---|
271 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() started"
|
---|
272 | server = arg(1)
|
---|
273 | username = arg(2)
|
---|
274 | password = arg(3)
|
---|
275 | grouprid = arg(4)
|
---|
276 |
|
---|
277 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'"'
|
---|
278 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'" >'samba.!msg
|
---|
279 |
|
---|
280 | rpc.querygroupmem. = ""
|
---|
281 |
|
---|
282 | Failure = 0
|
---|
283 |
|
---|
284 | count = 0
|
---|
285 | do until lines(samba.!msg) = 0
|
---|
286 | rpcline = linein(samba.!msg)
|
---|
287 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
288 |
|
---|
289 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
290 | Failure = 1
|
---|
291 | leave
|
---|
292 | end
|
---|
293 | parse var rpcline 'rid:['trid'] attr:['tattr']'
|
---|
294 |
|
---|
295 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
296 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
297 | count = count + 1
|
---|
298 |
|
---|
299 | dyn = 'rpc.querygroupmem.'count'.RID = "'Trid'"'
|
---|
300 | say " "dyn
|
---|
301 | interpret dyn
|
---|
302 |
|
---|
303 | dyn = 'rpc.querygroupmem.'count'.ATTR = "'Tattr'"'
|
---|
304 | say " "dyn
|
---|
305 | interpret dyn
|
---|
306 |
|
---|
307 | end
|
---|
308 | ok = stream(samba.!msg,'c','close')
|
---|
309 | ok = SysFileDelete(samba.!msg)
|
---|
310 | rpc.querygroupmem.0 = count
|
---|
311 |
|
---|
312 | if Failure = 0 then do
|
---|
313 | retval = 1
|
---|
314 | rpc.querygroupmem.LOGONSTATUS="OK"
|
---|
315 | end
|
---|
316 | else do
|
---|
317 | retval = 0
|
---|
318 | rpc.querygroupmem.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
319 | end
|
---|
320 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() done, "retval" "rpc.querygroupmem.LOGONSTATUS
|
---|
321 | return retval
|
---|
322 | /*:VRX _rpcqueryuser
|
---|
323 | */
|
---|
324 | _rpcqueryuser: procedure expose rpc. samba. options.
|
---|
325 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() started"
|
---|
326 | server = arg(1)
|
---|
327 | username = arg(2)
|
---|
328 | password = arg(3)
|
---|
329 | userrid = arg(4)
|
---|
330 |
|
---|
331 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'"'
|
---|
332 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'" >'samba.!msg
|
---|
333 |
|
---|
334 | rpc.queryuser. = ""
|
---|
335 |
|
---|
336 | Failure = 0
|
---|
337 |
|
---|
338 | do until lines(samba.!msg) = 0
|
---|
339 | rpcline = linein(samba.!msg)
|
---|
340 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
341 |
|
---|
342 | if pos("NT_STATUS", rpcline) > 0 then do
|
---|
343 | Failure = 1
|
---|
344 | leave
|
---|
345 | end
|
---|
346 | if pos("TDB(", translate(rpcline)) > 0 then do
|
---|
347 | Failure = 1
|
---|
348 | /* provide a fake NT_STATUS */
|
---|
349 | rpcline = 'NT_STATUS_TDBERROR 'rpcline
|
---|
350 | leave
|
---|
351 | end
|
---|
352 |
|
---|
353 | parse var rpcline token ':' tvalue
|
---|
354 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
355 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
356 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
357 | dyn = 'rpc.queryuser.'Token' = "'Tvalue'"'
|
---|
358 | say " "dyn
|
---|
359 | interpret dyn
|
---|
360 | end
|
---|
361 | end
|
---|
362 | ok = stream(samba.!msg,'c','close')
|
---|
363 | ok = SysFileDelete(samba.!msg)
|
---|
364 |
|
---|
365 | if Failure = 0 then do
|
---|
366 | retval = 1
|
---|
367 | rpc.queryuser.LOGONSTATUS="OK"
|
---|
368 | end
|
---|
369 | else do
|
---|
370 | retval = '0 '
|
---|
371 | rpc.queryuser.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
372 | end
|
---|
373 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() done, "retval" "rpc.queryuser.LOGONSTATUS
|
---|
374 | return retval
|
---|
375 | /*:VRX _rpcsrvinfo
|
---|
376 | */
|
---|
377 | _rpcsrvinfo:
|
---|
378 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() started"
|
---|
379 | server = arg(1)
|
---|
380 | username = arg(2)
|
---|
381 | password = arg(3)
|
---|
382 |
|
---|
383 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="srvinfo"'
|
---|
384 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="srvinfo" >'samba.!msg
|
---|
385 |
|
---|
386 | rpc.srvinfo. = ""
|
---|
387 |
|
---|
388 | Failure = 0
|
---|
389 |
|
---|
390 | do until lines(samba.!msg) = 0
|
---|
391 | rpcline = linein(samba.!msg)
|
---|
392 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
393 |
|
---|
394 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
395 | Failure = 1
|
---|
396 | leave
|
---|
397 | end
|
---|
398 | if pos(':',rpcline) <> 0 then do
|
---|
399 | parse var rpcline token ':' tvalue
|
---|
400 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
401 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
402 | dyn = 'rpc.srvinfo.'Token' = "'Tvalue'"'
|
---|
403 | say " "dyn
|
---|
404 | interpret dyn
|
---|
405 | end
|
---|
406 | else do
|
---|
407 | parse var rpcline '09'x rpc.srvinfo.NETBIOSNAME' 'rpc.srvinfo.SERVERSTRING
|
---|
408 | rpc.srvinfo.SERVERSTRING = strip(rpc.srvinfo.SERVERSTRING)
|
---|
409 | say ' rpc.srvinfo.NETBIOSNAME = "'rpc.srvinfo.NETBIOSNAME'"'
|
---|
410 | rpc.srvinfo.CAPABILITIES = ""
|
---|
411 | do I = 1 to words(rpc.srvinfo.SERVERSTRING)
|
---|
412 | if length(word(rpc.srvinfo.SERVERSTRING,I)) >=4 then leave
|
---|
413 | if length(word(rpc.srvinfo.SERVERSTRING,I)) = 2 | length(word(rpc.srvinfo.SERVERSTRING,I)) = 3 then do
|
---|
414 | rpc.srvinfo.CAPABILITIES = rpc.srvinfo.CAPABILITIES||word(rpc.srvinfo.SERVERSTRING,I)||' '
|
---|
415 | end
|
---|
416 | end
|
---|
417 | rpc.srvinfo.SERVERSTRING = strip(substr(rpc.srvinfo.SERVERSTRING,length(rpc.srvinfo.CAPABILITIES),))
|
---|
418 | rpc.srvinfo.CAPABILITIES = strip(rpc.srvinfo.CAPABILITIES)
|
---|
419 | say ' rpc.srvinfo.CAPABILITIES = "'rpc.srvinfo.CAPABILITIES'"'
|
---|
420 | say ' rpc.srvinfo.SERVERSTRING = "'rpc.srvinfo.SERVERSTRING'"'
|
---|
421 | end
|
---|
422 | end
|
---|
423 | ok = stream(samba.!msg,'c','close')
|
---|
424 | ok = SysFileDelete(samba.!msg)
|
---|
425 |
|
---|
426 | if Failure = 0 then do
|
---|
427 | retval = 1
|
---|
428 | rpc.srvinfo.LOGONSTATUS="OK"
|
---|
429 | end
|
---|
430 | else do
|
---|
431 | retval = 0
|
---|
432 | rpc.srvinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
433 | end
|
---|
434 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() done, "retval
|
---|
435 | return retval
|
---|