Who, What, When, Where and How of the Linux Command Line
21 hours 43 minutes
the who what when where and how the Lennox command line.
So in this lesson we'll learn the who what when where and how the Lennox command line and why did I break this lesson out into who? What when where who what when where and how. It's because when I was a police officer um and I would have to write a report. My training officers would say well if you want to cover everything
make sure you cover the who what when where why? Which we don't
why why are we here? What we're here to pass the Osc. P. And how um in your reports you cover everything. So hopefully I will cover as much as I can
in this. You know it's impossible to cover everything within the command line in one lesson. But hopefully I can cover this with these different who what when where and how tags in them. So you can remember more about the command line. So who who am I? You'll see this in some I. T. Or tech conferences.
Someone will put up who am I on the board? Well, it's a command in the Lenox terminal. It's also a command on Windows. It works on either. That's why I really like this command because if I'm a new rating system and I do, who am I? Um Hopefully we'll come back with either system or route because it will work on either Lennox or or Windows. I. D. Will only work on Lenox. It displays your user. Uh And what groups you're in? Maybe you're in the doctor groups. It will say that when you do the I. D. Command,
you name that Prince, the operating system, you name Space tack. A will show all the information. This is a great one to use to see if that operating system has a kernel exploit for it.
What So what can I do? Can you run something as the root user? Sudo space tack. L will list all the commands that you can perform as the root user. Maybe you'll do that and it will say, you know, you can perform bin bash as as the root user. Then you just simply have to run that command as with pseudo.
And you're the root user.
Easy privilege escalation day
I. D. When you do that command normally you'll see Zero is the root user If you C zero. That's really, really good. If you see 1000, it's normally the first user that's been registered on that box. Um If you see below that, it may be a service on that box. Maybe you're dub Dub. Dub data. Maybe you're a demon or Damon. I don't know either one. Um That will just tell you the number of that service or user
What is in a file. Cat will show you everything in the file strings. Maybe you're looking at a binary and you just want to see the printable characters in the binary strings. And then that binary name will show you all the printable characters. Head shows the 1st 10 lines, tail will show the last 10 lines in a file. You can change that with the head and tail command. Of course, you can figure that out.
Looking at the man page, right? We learned about that. What permissions do you have? So there are three permission groups owner uh the group and the users. Um And you'll see things like our W. X. Like we talked about globally readable and writable files.
Here's a globally readable and writable directory with the D. All the way at the left hand side.
If you saw it wouldn't have the D. But the password file has R. W. X. R W X, R D W exits globally. Readable. Writable execute Herbal. That's good for us. That's bad for that. That host,
what is running
PS space AUX will print all the running processes from all the users on that box
when So the Cron tab or Cron jobs that are running. So this is important also for privilege escalation. Maybe you look at all the Cron jobs and one is running as root, but you can write to it as an unprivileged user. You can then, you know, maybe change that Cron job
so that it executes as root, but it makes you the root user or you can do a reverse shell with it.
Um So that's also an important one for privilege escalation.
Where so where are we? Ls will show all the files in that directory.
Also also show other directories. Ls I usually do space tack, L, A or a. L. Doesn't matter. As long as the letters A and L. Are in their uh will show you the long format. It will show you, you know, if it's readable and writable and who can read and write to that file For permissions. PWd print working directory.
That will show you which directory you're in. That's also good because if I get into a box, one of the first commands all runs PWD to figure out where am I on that box?
Find. That's also an important It's also important command because what if I want to find the flag, maybe I know the name of the of the flag document is flagged at txt.
Um For that capture the flag, I'll do fine forward slash name. Flag dot txt. Um to greater than dev null. That just writes some output to knoll so that you know maybe you're you're searching a directory but it says permission denied.
If you do that to greater than dev null it won't print that. It will just print what what it finds
where is locates programs that you don't know where python is on that box you do. Whereas python I should tell you where it is.
Apropo I propose um that can help you find different commands. So maybe I'm looking for all the commands that can help me search for something. I can do a proposed search and it should show me all the commands that I could run to search for different things
grip, grip just searches for different words in a file. Um This is something that I may use as well grip. Uh attack R. N. W. Four slash pastor looks for all the different passwords you see to greater than Devono again there so I just see the output that where it finds something. Um This can be very verbose though
because you're looking for everything that has the word password in it.
so it's very important to know what commands are using and what they do. So when you're getting onto a box usually going to get a shell and you need to know what commands you've you've issued and also you need to know
why you're doing it. So enumeration. People always say you know the key to escape
is enumeration. Enumeration. Enumeration. You need to know how you found that vulnerable binary or that vulnerable file or that you had different sudo permissions. So make sure you document how you achieve privilege escalation or where you found certain files um when you're writing your report.
So in summary we learned the who, what, when, where and how of the Lennox command line