Kali Linux Penetration Testing Bible. Gus Khawaja

Чтение книги онлайн.

Читать онлайн книгу Kali Linux Penetration Testing Bible - Gus Khawaja страница 14

Kali Linux Penetration Testing Bible - Gus Khawaja

Скачать книгу

User Gus may run the following commands on kali: (ALL : ALL) ALL

      To view the current user information, use the id command:

      Gus@kali:~$ id uid=1001(Gus) gid=1001(Gus) groups=1001(Gus),27(sudo)

      To list the currently logged on users, use w or who (with fewer details):

      To remove a user (the user that we will remove in this example is test ), execute the userdel command:

      $userdel [user name – that you want to delete] Gus@kali:~$ sudo userdel test

      To list the last logged in users in the Kali system, use the last command:

      Gus@kali:~$ last root tty7 :0 Tue Sep 22 10:24 still logged in reboot system boot 5.7.0-kali1-amd6 Tue Sep 22 10:24 still running root tty8 :1 Tue Sep 22 10:21 - 10:23 (00:02) kali pts/1 tmux(1793).%0 Mon Sep 21 12:16 - 10:23 (22:07) kali pts/2 tmux(1584).%0 Mon Sep 21 11:48 - 11:48 (00:00) kali tty7 :0 Mon Sep 21 10:50 - 10:23 (23:33) reboot system boot 5.7.0-kali1-amd6 Mon Sep 21 10:50 - 10:23 (23:33) kali tty7 :0 Mon Jul 27 13:36 - 15:56 (02:20) reboot system boot 5.7.0-kali1-amd6 Mon Jul 27 13:36 - 15:57 (02:20) kali tty7 :0 Mon Jul 27 13:31 - crash (00:05) reboot system boot 5.7.0-kali1-amd6 Mon Jul 27 13:30 - 15:57 (02:26) kali tty7 :0 Mon Jul 27 13:28 - crash (00:02) reboot system boot 5.7.0-kali1-amd6 Mon Jul 27 13:28 - 15:57 (02:28) wtmp begins Mon Jul 27 13:28:09 2020

      Finally, take note that all the users in Kali are stored in a configuration file, /etc/passwd . Use the cat command to reveal its contents:

      Gus@kali:~$ cat /etc/passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin

      The previous command will list all the users, even the system ones (the example just shows the first three). To filter the contents and limit the results for the human users, pipe the output using | in the grep command:

      Groups Commands

      To add a new group in Kali Linux, use the groupadd command:

      $groupadd [new group name] Gus@kali:~$ sudo groupadd hackers

      To join a user (which is Gus for this example) to the hackers group that we created earlier, execute the usermod command:

      $usermod -aG [group name] [user name] Gus@kali:~$ sudo usermod -aG hackers Gus

      To list all the groups created in Kali Linux, open the file /etc/group . Again, use the cat command to get the job done (the following example shows only the first three):

      Gus@kali:~$ cat /etc/group root:x:0: daemon:x:1: bin:x:2: […] hackers:x:1002:Gus

      Managing Passwords in Kali

      You probably want your root user back like in the old days. To get this account back, you will need to set its password first. To change a user password, you have to use the passwd command:

      Gus@kali:~$ sudo passwd root New password: Retype new password: passwd: password updated successfully

      Now to use the powerful root account, you have to use the su command to switch user:

      From now on, on the login screen, you can choose your root account instead of your nonroot user.

      Finally, to list all the user's credentials in Kali Linux, you can reveal them in the file /etc/shadow . Use the grep command to get the user credentials for Gus:

      root@kali:/# cat /etc/shadow | grep "Gus" Gus:$6$Hb.QBfIoaCBTiqK$EUJ4ZdWmbsFqHMsPbMEz2df6FtWVf4J/tMulxCoLQmfMlVWyqpMUHBGmHFulRknYHgSrFIF.hQTANgzJ6CQM8/:18527:0:99999:7:::

      Let's simplify what you need to understand from the string. The delimiter that separates each section is the colon character (:).

      Second, the $6$ means that the password is hashed using SHA‐512. Finally, the hashed password starts after $6$ and right before the : delimiter:

      Hb.QBfIoaCBTiqK$EUJ4ZdWmbsFqHMsPbMEz2df6FtWVf4J/tMulxCoLQmfMlVWyqpMUHBGmHFulRknYHgSrFIF.hQTANgzJ6CQM8/

      Your next challenge in the Linux operating system is to learn how to manage files and folders. By the end of this section, you will start using the files and directories on Kali like the pros.

      Displaying Files and Folders

      To list the files and subfolders inside any directory, use the ls command to get the job done (I use it a lot to get simpler output). But sometimes, the ls command by itself is not enough, so you may need to add a couple of options to get better output clarity. The first option that you can use is the ‐a command (all contents including hidden files), and the second option is the ‐l command (formatted list):

      Take note that filenames that start with a dot character before their names mean that they are hidden (e.g., .bash_history ). Also, at the far left before the permissions, the letter d means it's a directory and not a file. Finally, you can list another directory's contents differently than the current one by specifying the path of the destination folder:

      $ls -la [destination directory path]

      Permissions

      For

Скачать книгу