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
- Student management system in Python
- Python | Implementation of Movie Recommender System
- What is Linux System Administration?
- Introduction to UNIX System
- Timer in C++ using system calls
- proc file system in Linux
- Groups in Linux System Administration
- Users in Linux System Administration
- Introduction to Linux Operating System
- dup() and dup2() Linux system call
- SAR command in Linux to monitor system performance
- Maximum number of Zombie process a system can handle
- How to check if a directory or a file exists in system or not using Shell Scripting?
- Linux Operating System | CLI (Command Line Interface) and GUI (Graphic User Interface)
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.