1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! # cerbero-lib

//! ```text
//!   ____          _                          _ _ _
//!  / ___|___ _ __| |__   ___ _ __ ___       | (_) |__
//! | |   / _ \ '__| '_ \ / _ \ '__/ _ \ _____| | | '_ \
//! | |__|  __/ |  | |_) |  __/ | | (_) |_____| | | |_) |
//!  \____\___|_|  |_.__/ \___|_|  \___/      |_|_|_.__/
//! ```
//!
//! Library to perform several tasks related with the Kerberos protocol in an Active Directory pentest.
//!
//! This repo was cloned from <https://gitlab.com/Zer1i0/cerbero> and has been converted into a library format.
//! I intend to add more features/clean up the code further -- view the
//! [TODO](https://github.com/NukingDragons/cerbero-lib/tree/main?tab=readme-ov-file#TODO) section
//! in the associated [github](https://github.com/NukingDragons/cerbero-lib).
//!
//! ## Table of Contents
//! 1. [**Installation**](#installation)
//! 2. [**Functions**](#functions)
//!     - [**ask**](#ask)
//!     - [**asreproast**](#asreproast)
//!     - [**brute**](#brute)
//!     - [**convert**](#convert)
//!     - [**craft**](#craft)
//!     - [**hash**](#hash)
//!     - [**kerberoast**](#kerberoast)
//! 3. [**TODO**](#todo)
//! 4. [**Credits**](#credits)
//!
//! ---
//!
//! ## Installation
//!
//! To use this library in your project you can add it via `cargo add`:
//!
//! ```sh
//! cargo add cerbero-lib
//! ```
//!
//! ## Functions
//!
//! ### Ask
//! The [ask](fn.ask.html) function allows retrieval of Kerberos tickets (TGT/TGS) from the KDC
//! (Domain Controller in Active Directory environment). Moreover, it also
//! perform requests to obtain tickets by using the S4U2Self and S4U2Proxy
//! Kerberos extensions.
//!
//! _(View the `ask` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/ask/src/main.rs))_
//!
//! ### AsRepRoast
//! The [asreproast](fn.asreproast.html) function can be used to discover users that do not require
//! pre-authentication and retrieve a ticket to crack with hashcat or john.
//!
//! _(View the `asreproast` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/asreproast/src/main.rs))_
//!
//! ### Brute
//! The [brute](fn.brute.html) function performs TGT requests in order to discover user credentials
//! based on the KDC response. This bruteforce technique allows you to discover:
//! + Valid username/password pairs
//! + Valid usernames
//! + Expired passwords
//! + Blocked or disabled users
//!
//! This attack should be performed carefully since can block user
//! accounts in case of perform many incorrect authentication attemps
//! for the same user.
//!
//! _(View the `brute` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/brute/src/main.rs))_
//!
//! ### Convert
//! The [convert](fn.convert.html) function will convert ticket files between krb (Windows)
//! and ccache (Linux) formats.
//!
//! _(View the `convert` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/convert/src/main.rs))_
//!
//! ### Craft
//! The [craft](fn.craft.html) function allows for the crafting of golden and silver tickets.
//!
//! _(View the `craft` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/craft/src/main.rs))_
//!
//! ### Hash
//! The [hash](hash/index.html) module contains functions that calculate the Kerberos keys (password hashes) from the user password.
//!
//! _(View the `hash` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/hash/src/main.rs))_
//!
//! ### Kerberoast
//! The [kerberoast](fn.kerberoast.html) function can be used to retrieve a (potentially crackable) password hash
//! for an account with an SPN set.
//!
//! To format encrypted part of tickets in order to be cracked by hashcat or john,
//! you need to provide a file with the user services. Each line of the file
//! must have one of the following formats:
//! * `user`
//! * `domain/user`
//! * `user:spn`
//! * `domain/user:spn`
//!
//! When a service [SPN](https://en.hackndo.com/service-principal-name-spn/)
//! is not specified, then a
//! [NT-ENTERPRISE principal](https://swarm.ptsecurity.com/kerberoasting-without-spns/)
//! is used. This can also be useful to bruteforce users with services.
//!
//! _(View the `kerberoast` example [here](https://github.com/NukingDragons/cerbero-lib/tree/main/examples/kerberoast/src/main.rs))_
//!
//! ## Credits
//! This work is based on great work of other people:
//! - [Impacket](https://github.com/SecureAuthCorp/impacket) of Alberto Solino [@agsolino](https://github.com/agsolino)
//! - [Rubeus](https://github.com/GhostPack/Rubeus) of Will [@harmj0y](https://twitter.com/harmj0y) and Elad Shamir [@elad_shamir](https://twitter.com/elad_shamir)
//! - [Mimikatz](https://github.com/gentilkiwi/mimikatz) of [@gentilkiwi](https://twitter.com/gentilkiwi)
//! - [Cerbero](https://gitlab.com/Zer1i0/cerbero) of Eloy [@zer1i0](zer1t0ps@protonmail.com)

// TODO: Fix the issues causing these warnings instead of this lazy fix
#![allow(deprecated)]
#![allow(clippy::too_many_arguments)]

mod commands;
mod communication;
mod core;
mod error;

/// Utilities for converting various things in this crate into strings
pub use crate::core::stringifier;

/// The file formats for tickets (KRB/CCache)
pub use crate::core::CredFormat;

pub use crate::{
	commands::{ask, asreproast, brute, convert, craft, hash, kerberoast},
	communication::{KdcComm, Kdcs, KrbChannel, TransportProtocol},
	core::{
		BruteResult, BufVault, CrackFormat, EmptyVault, EncryptionType, FileVault, KrbUser, TicketCred, TicketCreds,
		Vault,
	},
	error::Result,
};

pub use kerberos_asn1::Ticket;
pub use kerberos_crypto::Key;
pub use ms_pac::PISID;