業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

OracleLinux10.1 : Tripwire , Chkrootkit , DNS update Script , Logwatch , Disk Usage Check Script

Tripwire

1.Install

2. Passphrase setting

Set site passphrase and local passphrase

------------------------------------------------
The Tripwire site and local passphrases are used to sign a variety of
files, such as the configuration, policy, and database files.

Passphrases should be at least 8 characters in length and contain both
letters and numbers.

See the Tripwire manual for more information.
------------------------------------------------
Creating key files…

(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)

Enter the site keyfile passphrase: [site pass]
Verify the site keyfile passphrase: [site pass]
Generating key (this may take several minutes)…Key generation complete.

(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)

Enter the local keyfile passphrase: [local pass]
Verify the local keyfile passphrase: [local pass]
Generating key (this may take several minutes)…Key generation complete.

------------------------------------------------
Signing configuration file…
Please enter your site passphrase: [site pass]
Wrote configuration file: /etc/tripwire/tw.cfg

A clear-text version of the Tripwire configuration file:
/etc/tripwire/twcfg.txt
has been preserved for your inspection. It is recommended that you
move this file to a secure location and/or encrypt it in place (using a
tool such as GPG, for example) after you have examined it.

------------------------------------------------
Signing policy file…
Please enter your site passphrase: [site pass]
Wrote policy file: /etc/tripwire/tw.pol

A clear-text version of the Tripwire policy file:
/etc/tripwire/twpol.txt
has been preserved for your inspection. This implements a minimal
policy, intended only to test essential Tripwire functionality. You
should edit the policy file to describe your system, and then use
twadmin to generate a new signed copy of the Tripwire policy.

Once you have a satisfactory Tripwire policy file, you should move the
clear-text version to a secure location and/or encrypt it in place
(using a tool such as GPG, for example).

Now run "tripwire --init" to enter Database Initialization Mode. This
reads the policy file, generates a database based on its contents, and
then cryptographically signs the resulting database. Options can be
entered on the command line to specify which policy, configuration, and
key files are used to create the database. The filename for the
database can be specified as well. If no options are specified, the
default values from the current configuration file are used.

3. Tripwire Configuration

Configuration File Edit

Create a Tripwire configuration file (cryptographically signed version)

Delete Tripwire configuration file (text version)

Policy File Settings

Contents of twpolmake.pl

Policy File Optimizations

Create policy file (cryptographically signed version) based on optimized policy file

Create database and check operation

Create test files

Check Tripwire operation

Delete test files

⑧ Creating a Tripwire Script for Reporting Results via Email

Contents of tripwire.sh

Confirmation that the results of the tripwire execution are notified to the specified e-mail address

Chkrootkit

Install a rootkit detection tool called chkrootkit to check whether a rootkit has been installed on the Linux server.
Since chkrootkit is checked using the following command, it is desirable to install it in the early stages after Linux installation, since it is useless after the command itself has been tampered with so that rootkit cannot be detected.

[Commands used by chkrootkit]
awk, cut, echo, egrep, find, head, id, ls, netstat, ps, strings, sed, uname

Note that chkrootkit can only detect known rootkits and cannot detect new rootkits.

①Download and install chkrootkit

Create /root/bin directory and move chkrootkit command to that directory

Check chkrootkit.

If the following error occurs
egrep: warning: egrep is obsolescent; using grep -E

④Create chkrootkit periodic execution script and change permissions
Create chkrootkit execution script in a directory where it is automatically executed daily

Scheduled Script Contents

Add execution permission to chkrootkit execution script

Backup commands used by chkrootkit

If the commands used by chkrootkit are tampered with, rootkit will not be detected.
Back up these commands.
If necessary, run chkrootkit with the backed up command

Run chkrootkit on the copied command

If nothing is displayed, no problem.

Compresses backed up commands

Send chkrootkit use command (compressed version) to root by e-mail

Download and save chkrootkit_cmd.tar.gz file to Windows

Delete commands on the backed up server

Logwatch

①Install

Edit configuration file

Output Logwatch reports

It will appear as follows

Test to see if the report arrives at the address you set. Check if you receive a log report email like the one above.

DNS Update Script

Each time the global IP changes, which happens when the network is disconnected or the router disconnects and reboots, the dynamic DNS must be accessed to inform the user that the global IP has changed.
DiCE used to do that work automatically, but since we can no longer use 32-bit software in OracleLinux10

We will create a dedicated script and run it periodically in Cron

This time we will set up DNS in Valudomain.

Contents of valuedomain.sh

I'll run it.

Introduce disk usage check script

1. Script Creation

Contents of disk_capacity_check.sh

2. Execution Confirmation

①Check current usage rates

It appears as follows

②Create a dummy file to achieve at least 80% utilization(In the example, it is called "dummyfile" and is about 6G)

③check again
Confirm that it is above 80% by performing the following

④Run check scripts

You will receive an email to the email address you have set up, stating something like "Disk usage alert: 86 %".

⑤Delete "dummyfile"

⑥Periodic Execution Setting

Copied title and URL