HackTheBox - Silentium
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
What's going on, YouTube? This is Ipsac, and today we'll be doing Selentium from Hack the Box, which funny story, when this box was being evaluated, I left the comment of, "I want to reject this for being highly unrealistic, but somehow this vulnerability made its way into a semi-large open source project." The vulnerability is at the start of the box. When doing the forgot password, the web server responds with the entire user object, not only including the user's password hash, but the reset token itself. Definitely a vibe induced vulnerability and I hope the models have gotten better to where we don't see this type of vulnerability in the future.
Anyways, as you can guess there's also an rce vulnerability which gets us a foothold onto the box. For root there's a pretty cool GOGS vulnerability that's taken advantage of a insufficiently patched CVE. There's a file rate CVE in 2024 which had a directory traversal vulnerability that got patched but the patch forgot about SIM links and another CVE was in 2025 for pretty much the same thing. So with all that being said, let's just jump in. As always, we're going to start off with an end map. So - sc for default scripts as v enumerate versions-reason to give us things like the ttl oa output all formats in the end map directory and call it centium and then the IP address of 10129245.103.
This can take some time to run. So I've already ran it. Looking at the results, we have just two ports open. The first one being SSH on port 22 and the banner tells us it's an Abuntu server. We also have HTTP on port 80. Its banner tells us it's Ubuntu also running Engine X and is directing us over to selentium.htb. So I'm going to add this to my host file real quick. So we'll do pseudo v etsy host. Then 10129245103. Paste the domain. Save that. And then let's go take a look at the page. So I'll do http selentium.http or httb. And then we can get um the page
of this. So, doing a quick glance, it looks like it's a single web page. We have a few names here. Marcus Thorne, Ben, Elena, Rossy. Oddly enough, Ben doesn't have a last name. Um, that is just odd to me. Uh, these pages just go
uh back. I want to see exactly what this is coded in. So, looking at the source, uh, we see some tailwind asset style. It's not really leaking too much information. Um, there it is. JavaScript right here. We see assets app.j JS. Um, let's see. Do I have Oh, let's see. Where's plugins account? Maybe this.
Maybe I don't have Weapilizer installed on this right now. Normally, I'd look at Wapalizer also and see exactly what is built with, but we can do some manual playing with. Let's try index.php. Uh, we get a page. index.html. We get a page. Index.exist.
We get a page. So, it looks like everything is directing us to this single page app, right? Um, we see this slider here, but it's updating instantly. So, I don't think any API requests are being made on the back end. So, I have no idea what this is other than just like a static website right now. So, before I poke at this more, I want to just set up some recon to go in the background. And I'm going to start with a um virtual host enumeration, right? See if there's any subdomains. So do afu uh http selentium.htb because I don't feel like typing that IP address. Uh we're going to add the header of a host and then say
fuzz.entium.htb and then the word list. I'm just going to use opseck list discovery DNS and
then subdomains top million. Let's just do 5,000 for now. And I'm going to do - AC for autoc calibrate. and it finds the staging. So, let's go ahead and do pseudo v etsy host. Then I can add a staging.selentium.htb. Save that. Let's take a look at this page. So, http um that's lentium staging.
And the host header tells us this is flowy. So, we could do some enumeration around this and find out it's an open source application. But normally I like poking at things first. If I try signing in root at ipsseack.rocks, let's do a password of password. We get user not found, right? There were a few users on the page. I want to say like Marcus Thorne or Ben or Elena Rossi or something. I'm just going to start with Ben because Ben didn't have a last name. So, I'm going to guess his email is ben.salentium.htb. And we get incorrect email or password. There's one other interesting thing I want to show because if we try to do a single quote here, the JavaScript prevents us. So that would be like testing SQL injection, right? So let's go ahead and paste this. Uh what just happened there?
Repeater. Uh okay. I don't know why
repeater was in its own window, but we'll just move on. Uh send this waiting. Um, is this server dead?
Send. Oh, wait. Is it here? Uh, okay. My repeater was in a really odd state, but we got it back. So, we just have the email there. That is incorrect email or password. If we do a user that doesn't exist or email that doesn't exist, we get user not found. If I do a
single quote here, we get invalid user
email. So, we got some type of schema validation or something just testing the characters in an email and it's saying, you know what, emails can't contain a single quote. So, we're just going to reject that right away. So, I'm not going to test for SQL injection there. Um, we could play with it on password. So if we do a single quote incorrect um
we could try like 41 equals 1 like that I think would be uh
valid. We probably got to put a space there.
And we still get user not found. So chances are this is not SQL injectable. Um we do have a way to validate um that
emails exist though because we have incorrect email or password versus the
uh user not found and there is one other functionality of this application right we have the password reset and I like testing for this because it is saying password reset code so my guess is we do a forgot password it sends us like a four or sixdigit code and then I can brute force that code right so let's try this we'll do ben selentium am.htb
and let's go ahead and intercept this request. So intercept is on still. I'm going to go back over here. Burp sweetite send. This is the forgot password. And if we send it, we get something I rarely ever
see back. It is the full like column or
entry for the user. We have their password hash what it is. So we could try cracking Ben's password. Right now, we have the token for the password reset. Um, where they're a member of, what roles, like we have everything about the user right here. So, let's go ahead and, uh, go back to the proxy. I'm
going to intercept the response to this request. I'm going to forward it. We're going to look at this. I'm going to grab the token. And then we are forward that to the browser. Turn intercept off. And because I had two requests there, it went back. Let's just reso this whole endpoint. Uh we'll do benalentium.htb
intercept. Send it. Let's go ahead and intercept the response to this request so we can easily copy this out. There we go. It's on my clipboard. Forward it. And then I'm going to click here. And we have a thing to input the reset token. So benentium.htb.
And then we're just going to do the password of password one. Right? And I'm doing P at SSW ord one exclamation point. And we have successfully reset the password. So we can say ben at selentium.htb password one exclamation point. And I did all this because it is a CTF. If I was doing this for like an engagement or something like that, um I would probably well notify the customer after I discover this. um because this looks like it's probably vibecoded and just a big mistake. But after I notify them, I'd probably try other users and then crack credentials and see if I can log in that way because I consider resetting passwords like a destructive action because we're locking users out of the system. Um this is an admin, so you never want to lock a user out without notifying them unless like that is a specific test case, right? So, I would have spent more time trying to crack it, but this is a CTF, so I really don't care, right? I could just revert the box, but we get logged into FlowWise.
And then there's one other thing I want to point out. Um, normally I would be looking at CVEEs, and this is a CVE within um, flow-wise, but I like showing my normal attack path as well, which just like goes testing the like user login, password reset functionality, etc., right? But if we look at these endpoints, we have it going to API v1. You could run like a um go buster against this or a
durbuster and then enumerate what functions of the API there are. There may even be like a swagger thing we can access. I don't know. But one common one would just be API v1 version, right? Most APIs support a way to enumerate the version. And this tells us it's version 305, right? Um, if we went to the GitHub
page, come on. Once it loads, I'm going to turn burpuite off for now.
Uh, let's go over to Google as well. I don't know why that's taking forever to load. Um, we can say flowwise three. Well, that is not it. 305.
We can see it's a public archive, so it's no longer in development, but there are 124 security and quality issues. 341 pull requests, tons and tons of issues. I'm guessing this is all just um vibe coded stuff. Whenever you see like get this active, probably vibe coded. Um we
could also look at the commits. 3,000 commits. There is something last month, so it was probably recently archived. Um, but it's not the most insane active thing for like vibe coding. Maybe I'm wrong by that. I was expecting to see like a 100 commits a day. But if we look at this, uh, we can see there is a remote code execution vulnerability. I think this missing authentication or critical function that is talking about the password reset functionality if I remember correctly. But trying to load this, my internet or GitHub is just going extremely slow. I'm guessing that's GitHub because the box was loading fine. But we have a potential rce path, it's saying. So they're doing API v1 node load method custom MCP um login stuff
and then they can run some JavaScript. So let's go ahead and try this out on oursel. So let's go ahead and do a
curl like this. And then we want to change the URL because we're not running on localhost 3000. It is staging. Celentium.htb.
And I'm guessing this authorization bearer is going to have to change, right? We have unauthorized access if we just send that. Um, so let's go ahead and update this token. So that is deleted. Let's go to the application. We have an API key section. I'm just going to go ahead and grab this. And we're going to try this token real quick. We will copy. We will paste.
Hit enter. And we don't have anything. It says no available actions. Check your API key. So, what I'm going to do really quick is change this to a sleep command. So, let's do a sleep two. That's taking a while. So, I'm assuming this executing code. Uh, we could do X
http 127001 8080. Send this to Burpswuite. So, it's a little bit um easier to see. So, now
let's go over to the repeater tab. We run it. We're going to see a sleep for like 2,000 milliseconds or 3,000 milliseconds. Um, let's do a sleep for four. I'm going to expect to see 5 seconds here if we have rce, right? Come on. Uh, five. Yep. So it takes about a second to process the page and then we have asleep for whatever. So we have code injection here. Um let's try to get a reverse shell. So I'm going to do um let's see echo- n-
I uh yeah we'll do this dev tcp 101041 171
900 and one like that. That looks like a reverse shell. Base 64 W. And then I
like getting rid of all special characters. So we can do a space there.
Go to the end. Uh I think two equals we'll get that. So now it's purely alpha numeric which means I should be able just to copy this echo base 64-d
bash. And that should work if this um works.
So I'll do nclvmpp 90001 send this. And
we don't get anything. Um, let's try a NC10 10. Uh, what is it? 14171 is my IP.
9,0001. Send this. And we can see it connects back and sends everything. So, we know we have code execution. We just can't get a shell. So, my next bet would be um let's see, we can run commands.
So, let's do a ls. Um, I deleted too much there. Hold on.
Let's just do a witch bash.
And we get nothing. Let's do a witch sh.
We get that. So, bash is not installed in this box. We can do a lsla bin.
And we see we're running by. So busy box normally has netcat that it has the dash e flag. So that is my next thought real quick. So let's just do a
um nc- e
bsh like this. We don't get anything. So maybe not. Um let's go to a reverse shell cheat sheet
and see if we have a different shell we can use because we don't have bash. So that means we can't do the dev TCP thing that we like doing. But there's plenty of other reverse shells, right? We could potentially use Pearl, uh, Python, PHP, Ruby. Uh, we just tried that. Netcat. I'm going to use this one.
And let's see. I'm going to do vshell. We will paste this here. And I'm going to say 10 10 14
171 like that.
9,0001. That looks fine. Let's do a base 64
W0 shell. Uh, we probably should get rid of some of these spaces. And that's going to be tougher. About halfway through, I'm going to guess you.
Hey, that worked. I just eyeballed B 64. That is sometimes I surprise myself. So now we have this giant payload. Uh let's go ahead and try this. So we'll do a
echo base 64-d pipe it to sh.
Uh we already have the shell listening and hope we get a shell. We do. Awesome. We do ls and it looks like it works. Um, I'm going to do Python 3- C import pt y
pty spawn.
Ben bash like that.
Uh, well, not found. What? Oh, I don't have bin bash. Um, let's copy this. Then sh.
There we go. And then we can do stdty raw minus echo foreground. Enter. Enter. and we can say export term is equal to xterm and that lets us clear the screen. So now that we have a shell um we didn't need to we could have ran the same exact command we did before like just envip it to NC and look at the environment variable but the key thing is looking at the environment we see uh Ben here but
there is something we have an SMT password of road rage and this is actually Ben's password so if we did SSH ben selentium.htbaste HTTP paste this in
we get logged in. Awesome. And one thing I would want to point out um I think while we have the shell uh we
hang the server. So if I do curlstaging.salentium.htb it's no longer responding to us. I don't know if that's just my IP address that's hung or it's just um the server itself.
But this is always something you should test when you get a reverse shell. Um, did you take the website down? Because if it's a single threaded process, there is a chance you take it down and that just sucks. Um, I guess we could go from this uh curl. Let's do a hold on SSLTP.
It's either probably 3000 or 301, I would guess. 127001. 3000. It looks like it's hung for everyone is my guess here. Um, I think that's flowy. Uh, it's definitely running in Docker because it is a um, what am I going to say here?
Uh, busy box and this is Linux. So, I definitely know it's in Docker. Uh, PSEF Forest. Let's do less S. Uh, look at 3000. Let's see. Hostport. It's using container 1721802. I don't know if I can identify exactly what container that is. Um, let's see this movie address.
I don't think I can easily, but we can see my reverse shell here. It is node flowz start and then my shell. I'm guessing this is where it's just single threaded. So, until this command finishes, we have completely hung that server, which is not good. Um, interesting enough, we do have MailHog here. Um, container D. Let's see.
So, I'm guessing MailHog is probably
1025. I think 25 is port 25 SMTP. Um,
let's see. Port 25.
Google. There we go. Um, yes, that is SMTP. So, this is probably Mailhog. This is Floy. I don't know what a I guess that's MailHog too. Yeah, 03 is both. So these this is probably MailHog definitely. That is the web interface to MailHog and that is I don't know. Um let's see what else do we have looking up Laurel VM tool. Uh we do have
Goggs running. This is going to be like get T. So, if we do SSL and TP, I'm
guessing GOGs is either probably 3001 or 43507. Um, curl 127001 43507. Uh, 404 not found. And let's just do 3001,
I'm guessing. Yeah, this is definitely Goggs. So, let's take a look at um
Goggs. I'm going to stand up a port forward. So we'll do a local port forward 3001 forward it to 127001 30001
and what that's going to do I haven't hit enter just yet but if I curl 127001
3001 we don't have anything listening right if I hit enter here now 3001's going to be listening on my box and anything to it is going to go through the SSH tunnel and then come out this end and try to hit localhost 3001 and now I can hit goss from my local machine. Awesome. So, let's go ahead and go back to our browser. And then we can just go 127001 port 3001.
And we see GOGs. And I was just checking to see if it gave me like a version anywhere. I'm sure if you look at my
YouTube channel, I probably have a way to enumerate Gogg's version. Um, I know
I've done it before, but I'm not sure off the top of my head. I'm just going to cheat because we have command access to this. Uh, we can do a psf grap goss.
And we can go op go. Wow. Triple goss. Uh, h,
uh, -v will show us the version. And we have goss version 0133. I think goss has some type of API where you can just enumerate it. Is there like a API v1 version? Do you have it too? No. I think there's an API where you can enumerate the version of Goggs, but I'm not positive. Uh, let's see. That's the password. Uh, let's go ahead and grab this on the clipboard. Let's go to Google and I'm gonna say Goggs this version. And the first post is a Whiz.io with a CVE that's actively exploited. So, let's take a look at this. Um, looking at it,
there are a few key p uh key points. And this CVE is a bypass for an earlier r vulnerability in 2024. Um, so essentially, uh, it was an
incomplete patch, right? The previous flaw abused a path traversal weakness and put contents API. It allowed an attacker to write files outside of the git repository directory, gring the ability to overwrite sensitive files. So essentially, um, this was a path reversal and they fixed the path reversal by putting in a path util. So that's going to remove like dot dot slash dot dot slash dot dot slash. Um but it didn't account for symbolic links. So it was still exploitable. Um in this the attacker did something slightly different than I'm going to show probably. They overwrote the global git config and changed the SSH command.
So instead of doing like a git poll or something like that whenever goss did it, it would just run uh in this case who am I tempacted, right? So they just essentially remapped where git was. They don't really tell too much on how to exploit this. I think on this post
um they're just overwriting it, but they don't go into the original vulnerability. They're talking what the attacker did here, right? They dropped the binary on the box and had it execute. Um the easiest way to put this
together is to go up to where they say the original exploit was. look at that GitHub advisory and let's see once this page fully loads it'll become more readable. I would think it'll load soon. I don't know why GitHub is going so slow for me. Um there
we go. So what they do is they do a curl
and then these dot dot slashes um and then put whatever file they want to override here um and then they can sh right.
So what we're going to do is pretty much the same thing. And we got to create a repo, but instead of um all these sim
links, I mean all these patch reversals do slash, we're just going to use a sim link and overwrite. So let's go and um
do this. So first we have to get into goss. So let's go back home. Uh localhost 3000. Uh let's see. Let's see if I can just register account. If I can't register, then we'll try like Ben's password and other things. But I'll do ipsack root at ipsseack.rocks password of password and then 2 44 566. Please say I'm not a
robot. There we go. IPSC password
um API v1. Oh, it's going to my version.
Let's create a new repo and we'll just call this pone. We can make it private.
That's fine. Create the repo. Let's do a get pull. So get pull on this
repo. Uh
get clone hips password cdpone. And let's do ln uh- s. We're
going to say root.sh sh uh root.sh
authorize keys to pone. So now in this
repo we have a file called pone and that is going to be sim linked to roots ssh keys right. So now let's do a get add on
pone get commit-m uh place the payload I guess and then get push.
Okay. So now this exists. So what we
have to do here is we're going to go
back to this and it's API v1 repos.
I'm going to guess this is IPS and then the repo name. So IPSAC pone and then contents. And instead of these dot dot slashes, we'll just write the pone and see if this works. Um we'll also need an authorization token. So, let's see. If I go into my settings, I should be able to create a API key, right? Applications, new token. Oh, we'll just create a token. Doesn't matter what the name is. Save this.
V get token. Paste.
Okay. So let's do this
curl. This is now going to be localhost
3001 API v1 repos.
sec pone. It is user then repo
and then we can just do pone because that is going to be sim linked to um the box. Let's see we have to update the token.
So we can say token is equal to this
and let's see we need a base 64 encode or SSH public key.
So let's do I don't want to exit that session. I almost did. Um sh-t
ed25519-fip
catip.pub pub. Uh,
what? Oh, sh key genen.
Catip.pub. Okay, we'll want to B 64. So, B 64-wz.
Copy this.
paste.
And before I hit enter, we can ship
root at selenium.htb.
Say we need a password. We're going to now send this,
hit enter, and it lets us in just like
that. Because what happened is get t is running as root, right? And this command is going to tell git t to try to write to this file with the file being pone right and its contents is the um user repository. So it's trying to write here and pone is sim linked to the authorized key file. So when git t as root tries to write to that it can write and for some reason git t or git in general loves b 64. So it just automatically on B 64 is
the content and then does that write command, right? I bet if we on this
shell did like find slash uh-name pone
let's hide error messages in a couple seconds probably this will find exactly where it exists on the file system itself. Um and then we can look and see
the sim link there. I don't know exactly where it exists. So I'm going to just pause the video. We'll let this command run and see if it returns anything. Okay, that command finished. And it's a little bit weirder than I expected because the file path is op data temp local repo one pone. Like I expected to
see IPSAC um pone, but I'm guessing like IPSC pone is mapped to some type of ID
and that's how they store it on the file system. That's the only guess I can uh assume here, right? But if we look at that file, we can see it has indeed pointed to root SSH authorized keys. So, um, with that being said, that's going to be the video. Hope you guys enjoyed it. Take care and I will see you all next time.





