Daily Blog #780: Self validating linux executables
文章介绍了如何通过 `rpm -Vf` 命令快速验证 Linux 系统中文件的完整性。该命令检查文件大小、权限、MD5 校验码等属性是否与安装包一致,帮助确认文件未被篡改。 2025-3-18 04:30:0 Author: www.hecfblog.com(查看原文) 阅读量:16 收藏

By March 17, 2025

Hello Reader,

When I first started doing Digital Forensics and Incident Response (DFIR) back in 2000, one challenge I faced was verifying the integrity of Linux executables. Often, systems didn't record file hashes during installation, and sometimes we didn't even have a reliable set of installation media to compare against.

To solve this problem, I initially wrote a lengthy Perl script. The script went through each installed package on the local system, comparing the file hashes on disk against the original package hashes, and then validating these against the official distribution hashes.

Today, this task is much simpler. On Linux systems using RPM (like RedHat, Fedora, or CentOS), you can quickly verify a file's integrity with a single command:

rpm -Vf /path/to/file

What does this command do?

  • rpm -V (or rpm --verify) checks the integrity of installed packages.
  • -f identifies the installed package that owns the specified file and then verifies the file against the original installed version.

Example Output:

Running the command might give you output like this:

S.5....T.  c /etc/httpd/conf/httpd.conf

Here's what those verification flags mean:

Flag Meaning
S File size differs
M Mode (permissions) differs
5 MD5 checksum differs
D Device number mismatch
L Symlink path differs
U User ownership differs
G Group ownership differs
T Modification time differs
P Capabilities differ
. Test passed (no changes)

If the command produces no output, the file exactly matches what's included in the installed RPM package.

Quick Example:

rpm -Vf /usr/bin/bash

This command verifies the integrity of the bash executable against the installed bash RPM package.


文章来源: https://www.hecfblog.com/2025/03/daily-blog-780-self-validating-linux.html
如有侵权请联系:admin#unsafe.sh