Windows Privilege Escalation

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

21 hours 43 minutes
Video Transcription
Windows privilege escalation
are learning objectives are to demonstrate how to use power up dot PS one, a power shell script to enumerate privilege escalation. Vulnerabilities
explain the various methods to escalate privileges in Windows.
So Windows privileged escalation was a huge weakness of mine
and it's basically the reason that I failed uh my second attempt at O S C P is I I didn't know if I got on a Windows box. Hypothetically, in my second attempt,
I had no idea what to do, I had no idea how to enumerate windows and how to escalate privileges properly and you're going to have to know how to escalate privileges on both Windows and Lennox boxes. But
Windows, for me was very, very tricky. I think that the updated pen 200 or P W. K materials do a very good job, a lot better than the older material and explaining how to escalate privileges and Windows.
so we need to look at some tools of the trade on how to enumerate Windows machines for privilege escalation vulnerabilities. One is access check dot e x c. This is not something that's installed in Windows by default. It's something you need to download onto your Cali box and then upload onto the Windows host.
So this checks for service permissions. The first thing you do is accept the end user license agreement and then you can start checking for service permissions. You can see here that I'm checking the service permissions for authenticated users. You can check the service permissions for everyone um or you can check the service uh,
permissions for whatever user you are then,
so what you want to look for when you do that is if you see service all access below the service name,
that means that you can edit the bin path of that service using sc which we'll talk about the next slide, but you'll configure the bin path to do something malicious. Like, let's say, add another user in the administrators group.
There's also W m I see that this is to check for unquoted service paths, unquoted service path or something you'll actually get to
exploit in the lab, hint there. I don't expect you to copy this down verbatim here. Obviously you can google this um and and get the full string that you can use in your own machine to test out.
So s C like I said, this starts stops and query services as well as configure services.
So you can do sc config the service and you can you can add that bin path. Like I said, that you could add uh evil user and and put them in the administrators group.
So the thing about sc is you can query but you may not have the ability to start or stop services if you get access denied, don't panic.
What you can do is you can shut hopefully you have permissions to shut down the system from the command line, so if you're in the command line that shut down forward slash art or restart it and you have to wait for the machine to restart.
But hopefully that service automatically executes at start and it will do that malicious thing, like add that user into the administrators group for you. So not all is lost when you do S E stop, RSC, start and you get access tonight.
So my favorite power shell script here, power up dot PS one.
It not only enumerates privilege escalation, vulnerabilities on Windows boxes, it also allows you to exploit them because it's Power Shell, it has a lot of versatility.
So it runs when you do invoke all checks, it runs all these checks for you, unquoted service paths, service executed an argument permissions, etcetera, etcetera.
But it does a whole lot of things in a very short amount of time.
So first you'll download the script and you put it on the Windows box and then you'll start up Power Shell, Power Shell with a few different flags here, then you'll import module power up to P. S. One. Sometimes after import module, I have to do the space and then dot forward slash power dot ps one
to get it into memory. And then you can do invoke all checks and that's what runs all the checks for you. All the enumeration checks for vulnerabilities. So what does that look like?
Here's an example checking service permissions, so that's from my power UP, invoke all checks
and it finds this service name, a look up service
the path for it
and the abuse function so I can copy this abuse function
and when I'm in power shell and what it does is very I had the verbose output so it finds the original path of the service which is Windows system
32 service host etc.
Okay, blah blah blah. Um and then it finds it that it's running. So what it does is it stops the service
that I'll execute this command in the bin path that I was talking about. Net user jOHN password 123 exclamation add. So is adding the jOHN user by starting stopping the service.
Now it's executing another command. Net local group administrators jOHN adds is adding jOHN to the administrators group
then it's starting the service again, it's restoring the regional been path and then
no one's the wiser. But now we have this new user named jOHN and we know their password and SMB is enabled in the box. So I use I am packets ps exact from my Cali box to then login with SMB
and right to the admin share and now I am system.
so unquoted service paths here again, I'm running power up
and I find this service named unquoted service hint there the abuse function is right service, binary service named unquoted service. So you'll see
I can get my pointer here. You'll see it makes this service e x E.
So to get this to work is you I need to change service dot e x E two unquoted. So the way that the unquoted service path vulnerabilities work is windows checks every single
line. So we'll first we'll check for temp then I'll check for unquoted then it will keep checking and if I name something because there's a space here, my name, something unquoted e x e
when it looks to that path and it's checking all those, you know, first 10th and unquoted it will find unquoted dot e x c and executed.
So that's what happened here is when I change service dot txt to unquoted dot txt I put it in the temp directory as in temp as unquoted dot e x c. And then I started to stop the service and then started the service and it added this user john and then again I'm using I impact as PS execs
to get in the box that way and become system.
It's also good to know how to exploit manually. So what I also did is I created an MSF venom payload
and you can see them and execute herbal. I call it evil dot txt. I should have called it unquoted dot txt because I'm creating an extra step for myself. But again I'm putting it in the temp directory
as unquoted at X. And this is of course a reverse shell here
On Port 443. So I have my listener up
and I stopped the service and then I start the service and you can see when I start the service, my reverse shell activates.
So give that a try in the lab to don't just use power up. Also try to figure it out manually.
Here's the guide for power up. Always good to read the guide. I know I hate reading guides but it's good to know how it works.
Here's some resources. So it's there are a lot of different vulnerabilities, privilege, escalation, vulnerabilities in Windows. These are just some resources. It's really good to know what your resources are
when you go to SCP. You know if if I'm trying to look for all my when I was privileged escalation resources, I I put them in one place and that's why I talked to note taking,
you know, make sure, you know where your resources are. And it's also it's not just finding these vulnerable, unquoted paths and things like that, but maybe there's a vulnerable, vulnerable version of Windows, kind of like a Colonel exploit for Lennox. Maybe you have a vulnerable version of Windows, which I don't really talk about here, but check these guides and they may give you
some help when it comes to versions of Windows.
You know, the newer version of Windows I don't think are as vulnerable. They don't have these, you know, quote unquote colonel, uh Colonel exploits or version exploits. Um but you know, if if you have more of a legacy box, maybe they do. And these guides will tell you about that
Medicine Post module. I talked about this as well. Local exploit suggestion. It used to be Windows exploit suggestions spelled wrong, but now it does Lennox as well. And that's why I talk about architecture being important and you'll see here collecting local exploits for x 86 windows.
If your uh, interpreter session was X 86, you wouldn't be able to enumerate things correctly and find the all the vulnerabilities.
So I found a privilege escalation module and I tried it and it worked. This doesn't always happen. Sometimes you'll try the first one, it won't work, you'll try the second one, third 1/4 1, they all won't work. May be the first one that you try DAS the box or or cause some issue.
Um, so what I typically do are a lot of resets when I do this. Obviously I don't do this. Ah, no SCP day, I do this in the labs. I would be very hesitant to use local exploit suggest er,
because then you've used the module up,
so use this sparingly.
so in summary, we should now be able to demonstrate how to use the power up dot PS one script to enumerate privilege, escalation vulnerabilities, as well as explain the various methods to escalate privileges in Windows.
Up Next