(self, addr)
Dumps the list of users and shares registered present at
        addr. Addr is a valid host name or IP address.
Dumps the list of users and shares registered present at
        addr. Addr is a valid host name or IP address.
Dumps the list of users and shares registered present at addr . Addr is a valid host name or IP address .
def dump(self, addr):
        """Dumps the list of users and shares registered present at
        addr. Addr is a valid host name or IP address.
        """

        encoding = sys.getdefaultencoding()

        print 'Retrieving endpoint list from %s' % addr

        # Try all requested protocols until one works.
        entries = []
        for protocol in self.__protocols:
            protodef = SAMRDump.KNOWN_PROTOCOLS[protocol]
            port = protodef[1]

            print "Trying protocol %s..." % protocol
            rpctransport = transport.SMBTransport(addr, port, r'\samr', self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash)

            try:
                entries = self.__fetchList(rpctransport)
            except Exception, e:
                print 'Protocol failed: %s' % e
                raise
            else:
                # Got a response. No need for further iterations.
                break


        # Display results.

        for entry in entries:
            (username, uid, user) = entry
            base = "%s (%d)" % (username, uid)
            print base + '/Enabled:', ('false', 'true')[user.is_enabled()]
            print base + '/Last Logon:', user.get_logon_time()
            print base + '/Last Logoff:', user.get_logoff_time()
            print base + '/Kickoff:', user.get_kickoff_time()
            print base + '/Last PWD Set:', user.get_pwd_last_set()
            print base + '/PWD Can Change:', user.get_pwd_can_change()
            print base + '/PWD Must Change:', user.get_pwd_must_change()
            print base + '/Group id: %d' % user.get_group_id()
            print base + '/Bad pwd count: %d' % user.get_bad_pwd_count()
            print base + '/Logon count: %d' % user.get_logon_count()
            items = user.get_items()
            for i in samr.MSRPCUserInfo.ITEMS.keys():
                name = items[samr.MSRPCUserInfo.ITEMS[i]].get_name()
                name = name.encode(encoding, 'replace')
                print base + '/' + i + ':', name

        if entries:
            num = len(entries)
            if 1 == num:
                print 'Received one entry.'
            else:
                print 'Received %d entries.' % num
        else:
            print 'No entries received.'
def dump ( self , addr ) : encoding = sys . getdefaultencoding ( ) print 'Retrieving endpoint list from %s' % addr # Try all requested protocols until one works. entries = [ ] for protocol in self . __protocols : protodef = SAMRDump . KNOWN_PROTOCOLS [ protocol ] port = protodef [ 1 ] print "Trying protocol %s..." % protocol rpctransport = transport . SMBTransport ( addr , port , r'\samr' , self . __username , self . __password , self . __domain , self . __lmhash , self . __nthash ) try : entries = self . __fetchList ( rpctransport ) except Exception , e : print 'Protocol failed: %s' % e raise else : # Got a response. No need for further iterations. break # Display results. for entry in entries : ( username , uid , user ) = entry base = "%s (%d)" % ( username , uid ) print base + '/Enabled:' , ( 'false' , 'true' ) [ user . is_enabled ( ) ] print base + '/Last Logon:' , user . get_logon_time ( ) print base + '/Last Logoff:' , user . get_logoff_time ( ) print base + '/Kickoff:' , user . get_kickoff_time ( ) print base + '/Last PWD Set:' , user . get_pwd_last_set ( ) print base + '/PWD Can Change:' , user . get_pwd_can_change ( ) print base + '/PWD Must Change:' , user . get_pwd_must_change ( ) print base + '/Group id: %d' % user . get_group_id ( ) print base + '/Bad pwd count: %d' % user . get_bad_pwd_count ( ) print base + '/Logon count: %d' % user . get_logon_count ( ) items = user . get_items ( ) for i in samr . MSRPCUserInfo . ITEMS . keys ( ) : name = items [ samr . MSRPCUserInfo . ITEMS [ i ] ] . get_name ( ) name = name . encode ( encoding , 'replace' ) print base + '/' + i + ':' , name if entries : num = len ( entries ) if 1 == num : print 'Received one entry.' else : print 'Received %d entries.' % num else : print 'No entries received.'