Files
This page describes Open-AudIT version 7. Content for earlier versions is kept further down the page, under Pre version 7.
Files
What is it?
On every server there's a handful of files that really matter. The sudoers file, the SSH daemon config, the web server config, that scheduled script finance depends on. When one of them changes, you want to know, and you especially want to know when nobody admits to changing it.
Files is change monitoring for exactly those. You name the files and directories worth watching, and every audit from then on records their size, ownership, permissions and a hash of their contents. When any of it changes, the change is recorded against the device like any other change Open-AudIT tracks. Windows and Linux targets are supported.
You'll find it at menu > Settings > Files. It is a feature available to Open-AudIT Enterprise licensed customers.
What does it do?
Your paths ride along with the audit. A Files entry is just a path and a description. Whenever an audit script is prepared, for a discovery or for download, every entry is written into the script's configuration section. The path style decides who gets it: paths starting with a / go into the Linux and Unix scripts, Windows style paths go into the Windows script. A Linux path never troubles a Windows machine, it simply isn't given to it.
The audit reads the files. A path can be a single file or a directory, and a directory, given with a trailing slash, means every file in it. For each file the script records:
Target | What is recorded per file |
|---|---|
Windows | Name, directory, size, a SHA-256 hash of the contents, last changed, permissions, owner, and the version where the file carries one. |
Linux | Name, directory, size, a SHA-1 hash of the contents, last changed, metadata change time, permissions, owner, group and inode. |
Changes are tracked like everything else. The details land in the file database table and are stored against the device with the same first seen, last seen and current handling as any other attribute. An alert is raised when any of full_name, hash, inode or last_changed changes, so an edited file, a replaced file or a permission change shows up in the device's change history, and the rules and alerting you already use apply.
How does it work?
Every audit script carries a marked configuration section. When Open-AudIT prepares a script it writes your entries in below the marker. With a directory entry of /etc/init.d/, the Linux script's section ends up like this.
# DO NOT REMOVE THE LINE BELOW
# Configuration from web UI here
files[1]="/etc/init.d/"The script then works through the files[] array and reports the details of each file it finds. Nothing else in the script changes.
You aren't limited to discovery either. The same populated script can be downloaded from the scripts endpoint and run however you like. See the Scripts help page for that.
Why?
The hash doesn't take anybody's word for it. A file can keep its size, its date and its name and still have different contents. The content hash catches the edit that was made to look like no edit at all.
It's the cheap end of file integrity monitoring. No agent to deploy, no separate product to run. If a machine is being audited, it can be watching files, and the results sit next to the rest of the machine's history rather than in another console.
Directories catch what you didn't name. Watching /etc/init.d/ or a web root as a directory means a file added there turns up too, not just changes to files you knew about.
How?
Two steps, and one Windows server note.
1. Create the entries. Go to menu > Settings > Files > Create Files. Give each entry a name, an organisation, and the path. A directory should end with its slash, /etc/init.d/ style on Linux, and Windows paths are written the Windows way, c:\windows\system32\drivers\etc\ for example. There's an import at menu > Settings > Files > Import Files when you have a list. One thing worth knowing, entries are global, so a Linux path is read on every Linux machine audited, not on a machine of your choosing. Name paths that make sense everywhere they exist.
The Create Files form in version 7.
2. Audit as usual. There's nothing to attach and nothing to schedule separately. The next discovery that audits a machine carries the entries with it, and the results appear on the device's page with its other components. From then on, changes appear in the device's change history as they're found.
The Windows server note. If your Open-AudIT server runs on Linux, skip this paragraph. On a Windows Open-AudIT server, the Apache service runs as the Local System account, which has no access to network resources, and that gets in the way of the file collection that has to run on the target. The fix is to run the Apache service as a real account, the local Administrator being the simplest choice. There's a walkthrough in the built in help at menu > Help > FAQ, under Running Open-AudIT Apache Service Under Windows.
Pre version 7. Everything below this line describes Open-AudIT before version 7. Menus, screens and behaviour may differ.
Pre version 7
Introduction
Open-AudIT can now retrieve details about a file or directory of files and monitor these files for changes as per other attributes in the Open-AudIT database.
This feature works out of the box for Linux Open-AudIT servers, but needs a change to the service account name under a Windows Open-AudIT server.
Supported clients are Windows and Linux.
How does it Work?
When a device is Discovered the audit script will be injected with the file (or directory) details. Both audit_linux.sh and audit_windows.vbs will be populated, regardless of the file path. If you're thinking "but putting a Linux path into a Windows machine will break things!", it won't break, you just won't receive any data from that file or directory entry.
Retrieved details will be stored in the "file" database table and are stored like any other attribute. File details will be stored as any other attribute and generate alerts if any of the following attributes change - 'full_name', 'hash', 'inode', 'last_changed'. The table contain a system_id, first_seen, last_seen and current columns as well as the file details.
Attributes recorded are:
Windows - name, size, directory, SHA1 hash (of the file contents), last changed, permissions, owner, version (file permitting).
Linux - name, size, directory, SHA1 hash (of the file contents), last changed, meta data last changed, permissions, owner, group, inode.
You will see a section in both the Windows and Linux audit scripts as below:
# DO NOT REMOVE THE LINE BELOW# Configuration from web UI here
Below these lines are where the variables are injected into the script. Following on from our earlier example, the Linux audit script is populated with our directory like so:
# DO NOT REMOVE THE LINE BELOW# Configuration from web UI herefiles[1]="/etc/init.d/"
The audit script will use the files[ ] array and retrieve the file details.
If you would like to use the script outside of Discovery we have created another endpoint called "scripts". See the documentation here - Scripts.
Creating File Entries
To create an entry to track either a single file or a directory of files, use Open-AudIT Enterprise and go to menu: Discover-> Files -> Create Files. Create a file by providing values for the path (either the file or a directory with a trailing slash) and an optional description. Click Submit. Once you have created the file you will see it appear in the list at Discover -> Files -> List Files.
An entry will be create in the Open-AudIT database, in the "files" table.
Viewing File Details
Go to menu: Discover -> Files -> List Files.
You will see a list of files. You can view a file by clicking on the blue view icon. You can also edit or delete your file.
Enabling the Feature Under Windows
There is no need to do anything if you're running Open-AudIT on a Linux server.
Windows clients are just fine and require no special actions, however.... to enable this feature the audit script must be run locally on the target Windows system. It cannot be run remotely as we do with WMI calls when running the audit script on one Windows machine, while targeting a second Windows machine. To do this we need to copy the audit script to the target Windows machine and then run it. Unfortunately the service account that Apache runs under is the Local System account. This account has no access to remote (network based) resources. To work around this issue the service must be run under another account. It is easiest to just use the local Administrator account, but you can try any account you like as long as it has the required privileges. The Local System account has as much local access as the local Administrator account.
Navigate to the Service list.
Double click the apache 2.2 service.
Click the tab for logon and then click the "this account" option. You might want to click the Browse button and search for the account. Click OK and then restart the service.
Apache will now be running under an account with network access and Open-AudIT will now be able to copy the audit script to the target Windows machine and run it, hence retrieving file details.
Database Schema
The database schema can be found in the application is the user has database::read permission by going to menu: Admin -> Database -> List Tables, then clicking on the details button for the table.
API / Web Access
You can access the collection using the normal Open-AudIT JSON based API. Just like any other collection. Please see The Open-AudIT API documentation for further details.