kerbad 0.5.0__tar.gz
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.
- kerbad-0.5.0/LICENSE +86 -0
- kerbad-0.5.0/MANIFEST.in +2 -0
- kerbad-0.5.0/PKG-INFO +30 -0
- kerbad-0.5.0/README.md +67 -0
- kerbad-0.5.0/kerbad/__init__.py +22 -0
- kerbad-0.5.0/kerbad/_version.py +8 -0
- kerbad-0.5.0/kerbad/aioclient.py +981 -0
- kerbad-0.5.0/kerbad/client.py +855 -0
- kerbad-0.5.0/kerbad/common/__init__.py +0 -0
- kerbad-0.5.0/kerbad/common/ccache.py +847 -0
- kerbad-0.5.0/kerbad/common/constants.py +23 -0
- kerbad-0.5.0/kerbad/common/creds.py +568 -0
- kerbad-0.5.0/kerbad/common/factory.py +258 -0
- kerbad-0.5.0/kerbad/common/keytab.py +262 -0
- kerbad-0.5.0/kerbad/common/kirbi.py +127 -0
- kerbad-0.5.0/kerbad/common/spn.py +81 -0
- kerbad-0.5.0/kerbad/common/target.py +27 -0
- kerbad-0.5.0/kerbad/common/utils.py +68 -0
- kerbad-0.5.0/kerbad/common/windows/__init__.py +0 -0
- kerbad-0.5.0/kerbad/common/windows/crypt32.py +418 -0
- kerbad-0.5.0/kerbad/common/windows/defines.py +740 -0
- kerbad-0.5.0/kerbad/examples/CVE_2022_33647.py +316 -0
- kerbad-0.5.0/kerbad/examples/CVE_2022_33679.py +234 -0
- kerbad-0.5.0/kerbad/examples/__init__.py +0 -0
- kerbad-0.5.0/kerbad/examples/__main__.py +38 -0
- kerbad-0.5.0/kerbad/examples/asreproast.py +101 -0
- kerbad-0.5.0/kerbad/examples/ccache2kirbi.py +28 -0
- kerbad-0.5.0/kerbad/examples/ccache_editor.py +74 -0
- kerbad-0.5.0/kerbad/examples/ccacheroast.py +20 -0
- kerbad-0.5.0/kerbad/examples/changepassword.py +63 -0
- kerbad-0.5.0/kerbad/examples/crosstest.py +50 -0
- kerbad-0.5.0/kerbad/examples/getNT.py +35 -0
- kerbad-0.5.0/kerbad/examples/getS4U2proxy.py +71 -0
- kerbad-0.5.0/kerbad/examples/getS4U2self.py +85 -0
- kerbad-0.5.0/kerbad/examples/getTGS.py +56 -0
- kerbad-0.5.0/kerbad/examples/getTGT.py +46 -0
- kerbad-0.5.0/kerbad/examples/kerb23hashdecrypt.py +171 -0
- kerbad-0.5.0/kerbad/examples/kirbi2ccache.py +39 -0
- kerbad-0.5.0/kerbad/examples/spnroast.py +109 -0
- kerbad-0.5.0/kerbad/gssapi/__init__.py +0 -0
- kerbad-0.5.0/kerbad/gssapi/channelbindings.py +81 -0
- kerbad-0.5.0/kerbad/gssapi/gssapi.py +413 -0
- kerbad-0.5.0/kerbad/network/__init__.py +0 -0
- kerbad-0.5.0/kerbad/network/aioclientsocket.py +118 -0
- kerbad-0.5.0/kerbad/network/clientsocket.py +88 -0
- kerbad-0.5.0/kerbad/pkinit.py +509 -0
- kerbad-0.5.0/kerbad/protocol/__init__.py +0 -0
- kerbad-0.5.0/kerbad/protocol/asn1_structs.py +908 -0
- kerbad-0.5.0/kerbad/protocol/constants.py +181 -0
- kerbad-0.5.0/kerbad/protocol/dirtydh.py +44 -0
- kerbad-0.5.0/kerbad/protocol/encryption.py +770 -0
- kerbad-0.5.0/kerbad/protocol/errors.py +153 -0
- kerbad-0.5.0/kerbad/protocol/external/__init__.py +0 -0
- kerbad-0.5.0/kerbad/protocol/external/dtypes.py +546 -0
- kerbad-0.5.0/kerbad/protocol/external/enum.py +762 -0
- kerbad-0.5.0/kerbad/protocol/external/ndr.py +1685 -0
- kerbad-0.5.0/kerbad/protocol/external/nrpc.py +80 -0
- kerbad-0.5.0/kerbad/protocol/external/pac.py +240 -0
- kerbad-0.5.0/kerbad/protocol/external/rpcrt.py +39 -0
- kerbad-0.5.0/kerbad/protocol/external/structure.py +661 -0
- kerbad-0.5.0/kerbad/protocol/external/ticketutil.py +48 -0
- kerbad-0.5.0/kerbad/protocol/mskile.py +95 -0
- kerbad-0.5.0/kerbad/protocol/rfc3244.py +107 -0
- kerbad-0.5.0/kerbad/protocol/rfc4556.py +136 -0
- kerbad-0.5.0/kerbad/protocol/rfc_iakerb.py +29 -0
- kerbad-0.5.0/kerbad/protocol/structures.py +79 -0
- kerbad-0.5.0/kerbad/protocol/ticketutils.py +86 -0
- kerbad-0.5.0/kerbad/security.py +103 -0
- kerbad-0.5.0/kerbad.egg-info/PKG-INFO +30 -0
- kerbad-0.5.0/kerbad.egg-info/SOURCES.txt +87 -0
- kerbad-0.5.0/kerbad.egg-info/dependency_links.txt +1 -0
- kerbad-0.5.0/kerbad.egg-info/entry_points.txt +16 -0
- kerbad-0.5.0/kerbad.egg-info/requires.txt +6 -0
- kerbad-0.5.0/kerbad.egg-info/top_level.txt +1 -0
- kerbad-0.5.0/kerbad.egg-info/zip-safe +1 -0
- kerbad-0.5.0/pyproject.toml +3 -0
- kerbad-0.5.0/setup.cfg +4 -0
- kerbad-0.5.0/setup.py +78 -0
- kerbad-0.5.0/tests/test_ccache.py +221 -0
- kerbad-0.5.0/tests/test_conn.py +355 -0
- kerbad-0.5.0/tests/test_conn_blocking.py +322 -0
- kerbad-0.5.0/tests/test_credential.py +249 -0
- kerbad-0.5.0/tests/test_encryption.py +183 -0
- kerbad-0.5.0/tests/test_examples.py +225 -0
- kerbad-0.5.0/tests/test_keytab.py +56 -0
- kerbad-0.5.0/tests/test_kirbi.py +44 -0
- kerbad-0.5.0/tests/test_security.py +65 -0
- kerbad-0.5.0/tests/test_url.py +154 -0
- kerbad-0.5.0/tests/test_version.py +7 -0
kerbad-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Tamas Jos (@skelsec)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
PAC parsing code in /protocol/external/* is taken from Impacket. License as follows:
|
|
28
|
+
---------
|
|
29
|
+
|
|
30
|
+
We provide this software under a slightly modified version of the
|
|
31
|
+
Apache Software License. The only changes to the document were the
|
|
32
|
+
replacement of "Apache" with "Impacket" and "Apache Software Foundation"
|
|
33
|
+
with "Fortra". Feel free to compare the resulting
|
|
34
|
+
document to the official Apache license.
|
|
35
|
+
|
|
36
|
+
The `Apache Software License' is an Open Source Initiative Approved
|
|
37
|
+
License.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
The Apache Software License, Version 1.1
|
|
41
|
+
Modifications by Fortra (see above)
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2000 The Apache Software Foundation. All rights
|
|
44
|
+
reserved.
|
|
45
|
+
|
|
46
|
+
Redistribution and use in source and binary forms, with or without
|
|
47
|
+
modification, are permitted provided that the following conditions
|
|
48
|
+
are met:
|
|
49
|
+
|
|
50
|
+
1. Redistributions of source code must retain the above copyright
|
|
51
|
+
notice, this list of conditions and the following disclaimer.
|
|
52
|
+
|
|
53
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
54
|
+
notice, this list of conditions and the following disclaimer in
|
|
55
|
+
the documentation and/or other materials provided with the
|
|
56
|
+
distribution.
|
|
57
|
+
|
|
58
|
+
3. The end-user documentation included with the redistribution,
|
|
59
|
+
if any, must include the following acknowledgment:
|
|
60
|
+
"This product includes software developed by
|
|
61
|
+
SecureAuth Corporation (https://www.secureauth.com/) and Fortra (https://www.fortra.com)."
|
|
62
|
+
Alternately, this acknowledgment may appear in the software itself,
|
|
63
|
+
if and wherever such third-party acknowledgments normally appear.
|
|
64
|
+
|
|
65
|
+
4. The names "Impacket", "SecureAuth Corporation", and "Fortra" must
|
|
66
|
+
not be used to endorse or promote products derived from this
|
|
67
|
+
software without prior written permission. For written
|
|
68
|
+
permission, please reach out to https://www.coresecurity.com/about/contact.
|
|
69
|
+
|
|
70
|
+
5. Products derived from this software may not be called "Impacket",
|
|
71
|
+
nor may "Impacket" appear in their name, without prior written
|
|
72
|
+
permission of Fortra.
|
|
73
|
+
|
|
74
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
75
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
76
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
77
|
+
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
78
|
+
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
79
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
80
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
81
|
+
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
82
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
83
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
84
|
+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
85
|
+
SUCH DAMAGE.
|
|
86
|
+
|
kerbad-0.5.0/MANIFEST.in
ADDED
kerbad-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kerbad
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Kerberos manipulation library in pure Python
|
|
5
|
+
Home-page: https://github.com/CravateRouge/kerbad
|
|
6
|
+
Author: Tamas Jos
|
|
7
|
+
Author-email: info@skelsec.com
|
|
8
|
+
Maintainer: Baptiste Crépin
|
|
9
|
+
Maintainer-email: baptiste@cravaterouge.com
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: asn1crypto>=1.5.1
|
|
16
|
+
Requires-Dist: cryptography>=44.0.2
|
|
17
|
+
Requires-Dist: asysocks>=0.2.8
|
|
18
|
+
Requires-Dist: unicrypto>=0.0.10
|
|
19
|
+
Requires-Dist: tqdm
|
|
20
|
+
Requires-Dist: six
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: maintainer
|
|
27
|
+
Dynamic: maintainer-email
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
Dynamic: summary
|
kerbad-0.5.0/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# kerbad
|
|
2
|
+
`kerbad` is fork of `minikerberos` a kerberos client library written in `Python>=3.6`. It is the kerberos library used for `bloodyAD`. It also comes with multiple useful examples for pentesters who wish to perform security audits on the kerberos protocol.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Install it via either cloning it from GitHub and using
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
$ git clone https://github.com/CravateRouge/kerbad.git
|
|
10
|
+
$ cd kerbad
|
|
11
|
+
$ python3 setup.py install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
or with `pip` from the Python Package Index (PyPI).
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
$ pip install kerbad --user
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Consider to use a Python virtual environment.
|
|
21
|
+
|
|
22
|
+
## Information for developers
|
|
23
|
+
`kerbad` library contains both asynchronous and blocking versions of the kerberos client with the same API. Besides the usual password/aes/rc4 LTK authentication methods it also supports PKINIT using `pfx` or `pem` formatted certificates as well as certificates stored in windows certificate store.
|
|
24
|
+
|
|
25
|
+
## Information for pentesters
|
|
26
|
+
`kerbad` comes with examples which can be used to perform the usual pentest activities out-of-the-box without additional coding required.
|
|
27
|
+
|
|
28
|
+
# Examples AKA the pentest tools
|
|
29
|
+
Installing `kerbad` module via pip will automatically place all examples in the `Scripts` directory by the `setuptools` build environment. All tools named in the following way `bad<toolname>`
|
|
30
|
+
|
|
31
|
+
## kerbad-getTGT
|
|
32
|
+
Fetches a TGT for the given kerberos credential. The kredential must be in a standard `kerberos URL` format.
|
|
33
|
+
|
|
34
|
+
## kerbad-getTGS
|
|
35
|
+
Fetches an TGS ticket (TGSREP) for the given cerberos credential and SPN record.
|
|
36
|
+
SPN must be in `service/hostname@FQDN` format.
|
|
37
|
+
|
|
38
|
+
## kerbad-kerberoast
|
|
39
|
+
Also known as SPNRoast, this tool performs a kerberoast attack against one or multiple users, using the provided kerberos credential.
|
|
40
|
+
|
|
41
|
+
## kerbad-getNTPKInit
|
|
42
|
+
This tool recovers the NT hash for the user specified by the kerberos credential. This only works if PKINIT (cert based auth) is used.
|
|
43
|
+
|
|
44
|
+
## kerbad-kerb23hashdecrypt
|
|
45
|
+
This tool attempts to recover the user's NT hash for a list of kerberoast hashes.
|
|
46
|
+
When you performed a kerberoast attack against one or multiple users, and have a huge list of NT hashes (no password needed) this tool will check each NT hash if it can decrypt the ticket in the kerberoasted hashes.
|
|
47
|
+
Full disclosure, those are not hashes and it hurt me writing the previous sentence.
|
|
48
|
+
|
|
49
|
+
## kerbad-getS4U2self
|
|
50
|
+
This tool is used when you have credentials to a machine account and would like to impersonate other users on the same machine. Machine account credential should be supplied in the `kerberos URL` format, while the user to be impersonated should be in the usual UserPrincialName format eg `username@FQDN`
|
|
51
|
+
|
|
52
|
+
## kerbad-getS4U2proxy
|
|
53
|
+
This tool is used when you have a machine account which has the permission to perform Kerberos Resource-based Constrained Delegation (RBCD). With this, you can impersonate users. For this to work, the machine account must be allowed to delegate on all protocols, not kerberos-only!
|
|
54
|
+
|
|
55
|
+
## kerbad-ccacheroast
|
|
56
|
+
Performs "Kerberoast" attack on a CCACHE file. You get back the "hashes" for all TGS tickets stored in the CCACHE file.
|
|
57
|
+
|
|
58
|
+
## kerbad-ccache2kirbi
|
|
59
|
+
Converts a CCACHE file to a list of `.kirbi` files.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## kerbad-kirbi2ccache
|
|
63
|
+
Converts one or more `.kirbi` files into one CCACHE file
|
|
64
|
+
|
|
65
|
+
## kerbad-ccacheedit
|
|
66
|
+
Command-line CCACHE file editor. It can list/delete credentials in a CCACHE file.
|
|
67
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
logger = logging.getLogger(__name__)
|
|
4
|
+
logger.setLevel(logging.INFO)
|
|
5
|
+
|
|
6
|
+
def getLogger():
|
|
7
|
+
logger.propagate = False
|
|
8
|
+
handler = logging.StreamHandler()
|
|
9
|
+
class SymbolFormatter(logging.Formatter):
|
|
10
|
+
LEVEL_SYMBOLS = {
|
|
11
|
+
logging.DEBUG: '[*]',
|
|
12
|
+
logging.INFO: '[+]',
|
|
13
|
+
logging.WARNING: '[!]',
|
|
14
|
+
logging.ERROR: '[-]',
|
|
15
|
+
logging.CRITICAL: '[X]',
|
|
16
|
+
}
|
|
17
|
+
def format(self, record):
|
|
18
|
+
symbol = self.LEVEL_SYMBOLS.get(record.levelno, '[?]')
|
|
19
|
+
return f"{symbol} {record.getMessage()}"
|
|
20
|
+
handler.setFormatter(SymbolFormatter())
|
|
21
|
+
logger.addHandler(handler)
|
|
22
|
+
return logger
|