<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stéphan Zych</title>
    <description>The latest articles on DEV Community by Stéphan Zych (@monkeymonk).</description>
    <link>https://dev.to/monkeymonk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F50292%2Ffca9b26f-eac8-44ad-a847-bb8cd549ff68.png</url>
      <title>DEV Community: Stéphan Zych</title>
      <link>https://dev.to/monkeymonk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/monkeymonk"/>
    <language>en</language>
    <item>
      <title>We've Been Hacked!</title>
      <dc:creator>Stéphan Zych</dc:creator>
      <pubDate>Tue, 29 Jul 2025 08:10:37 +0000</pubDate>
      <link>https://dev.to/monkeymonk/weve-been-hacked-4g1o</link>
      <guid>https://dev.to/monkeymonk/weve-been-hacked-4g1o</guid>
      <description>&lt;h1&gt;
  
  
  🏴‍☠️ We’ve Been Boarded!
&lt;/h1&gt;

&lt;p&gt;Billions of blistering barnacles! One of our ships has been boarded.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A calm, professional, pirate‑approved guide to surviving a security incident without losing the ship, the cargo, or your sanity.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Purpose of This Logbook
&lt;/h2&gt;

&lt;p&gt;This document is an &lt;strong&gt;incident‑response playbook&lt;/strong&gt; for web applications in general.&lt;/p&gt;

&lt;p&gt;While command snippets may reference common tools found in many environments (Linux servers, web servers, databases, containers), the &lt;strong&gt;procedure itself is deliberately stack‑agnostic&lt;/strong&gt; and applies to any traditional web application stack.&lt;/p&gt;

&lt;p&gt;The intent is to describe &lt;em&gt;what must be done and in which order&lt;/em&gt;; adapt the commands to your vessel, sails, and seas.&lt;/p&gt;

&lt;p&gt;Its goals are to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;De‑escalate stressful situations (for clients &lt;em&gt;and&lt;/em&gt; developers)&lt;/li&gt;
&lt;li&gt;Preserve evidence for technical or legal needs&lt;/li&gt;
&lt;li&gt;Protect user and client data&lt;/li&gt;
&lt;li&gt;Restore service safely&lt;/li&gt;
&lt;li&gt;Ensure we almost never lose data thanks to modern practices&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Golden Rule of the Seas&lt;/strong&gt;: Panic sinks ships. Procedure keeps them afloat.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧭 The Pirate Code (Read Before Acting)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Stop the bleeding before swabbing the deck&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preserve evidence before fixing anything&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assume the ship is compromised until proven otherwise&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Restore from trusted charts, don’t patch rotten planks&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Say only what you know — speculation feeds mutiny&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  ⚓ Phase 1 — Freeze the Moment (Snapshots &amp;amp; Evidence)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Goal: Capture &lt;em&gt;everything&lt;/em&gt; before the winds shift.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1.1 Open an Incident Chest
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;INCIDENT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/quarantine/incident-&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%F-%H%M&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;700 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This chest is &lt;strong&gt;read‑only evidence&lt;/strong&gt;. Never clean or modify it.&lt;/p&gt;




&lt;h3&gt;
  
  
  1.2 Secure the Cargo Hold (Application Files)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-aHAX&lt;/span&gt; &lt;span class="nt"&gt;--numeric-ids&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  /var/www/ &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/www/"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gives a forensic snapshot&lt;/li&gt;
&lt;li&gt;Protects you from accidental data loss&lt;/li&gt;
&lt;li&gt;Buys time to think clearly&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  1.3 Bottle the Rum (Database Backup)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;MySQL / MariaDB&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;--single-transaction&lt;/span&gt; &lt;span class="nt"&gt;--routines&lt;/span&gt; &lt;span class="nt"&gt;--events&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--all-databases&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/db.sql"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PostgreSQL&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pg_dumpall &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/db.sql"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  1.4 Capture the Ship’s Logbooks (Logs)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /var/log/nginx &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/"&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /var/log/auth.log &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/"&lt;/span&gt;
journalctl &lt;span class="nt"&gt;--since&lt;/span&gt; &lt;span class="s2"&gt;"30 days ago"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/journal.log"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logs are often &lt;strong&gt;more valuable than code&lt;/strong&gt; when storms reach lawyers.&lt;/p&gt;




&lt;h3&gt;
  
  
  1.5 Note the Crew &amp;amp; Rigging (System State)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps auxfw &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/processes.txt"&lt;/span&gt;
ss &lt;span class="nt"&gt;-plant&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/network.txt"&lt;/span&gt;
crontab &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/crontab-root.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  1.6 Preserve the Captain’s Orders (Command History)
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Shell history can reveal attacker activity &lt;em&gt;or&lt;/em&gt; emergency commands run during the incident.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Capture command histories &lt;strong&gt;before logging out or restarting shells&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Root history&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /root/.bash_history &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/bash_history_root"&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# Current user history&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; ~/.bash_history &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/bash_history_user"&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If other shells are in use (zsh, fish), capture their history files as well.&lt;/p&gt;

&lt;p&gt;Why this matters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;attackers sometimes leave traces via interactive shells&lt;/li&gt;
&lt;li&gt;helps reconstruct timelines&lt;/li&gt;
&lt;li&gt;protects operators from "who ran what" uncertainty&lt;/li&gt;
&lt;/ul&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps auxfw &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/processes.txt"&lt;/span&gt;
ss &lt;span class="nt"&gt;-plant&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/network.txt"&lt;/span&gt;
crontab &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INCIDENT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/crontab-root.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🚧 Phase 2 — Containment (Batten Down the Hatches)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Goal: Stop further damage while looking calm and in control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2.1 Raise the Maintenance Flag (Maintenance Mode)
&lt;/h3&gt;

&lt;p&gt;Serve a static maintenance page while the crew works below deck.&lt;/p&gt;

&lt;p&gt;How this is done depends on your stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;web‑server level redirect&lt;/li&gt;
&lt;li&gt;application maintenance mode&lt;/li&gt;
&lt;li&gt;load‑balancer / gateway rule&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Principle&lt;/strong&gt;: stop user traffic cleanly while presenting a calm, professional message.&lt;/p&gt;

&lt;p&gt;Client message should always be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;calm&lt;/li&gt;
&lt;li&gt;short&lt;/li&gt;
&lt;li&gt;confident&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2.2 Full Quarantine (If the Kraken Is Active)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;iptables &lt;span class="nt"&gt;-I&lt;/span&gt; INPUT &lt;span class="nt"&gt;-p&lt;/span&gt; tcp &lt;span class="nt"&gt;--dport&lt;/span&gt; 80 &lt;span class="nt"&gt;-j&lt;/span&gt; DROP
iptables &lt;span class="nt"&gt;-I&lt;/span&gt; INPUT &lt;span class="nt"&gt;-p&lt;/span&gt; tcp &lt;span class="nt"&gt;--dport&lt;/span&gt; 443 &lt;span class="nt"&gt;-j&lt;/span&gt; DROP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use only when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;live exploitation is suspected&lt;/li&gt;
&lt;li&gt;data exfiltration is possible&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🗣️ Phase 3 — Control the Message
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Loose tongues sink ships.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Internal&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Incident contained”&lt;/li&gt;
&lt;li&gt;“Evidence preserved”&lt;/li&gt;
&lt;li&gt;“Investigation underway”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Client-facing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No speculation&lt;/li&gt;
&lt;li&gt;No blame&lt;/li&gt;
&lt;li&gt;Emphasize protection of data and professionalism&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔍 Phase 4 — Find How They Boarded
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;We don’t just clean the mess — we find the hole in the hull.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  4.1 Timeline Recon
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find /var/www &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-mtime&lt;/span&gt; &lt;span class="nt"&gt;-7&lt;/span&gt; &lt;span class="nt"&gt;-ls&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; recent-files.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.2 Black Magic Detection (Code Scanning)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rg &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"(eval&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="s2"&gt;|base64_decode|shell_exec|system&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="s2"&gt;|passthru|assert&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="s2"&gt;|gzinflate)"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.3 Access Log Recon
&lt;/h3&gt;

&lt;p&gt;Review web access logs for suspicious activity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Adapt path and tooling to your environment&lt;/span&gt;
zgrep &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"POST&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;upload&lt;/span&gt;&lt;span class="se"&gt;\|\.&lt;/span&gt;&lt;span class="s2"&gt;php"&lt;/span&gt; /var/log/&lt;span class="k"&gt;*&lt;/span&gt;access&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common boarding points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;file uploads&lt;/li&gt;
&lt;li&gt;admin endpoints&lt;/li&gt;
&lt;li&gt;executable files in upload directories&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4.4 Hidden Persistence
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lah&lt;/span&gt; /etc/cron&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔑 Phase 5 — Roll All Credentials
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Assume the enemy copied the keys.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rotate &lt;strong&gt;everything&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database users&lt;/li&gt;
&lt;li&gt;Application secrets (&lt;code&gt;.env&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;API keys&lt;/li&gt;
&lt;li&gt;OAuth tokens&lt;/li&gt;
&lt;li&gt;JWT secrets&lt;/li&gt;
&lt;li&gt;Admin passwords&lt;/li&gt;
&lt;li&gt;SSH keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;USER&lt;/span&gt; &lt;span class="s1"&gt;'appuser'&lt;/span&gt; &lt;span class="n"&gt;IDENTIFIED&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="s1"&gt;'NEW_STRONG_PASSWORD'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;FLUSH&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧱 Phase 6 — Restore From Trusted Charts
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Never patch a rotten plank.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  6.1 Code from Version Control Only
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; origin/main
git clean &lt;span class="nt"&gt;-fdx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Modern Rule&lt;/strong&gt;: Anything not in Git is considered lost at sea.&lt;/p&gt;




&lt;h3&gt;
  
  
  6.2 Reinstall Dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--no-dev&lt;/span&gt; &lt;span class="nt"&gt;--optimize-autoloader&lt;/span&gt;
npm ci &lt;span class="nt"&gt;--production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6.3 Carefully Reintroduce User Cargo
&lt;/h3&gt;

&lt;p&gt;Restore only:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;media uploads&lt;/li&gt;
&lt;li&gt;verified database rows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Never restore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;executable files&lt;/li&gt;
&lt;li&gt;modified core files&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🐳 Phase 7 — Containerized Ships
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Containers are disposable rowboats, not galleons.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If your application runs in containers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Do not attempt in‑place cleanup&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Assume images and runtime are tainted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If compromised:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Stop and destroy&lt;/span&gt;
container stop &amp;lt;container&amp;gt;
container &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container&amp;gt;

&lt;span class="c"&gt;# Rebuild from trusted sources&lt;/span&gt;
container build &lt;span class="nt"&gt;--no-cache&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; app:clean &lt;span class="nb"&gt;.&lt;/span&gt;
container run ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Distroless or minimal images offer fewer attack surfaces&lt;/li&gt;
&lt;li&gt;Forensics usually happen on the &lt;strong&gt;host, volumes, and CI pipeline&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Rotate all secrets&lt;/li&gt;
&lt;li&gt;Rebuild images from known‑good sources&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔐 Phase 8 — Guarding the Crew’s Data
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 Encryption at Rest
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Encrypted disks (LUKS / cloud KMS)&lt;/li&gt;
&lt;li&gt;Encrypted backups:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gpg &lt;span class="nt"&gt;--encrypt&lt;/span&gt; &lt;span class="nt"&gt;--recipient&lt;/span&gt; security@example.com db.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  8.2 Encryption in the App
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Passwords: &lt;code&gt;bcrypt&lt;/code&gt; or &lt;code&gt;argon2id&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Sensitive user data: application‑level encryption&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;never committed&lt;/li&gt;
&lt;li&gt;rotated&lt;/li&gt;
&lt;li&gt;stored in secret managers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  8.3 Backup Strategy (Modern Seamanship)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Back up&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;databases&lt;/li&gt;
&lt;li&gt;user uploads&lt;/li&gt;
&lt;li&gt;secrets (encrypted)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Do NOT back up&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;vendor directories&lt;/li&gt;
&lt;li&gt;build artifacts&lt;/li&gt;
&lt;li&gt;containers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;off‑site&lt;/li&gt;
&lt;li&gt;encrypted&lt;/li&gt;
&lt;li&gt;versioned&lt;/li&gt;
&lt;li&gt;restore tested regularly&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Phase 9 — Final Inspection
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;clamscan &lt;span class="nt"&gt;-r&lt;/span&gt; /var/www
rg &lt;span class="s2"&gt;"(eval&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="s2"&gt;|base64_decode)"&lt;/span&gt; /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;re‑enable traffic&lt;/li&gt;
&lt;li&gt;monitor logs closely&lt;/li&gt;
&lt;li&gt;watch for unexpected writes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📜 Phase 10 — Captain’s Report (Non‑Optional)
&lt;/h2&gt;

&lt;p&gt;Include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;timeline&lt;/li&gt;
&lt;li&gt;entry point (or unknown)&lt;/li&gt;
&lt;li&gt;affected data scope&lt;/li&gt;
&lt;li&gt;credentials rotated&lt;/li&gt;
&lt;li&gt;preventive actions taken&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This report protects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the client&lt;/li&gt;
&lt;li&gt;the crew&lt;/li&gt;
&lt;li&gt;future captains&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🍻 Final Words from the Captain
&lt;/h2&gt;

&lt;p&gt;A good incident response doesn’t prove the ship was unsinkable.&lt;/p&gt;

&lt;p&gt;It proves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;discipline&lt;/li&gt;
&lt;li&gt;professionalism&lt;/li&gt;
&lt;li&gt;and that even when boarded…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;you stayed in command of the seas. Celebrate with a liter of rum. 🥃&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
