Skip to Content
Cybersecurity Ops with bash
book

Cybersecurity Ops with bash

by Paul Troncone, Carl Albing
April 2019
Intermediate to advanced
303 pages
6h 16m
English
O'Reilly Media, Inc.
Content preview from Cybersecurity Ops with bash

Chapter 21. Tool: Validating Configuration

As a system administrator or security practitioner, it is useful to have a tool that allows you to verify the current configuration of a system, such as files that exist, registry values, or user accounts. In addition to verifying a configuration, this technique can be used as a lightweight host intrusion-detection system by recording a baseline configuration and then monitoring for variations from that baseline. You can also use it to look for specific indicators of compromise.

In this chapter, we develop a tool to read in a text file that consists of a series of configurations to validate, such as the existence of a file or user, and verify that the condition exists on the system. This tool is targeted at the Windows operating system but could easily be modified to support Linux.

Implementation

The validateconfig.sh tool validates the following:

  • The existence or nonexistence of a file

  • The SHA-1 hash of a file

  • A Windows Registry value

  • The existence or nonexistence of a user or group

Table 21-1 shows the syntax for the configuration file the script will read.

Table 21-1. Validation file format
Purpose Format

Existence of a file

file <_file path_>

Nonexistence of a file

!file <_file path_>

File hash

hash <_sha1 hash_> <_file path_>

Registry key value

reg "<_key path_>" "<_value_>" "<_expected_>"

Existence of a user

user <_user id_>

Nonexistence of a user

!user <_user id_>

Existence of a group

group <_group ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Linux Basics for Hackers

Linux Basics for Hackers

OccupyTheWeb .
Hacking Kubernetes

Hacking Kubernetes

Andrew Martin, Michael Hausenblas

Publisher Resources

ISBN: 9781492041306Errata Page