Kali Linux Penetration Testing Bible. Gus Khawaja
Чтение книги онлайн.
Читать онлайн книгу Kali Linux Penetration Testing Bible - Gus Khawaja страница 13
Figure 1.3 Tmux Vertical Windows Side by Side
Navigating Inside Tmux
Amazing, right? As you can see, the cursor is on the right pane (see Figure 1.3). To switch between panes (subwindows), press Ctrl+B and use the arrow keys on your keyboard (to change left, right, up, and bottom).
Next, go back to the Window1 session. To switch between windows, press Ctrl+B and then the number of the window (which is 0 according to this example), and we should be back to the first window.
Now, divide the window into two sections, one over the other, as shown in Figure 1.4. To get this done, use Ctrl+B and then the double quote (“). Remember that you need to press Shift+“ or else that key produces a single quote.
Figure 1.4 Tmux Horizontal Windows
The final tip for managing Tmux is for scrolling up and down inside a window or a pane session. In fact, you can't use your mouse to scroll up and down in a Tmux session (the mouse scrolling is for commands history). Instead, you need to press Ctrl+B and then [ on your keyboard, and after that you can use the up and down arrow keys on your keyboard to scroll. Once you're done with the scrolling, press Esc or the Q key on your keyboard to go back to the normal mode.
To close a pane or a window, just use exit
like with any regular terminal window session.
Tmux Commands Reference
Table 1.1 summarizes all the Tmux commands that you learned in this section. You can use it as a reference (this is just a quick guide so you can start using Tmux; if you want to go beyond basics, check the manual reference).
Table 1.1 Tmux Keyboard Shortcuts
DESCRIPTION | COMMAND |
---|---|
To rename a window | Ctrl+B+, |
To open a new window | Ctrl+B+C |
To split windows vertically | Ctrl+B+% |
To split windows horizontally | Ctrl+B+" |
To navigate subwindows | Ctrl+B+Left Arrow, Ctrl+B+Right Arrow |
To switch between windows | Ctrl+B+[window number] |
To scroll up | Ctrl+B+[+Up Arrow |
To scroll down | Ctrl+B+[+Down Arrow |
To escape the scrolling mode | Esc |
To close a pane/window | Type exit (inside it) |
Managing Users and Groups in Kali
Understanding the commands for managing users and groups is important because you'll use the information when you learn about privilege escalation later in the book. All the commands in this chapter will help you a lot in your engagements while using Kali Linux (as an OS for your pentests).
Figure 1.5 summarizes all the commands related to users' management/security in Kali Linux.
Users Commands
Low‐privilege users must prepend commands with sudo
to execute system commands (and the low‐privilege user must be in the sudo
group to execute sudo
). You will be asked for your account password if you want to use the sudo
command. For example, if you want to execute the fdisk
system tool to show the Kali‐attached devices, use the following command:
root@kali:~# fdisk -l Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x7c02676c Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 165771263 165769216 79G 83 Linux /dev/sda2 165773310 167770111 1996802 975M 5 Extended /dev/sda5 165773312 167770111 1996800 975M 82 Linux swap / Solaris
Figure 1.5 Kali Linux OS Security Commands
To add a new user to Kali (in this example, Gus is going to be the user), use the useradd
command. Along with it you need to choose the sudo
group with the ‐G
option and the shell type with the ‐s
option:
$useradd -m [user name] -G [group name] -s [shell type]
For our example, it looks like this:
root@kali:~# useradd -m Gus -G sudo -s /bin/bash
Next, let's give the new user a password using the passwd
command:
$passwd [user name - that you want to change password]
Here's how it looks in the terminal window:
root@kali:~# passwd Gus New password: Retype new password: passwd: password updated successfully
If you look closely at the top left, it's written root@kali
; I know that this is confusing, but the structure of this part is in the following format:
username@hostname
To switch to the new user Gus that we created previously, we use the su
command (pay attention to how the user has changed in the terminal window text and turned into Gus@kali
):
$su [user name – that you want to switch to] root@kali:~# su Gus Gus@kali:/root$
To learn the capabilities of the current user with the sudo
command, you need to execute sudo ‐l
to get the correct information:
Gus@kali:~$ sudo -l We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for Gus: Matching Defaults entries for Gus on kali: env_reset, mail_badpass,