diff options
Diffstat (limited to 'source4/scripting/swig/rpcclient')
-rwxr-xr-x | source4/scripting/swig/rpcclient | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index aad4597053..8f33a6133b 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -7,6 +7,23 @@ from pprint import pprint import dcerpc, samr +def swig2dict(obj): + """Convert a swig object to a dictionary.""" + + result = {} + + for attr in filter(lambda x: type(x) == str, dir(obj)): + + if attr[:2] == '__' and attr[-2:] == '__': + continue + + if attr == 'this' or attr == 'thisown': + continue + + result[attr] = getattr(obj, attr) + + return result + class rpcclient(Cmd): prompt = 'rpcclient$ ' @@ -67,7 +84,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -89,7 +106,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -110,7 +127,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -121,22 +138,23 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrQueryDomInfo2(self, line): - """Return information about a domain designated by its SID. (Windows 2000 and >)""" + """Return information about a domain designated by its SID. + (Windows 2000 and >)""" usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)' parser = OptionParser(usage) options, args = parser.parse_args(string.split(line)) - if (len(args) == 0) or (len(args) > 2): + if len(args) == 0 or len(args) > 2: print 'usage:', usage return pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -147,7 +165,7 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo2() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrEnumDomainGroups(self, line): """Return the list of groups of a domain designated by its SID.""" @@ -163,7 +181,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -171,11 +189,11 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainGroups() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainAliases(self, line): - """Return the list of aliases (local groups) of a domain designated by its SID.""" + """Return the list of aliases (local groups) of a domain designated + by its SID.""" usage = 'SamrEnumDomainAliases DOMAIN_SID' @@ -188,7 +206,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -196,8 +214,7 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainAliases() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainUsers(self, line): """Return the list of users of a domain designated by its SID.""" @@ -213,7 +230,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -224,8 +241,7 @@ class rpcclient(Cmd): else: result = domain_handle.EnumDomainUsers() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) if __name__ == '__main__': |