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
- Python | Implementation of Movie Recommender System
- Timer in C++ using system calls
- dup() and dup2() Linux system call
- Groups in Linux System Administration
- Users in Linux System Administration
- Operating System | The Linux Kernel
- proc file system in Linux
- SAR command in Linux to monitor system performance
- Maximum number of Zombie process a system can handle
- Linux Operating System | CLI (Command Line Interface) and GUI (Graphic User Interface)
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Sort Python Dictionaries by Key or Value
- Python | Set 4 (Dictionary, Keywords in Python)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.