An overview of the LPIC-3 certification, outlining the scope and objectives of the security-related topics covered.
Details on the versions of the certification exams and any relevant updates or changes.
Information on how the objectives are translated into various languages to support a global audience.
331.1 X.509 Certificates and Public Key Infrastructures (weight: 5)
331.2 X.509 Certificates for Encryption, Signing, and Authentication (weight: 4)
331.3 Encrypted File Systems (weight: 3)
331.4 DNS and Cryptography (weight: 5)
332.1 Host Hardening (weight: 5)
332.2 Host Intrusion Detection (weight: 5)
332.3 Resource Control (weight: 3)
333.1 Discretionary Access Control (weight: 3)
333.2 Mandatory Access Control (weight: 5)
334.1 Network Hardening (weight: 4)
334.2 Network Intrusion Detection (weight: 4)
334.3 Packet Filtering (weight: 5)
334.4 Virtual Private Networks (weight: 4)
335.1 Common Security Vulnerabilities and Threats (weight: 2)
335.2 Penetration Testing (weight: 3)
1. X.509 Certificates
Structure and Fields:
X.509v3 Extensions:
2. Trust Chains and PKI
Trust Chains:
Certificate Transparency:
3. Generating and Managing Keys
Private Key Generation:
openssl genpkey -algorithm RSA -out private.key -aes256
Public Key Extraction:
openssl rsa -pubout -in private.key -out public.key
Key Management:
4. Certification Authority (CA)
Creating a CA:
openssl genpkey -algorithm RSA -out ca.key -aes256
openssl req -x509 -new -nodes -key ca.key -sha256 -out ca.crt -days 3650
Issuing Certificates:
openssl req -new -key server.key -out server.csr
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365
5. Certificate Management
Renewing Certificates:
openssl req -new -key server.key -out server_new.csr
openssl x509 -req -in server_new.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server_new.crt -days 365
Revoking Certificates:
openssl ca -revoke server.crt
openssl ca -gencrl -out crl.pem
6. Using Let’s Encrypt and Certbot
Install Certbot:
sudo apt-get install certbot
sudo yum install certbot
Obtain and Install Certificate:
sudo certbot --apache
Renew Certificates Automatically:
sudo certbot renew
7. Using CFSSL
Install CFSSL:
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
chmod +x cfssl_linux-amd64
sudo mv cfssl_linux-amd64 /usr/local/bin/cfssl
Generate CA Certificate:
cfssl genkey -initca csr.json | cfssljson -bare ca
Sign a Certificate:
cfssl sign -ca ca.pem -ca-key ca-key.pem -config ca-config.json -profile server csr.json | cfssljson -bare server
8. Key Commands and Files
PEM (Privacy-Enhanced Mail): Common format for certificates and private keys.
DER (Distinguished Encoding Rules): Binary format for certificates.
PKCS12: Standard for storing private keys and certificates in a single file.
OpenSSL Configuration Files:
openssl.cnf
: Configuration file defining settings for certificates, CAs, and requests.Example Files:
server.csr
server.key
server.crt
crl.pem
Description:
This topic focuses on using X.509 certificates for server and client authentication in Apache HTTPD, specifically version 2.4 or higher. The goal is to understand SSL/TLS protocols, configure Apache HTTPD for secure communication, and use OpenSSL for testing.
SSL (Secure Sockets Layer): An older protocol for securing communications. SSL 2.0 and 3.0 are now considered obsolete and insecure.
TLS (Transport Layer Security): The successor to SSL, with more secure versions:
Ciphers: Algorithms used to encrypt data. They can be classified as:
Configuration Example:
To set up TLS in Apache HTTPD and define cipher suites, add the following to httpd.conf
or a virtual host configuration file:
# Enable SSL/TLS
LoadModule ssl_module modules/mod_ssl.so
# Enable HTTPS
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/path/to/server.crt"
SSLCertificateKeyFile "/path/to/server.key"
SSLCertificateChainFile "/path/to/chain.crt"
# Protocols
SSLProtocol all -SSLv2 -SSLv3
# Cipher suites
SSLCipherSuite HIGH:!aNULL:!MD5
# Server Name Indication (SNI)
ServerName example.com
# HTTP Strict Transport Security (HSTS)
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# DocumentRoot and other configurations
DocumentRoot "/var/www/html"
</VirtualHost>
Installation:
Ensure mod_ssl
is installed. On Debian/Ubuntu:
sudo apt-get install apache2
sudo apt-get install libapache2-mod-ssl
On Red Hat/CentOS:
sudo yum install httpd
sudo yum install mod_ssl
Configuration:
Enable SSL Module:
sudo a2enmod ssl
Configure HTTPS:
In the httpd.conf
or /etc/apache2/sites-available/default-ssl.conf
file:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
SSLCertificateChainFile /etc/ssl/certs/chain.crt
# HSTS
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# SNI
ServerName example.com
</VirtualHost>
Reload Apache Configuration:
sudo systemctl reload apache2
Server Authentication:
Configure Apache to use client certificates for server authentication by adding:
SSLCACertificateFile /path/to/ca.crt
SSLVerifyClient require
SSLVerifyDepth 1
Client Authentication:
Configure Apache to require client certificates for certain directories:
<Directory "/var/www/html/secure">
SSLRequireSSL
SSLVerifyClient require
SSLVerifyDepth 1
Require valid-user
</Directory>
Overview: Online Certificate Status Protocol (OCSP) stapling improves certificate revocation checking performance by attaching the OCSP response to the SSL/TLS handshake.
Configuration Example:
Add the following directives to your Apache configuration:
SSLUseStapling on
SSLStaplingCache "shmcb:/var/run/ocsp(128000)"
Check OCSP Status:
Use OpenSSL to verify OCSP responses:
openssl s_client -connect example.com:443 -status
Testing Server Configuration:
openssl s_client -connect example.com:443
Testing Cipher Suites:
openssl s_client -connect example.com:443 -cipher 'AES256-SHA'
Checking Certificate Details:
openssl x509 -in server.crt -text -noout
Generating a Self-Signed Certificate (for testing):
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout test.key -out test.crt
Files:
server.crt
server.key
chain.crt
server.csr
ocsp
Description:
This topic involves setting up and configuring encrypted file systems using various tools and technologies. Candidates should be familiar with block device encryption, file system encryption, and relevant utilities for implementing encryption in a Linux environment.
Block Device Encryption:
dm-crypt
, LUKS
.File System Encryption:
eCryptfs
.dm-crypt: A kernel module that provides disk encryption using the device mapper framework.
LUKS (Linux Unified Key Setup): A standard for disk encryption that works with dm-crypt
. Provides a key management framework and support for multiple keys.
Basic Commands and Configuration:
Install cryptsetup
:
sudo apt-get install cryptsetup
Create a LUKS-encrypted Partition:
sudo cryptsetup luksFormat /dev/sdX
Open an Encrypted Partition:
sudo cryptsetup open /dev/sdX my_encrypted_partition
Format the Encrypted Partition:
sudo mkfs.ext4 /dev/mapper/my_encrypted_partition
Close the Encrypted Partition:
sudo cryptsetup close my_encrypted_partition
Add to /etc/crypttab
for Automatic Mounting:
my_encrypted_partition /dev/sdX none luks
Mounting:
sudo mount /dev/mapper/my_encrypted_partition /mnt
LUKS2 Features:
sudo cryptsetup convert --type luks2 /dev/sdX
Basic Commands and Configuration:
Install ecryptfs-utils
:
sudo apt-get install ecryptfs-utils
Mount an Encrypted Directory:
sudo mount -t ecryptfs /home/user/encrypted /home/user/decrypted
Setup Encrypted Home Directory:
ecryptfs-setup-private
Mounting and Unmounting:
mount.ecryptfs /home/user/encrypted /home/user/decrypted
umount.ecryptfs /home/user/decrypted
PAM Integration:
To integrate with PAM for automatic mounting during login, add the following to /etc/pam.d/common-auth
:
auth optional pam_ecryptfs.so
dm-crypt
.Basic Commands and Configuration:
Create a Plain dm-crypt Device:
sudo cryptsetup create my_plain /dev/sdX
Format and Mount:
sudo mkfs.ext4 /dev/mapper/my_plain
sudo mount /dev/mapper/my_plain /mnt
Close the Device:
sudo cryptsetup remove my_plain
Basic Commands and Configuration:
Install Clevis:
sudo apt-get install clevis
Add a TPM2 PIN:
sudo clevis luks bind -d /dev/sdX tpm2 '{"pcr_ids":"0,1"}'
Add a Network Binding (Tang server):
sudo clevis luks bind -d /dev/sdX tang '{"url":"http://tang-server.example.com"}'
List Bindings:
sudo clevis luks list -d /dev/sdX
cryptsetup
: Command-line utility for managing LUKS and dm-crypt.cryptmount
: Utility for managing encrypted file systems./etc/crypttab
: Configuration file for automatic unlocking of encrypted partitions.ecryptfs-utils
: Utilities for managing eCryptfs.ecryptfsd
: Daemon for managing eCryptfs mounts.ecryptfs-*
commands: Utilities related to eCryptfs, such as ecryptfs-add-passphrase
, ecryptfs-setup-private
.pam_ecryptfs
: PAM module for integrating eCryptfs with authentication.DNS Concepts:
DNSSEC (Domain Name System Security Extensions):
Install BIND:
sudo apt-get install bind9
BIND Configuration Files:
named.conf
: Main configuration file for BIND.named.conf.options
: Configuration options for BIND.named.conf.local
: Local zone and record configurations.Configure DNSSEC:
a. Generate Keys:
dnssec-keygen -a RSA/SHA256 -b 2048 -n ZONE example.com
dnssec-keygen -a RSA/SHA256 -b 2048 -n ZONE -f KSK example.com
b. Sign the Zone:
dnssec-signzone -A -3 -o example.com -k Kexample.com.+008+12345 example.com.zone
c. Update Zone Files:
Add the generated DS records to the parent zone and update your zone files with the signed data.
d. Key Rollover:
dnssec-keygen -a RSA/SHA256 -b 2048 -n ZONE example.com
dnssec-signzone -A -o example.com -k Kexample.com.+008+12346 example.com.zone
e. Re-sign Zones:
dnssec-signzone -o example.com -K /path/to/keys example.com.zone
Configure BIND for DNSSEC Validation:
a. Update named.conf.options
:
options {
dnssec-validation auto;
...
};
b. Restart BIND:
sudo systemctl restart bind9
CAA (Certification Authority Authorization):
example.com. IN CAA 0 issue "letsencrypt.org"
DANE (DNS-Based Authentication of Named Entities):
_443._tcp.example.com. IN TLSA 3 1 1 <certificate_hash>
TSIG (Transaction Signature):
named.conf
:key "tsig-key" {
algorithm hmac-md5;
secret "base64-encoded-key";
};
server 192.0.2.1 {
keys { "tsig-key"; };
};
DNS over TLS (DoT) and DNS over HTTPS (DoH):
stubby
for DoT, dnsdist
for DoH).Multicast DNS (mDNS):
named.conf
: Main BIND configuration file.dnssec-keygen
: Generates DNSSEC keys.dnssec-signzone
: Signs DNS zone files.dnssec-settime
: Adjusts DNSSEC key lifetimes.dnssec-dsfromkey
: Generates DS records from DNSKEY records.rndc
: Command-line utility for managing BIND.dig
: DNS lookup utility.delv
: DNSSEC verification utility.openssl
: Provides tools for generating and managing certificates.Description:
Candidates should be adept at securing Linux systems against common threats through a variety of techniques, including configuring boot loader security, managing services, and implementing security features in systemd. This section focuses on ensuring that systems are hardened against potential attacks.
BIOS Security:
GRUB 2 Security:
Password Protect GRUB:
/etc/grub.d/40_custom
to add:set superusers="admin"
password_pbkdf2 admin $(grub-mkpasswd-pbkdf2)
sudo update-grub
Disable Unnecessary Features:
List Active Services:
systemctl list-units --type=service
Disable Unnecessary Services:
sudo systemctl disable <service>
Remove Unnecessary Packages:
sudo apt-get remove --purge <package>
List Capabilities:
getcap -r / | grep <binary>
Drop Capabilities:
Edit unit file (e.g., /etc/systemd/system/myapp.service
):
[Service]
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
Reload systemd configuration:
sudo systemctl daemon-reload
Configure ASLR:
sysctl -w kernel.randomize_va_space=2
/etc/sysctl.conf
:kernel.randomize_va_space=2
DEP and Exec-Shield:
/etc/sysctl.conf
:kernel.exec-shield=1
Install USBGuard:
sudo apt-get install usbguard
Configure USBGuard:
Edit /etc/usbguard/usbguard-daemon.conf
to enable the service:
[Daemon]
AllowUsbDevices=true
Define rules in /etc/usbguard/rules.conf
:
allow id:1234:5678
Reload USBGuard rules:
sudo systemctl restart usbguard
Generate CA Key:
ssh-keygen -f /etc/ssh/ssh_ca -t rsa -b 4096
Create Host Certificate:
ssh-keygen -s /etc/ssh/ssh_ca -I host_key -h -n <hostname> -V +52w /etc/ssh/ssh_host_rsa_key.pub
Configure OpenSSH:
/etc/ssh/sshd_config
:TrustedUserCAKeys /etc/ssh/ssh_ca.pub
Create a chroot Environment:
sudo mkdir -p /var/chroot/{bin,etc,lib,lib64,usr}
Copy Required Binaries and Libraries:
sudo cp /bin/bash /var/chroot/bin/
Setup chroot:
sudo chroot /var/chroot /bin/bash
Limit System Calls:
/etc/systemd/system/myapp.service
):[Service]
SystemCallFilter=~@clock
Limit File and Device Access:
[Service]
ProtectSystem=yes
ProtectHome=yes
Dedicated Temporary and /dev Directories:
[Service]
ReadOnlyPaths=/dev
Disable Network Access:
[Service]
NetworkNamespaceMode=none
Check Mitigations:
grep . /sys/devices/system/cpu/vulnerabilities/*
Enable/Disable Mitigations:
Edit kernel command line in /etc/default/grub
:
GRUB_CMDLINE_LINUX_DEFAULT="mitigations=auto"
Update GRUB:
sudo update-grub
Polkit (PolicyKit):
Virtualization and Containerization:
grub.cfg
: GRUB configuration file.systemctl
: Systemd command-line utility.getcap
, setcap
, capsh
: Manage and view capabilities.sysctl
, /etc/sysctl.conf
: Kernel parameter configuration./etc/usbguard/usbguard-daemon.conf
, /etc/usbguard/rules.conf
: USBGuard configuration.ssh-keygen
: Generate SSH keys and certificates./etc/ssh/sshd_config
, ~/.ssh/
: SSH configuration files.chroot
: Change root environment.systemd
: Service manager for managing systemd units and configurations.Description:
Candidates should be proficient in restricting the resources that services and programs can consume on a Linux system. This involves configuring user limits, managing control groups (cgroups), and using systemd features to control resource usage.
ulimits
View Current Limits:
ulimit -a
Set User Limits Temporarily:
ulimit -n 1024 # Set the number of open files limit
Set User Limits Permanently:
Edit /etc/security/limits.conf
:
* soft nofile 1024
* hard nofile 2048
Include pam_limits.so
in PAM Configuration:
/etc/pam.d/common-session
and /etc/pam.d/common-session-noninteractive
:session required pam_limits.so
Overview of cgroups:
Create and Manage cgroups:
View cgroups Hierarchy:
cat /proc/cgroups
Create a New cgroup (e.g., CPU):
sudo mkdir /sys/fs/cgroup/cpu/mygroup
Set Limits (e.g., CPU):
echo "50000" | sudo tee /sys/fs/cgroup/cpu/mygroup/cpu.cfs_quota_us
Associate Processes with cgroup:
echo <pid> | sudo tee /sys/fs/cgroup/cpu/mygroup/cgroup.procs
Tools:
cgmanager
and libcgroup
Utilities:
cgcreate
: Create cgroups.cgset
: Set cgroup parameters.cgexec
: Execute commands in a cgroup.Systemd Slices:
Purpose: Group services for resource control.
Configuration: Use slices to manage resource limits for groups of services.
Example Configuration (/etc/systemd/system/my-slice.slice
):
[Slice]
CPUQuota=50%
Systemd Scopes:
systemd-run --scope --slice=my-slice
Systemd Services:
Set Resource Limits in Unit Files:
/etc/systemd/system/myservice.service
):[Service]
CPUQuota=20%
MemoryMax=1G
Reload Systemd and Apply Changes:
sudo systemctl daemon-reload
sudo systemctl restart myservice
ulimit
: Command to set user process resource limits./etc/security/limits.conf
: Configuration file for setting user limits.pam_limits.so
: PAM module to enforce limits./sys/fs/cgroup/
: Mount point for cgroups filesystem./proc/cgroups
: File listing available cgroup controllers.systemd-cgls
: Display control group hierarchy.systemd-cgtop
: Monitor cgroup resource usage.Check Current Limits:
ulimit -a
Set Limits for a Service:
Create and edit unit file:
sudo nano /etc/systemd/system/myapp.service
[Service]
CPUQuota=10%
MemoryMax=500M
Apply changes:
sudo systemctl daemon-reload
sudo systemctl restart myapp
Manage cgroups with cgcreate
:
sudo cgcreate -g memory,cpu:/mygroup
Set CPU limit:
echo "50000" | sudo tee /sys/fs/cgroup/cpu/mygroup/cpu.cfs_quota_us
Assign process to cgroup:
echo <pid> | sudo tee /sys/fs/cgroup/cpu/mygroup/cgroup.procs
Description:
Candidates should have a solid understanding of Discretionary Access Control (DAC) and be able to implement it using Access Control Lists (ACLs) and extended attributes on Linux systems.
File Ownership and Permissions:
User and Group Ownership:
ls -l filename
Change Ownership:
chown user:group filename
Change Permissions:
chmod 755 filename
SetUID and SetGID Bits:
SetUID Bit:
chmod u+s filename
SetGID Bit:
chmod g+s directoryname
Overview:
View ACLs:
getfacl filename
Set ACLs:
setfacl -m u:user:rwx filename
Remove ACLs:
setfacl -x u:user filename
Default ACLs for Directories:
setfacl -d -m u:user:rwx directoryname
Overview:
View Extended Attributes:
getfattr -d filename
Set Extended Attributes:
setfattr -n user.attrname -v "value" filename
Remove Extended Attributes:
setfattr -x user.attrname filename
Check File Permissions and Ownership:
ls -l /path/to/file
Change File Owner:
sudo chown alice:admins /path/to/file
Set File Permissions:
chmod 644 /path/to/file
Add ACL Entry:
setfacl -m u:bob:rx /path/to/file
Check ACLs:
getfacl /path/to/file
Add Extended Attribute:
setfattr -n user.comment -v "This is a file comment" /path/to/file
Remove Extended Attribute:
setfattr -x user.comment /path/to/file
Description:
Candidates should be proficient with Mandatory Access Control (MAC) systems, with a focus on SELinux (Security-Enhanced Linux), and should have a general awareness of other MAC systems like AppArmor and Smack. They should understand the core concepts of MAC, type enforcement, role-based access control, and how these differ from discretionary access control.
Type Enforcement (TE):
Role-Based Access Control (RBAC):
Mandatory Access Control (MAC) vs. Discretionary Access Control (DAC):
Check SELinux Status:
sestatus
Check SELinux Mode:
getenforce
Set SELinux Mode:
setenforce 1
setenforce 0
Manage SELinux Booleans:
getsebool -a
setsebool httpd_can_network_connect on
togglesebool httpd_can_network_connect
Manage File Contexts:
restorecon -R /path/to/directory
chcon -t httpd_sys_content_t /path/to/file
Role Management:
newrole -r system_r -t httpd_t
SELinux Policy Tools:
semanage fcontext -a -t httpd_sys_content_t "/path/to/dir(/.*)?"
seinfo
audit2why
audit2allow -m mymodule
AppArmor:
sudo aa-status
sudo aa-enforce /etc/apparmor.d/profile
Smack (Simplified Mandatory Access Control Kernel):
cat /sys/kernel/security/smackfs/summary
chsmack -a label /path/to/file
Check SELinux Mode and Status:
sestatus
getenforce
Set SELinux to Enforcing Mode:
setenforce 1
Change File Context for Web Content:
chcon -t httpd_sys_content_t /var/www/html
restorecon -R /var/www/html
Add SELinux Policy for New Directory:
semanage fcontext -a -t httpd_sys_content_t "/var/www/newdir(/.*)?"
restorecon -R /var/www/newdir
Manage AppArmor Profiles:
sudo aa-status
sudo aa-enforce /etc/apparmor.d/usr.bin.myapp
Check Smack Labels:
cat /sys/kernel/security/smackfs/summary
This guide provides an overview of Mandatory Access Control (MAC) systems, focusing on SELinux, with essential commands and configurations for implementing and managing MAC policies on Linux systems.
Here’s a detailed guide to the enterprise commands and configuration files related to SELinux, focusing on their use in managing and configuring SELinux policies in a Linux environment.
getenforce
getenforce
Enforcing
: SELinux is enforcing policies.Permissive
: SELinux is in permissive mode, logging violations but not enforcing policies.Disabled
: SELinux is disabled.setenforce
setenforce [Enforcing|Permissive]
setenforce 1
setenforce 0
selinuxenabled
selinuxenabled
getsebool
getsebool -a
getsebool -a
getsebool httpd_can_network_connect
setsebool
setsebool [boolean] [on|off]
setsebool httpd_can_network_connect on
setsebool httpd_can_network_connect off
togglesebool
togglesebool [boolean]
togglesebool httpd_can_network_connect
fixfiles
fixfiles [restore|relabel] [options]
fixfiles relabel
restorecon
restorecon [options] [file|directory]
restorecon -R /path/to/directory
setfiles
setfiles [options] /etc/selinux/targeted/contexts/files/file_contexts /path/to/directory
setfiles /etc/selinux/targeted/contexts/files/file_contexts /path/to/directory
newrole
newrole -r [role] -t [type] [command]
newrole -r sysadm_r
setcon
setcon [context] [command]
setcon system_u:system_r:unconfined_t /bin/bash
runcon
runcon [context] [command]
runcon system_u:system_r:unconfined_t /bin/bash
chcon
chcon [options] [context] [file|directory]
chcon -t httpd_sys_content_t /var/www/html/index.html
semanage
semanage [options] [subcommand]
semanage fcontext -a -t httpd_sys_content_t "/var/www/html(/.*)?"
restorecon -R /var/www/html
sestatus
sestatus
seinfo
seinfo [options]
seinfo -a
apol
apol [options]
apol
seaudit
seaudit [options] [logfile]
seaudit /var/log/audit/audit.log
audit2why
audit2why < [logfile]
audit2why < /var/log/audit/audit.log
audit2allow
audit2allow -a -M [module_name]
audit2allow -a -M mymodule
/etc/selinux/
/etc/selinux/config
: SELinux configuration file.
SELINUX=enforcing
SELINUXTYPE=targeted
/etc/selinux/targeted/contexts/files/file_contexts
: File contexts definitions.
/etc/selinux/targeted/policy/
: SELinux policy modules.
Here’s a detailed overview of the commands, utilities, and files related to network hardening, focusing on securing networks, analyzing traffic, and configuring network services:
radiusd
radiusd [options]
-X
: Run in debug mode.-f
: Run in foreground.-C
: Check configuration file syntax.radmin
radmin [options]
-a
: Add a new user.-d
: Delete a user.radtest
radtest [username] [password] [radius_server] [port] [secret]
radtest user password localhost 0 testing123
radclient
radclient [radius_server] [port] [request_type] [secret] [options]
radclient localhost auth testing123
radlast
radlast [options] [username]
radwho
radwho [options]
radiusd.conf
/etc/raddb/radiusd.conf
or similar path depending on installation./etc/raddb/*
clients.conf
: Defines RADIUS clients.users
: Defines user accounts and authentication methods.eap.conf
: Configuration for EAP (Extensible Authentication Protocol).wireshark
ip.addr == 192.168.1.1
tshark
tshark [options]
tshark -i eth0
tshark -i eth0 -f "tcp port 80"
tcpdump
tcpdump [options]
tcpdump -i eth0
tcpdump -i eth0 'tcp port 80'
kismet
kismet
ndpmon
ndpmon [options]
ndpmon
to monitor NDP messages:ndpmon -i eth0
aircrack-ng
aircrack-ng [options]
bettercap
bettercap [options]
/etc/raddb/
clients.conf
: Configures RADIUS clients.users
: Defines users and authentication methods./etc/selinux/
config
: SELinux configuration file.targeted/contexts/
: SELinux contexts and policy files.Understanding these commands and configuration files will help you secure and analyze network traffic, manage RADIUS authentication, and handle potential threats in your network environment.
Here’s a detailed overview of the commands, utilities, and files related to network intrusion detection and monitoring. This includes implementing bandwidth monitoring, and configuring and using Snort and OpenVAS.
ntop
ntopng [options]
-i
: Specify the network interface to monitor.-d
: Specify the data directory.snort
snort [options]
-c
: Specify the configuration file.-A
: Specify alert mode.-i
: Specify the network interface.snort-stat
snort-stat [options]
-c
: Specify the Snort configuration file.-d
: Specify the directory with Snort logs.pulledpork.pl
pulledpork.pl [options]
-c
: Specify the configuration file.-h
: Display help./etc/snort/*
snort.conf
: Main Snort configuration file.threshold.conf
: Threshold configuration for Snort alerts.rules/
: Directory containing Snort rules.openvas-adduser
openvas-adduser [options]
-u
: Specify username.-p
: Specify password.openvas-rmuser
openvas-rmuser [options]
-u
: Specify username.openvas-nvt-sync
openvas-nvt-sync
openvassd
openvassd [options]
-f
: Run in the foreground.-c
: Specify the configuration file.openvas-mkcert
openvas-mkcert [options]
openvas-feed-update
openvas-feed-update
/etc/openvas/*
openvasmd.conf
: OpenVAS Manager configuration file.openvassd.conf
: OpenVAS Scanner configuration file.openvas.conf
: General OpenVAS configuration file.Bandwidth Monitoring:
ntop
to monitor and analyze network bandwidth and traffic.Snort Configuration and Management:
snort
: Main command to run Snort for IDS/IPS.snort-stat
: Generates statistics for Snort.pulledpork.pl
: Manages and updates Snort rules./etc/snort/*
: Contains configuration and rules for Snort.OpenVAS Configuration and Management:
openvas-adduser
: Adds users to OpenVAS.openvas-rmuser
: Removes users from OpenVAS.openvas-nvt-sync
: Syncs the NVT feed.openvassd
: OpenVAS Scanner daemon.openvas-mkcert
: Creates SSL/TLS certificates for OpenVAS.openvas-feed-update
: Updates OpenVAS feeds./etc/openvas/*
: Contains configuration files for OpenVAS.Here’s an overview of the netfilter packet filtering tools and utilities for configuring and managing network traffic on Linux. This includes iptables
, ip6tables
, ipset
, and related commands and concepts.
iptables
and ip6tables
iptables
iptables [options] [chain] [rule-specification]
iptables -L
: List rules in the filter table.iptables -A [chain] [rule]
: Append a new rule.iptables -D [chain] [rule]
: Delete a rule.iptables -F
: Flush all rules in the selected chain.iptables-save
: Save the current rules to a file.iptables-restore
: Restore rules from a file.ip6tables
ip6tables [options] [chain] [rule-specification]
ip6tables -L
: List rules in the filter table.ip6tables -A [chain] [rule]
: Append a new rule.ip6tables -D [chain] [rule]
: Delete a rule.ip6tables -F
: Flush all rules in the selected chain.ip6tables-save
: Save the current rules to a file.ip6tables-restore
: Restore rules from a file.Connection Tracking:
conntrack -L
: List tracked connections.conntrack -D [conn_id]
: Delete a specific tracked connection.Network Address Translation (NAT):
iptables -t nat -A POSTROUTING -o [interface] -j MASQUERADE
: Set up source NAT for outgoing traffic.iptables -t nat -A PREROUTING -p tcp --dport [port] -j DNAT --to-destination [IP]:[port]
: Set up destination NAT for incoming traffic.ipset
iptables
rules.ipset [options]
ipset create [setname] [type]
: Create a new set.ipset add [setname] [IP or network]
: Add an entry to a set.ipset list [setname]
: List the contents of a set.ipset del [setname] [IP or network]
: Delete an entry from a set.ipset flush
: Flush all entries in all sets.nftables
and nft
iptables
, offering more flexibility and better performance.nft [options]
nft list ruleset
: List the current ruleset.nft add rule [table] [chain] [rule]
: Add a new rule.nft delete rule [table] [chain] [rule]
: Delete a rule.ebtables
ebtables [options]
ebtables -L
: List current rules.ebtables -A [chain] [rule]
: Append a rule.ebtables -D [chain] [rule]
: Delete a rule.conntrackd
conntrackd [options]
Firewall Architectures:
iptables
and ip6tables
:
Connection Tracking and NAT:
ipset
:
iptables
rules.Other Tools:
nftables
and nft
: Modern replacement for iptables
.ebtables
: Layer 2 filtering.conntrackd
: Synchronize connection tracking tables.Here’s an overview of the VPN technologies and tools you need to be familiar with for setting up remote access and site-to-site VPNs, including OpenVPN, IPsec (using strongSwan), and WireGuard.
Bridged VPNs:
Routed VPNs:
OpenVPN:
IPsec (Internet Protocol Security):
WireGuard:
L2TP (Layer 2 Tunneling Protocol):
OpenVPN:
/etc/openvpn/
openvpn /etc/openvpn/server.conf
openvpn /etc/openvpn/client.conf
strongSwan (IPsec):
/etc/strongswan.conf
/etc/strongswan.d/
/etc/swanctl/swanctl.conf
/etc/swanctl/
ipsec start
ipsec status
ipsec restart
WireGuard:
/etc/wireguard/
wg-quick up wg0
wg-quick down wg0
wg0.conf
) specify private and public keys, peer information, and network settings.OpenVPN Server Configuration (/etc/openvpn/server.conf
):
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
keepalive 10 120
cipher AES-256-CBC
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
strongSwan Configuration (/etc/strongswan.conf
):
charon {
plugins {
md4 {
status = yes
}
}
}
WireGuard Configuration (/etc/wireguard/wg0.conf
):
[Interface]
Address = 10.0.0.1/24
PrivateKey = <server-private-key>
[Peer]
PublicKey = <client-public-key>
AllowedIPs = 10.0.0.2/32
VPN Principles:
Protocols:
Configuration:
/etc/openvpn/
/etc/strongswan.conf
, /etc/strongswan.d/
/etc/wireguard/
Commands:
openvpn
, openvpn --config
ipsec start
, ipsec status
wg-quick up
, wg-quick down
Understanding common security vulnerabilities and threats is crucial for protecting systems, networks, and applications. Here’s a breakdown of major types of security threats and vulnerabilities, including conceptual explanations and examples:
Trojans:
Viruses:
Rootkits:
Keyloggers:
DoS and DDoS Attacks:
Man-in-the-Middle (MitM) Attacks:
ARP and NDP Forgery:
Rogue Access Points, Routers, and DHCP Servers:
Link Layer Address and IP Address Spoofing:
Buffer Overflows:
SQL Injection:
Code Injections:
Cross-Site Scripting (XSS):
Cross-Site Request Forgery (CSRF):
Privilege Escalation:
Brute Force Attacks:
Rainbow Tables:
Phishing:
Social Engineering:
Individual Nodes:
Networks:
Applications:
Credentials and Confidentiality:
Honeypots:
Here is a detailed list of commands and information for each tool and utility related to common security vulnerabilities and threats:
ClamAV
clamscan
: Scan files or directories.
clamscan /path/to/file_or_directory
clamscan /home/user/documents
freshclam
: Update ClamAV virus definitions.
freshclam
freshclam
(Run periodically to keep definitions updated)chkrootkit
chkrootkit
: Scan for rootkits.
chkrootkit
chkrootkit
(Run to check for known rootkits)rkhunter
rkhunter --check
: Scan for rootkits, backdoors, and local exploits.
rkhunter --check
rkhunter --check --skel /var/lib/rkhunter
rkhunter --update
: Update rootkit definitions.
rkhunter --update
rkhunter --update
ps aux
: List running processes to identify suspicious activity.
ps aux
ps aux | grep keylogger
netstat
netstat -an
: Display active connections and listening ports.
netstat -an
netstat -an | grep LISTEN
tcpdump
tcpdump
: Capture and analyze network traffic.
tcpdump -i [interface]
tcpdump -i eth0
tcpdump -i [interface] port [port]
: Capture traffic on a specific port.
tcpdump -i eth0 port 80
Wireshark
wireshark
: GUI tool for network traffic analysis.
wireshark
in terminal or use the application launcher.ettercap -T -M ARP /target1/ /target2/
: Perform ARP poisoning attacks.
ettercap -T -M ARP /192.168.1.10/ /192.168.1.1/
ettercap -T -M ARP /192.168.1.10/ /192.168.1.1/
arpspoof
arpspoof -i [interface] -t [target_ip] [router_ip]
: Spoof ARP responses.
arpspoof -i eth0 -t 192.168.1.5 192.168.1.1
arpspoof -i eth0 -t 192.168.1.5 192.168.1.1
ndppd
ndppd
: Manage NDP spoofing for IPv6.
/etc/ndppd.conf
./etc/ndppd.conf
with appropriate rules.Kismet
kismet
: GUI tool for detecting and capturing wireless network traffic.
kismet
in terminal or use the application launcher.dhcpdump
dhcpdump
: Analyze DHCP traffic.
dhcpdump
dhcpdump -i eth0
hping3
hping3 -a [source_ip] [target_ip]
: Perform IP address spoofing tests.
hping3 -a 192.168.1.100 192.168.1.1
hping3 -a 192.168.1.100 192.168.1.1
arping
arping -c 4 [target_ip]
: Send ARP packets to test for spoofing.
arping -c 4 192.168.1.1
arping -c 4 192.168.1.1
GDB (GNU Debugger)
gdb [program]
: Debug applications to analyze buffer overflows.
gdb ./vulnerable_program
gdb ./my_app
Valgrind
valgrind --leak-check=yes [program]
: Detect memory leaks and buffer overflows.
valgrind --leak-check=yes ./my_program
valgrind --leak-check=yes ./my_app
sqlmap -u [URL] --dbs
: Detect and exploit SQL injection vulnerabilities.
sqlmap -u "http://example.com/page?id=1" --dbs
sqlmap -u "http://example.com/vuln?id=1" --dbs
zap
: Use OWASP ZAP GUI to scan web applications for code injection vulnerabilities.
zap
in terminal or use the application launcher.OWASP ZAP
zap
: Use OWASP ZAP to detect XSS vulnerabilities.
zap
in terminal or use the application launcher.Burp Suite
burpsuite
: Use Burp Suite for XSS testing.
burpsuite
in terminal or use the application launcher.zap
: Use OWASP ZAP to identify CSRF vulnerabilities.
zap
in terminal or use the application launcher.LinPEAS
linpeas.sh
: Automate the search for privilege escalation vectors.
linpeas.sh
./linpeas.sh
sudo
sudo -l
: List the commands the current user can run with sudo
.
sudo -l
sudo -l
Hydra
hydra -l [username] -P [password_list] [target] [protocol]
: Perform brute force attacks.
hydra -l admin -P /path/to/password_list.txt 192.168.1.1 ssh
hydra -l admin -P /usr/share/wordlists/rockyou.txt 192.168.1.1 ssh
John the Ripper
john --wordlist=[wordlist] --rules [password_file]
: Crack password hashes.
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
ophcrack
: Use Ophcrack GUI to utilize rainbow tables.
ophcrack
in terminal or use the application launcher.setoolkit
: Create and simulate social engineering attacks.
setoolkit
setoolkit
and follow the prompts to create phishing scenarios.setoolkit
: Use SET to simulate social engineering attacks.
setoolkit
oolkit` and follow the prompts for various social engineering attacks.
Honeyd
honeyd -d -f [config_file]
: Deploy a honeypot.
honeyd -d -f /etc/honeyd/honeyd.conf
honeyd -d -f /etc/honeyd/honeyd.conf
Cowrie
cowrie
: Set up a honeypot for SSH and Telnet.
systemctl start cowrie
(if configured as a service)This detailed information should help in understanding and using these tools for analyzing and mitigating security vulnerabilities and threats.
Here’s a detailed overview of penetration testing concepts, commonly used tools, and specific commands and functionalities related to the Nmap network scanner:
Concepts of Penetration Testing and Ethical Hacking:
Legal Implications:
Phases of Penetration Testing:
Metasploit Framework:
Nmap Network Scanner:
nmap -sT [target]
nmap -sS [target]
(stealthier than TCP connect scan)nmap -sU [target]
nmap -sV [target]
(identifies service versions)nmap -O [target]
nmap --script [script_name] [target]
nmap --script=vuln [target]
(runs vulnerability scanning scripts)nmap -sS -sV -O [target]
(run SYN scan, version detection, and OS detection)Awareness of Other Tools:
Basic Scan:
nmap [target]
nmap 192.168.1.1
Port Scan:
nmap -p [port_range] [target]
nmap -p 22,80,443 192.168.1.1
nmap -p 1-1000 192.168.1.1
Service Version Detection:
nmap -sV [target]
nmap -sV 192.168.1.1
Operating System Detection:
nmap -O [target]
nmap -O 192.168.1.1
Nmap Scripting Engine:
nmap --script [script_name] [target]
nmap --script http-vuln-cve2017-5638 192.168.1.1
nmap --script=vuln [target]
nmap --script=vuln 192.168.1.1
Aggressive Scan:
nmap -A [target]
nmap -A 192.168.1.1
(includes OS detection, version detection, script scanning, and traceroute)Network Scanning:
nmap -sn [network_range]
nmap -sn 192.168.1.0/24
(ping scan to identify live hosts)