Skip to main content

Linux auditing using Nessus

Nessus can scan a range of Linux flavours. As of writing these are:
  • CentOS
  • Debian
  • Fedora
  • Gentoo
  • Red Hat
  • Slackware
  • SuSE
  • Ubuntu
There are two types of scans Nessus can run against Linux hosts: 
  • Patch audit
  • Compliance audit

Patch audit - the plugin families are "[distro name] Local Security Checks". Nessus will audit targets and report on missing security patches based on advisories released by respective distributions. Nessus requires credentials in order to preform this type of scan as this are local checks. Tenable recommends that root level  credentials are used, though I have been able to successfully scan Linux hosts with a "standard" account. This however depends on distribution and how hardened it is.

On Red Hat distros Nessus executes the following commands which work with non-root accounts:

$rpm -qa
$uname -a

Nessus then compares its database with versions of kernel and installed packages.
  
Compliance audit - Tenable provides a number compliance audit files based on various industry best practices or regulations. The audit files can be downloaded from support forums. Compliance scan require elevated permissions as Nessus reads various system files. 


I generally opt for using elevated permissions in both types of scans.


Setting up an account used for scanning


In most cases SSHing directly with root account is disabled (which is a good thing from security standpoint). To confirm if it's disabled we can check /etc/ssh/sshd_confing. We need to look for line reading: "PermiRootLogin". If it's commented out or set to "yes". Root login is possible. 

Nessus can use standard account to connect and then elevate permissions using su, sudo, su + sudo. I generally opt for "sudo" option. In this case Nessus will prepend each command with sudo.

To create a user "auditor"  and add it to sudoers list do the following:

#useradd auditor
#passwd auditor

#vi /etc/sudoers  or simply #visudo

add the following line: 

auditor    ALL=(ALL)    ALL

This will allow user "auditor" to execute all commands including "sudo su" which would let the account to elevate to full root - which may not always be desired. This can be restricted by adding ",! /bin/su" at the end of the line. 

Nessus supports both password and key authentication. For highest level of security and scanning targets out on the internet key auth should be used. This would also apply to blanket scans, when you scan a whole subnet and not specific hosts. There is a risk of someone setting up an SSH server and intercepting the password. We'll use password authentication in our example.

Configuring Linux scanning policy in Nessus:


General:


I like leaving "Netstat SSH Scan" enabled to get a list of listening ports. Output from netstat is most accurate and least intrusive. 
Credentials:

1. Set credentials type to "SSH Settings"
2. Specify the user name
3. Set "Elevate privileges with" to "sudo" (or whatever method you chose)
4. Specify escalation password
5. optionally change ssh port


Plugins - Patch Audit policy:


We need to enable actual local security checks as well as relevant settings. I recommend enabling the whole "Settings" family as it contains a number of useful plugins besides required "SSH Settings" plugin.


1. enable desired local security checks family (for instance "CentOS Local Security Checks"
2. enable whole "settings" family 

Useful plugins in "settings" family:



19506 Nessus Scan Information - info about the scan itself


12634 Authenticated Check: OS Name and Installed Package Enumeration  - this plugin confirms whether supplied credentials worked and if Nessus was able to elevate permissions. If this plugin does not appear in scan output it means Nessus was unable to login to the target.  


21745 Authentication Failure - Local Checks Not Run - If this plugin appears in scan output it means that authentication did not work and Nessus was unable to login to the target. 

In additional to the above the following plugins provide additional information about Linux hosts:



33851 Network daemons not managed by the package system - lists software installed - in most cases - from source. These application will not be updated by the package manager and may indicate compromised host. 


25221 Remote listener enumeration  - show processes listening on ports
33276 Enumerate MAC Addresses via SSH - shows L2 interfaces

22869 Software Enumeration (SSH) - list of installed software
25202 Enumerate IPv6 Interfaces via SSH - shows IPv6 interfaces
25203 Enumerate IPv4 Interfaces via SSH - shows IPv4 interfaces

This is all we need to do to create oatch audit policy. 

Plugins - Compliance Audit policy:


For compliance audit we need to enable "Settings" family and plugin "21157 Unix Compliance Checks"


Preferences:

A desired audit policy file must be uploaded to Nessus server. 



Comments

Popular posts from this blog

x.509 Certificates - Critical vs non-critical extensions

Extensions are used to associate additional information with the user or the key.  Each certificate extension has three attributes - extnID, critical, extnValue extnID - Extension ID - an OID that specifies the format and definitions of the extension critical - Critical flag - Boolean value extnValue - Extension value  Criticality flag specifies whether the information in an extension is important. If an application doesn't recognize the extension marked as critical, the certificate cannot be accepted. If an extension is not marked as critical (critical value False) it can be ignored by an application. In Windows, critical extensions are marked with a yellow exclamation mark,  View certificate extensions using OpenSSL: # openssl x509 -inform pem -in cert.pem -text -noout (output abbreviated)         X509v3 extensions:             X509v3 Key Usage: critical          ...

DNS response and error types

In this post we explore common DNS response codes. We will cover the following responses: NOERROR SERVFAIL NXDOMAIN NODATA REFUSED Throughout article we’ll refer to the following RFCs: RFC 1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES RFC 2308 - Negative Caching of DNS Queries (DNS NCACHE) RFC 2136 - Dynamic Updates in the Domain Name System (DNS UPDATE) RFC 8914 - Extended DNS Errors Response Codes - RCODEs The DNS RCODES are best defined in RFC2316 .  They signify what type of response was sent by the server. “RCODE   Response code - this four bit field is undefined in requests and set in responses.”   The table below shows the summary of the currently defined RCODEs. Mnemonic Val Description NOERROR 0 No error condition. ...

DNS blocking in Indonesia

DNS based censorship and domain blocking in Indonesia is very inconsistent among ISPs. There’s a government mandated black list which the ISPs operating in the country should enforce. However, Indonesia lacks centralised internet infrastructure and has many separate ISPs. In addition, the Indonesian government granted ISPs the authority to block content at their own discretion. All of this leads to a very inconsistent DNS blocking in Indonesia. Official DNS domain blacklist in Indonesia The Government mandated DNS blacklist is published in a redacted form and can be downloaded here: https://trustpositif.kominfo.go.id/ . This is where the blocked domains get redirected to. We can search the database and check if a domain is blocked. In the screenshot below we can see that a popular cryptocurrency exchange is blocked (Ada) and that wikipedia.org is not (Tidak Ada) - thanks to Google Translate. Examples of blocked DNS queries dig binance.com @182.253.45.122 ;; global options: +cmd ;; Got ...