Guest User

Untitled

a guest
Dec 8th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. from ldap3 import *
  2. from ldap3.core.exceptions import *
  3. from colorama import *
  4.  
  5. server_name = 'jolas.pt'
  6. domain_name = 'jolas'
  7. user_name = 'jolas.pt\Administrador'
  8. password = ''
  9.  
  10. print(Fore.GREEN+'''
  11.  
  12. ==================================
  13. | |
  14. | |
  15. | Active Directory Finder |
  16. | |
  17. | by: Bruno Teixeira |
  18. | |
  19. | |
  20. ==================================
  21. ''')
  22.  
  23. def connection_to_ad():
  24. server = Server(server_name, get_info = ALL)
  25. conn = Connection(server, user = user_name, password = password, authentication = NTLM, auto_bind = True)
  26. conn.search('dc = {}, dc = pt'.format(domain_name), '(objectclass=person)', attributes = [ALL_ATTRIBUTES,ALL_OPERATIONAL_ATTRIBUTES])
  27. return conn
  28.  
  29.  
  30. def search(conn):
  31. name = input('Name: ')
  32. for people in conn.entries:
  33. if name == people['sAMAccountName']:
  34. created = people['whenCreated']
  35. logoncount = people['logonCount']
  36. pwdLastSet = people['pwdLastSet']
  37. lastlogon = people['lastLogon']
  38. lastlogoff = people['lastLogoff']
  39. accexpires = people['accountExpires']
  40. memberoff = people['memberOf']
  41. print(lastlogon)
  42. print(f'\nName:{name}\n\nAccountCreated:{created}\n\nPasswordLastSet:{pwdLastSet}\n\nLogonCount:{logoncount}\n\nLastLogon:{lastlogon}\n\nLastLogoff:{lastlogoff}\n\nAccountExpires:{accexpires}\n\nMemberOff:{memberoff}')
  43. print(Style.RESET_ALL)
  44. if __name__ == '__main__':
  45. conn = connection_to_ad()
  46. search(conn)
Add Comment
Please, Sign In to add comment