badldap 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. badldap/__init__.py +15 -0
  2. badldap/__main__.py +75 -0
  3. badldap/_version.py +8 -0
  4. badldap/bloodhound.py +779 -0
  5. badldap/client.py +1932 -0
  6. badldap/commons/__init__.py +0 -0
  7. badldap/commons/adexplorer.py +833 -0
  8. badldap/commons/authbuilder.py +18 -0
  9. badldap/commons/common.py +7 -0
  10. badldap/commons/exceptions.py +84 -0
  11. badldap/commons/factory.py +182 -0
  12. badldap/commons/ldif.py +127 -0
  13. badldap/commons/plugin.py +18 -0
  14. badldap/commons/target.py +134 -0
  15. badldap/commons/utils.py +124 -0
  16. badldap/connection.py +923 -0
  17. badldap/examples/__init__.py +6 -0
  18. badldap/examples/jsontest.py +130 -0
  19. badldap/examples/msldapbloodhound.py +19 -0
  20. badldap/examples/msldapclient.py +1815 -0
  21. badldap/examples/msldapcompdnslist.py +99 -0
  22. badldap/examples/utils/__init__.py +0 -0
  23. badldap/examples/utils/completers.py +60 -0
  24. badldap/external/__init__.py +0 -0
  25. badldap/external/aiocmd/__init__.py +0 -0
  26. badldap/external/aiocmd/aiocmd/__init__.py +0 -0
  27. badldap/external/aiocmd/aiocmd/aiocmd.py +159 -0
  28. badldap/external/aiocmd/aiocmd/nested_completer.py +97 -0
  29. badldap/external/aiocmd/setup.py +22 -0
  30. badldap/external/asciitree/__init__.py +0 -0
  31. badldap/external/asciitree/asciitree/__init__.py +83 -0
  32. badldap/external/asciitree/asciitree/drawing.py +101 -0
  33. badldap/external/asciitree/asciitree/traversal.py +43 -0
  34. badldap/external/asciitree/asciitree/util.py +4 -0
  35. badldap/external/asciitree/setup.py +24 -0
  36. badldap/external/bloodhoundpy/__init__.py +0 -0
  37. badldap/external/bloodhoundpy/acls.py +608 -0
  38. badldap/external/bloodhoundpy/lib/__init__.py +0 -0
  39. badldap/external/bloodhoundpy/lib/cstruct.py +1894 -0
  40. badldap/external/bloodhoundpy/resolver.py +141 -0
  41. badldap/external/bloodhoundpy/utils.py +55 -0
  42. badldap/ldap_objects/__init__.py +57 -0
  43. badldap/ldap_objects/adca.py +38 -0
  44. badldap/ldap_objects/adcertificatetemplate.py +517 -0
  45. badldap/ldap_objects/adcomp.py +334 -0
  46. badldap/ldap_objects/adcontainer.py +87 -0
  47. badldap/ldap_objects/adenrollmentservice.py +48 -0
  48. badldap/ldap_objects/adgmsa.py +176 -0
  49. badldap/ldap_objects/adgpo.py +108 -0
  50. badldap/ldap_objects/adgroup.py +136 -0
  51. badldap/ldap_objects/adinfo.py +213 -0
  52. badldap/ldap_objects/adou.py +128 -0
  53. badldap/ldap_objects/adschemaentry.py +95 -0
  54. badldap/ldap_objects/adsec.py +76 -0
  55. badldap/ldap_objects/adtrust.py +200 -0
  56. badldap/ldap_objects/aduser.py +375 -0
  57. badldap/ldap_objects/common.py +45 -0
  58. badldap/network/__init__.py +0 -0
  59. badldap/network/packetizer.py +41 -0
  60. badldap/protocol/__init__.py +0 -0
  61. badldap/protocol/constants.py +12 -0
  62. badldap/protocol/ldap_filter/__init__.py +2 -0
  63. badldap/protocol/ldap_filter/filter.py +492 -0
  64. badldap/protocol/ldap_filter/parser.py +1530 -0
  65. badldap/protocol/ldap_filter/soundex.py +20 -0
  66. badldap/protocol/messages.py +407 -0
  67. badldap/protocol/query.py +132 -0
  68. badldap/protocol/typeconversion.py +2015 -0
  69. badldap/protocol/utils.py +16 -0
  70. badldap/relay/__init__.py +0 -0
  71. badldap/relay/server.py +89 -0
  72. badldap/relay/serverconnection.py +148 -0
  73. badldap/wintypes/__init__.py +10 -0
  74. badldap/wintypes/asn1/__init__.py +7 -0
  75. badldap/wintypes/asn1/sdflagsrequest.py +20 -0
  76. badldap/wintypes/dnsp/__init__.py +0 -0
  77. badldap/wintypes/dnsp/structures/__init__.py +3 -0
  78. badldap/wintypes/dnsp/structures/dnsproperty.py +284 -0
  79. badldap/wintypes/dnsp/structures/dnsrecord.py +342 -0
  80. badldap/wintypes/dnsp/structures/misc.py +63 -0
  81. badldap/wintypes/encryptedlaps.py +85 -0
  82. badldap/wintypes/managedpassword.py +60 -0
  83. badldap-0.6.0.dist-info/METADATA +37 -0
  84. badldap-0.6.0.dist-info/RECORD +88 -0
  85. badldap-0.6.0.dist-info/WHEEL +5 -0
  86. badldap-0.6.0.dist-info/entry_points.txt +3 -0
  87. badldap-0.6.0.dist-info/licenses/LICENSE +97 -0
  88. badldap-0.6.0.dist-info/top_level.txt +1 -0
badldap/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Author:
4
+ # Tamas Jos (@skelsec)
5
+ #
6
+
7
+ import logging
8
+
9
+ logger = logging.getLogger(__name__)
10
+ handler = logging.StreamHandler()
11
+ formatter = logging.Formatter(
12
+ '%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
13
+ handler.setFormatter(formatter)
14
+ logger.addHandler(handler)
15
+ logger.setLevel(logging.INFO)
badldap/__main__.py ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Author:
4
+ # Tamas Jos (@skelsec)
5
+ #
6
+
7
+ import logging
8
+ import csv
9
+ from badldap.connection import MSLDAPClientConnection
10
+ from badldap.commons.factory import LDAPConnectionFactory
11
+ from badldap.ldap_objects import MSADUser, MSADMachine
12
+
13
+
14
+ def run():
15
+ import argparse
16
+ parser = argparse.ArgumentParser(description='MS LDAP library')
17
+ parser.add_argument('-v', '--verbose', action='count', default=0, help='Verbosity, can be stacked')
18
+ parser.add_argument('connection', help='Connection string in URL format.')
19
+ parser.add_argument('--tree', help='LDAP tree to perform the searches on')
20
+
21
+ subparsers = parser.add_subparsers(help = 'commands')
22
+ subparsers.required = True
23
+ subparsers.dest = 'command'
24
+
25
+ dump_group = subparsers.add_parser('dump', help='Dump all user objects to TSV file')
26
+ dump_group.add_argument('outfile', help='output file')
27
+
28
+ spn_group = subparsers.add_parser('spn', help='Dump all users with servicePrincipalName attribute set to TSV file')
29
+ spn_group.add_argument('outfile', help='output file')
30
+
31
+ dsa_group = subparsers.add_parser('dsa', help='Grab basic info about the AD')
32
+
33
+ args = parser.parse_args()
34
+
35
+
36
+ ###### VERBOSITY
37
+ if args.verbose == 0:
38
+ logging.basicConfig(level=logging.INFO)
39
+ else:
40
+ logging.basicConfig(level=logging.DEBUG)
41
+
42
+ url_dec = LDAPConnectionFactory.from_url(args.connection)
43
+ creds = url_dec.get_credential()
44
+ target = url_dec.get_target()
45
+ print(str(creds))
46
+ print(str(target))
47
+ connection = MSLDAPClientConnection(creds, target)
48
+
49
+ if args.command == 'dsa':
50
+ print(connection.get_server_info())
51
+
52
+ elif args.command == 'dump':
53
+ connection.connect()
54
+ adinfo = connection.get_ad_info()
55
+ with open(args.outfile, 'w', newline='', encoding = 'utf8') as f:
56
+ writer = csv.writer(f, delimiter = '\t')
57
+ writer.writerow(MSADUser.TSV_ATTRS)
58
+ for user in connection.get_all_user_objects():
59
+ writer.writerow(user.get_row(MSADUser.TSV_ATTRS))
60
+
61
+ with open(args.outfile + '_comp', 'w', newline='', encoding = 'utf8') as f:
62
+ writer = csv.writer(f, delimiter = '\t')
63
+ writer.writerow(MSADMachine.TSV_ATTRS)
64
+ for comp in connection.get_all_machine_objects():
65
+ writer.writerow(comp.get_row(MSADMachine.TSV_ATTRS))
66
+
67
+ elif args.command == 'spn':
68
+ connection.connect()
69
+ adinfo, err = connection.get_ad_info()
70
+ with open(args.outfile, 'w', newline='', encoding = 'utf8') as f:
71
+ for user in connection.get_all_service_user_objects():
72
+ f.write(user.sAMAccountName + '\r\n')
73
+
74
+ if __name__ == '__main__':
75
+ run()
badldap/_version.py ADDED
@@ -0,0 +1,8 @@
1
+
2
+ __version__ = "0.6.0"
3
+ __banner__ = \
4
+ """
5
+ # badldap %s
6
+ # Original Author: Tamas Jos (@skelsec)
7
+ # Current Maintainer: Baptiste Crépin (baptiste@cravaterouge.com)
8
+ """ % __version__