Lynis is a battle-tested security tool for systems running Linux, macOS, or Unix-based operating system. It performs an extensive health scan of your systems to support system hardening and compliance testing. The project is open source software with the GPL license and available since 2007.
Since Lynis is flexible, it is used for several different purposes. Typical use cases for Lynis include:
- Security auditing
- Compliance testing (e.g. PCI, HIPAA, SOx)
- Penetration testing
- Vulnerability detection
- System Hardening
System hardening refers to securing your system from potential Threats and Vulnerabilities. Lynis can be used to generate a detailed report on various Threats and Vulnerabilities in your system. The user or System Administrator can then take the necessary actions to secure the system.
Lynis reports are hard to read and usually have a lot of information. Therefore, we use Bash and Python scripts to parse through the report, extract relevant information from the report such as warnings, suggestions and store them in an excel file as a report.
Prerequisites for Lynis –
- Install Lynis on your system by cloning the github repository: https://github.com/CISOfy/lynis
- Install the pandas library using the command
sudo pip3 install pandas.
- Once you have installed Lynis on your system, navigate to the Lynis directory where you will find a bunch of files along with an executable file called Lynis.
- Use the bash script (code is given below) to extract relevant information such as warning and suggestions given in the lynis report. create a file called run.sh and copy paste the bash code into that file and type:
sudo ./run.shto run the bash script.
- Run the Python script (code is given below) to clean and parse the extracted data and output the relevant information as an excel file.
You must run a Linux/Unix based OS such as Ubuntu, Mac Os or any other Linux distribution.
Below are the Bash and Python scripts –
Once you run the above scripts, you will find a folder called outputs in the current directory. navigate to the outputs folder where you will find excel sheets that contain warnings, suggestions and installed packages.
- Python | os.system() method
- Get Your System Information - Using Python Script
- Student management system in Python
- Python | Implementation of Movie Recommender System
- Python - Get Hardware and System information using platform module
- List all the Microphones connected to System in Python using PyAudio and SpeechRecognition
- What is Linux System Administration?
- Timer in C++ using system calls
- Introduction to UNIX System
- Tableau - File System
- 5 Ways to Keep Your Ubuntu System Clean
- Users in Linux System Administration
- Groups in Linux System Administration
- Introduction to Linux Operating System
- FaceNet - Using Facial Recognition System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.