πŸ•ΉοΈ
Ghoulsec Vault
Website Toolbase
  • Welcome !
  • πŸ—ƒοΈExam Prep Notes
    • πŸ“”CEH V13 (Master Edition)
      • Module 02: Footprinting and Reconnaissance
      • Module 03: Scanning Networks
      • Module 04: Enumeration
      • Module 05: Vulnerability Analysis
      • Module 06: System Hacking
      • Module 07: Malware Threats
      • Module 08: Sniffing
      • Module 09 : Social Engineering
      • Module 10: Denial of Service
      • Module 11: Session Hijacking
      • Module 12: Evading IDS, Firewalls , Honeypots
      • Module 13: Hacking web servers
      • Module 14: Hacking Web Applications
      • Module 15:SQL Injection
      • Module 16: Wireless Attacks
      • Module 17: Hacking Mobile Platforms
      • Module 18: IoT & OT Hacking
      • Module 19 : Cloud Computing
      • Module 20 : Cryptography
    • πŸ“˜ISC2 -Certified in Cyber Security
      • Chapter -1 Security Principals
      • Chapter -2 Disaster Recovery,Business Continuity & Incident Response
      • Chapter -3 Access Control Concepts
      • Chapter -4 Network Security
      • Chapter -5 Security Operations
    • πŸ“—AZ - 900
      • Basics of Cloud Computing
        • Economic of Scale
        • CapEx & OpEx
        • Consumption based model
        • Cloud Deployment Models
        • Shared Responsibility Model
        • Data centers, Regions & Availability Zones & Geographyies in Azure
        • Resources & Resource Group
        • Azure Access Tools
        • Azure Service Lifecycle
        • Azure SLAs
        • Azure Cloud Adoption Framework
      • Azure Services
        • Azure Computing Services
        • Azure Networking Services
        • Azure Storage Services
        • Azure Database Service
        • Azure Marketplace
        • Big Data & Azure
        • Azure Serverless Computing
        • IoT & Azure
        • Other Azure Services
        • Azure Resource Locks & Resource Tags
        • Azure Security Services
          • Security Groups
          • Routing Tables
          • Azure Firewall
          • Azure DDOS Protection
          • Azure Identity & Access Management (Azure AD)
          • Azure RBAC
          • Azure Security Center
          • Azure Key Vault
      • Azure policies & Blueprints
      • Azure Cost Management
      • Azure Core Tenents
    • πŸ“—SC - 900
      • Zero Trust Model
      • Shared Responsibility Model
      • Defense in Depth
      • Security Controls
      • CIA Triad
      • Encryption / Hashing / Signing
      • Microsoft Security & Compliance Principals
      • Common Identity Attacks
      • Microsoft Identity as Primary Security Perimeter
      • Modern Authentication with Azure AD
      • Azure AD Identity Types
      • Azure External Identities
      • Hybrid Identities
      • Authentication Methods & Password Protection
      • Conditional Access
      • Azure AD Roles & RBAC
      • Governance in Azure AD
      • Azure Identity Protection
      • Azure NSG, DDOS, Firewall
      • Azure Bastion & Keyvault
      • Azure Encryption
      • Azure CSPM
      • Azure Security Center
      • Azure Defender
        • Microsoft O365 Defender
        • Azure Sentinel
      • Microsoft Cloud App Security
      • Microsoft Intune
      • Microsoft Complaince Manager
      • Information Protection
      • Microsoft insider risk capabilities
    • πŸ“”AWS Cloud Practitioner
      • Cloud Deployment
        • AWS Global Infrastructure
      • AWS Cloud Essentials
        • AWS SNS
          • AWS SQS
      • AWS Compute & Container Services
        • AWS EC2
          • Elasticity & Agility
        • AWS Serverless Computing
        • AWS Container Services
        • AWS Beanstalk
        • AWS Load Balancing
      • AWS Storage & Databases
      • AWS Networking
      • AWS Security
        • AWS Organisation
        • AWS Compliance
        • AWS DDOS
        • Additional Security Services
      • AWS Monitoring & Analytics
        • Other Analytics Services
      • AWS Pricing & Support
      • AWS Migration & Innovation
        • Migration Statergies
        • AWS Snow Family
        • AWS Transfer Family
        • Innovation on AWS
      • AWS Well Architecture Framework
      • Other AWS Services
  • πŸ§‘β€πŸ’»Cyber Security Base
    • Ghoul's Den
    • Cheatsheets
    • SSL Handbook
      • Installing OpenSSL
      • Encrypting Web Servers using SSL
      • Compiling .pfx file using openssl
      • De-compiling .pfx file
      • Zimbra Mail Server SSL renew
      • SSL Certificates
    • ☁️Cloud Security
      • Amazon Web Services (AWS)
        • AWS - IAM & Policy Management
        • AWS Organization
        • AWS - Roles (Assume Role)
        • AWS - EC2 (Elastic Computing)
        • AWS - VPC
        • AWS - Bastion Host
        • AWS Application Load Balancer
        • AWS Auto Scaling Group
        • AWS WAF
        • AWS - VPC Peering
        • AWS Transit Gateway
        • AWS NAT Gateway
        • AWS - Route 53
        • AWS Certificates Manager
        • AWS Network Load Balancer (NLB)
    • πŸ•ΈοΈNetwork Security
      • Firewalls
        • Sophos - Security Suite
          • Sophos Firewalls
      • VPN
        • VPNs
          • Wireguard Tunneling
          • StrongSwan Gateway VPN Server on Ubuntu
      • IP Address and IP Subnetting
      • Basic to Advance Networking Materials
    • πŸ§‘β€πŸ’»VAPT
      • Sample Report Templete
      • OWASP
        • OWASP Web Application Security & WebGoat
      • Web Application testing checklist
        • Client Side Penetration Testing
          • Clickjacking
          • Websockets
          • CSRF
          • XSS Filters
        • Server Side Penetration Testing
        • Advanced Web Application Pentesting
          • OAuth
          • JWT Injection
          • Server Side Templete Injection
    • β˜„οΈGRC
      • ISMS AUDIT PLAN
      • CIS Compliance Windows
    • πŸ”Forensic
      • Forensic Tools
      • EMAIL Forensics
      • File header forensics
    • Trend Micro
      • Deep Security
        • Installation & Prerequisite
          • Microsoft SQL server 2022
          • Postgres 16 Core
          • Installation
    • Practical Malware Analysis & API Threats
  • πŸ•ΉοΈServer are fun !
    • Securing Linux
      • Securing SSH
      • Sudoers
      • UFW (Uncomplicated FW)
      • Unattended Upgrades
      • Password Complexiety
      • Auditing Linux
      • Samba - SMB
      • NFS - Network File System
      • FTP
      • AIDE
    • Servers
      • Linux Sever
        • OpenLDAP Server Setup
          • ldap-account-manager
          • Securing OpenLDAP
          • OpenLDAP client setup
          • Checking LDAP setup
        • Users & Groups
        • Password Policy
        • File & File Permissions
        • Automatic Updates
        • Adding GUI to Ubuntu Server
        • DNS Server
        • NTP Server
      • Windows Sever
        • Deep dive into Windows Server
        • Windows server Installation
        • Disable IPv6
        • Disable Server Manager on startup
        • Promoting OS to AD server
        • AD DNS
        • AD DHCP
        • AD Activation
        • AD Users & Groups
        • AD FileServer
        • Adding Users into AD
        • Bulk Importing users into Domain
        • Windows AD Resources
        • Group Policy Editor
          • Creating First Policy
          • Restricting CMD & Powershell
          • Password Policies
          • Audit Policies
          • Log Retention Policy
          • Windows Defender Firewall
          • Patch Management & Window Updates
        • Setting Up local accounts for windows hosts
    • Hacking Systems
      • Linux Systems
        • Battery Charge Threshold (Linux)
        • Metasploitable OS Complete Solved
      • Tricking Windows
        • Bitlocker & Time based policy bypass
    • Monitoring HeartBeats
    • RAID Technology
    • Managing Partitions
      • Parted
      • Fdisk
      • LVM
        • Re-claiming unused disk space
        • Adding physical volume into VG
        • Removing physical volume from VG
      • SWAP Memory
    • Virtualization
      • Proxmox
        • Proxmox VE Installation
        • Default Storage Expansion
        • Proxmox Network Link Aggegration
        • NAT Interface Configuration
        • Importing disk into proxmox
        • Creating an LVM Thin Pool
        • Proxmox IAM
  • πŸ™β€β™‚οΈDan the AI Expert
    • Ollama Ollama ...
      • Ollama
        • Ollama models
        • Open Web UI & Ollama Integration
    • Microsoft Presentation using AI
  • πŸ›‘οΈSecurity Operations
    • Wazuh - Open Source XDR. Open Source SIEM.
      • Components
      • Deployment Methods
      • Installation
        • Single Node Installation
          • Wazuh Indexer Installation
          • Wazuh Server Installation
          • Wazuh Dashboard Installation
          • Single node deployment with Script
        • Managing multiple Wazuh clusters with Cross-Cluster Search
          • Cluster Configuration
          • Set up Cross-Cluster Search
        • Upgrading Wazuh Central Components
        • Uninstalling Wazuh
      • Custom Decoder & Rules
        • Pfsense Decoders
        • Pfsense Rules
      • Security Operations Center Tools (Wazuh)
    • IRIS-DFIR / Case Management
    • Graylog & ElasticSearch
    • Zabbix NMS
      • Zabbix Installation
      • Zabbix Database Management
        • Zabbix Database backup
        • Zabbix Database restore
        • MySQL Replication (M-M)
        • MySQL Replication (M-W)
      • Zabbix Geomap Setup
      • Adding Hosts into Zabbix
      • Zabbix Hostgroups
      • Auto Registration Hosts Zabbix
      • Zabbix Globalscrips
      • Zabbix HA Cluster
      • Zabbix Proxy
      • Zabbix Notifications
      • Zabbix Maintainance
      • Zabbix User Management & Authentication
      • Zabbix Housekeeping
      • Scheduled Reporting
      • Service Monitoring using Zabbix
  • Git the master!!
    • Configuring git
    • Git Branches
    • Undoing changes
    • Git - Cheat sheet
    • My first git...
Powered by GitBook
On this page
  • Use Cases
  • Searching & Parsing Logs
  1. Server are fun !
  2. Securing Linux

Auditing Linux

auditd is the Linux Audit Daemon responsible for writing audit records to disk, logging security-relevant events like user activity, system changes, and access to files or directories, helping with system monitoring and security compliance.

1. Install auditd on Ubuntu:

  1. Update the package list:

    bashCopysudo apt update
  2. Install the auditd package:

    bashCopysudo apt install auditd
  3. Verify installation:

    bashCopyauditctl -v

    If everything is installed correctly, it will show the version of the audit daemon.

2. Start and Enable auditd Service:

Once installed, you need to start the auditd service and enable it to start on boot.

  1. Start the auditd service:

    bashCopysudo systemctl start auditd
  2. Enable the auditd service to start on boot:

    bashCopysudo systemctl enable auditd
  3. Check the status of auditd:

    bashCopysudo systemctl status auditd

    This should show active (running) if it's working properly.


Configuring Auditd

The configuration files responsible for auditd is loacated on the following path :

/etc/audit/auditd.conf ## Config File
/etc/audit/audit.rules ## Rules File

Now we we set same basic configs under the config file :

$> sudo nano /etc/audit/auditd.conf    

From here we can set & change some basic configurations of the auditd modules and restart the service to apply the changes.

$> sudo systemctl restart auditd

Use Cases

Here are some common use cases for auditd and auditctl in Linux environments. These examples will help you understand how to configure the audit system for security monitoring, compliance, and auditing of key activities on the system.

1. Track File Access or Changes (File Integrity Monitoring)

Use Case: Monitor when critical system files or configuration files are accessed, modified, or deleted.

Example: Monitor changes to /etc/passwd (which contains user account information).

sudo auditctl -w /etc/passwd -p wa -k passwd_changes
  • Explanation: This rule watches the /etc/passwd file for write (w) and attribute change (a) permissions. If any changes occur, it will log the event with the key passwd_changes.

Use Case Application:

  • Useful for detecting unauthorized changes to user account files or sensitive configuration files, a common attack vector for attackers attempting to add themselves to the system.


2. Monitor Executable Command Usage

Use Case: Track when a user runs certain commands or programs, especially privileged ones.

Example: Monitor all executions of the sudo command.

sudo auditctl -a always,exit -F arch=b64 -S execve -F exe=/usr/bin/sudo -k sudo_usage
  • Explanation: This rule tracks the execution (execve) of the /usr/bin/sudo command on a 64-bit system. Any time a user runs sudo, it will be logged with the key sudo_usage.

Use Case Application:

  • Useful for detecting privilege escalation or unauthorized attempts to run commands with elevated privileges.


3. Monitor System Calls for Specific Activities

Use Case: Capture specific system calls made by applications or users, such as changes to the system or interaction with the kernel.

Example: Track file creation and deletion (via open and unlink syscalls).

sudo auditctl -a always,exit -F arch=b64 -S open -S unlink -k file_operations
  • Explanation: This rule monitors the open and unlink syscalls, which are used to open and delete files. Logs are tagged with the key file_operations.

Use Case Application:

  • This can help in tracking suspicious activities like file deletion or unauthorized file access in real time.


4. Monitor User Logins and Logouts

Use Case: Track user logins and logouts to detect unauthorized access attempts.

Example: Monitor user login attempts through sshd (SSH).

sudo auditctl -w /var/log/auth.log -p r -k user_logins
  • Explanation: This rule watches the /var/log/auth.log file for read (r) permissions, capturing any logins or authentication attempts.

Use Case Application:

  • Helps in identifying brute-force login attempts or unauthorized logins to the system via SSH.


5. Monitor Privileged Command Executions

Use Case: Track when users with administrative privileges perform critical actions on the system.

Example: Monitor when a user runs a command that requires root access, such as chmod or chown.

sudo auditctl -a always,exit -F arch=b64 -S chmod -S chown -k privileged_commands
  • Explanation: This rule tracks the chmod and chown syscalls, which are commonly used to change file permissions or ownership. Any use of these commands will be logged with the key privileged_commands.

Use Case Application:

  • Detects improper or unauthorized changes to file permissions or ownership, which could indicate an attempt to escalate privileges.


6. Monitor Network Configuration Changes

Use Case: Track changes to networking settings to prevent unauthorized modifications.

Example: Monitor changes to the network interfaces file (/etc/network/interfaces).

sudo auditctl -w /etc/network/interfaces -p wa -k network_changes
  • Explanation: This rule watches for write (w) or attribute changes (a) to the /etc/network/interfaces file, which typically contains network configuration information.

Use Case Application:

  • Useful for detecting unauthorized changes to network configurations, such as altering IP settings or adding new routes.


7. Monitor Sudo Usage for Privileged Commands

Use Case: Track any usage of sudo (which grants elevated privileges) to ensure users are only executing authorized commands.

Example: Track usage of sudo to run system commands.

sudo auditctl -a always,exit -F arch=b64 -S execve -F exe=/usr/bin/sudo -F uid!=0 -k non-root_sudo_usage
  • Explanation: This rule monitors for non-root users running the sudo command, and logs it with the key non-root_sudo_usage. It helps detect misuse or unusual usage of sudo by non-administrative users.

Use Case Application:

  • Helps track users who may be executing administrative tasks using sudo inappropriately.


8. Monitor Sensitive File Access (Read Operations)

Use Case: Monitor sensitive files or directories (e.g., /etc/passwd, /etc/shadow, or /root) for unauthorized read access.

Example: Monitor any read access to /etc/shadow (which contains password hashes).

sudo auditctl -w /etc/shadow -p r -k shadow_read
  • Explanation: This rule watches for read (r) access to the /etc/shadow file, where password hashes are stored. Any such access is logged with the key shadow_read.

Use Case Application:

  • Helps detect attempts by unauthorized users or processes to access sensitive user data, like password hashes.


9. Track System Reboots

Use Case: Detect when a system is rebooted, which may indicate potential unauthorized restarts or maintenance windows.

Example: Monitor reboot events by auditing the syslog.

sudo auditctl -w /var/log/syslog -p r -k system_reboot
  • Explanation: This rule watches the /var/log/syslog file for read (r) access. Any time the system is rebooted, entries will be created in syslog and captured under the key system_reboot.

Use Case Application:

  • Ensures visibility into when the system is restarted, which could be important for tracking incidents, outages, or suspicious behavior.


10. Detect Execution of Unauthorized Programs

Use Case: Track execution of specific programs that are not part of the approved list of applications.

Example: Track the execution of any program in the /tmp directory (which could be used for malicious programs).

sudo auditctl -w /tmp -p x -k tmp_program_execution
  • Explanation: This rule tracks executable programs (x permission) in the /tmp directory. Any execution of files in this directory will be logged under the key tmp_program_execution.

Use Case Application:

  • Useful for detecting malicious or unauthorized programs that are running from temporary directories, which are often used by attackers for malware.


Searching & Parsing Logs

1. ausearch

ausearch is a tool for searching the audit logs generated by auditd. It allows you to filter logs based on various criteria such as event type, user ID, key, timestamp, and more.

Common Uses of ausearch:

  • Search by Key:

    bashCopysudo ausearch -k <key>

    Example:

    bashCopysudo ausearch -k sudo_usage
    • Explanation: This searches for logs tagged with the key sudo_usage.

  • Search by Event Type (e.g., execve):

    bashCopysudo ausearch -m execve
    • Explanation: This searches for all execve syscalls in the audit logs.

  • Search by Date:

    bashCopysudo ausearch -ts 2025-02-20
    • Explanation: This searches for logs generated on February 20, 2025.

  • Search by User ID (UID):

    bashCopysudo ausearch -ui 1000
    • Explanation: This searches for logs associated with the user with UID 1000.


2. aureport

aureport generates summary reports from the audit logs. It helps in analyzing the collected audit data by aggregating logs based on various parameters such as event type, user, system call, etc.

Common Uses of aureport:

  • Generate a Summary of Audit Logs:

    bashCopysudo aureport
    • Explanation: Displays a general summary of the audit logs, showing the most common events and actions.

  • Generate a Report for a Specific Event Type (e.g., user logins):

    bashCopysudo aureport -u
    • Explanation: This generates a summary of all user login events.

  • Generate a Report for Syscalls:

    bashCopysudo aureport -s execve
    • Explanation: This generates a summary report of execve syscalls (executions of programs).

  • Generate a Report for All Authentication Events:

    bashCopysudo aureport -a
    • Explanation: Generates a report of authentication events, such as login attempts and sudo usage.


3. autrace

autrace is a command that allows you to trace system calls and events. It uses the auditd subsystem to capture and log system calls made by a process. It’s typically used for monitoring the activity of specific programs or system processes.

Common Use of autrace:

  • Trace a Specific Program's System Calls:

    bashCopysudo autrace <command>

    Example:

    bashCopysudo autrace ls
    • Explanation: This runs the ls command while tracing the system calls it makes and logs them with auditd.

  • Trace All Syscalls by a Program:

    bashCopysudo autrace -p <PID>
    • Explanation: This will trace all syscalls made by a process with the specified PID.

PreviousPassword ComplexietyNextSamba - SMB

Last updated 2 months ago

πŸ•ΉοΈ