how to upgrade a shell.
Learning objectives to understand why we try to upgrade a shell and demonstrate the various ways to upgrade a shell.
So I hope the last lesson didn't get you down. Um there are ways to go from a bad shell to a good shell and I'm gonna tell you how you can do that, we're hackers right, because I think outside the box, if we're stuck with a bad shell, there has to be a good way to get a good shell.
Some of those ways are in Ritter printer, you can go from a command shell and you'll see here. I used multi manage sheldon interpreter
and again, this is gonna be something that more in P W K and C T F s, that actually, oh, SCP, because again, this is a module here, so you will migrate from a command shell which has limited functionality
to a interpreter shell where we can do things like set up a pivot point.
So that's to say that when you are in C T S and P W K and you're using medicine Floyd and you do get a command shell off the bat. There is a module that you can go from getting just a command shell to aim interpreter show with a lot more functionality.
in some cases you'll find you have a restricted shell. So on the top image or ssh in which I did say it is great to get an ssh ssh session into a box. But you'll see here we're in a restricted our bash shell. So trying to change director to root says restricted, who am I?
It's not letting us specify a forward slash.
You can get around that. And there are some, I've seen some cts or boxes that are like tailored around uh escapes escaping these types of restricted shells.
One way to do that is, you know, I've taught you tak tea and you can do Ben bash Corbyn Shelby S. H.
In some cases you can do bash tack techno profile and in this case it worked for me
and you can see now I can change directory to fc
um and sc password. So I have a whole lot more functionality than I did uh in this our bash shell, that's how to escape in our bash shell is to try this tactic. E bash no profile. Sometimes it works. Sometimes it doesn't, but this is a total put in your toolbar.
Um Also here you'll see that
and you can see I'm issuing commands and I don't get any output. I don't see anything.
So what I want to do is I want to upgrade
um to aim interpreter, shelf possible. Multi handler. Like I said multi handler. When I recorded this, when I'm recording this now, you can use multi handler on any box you want.
So that's what I typically do is that once I have a PHP shell, normally through a web shell or I get are see through a web server
is I'll get on the box of the net cat shell and then I will download, you'll see curl and w get which you should recognize as ways to get the shell from my box and I'm making it execute herbal
and ultimately I am executing this this shell dot elf, which is something that I created with MSF venom.
So if you're on Lenox box, you can use MSF venom to create this L file and ultimately have it executed. You see here now I have a nice interpreter session open.
So here's a cheat sheet. If you do get on a box and you do see have limited functionality, you can do this python import pt Why that's importing basically having python
this library and in this language to create its own shell, which is very stable. I found echo O. S system
bin bash or even been shell in some cases and Ben, s. H. Tak I
so give those a try if you don't see anything if you're on the box and you don't see any type of
prompt. Um give the each other to try.
Also note that with python, sometimes it's python three and not python that will work because the box will only recognize when you write python three.
So also no, like I said, sometimes it's not been S H talk, I sometimes been bashed, acai or Echo? S system been shell that will work. So switch this around. And and sometimes it's I think in more modern boxes, user bin bash is a link to bin bash.
But in some of these older boxes, I think they were different. So try to try to switch them up.
Sometimes the binaries are for the user and not just in bin bash. So look for those as well. There there could be other places where that binary is that will that will work for you.
So here's a tale of two terminals
on the left. I'm doing the dirty cow exploit
and you'll see on the left, I don't see any output. And I was just sitting there says in a new password, evil, I entered evil.
And it's just sitting there.
And that's what I also said with like uh these exploits, I have gcc I'm trying to compile it. P thread decal output, decal. L crypt. That was a nice script because it told me how to how to compile that exploit. But ultimately I'm just sitting there because I have a bad shell
on the right hand side. I'm using that python, taxi import peat. Ey.
So I have that python nice python shell and you can see all this output and at the end I password, evil, fire farts. The guy that made the exploits. So that's why it's fire fart.
But you'll see ultimately I'm route.
So using using that upgrade ultimately led me to privilege escalation. Whereas if I didn't do that, I'm just sitting there indefinitely and hoping that somehow I become
here is a link. I suggest you take a look at it.
Ways to upgrade your shell. I will note that the author wrapped up
does have a portion that you can upgrade shells with magic and it's really, it really is cool and it's worked for me some of the time
that's to say sometimes I completely wrecked my terminal and I have no idea what's going on and I ultimately have to close it and I've lost that foothold. And when you're taking over SCP, you're you're nervous enough. Um and if your shell, if you if you have to exit out of your shell or exit of your terminal, you know, that's like very, very, very nerve wracking. So
that's to say, be careful with his upgrade with magic technique because it's very possible that it may not work for you.
So, I know when I took over SCP, I didn't use it when I was in fact the box and things like that, I was more than happy to give it a try
and see that it worked when it did. It was really cool because I attacked completion and I could hit the up arrow for history and it was very, very useful.
So use that at your discretion.
So in summary, we should now understand why we try to upgrade a shell and we should be able to demonstrate the various ways to upgrade a shell.