SlideShare a Scribd company logo
1 of 27
Download to read offline
HARDENING LINUX SERVER
A SECURE APPROACH
Kaleem
Technical consultant / Operations engineer
CipherCloud
Email : shiek.kaleem@gmail.com
BENCHMARKS
• CIS Security Benchmarks for Linux
• NSA Security Configuration Guides for Linux
CHOOSE A FLAVOUR ?
For better or worse, there’s no one “Linux”. Instead, there are loads of Linux
distributions that all run the Linux kernel.
" Server distributions differ from desktop versions,security distros both in
packages and in support "
DIVISION OF LABOUR
Basic idea behind the protection of a Linux server is to have the
system administrator control the work of the entire server and
only use the packages that are necessary for the planned
services.
• BASIC
• SERVER (WEB,DNS,MAIL)
• DESKTOP
KEEP IT SEPARATED ( FILE SYSTEM PARTITIONING)
Keep partitions Separate for a better administration and security
ENCRYPTING THE FILESYSTEM
ENCRYPTING THE RUNNING SERVER
• To encrypt a partition using dm-crypt+LUKS on Linux
• $ sudo yum install cryptsetup
• $ sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1
• sudo cryptsetup luksDump /dev/sdb1
• sudo cryptsetup luksOpen /dev/sdb1 sdb1
• Follow the FIPS -140
• Install the dracut-fips package:
# yum install dracut-fips
• Recreate the INITRAMFS image:
# dracut -f
SECURE THE BOOT
Root password to access run level 1:
echo "~~:S:wait:/sbin/sulogin" >> /etc/inittab
perl -npe 's/ca::ctrlaltdel:/sbin/shutdown/#ca::ctrlaltdel:/sbin/shutdown/' -i /etc/inittab
Password Protecting GRUB :
/sbin/grub-md5-crypt
password --md5 <password-hash>
Replace <password-hash> with the value returned by /sbin/grub-md5-crypt
The next time the system boots, the GRUB menu prevents access to the editor or command interface without first
pressing p followed by the GRUB password.
IPFILTERS & TCP WRAPPERS
IPTables has the following 4 built-in tables
• FILTER Table - (Input ,output ,Forward chain )
• NAT Table - (Pre routing,Post routing,output chain )
• MANGLE Table - (Pre routing, Output,Forward, Input, Post routing)
• RAW Table - (Pre routing , Output )
• Tcp warppers for a restrictive network
• # /etc/hosts.allow
• # /etc/hosts.deny
EGRESS FILTERING FOR A HEALTHIER INTERNET
When your SERVER is compromised, you are no longer the innocent party
trying to defend yourself, to other machines you have become the attacker.
Just reverse the -d / --dport (destination address / destination port) and -s / -
-sport (source address / source port) arguments.
JUST A SAMPLE FIREWALL RULE
THE "RIGHTS"
Restrict the root :
No one other than root should be allowed in root's home directory. The default
settings are close to this, but not quite paranoid enough.
echo "tty1" > /etc/securetty
chmod 700 /root
USE SUDO :
sudo allows for granular control over privileged actions. This way administrator
can start, stop and otherwise manage the web server without being able to affect
other services.
PERMISSIONS & PASSWORDS
• Narrow down rights for system files and folders
chmod 700 ( files owned by root )
chown root:root ( files owned by root )
Set a crotab to check the permissions periodically.
• Upgrade Password Hashing Algorithm to SHA-512
# authconfig --passalgo=sha512 --update
PASSWORD POLICIES
Set Password Creation Requirement Parameters Using pam_cracklib
RecommendedValues:
PASS_MAX_DAYS 90
PASS_MIN_DAYS 6
PASS_MIN_LEN 14
PASS_WARN_AGE 7
#sed -i 's/PASS_MAX_DAYS.*/PASS_MAX_DAYS 90/g' /etc/login.defs
#sed -i 's/PASS_MIN_LEN.*/PASS_MIN_LEN14/g' /etc/login.defs
#sed -i 's/PASS_MIN_LEN.*/PASS_MIN_DAYS 6/g' /etc/login.defs
#sed -i 's/PASS_WARN_AGE.*/PASS_WARN_AGE 7/g' /etc/login.defs
CLEANUP !
Delete non-used user accounts
# userdel ( shutdown, halt, games, operator, gopher, games )
Disable unnecessary services
#for i in rpcbind restorecond nfslock lldpad fcoe rpcidmapd; do service $i stop;
chkconfig $i off; done
Remove unnecessary packages
# yum groupremove (package names )
# sudo apt-get remove pino
Make sure no non-root accounts have UID set to 0
# % awk -F: '($3 == "0") {print}' /etc/passwd
BASH HARDENING
• Define Read-Only environment variables -> To avoid
being overwriten by users (declare –r
HISTFILE=~/.bash_history && chattr +I .bash_history)
• HISTFILESIZE -> Maximum number of lines to keep
• HISTFSIZE -> Maximum stored commands in memory
• HISTTIMEFORMAT -> Date/Time format to store
commands execution
• Force to commit HISTFILE every time a command is
typed instead of logout -> readonly || declare -r
PROMPT_COMMAND="history -a"
• Limit Timeout login session -> declare -r TMOUT=120
AVOID THE FORK BOMBS
• The ulimit and sysctl programs allow to limit system-wide resource use. This can help a lot in
system administration, e.g. when a user starts too many processes and therefore makes the system
unresponsive for other users.
• # ulimit -u 30
# ulimit -a
…
max user processes (-u) 30
• # sysctl -a
…
vm.swappiness = 60
• # sysctl vm.swappiness=0
vm.swappiness = 0
• "fork: resource temporarily unavailable".
STRIPPING DOWN LINUX
( REMOVE THE UNNECESSARY PACKAGES)
• One of the simplest ways to hinder an intruder is to remove unnecessary
system binaries.On a typical Linux server, there are many unneeded tools,
which can be useful to an attacker if he gains entry.
• Unnecessary Binaries
• Network Utilities
• Compilers and Interpreters
SECURE REMOTE ADMINISTRATION
• Remove the legacy , unsecure tools.
• Make sure to keep the crypto libraries updated ( Patch them)
• Avoid installing ssh client
• Harden the SSH
• Use jumphosts, vpn to connect.
• Avoid using passwords, start using key based authentication.
• Remove the non-ssl processes
# yum remove erase xinetd tftp-server ypserv telnet-server rsh-server
SSH HARDENING PARAMETERS
KEY BASED AUTHENTICATION
# ssh-keygen
Created directory '/home/username/.ssh'. Enter
passphrase (empty for no passphrase): Enter same
passphrase again:
Your identification has been saved in
/home/username/.ssh/id_rsa. Your public key has
been saved in /home/username/.ssh/id_rsa.pub. The
key fingerprint is:
a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26
username@remote_host The key's randomart image is:
+--[ RSA 2048]----+ | ..o | | E o= . | | o. o | |
.. | | ..S | | o o. | | =o.+. | |. =++.. | |o=++.
| +-----------------+
KERNEL HARDENING: DISABLE AND BLACKLIST LINUX
MODULES
• The Linux kernel is modular, which makes it more flexible than monolithic kernels. New
functionality can be easily added to a run kernel, by loading the related module.
One option to disallow loading modules, is by blacklisting them.
# modinfo
# modprobe --showconfig | grep blacklist
# /etc/modprobe.d/blacklist-firewire.conf
# modprobe --showconfig | grep "^install" | grep "/bin"
By using the kernel setting kernel.modules_disabled and set its value to 1, we can make sure
things are really tightened. Even the root user can not load any modules anymore.
TUNING KERNEL FOR BETTER SECURITY
• Enable TCP SYN Cookie Protection - net.ipv4.tcp_syncookies = 1
• Disable IP Source Routing - net.ipv4.conf.all.accept_source_route = 0
• Disable ICMP Redirect Acceptance - net.ipv4.conf.all.accept_redirects = 0
• Enable IP Spoofing Protection - net.ipv4.conf.all.rp_filter = 1
• Enable Ignoring to ICMP Requests - net.ipv4.icmp_echo_ignore_all = 1
• Enable Ignoring Broadcasts Request - net.ipv4.icmp_echo_ignore_broadcasts = 1
• Enable Logging of Spoofed Packets, Source Routed Packets, Redirect Packets
• (net.ipv4.conf.all.log_martians = 1 )
•
CRITICAL,UNKNOWN AND THIRD PARTY
• SE LINUX Security-Enhanced Linux (SELinux) is a Linux feature that
provides a variety of security policies for Linux kernel.
• APP ARMOUR (Application Armor) is another security software for Linux
which maintained and released by Novell under GPL. AppArmor was
created as an alternative to SELinux. AppArmor works with file paths.
• GRSECURITY is a set of patches for the Linux kernel with an emphasis on
enhancing security. It utilizes a multi-layered detection, prevention, and
containment model.
AUDIT ,LOG, INTEGRITY CHECK
Record Events That Modify Date and Time Information,
System's Network Environment ,System's Mandatory Access
Controls ,Unsuccessful Unauthorized Access Attempts to Files
Install AIDE, Implement Periodic Execution of File Integrity.
( TRIP WIRE ,AIDE ,AUDITD,LOGWATCH)
QUESTIONS & SUGGESTIONS

More Related Content

What's hot

Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLMydbops
 
Abusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itBenjamin Delpy
 
Linux Performance Analysis and Tools
Linux Performance Analysis and ToolsLinux Performance Analysis and Tools
Linux Performance Analysis and ToolsBrendan Gregg
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentJean-François Gagné
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersSam Bowne
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX, Inc.
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemdYusaku OGAWA
 
pfSense presentation
pfSense presentationpfSense presentation
pfSense presentationSimon Vass
 
Installing & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSInstalling & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSDevin Olson
 
Managing PostgreSQL with Ansible
 Managing PostgreSQL with Ansible Managing PostgreSQL with Ansible
Managing PostgreSQL with AnsibleEDB
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalsRaghu nath
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0GlobalLogic Ukraine
 
You can detect PowerShell attacks
You can detect PowerShell attacksYou can detect PowerShell attacks
You can detect PowerShell attacksMichael Gough
 
LINUX DISTRIBUTIONS.pptx
LINUX DISTRIBUTIONS.pptxLINUX DISTRIBUTIONS.pptx
LINUX DISTRIBUTIONS.pptxrahul355835
 

What's hot (20)

Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQL
 
Abusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get it
 
Linux Performance Analysis and Tools
Linux Performance Analysis and ToolsLinux Performance Analysis and Tools
Linux Performance Analysis and Tools
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
SCSI Interfaces
SCSI InterfacesSCSI Interfaces
SCSI Interfaces
 
Metasploitable
MetasploitableMetasploitable
Metasploitable
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web Servers
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemd
 
pfSense presentation
pfSense presentationpfSense presentation
pfSense presentation
 
Linux security
Linux securityLinux security
Linux security
 
Installing & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOSInstalling & Configuring IBM Domino 9 on CentOS
Installing & Configuring IBM Domino 9 on CentOS
 
Managing PostgreSQL with Ansible
 Managing PostgreSQL with Ansible Managing PostgreSQL with Ansible
Managing PostgreSQL with Ansible
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Nginx Essential
Nginx EssentialNginx Essential
Nginx Essential
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
 
Web Server Hardening
Web Server HardeningWeb Server Hardening
Web Server Hardening
 
You can detect PowerShell attacks
You can detect PowerShell attacksYou can detect PowerShell attacks
You can detect PowerShell attacks
 
LINUX DISTRIBUTIONS.pptx
LINUX DISTRIBUTIONS.pptxLINUX DISTRIBUTIONS.pptx
LINUX DISTRIBUTIONS.pptx
 

Viewers also liked

Linux Server Hardening - Steps by Steps
Linux Server Hardening - Steps by StepsLinux Server Hardening - Steps by Steps
Linux Server Hardening - Steps by StepsSunil Paudel
 
Hardening Linux Server Security
Hardening Linux Server SecurityHardening Linux Server Security
Hardening Linux Server SecurityIlham Kurniawan
 
Hardening Linux and introducing Securix Linux
Hardening Linux and introducing Securix LinuxHardening Linux and introducing Securix Linux
Hardening Linux and introducing Securix LinuxSecurity Session
 
Membaca Isi File Menggunakan Admin Postgres Auxiliary Modules
Membaca Isi File Menggunakan Admin Postgres Auxiliary ModulesMembaca Isi File Menggunakan Admin Postgres Auxiliary Modules
Membaca Isi File Menggunakan Admin Postgres Auxiliary ModulesSteven Nathaniel
 
Server Hardening Primer - Eric Vanderburg - JURINNOV
Server Hardening Primer - Eric Vanderburg - JURINNOVServer Hardening Primer - Eric Vanderburg - JURINNOV
Server Hardening Primer - Eric Vanderburg - JURINNOVEric Vanderburg
 
Grub2 Booting Process
Grub2 Booting ProcessGrub2 Booting Process
Grub2 Booting ProcessMike Wang
 
Andrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategiesAndrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategiesMeet Magento Italy
 
Comparison between grub-legacy ,lilo and grub -2
Comparison between grub-legacy ,lilo and grub -2Comparison between grub-legacy ,lilo and grub -2
Comparison between grub-legacy ,lilo and grub -2iamumr
 
Mise en place d'un serveur de mail complet linux server wiki
Mise en place d'un serveur de mail complet   linux server wikiMise en place d'un serveur de mail complet   linux server wiki
Mise en place d'un serveur de mail complet linux server wikidebaros
 

Viewers also liked (9)

Linux Server Hardening - Steps by Steps
Linux Server Hardening - Steps by StepsLinux Server Hardening - Steps by Steps
Linux Server Hardening - Steps by Steps
 
Hardening Linux Server Security
Hardening Linux Server SecurityHardening Linux Server Security
Hardening Linux Server Security
 
Hardening Linux and introducing Securix Linux
Hardening Linux and introducing Securix LinuxHardening Linux and introducing Securix Linux
Hardening Linux and introducing Securix Linux
 
Membaca Isi File Menggunakan Admin Postgres Auxiliary Modules
Membaca Isi File Menggunakan Admin Postgres Auxiliary ModulesMembaca Isi File Menggunakan Admin Postgres Auxiliary Modules
Membaca Isi File Menggunakan Admin Postgres Auxiliary Modules
 
Server Hardening Primer - Eric Vanderburg - JURINNOV
Server Hardening Primer - Eric Vanderburg - JURINNOVServer Hardening Primer - Eric Vanderburg - JURINNOV
Server Hardening Primer - Eric Vanderburg - JURINNOV
 
Grub2 Booting Process
Grub2 Booting ProcessGrub2 Booting Process
Grub2 Booting Process
 
Andrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategiesAndrea Zwirner - Magento security and hardening strategies
Andrea Zwirner - Magento security and hardening strategies
 
Comparison between grub-legacy ,lilo and grub -2
Comparison between grub-legacy ,lilo and grub -2Comparison between grub-legacy ,lilo and grub -2
Comparison between grub-legacy ,lilo and grub -2
 
Mise en place d'un serveur de mail complet linux server wiki
Mise en place d'un serveur de mail complet   linux server wikiMise en place d'un serveur de mail complet   linux server wiki
Mise en place d'un serveur de mail complet linux server wiki
 

Similar to Linux Hardening - nullhyd

Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guideCraig Cannon
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX SecurityHelpSystems
 
Server hardening
Server hardeningServer hardening
Server hardeningTeja Babu
 
Systems administration for coders presentation
Systems administration for coders presentationSystems administration for coders presentation
Systems administration for coders presentationMatt Willsher
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Metasploit: Pwnage and Ponies
Metasploit: Pwnage and PoniesMetasploit: Pwnage and Ponies
Metasploit: Pwnage and PoniesTrowalts
 
High performance content hosting
High performance content hosting High performance content hosting
High performance content hosting Aleksey Korzun
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production OverviewDelve Labs
 
Lateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkLateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkEC-Council
 
Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Xavier Ashe
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Chris Tankersley
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetOmar Reygaert
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxWO Community
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersYury Chemerkin
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - RoutersLogicaltrust pl
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1Susant Sahani
 

Similar to Linux Hardening - nullhyd (20)

Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guide
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security
 
Server hardening
Server hardeningServer hardening
Server hardening
 
Penetration Testing Boot CAMP
Penetration Testing Boot CAMPPenetration Testing Boot CAMP
Penetration Testing Boot CAMP
 
Systems administration for coders presentation
Systems administration for coders presentationSystems administration for coders presentation
Systems administration for coders presentation
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Security Onion
Security OnionSecurity Onion
Security Onion
 
Metasploit: Pwnage and Ponies
Metasploit: Pwnage and PoniesMetasploit: Pwnage and Ponies
Metasploit: Pwnage and Ponies
 
High performance content hosting
High performance content hosting High performance content hosting
High performance content hosting
 
Hacking the swisscom modem
Hacking the swisscom modemHacking the swisscom modem
Hacking the swisscom modem
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production Overview
 
Essential security for linux servers
Essential security for linux serversEssential security for linux servers
Essential security for linux servers
 
Lateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkLateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your Network
 
Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS Linux
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routers
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - Routers
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 

More from n|u - The Open Security Community

Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...n|u - The Open Security Community
 

More from n|u - The Open Security Community (20)

Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)
 
Osint primer
Osint primerOsint primer
Osint primer
 
SSRF exploit the trust relationship
SSRF exploit the trust relationshipSSRF exploit the trust relationship
SSRF exploit the trust relationship
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Metasploit primary
Metasploit primaryMetasploit primary
Metasploit primary
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Introduction to TLS 1.3
Introduction to TLS 1.3Introduction to TLS 1.3
Introduction to TLS 1.3
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
 
Talking About SSRF,CRLF
Talking About SSRF,CRLFTalking About SSRF,CRLF
Talking About SSRF,CRLF
 
Building active directory lab for red teaming
Building active directory lab for red teamingBuilding active directory lab for red teaming
Building active directory lab for red teaming
 
Owning a company through their logs
Owning a company through their logsOwning a company through their logs
Owning a company through their logs
 
Introduction to shodan
Introduction to shodanIntroduction to shodan
Introduction to shodan
 
Cloud security
Cloud security Cloud security
Cloud security
 
Detecting persistence in windows
Detecting persistence in windowsDetecting persistence in windows
Detecting persistence in windows
 
Frida - Objection Tool Usage
Frida - Objection Tool UsageFrida - Objection Tool Usage
Frida - Objection Tool Usage
 
OSQuery - Monitoring System Process
OSQuery - Monitoring System ProcessOSQuery - Monitoring System Process
OSQuery - Monitoring System Process
 
DevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -SecurityDevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -Security
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Linux for hackers
Linux for hackersLinux for hackers
Linux for hackers
 
Android Pentesting
Android PentestingAndroid Pentesting
Android Pentesting
 

Recently uploaded

『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 

Recently uploaded (11)

『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 

Linux Hardening - nullhyd

  • 1. HARDENING LINUX SERVER A SECURE APPROACH
  • 2. Kaleem Technical consultant / Operations engineer CipherCloud Email : shiek.kaleem@gmail.com
  • 3. BENCHMARKS • CIS Security Benchmarks for Linux • NSA Security Configuration Guides for Linux
  • 4. CHOOSE A FLAVOUR ? For better or worse, there’s no one “Linux”. Instead, there are loads of Linux distributions that all run the Linux kernel. " Server distributions differ from desktop versions,security distros both in packages and in support "
  • 5. DIVISION OF LABOUR Basic idea behind the protection of a Linux server is to have the system administrator control the work of the entire server and only use the packages that are necessary for the planned services. • BASIC • SERVER (WEB,DNS,MAIL) • DESKTOP
  • 6. KEEP IT SEPARATED ( FILE SYSTEM PARTITIONING) Keep partitions Separate for a better administration and security
  • 8. ENCRYPTING THE RUNNING SERVER • To encrypt a partition using dm-crypt+LUKS on Linux • $ sudo yum install cryptsetup • $ sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1 • sudo cryptsetup luksDump /dev/sdb1 • sudo cryptsetup luksOpen /dev/sdb1 sdb1 • Follow the FIPS -140 • Install the dracut-fips package: # yum install dracut-fips • Recreate the INITRAMFS image: # dracut -f
  • 9. SECURE THE BOOT Root password to access run level 1: echo "~~:S:wait:/sbin/sulogin" >> /etc/inittab perl -npe 's/ca::ctrlaltdel:/sbin/shutdown/#ca::ctrlaltdel:/sbin/shutdown/' -i /etc/inittab Password Protecting GRUB : /sbin/grub-md5-crypt password --md5 <password-hash> Replace <password-hash> with the value returned by /sbin/grub-md5-crypt The next time the system boots, the GRUB menu prevents access to the editor or command interface without first pressing p followed by the GRUB password.
  • 10. IPFILTERS & TCP WRAPPERS IPTables has the following 4 built-in tables • FILTER Table - (Input ,output ,Forward chain ) • NAT Table - (Pre routing,Post routing,output chain ) • MANGLE Table - (Pre routing, Output,Forward, Input, Post routing) • RAW Table - (Pre routing , Output ) • Tcp warppers for a restrictive network • # /etc/hosts.allow • # /etc/hosts.deny
  • 11. EGRESS FILTERING FOR A HEALTHIER INTERNET When your SERVER is compromised, you are no longer the innocent party trying to defend yourself, to other machines you have become the attacker. Just reverse the -d / --dport (destination address / destination port) and -s / - -sport (source address / source port) arguments.
  • 12. JUST A SAMPLE FIREWALL RULE
  • 13. THE "RIGHTS" Restrict the root : No one other than root should be allowed in root's home directory. The default settings are close to this, but not quite paranoid enough. echo "tty1" > /etc/securetty chmod 700 /root USE SUDO : sudo allows for granular control over privileged actions. This way administrator can start, stop and otherwise manage the web server without being able to affect other services.
  • 14. PERMISSIONS & PASSWORDS • Narrow down rights for system files and folders chmod 700 ( files owned by root ) chown root:root ( files owned by root ) Set a crotab to check the permissions periodically. • Upgrade Password Hashing Algorithm to SHA-512 # authconfig --passalgo=sha512 --update
  • 15. PASSWORD POLICIES Set Password Creation Requirement Parameters Using pam_cracklib RecommendedValues: PASS_MAX_DAYS 90 PASS_MIN_DAYS 6 PASS_MIN_LEN 14 PASS_WARN_AGE 7 #sed -i 's/PASS_MAX_DAYS.*/PASS_MAX_DAYS 90/g' /etc/login.defs #sed -i 's/PASS_MIN_LEN.*/PASS_MIN_LEN14/g' /etc/login.defs #sed -i 's/PASS_MIN_LEN.*/PASS_MIN_DAYS 6/g' /etc/login.defs #sed -i 's/PASS_WARN_AGE.*/PASS_WARN_AGE 7/g' /etc/login.defs
  • 16. CLEANUP ! Delete non-used user accounts # userdel ( shutdown, halt, games, operator, gopher, games ) Disable unnecessary services #for i in rpcbind restorecond nfslock lldpad fcoe rpcidmapd; do service $i stop; chkconfig $i off; done Remove unnecessary packages # yum groupremove (package names ) # sudo apt-get remove pino Make sure no non-root accounts have UID set to 0 # % awk -F: '($3 == "0") {print}' /etc/passwd
  • 17. BASH HARDENING • Define Read-Only environment variables -> To avoid being overwriten by users (declare –r HISTFILE=~/.bash_history && chattr +I .bash_history) • HISTFILESIZE -> Maximum number of lines to keep • HISTFSIZE -> Maximum stored commands in memory • HISTTIMEFORMAT -> Date/Time format to store commands execution • Force to commit HISTFILE every time a command is typed instead of logout -> readonly || declare -r PROMPT_COMMAND="history -a" • Limit Timeout login session -> declare -r TMOUT=120
  • 18. AVOID THE FORK BOMBS • The ulimit and sysctl programs allow to limit system-wide resource use. This can help a lot in system administration, e.g. when a user starts too many processes and therefore makes the system unresponsive for other users. • # ulimit -u 30 # ulimit -a … max user processes (-u) 30 • # sysctl -a … vm.swappiness = 60 • # sysctl vm.swappiness=0 vm.swappiness = 0 • "fork: resource temporarily unavailable".
  • 19. STRIPPING DOWN LINUX ( REMOVE THE UNNECESSARY PACKAGES) • One of the simplest ways to hinder an intruder is to remove unnecessary system binaries.On a typical Linux server, there are many unneeded tools, which can be useful to an attacker if he gains entry. • Unnecessary Binaries • Network Utilities • Compilers and Interpreters
  • 20. SECURE REMOTE ADMINISTRATION • Remove the legacy , unsecure tools. • Make sure to keep the crypto libraries updated ( Patch them) • Avoid installing ssh client • Harden the SSH • Use jumphosts, vpn to connect. • Avoid using passwords, start using key based authentication. • Remove the non-ssl processes # yum remove erase xinetd tftp-server ypserv telnet-server rsh-server
  • 22. KEY BASED AUTHENTICATION # ssh-keygen Created directory '/home/username/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/username/.ssh/id_rsa. Your public key has been saved in /home/username/.ssh/id_rsa.pub. The key fingerprint is: a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26 username@remote_host The key's randomart image is: +--[ RSA 2048]----+ | ..o | | E o= . | | o. o | | .. | | ..S | | o o. | | =o.+. | |. =++.. | |o=++. | +-----------------+
  • 23. KERNEL HARDENING: DISABLE AND BLACKLIST LINUX MODULES • The Linux kernel is modular, which makes it more flexible than monolithic kernels. New functionality can be easily added to a run kernel, by loading the related module. One option to disallow loading modules, is by blacklisting them. # modinfo # modprobe --showconfig | grep blacklist # /etc/modprobe.d/blacklist-firewire.conf # modprobe --showconfig | grep "^install" | grep "/bin" By using the kernel setting kernel.modules_disabled and set its value to 1, we can make sure things are really tightened. Even the root user can not load any modules anymore.
  • 24. TUNING KERNEL FOR BETTER SECURITY • Enable TCP SYN Cookie Protection - net.ipv4.tcp_syncookies = 1 • Disable IP Source Routing - net.ipv4.conf.all.accept_source_route = 0 • Disable ICMP Redirect Acceptance - net.ipv4.conf.all.accept_redirects = 0 • Enable IP Spoofing Protection - net.ipv4.conf.all.rp_filter = 1 • Enable Ignoring to ICMP Requests - net.ipv4.icmp_echo_ignore_all = 1 • Enable Ignoring Broadcasts Request - net.ipv4.icmp_echo_ignore_broadcasts = 1 • Enable Logging of Spoofed Packets, Source Routed Packets, Redirect Packets • (net.ipv4.conf.all.log_martians = 1 ) •
  • 25. CRITICAL,UNKNOWN AND THIRD PARTY • SE LINUX Security-Enhanced Linux (SELinux) is a Linux feature that provides a variety of security policies for Linux kernel. • APP ARMOUR (Application Armor) is another security software for Linux which maintained and released by Novell under GPL. AppArmor was created as an alternative to SELinux. AppArmor works with file paths. • GRSECURITY is a set of patches for the Linux kernel with an emphasis on enhancing security. It utilizes a multi-layered detection, prevention, and containment model.
  • 26. AUDIT ,LOG, INTEGRITY CHECK Record Events That Modify Date and Time Information, System's Network Environment ,System's Mandatory Access Controls ,Unsuccessful Unauthorized Access Attempts to Files Install AIDE, Implement Periodic Execution of File Integrity. ( TRIP WIRE ,AIDE ,AUDITD,LOGWATCH)