Kerberoasting in C#: An OPSEC Perspective
Jayden Caelli (Senior Penetration Tester · SilentGrid)
BSides Canberra VIII (2025) · Day 2 · Off-Main Track
Overview
In this insightful talk from BSides Canberra, Jayden Caelli, a Senior Penetration Tester at SilentGrid (also known as "red to desync"), delves into the critical operational security (OPSEC) considerations when performing Kerberoasting attacks using custom C# tooling. The presentation primarily focuses on understanding how Endpoint Detection and Response (EDR) solutions collect telemetry and how an attacker can build custom tools to evade detection. Using Kerberoasting as a practical example due to its relative simplicity as an Active Directory attack, Caelli outlines common detection vectors, explores various EDR components, and proposes advanced bypass techniques.

Key moments
- 0:00 Introduction: OPSEC for custom C# tooling
- 6:00 What is Kerberoasting? Attack explanation
- 12:30 Rubious LDAP query detection and evasion
- 20:00 Overview of Windows EDR components
- 26:00 ETW logging and bypass techniques
- 30:30 AMZ (Antimalware Scan Interface) evasion
- 34:00 Closing thoughts: EDR bypass process
Kerberoasting in C#: An OPSEC Perspective
Speakers: Jayden Caelli, Senior Penetration Tester, SilentGrid
Conference: BSides Canberra
YouTube: https://www.youtube.com/watch?v=owzWkM0yI6o
Overview
In this insightful talk from BSides Canberra, Jayden Caelli, a Senior Penetration Tester at SilentGrid (also known as "red to desync"), delves into the critical operational security (OPSEC) considerations when performing Kerberoasting attacks using custom C# tooling. The presentation primarily focuses on understanding how Endpoint Detection and Response (EDR) solutions collect telemetry and how an attacker can build custom tools to evade detection. Using Kerberoasting as a practical example due to its relative simplicity as an Active Directory attack, Caelli outlines common detection vectors, explores various EDR components, and proposes advanced bypass techniques.
The core purpose of this talk is to equip offensive security practitioners with the knowledge to develop bespoke C# tools that are more resilient to EDR scrutiny. Caelli aims to clarify what aspects of Windows client endpoints EDRs monitor, the types of telemetry they collect, and how widely used tools like Rubeus often trigger immediate alerts. By dissecting the underlying mechanisms of Kerberoasting and the intricate workings of EDRs, the talk provides a roadmap for building stealthier attack tools, offering a valuable perspective for both red teamers seeking to improve their evasion capabilities and blue teamers aiming to understand sophisticated attacker methodologies.
Background
▶ Watch: Introduction: OPSEC for custom C# tooling (0:00)
Kerberos is the default authentication protocol used within Active Directory (AD) environments, relying on a system of tickets to prove identity and grant access. When a user or service wants to access a resource, they first obtain a Ticket Granting Ticket (TGT) from the Key Distribution Center (KDC), typically a Domain Controller. This TGT authenticates the user to the domain itself. With the TGT, the user can then request a Ticket Granting Service (TGS) ticket (also known as a service ticket) for a specific service, such as an MSSQL server. The KDC generates this TGS, encrypting part of it with the target service account's password. The client then presents this TGS to the service, which decrypts it using its own stored password to validate the ticket and grant access.
The link between a service and its authenticating account is established through a Service Principal Name (SPN). An SPN is a unique identifier for a service instance, assigned to a specific Active Directory user or computer account. For example, an MSSQL server running on server.corp.local might have an SPN like MSSQL/server.corp.local, which is then associated with a dedicated service control user account (e.g., MSSQLServiceUser).
Kerberoasting is an attack that exploits this process. If an attacker can obtain a TGS ticket for a service account, they can extract the encrypted portion of the ticket (which contains a hash of the service account's password) and attempt to crack it offline. If successful, the attacker gains the plaintext password for that service account. With the password, they can then impersonate the service account, forge their own service tickets (a silver ticket attack), or simply log in as the service account to gain access to its associated privileges.
The viability of Kerberoasting hinges entirely on the strength of the service account's password. Ideally, service accounts should have long, complex, and randomized passwords that are computationally infeasible to crack. However, in many environments, misconfigurations, legacy applications, or developer oversight lead to service accounts being provisioned with weak, default, or easily guessable passwords. This makes Kerberoasting a highly effective reconnaissance and privilege escalation technique, as it can yield anything from low-level access to Domain Administrator credentials, depending on the context. The ubiquitous C# tool Rubeus, created by SpectreOps, has long been the go-to utility for pentesters performing Kerberoasting, but its widespread use has also made its indicators of compromise (IOCs) well-known to defenders, leading to its easy detection if used without modification.
Key Findings
▶ Watch: Rubious LDAP query detection and evasion (12:30)
Jayden Caelli's talk meticulously breaks down the common detection pitfalls of standard Kerberoasting tools and presents a comprehensive methodology for developing custom C# tooling with enhanced OPSEC. The central findings revolve around identifying and circumventing the telemetry collection mechanisms of modern EDR solutions.
A primary finding is that off-the-shelf tools like Rubeus are easily detectable due to their predictable behaviors. Specifically, Rubeus's default LDAP queries, which often use broad wildcards like servicePrincipalName=*, generate obvious signatures. Additionally, its tendency to request TGS tickets as fast as possible creates anomalous spikes in network traffic, and its default encryption preferences (sometimes including weaker RC4) can also serve as IOCs.
Caelli then categorizes the various EDR components that adversaries must consider:
- User-mode drivers: These often hook Win32 API calls in user-land DLLs to monitor process behavior.
- Event Tracing for Windows (ETW): A powerful logging mechanism, ETW providers (like the .NET ETW provider or the LDAP ETW provider) can log detailed information about function calls, parameters, outputs, and even assembly metadata. A kernel-side variant, ETW Threat Intelligence (ETWI), is even harder to bypass.
- Network filter drivers: Operating in the kernel, these drivers monitor all network I/O operations, including the process, port, and nature of LDAP and Kerberos traffic.
- Anti-Malware Scan Interface (AMSI): This interface allows applications (like PowerShell or .NET runtime) to submit code or content for real-time scanning by registered antivirus products.
- Kernel callback arrays: These are functions called by the kernel in response to critical system events, such as process or thread creation.
- File system mini-filters: These drivers monitor file system operations, detecting file creation, modification, or access.
The key takeaway for attackers is that successful evasion requires a multi-pronged approach. This includes:
- Modifying LDAP query patterns: Moving away from obvious wildcards to more subtle, yet equally effective, lexical comparisons and restricting search scopes.
- Pacing and diversification of requests: Slowing down ticket requests and distributing them across different hosts or users to avoid traffic anomalies.
- Prioritizing strong encryption: Forcing AES encryption for TGS requests, which is harder to crack and less suspicious than RC4.
- Bypassing ETW and AMSI: Employing low-level techniques like byte patching or hardware breakpoints to disable or manipulate these telemetry sources, or, more subtly, refactoring code and customizing assembly metadata.
- Avoiding disk writes: Preventing hashes or other sensitive data from being written to disk, which is easily monitored by file system filters.
Ultimately, Caelli emphasizes that each EDR product and customer configuration is unique, necessitating a tailored approach to bypass. The process involves obtaining a copy of the target EDR, identifying known IOCs, iteratively testing custom tools, analyzing alerts, and adapting strategies based on the observed detections.
Technical Deep Dive
▶ Watch: Overview of Windows EDR components (20:00)
The technical deep dive of the talk begins by dissecting how Rubeus traditionally performs Kerberoasting, highlighting the specific C# classes and LDAP query patterns that lead to its detection. Rubeus, in its older iterations, would use the DirectorySearcher class to find accounts with SPNs. This involved constructing an LDAP filter that searched the entire domain (root LDAP path) for user accounts (samAccountType=805306368) that had any service principal name set (servicePrincipalName=), while excluding the krbtgt account and ensuring the account was enabled. The servicePrincipalName= wildcard is a significant indicator of compromise (IOC) because it's a very broad, reconnaissance-oriented query that is uncommon for legitimate applications. Once SPNs were found, Rubeus would use the KerberosRequestSecurityToken class to request a TGS for each, then decode the ASN.1-encoded ticket and format the hash for cracking tools like Hashcat or John the Ripper.
Caelli then proposes several OPSEC improvements for these techniques:
1. Stealthier LDAP Queries:
- Replacing Wildcards with Lexical Comparison: Instead of
servicePrincipalName=*, Caelli suggests using a lexical comparison. For instance, anORstatement like(servicePrincipalName>=http/random.corp.local)(servicePrincipalName<=http/random.corp.local)can effectively match any existing SPN without using a wildcard. The key is that if an SPN exists, it will fall within some arbitrary alphabetical range, thus appearing to be a more specific query while still retrieving all desired results. - Restricting Search Scope: Rather than searching from the root of the domain, an attacker can limit the search to specific Organizational Units (OUs) known to contain service accounts (e.g.,
OU=Service Accounts,DC=corp,DC=local). Alternatively, an attacker could iterate through OUs, making each individual query appear more focused. - Limiting Returned Properties: Default LDAP queries often return many properties (e.g.,
lastLogonTime,description,givenName). By explicitly requesting only necessary properties likesAMAccountName,servicePrincipalName,whenCreated, andwhenChanged, attackers can reduce the volume of LDAP traffic, making it less likely to trigger alerts based on data transfer size. ThewhenCreated/whenChangedproperties can also help identify potential honeypot accounts with anomalous creation dates.
2. Kerberos Protocol OPSEC:
- Encryption Type Preference: While RC4 encryption is easier to crack, its use is often an IOC for downgraded attacks. Caelli recommends prioritizing AES encryption, which is the modern default and harder to crack but less anomalous. This requires manually implementing the Kerberos protocol to specify encryption types, adding complexity.
- Request Pacing: Rapid requests (e.g., "20 tickets in 5 seconds") are a clear sign of automation. Attackers should space out requests (e.g., 10 minutes or longer between requests) or distribute them across different host/user combinations to avoid correlation.
- Targeted Reconnaissance: Instead of blindly requesting TGS tickets for all SPNs, attackers should perform prior reconnaissance to identify high-value service accounts, reducing unnecessary traffic and interaction with potential honeypot accounts.
3. EDR Component Bypass Strategies:
- ETW Bypass: The .NET ETW provider logs extensive details. To bypass, Caelli demonstrates byte patching the
EtwEventWritefunction inntdll.dll. This involves locating the function in memory, changing its memory permissions to read/write/execute, and then writing aRET(return) instruction at its entry point. This causes the function to immediately return without writing any event data. A variation uses hardware breakpoints to achieve a similar effect without directly modifying code. A less aggressive approach involves obfuscating function/variable names and populating the .NET assembly manifest with legitimate-looking metadata (e.g., version1.0.0.4, copyright, product, company, description) instead of the suspicious default0.0.0.0version. - AMSI Bypass: AMSI (
amsi.dll) scans code at runtime. Similar to ETW, Caelli shows how to bypass it by hookingAmsiScanBuffer. The technique involves byte patching the function to force a return value of0(indicating "clean") in the appropriate register, then immediately returning. This tricks the calling application into believing the code is benign. Again, hardware breakpoints offer an alternative. A more resilient strategy is to rewrite code (changing method names, variable names, control flow) to evade AMSI's static analysis signatures. - Network Filter Evasion: For LDAP traffic, if running from a custom executable is anomalous, injecting into a process known to make LDAP queries (e.g., Microsoft Excel) can help. Alternatively, using Active Directory Web Services (ADWS) on TCP port
9389(XML/SOAP-based) can bypass LDAP filters, though ADWS itself might be monitored if its usage is unusual for the process. For Kerberos,KerberosRequestSecurityTokenuses LSASS, which is normal. However, if manually implementing Kerberos to gain more control, the traffic will originate from the attacker's process. In this case, injecting into a process known to generate Kerberos traffic (e.g., a web browser) would be ideal. - File System Mini-filters: The simplest advice here is to avoid writing to disk if possible. Writing extracted hashes to a file (especially one named
kerbroast_ticket.txt) is highly detectable.
These techniques demonstrate a shift from simply executing an attack to carefully crafting the execution environment and method to minimize an attacker's footprint against sophisticated EDR solutions.
Demo / Proof of Concept
▶ Watch: AMZ (Antimalware Scan Interface) evasion (30:30)
While the talk primarily focused on conceptual and code-level explanations rather than a live, full-scale demo, Jayden Caelli presented several code snippets and simulated output to illustrate the core concepts.
The first part of the "demo" involved showing the output of a standard Kerberoasting attack using a tool similar to Rubeus. This output clearly displayed the identified SPN (MSSQL/server.corp.local), the service account (MSSQL Service Control User), and the extracted NTLM hash in a format ready for Hashcat cracking. He then demonstrated how Hashcat would successfully crack this hash using a wordlist, revealing a weak password like "myleadpass@1". This segment served to establish the baseline for the attack and the typical output an attacker aims for.
Following this, Caelli presented C# code snippets that demonstrated how the original Rubeus-like behavior was implemented using DirectorySearcher and KerberosRequestSecurityToken. He then showed how this code could be modified to incorporate the proposed OPSEC improvements for LDAP queries:
- The LDAP filter was updated to replace the
servicePrincipalName=*wildcard with a lexical comparison (e.g.,(servicePrincipalName>=http/random.corp.local)or(servicePrincipalName<=http/random.corp.local)). - The
LDAP pathwas restricted to a specific Organizational Unit (e.g.,OU=Service Accounts) instead of the entire domain root. - The code was adjusted to only request specific properties (
sAMAccountName,description,servicePrincipalName,whenCreated,whenChanged,lastLogon), reducing the overall data volume.
Crucially, the talk included detailed C# code examples for bypassing EDR telemetry sources:
- ETW Bypass: Caelli showed code that performs byte patching on the
EtwEventWritefunction withinntdll.dll. The code first usesGetModuleHandleorLoadLibraryto findntdll.dllin memory, thenGetProcAddressto locateEtwEventWrite. It then changes the memory protection of this region toREAD_WRITE_EXECUTEand writes aRET(return) instruction at the function's entry point. This effectively disables ETW event writing for the process. - AMSI Bypass: Similarly, a C# code snippet was presented to bypass AMSI. This involved locating
amsi.dlland theAmsiScanBufferfunction. The code then patched this function to inject assembly instructions that force a return value of0(indicating a "clean" scan result) into the appropriate register, followed by aRETinstruction. This tricks AMSI into always reporting benign findings for the process.
These code demonstrations, while not a live exploit against an EDR, served as a clear proof of concept for the feasibility of the described low-level evasion techniques, illustrating the precise byte-level modifications and assembly instructions required. The emphasis was on how these bypasses are implemented rather than merely stating their existence.
Defensive Implications
▶ Watch: Closing thoughts: EDR bypass process (34:00)
Jayden Caelli's talk offers critical insights for defenders looking to bolster their defenses against sophisticated Kerberoasting attacks and general custom tooling. The implications for blue teams are multifaceted, spanning from fundamental password policies to advanced EDR telemetry analysis.
- Enforce Strong Service Account Passwords: This is the most direct and effective defense. If service accounts use long (e.g., 25+ characters), complex, and randomized passwords, Kerberoasting becomes computationally infeasible, regardless of attacker OPSEC. Regularly audit service accounts for weak or default passwords.
- Monitor LDAP Traffic for Anomalies:
- Broad Queries: Look for LDAP queries that use wildcards in the
servicePrincipalNameattribute (servicePrincipalName=*). While attackers may use lexical comparison, this signature remains a high-fidelity indicator of reconnaissance. - High Volume/Frequency: Detect sudden spikes in LDAP query volume or frequency from individual users or hosts. Normal user behavior rarely involves requesting hundreds of SPNs in a short timeframe.
- Anomalous Processes: Identify unusual processes (e.g.,
excel.exe, web browsers) making LDAP queries, especially if they are targeting SPNs. - ADWS Usage: Monitor for connections to Active Directory Web Services (ADWS) on TCP port
9389from processes not typically associated with ADWS interaction.
- Monitor Kerberos Traffic for Suspicious Patterns:
- Rapid TGS Requests: Implement detections for a single user or host rapidly requesting multiple TGS tickets for various SPNs.
- Encryption Type Downgrade: While harder to detect post-compromise, identify attempts to request TGS tickets using weaker RC4 encryption types when AES is available, as this can be an indicator of an attacker trying to simplify hash cracking.
- Anomalous Processes: Monitor for processes outside of
lsass.exe(or known legitimate Kerberos-aware applications) generating Kerberos requests, especially if an attacker has manually implemented the protocol.
- Detect EDR Bypass Attempts:
- Memory Patching/Hooking: EDRs should actively monitor for attempts to modify memory regions of critical system DLLs like
ntdll.dll(for ETW) andamsi.dll(for AMSI). WritingRETinstructions or forcing return values are highly malicious activities. - Hardware Breakpoints: Detecting the placement of hardware breakpoints on sensitive API functions can also signal an evasion attempt.
- Suspicious .NET Assembly Metadata: Scrutinize .NET executables or loaded assemblies with default or missing metadata (e.g., version
0.0.0.0, no copyright, generic product names). While easily modified, it's a quick win for defenders if overlooked by attackers.
- File System Monitoring: Prevent attackers from writing extracted hashes to disk. Implement rules to detect the creation of files with suspicious names (e.g.,
kerbroast_ticket.txt,hashes.txt) or content patterns, particularly in unusual locations. - Deploy Honeypot Accounts: Create "too good to be true" service accounts with enticing privileges but no actual function. These accounts should be configured to trigger immediate, high-severity alerts upon any interaction, serving as an early warning system for attacker reconnaissance.
- Regular EDR Configuration Review: Understand that EDR products and their configurations vary. Continuously review and fine-tune EDR rules to detect the specific techniques outlined in the talk, considering custom configurations that might target unique aspects of your environment. This includes reviewing logs for ETW events, AMSI detections, and network traffic from both endpoints and domain controllers.
By proactively addressing these areas, defenders can significantly raise the bar for attackers, forcing them to expend more effort and increasing the likelihood of detection.
Key Takeaways
- Custom tooling requires deep OPSEC: Relying on stock tools like Rubeus for Kerberoasting is highly detectable; effective evasion necessitates building custom C# tools with meticulous attention to detail.
- Understand EDR telemetry sources: EDRs leverage various Windows components (ETW, AMSI, network filters, file system mini-filters) to collect telemetry. Bypassing them requires specific knowledge of each mechanism.
- Stealthy LDAP queries are crucial: Modify broad LDAP queries (e.g.,
servicePrincipalName=*) using techniques like lexical comparison, scope reduction, and property limitation to reduce detection surface. - Pacing and encryption matter for Kerberos: Avoid rapid TGS requests and prioritize AES encryption over RC4 to mimic legitimate behavior and make cracking harder.
- Low-level bypasses (ETW/AMSI) are effective but risky: Techniques like byte patching or hardware breakpoints can disable EDR telemetry, but these actions themselves are highly malicious and can be detected. Code refactoring and metadata customization offer a less aggressive alternative.
- Defenders must enforce strong passwords and monitor for anomalies: The most effective defense against Kerberoasting is strong, randomized service account passwords. Additionally, blue teams should actively monitor for anomalous LDAP/Kerberos traffic, EDR bypass attempts, and suspicious file writes.
About the Speaker(s)
Jayden Caelli, who also goes by the handle "red to desync," is a Senior Penetration Tester at SilentGrid. His expertise lies in offensive security, with a particular focus on Active Directory attacks and advanced EDR evasion techniques. Through his work, Caelli aims to push the boundaries of red teaming by developing custom tooling and methodologies that can circumvent modern defensive solutions, providing valuable insights for both offensive and defensive security communities.