<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mariam Obeid on Medium]]></title>
        <description><![CDATA[Stories by Mariam Obeid on Medium]]></description>
        <link>https://medium.com/@mko244?source=rss-3557e0800640------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7cv3SILmure4KICm</url>
            <title>Stories by Mariam Obeid on Medium</title>
            <link>https://medium.com/@mko244?source=rss-3557e0800640------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:17:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mko244/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automated File Integrity Verification at System Initialization Level on Linux Systems]]></title>
            <link>https://medium.com/@mko244/automated-file-integrity-verification-at-system-initialization-level-on-linux-systems-e0689e45f551?source=rss-3557e0800640------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0689e45f551</guid>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Mariam Obeid]]></dc:creator>
            <pubDate>Sun, 21 Jul 2024 20:30:55 GMT</pubDate>
            <atom:updated>2024-08-21T11:54:39.145Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>File integrity verification is a crucial aspect of system security, aimed at detecting unauthorized modifications to critical system files. This article presents a method for automated file integrity checking during system initialization on Linux systems. By employing cryptographic hash functions and leveraging the systemd service manager, the proposed solution ensures that any discrepancy in the integrity of files within the /bin and /sbin directories triggers a response to protect the system. This proactive measure helps prevent potential security breaches caused by unauthorized file alterations.</blockquote><h3>1. Introduction</h3><p>Maintaining the integrity of system files is fundamental to securing a Linux environment. Critical system directories, such as /bin and /sbin, contain essential executable files and utilities. Unauthorized changes to these files can lead to severe security vulnerabilities. This research aims to develop a bash script that runs at the system initialization level to verify the integrity of all files in these directories. If integrity issues are detected, the system will take appropriate action to prevent further potential damage.</p><h3>2. Background and Related Work</h3><p>File integrity monitoring (FIM) involves validating system files to ensure they have not been altered maliciously. Traditional methods use tools like Tripwire and AIDE, which generate cryptographic checksums of files and compare them against known baselines. However, these tools typically run as part of periodic checks or manual processes. This research proposes an automated approach integrated into the system’s initialization sequence, enhancing real-time protection capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OodpsAWC9vjT5ZQPPORhMg.png" /></figure><h3>3. Methodology</h3><p>This section outlines the systematic approach to implementing an automated file integrity verification mechanism during system initialization.</p><h4>3.1 System Initialization</h4><p>Modern Linux distributions use systemd for managing system and service initialization. Custom services can be defined to execute scripts at specific stages of the boot process. This project leverages systemd to create a service that runs a bash script checking file integrity.</p><h4>3.2 Cryptographic Hash Functions</h4><p>Cryptographic hash functions, such as SHA-256, are utilized to create unique fingerprints for files. These hashes are stored as baseline references and compared against current hashes to detect any modifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*w7Me1UZsH6Q3y8TyAPzIeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38C3L98n8woK21gOtV6XMw.png" /></figure><h4>3.3 Script Implementation</h4><p>The implementation involves two main scripts:</p><ol><li><strong>Baseline Hash Generation Script:</strong> Creates initial hash values for all files in /bin and /sbin.</li><li><strong>Integrity Check Script:</strong> Compares current hash values with the baseline at each system boot.</li></ol><h3>4. Implementation</h3><h4>4.1 Baseline Hash Generation Script</h4><p>The baseline script generates SHA-256 hashes for all files in /bin and /sbin, storing them in a secure location.</p><pre>#!/bin/bash<br># Generate baseline hashes for /bin and /sbin files<br>find /bin /sbin -type f -exec sha256sum {} \; &gt; /root/baseline_hashes.txt</pre><h4>4.2 Integrity Check Script</h4><p>The integrity check script runs at system initialization, generating current hashes and comparing them with the baseline. If discrepancies are found, the system logs the event and shuts down to protect the system.</p><pre>#!/bin/bash<br># Check file integrity at system initialization<br><br># Load baseline hashes<br>BASELINE_HASHES=&quot;/root/baseline_hashes.txt&quot;<br><br># Create a temporary file to store current hashes<br>CURRENT_HASHES=$(mktemp)<br><br># Generate current hashes<br>find /bin /sbin -type f -exec sha256sum {} \; &gt; &quot;$CURRENT_HASHES&quot;<br><br># Compare current hashes with baseline<br>if ! cmp -s &quot;$BASELINE_HASHES&quot; &quot;$CURRENT_HASHES&quot;; then<br>    echo &quot;File integrity check failed. Notifying administrator and initiating system shutdown.&quot;<br>    # Log the issue<br>    logger &quot;File integrity check failed. System is shutting down.&quot;<br>    # Trigger system shutdown<br>    shutdown -h now<br>fi<br><br># Clean up<br>rm -f &quot;$CURRENT_HASHES&quot;</pre><h4>4.3 Systemd Service</h4><p>A custom systemd service ensures the integrity check script runs at boot time.</p><pre>[Unit]<br>Description=File Integrity Check at Init Level<br>DefaultDependencies=no<br>After=local-fs.target<br><br>[Service]<br>Type=oneshot<br>ExecStart=/root/file_integrity_check.sh<br>TimeoutSec=0<br>RemainAfterExit=yes<br><br>[Install]<br>WantedBy=sysinit.target</pre><p>This service file is saved as /etc/systemd/system/file_integrity_check.service and enabled with:</p><pre>sudo systemctl enable file_integrity_check.service</pre><h3>5. Testing and Validation</h3><h4>5.1 Baseline Hash Generation</h4><p>Run the baseline hash generation script to create initial hashes:</p><pre>sudo /root/baseline_hash_generation.sh</pre><h4>5.2 Integrity Check Validation</h4><ol><li>Modify a file in /bin or /sbin to simulate an integrity breach.</li><li>Reboot the system.</li><li>Observe the system’s behavior, ensuring it shuts down if discrepancies are detected.</li></ol><h3>6. Discussion</h3><p>The proposed method effectively integrates file integrity checking into the system’s initialization process, providing an automated and immediate response to potential security threats. The use of cryptographic hashes ensures reliable detection of unauthorized modifications. However, this approach may introduce a minor delay during system boot and requires secure storage of baseline hashes.</p><h3>7. Conclusion</h3><p>This research demonstrates a robust method for enhancing Linux system security through automated file integrity verification at the initialization level. By leveraging systemd services and cryptographic hash functions, the implemented solution ensures critical system files remain unaltered, immediately responding to potential breaches with a system shutdown.</p><h3>8. Future Work</h3><p>Future enhancements could include:</p><ol><li>Implementing more sophisticated alert mechanisms (e.g., logging, notifications).</li><li>Extending the integrity check to additional critical directories.</li><li>Optimizing performance to minimize boot time impact.</li></ol><h3>References</h3><ul><li>Kim, G. H., Spafford, E. H., &amp; Spafford, G. H. (1994). The design and implementation of Tripwire: A file system integrity checker. Purdue University.</li><li>Tripwire Open Source. (n.d.). Retrieved from <a href="https://github.com/Tripwire/tripwire-open-source">https://github.com/Tripwire/tripwire-open-source</a></li><li>AIDE — Advanced Intrusion Detection Environment. (n.d.). Retrieved from <a href="https://aide.github.io/">https://aide.github.io/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0689e45f551" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>