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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- PyQt5 QCalendarWidget - Mapping Co-ordinate system to Calendar co-ordinate system
- PyQt5 QCalendarWidget - Mapping co-ordinate system from Calendar co-ordinate system
- Python - Get Hardware and System information using platform module
- List all the Microphones connected to System in Python using PyAudio and SpeechRecognition
- Getting System and Process Information Using C Programming and Shell in Linux
- Get Your System Information - Using Python Script
- Timer in C++ using system calls
- How to check if a directory or a file exists in system or not using Shell Scripting?
- FaceNet - Using Facial Recognition System
- Voting System Project Using Django Framework
- System tray applications using PyQt5
- Menu driven program for system control using C++
- Intrusion Detection System Using Machine Learning Algorithms
- How to Setup VPN on Ubuntu Linux System for IP Spoofing Using windscribe?
- Python | Implementation of Movie Recommender System
- Python | os.system() method
- Student management system in Python
- Python - Getting all the Wifi Devices the system has connected
- Movie tickets Booking management system in Python
- dup() and dup2() Linux system call
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.