Linux 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
Module nine privilege escalation,
Lennox privilege escalation
are. Learning objectives are to understand what Lennox colonel exploits are and explain the various methods to escalate privileges and Lennox.
So, getting a shell or a foothold on the box is only half the battle and no SCP on some of these boxes, you're gonna have to escalate privileges from an privileged user
to either route. If it's alan X box or system, if it's a Windows box,
people typically, you know, in the in the lab environment, I would say rely a lot on Colonel exploits and colonel exploits are great because they're um all you have to do is enumerate the kernel version of that Lennox box and hopefully it matches up to an exploit and
you can become route, which we saw with this dirty cow wax plate
and that's how I figured it out was, you know, we go back to the command line uh, module I did you name A and I saw the version of the kernel was 3.2 point zero. Well if I searched dirty cow, I see that the vulnerable kernels are 2.6 point 22 before 3.9. So obviously this
colonel version is vulnerable to dirty Count. We saw that we were able to use this exploit
successfully to escalate our privileges to root.
they're typically compiled or I'm sorry, written in C and they need to be compiled.
Which in and of itself can be difficult. As you you saw the different flags. I had add when I compiled this. If you don't see that in the comments, the default syntax would be gcc the name of that C program tack. Oh little Oh, and then whatever output you want to make it,
sometimes you'll get errors on the box. Um and sometimes that you'll have issues compiling
that. Either on that box or you can compile it locally on your machine, but you might have different architectures than the vulnerable box, in which case it's not gonna work.
So you take a risk compiling it locally and putting on the machine again, if your architecture is different. Um but that's a possibility of gcc isn't on the victim box, you can always compile it locally.
Also you have to get it onto that box and that's why we did all that file transfer and how to transfer files was because you had to figure out different ways to get it on the host machine.
Don't get comfortable with these colonel exploits. I mean, they're great when they work,
but you should also figure out other ways to enumerate vulnerability is a privilege escalation, vulnerabilities on Lenox hosts.
And how do we do that? There's a really great got milk has this really great page. Why is it really long? Well I had issues recently getting onto his page directly,
but if you use archive dot org, you'll see here that I'm referencing a certain date and time the way back machine. This is how I got to read his blog. But he goes, this is kind of like the de facto source for privilege escalation, manually figuring out how to escalate privileges
and find weaknesses.
I recommend, highly recommend you go to his blog and you read through this information.
So start with the basics. I've been on plenty of boxes where I do Sudo tack l
and it says that you can run everything that you have all privileges.
Um so all you have to do is Sudo Su and you are the root user
makes things really easy. I just did this on a capture the flag recently. Uh did Sudo Su and I was the root user.
The problem
you can also find processes running as root
and the command line lab. You found
a flag running as a process. So that's to say you can also find all the processes running his route
and from there we need to figure out if the process has some kind of if it's a sewage binary, if it's something that we can write to and if we can write to it then hopefully we can run it as root and you know, maybe put a nice reverse shell in there.
So improper permissions. This is another big thing proper permissions in sc password.
If you find that you can write to etc password you can add a user and you can see here
I have this user hacker and the password here is hacker.
And what I can do is if I can put this into the etc. Password file, I can then sue hacker
password hacker and become the root user.
Also, if you can view the ETC. Shadow file, you can crack passwords, which we'll talk about more in the pastor cracking lab. But together if I can only read the etc password file and I can only read the etc shadow file, I can put those together with jOHn the ripper and I can crack passwords that way.
sewage binaries. So this might be hard to see. Um, but you'll see here. I'm running an enumeration script. I see sewage files,
I see user espen P P P D
and I see that there's a vulnerability for it via IOS privilege escalation via Sudo, P P P D.
And what I'm running here is
Annette Cat shell. I'm using pseudo P P P D connect and you'll see Net Cat here
and I now am route on the box, so sued binaries when you can run Sudo on a binary and and basically run something with root permissions, google that service and see if there is a privilege escalation vulnerability for that is like I did here
and ultimately I got root here.
Cron jobs also why I had you
uh look at Cron jobs is because if a Cron job is running as root and you can edit that file, then you could again put a nice reverse shell in there, you know, to take out whatever is in their ad
a reverse shell in there and connect to your box is route.
Of course, it depends on the timing. If it only runs, you know, every once every monday,
you know, every other month.
Um, it's not gonna work because you want something that's continually running every minute every five minutes. P. S P Y on on GIT hub has helped me a lot of hacked the box challenges and it will show you all the processes that are running. So you'll you'll see it in kind of in nearly real time
what processes are running and it polarizes it so you can tell which ones are running as root
and then see if a process is running as root and then see if you have permissions to modify that file.
Enumeration is your friend in all things as you saw with that. I didn't even know about that privilege escalation on that machine. I make a lot of labs as I've told you. I didn't even know about that until I googled it and found that that was a vulnerable service.
Um I'll talk about this in the in the enumeration script part.
But simple, I think simple targeted searches are are good, at least when you're getting used to this than just running an enumeration script that spits out page after page after page of output
and you have no idea what you're looking at.
so we'll talk about these privileged escalation, enumeration scripts at length more,
but you should understand what Lennox colonel exploits are our nuclear option and then also be able to explain the various methods to escalate privileges. And Lennox. This is another thing that you'll get familiar with after time,
as I said, getting a foothold on getting initial shell in a box is only half the battle privilege escalation is a big thing as well and something that you need to get good at. So in the lab you'll get to explore the various ways to uh to escalate privileges to root. And that's why I put that box in there because I think
it's better that you see the various ways I'd rather have too many vulnerabilities
and you see all of them then too little. So definitely practice on boxes and labs and get to see the various ways you could escalate privileges uh, from becoming a unprivileged user to the user.
Up Next