HackMyVM - Messages
Messages is a medium difficulty machine that should make you think a little...
As it is a medium machine I will assume a little knowldge and just mention the relevant points rather than detail the simple bits.
Find it
┌──(kali㉿kali)-[~/messages]
└─$ sudo netdiscover -r 10.0.0.0/24 -P|tee findit
[sudo] password for kali:
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
10.0.0.1 08:00:27:d5:3a:9b 1 60 PCS Systemtechnik GmbH
10.0.0.136 08:00:27:b9:c9:3f 1 60 PCS Systemtechnik GmbH
-- Active scan completed, 2 Hosts found.
Scan it
└─$ nmap -T4 -p- -sC -sV -oN nmap.out 10.0.0.136
Starting Nmap 7.91 ( https://nmap.org ) at 2022-02-14 11:50 EST
Nmap scan report for 10.0.0.136
Host is up (0.00063s latency).
Not shown: 65525 filtered ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
| 3072 3f:95:7f:d8:b0:55:f2:55:b0:54:8f:e3:02:01:ac:61 (RSA)
| 256 4c:93:71:5c:f7:45:4a:24:d0:9e:f8:d5:19:64:ee:9a (ECDSA)
|_ 256 32:80:9c:9b:8c:b3:c1:8c:9b:51:08:25:32:9c:d6:e4 (ED25519)
25/tcp open smtp Postfix smtpd
|_smtp-commands: SMTP: EHLO 521 5.5.1 Protocol error\x0D
80/tcp open http nginx
|_http-title: Did not follow redirect to https://10.0.0.136/
110/tcp open pop3 Dovecot pop3d
|_pop3-capabilities: STLS AUTH-RESP-CODE UIDL SASL RESP-CODES CAPA TOP PIPELINING
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
143/tcp open imap Dovecot imapd
|_imap-capabilities: LOGIN-REFERRALS IMAP4rev1 have LOGINDISABLEDA0001 ENABLE LITERAL+ capabilities ID IDLE OK post-login Pre-login listed SASL-IR STARTTLS more
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
443/tcp open ssl/http nginx
| http-robots.txt: 1 disallowed entry
|_/
|_http-title: Welcome to the Landing Page
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
465/tcp open ssl/smtp Postfix smtpd
|_smtp-commands: mx.messages.hmv, PIPELINING, SIZE 15728640, ETRN, AUTH PLAIN LOGIN, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING,
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
|_ssl-date: TLS randomness does not represent time
587/tcp open smtp Postfix smtpd
|_smtp-commands: mx.messages.hmv, PIPELINING, SIZE 15728640, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING,
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
|_ssl-date: TLS randomness does not represent time
993/tcp open imaps?
|_imap-capabilities: LOGIN-REFERRALS IMAP4rev1 have ENABLE AUTH=LOGINA0001 LITERAL+ AUTH=PLAIN ID IDLE Pre-login post-login capabilities listed SASL-IR OK more
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
995/tcp open pop3s?
|_pop3-capabilities: SASL(PLAIN LOGIN) AUTH-RESP-CODE UIDL USER RESP-CODES CAPA TOP PIPELINING
| ssl-cert: Subject: commonName=mx.messages.hmv/organizationName=mx.messages.hmv/stateOrProvinceName=GuangDong/countryName=CN
| Not valid before: 2022-01-26T18:05:23
|_Not valid after: 2032-01-24T18:05:23
Service Info: Hosts: -mx.messages.hmv, mx.messages.hmv; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 109.08 seconds
So there are a few ports available,
Mostly messaging related (SMTP, POP3, IMAP etc)
ssh is restricted to keys only so lets look at the webpages first.
RCE
Webmail wont be much use without any credentials, lets look at the chatbot.
Searching for Chatbot v1.0 there are vulnerabilities listed.
https://www.exploit-db.com/exploits/50673 https://www.exploit-db.com/exploits/50672
Looking at the records on exploits-db.com also links to the download link.
There are multiple ways to exploit this - either by:
a. trying to replace an icon with a malicious php script
b. exploiting the SQL injection vulnerability.
c. looking at the install documentation for the default credentials.
the SQL injection method is actually the easiest to bypass the admin login.
by setting the username to: admin'-- -
and anything as a password you can just login:
If the username was unknown or had been changed for security... then
admin' or username in (select username from users) LIMIT 1;-- -
If you were to look at the source code you would see:
"SELECT * from users where username = '$username' and password = md5('$password') "
So by closing the quote early and using "-- -" the remainder of the line is effectively commented out:
"SELECT * from users where username = '$username'-- -' and password = md5('$password') "
Escalate to User
Escalate to Root
find / -perm -4000 -exec ls -al {} \; 2>/dev/null
Comments
Post a Comment