Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SHELL system file integrity check

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

System integrity audit tool

The shell script is as follows:

#! / bin/bash## variable can be declared before using shopt-s-o nounset# declaration # Establishment date Date=$ (date +'% Y% m% d% H% M% S') # directory added to the audit # Dirs= "/ bin/ sbin / usr/bin / usr/sbin / lib / usr/local/sbin / usr/local/bin / usr/local/lib" # temporary file # TMP _ file=$ (mktemp / tmp/check.XXXXXX) # File checksum storage file FP= "/ root/fp.$Date.chksum" # which checksum tool Checker= "/ usr/bin/md5sum" Find= "/ usr/bin/find" # function area # scan_file () {local f for fin $Dirs do $Find $f-type f > > $TMP_file done} # read Take the file to establish the checksum value cr _ checksum_list () {local f if [- f $TMP_file] for each file Then for f in $(cat $TMP_file); do $Checker $f > > $FP done fi} rmTMP () {[- f $TMP_file] & & rm-rf $TMP_file} # main program area # scan list the checksum value cr _ checksum_list# of the creation file cr _ checksum_list# cleans up the temporary file rmTMP

Script execution:

[root@node3 ~] # sh my_filecheck.sh

To verify:

Md5sum-c fp.20141205160628.chksum

If all OK, the word OK will be displayed. If there is a problem, the corresponding error will be reported, as follows:

[root@node3 ~] # md5sum-c fp.20141205160628.chksum | grep-v "OK" md5sum: / usr/bin/chattr: No such file or directory/usr/bin/chattr: FAILED open or readmd5sum: WARNING: 1 of 8267 listed files could not be read

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report