HackTheBox - Bastion — Transcript
Full transcript
- 0:00what's going on YouTube this is a hip
- 0:01sack and we don't bash them from hack
- 0:02the box which is set up like a bastion
- 0:04host some people call them jump boxes
- 0:06essentially the idea is you create one
- 0:09super secure box that's absolutely
- 0:10hacker-proof for all your users to
- 0:13remote into in order to access things on
- 0:15the other side so let's say I'm at home
- 0:17and I want to access things on the
- 0:18corporate network instead of leaving my
- 0:21corporate Windows workstation exposed to
- 0:23the Internet
- 0:24I'd just leave a bastion host exposed
- 0:27and then from home I can SSH into the
- 0:29bastion host which is dual homed and I
- 0:31can then create a port forward to access
- 0:34my workstation that's essentially the
- 0:36idea the main drawback is a bastion host
- 0:39by definition is one host so if that
- 0:42host ever gets compromised all the
- 0:44credentials that access it also get
- 0:45compromised which often is domain admins
- 0:47and they normally can get into a lot of
- 0:50things that technology has kind of been
- 0:52replaced by the web browser because you
- 0:54can do almost anything in the web
- 0:55browser especially with no VNC guacamole
- 0:57etc you can just create virtual
- 1:00environments that contain users choose
- 1:02specific places and don't give them a
- 1:05whole environment so you're not sharing
- 1:07credentials if you don't want to do that
- 1:09you got things like virtual application
- 1:11streaming so you can just stream them
- 1:13the app they need and then if you want
- 1:15to go even more you can do like a Remote
- 1:17Desktop gateway so when they remote
- 1:19desktop in they get their own
- 1:21environment so again if that environment
- 1:23ever gets compromised it commbuys is
- 1:26just their credentials it's not sharing
- 1:28a host for everyone so with all that
- 1:31being said let's go exploit a bastion
- 1:33host as always we begin with a and maps
- 1:37are - SC for default scripts SV
- 1:39enumerate versions hue output all
- 1:41formats pin the end map director and
- 1:42call it bash 10 and then the IP address
- 1:45which is 10 10 10 134 can take some come
- 1:48to run so I've already ran it look at
- 1:50the results we have a few ports open
- 1:53the first thing is SSH on 422 and that's
- 1:56running OpenSSH for windows SSH on
- 1:59Windows is a bit unique but hey it's
- 2:01there so definitely take note of it then
- 2:04we have a procedural call on ports 135
- 2:07and 139 nothing too interesting there
- 2:09then this mics off - des which is SMB on
- 2:13point for four or five and interesting
- 2:16enough there's no web servers so I
- 2:18believe the biggest attack surface right
- 2:20now is SMB so that's where we can begin
- 2:23SSH generally has authentication and
- 2:26I've never seen like guest access to SSH
- 2:29or anonymous access but I have seen
- 2:31anonymous access to SMB so let's go and
- 2:33try that out first thing I'm going to do
- 2:36is SMB client - Capra l - where shares
- 2:40then slash slash ten ten ten one thirty
- 2:42four and then for the past four I'm just
- 2:45gonna hit enter and it will list the
- 2:47shares the admin C and IP C are all
- 2:51defaults backups is a unique share so
- 2:54I'm going to mount backups with mount -
- 2:57t CIFS which is the like Windows
- 3:01protocol for mounting I think SMB FS may
- 3:04work as well I honestly don't know the
- 3:07difference between CIFS and SMB FS but
- 3:10back to the point but the mount point
- 3:13which is ten ten ten one thirty four
- 3:15slash backups and then where do you want
- 3:17to mount it to so I'm gonna make the
- 3:19directory /mnt
- 3:21slash SMB and then we'll mount it there
- 3:25and then password just hit nothing for a
- 3:29guest authentication and if we do LS /
- 3:33mount SMB we see files
- 3:36there's also SMB map which we could use
- 3:38if you don't want to use SMB client so
- 3:41that'd be SMB map - capital H ten ten
- 3:44ten one thirty four and the first thing
- 3:48it does I believe is like anonymous
- 3:50access which we get denied if you
- 3:52specify any user name it doesn't matter
- 3:54which one it will try guest access and
- 3:57we can see files the interesting thing
- 4:01to note though is I believe it attempted
- 4:04to write this directory so let's do LS /
- 4:07mount / SMB and we see that directory
- 4:11exists because it says the permissions
- 4:13are readwrite so it tests to write but
- 4:16it doesn't have mission to delete so
- 4:19always keep in mind what your tools do
- 4:22and if your defender
- 4:24also know what tools do because you can
- 4:26create IO cs4 indicators of compromise
- 4:28but if we try to remove this we get
- 4:32access to nine and we can verify that it
- 4:34does indeed create a random file by just
- 4:37drawing that same command again and if
- 4:40we do LS la mount SMB will see the
- 4:45second file it attempted to create so if
- 4:48I was creating some type of IRC for this
- 4:50I just like monitor shared drives and
- 4:53the root directory for things that are
- 4:56let's see probably 10 characters long so
- 5:01that couldn't help detect SMB map usage
- 5:04on your network but it's also a reason
- 5:08why sometimes I prefer just using like
- 5:10the dumb tools like SMB client instead
- 5:12of automated things because typically
- 5:14those don't make mistakes like that and
- 5:19that may not be a mistake but always
- 5:22know what your tools do so let's just
- 5:25get back on topic and go through this we
- 5:27have no dot txt so I'm going to see what
- 5:30that file is if we cat it out it says
- 5:33sis admins please don't transfer the
- 5:35entire backup locally while on a VPN or
- 5:37office is just too slow for that so if
- 5:40we do like a D u - H s to see the size
- 5:45and then let's just go into that
- 5:48directory oh it's 5.1 gigs so they don't
- 5:51want you copying five gigs over the
- 5:53network that's fair so let's just go
- 5:56through this we got the Machine name ll4
- 5:59m pj e - PE i've got pc if we go do it
- 6:04nmap scans that will probably say it
- 6:07here NetBIOS computer name is Bastion so
- 6:12a little bit different we got a backup
- 6:15of this PC but the computer name and add
- 6:18map at least is bashed in so let's keep
- 6:22going through this we do have a backup
- 6:25so let's check this l LS la and there
- 6:31are a few files so right here the
- 6:34interesting files are probably gonna be
- 6:35v HD virtual
- 6:37drive and there's two options we could
- 6:39do we can do like 7zl to list files and
- 6:437-zip has the ability to go and view the
- 6:46files of a VHD file so we can see this
- 6:49and we can see all the paths given that
- 6:53it's only got system boot that is
- 6:55probably the boot partition that's
- 6:57backed up so let's go to the next one
- 6:59down and this will be FBC for this one
- 7:03is FPC 3 so it's just a guin but let's
- 7:06try the other petition and this one is
- 7:09probably much bigger if we do DHS stir
- 7:11this one one is the 5j petition you can
- 7:15do 7-zip here as well and then you could
- 7:18do like 7z space X to extract it but
- 7:23typically it's just a pain working with
- 7:267-zip and this can be a little bit slow
- 7:28so I'm gonna pause the video will let
- 7:30this view all the files and then we're
- 7:32just gonna mount the VHD soon zip has
- 7:36finished and we can look at all the
- 7:38files it shows and it shows us pretty
- 7:41much a Windows install but there's just
- 7:43so many files to go through and search
- 7:45it's a pain
- 7:47so let's mount this did you mount a VHD
- 7:50on linux use guest mail and I don't have
- 7:54that installed so I'm gonna do app to
- 7:55install Lib guest FS - tools and install
- 8:00this well that installs there is one
- 8:04thing I missed that I probably would do
- 8:06if I was on an engagement if we did SMB
- 8:08map
- 8:09- you does not exist and then - H 10 10
- 8:1510 134 if I saw this readwrite on like
- 8:21backups or pretty much readwrite
- 8:23anywhere I probably create a dot SCF
- 8:26file if you have unfamiliar with that we
- 8:29showed it in sizzle essentially it's a
- 8:32method to do steal hashes so when a user
- 8:36views a directory that has that SCF file
- 8:38if the SCF file is specifically created
- 8:42you can force them to try to connect it
- 8:44back to your machine and when they do so
- 8:47they may perform an authentication if
- 8:48they perform an authentication get the
- 8:50hash
- 8:50crack it so being on the back abstractor
- 8:53in particular is super useful because
- 8:55the people who view backups are probably
- 8:57admins so if you put an SCF file there
- 8:59and an admin goes you may get an admin
- 9:01hash so definitely check out the sizzle
- 9:04video for that it's not gonna work on
- 9:06this box because there's no automated
- 9:07process looking at that directory but I
- 9:10was hoping the tool would finish by the
- 9:13time I explained that it didn't so I'm
- 9:16gonna pause the video again and we'll
- 9:17just resume when this is done once Lib
- 9:21guest FS tools is done we can mount the
- 9:23drive so we'll do guest mount and then -
- 9:27- ad specify the VHD file do - -
- 9:33inspector - - read-only and you could do
- 9:38- beef of a bose just to make sure it's
- 9:41doing something
- 9:42oh we had specify a directory so let's
- 9:45do make to mount a VHD and we'll mount
- 9:49it there so it's going to take probably
- 9:54a minute to two minutes to mount and
- 9:57just spew a bunch of stuff to tech the
- 10:01screen so we'll just let that mount and
- 10:04resume the video when this is done when
- 10:07the command finishes you'll be back at a
- 10:09command prompt so now we can go into
- 10:11slash mount VHD where we mounted it and
- 10:13doing LS here shows we're at the C Drive
- 10:17so the very first thing I'm going to do
- 10:18is go into the users do an LS and we got
- 10:23the l4m pje user and we can look at what
- 10:28files are here so we can do like find
- 10:31desktop documents downloads and then do
- 10:37like - LS to list all the files and we
- 10:40see really nothing too interesting so
- 10:46one thing we could try to do is extract
- 10:49maybe the administrator password to this
- 10:51guy so if we go into Windows then
- 10:56system32
- 10:59and then config we have a few files
- 11:03important ones are I believe Sam and
- 11:06system and these are the registry hives
- 11:10if you like H key local machine whatnot
- 11:13I think the user database is in the Sam
- 11:18but the boot key which the user database
- 11:21is encrypted is in the system so that's
- 11:23why you need that one and if you're only
- 11:25the main control you'd also want to grab
- 11:26like NTDs did and if you have all three
- 11:30files NTDs Sam and system you can
- 11:32extract the Active Directory database
- 11:34but for now we're just on the box so
- 11:37we'll do that root H GB boxes and then
- 11:42bash them so let's go into that
- 11:47directory and we can make a directory
- 11:53backup doll and move those files there
- 11:58go in here and we can do I think it's
- 12:03secrets dump or in packet - secrets dump
- 12:07- Sam the file name system the file name
- 12:12and then local and here we go we have a
- 12:17few hashes the first thing I notice is
- 12:19the administrator hash is blank 31 d6
- 12:22means nothing
- 12:23same with aad 3 B as a LM hash LM is it
- 12:27used a more so that's why you see it
- 12:28always blanked out but this being
- 12:31blanked out means administrator account
- 12:33is probably disabled so we do have a
- 12:36hash for a user and we can check if he
- 12:44has write access over the sieve all or C
- 12:46dollar sign if he does then we can
- 12:49probably use PS exec and get
- 12:51administrator if he doesn't then want to
- 12:53find another way so I'm doing - H - test
- 12:57as a hash flow again and this does pass
- 13:00the hash so a paste the whole hash in
- 13:03and then - capital H is the host name 10
- 13:0510 10 134 maybe it's just - P and that
- 13:10uses some regular expression there we go
- 13:12hash to tack
- 13:13so we see we authenticated but the admin
- 13:17has no access si has no access backup
- 13:19still has the same so we didn't get
- 13:21anything there was that SSH login so
- 13:24let's try to decrypt this hash and see
- 13:27if we can log in via SSH so I'm just
- 13:29gonna go to hashes org we can do hash
- 13:33search and then search hashes org for
- 13:37this so ki 2 D 9 u 0 and we see the
- 13:44password is something so V dot creds l
- 13:514m p je i think is the username what did
- 13:57I use here l4m pje yep so we got a
- 14:02password so let's try ssh l 4m p je @ 10
- 14:0810 10 134 to see if they allow SSH to
- 14:11log in yes ok creds copy this paste and
- 14:22there we go
- 14:24we are now on the box so the first thing
- 14:27I'm gonna do is net local group
- 14:30administrator administrators and we see
- 14:36the members of the administrators group
- 14:38is administrator which is odd because it
- 14:42looked like this account was disabled so
- 14:45we can do net local group or not net
- 14:48local group net user l 4m p je to see
- 14:51what groups were a member of I believe
- 14:54it says there we go local group
- 14:56membership users so let's check net user
- 15:01administrator and we can see he has
- 15:07logged on he does have a password last
- 15:11set date of April 16th so what I'm going
- 15:15to do is go back into the VHD and we're
- 15:20going to see the dates of those files so
- 15:23LS la and we can see
- 15:27grab Sam the Sam was last modified
- 15:31February 22nd and the system was
- 15:37modified February 22nd as well the
- 15:40password was updated in April so this is
- 15:43an old backup and that's why the
- 15:45administrator account was blank now but
- 15:48now it definitely looks like there is
- 15:49one so we have to figure out how to
- 15:52reverse things I'm gonna do is run a
- 15:56tool called jaws and just another
- 15:57Windows enumeration script that's on
- 16:00PowerShell so we'll get hub to find it
- 16:03and install it I had installed Kali
- 16:07again so I don't have all my tools
- 16:09we can't opt you can see it's rather
- 16:12bare so go into drawers we can do python
- 16:18m simple HTTP server and then look at
- 16:23our IP address which is probably ten ten
- 16:25fourteen three it is so we can do
- 16:32powershell and then IX new object net
- 16:39web client download string HTTP ten ten
- 16:45fourteen three four eight thousand jaws
- 16:50a new mess one I think that's the name
- 16:53of the script there we go now it's
- 16:56running well that runs let's just see if
- 16:59we can get another session to this box
- 17:02because it can take a while and you
- 17:05should always be doing recon in the
- 17:07background and working while you do
- 17:09recon it's getting a lot of permission
- 17:15denied but we don't care about that
- 17:16right now we are enumerated box so going
- 17:21to go into the root of C actually let's
- 17:24just check users we got the
- 17:28administrator user and l4 m p je we
- 17:33didn't have a flag I think and the
- 17:35desktop of the background
- 17:36of the background
- 17:40back up so let's check if we have a flag
- 17:43here so l4m pje CD desktop dir
- 17:50you got user text there says it's 32
- 17:52bytes so chances are that is the flag
- 17:56let's look at what is in documents
- 18:02nothing you can check all the
- 18:04directories I don't think you'll find
- 18:05anything so let's go to the root of C
- 18:07and see what's here
- 18:08we got backups for you look in backups
- 18:11this is the share so nothing too
- 18:14interesting there you got logs looking
- 18:17in quite a few of that logs and things
- 18:21but I'm going to ignore these because
- 18:24look at the date September 12 2016
- 18:30wasn't it like February something and
- 18:33recent so chances are these logs are old
- 18:36so I could care less about them because
- 18:40we know the administrator change his
- 18:41password after then at least I think it
- 18:44was 2018 let's check net users
- 18:47administrator yeah that'll last at 2019
- 18:52so looking at file dates is generally a
- 18:56good thing to do so I'm gonna go into
- 18:58Program Files do I dir and see what's
- 19:01here we have the OpenSSH directory
- 19:04powershell nothing too interesting
- 19:07we can check Program Files x86
- 19:14dir and there's an application that
- 19:18looks unique M remote ng and this is
- 19:22just a like I think it's imagine a tool
- 19:27that manages a bunch of putties it's
- 19:29just a remote desktop management tool or
- 19:32something I've used it before a long
- 19:35time ago don't exactly remember but
- 19:37going on the theme of bashed in it's a
- 19:40remote management tool and generally
- 19:43people use Bastion host as a jump box
- 19:45and you load remote management tools on
- 19:48it so they can access other equipment
- 19:50Bastien doesn't really serve any purpose
- 19:51other than getting into other places so
- 19:56let's go and google em remote ng extract
- 20:02password so we got this view M remote
- 20:08passwords M remote password recover so
- 20:13let's see is there anything here recover
- 20:20easy I don't want to download something
- 20:23off some guys Dropbox account so let's
- 20:26do instead of extract password decrypt
- 20:29password and going down we get a blog
- 20:34post that says M remote ng password is
- 20:36insecure and then links to this post and
- 20:39if we go over it we can see there is a
- 20:43specific version of something where it's
- 20:46saying you can reverse the encryption
- 20:51this blog post has something different
- 20:53and installs M remote ng and here you go
- 20:56you can see the connection
- 20:57this is saying Remote Desktop so it's
- 21:00going to open up Remote Desktop and
- 21:01probably put the password on your
- 21:03clipboard so you can paste it in so what
- 21:07they did is they say hey instead of
- 21:10opening remote desktop which is M stsc
- 21:13open up CMD and then echo me the
- 21:16password variable which is what I would
- 21:18put in your clipboard or paste in or
- 21:19whatnot we're going to do this box a
- 21:21little bit differently because I don't
- 21:22want to load up windows I'm going to do
- 21:24a offline decoder so I'm just going to
- 21:26search github M remote ng decrypt and
- 21:32we'll go to the first one and use this
- 21:34guys Python script so let's go back to
- 21:38this pane we can stop posting jaws I
- 21:42guess and do get clone Emmert ng decrypt
- 21:50and yes I know that I already have not
- 21:53wanted to download a Dropbox thing and
- 21:55then immediately get cloning something
- 21:57from github and just executing without
- 21:59reading the source
- 22:00irony's not lost on me there but we can
- 22:05look at this and it needs this string of
- 22:07the password so that's what we have to
- 22:08find we have to find the string of the
- 22:11password and if you read the blog post
- 22:14it's in the config file so generally in
- 22:19Windows config files for users or stored
- 22:22an app data which is in the user
- 22:24directory so CD / users l4m pje I think
- 22:29dir slash a will list all files
- 22:31including hidden so that's where you can
- 22:33see app data if you don't have the slash
- 22:36a you don't see it but we go into app
- 22:39data and then normally it's in roaming
- 22:42and we can go em remote and G dir and
- 22:47here we go we got a bunch of configs
- 22:49with some backups so I'm just gonna do
- 22:51type to cat the file
- 22:55there's the XML I'm going to search for
- 22:58password so username l4m pje here's this
- 23:05password and let's try decrypting it so
- 23:08we'll do Python 3mm remote ng string
- 23:11paste this this credential looks similar
- 23:15we already had that so let's go see if
- 23:18there's another one that's just my bad
- 23:25search for password hit and to do next
- 23:30and just keep going up until we see
- 23:31something interesting and right here I
- 23:34see a different base 64 string this use
- 23:37name is administrator so let's copy this
- 23:41and do the same exact thing so python 3
- 23:45- s paste and then we get a different
- 23:50password so i'm going to do
- 23:52SMB matt - you administrator - p for
- 23:57password - h for host 10 10 10 134 and
- 24:01we see
- 24:03now we can read and write to admin a see
- 24:06dollar sign so we should be able to do
- 24:08like in packet - PS exact do I don't
- 24:13have that impact it I guess I don't have
- 24:17it installed locate PS exec PI user
- 24:25share is it here not on my path
- 24:32use a shared dock pass on
- 24:35- and packet we could also just SSH in
- 24:40but I wanted to use in packet so PS
- 24:44exact up PI okay administrator at 10 10
- 24:4910 134 paste the password request in the
- 24:53shares uploading the file and as long as
- 24:56antivirus or something doesn't stop this
- 24:58we should get a shell well that goes we
- 25:01can just SSH administrator at 10 10 10
- 25:04134 and now we're rushing to who get the
- 25:09shell first PS exact or my SSH session
- 25:13come on let's go down ping 10 10 10 134
- 25:23nope
- 25:23just going slow paste it in can only
- 25:27imagine would be like downloading that 5
- 25:29gigabyte file come on
- 25:32eventually something will let me in as
- 25:35that PS exact or this SSH there we go so
- 25:40Who am I
- 25:41administrator at Bastion Desktop dir
- 25:47root dot txt and then we can also CD
- 25:52users administrator desktop and we see
- 26:04root
- 26:05texts it should be important to note
- 26:08that willing to do PS exact we're
- 26:10running a system when I do SSH we're
- 26:12running as the administrator user just
- 26:16something to keep note of if you use the
- 26:18I think Windows version of PS exact you
- 26:21can use remain as the user I don't think
- 26:24there's a flag in in packets to not
- 26:27impersonate or yeah not impersonate the
- 26:30user so let's see maybe there's a help
- 26:36if there is we can see if there's not
- 26:41impersonate don't see it so yep but
- 26:46that'll be the video hope you guys
- 26:47enjoyed it take care and I will see you
- 26:49all next week
About this transcript
This page contains the full transcript of HackTheBox - Bastion by IppSec, generated from the public captions YouTube serves with the video. The transcript has 3,843 words across 509 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.