Using
sudo - Kali Linux Revealed

Using
sudo
to access
Administrative Privileges
The
sudo
(super user do) command allows privileged users to run commands with
administrative permissions. This gives full access to items that may be restricted to
only the root user, such as programs in
/sbin/
or access to network options that are
useful for common penetration testing tools.
The command takes one argument, being the subsequent command that will be run
with administrative permissions. One useful use case when dealing with services is to
elevate to the root user account. To elevate to root user, we will use the command
su
(substitute user) to create a shell under the root user. The substitute user command
takes a user account as an argument. Additionally, the
su
command has a useful flag (
--login, or -l, or -) to use the substituted user’s login environment. Multiple commands
in the following chapter require the use of
sudo
, as such we will elevate to the root
user to seamlessly execute these commands.
$ sudo su --login
[sudo] password for kali:
root@kali:~#
Each network device managed by ifupdown can be deconfigured at any time with
ifdown
network-device
. You can then modify
/etc/network/interfaces
and bring the network back
up (with the new configuration) with
ifup network-device
.
Let’s take a look at what we can put in ifupdown’s configuration file. There are two main directives:
auto
network-device
, which tells ifupdown to automatically configure the network interface once it
is available, and iface
network-device inet/inet6 type
to configure a given interface. For example,
a plain DHCP configuration looks like this:
auto lo
109
Chapter 5 — Configuring Kali Linux
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
Note that the special configuration for the loopback device should always be present in this file.
For a fixed IP address configuration, you have to provide more details such as the IP address, the
network, and the IP of the gateway:
auto eth0
iface eth0 inet static
address 192.168.0.3
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0
gateway 192.168.0.1
For wireless interfaces, you must have the wpasupplicant package (included in Kali by default),
which provides many wpa-* options that can be used in
/etc/network/interfaces
. Have a look
at
/usr/share/doc/wpasupplicant/README.Debian.gz
for examples and explanations. The
most common options are wpa-ssid (which defines the name of the wireless network to join) and
wpa-psk (which defines the passphrase or the key protecting the network).
iface wlan0 inet dhcp
wpa-ssid MyNetWork
wpa-psk plaintextsecret
5.1.3. On the Command Line with
systemd-networkd
While ifupdown is the historical tool used by Debian and Kali, and while it is still the default for
minimal installations, there is a newer tool worth considering: systemd-networkd. Its integration
with the systemd init system makes it a very attractive choice. It is not specific to Debian-based
distributions (contrary to ifupdown) and has been designed to be very small, efficient, and rela-
tively easy to configure if you understand the syntax of systemd unit files. This is an especially
attractive choice if you consider NetworkManager bloated and hard to configure.
You configure
systemd-networkd
by placing
.network
files into the
/etc/systemd/network/
directory. Alternatively, you can use
/lib/systemd/network/
for packaged files or
/run/
systemd/network/
for files generated at run-time. The format of those files is documented in
systemd.network(5)
(see section
6.1.1
, “
Manual Pages
” [page 128]). The [Match] section indi-
cates the network interfaces the configuration applies to. You can specify the interface in many
ways, including by media access control (MAC) address or device type. The [Network] section
defines the network configuration.
110
Kali Linux Revealed
|