Kali Linux Penetration Testing Bible. Gus Khawaja
Читать онлайн книгу.sys : This is similar to /dev , which contains configurations about devices and drivers.
/ etc (etcetera): This directory contains all the administration system files (e.g., /etc/passwd shows all the system users in Kali).
/ lib (libraries): This directory contains the shared libraries for the binaries inside /bin and /sbin .
/ proc (processes): This directory holds the processes and kernel information files.
/ lost+found : As the name says, this directory contains the files that have been recovered.
/ mnt (mount): This directory contains the mounted directories (e.g., a remote file share).
/ media : This directory holds the removable media mounted directories (e.g., DVD).
/ opt (option): This directory is used for add‐on software package installation. Also, it is used when installing software by users (e.g., hacking tools that you download from GitHub).
/ tmp (temporary): This is a temporary folder used temporarily; the contents are wiped after each reboot. The tmp folder is a good place to download your tools for privilege escalation once you get a limited shell.
/ usr (user): This directory contains many subdirectories. In fact, /usr/share is a folder that you need to memorize because most of the tools that you use in Kali Linux (e.g., Nmap, Metasploit, etc.) are stored there, and it contains the wordlists dictionary files ( /usr/share/wordlists/ ).
/ home : This is the home for Kali Linux users (e.g., /home/john/ ).
/ root : This is the root user home directory.
/ srv (serve): This folder holds some data related to system server functionalities (e.g., data for FTP servers).
/ var (variable): This folder holds variable data for databases, logs, and websites. For example, /var/www/html/ contains the files for the Apache web server.
/ run (runtime): This directory contains runtime system data (e.g., currently logged‐in users).
Terminal Window Basic Commands
There are lots of common commands that we use as penetration testers on a daily basis. Many of these commands will be listed in the upcoming sections or later in this book. In this section, you will see all the general standard tools that I personally use frequently. You will also learn the basic commands that are identified for general use.
First, to open the terminal window from the desktop, you can use the Ctrl+Alt+T key combination instead of opening the application from its icon using the mouse cursor.
If you want to get help for any command that you want to execute, just append ‐h
or ‐ ‐ help
to it (some commands require you to use only one of them). For example, if you want to see the different options for the cat
command, just type cat ‐‐help
in your terminal window to get all the help needed regarding this tool. In the next command ( cat ‐h
), you'll see that the ‐h
option does not work for the cat
command. Instead, I used the ‐ ‐help
option. (The cat
command is used frequently to display the contents of a text file in the terminal window.)
kali@kali:~$ cat -h cat: invalid option -- 'h' Try 'cat --help' for more information. kali@kali:~$ cat --help Usage: cat [OPTION]… [FILE]… Concatenate FILE(s) to standard output. With no FILE, or when FILE is -, read standard input. -A, --show-all equivalent to -vET -b, --number-nonblank number nonempty output lines, overrides -n -e equivalent to -vE -E, --show-ends display $ at end of each line -n, --number number all output lines -s, --squeeze-blank suppress repeated empty output lines -t equivalent to -vT -T, --show-tabs display TAB characters as ^I -u (ignored) -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB --help display this help and exit --version output version information and exit Examples: cat f - g Output f's contents, then standard input, then g's contents. cat Copy standard input to standard output. GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Full documentation at: <https://www.gnu.org/software/coreutils/cat> or available locally via: info '(coreutils) cat invocation'
To clear the terminal window text, execute the clear
command or press Ctrl+L to get the job done.
To open a new terminal window tab, from your current terminal session press Ctrl+Shift+T.
To complete the input (e.g., a filename or a command name) automatically, I use the Tab key. What if multiple files start with the same text? Then, if you hit Tab twice, the terminal window will display all the options in place. (The best way to understand this chapter is to open the terminal window and practice while reading the instructions.)
Let's look at an example. In my home directory, I have two files, test.sh
and test.txt
. Once I start typing cat tes
, I hit Tab once, and it shows me cat test.
. This means I have multiple files with the same name. Then I hit Tab twice, and it shows me the list of files in the current directory. Finally, I can open the desired file, which is test.txt
:
root@kali:~# cat test. Test.sh test.txt root@kali:~ cat test.txt test
To stop the execution of any tool while it's running, you can use the Ctrl+C shortcut to stop it.
To exit the terminal window and close it, use the exit
command or press Ctrl+D to get the job done.
To restart Kali Linux from the terminal window, you must use the reboot
command, and to shut it down, you must use the poweroff
command.
Now, to get the list of executed recent commands, you'll have to use the history
command.
In Linux, you must understand that we use a lot of redirection in the terminal window. For example, to save the output of the ls
command into a file, I can redirect the output from the terminal window to a text file using the >
(greater than) character:
kali@kali:~$ ls> ls_file.txt kali@kali:~$ cat ls_file.txt Desktop Documents Downloads ls_file.txt Music Pictures Public Templates Videos
Now, you can do the opposite by redirecting (printing) the text file contents into the terminal window using the <
(less than) character:
kali@kali:~$ cat < ls_file.txt Desktop Documents Downloads ls_file.txt Music Pictures Public Templates Videos
Another redirection that you need to be aware of is the commands pipe. In summary, you can combine the output of each command and send it to the next one using the |
character:
$command 1 | command2 | command3 …
For example, I will read a file, then sort the results, and finally use the grep
command to filter out some text strings (the goal is to extract the files that start with the word test):
kali@kali:~$ cat ls_file.txt | sort | grep test test.sh test.txt
Tmux Terminal Window
Tmux is a particular terminal window that allows you to manage multiple windows in your current terminal session. The best way to explain it is through examples.
Starting Tmux
To start Tmux, you just type Tmux
in your terminal window. At the bottom of your terminal window, you'll notice that a number and a name have been assigned to your opened window tab, as shown in Figure 1.1.