Calculates the MD5 value in the directory, which is used to compare files after being tampered with

Source: Internet
Author: User

Calculates the MD5 value in the/etc directory for the file to be tampered with, following the command:

find/etc/-maxdepth 1-type F | Xargs-n1 md5sum>/root/etc_sum-$ (date +%f). log

The same truth,

We can/usr/bin/usr/sbin//usr/local/bin/root/bin and so on the important directory of the file checksum is calculated once, so that the regular execution of the command, generate a new checksum, Compare the generated log file with the original md5sum.log by using the diff command.

If there is a change, the server may be compromised, need to promptly check the poison (check the poison, you can use ClamAV this software, Epel source has this RPM package)


Here is the script I wrote about whether the test file has changed, Sir, as a sample of the original MD5 checksum, as follows:

Find/bin-maxdepth 1-type F | Xargs-n1 md5sum >/home/sum/bin_sum_ori.log find/sbin-maxdepth 1-type F | Xargs-n1 md5sum >/home/sum/sbin_sum_ori.log



Then, write the/home/scripts/chkmd5sum.sh script, the following script I only/sbin and/bin under the file md5sum do the check, the other can be referenced to add:

#!/bin/bashbin_sum_log= "/home/sum/bin_sum-$ (date +%f). LOG" sbin_sum_log= "/home/sum/sbin_sum-$ (date +% F). Log "find /bin -maxdepth 1 -type f | xargs -n1 md5sum >   $BIN _sum_logfind /sbin -maxdepth 1 -type f | xargs -n1  md5sum >  $SBIN _sum_logif ! diff  $BIN _sum_log  /home/sum/bin_sum_ori.log  > /dev/null ;thenecho  "Some file ' s md5sum is changed in  /bin,please check "|mail -s " warning, /bin checksum not matched " [email  protected]fiif ! diff  $SBIN _sum_log  /home/sum/sbin_sum_ori.log >  /dev/null ;thenecho  "Some file ' s md5sum is changed in /sbin,please  check "|mail -s " warning, /sbin checksum not matched " [email  Protected]fi


Then we add a Cron scheduled task (below), 0 points a day 30 check the execution of the script, detect whether the file changes.

Echo ' 0 * * */bin/bash/home/scripts/chkmd5sum.sh >/dev/null 2>&1 ' >>/var/spool/cron/root


Of course, there is a Linux under the software called Tripwire, it is more powerful, interested in Baidu can be their own under.

Calculates the MD5 value in the directory, which is used to compare files after being tampered with

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.