| 40 | |
| 41 | class GetADUsers: |
| 42 | def __init__(self, username, password, domain, cmdLineOptions): |
| 43 | self.options = cmdLineOptions |
| 44 | self.__username = username |
| 45 | self.__password = password |
| 46 | self.__domain = domain |
| 47 | self.__target = None |
| 48 | self.__lmhash = '' |
| 49 | self.__nthash = '' |
| 50 | self.__aesKey = cmdLineOptions.aesKey |
| 51 | self.__doKerberos = cmdLineOptions.k |
| 52 | #[!] in this script the value of -dc-ip option is self.__kdcIP and the value of -dc-host option is self.__kdcHost |
| 53 | self.__kdcIP = cmdLineOptions.dc_ip |
| 54 | self.__kdcHost = cmdLineOptions.dc_host |
| 55 | self.__requestUser = cmdLineOptions.user |
| 56 | self.__all = cmdLineOptions.all |
| 57 | if cmdLineOptions.hashes is not None: |
| 58 | self.__lmhash, self.__nthash = cmdLineOptions.hashes.split(':') |
| 59 | |
| 60 | # Create the baseDN |
| 61 | domainParts = self.__domain.split('.') |
| 62 | self.baseDN = '' |
| 63 | for i in domainParts: |
| 64 | self.baseDN += 'dc=%s,' % i |
| 65 | # Remove last ',' |
| 66 | self.baseDN = self.baseDN[:-1] |
| 67 | |
| 68 | # Let's calculate the header and format |
| 69 | self.__header = ["Name", "Email", "PasswordLastSet", "LastLogon"] |
| 70 | # Since we won't process all rows at once, this will be fixed lengths |
| 71 | self.__colLen = [20, 30, 19, 19] |
| 72 | self.__outputFormat = ' '.join(['{%d:%ds} ' % (num, width) for num, width in enumerate(self.__colLen)]) |
| 73 | |
| 74 | @staticmethod |
| 75 | def getUnixTime(t): |