<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sumit Sah on Medium]]></title>
        <description><![CDATA[Stories by Sumit Sah on Medium]]></description>
        <link>https://medium.com/@er.sumitsah?source=rss-1c65c5cdd655------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XImOyZh2KWs0TUezakVsiA@2x.jpeg</url>
            <title>Stories by Sumit Sah on Medium</title>
            <link>https://medium.com/@er.sumitsah?source=rss-1c65c5cdd655------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:18:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@er.sumitsah/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Phishing Investigation Demystified: From Inbox to Incident Report]]></title>
            <link>https://medium.com/@er.sumitsah/phishing-investigation-demystified-from-inbox-to-incident-report-a3b7d28bc5b4?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3b7d28bc5b4</guid>
            <category><![CDATA[soc-l1-alert-triage]]></category>
            <category><![CDATA[soc-analyst]]></category>
            <category><![CDATA[phishing-attacks]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[phishing-email]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 08:12:48 GMT</pubDate>
            <atom:updated>2026-08-26T08:21:51.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*mhNbg4eiLR5q3WW0-fy2hw.png" /></figure><p>Phishing remains the most common initial access vector in modern breaches. The FBI IC3 continues to rank phishing and spoofing as the top reported crime category, while <a href="https://www.verizon.com/business/resources/T4a2/reports/2026-dbir-data-breach-investigations-report.pdf">Verizon’s Data Breach Investigations Report</a> consistently shows the human element contributing to roughly 60%+ of incidents. For SOC analysts, the difference between a closed ticket and a full-blown account takeover often comes down to a disciplined, repeatable investigation process.</p><p>This guide walks through that process end-to-end: from the moment a suspicious message lands in a user’s inbox, through authentication analysis (<strong>SPF, DKIM, DMARC</strong>), command-line evidence collection, alert triage integration, scoping, and finally the incident report. It draws on established SOC workflows (including practical frameworks published by teams such as <a href="https://www.prophetsecurity.ai/ai-soc-analyst">Prophet Security</a>) and points to open-source tooling that can accelerate the work.</p><h3>The Four Questions Every Phishing Investigation Must Answer</h3><p>A solid investigation answers these in sequence:</p><ol><li>Is the message genuinely malicious?</li><li>Who received it?</li><li>Did anyone interact with it (open, click, reply, or submit credentials)?</li><li>What is the blast radius and current exposure?</li></ol><p>The lure (credential harvest, BEC, brand impersonation, or abuse of legitimate services) changes the artifacts, but the questions stay the same. <a href="https://attack.mitre.org/">MITRE ATT&amp;CK</a> catalogs the delivery under <a href="https://attack.mitre.org/techniques/T1566/">T1566</a> and its sub-techniques; the investigation treats phishing as a delivery mechanism whose outcome must still be scoped.</p><h3>Step 1: Confirmation and Initial Triage</h3><p>Most reported messages turn out to be benign or low-impact. Still, every report needs validation because the cost of missing a real compromise is high. Confirmation includes:</p><ul><li>Deduplicating against known campaigns already under investigation.</li><li>Assigning a severity that drives prioritization (business impact over pure volume).</li><li>Checking whether the message has already been auto-quarantined or purged.</li></ul><p>This sits inside the broader <strong>alert triage</strong> pipeline. Alert triage is the systematic evaluation and classification of incoming signals so limited analyst time goes to the highest-risk items. Phishing reports are one input among endpoint, identity, cloud, and network alerts. Effective triage requires:</p><ul><li>Understanding the detection logic that fired.</li><li>Pre-correlated entity context (user, assets, recent related alerts).</li><li>Alert-type-specific investigation paths rather than a generic “check the logs” playbook.</li></ul><p>Severity-based prioritization alone creates blind spots: early-stage activity often surfaces as medium or low severity. High false-positive rates breed alert fatigue. Context assembly that forces analysts to jump across five consoles burns investigation time before real analysis begins. Structured, type-specific methodology and a feedback loop into detection engineering are what turn triage from a queue-management exercise into a quality control layer.</p><h3>Step 2: Evidence Collection — Headers, Authentication, and the Email Itself</h3><p>Preserve the original message in native format (.eml or .msg) with full headers and attachments intact <strong>before</strong> any remediation. Containment can destroy the very artifacts needed for the report or for law enforcement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PMloYpkb65ZXymK_U1tGjQ.png" /><figcaption>Example of authentication results from a mail security console showing SPF, DKIM, and DMARC all passing.</figcaption></figure><h4>Authentication Results: SPF, DKIM, and DMARC</h4><p>These three mechanisms form the first technical verdict most analysts look at.</p><ul><li><strong>SPF (Sender Policy Framework)</strong> checks whether the sending IP is authorized by the domain’s DNS TXT record.</li><li><strong>DKIM (DomainKeys Identified Mail)</strong> verifies a cryptographic signature over selected headers and the body.</li><li><strong>DMARC (Domain-based Message Authentication, Reporting &amp; Conformance)</strong> ties the two together with an alignment check and a policy (none / quarantine / reject).</li></ul><p>A message that shows <strong>PASS</strong> on all three is not automatically safe. Attackers routinely send from compromised legitimate infrastructure or use lookalike domains that pass authentication. Conversely, a hard FAIL is a strong signal but still requires correlation with content, URLs, and user interaction.</p><p>Here is a typical view of authentication results on a legitimate report message (the kind of screenshot an analyst might capture during investigation):</p><p>The highlighted section confirms:</p><ul><li><strong>SPF:</strong> PASS with a specific IP</li><li><strong>DKIM:</strong> PASS with the domain</li><li><strong>DMARC:</strong> PASS</li></ul><p>In real investigations you will also see SoftFail, Neutral, None, or Fail, plus the exact IP and selector used.</p><h4>DNS Record Structure (Quick Reference)</h4><p><strong>SPF example</strong></p><pre>v=spf1 include:_spf.google.com ip4:192.0.2.1 -all</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*dxvJsJCFxe7w1AxozYtRAQ.png" /></figure><p><strong>DKIM example</strong> (selector + public key)</p><p>Host: google._domainkey</p><p>Value: v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*Cd4i2OiEjXReLAeaXsCvOg.png" /></figure><p><strong>DMARC example</strong> (always at _dmarc.yourdomain.com )</p><p>v=DMARC1; p=quarantine; pct=100; rua=mailto:dmarc-reports@example.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*pkml4ysBEs3vkqP4JW2Uqw.png" /></figure><h4>DNS Verification (Command-Line)</h4><p>Once you have the From domain (and any lookalike domains that appear in the body or links), verify the published records directly:</p><pre># DNS checks for the From domain and any lookalikes<br>dig TXT example.com +short<br>dig TXT _dmarc.example.com +short<br>dig TXT selector._domainkey.example.com +short</pre><p>For richer automation, open-source projects such as <a href="https://phishguard-ai-dashboard.streamlit.app/"><strong>PhishGuard AI</strong></a> demonstrate hybrid pipelines (TF-IDF + SVM + heuristic scoring + Streamlit dashboard) that can ingest message text or structured fields and return a risk verdict with explanations. Use them as accelerators, never as replacements for judgment.</p><p>Live URLs and attachments should be detonated only in an isolated sandbox. Never open them on an analyst workstation that has production credentials or network access to internal resources.</p><h3>Step 3: Exposure and Interaction</h3><p>Identify every recipient. Partition them:</p><ul><li>Received only</li><li>Opened</li><li>Clicked link or opened attachment</li><li>Submitted credentials or replied</li></ul><p>Interaction turns a delivered message into an incident. Pull this data from the mail gateway, SIEM, or EDR/mail security console. For any interacting user, immediately review:</p><ul><li>Recent sign-in logs (impossible travel, new devices, unusual geographies)</li><li>Newly created inbox rules (especially auto-forward or delete)</li><li>OAuth grants and consented applications</li><li>Outbound mail volume and new contacts</li></ul><h3>Step 4: Scoping the Blast Radius</h3><p>Second-order indicators reveal whether the attacker moved beyond the original inbox. Look for <strong>lateral movement</strong>, additional mailbox access, persistence mechanisms, and any data that may have left the environment. Document every related alert on the same entity within the relevant time window.</p><h3>Step 5: Containment, Remediation, and the Incident Report</h3><p>Containment actions flow from the evidence:</p><ul><li>Purge the message across all mailboxes</li><li>Reset credentials and revoke active sessions for affected accounts</li><li>Block malicious infrastructure (domains, IPs, file hashes)</li><li>Revoke suspicious OAuth grants and remove malicious inbox rules</li><li>Notify affected users with clear next steps</li></ul><p>Remediate <strong>after</strong> scoping. Acting too early can leave forwarding rules or OAuth tokens intact.</p><p>The final incident report should contain:</p><ul><li>Timeline of discovery, investigation, and containment</li><li>Original message (headers + body summary)</li><li>Authentication results and sending infrastructure</li><li>URLs, attachment hashes, and sandbox reports</li><li>Recipient list and interaction status</li><li>Account-level findings (sign-ins, rules, grants)</li><li>Indicators of compromise written back into detection rules</li><li>Lessons learned and any detection or process improvements</li></ul><p>Evidence preservation is non-negotiable. The original message, authentication results, resolved URLs, hashes, interaction records, and account telemetry form the audit trail.</p><h3>Scaling the Work: Automation and AI</h3><p>Manual investigation does not compress easily. Retroactive quarantine notices alone can force the same sequence hundreds of times. SOAR playbooks handle repetitive enrichment and containment. AI-assisted investigation systems can apply the full five-step method to every reported message, produce documented reasoning, and free analysts for the ambiguous or high-impact cases. Both approaches preserve the core workflow; the difference is how many cases receive consistent depth.</p><p>Projects like PhishGuard AI illustrate one direction: lightweight, explainable models that score intent and surface threat reasons so an analyst can focus on the judgment calls that still require a human.</p><h3>Closing the Loop</h3><p>A phishing investigation that ends without writing indicators back into detection engineering is a case that is likely to recur. Feed sender infrastructure, lookalike domains, credential-harvest URLs, and file hashes into the detection pipeline. Use triage outcomes to tune rules and reduce the noise that creates fatigue.</p><p>The method itself stays fixed. Whether the lure is a classic credential harvest, a targeted BEC payment request, or a message routed through legitimate infrastructure, the same five steps — confirm, collect, determine exposure and interaction, scope, remediate — produce a defensible verdict and a usable incident report.</p><p>Master the email authentication signals, keep your command-line toolkit sharp, treat every report as potential evidence, and integrate the work into a disciplined alert triage process. That is how an inbox notification becomes a controlled, well-documented incident rather than an open door.</p><h3>References and Further Reading</h3><p><strong>Email authentication standards</strong></p><ul><li><a href="https://www.rfc-editor.org/rfc/rfc7208.html?utm_source=chatgpt.com">RFC 7208 — Sender Policy Framework</a></li><li><a href="https://www.rfc-editor.org/rfc/rfc6376.html?utm_source=chatgpt.com">RFC 6376 — DomainKeys Identified Mail Signatures</a></li><li><a href="https://www.rfc-editor.org/rfc/rfc7489.html?utm_source=chatgpt.com">RFC 7489 — Domain-based Message Authentication, Reporting and Conformance</a></li></ul><p><strong>Provider guidance</strong></p><ul><li><a href="https://support.google.com/mail/answer/81126?utm_source=chatgpt.com">Google Gmail Sender Guidelines</a></li><li><a href="https://support.google.com/mail/answer/14229414?utm_source=chatgpt.com">Google Gmail Sender Guidelines FAQ</a></li></ul><p><strong>Threat framework</strong></p><ul><li><a href="https://attack.mitre.org/techniques/T1566/?utm_source=chatgpt.com">MITRE ATT&amp;CK — Phishing T1566</a></li><li><a href="https://attack.mitre.org/techniques/T1566/001/?utm_source=chatgpt.com">MITRE ATT&amp;CK — Spearphishing Attachment T1566.001</a></li></ul><p><strong>Threat and fraud reporting</strong></p><ul><li><a href="https://www.ic3.gov/AnnualReport/Reports/2024_IC3Report.pdf?utm_source=chatgpt.com">FBI Internet Crime Complaint Center — 2024 IC3 Annual Report</a></li></ul><p><strong>Project</strong></p><ul><li><a href="https://github.com/sumit-jr/phishguard-ai?utm_source=chatgpt.com">PhishGuard AI — GitHub</a></li></ul><h3>Connect with Me</h3><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3b7d28bc5b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DHCP Inside Out: The Complete Guide to Dynamic Host Configuration Protocol]]></title>
            <link>https://systemweakness.com/dhcp-inside-out-the-complete-guide-to-dynamic-host-configuration-protocol-60cbdd565d74?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/60cbdd565d74</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[dhcp]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[network-security]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 04:16:01 GMT</pubDate>
            <atom:updated>2026-04-15T07:49:06.114Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine booting up your laptop in a coffee shop, hotel, or enterprise office. Within seconds, you’re online — no manual IP configuration, no subnet mask headaches. That seamless magic? It’s DHCP at work.</p><p>But behind the simplicity lies one of the most critical — and attack-prone — protocols in modern networking. In this definitive deep-dive, we go inside out on DHCP: from packet-level mechanics to the full DORA lease lifecycle, DHCP relay agents, every detail of Option 82, APIPA fallback, dynamic DNS (A and PTR records), Option 53/60, the critical fields chaddr and giaddr, rogue DHCP servers, starvation attacks, and rock-solid defenses.</p><p>These topics aren’t just theory. They explain the vast majority of real-world “no IP” tickets, multi-subnet headaches, and dynamic DNS problems you actually encounter in the field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*K6UmjmVq9qVOCPBl.jpg" /><figcaption>Understanding Dora Process in DHCP — IP With Ease</figcaption></figure><h3>1. DHCP Fundamentals + Packet Structure</h3><p><strong>Dynamic Host Configuration Protocol (DHCP)</strong> is defined in <a href="https://datatracker.ietf.org/doc/html/rfc2131">RFC 2131</a>. It automates IP address assignment and delivers critical network parameters (subnet mask, default gateway, DNS servers, lease time, etc.).</p><ul><li><strong>Client-server model</strong> over UDP</li><li><strong>Server port</strong>: 67 (bootps)</li><li><strong>Client port</strong>: 68 (bootpc)</li><li>Backward-compatible with BOOTP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ChUEBAlCXoiyg6leTEPdw.png" /></figure><p><strong>Option 53 (DHCP Message Type — mandatory) tells you exactly what the packet is:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*j2MhZCIMuFF04M0VsrbTKw.png" /></figure><blockquote>Note :- further reading → <a href="https://www.geeksforgeeks.org/computer-networks/dynamic-host-configuration-protocol-dhcp/"><strong>GFG</strong></a></blockquote><p><strong>Option 60 (Vendor Class Identifier — VCI) → </strong>lets the client say “VCI string: “MSFT 5.0” (Windows), “Cisco Systems, Inc. IP Phone CP-8841” allowing the server to send vendor-specific options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*f95EC8ZaVkmT8e1_.png" /><figcaption>DHCP Packet Analysis</figcaption></figure><h3>2. The DHCP Lease Process: DORA in Glorious Detail</h3><p>Every new client follows the legendary <strong>DORA</strong> process:</p><ol><li><strong>DHCPDISCOVER</strong> (Client → Broadcast, Option 53 = 1)</li><li><strong>DHCPOFFER</strong> (Server → Client/relay, Option 53 = 2)</li><li><strong>DHCPREQUEST</strong> (Client → Broadcast, Option 53 = 3)</li><li><strong>DHCPACK</strong> (Server → Confirmation, Option 53 = 5)</li></ol><p><strong>Client States</strong> (RFC 2131): INIT → SELECTING → REQUESTING → BOUND → RENEWING → REBINDING.</p><p><strong>Lease Timers</strong>:</p><ul><li><strong>T1</strong> (50% lease time) → unicast renew to original server</li><li><strong>T2</strong> (87.5%) → broadcast rebinding</li><li>Expiration → back to INIT</li></ul><p>Servers must ARP-probe the offered IP. Clients must ARP the assigned IP after ACK (conflict → DHCPDECLINE).</p><h3>2. The DHCP Lease Process: DORA in Glorious Detail</h3><p>Every new client follows the legendary <strong>DORA</strong> process:</p><ol><li><strong>DHCPDISCOVER</strong> (Client → Broadcast, Option 53 = 1)</li><li><strong>DHCPOFFER</strong> (Server → Client/relay, Option 53 = 2)</li><li><strong>DHCPREQUEST</strong> (Client → Broadcast, Option 53 = 3)</li><li><strong>DHCPACK</strong> (Server → Confirmation, Option 53 = 5)</li></ol><p><strong>Client States</strong> (RFC 2131): INIT → SELECTING → REQUESTING → BOUND → RENEWING → REBINDING.</p><p><strong>Lease Timers</strong>:</p><ul><li><strong>T1</strong> (50% lease time) → unicast renew to original server</li><li><strong>T2</strong> (87.5%) → broadcast rebinding</li><li>Expiration → back to INIT</li></ul><p>Servers must ARP-probe the offered IP. Clients must ARP the assigned IP after ACK (conflict → DHCPDECLINE).</p><h3>2. The DHCP Lease Process: DORA in Glorious Detail</h3><p>Every new client follows the legendary <strong>DORA</strong> process:</p><ol><li><strong>DHCPDISCOVER</strong> (Client → Broadcast, Option 53 = 1)</li><li><strong>DHCPOFFER</strong> (Server → Client/relay, Option 53 = 2)</li><li><strong>DHCPREQUEST</strong> (Client → Broadcast, Option 53 = 3)</li><li><strong>DHCPACK</strong> (Server → Confirmation, Option 53 = 5)</li></ol><p><strong>Client States</strong> (RFC 2131): INIT → SELECTING → REQUESTING → BOUND → RENEWING → REBINDING.</p><p><strong>Lease Timers</strong>:</p><ul><li><strong>T1</strong> (50% lease time) → unicast renew to original server</li><li><strong>T2</strong> (87.5%) → broadcast rebinding</li><li>Expiration → back to INIT</li></ul><p>Servers must ARP-probe the offered IP. Clients must ARP the assigned IP after ACK (conflict → DHCPDECLINE).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*84Vhc90J_7W6jIgf.png" /><figcaption>DHCP and DORA</figcaption></figure><h3>3. DHCP Relay Agents — How Broadcasts Cross Subnets (giaddr in Action)</h3><p>DHCP clients broadcast to 255.255.255.255. Routers drop broadcasts. <strong>DHCP relay agents</strong> (IP helper/BOOTP relay) solve this.</p><p><strong>Step-by-step</strong>:</p><ol><li>Client sends DISCOVER (broadcast, giaddr = 0, chaddr = MAC).</li><li>Relay receives it, <strong>sets giaddr</strong> = its own IP on the client interface.</li><li>Relay converts to unicast and forwards to the configured DHCP server.</li><li>Server replies to giaddr.</li><li>Relay strips extra options (if needed) and forwards locally.</li></ol><p>Without relays, you’d need a DHCP server on every subnet. One central server + relays = enterprise scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jUqZBOSCHeBsp7lWJa9Kvw.png" /><figcaption>Understanding DHCP Relay Agents</figcaption></figure><h3>4. Option 82 Deep Dive: Relay Agent Information Option</h3><p><strong>RFC 3046</strong>. Option 82 gives the DHCP server circuit-level visibility.</p><p><strong>Format</strong>:</p><ul><li>Code: 82</li><li>Sub-options:</li><li><strong>1: Agent Circuit ID</strong> → physical port/VLAN (e.g., Gi0/5)</li><li><strong>2: Agent Remote ID</strong> → subscriber/modem identifier</li></ul><p><strong>Flow</strong>:</p><ol><li>Relay (untrusted port) inserts Option 82 + giaddr.</li><li>Server uses it for policy-based assignment.</li><li>Server echoes Option 82 back in OFFER/ACK.</li><li>Relay removes it before delivering to client.</li></ol><p>Modern switches use this with DHCP snooping for port-level binding and anti-spoofing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*DqlNiaLy3Zas1xbD.png" /><figcaption>DHCP opt 82 Message Format</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/0*8MtqwfMwxPjPA2Fj.png" /><figcaption>Understanding DHCP opt 82</figcaption></figure><h3>5. When DHCP Fails: APIPA (169.254.x.x)</h3><p>No server response? Modern OSes fall back to <strong>Automatic Private IP Addressing</strong> (RFC 3927):</p><ul><li>Range: <strong>169.254.0.0/16</strong> (excluding .0 and .255)</li><li>Mask: 255.255.0.0</li><li>No gateway, no DNS</li><li>Devices perform ARP duplicate detection</li></ul><p>You get local L2 communication but <strong>no Internet</strong>. Classic yellow exclamation mark in Windows.</p><blockquote><strong>NOTE :- </strong>Each /24 within the /16 follows the same rule</blockquote><p><strong>Troubleshoot</strong>: cable, relay, server reachability, giaddr in captures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tNLuLTjX8jP_FKbH.jpg" /><figcaption>What is Automatic Private IP Addressing (APIPA)</figcaption></figure><h3>6. Dynamic DNS Updates — A and PTR Records</h3><p>DHCP + DNS = automatic hostname resolution.</p><ul><li><strong>A record</strong>: hostname → IP (forward)</li><li><strong>PTR record</strong>: IP → hostname (reverse)</li></ul><p>Clients can send <strong>Option 81</strong> (Client FQDN). Most enterprises let the DHCP server perform secure updates (RFC 2136) using GSS-TSIG/Kerberos.</p><p>Proper A/PTR records mean clean logs, working reverse DNS, and happy security teams.</p><h3>7. DHCP Attacks: Rogue Servers and Starvation</h3><p><strong>Rogue DHCP (Spoofing)</strong>: Attacker answers DISCOVER faster, becomes gateway/DNS → MITM, credential theft.</p><p><strong>DHCP Starvation</strong>: Flood random MAC DISCOVERs → exhaust pool → DoS for legitimate clients.</p><p>Both often combined for full network takeover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*oMLvDYBiqpfa8PLf.jpeg" /><figcaption>What is MiTM</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/0*2TZLFLMg5aVIKs96.png" /><figcaption>DHCP DoS and starvation attack on SDN controller and their mitigation</figcaption></figure><h3>8. Defenses: DHCP Snooping + Option 82</h3><p>Enterprise switches enable <strong>DHCP Snooping</strong>:</p><ul><li>Ports = untrusted by default</li><li>Only trusted ports send server messages</li><li>Builds MAC-IP-Port binding table</li><li>Validates/inserts Option 82</li><li>Rate-limits to stop starvation</li></ul><p>Result: rogue servers blocked, port-level enforcement, policy-based assignment.</p><h3>9. Troubleshooting Pro Tips</h3><ul><li>Wireshark filter: bootp</li><li>Look for giaddr, chaddr, Option 53/60/82</li><li>Cisco: show ip dhcp snooping binding, debug ip dhcp server packet</li><li>Common issues: missing relay, Option 82 not echoed, APIPA after relay misconfig</li></ul><h3>Conclusion: You Now Know DHCP Inside Out</h3><p>From chaddr and giaddr to Option 82 policies, APIPA fallback, A/PTR automation, and attack surface — you have the full picture.</p><p>DHCP is simple until it isn’t. Master it, and you’ll never look at a “can’t get IP” ticket the same way again.</p><p><a href="https://datatracker.ietf.org/doc/html/rfc2131"><strong>Further Reading</strong>:</a></p><ul><li>RFC 2131 — DHCP</li><li>RFC 3046 — Option 82</li><li>RFC 3927 — APIPA</li><li>RFC 2136 — Dynamic DNS Updates</li></ul><h3>Connect with Me</h3><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60cbdd565d74" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/dhcp-inside-out-the-complete-guide-to-dynamic-host-configuration-protocol-60cbdd565d74">DHCP Inside Out: The Complete Guide to Dynamic Host Configuration Protocol</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Linux Isolation: A Practical Guide to Namespaces and cgroups]]></title>
            <link>https://medium.com/@er.sumitsah/mastering-linux-isolation-a-practical-guide-to-namespaces-and-cgroups-5cd39c82fe3d?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cd39c82fe3d</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[namespaces]]></category>
            <category><![CDATA[cgroupsv2]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 13:14:38 GMT</pubDate>
            <atom:updated>2025-12-27T13:14:38.927Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4YdOGHXlKMG0MNmtNUwIyg.jpeg" /></figure><p>In the world of Linux, where efficiency and security are paramount, two kernel features stand out as the foundational pillars of modern computing: <strong>namespaces and control groups (cgroups)</strong>. Together, they enable the container revolution that powers cloud infrastructure, microservices, and scalable applications. But what exactly are they, and how can you leverage them directly? This guide breaks down the concepts with practical examples you can use today.</p><h3>The Core Concepts: Isolation and Control</h3><p>Think of your Linux system as a large, shared office building.</p><ul><li><strong>Namespaces</strong> are like giving each team (process) its own private office with soundproof walls. The team inside can see its own desks (files), have its own phone system (network), and its own internal roster of employees (process IDs), <strong>completely isolated from the noisy chaos of other teams</strong>. It creates the illusion of having a building to themselves.</li><li><strong>Cgroups</strong>, on the other hand, are the building manager. They don’t provide walls but <strong>control the shared resources</strong>. They ensure no single team can hog all the electricity (CPU), air conditioning (memory), or conference rooms (I/O bandwidth), enforcing fair usage for everyone.</li></ul><p>This combination —<strong> isolation via namespaces</strong> and <strong>resource control via cgroups </strong>— is what makes technologies like Docker, Kubernetes, and Podman possible, allowing <strong>multiple secure, efficient applications to run on a single host.</strong></p><h3>Deep Dive: Linux Namespaces</h3><p>Introduced in 2008, namespaces virtualize global system resources. A process in a namespace has its own isolated view; changes there don’t affect the host or other namespaces.</p><h3>The Seven Types of Namespaces</h3><p>The Linux kernel provides several namespace types, each isolating a specific resource:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVGq8UOLt71DlOiOFAO7CQ.png" /></figure><h3>Hands-On with Namespaces: The unshare Command</h3><p>The easiest way to experiment is with the unshare command. It runs a program in new namespaces.</p><ol><li><strong>Create an isolated shell with a new hostname:</strong></li></ol><pre>sudo unshare --uts --fork /bin/bash<br>hostname my-isolated-box</pre><p>Run hostname in this shell, then from another terminal. You&#39;ll see the change is isolated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N3NIhm8tTsWVdKoyo3anCQ.png" /></figure><p>2. <strong>Create a network namespace (a fundamental container building block):</strong></p><pre>sudo ip netns add mynetns  <br>sudo ip netns exec mynetns ip link list  </pre><p>You’ll only see a loopback interface (lo), demonstrating complete network isolation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHH-cSYFJKQRPLy2wD01RQ.png" /></figure><h3>Deep Dive: Linux Control Groups (cgroups)</h3><p>While namespaces answer <em>“what do you see?”</em>, cgroups answer <em>“how much can you use?”</em>. As defined in the Linux manual, “control groups… allow processes to be organized into hierarchical groups whose usage of various types of resources can then be limited and monitored.”</p><p>Key components are:</p><ul><li><strong>Subsystems (Controllers):</strong> Kernel modules that manage a specific resource (e.g., cpu, memory, io).</li><li><strong>Hierarchy:</strong> A tree of cgroups where limits can be inherited.</li><li><strong>Process Association:</strong> A process belongs to exactly one cgroup per hierarchy.</li></ul><h3>cgroup v1 vs. v2: Understanding the Shift</h3><blockquote>⚠️ Important: There are two versions, with v2 being the modern standard.</blockquote><ul><li>cgroup v1: The original. Controllers could be mounted in separate, multiple hierarchies, leading to complexity. A process could have different membership in each hierarchy.</li><li>cgroup v2: The modern, unified hierarchy. All controllers are mounted together on a single tree, simplifying management and eliminating inconsistencies. It’s the present and future of resource control on Linux.</li></ul><p>Most modern distributions now use cgroup v2 by default. You can check by looking for a unified mount:</p><pre>mount | grep cgroup2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lMTDu-I64DHerktogDiVQ.png" /></figure><h3>Hands-On with cgroups v2: Limiting a Process</h3><p>The cgroup interface is exposed via a virtual filesystem, typically at /sys/fs/cgroup/. Let&#39;s limit a shell&#39;s memory.</p><pre># 1. Navigate to the unified cgroup root<br>cd /sys/fs/cgroup/<br><br># 2. Create a new child cgroup for our experiment<br>sudo mkdir ./test-limit<br>cd ./test-limit<br><br># 3. Enable the memory controller for this cgroup and its children<br>echo &quot;+memory&quot; | sudo tee cgroup.subtree_control<br><br># 4. Set a hard memory limit of 50 Megabytes<br>echo &quot;50M&quot; | sudo tee memory.max<br><br># 5. Start a memory-hungry process in this cgroup<br>echo $$ | sudo tee cgroup.procs  # Moves the current shell into the cgroup<br><br># 6. Run a test that will exceed the limit<br>python3 -c &quot;<br>data = []<br>for i in range(1000):<br>    data.append(&#39; &#39; * 1024*1024) # Allocate ~1GB<br>print(&#39;Done&#39;)<br>&quot;</pre><p>The Python process will be terminated by the Out-Of-Memory (OOM) killer once it tries to exceed 50MB. Exit the shell to clean up (exit).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5yQj0c8WnZSgF50ZN9iIpg.png" /></figure><h3>The Powerful Synergy: Building a Mini-Container</h3><p>The real magic happens when you combine namespaces and cgroups. This is essentially what Docker does when you run docker run.</p><p>Here’s a simplified example that creates an isolated, resource-limited environment — a “poor man’s container”:</p><pre>#!/bin/bash<br># Save this as mini-container.sh<br><br># Create a new namespace &quot;bundle&quot;<br>sudo unshare --fork --pid --mount-proc --uts --net --ipc --user --map-root-user /bin/bash &lt;&lt; &#39;EOF&#39;<br># ===== Inside the new, isolated context =====<br># Set a custom hostname<br>hostname my-container<br><br># Mount a fresh /proc so &#39;ps&#39; works<br>mount -t proc proc /proc<br><br># Create and enter a cgroup for memory limits<br>mkdir /sys/fs/cgroup/mycontainer<br>cd /sys/fs/cgroup/mycontainer<br>echo &quot;+memory&quot; &gt; cgroup.subtree_control<br>echo &quot;30M&quot; &gt; memory.max<br>echo $$ &gt; cgroup.procs<br><br>echo &quot;=== Inside Container ===&quot;<br>echo &quot;Hostname: $(hostname)&quot;<br>echo &quot;PID of this shell: $$&quot;<br>echo &quot;Memory limit: $(cat memory.max)&quot;<br>echo &quot;Running &#39;ps aux&#39;:&quot;<br>ps aux<br>echo &quot;========================&quot;<br><br># Keep the shell running<br>exec /bin/bash<br>EOF</pre><p>Run it with sudo ./mini-container.sh. You&#39;ll be in an isolated environment with a custom hostname, its own PID list, and a strict memory limit.</p><h3>Best Practices and Common Pitfalls</h3><ul><li>Prefer cgroup v2: New projects should target cgroup v2 for its cleaner API and unified model. Be aware that some older orchestration tools might still expect v1.</li><li>Security is a Double-Edged Sword: While user namespaces are powerful for mapping root inside a container to a non-root user outside (enhancing security), incorrect configuration can introduce vulnerabilities. Always keep your kernel updated.</li><li>Monitor Your Limits: Use tools like systemd-cgtop or inspect the files in /sys/fs/cgroup/ to monitor resource usage and pressure.</li><li>Containers Do the Heavy Lifting: For production, use Docker, Podman, or systemd-nspawn. They handle the complex namespace and cgroup setup, security profiles, and image management.</li></ul><h3>Conclusion</h3><p>Namespaces and cgroups transform Linux from a single-tenant system into a secure, efficient multi-tenant platform. By understanding these building blocks, you gain deeper insight into how containers work, empowering you to debug complex issues, design better systems, and optimize resource usage.</p><p>Start experimenting with the unshare command and the cgroup filesystem in a virtual machine or spare environment. The hands-on experience is the best way to solidify these foundational concepts that power the modern cloud.</p><h3>Connect with Me</h3><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cd39c82fe3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Race Conditions in Web Applications: Vulnerabilities, Exploits, and Mitigations]]></title>
            <link>https://medium.com/@er.sumitsah/understanding-race-conditions-in-web-applications-vulnerabilities-exploits-and-mitigations-96a2fbca39c8?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/96a2fbca39c8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[race-condition]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[web-security]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 13:01:29 GMT</pubDate>
            <atom:updated>2025-10-29T13:01:29.330Z</atom:updated>
            <content:encoded><![CDATA[<p>In the fast-paced world of web development, where applications handle thousands of simultaneous requests, race conditions lurk as silent threats that can undermine security and integrity. These vulnerabilities exploit the subtle timing differences in concurrent operations, potentially allowing attackers to perform unauthorized actions like duplicating transactions or bypassing limits. Drawing from foundational concepts in computer science and real-world examples, this comprehensive exploration delves into the mechanics of race conditions, their causes in web applications, exploitation techniques, and robust prevention strategies. Whether you’re a developer, security professional, or curious tech enthusiast, grasping these concepts is crucial for building resilient systems.</p><p>Research suggests race conditions represent a critical yet often overlooked vulnerability in modern web applications, arising from improper handling of concurrent operations. Evidence indicates that these flaws can lead to unauthorized actions, such as multiple applications of discounts or overdrawing accounts, due to timing discrepancies in multi-threaded environments. While challenging to detect because of their intermittent nature, implementing robust synchronization and atomic operations can significantly reduce risks, though ongoing testing is essential.</p><h4>What Are Race Conditions?</h4><p>Race conditions, also known as race hazards, emerge when multiple threads or processes access shared resources concurrently without adequate synchronization, leading to unexpected behaviors. Research suggests this vulnerability is particularly prevalent in web applications due to their distributed nature. For instance, in a banking app, two simultaneous withdrawal requests might both check the balance before either updates it, resulting in an overdraft.</p><h4>Real-World Impacts</h4><p>These vulnerabilities have been linked to significant exploits, including cases where attackers manipulated timing to apply single-use discounts multiple times or withdraw more funds than available. In fintech, race conditions can silently erode trust and cause monetary damage, as seen in various reported incidents, such as the 2015 Starbucks gift card hack where a race condition in value transfers enabled unlimited funds.</p><h4>Basic Mitigation Tips</h4><p>To address these, developers should prioritize atomic operations and database transactions, ensuring operations are indivisible. Tools like Burp Suite can help identify potential issues during testing.</p><h4>The Basics: Programs, Processes, and Threads</h4><p>To understand race conditions, we must first grasp the building blocks of software execution.</p><h4>Programs: Static Instructions</h4><p>A program is essentially a set of instructions designed to perform a specific task. It’s static until executed — like a recipe waiting to be followed. For example, consider a simple Python web server using Flask:</p><pre>from flask import Flask<br><br>app = Flask(__name__)<br><br>@app.route(&#39;/&#39;)<br>def hello_world():<br>    return &#39;&lt;h1&gt;Hello, World!&lt;/h1&gt;&#39;<br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=8080)</pre><p>This code defines a server but does nothing until run. Once executed, it becomes dynamic.</p><h4>Processes: Execution in Action</h4><p>When a program runs, it becomes a process — a dynamic entity with states like New, Ready, Running, Waiting, and Terminated. A state diagram illustrates these transitions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*WtL6L3ToV8Dm46nX.png" /><figcaption>States of a Process in Operating Systems — GeeksforGeeks</figcaption></figure><p>In a single-threaded web server, requests are handled sequentially, which can lead to bottlenecks under high load.</p><h4>Threads and Multi-Threading: Parallel Power</h4><p>Threads are lightweight units within a process, sharing resources for parallel execution. Analogize this to an espresso machine with multiple portafilters: the machine (process) handles orders via separate portafilters (threads) for efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F4R5sfFwbznLTrVO.jpg" /></figure><p>In code, Python’s threading module demonstrates this:</p><pre>import threading<br><br>x = 0<br><br>def increment():<br>    global x<br>    for _ in range(100000):<br>        x += 1<br><br>threads = [threading.Thread(target=increment) for _ in range(10)]<br>for t in threads:<br>    t.start()<br>for t in threads:<br>    t.join()<br><br>print(x)  # May not be 1,000,000 due to race condition</pre><p>Without synchronization, the final value of x can be inconsistent due to interleaved operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yMG_nZ_MrxpZFfrR.jpeg" /><figcaption>Understanding Race Conditions in Software Development</figcaption></figure><h3>Race Conditions Defined</h3><p>A race condition occurs when the timing or order of events affects the program’s correctness, often in multi-threaded or concurrent environments. A subset, data races, involve unsynchronized memory accesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EH9LINPmlvljjGzv.jpeg" /><figcaption>Race Condition Explained</figcaption></figure><h4>Types of Race Conditions</h4><ul><li><strong>Time-of-Check to Time-of-Use (TOCTOU):</strong> A common type where a condition is checked, but the state changes before action. Diagrams often show this time window:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7HHqlL0I6hD-b6hs.png" /><figcaption>Time of Check, Time of Use Attack</figcaption></figure><ul><li><strong>Read-Modify-Write</strong>: Non-atomic updates lead to lost changes.</li><li><strong>Critical vs. Non-Critical</strong>: Those affecting final state are critical.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ehfc6Hp1tARjGnpfaAXPZA.png" /></figure><h4>Causes in Web Applications</h4><p>Web apps follow a client-server model, often with multi-tier architecture: presentation (client), application (server logic), and data (database).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4fIuUvVy4zFCd9lq.png" /><figcaption>Client-Server Architecture Explained</figcaption></figure><p><strong>Key causes:</strong></p><ul><li><strong>Shared Resources</strong>: Concurrent access to databases or memory without locks.</li><li><strong>Parallel Processing</strong>: Servers handle requests simultaneously, risking inconsistencies.</li><li><strong>Database Interactions</strong>: Non-atomic operations lead to conflicts.</li><li><strong>Third-Party Integrations</strong>: External services may not handle concurrency well.</li></ul><h4>Illustrative Examples</h4><h4>Banking Withdrawal Scenario</h4><p>Imagine an account with $100. Two threads attempt $60 withdrawals:</p><ol><li>Both check balance (&gt; $60).</li><li>One withdraws, updates to $40.</li><li>The other, seeing old $100, withdraws, leading to negative balance.</li></ol><p>This TOCTOU exploit has been seen in real banking apps.</p><h4>E-Commerce Coupon Application</h4><p>A user applies a 10% off coupon. The system checks validity, then applies it. If multiple requests hit during the check-apply window, the discount multiplies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_PGCCBiSgRMXjqNu2zFjw.png" /></figure><h4>Custom Scenario: Online Voting System</h4><p>In a hypothetical poll app, votes are limited to one per user. The process: check if voted, then record vote. An attacker sends parallel requests; both pass the check before the first updates, allowing multiple votes. This could skew results in contests or surveys.</p><h4>Exploitation Techniques</h4><p>Exploiting requires precise timing. Tools like Burp Suite’s Repeater facilitate this by sending grouped requests in parallel or sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2kM_3CXaqTDUQ_Sn.jpg" /><figcaption>Burp Suite 2: Repeater Tool(only for demo)</figcaption></figure><p><strong>Steps:</strong></p><ol><li>Capture a critical request (e.g., transfer funds).</li><li>Duplicate in Repeater (20+ times).</li><li>Send in parallel to hit the time window.</li></ol><p>Extensions like <strong>Turbo Intruder</strong> enhance this for high-volume attacks.</p><h4>Detection Challenges</h4><p>Race conditions are “Heisenbugs” — hard to reproduce. Methods:</p><ul><li>Code reviews for unsynchronized access.</li><li>Static analysis tools.</li><li>Dynamic testing under load.</li><li>Monitoring for anomalies like unexpected balances.</li></ul><h4>Mitigation Strategies</h4><p>Prevent with:</p><ul><li><strong>Locks and Synchronization</strong>: Use mutexes to ensure exclusive access.</li></ul><p>Example in Python:</p><pre>import threading<br><br>lock = threading.Lock()<br>x = 0<br><br>def increment():<br>    global x<br>    with lock:<br>        x += 1</pre><ul><li><strong>Atomic Operations</strong>: Database transactions ensure all-or-nothing execution.</li><li><strong>Design Choices</strong>: Avoid shared state; use message queues.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzzYsZn_LwZmnTKhpmLr2A.png" /><figcaption>What is Race Condition in OS?</figcaption></figure><p><strong>Testing:</strong> Simulate concurrency with tools like Burp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rarrwjvRD-pJzEW913qy-A.png" /></figure><h4>Security Implications and Famous Cases</h4><p>Race conditions <strong>(</strong><a href="https://cwe.mitre.org/data/definitions/362.html"><strong>CWE-362</strong></a><strong>) </strong>enable escalation, DoS, or data leaks. Notable exploits include the Starbucks gift card hack, where timing allowed infinite reloads.</p><h4>Conclusion: Building Resilient Applications</h4><p>Race conditions highlight the perils of concurrency, but with vigilant design and testing, they can be tamed. As web apps evolve, prioritizing synchronization will safeguard against these timing-based threats.</p><h4>Connect with Me</h4><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96a2fbca39c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Subdomain Enumeration: A Beginner’s Guide to Expanding Your Reconnaissance]]></title>
            <link>https://medium.com/@er.sumitsah/mastering-subdomain-enumeration-a-beginners-guide-to-expanding-your-reconnaissance-c1719a97fbff?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1719a97fbff</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[osint]]></category>
            <category><![CDATA[subdomain-enumeration]]></category>
            <category><![CDATA[reconnaissance]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 14:11:32 GMT</pubDate>
            <atom:updated>2025-10-22T14:11:32.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVoRbzInPtilkiAFHZpcEA.png" /></figure><p>Imagine uncovering hidden doors to a company’s digital fortress — servers, applications, or even forgotten admin panels that could expose critical vulnerabilities. This is the power of <strong>subdomain enumeration</strong>, a cornerstone of ethical hacking and reconnaissance. Whether you’re a bug bounty hunter or a cybersecurity enthusiast, mastering this skill expands your ability to find weaknesses before attackers do. In this beginner-friendly guide, we’ll break down what subdomain enumeration is, why it matters, and how to do it effectively using free tools and techniques.</p><h4>What Is Subdomain Enumeration?</h4><p>Subdomains are extensions of a main domain name, likeblog.hubspot.com or academy.hubspot.com, where hubspot.comis the root domain. Each subdomain can point to different servers or applications, often hosting unique functionalities. Subdomain enumeration is the process of discovering these subdomains to map out a target’s digital footprint, known as its <strong>attack surface</strong> — all the points where an attacker might strike.</p><h4>Why It Matters</h4><p>Subdomains often hide overlooked assets, making them prime targets for both ethical hackers and malicious actors. Here’s why enumeration is critical:</p><ul><li><strong>Uncover Hidden Systems</strong>: Development environments (e.g., dev.hubspot.com) may have weaker security than production systems.</li><li><strong>Expose Sensitive Portals</strong>: Admin panels (e.g., admin.hubspot.com) might reveal login pages or APIs.</li><li><strong>Prevent Subdomain Takeovers</strong>: Forgotten subdomains with expired DNS records can be hijacked, as noted in resources like the <em>0xffsec Handbook</em>.</li></ul><p>For organizations, regular enumeration ensures all assets are monitored. For ethical hackers, it’s a way to identify risks within bug bounty program scopes.</p><p><strong>Important</strong>: Always obtain explicit permission before scanning, as unauthorized enumeration can violate laws like the U.S. Computer Fraud and Abuse Act (CFAA) or resemble a denial-of-service (DoS) attack if not rate-limited.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*-ZtPDVXyRpMr4zAwGskt5w.png" /><figcaption>diagram showing a root domain with subdomains like blog, offers, and academy etc</figcaption></figure><h4>Types of Subdomain Enumeration</h4><p>There are two main approaches to subdomain enumeration: <strong>passive</strong> and <strong>active</strong>. Passive methods use public data without contacting the target, making them stealthy. Active methods query the target directly, which can reveal more but risks detection. Let’s explore both.</p><h4>Passive Enumeration: Stealthy Recon with OSINT</h4><p>Passive enumeration relies on <strong>Open-Source Intelligence (OSINT)</strong> — publicly available data from sources like search engines or certificate logs. It’s ideal for staying under the radar.</p><h4>1. Certificate Transparency Logs with crt.sh</h4><p>When websites secure SSL/TLS certificates, Certificate Authorities (CAs) log them in public <strong>Certificate Transparency (CT)</strong> logs to prevent misuse. These logs often reveal subdomains, especially for wildcard certificates (e.g., *.example.com).</p><p><strong>How to Use crt.sh</strong>:</p><ul><li>Visit <a href="https://crt.sh/">crt.sh</a>.</li><li>Enter the target domain (e.g., tryhackme.com).</li><li>Filter results by date or issuer to see historical entries.</li></ul><p><em>Example</em>: Searching tryhackme.com might uncover shop.tryhackme.com from a log dated 2020–12–26.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJnusVBLmRM-BNmigj9dWA.png" /><figcaption>screenshot of crt.sh results showing subdomains</figcaption></figure><h4>2. Search Engine Dorking</h4><p>Search engines like Google index billions of pages, including subdomains. Advanced queries called <strong>dorks</strong> help you find them.</p><p><strong>Example Google Dork</strong>:</p><pre>site:*.example.com -site:www.example.com</pre><p>This finds subdomains of example.com excluding the main site. For instance, site:*.tryhackme.com- site:www.tryhackme.com might reveal access.tryhackme.com.</p><p><strong>Other Useful Dorks</strong>:</p><ul><li>site:example.com filetype:pdf: Finds documents that might leak subdomains.</li><li>inurl:admin site:example.com: Uncovers admin panels.</li></ul><h3>3. Automated OSINT with Sublist3r</h3><p>Sublist3r is a Python tool that automates OSINT by querying sources like Google, Bing, Netcraft, and VirusTotal. It also supports brute-forcing subdomains.</p><p><strong>Installation</strong>:</p><pre>git clone https://github.com/aboul3la/Sublist3r.git<br>pip install -r requirements.txt</pre><p><strong>Example Command</strong>:</p><pre>python sublist3r.py -d acmeitsupport.thm -v -o results.txt</pre><ul><li>-d: Specifies the target domain.</li><li>-v: Enables verbose output.</li><li>-o: Saves results to a file.</li></ul><p>This might reveal subdomains like mail.acmeitsupport.thm. You can filter results with grep, e.g., grep admin results.txt, or use the -p flag to scan specific ports.</p><h4>Active Enumeration: Digging Deeper with Brute Force</h4><p>Active methods directly query the target’s DNS servers or web servers, using wordlists of common subdomain names (e.g., admin, api, test). These are more likely to be detected, so use them cautiously.</p><h4>1. DNS Brute Force with dnsrecon</h4><p>dnsrecon tries wordlist entries as subdomains to see if they resolve.</p><p><strong>Example Command</strong>:</p><pre>dnsrecon -t brt -d acmeitsupport.thm -D /path/to/wordlist.txt</pre><ul><li>-t brt: Specifies brute force mode.</li><li>-D: Points to a wordlist (e.g., SecLists’ namelist.txt).</li></ul><p>This might uncover subdomains like mail.acmeitsupport.thm. Use rate limiting (e.g., — threads 10) to avoid overwhelming the target.</p><h4>2. Virtual Host Enumeration with ffuf</h4><p>Some subdomains aren’t in public DNS but are configured on servers via HTTP Host headers. ffuf is a fast fuzzing tool to discover these.</p><p><strong>Installation</strong>:</p><pre>go install github.com/ffuf/ffuf/v2@latest</pre><p><strong>Example Command</strong>:</p><pre>ffuf -w /usr/share/wordlists/SecLists/Discovery/DNS/namelist.txt -H &quot;Host: FUZZ.acmeitsupport.thm&quot; -u http://MACHINE_IP -fs 1234</pre><ul><li>-w: Specifies the wordlist.</li><li>-H: Fuzzes the Host header with FUZZ as the placeholder.</li><li>-fs: Filters common response sizes (e.g., 1234 bytes) to highlight unique responses.</li></ul><p>This might reveal internal.acmeitsupport.thm. Use ffuf’s interactive mode (press Enter during execution) to tweak filters live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jgt7yEstGS1IwbChfRxrfw.png" /></figure><h3>Advanced Tools for Power Users</h3><p>Once you’re comfortable with the basics, explore these advanced tools:</p><ul><li><strong>Recon-ng</strong>: A modular framework with subdomain modules (e.g., recon/domains-hosts/brute_hosts).</li><li><strong>SubDomainizer</strong>: Scrapes URLs for subdomains, ideal for finding hidden assets.</li><li><strong>Massdns</strong>: A high-performance DNS resolver for large-scale brute forcing.</li></ul><p><strong>Integration Tip</strong>: Pipe Sublist3r output into ffuf for a hybrid passive-active scan:</p><pre>python sublist3r.py -d example.com -o subdomains.txt &amp;&amp; ffuf -w subdomains.txt -H &quot;Host: FUZZ.example.com&quot; -u http://MACHINE_IP</pre><h4>Best Practices and Legal Considerations</h4><ul><li><strong>Stay Ethical</strong>: Always operate within bug bounty scopes or with explicit permission. Unauthorized scanning can lead to legal consequences.</li><li><strong>Rate Limit</strong>: Use rate-limiting options in tools like dnsrecon or ffuf to avoid DoS-like behavior.</li><li><strong>Combine Tools</strong>: Start with passive methods (e.g., crt.sh, Sublist3r) to minimize detection, then use active methods for deeper insights.</li><li><strong>Document Findings</strong>: Save outputs (e.g., results.txt) for analysis and reporting.</li></ul><h4>Conclusion: Start Your Recon Journey</h4><p>Subdomain enumeration is a gateway to mastering reconnaissance in ethical hacking. By uncovering hidden assets, you can help organizations secure their systems or earn bug bounty rewards. Start practicing in safe environments like TryHackMe or HackTheBox, and experiment with tools like Sublist3r and ffuf. The more you explore, the better you’ll get at finding those hidden digital doors.</p><h4>Connect with Me</h4><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><p><strong>Reference:</strong></p><ul><li><a href="https://tryhackme.com/">Tryhackme</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1719a97fbff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Digital Gatekeeper: A Practical Guide to Understanding and Using Firewalls]]></title>
            <link>https://medium.com/@er.sumitsah/your-digital-gatekeeper-a-practical-guide-to-understanding-and-using-firewalls-2e22216517f7?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e22216517f7</guid>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[windows-defender]]></category>
            <category><![CDATA[network-security]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Wed, 15 Oct 2025 15:48:07 GMT</pubDate>
            <atom:updated>2025-10-15T15:48:07.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*zHO4CT-F1vmT3-De.png" /></figure><h4>What Is the Purpose of a Firewall</h4><p>Your computer is a bustling hub of data, constantly sending and receiving information over the internet. But what stops hackers or malicious programs from sneaking in? Enter the firewall — your digital gatekeeper. Like a security guard checking IDs at a building’s entrance, a firewall inspects incoming and outgoing traffic based on rules you set, blocking suspicious data and allowing only safe information to pass. In this article, you’ll learn what firewalls do, explore their types, and get hands-on with setting up rules on Windows and Linux systems to protect your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y5gL3u-jpkqj3Edl.png" /></figure><p>A <strong>firewall</strong> is like a security guard for your computer or network. Just like a guard at the entrance of a building checks who comes in and out to make sure only allowed people enter, a firewall checks the data going in and out of your computer or network. Its job is to block anything bad or suspicious and allow only safe information to pass through. This keeps your device and network protected from hackers or harmful programs trying to sneak in.</p><h4>Types of Firewalls</h4><p>Firewall deployment became common in networks after organizations discovered their ability to filter harmful traffic from their systems and networks. Several different types of firewalls were introduced afterward, each serving a unique purpose. It’s also important to note that different types of firewalls work on different OSI model layers. Firewalls are categorized into many types.</p><p>Let’s examine a few of the most common types of firewalls and their roles in the OSI model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LmOkSZvTHb5TYbgH.png" /></figure><h4>Stateless Firewall</h4><p>This type of firewall operates on layer 3 and layer 4 of the OSI model and works solely by filtering the data based on predetermined rules without taking note of the state of the previous connections. This means it will match every packet with the rules regardless of whether it is part of a legitimate connection… However, the firewall keeps forgetting this, and future packets from this source will be treated as new and matched by its rules again.</p><h4>Stateful Firewall</h4><p>A stateless firewall operates at OSI Layers 3 and 4 (Network and Transport), filtering packets based on predefined rules without tracking connection history.</p><ul><li><strong>How it Works</strong>: Each packet is checked independently, ignoring whether it’s part of an existing connection.</li><li><strong>Pros</strong>: Fast processing due to minimal memory use.</li><li><strong>Cons</strong>: Limited security, as it can’t block packets based on prior activity (e.g., if a malicious source is blocked, future packets from it are still evaluated).</li><li><strong>Use Case</strong>: Ideal for high-speed, low-risk environments like basic network filtering.</li></ul><h4>Proxy Firewall</h4><p>The problem with previous firewalls was their inability to inspect the contents of a packet. Proxy firewalls, or application-level gateways, act as intermediaries between the private network and the Internet and operate on the OSI model’s layer 7. They inspect the content of all packets as well. The requests made by users in a network are forwarded by this proxy after inspection and masking them with their own IP address to provide anonymity for the internal IP addresses. Content filtering policies can be applied to these firewalls to allow/deny incoming and outgoing traffic based on their content.</p><h4>Next-Generation Firewall (NGFW)</h4><p>NGFWs are advanced firewalls operating across OSI Layers 3 to 7, offering deep packet inspection (examining packet contents for advanced threat detection) and enhanced security features. They include:</p><ul><li><strong>Intrusion Prevention</strong>: Blocks malicious activities in real time.</li><li><strong>Heuristic Analysis</strong>: Detects attack patterns and stops them instantly.</li><li><strong>SSL/TLS Decryption</strong>: Inspects encrypted packets and correlates data with threat intelligence for efficient decisions.</li><li><strong>Use Case</strong>: Ideal for enterprises needing robust protection against sophisticated threats.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qDq7UTIWi3bOhl7D.png" /></figure><h4>Rules in Firewalls</h4><p>A firewall gives you control over your network’s traffic. Although it filters the traffic based on its built-in rules, some customized rules can be defined for various networks. For example, there would be networks that want to deny all the SSH traffic coming into their network. However, your network would have a requirement to allow SSH traffic from a few specific IP addresses. The rules allow you to configure these customized settings for your network’s incoming and outgoing traffic.</p><p>The basic components of a firewall’s rule are described below:</p><ul><li><strong>Source address:</strong> The machine’s IP address that would originate the traffic.</li><li><strong>Destination address:</strong> The machine’s IP address that would receive the data.</li><li><strong>Port:</strong> The port number for the traffic.</li><li><strong>Protocol:</strong> The protocol that would be used during the communication.</li><li><strong>Action:</strong> This defines the action that would be taken upon identifying any traffic of this particular nature.</li><li><strong>Direction:</strong> This field defines the rule’s applicability to incoming or outgoing traffic.</li></ul><h4>Types of Actions</h4><p>The component “Action” from a rule indicates the steps to take after a data packet falls under the category of the defined rule. Three main actions that can be applied to a rule are explained below.</p><ul><li><strong>Allow: </strong>A rule’s “Allow” action indicates that the particular traffic defined inside the rule would be permitted.</li></ul><p>For example, let’s create a rule with an action to allow all the outgoing traffic from our network for port 80 (used for HTTP traffic to the Internet).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T1cyF1M6NLIJlKni.png" /></figure><ul><li><strong>Deny: </strong>A rule’s “Deny” action means that the traffic defined inside the rule would be blocked and not permitted. These rules are fundamental for the security team to deny specific traffic coming from malicious IP addresses and create more rules to reduce the threat surface of the network.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aJmoktr0dLzlcW5s.png" /></figure><p>For example, let’s create a rule with an action to deny all the incoming</p><ul><li><strong>Forward: </strong>The action “Forward” redirects traffic to a different network segment using the forwarding rules created on the firewalls. This applies to the firewalls that provide routing functionality and act as gateways between different network segments.</li></ul><p>For example, let’s create a rule with an action to forward all the incoming traffic on port 80 (used for HTTP traffic) to the web server 192.168.1.8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2svcOjr0leFtR3R3.png" /></figure><h4>Directionality of Rules</h4><p>Firewalls have different categories of rules, each categorized based on the traffic directionality on which the rules are created. Let’s examine each of these directionalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xx7Uz60A4znyu2J7.png" /></figure><p><strong>Inbound Rules</strong></p><p>Rules are categorized as inbound rules when they are meant to be applied to incoming traffic only. For example, you might allow incoming HTTP traffic (port 80) on your web server.</p><p><strong>Outbound Rules</strong></p><p>These rules are made for outgoing traffic only. For example, blocking all outgoing SMTP traffic (port 25) from all the devices except the mail server.</p><p><strong>Forward Rules</strong></p><p>Forwarding rules are created to forward specific traffic inside the network. For example, a forwarding rule can be created to forward the incoming HTTP (port 80) traffic to the web server located in your network.</p><h4>Windows Defender Firewall</h4><p>Windows Defender is a built-in firewall introduced by Microsoft in the Windows OS. This firewall contains all the basic functionality for creating, allowing, or denying specific programs or creating customized rules. This task is designed to cover some of the essential components of the Windows Defender Firewall, which you can utilize to restrict your system’s incoming and outgoing network traffic. To open this firewall, you have to open the Windows search and type “Windows Defender Firewall.”</p><p>The Windows Defender Firewall’s home page shows the “Network Profiles” and the available options. This is the main dashboard with all the options for the firewall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rwsbHIQ9r1zKIQrI.png" /></figure><h4>Network Profiles</h4><p>There are two available network profiles. Windows firewall determines your current network based on Network Location Awareness (NLA) and applies that profile firewall settings for you. We can have different firewall settings for each of them.</p><ol><li><strong>Private networks:</strong> This includes the firewall configurations to apply when connected to our home network.</li><li><strong>Guest or public networks:</strong> This includes the firewall configurations to apply when connected to a public or untrusted network like coffee shops, restaurants, or similar. For example, when connecting to public networks, you can configure firewall settings to block all incoming network connections and allow only some outgoing connections that are essential for you. These settings will apply to the public network profile and will not be implemented when you are in your private home network.</li></ol><p>To allow/disallow any application in any of your network profiles, click on the option (highlighted as 1 in the screenshot). This will take you to the page listing all the apps and features installed in your system. You can checkmark the ones you want to allow in any of your network profiles or uncheck those if not needed. Windows Defender Firewall is turned on by default. However, if you want to turn it on/off, you can click on the option (highlighted as 2 in the screenshot). This will take you to the settings for both of your network profiles. Rather than completely turning it off, which Microsoft doesn’t recommend, you can also block all incoming connections. You can also click on “Restore Defaults” (highlighted as 3 in the screenshot) from the main dashboard anytime to restore all the firewall’s default settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*4hoCoGDgi2mXnht-.png" /></figure><h4>Custom Rules</h4><p>Windows Defender Firewall also allows you to create custom rules for your network to allow/disallow specific traffic as needed. Let’s create a custom rule to block all outgoing traffic on HTTP (port 80) or HTTPS (port 443). After creating this rule, we will be unable to browse any website on the Internet as the websites are working on port 80 or 443, which we will be blocking.</p><p>Before creating this rule, let’s test if we are able to visit a website. For testing, let’s visit http://10.10.10.10/. As shown in the screenshot below, we are able to visit this website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T5yOBrWWsm1avO12.png" /></figure><p>To create a custom rule, choose “<strong>Advanced Settings</strong>” from the available options in the main dashboard. This will open a new tab where you can create your own rules.</p><p><strong>Note: </strong>The rule created below is already available inside the attached VM. If you want to test it, you can create it on your Windows host machine or any other machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*jMsgIdQX4l8mN-Jd.png" /></figure><p>You can see the available options to <strong>create inbound and outbound rules.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l-qzOQKCutlKnNm-.png" /></figure><p>Let’s create an outbound rule to block all our outgoing HTTP and HTTPS traffic. For this, click on the <strong>Outbound Rules</strong> option on the left side, then click on <strong>New Rule</strong> on the right side. It will open the rule wizard.In the first step, select the <strong>Custom</strong> option and press <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*ubQRGQE-fOFhTvpt.png" /></figure><p>In the second step, select <strong>All programs</strong> from the next option and press <strong>Next</strong>. It will ask you to select the protocol type in the third step. Select the <strong>Protocol type</strong> as “TCP”, keep the <strong>Local port</strong> as it is, and change the <strong>Remote port</strong> to “Specific ports” from the dropdown. Write the port numbers in the field below (in our case, 80,443). Now, click on <strong>Next</strong>.</p><p><strong>Note:</strong> Separate the port numbers by commas, and please don’t leave spaces between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*avcnSbp4XFkoEWl8.png" /></figure><p>In the <strong>Scope </strong>tab, keep the local and remote IP addresses as they are and press the <strong>Next</strong> button. In the <strong>Action</strong> tab, enable the <strong>Block the connection</strong> option and press <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*TSk2F9q-POd1FgFN.png" /></figure><p>In the <strong>Profile</strong> tab, we keep all the network profiles check-marked. Lastly, the final phase is to give your rule a name and an optional description and press the <strong>Finish</strong> button.</p><p>We can see our rule is there in the available outbound rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9_s_-OrUkzK1-QP3.png" /></figure><p>Now, let’s test our rule by browsing to http://10.10.10.10/. We get an error message saying we cannot reach this page, meaning the rule works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_4kdnwp7tnbrG40O.png" /></figure><h3>Linux iptables Firewall</h3><p>In the previous task, we discussed the built-in firewall available in the Windows OS. What if you are a Linux user? You still need control over your network traffic. Linux also offers the functionality of a built-in firewall. We have multiple firewall options available here. Let’s briefly review most of them and explore one of them in detail.</p><h4>Netfilter</h4><p>Netfilter is the framework inside the Linux OS with core firewall functionalities, including packet filtering, NAT, and connection tracking. This framework serves as the foundation for various firewall utilities available in Linux to control network traffic. Some common firewall utilities that utilize this framework are listed below:</p><ul><li><strong>iptables</strong>: A widely used command-line tool in Linux distributions, leveraging the Netfilter framework to configure detailed firewall rules for packet filtering and NAT. Its complex syntax suits advanced users managing custom network policies.</li><li><strong>nftables</strong>: The successor to iptables, offering improved performance, simpler syntax, and enhanced features like better NAT and packet filtering. It’s ideal for modern Linux systems requiring scalable firewall solutions.</li><li><strong>firewalld</strong>: A dynamic firewall management tool using Netfilter, featuring predefined network zones (e.g., public, private) for easy configuration. It’s user-friendly for managing rules across different network environments.</li></ul><h4>ufw</h4><p>ufw (Uncomplicated Firewall), as the name says, eliminates the complications of making rules in a complex syntax in “iptables”(or its successor) by giving you an easier interface. It is more beginner-friendly. Basically, whatever rules you need in “iptables”, you can define them with some easy commands via ufw, which would then be configuring your desired rules in “iptables”. Let’s have a look at some basic ufw commands down below.</p><p>To check the status of the firewall, you could use the command below:</p><p><strong>Check status</strong></p><pre>user@ubuntu:~$ sudo ufw status<br>Status: inactive</pre><p>If it appears inactive, you can enable it using the following command:</p><p><strong>Enable firewall</strong></p><pre>user@ubuntu:~$ sudo ufw enable<br>Firewall is active and enabled on system startup</pre><p>To turn off the firewall, type “disable” instead of “enable” in the above command.</p><p>Below is a rule created to allow all the outgoing connections from a Linux machine. The default in the command means that we are defining this policy as a default policy allowing all the outgoing traffic unless we define an outgoing traffic restriction on any specific application in a separate rule. You can also make a rule to allow/deny traffic coming into your machine by replacing outgoing with incoming in the following command:</p><p><strong>Allow all outgoing traffic</strong></p><pre>user@ubuntu:~$ sudo ufw default allow outgoing<br>Default outgoing policy changed to &#39;allow&#39;<br>(be sure to update your rules accordingly)</pre><p>You can deny incoming traffic at any port in your system. Let’s say that we want to block incoming SSH traffic. We can achieve this with the command ufw deny 22/tcp. As you can see, we first specified the action, deny in this case; furthermore, we specified the port and the transport protocol, which is TCP port 22, or simply 22/tcp.</p><p><strong>Deny incoming SSH traffic</strong></p><pre>user@ubuntu:~$ sudo ufw deny 22/tcp<br>Rule added<br>Rule added (v6)</pre><p>To list down all the active rules in a numbered order, you can use the following command:</p><p><strong>List all rules</strong></p><pre>user@ubuntu:~$ sudo ufw status numbered<br>     To                         Action      From<br>     --                         ------      ----<br>[ 1] 22/tcp                     DENY IN     Anywhere                  <br>[ 2] 22/tcp (v6)                DENY IN     Anywhere (v6)</pre><p>To delete any rule, execute the following command with the rule number to delete:</p><p><strong>Delete a rule</strong></p><pre>user@ubuntu:~$ sudo ufw delete 2<br>Deleting:<br> deny 22/tcp<br>Proceed with operation (y|n)? y<br>Rule deleted (v6)</pre><p>These different utilities can be used to manage Netfilter. Choosing the right utility for the Linux OS depends on multiple factors, such as familiarity with the OS and your requirements. You can test your knowledge of Linux firewalls by creating some rules defined in this task and testing them to ensure they are working as expected.</p><h4>Conclusion</h4><p>Firewalls are your first line of defense against cyber threats, acting as gatekeepers for your network. Whether you’re using a stateless firewall for speed, a stateful one for smarter filtering, or an advanced NGFW for deep inspection, choosing the right firewall depends on your needs. Try setting up a custom rule on Windows Defender Firewall or experiment with ufw on Linux to see how they protect your system. For advanced setups, explore tools like nftables or visit x.ai/grok for deeper insights into network security. <strong>Have you set up a firewall before? Share your tips or challenges in the comments!</strong></p><h4>Connect with Me</h4><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><p><strong>Reference:</strong></p><ul><li><a href="https://tryhackme.com/room/firewallfundamentals">https://tryhackme.com/room/firewallfundamentals</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e22216517f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Diffie-Hellman: The Mathematical Foundations of Secure Key Exchange]]></title>
            <link>https://medium.com/@er.sumitsah/demystifying-diffie-hellman-the-mathematical-foundations-of-secure-key-exchange-29b531c9b805?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/29b531c9b805</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[diffie-hellman]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[key-exchange]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 15:13:36 GMT</pubDate>
            <atom:updated>2025-10-10T15:13:36.394Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ccCL-VM_h2snDLXMXfy-EQ.png" /></figure><p>In the world of <strong>cybersecurity</strong>, we often talk about the importance of <strong>symmetric encryption</strong> for its <strong>speed and efficiency</strong> when securing <strong>bulk data</strong>. But this leads to a classic <strong>chicken-and-egg problem</strong>: How do you securely share the <strong>secret key</strong> in the first place?</p><p>Sending it via <strong>email</strong> is like <strong>mailing your house key on a postcard</strong>. Whispering it over the <strong>phone</strong> isn’t scalable or secure. We need a way to create a <strong>shared secret</strong> <em>out in the open</em>, on a potentially <strong>insecure channel</strong>, in such a way that any <strong>eavesdropper</strong> listening to every byte of data exchanged still cannot figure out what the secret is.</p><p>This is precisely the problem that <strong>Whitfield Diffie</strong> and <strong>Martin Hellman</strong> solved in <strong>1976</strong>, <strong>revolutionizing cryptography</strong>. The <strong>Diffie-Hellman Key Exchange (DHKE)</strong> isn’t an <strong>encryption algorithm</strong>; it’s a <strong>method for two parties to jointly establish a shared secret over a public channel</strong>. Let’s dissect this <strong>cryptographic marvel</strong> from its <strong>mathematical foundations</strong> to its <strong>practical implications</strong>.</p><h4>The Core Conceptual Analogy: Mixing Paints</h4><p>Before we dive into the numbers, let’s grasp the concept with a famous analogy:</p><ol><li><strong>Agree on Public Colors:</strong> Alice and Bob publicly agree on a starting “common paint” (say, yellow). Anyone can know this color.</li><li><strong>Choose Secret Colors:</strong> Each chooses a secret color that they never reveal. Alice chooses Red, Bob chooses Blue.</li><li><strong>Mix and Exchange:</strong> Each mixes the common yellow paint with their own secret color. Alice gets Yellow-Red, Bob gets Yellow-Blue. They then send these mixed colors to each other over an open channel. An eavesdropper, Eve, can see these mixed colors.</li><li><strong>Create the Shared Secret:</strong> Upon receiving the other’s mixture, each person adds their <em>own</em> secret color to it.</li></ol><ul><li>Alice takes (Yellow-Blue) and adds her <em>Red</em> to get Yellow-Blue-Red.</li><li>Bob takes (Yellow-Red) and adds his <em>Blue</em> to get Yellow-Red-Blue.</li></ul><p><strong>Voilà!</strong> Both Alice and Bob now have the same final color (Yellow-Blue-Red), while Eve is left only with the publicly exchanged mixtures (Yellow-Red and Yellow-Blue). Separating the secret colors from these mixtures is computationally impractical — just like the mathematical problem underpinning DHKE.</p><h3>The Mathematical Engine: The Discrete Logarithm Problem</h3><p>The “magic” of Diffie-Hellman relies on a concept in modular arithmetic known as the Discrete Logarithm Problem (DLP).</p><h4><strong>The Setup: Finite Fields</strong></h4><p><strong>DHKE</strong> operates within the multiplicative group of integers modulo a prime number p. Think of this as a clock with p hours, where numbers wrap around after reaching p. We also need a <strong>generator (or primitive root)</strong> g. This is a number between 1 and p-1 with a special property: when you calculate g^1 mod p, g^2 mod p, ..., g^{p-1} mod p, the results will produce every number from 1 to p-1 in some permutation.</p><p>These two values, the prime p and the generator g, are the public parameters agreed upon by both parties. They are not secret.</p><h4><strong>The “One-Way” Function</strong></h4><p>The security rests on the fact that while exponentiation in this modular field is computationally easy, finding the exponent (the logarithm) is exceptionally hard.</p><ul><li>Easy Direction (Forward): Given g, a, and p, calculating A = g^a mod p is fast, even for very large numbers (hundreds of digits).</li><li>Hard Direction (Backward): Given g, p, and the result A, finding the secret exponent a (where a = log_g(A) mod p) is believed to be computationally infeasible for large, well-chosen primes p. This is the Discrete Logarithm Problem.</li></ul><p>It’s this asymmetry — easy to compute in one direction, hard to reverse — that makes DHKE secure.</p><h4>The Protocol in Action: A Numerical Walkthrough</h4><p>Let’s make this concrete with our specified numbers. (Remember, these are <em>insecure</em> in practice but perfect for illustration.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RjT-GRL-oh_3XZDiMj78ZA.png" /></figure><p><strong>Public Parameter Agreement:</strong></p><ul><li>Alice and Bob agree on a prime p = 29.</li><li>They agree on a generator g = 3.</li></ul><p><strong>Private Key Generation:</strong></p><ul><li>Alice secretly chooses a private key a = 13.</li><li>Bob secretly chooses a private key b = 15.</li></ul><p><strong>Public Key Calculation:</strong></p><ul><li>Alice computes her public key: A = g^a mod p = 3^13 mod 29.</li><li>3^2 = 9 mod 29</li><li>3^4 = (9)^2 = 81 mod 29 = 23</li><li>3^8 = (23)^2 = 529 mod 29 = 7</li><li>3^13 = 3^8 * 3^4 * 3^1 = 7 * 23 * 3 = 483 mod 29 = 19</li><li>So, Alice’s public key is A = 19.</li><li>Bob computes his public key: B = g^b mod p = 3^15 mod 29.</li><li>3^8 = 7 (from above)</li><li>3^15 = 3^8 * 3^4 * 3^2 * 3^1 = 7 * 23 * 9 * 3 = 4347 mod 29 = 26</li><li>So, Bob’s public key is B = 26.</li></ul><p><strong>Key Exchange:</strong></p><ul><li>Alice sends A = 19 to Bob.</li><li>Bob sends B = 26 to Alice.</li><li>Eve intercepts both 19 and 26.</li></ul><p><strong>Shared Secret Derivation:</strong></p><ul><li>Alice computes the shared secret s:</li><li>s = B^a mod p = 26^13 mod 29.</li><li>The result is s = 10.</li><li>Bob computes the shared secret s:</li><li>s = A^b mod p = 19^15 mod 29.</li><li>The result is s = 10.</li></ul><p>Alice and Bob have now independently arrived at the same shared secret, 10, without ever transmitting it. Eve is left with p=29, g=3, A=19, B=26. To find the secret 10, she would need to solve either 3^a ≡ 19 (mod 29) for a, or 3^b ≡ 26 (mod 29) for b. With our tiny numbers, she could brute-force it, but with a 2048-bit prime, it&#39;s impossible before the heat death of the universe.</p><h3>From Mathematical Elegance to Cybersecurity Practice</h3><p>For cybersecurity professionals, understanding DHKE is non-negotiable. It’s not just an academic exercise; it’s the bedrock of secure internet communication.</p><ol><li><strong>Real-World Parameters:</strong> In practice, we use primes p that are 2048 bits or larger. Standards like RFC 7919 even define specific, well-vetted &quot;safe primes&quot; to use, preventing the use of weak parameters that might be vulnerable to specialized attacks.</li><li><strong>The Man-in-the-Middle (MITM) Vulnerability:</strong> The classic <strong>DHKE</strong> described is unauthenticated. If Eve can intercept and modify messages, she can pose as “Bob” to Alice and as “Alice” to Bob, establishing two separate keys and decrypting/relaying all communication. This is why raw DHKE is rarely used alone.</li><li><strong>The Synergy with Asymmetric Cryptography (RSA):</strong> This is where the magic happens. Protocols like TLS (which secures HTTPS) combine the key-agreement strength of DHKE with the authentication strength of RSA (or Elliptic-Curve) digital signatures.</li></ol><ul><li>Diffie-Hellman is used for Forward Secrecy. Even if an attacker records your encrypted session and later steals the server’s private RSA key, they cannot decrypt the old session because the DH key was ephemeral and is no longer stored anywhere.</li><li>RSA is used to digitally sign the DH key exchange. The server proves its identity by signing the messages sent during the DH handshake. The client can verify this signature using the server’s certified public key, thwarting MITM attacks.</li></ul><h4>Conclusion</h4><p>The <strong>Diffie-Hellman Key Exchange</strong> is a masterpiece of <strong>applied mathematics</strong>. It transformed <strong>cryptography</strong> by showing that two parties could create a <strong>shared secret</strong> <em>in plain sight</em>, secured by the computational hardness of the <strong>Discrete Logarithm Problem</strong>. For <strong>cybersecurity professionals</strong>, it serves as a <strong>fundamental building block</strong>, a brilliant solution to the <strong>key distribution problem</strong>, and a critical component in achieving robust security properties like <strong>forward secrecy</strong> in the protocols that underpin our <strong>modern, connected world</strong>.</p><h4>Connect with Me</h4><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29b531c9b805" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Complete Guide to RSA Encryption: From Mathematical Foundations to CTF Breakthroughs]]></title>
            <link>https://medium.com/@er.sumitsah/the-complete-guide-to-rsa-encryption-from-mathematical-foundations-to-ctf-breakthroughs-f65b0a6fc883?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/f65b0a6fc883</guid>
            <category><![CDATA[rsa-algorithm]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 15:36:26 GMT</pubDate>
            <atom:updated>2025-10-07T15:36:26.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-cWt7M0nTFV32RbGdbUutg.png" /></figure><blockquote>Unlock the secrets, master the mathematics, and remember: in cryptography, understanding the attack is the first step toward building better defenses. 🔐</blockquote><p>In the digital age, where sensitive information constantly traverses insecure networks, <strong>RSA</strong> stands as one of the most significant cryptographic breakthroughs in history. Named after its creators — <strong>Ron Rivest</strong>, <strong>Adi Shamir</strong>, and <strong>Leonard Adleman</strong> — this public-key encryption algorithm has secured everything from online banking to confidential communications for decades.</p><p>What makes RSA truly remarkable is its elegant solution to a fundamental problem: <strong>how can two parties communicate securely without having previously shared a secret key?</strong> The answer lies in the beautiful marriage of number theory and computer science that forms RSA’s foundation.</p><h3>The Mathematical Heart of RSA Security</h3><h4>The Factorization Problem: Easy One Way, Hard the Other</h4><p>At its core, RSA’s security relies on a simple asymmetry: multiplication is easy, but factorization is hard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*GjU66ymP8iFHd7GMsyXBmQ.png" /><figcaption><strong>Image 1: An illustration of Alice and Bob exchanging encrypted messages using public-key cryptography.</strong></figcaption></figure><p>Consider this:</p><p><strong>Multiply two primes:</strong> 113 × 127 = 14,351 (easily done on paper)</p><p><strong>Factor 14,351</strong> back into 113 and 127 (significantly harder)</p><p>Scale this up:</p><p><strong>Prime number 1:</strong> 982,451,653,031 <strong>Prime number 2:</strong> 169,743,212,279</p><p><strong>Their product:</strong> 166,764,499,494,295,486,767,649</p><p>While a computer can still factor this larger number, imagine primes with <strong>300 digits each</strong>. The product would be approximately <strong>600 digits long</strong>, and factoring it would take the world’s fastest supercomputers <strong>longer than the age of the universe</strong>.</p><p>This computational asymmetry is RSA’s <strong>security guarantee</strong>: multiplying two large primes is computationally feasible, but factoring their product is practically impossible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gSXu_TsfcdCP54b8.png" /><figcaption><strong>Image 2: Progress in factoring large numbers over time, highlighting the increasing difficulty for RSA security.</strong></figcaption></figure><h3>RSA in Action: A Complete Numerical Example</h3><p>Let’s walk through <strong>Bob and Alice’s secure communication</strong> step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*VzQYArqo3i7lS-bUfoxULA.png" /><figcaption><strong>Image 3: A flowchart depicting the RSA encryption and decryption process.</strong></figcaption></figure><h4>Key Generation Phase</h4><p><strong>Step 1: Choose Primes</strong> Bob selects two prime numbers: <strong>p = 157</strong> <strong>q = 199</strong></p><p><strong>Step 2: Calculate the Modulus</strong> <strong>n = p × q = 157 × 199 = 31,243</strong></p><p><strong>Step 3: Calculate Totient Functions</strong></p><p>Traditional Approach using <strong>Euler’s Totient φ(n)</strong>: <strong>φ(n) = (p-1) × (q-1) = 156 × 198 = 30,888</strong></p><p>Alternative Approach using <strong>Carmichael’s Function λ(n)</strong>: <strong>λ(n) = lcm(p-1, q-1) = lcm(156, 198) = 5,148</strong></p><p>Both approaches work, but <strong>λ(n)</strong> often produces smaller values, making computations <strong>more efficient</strong>.</p><p><strong>Step 4: Choose Public Exponent</strong> Bob selects <strong>e = 163</strong>, ensuring it’s coprime to both φ(n) and λ(n).</p><p><strong>Step 5: Calculate Private Exponent</strong> Using the <strong>Extended Euclidean Algorithm</strong>:</p><p>With φ(n): <strong>d ≡ e⁻¹ mod φ(n) = 163⁻¹ mod 30,888 = 379</strong> Verification: <strong>163 × 379 = 61,777 ≡ 1 mod 30,888</strong></p><p>With λ(n): <strong>d ≡ e⁻¹ mod λ(n) = 163⁻¹ mod 5,148 = 379</strong> Verification: <strong>163 × 379 = 61,777 ≡ 1 mod 5,148</strong></p><p><strong>Final Keys:</strong> <strong>Public Key:</strong> (n, e) = (31,243, 163) <strong>Private Key:</strong> (n, d) = (31,243, 379)</p><h4>Encryption Phase</h4><p>Alice wants to send message <strong>x = 13</strong> to Bob:</p><p>She obtains Bob’s public key: <strong>(31,243, 163)</strong> She computes: <strong>y = x^e mod n = 13¹⁶³ mod 31,243</strong> After computation: <strong>y = 16,341</strong></p><p>Alice sends the <strong>ciphertext 16,341</strong> to Bob.</p><h4>Decryption Phase</h4><p>Bob receives the encrypted message:</p><p>He uses his private key: <strong>(31,243, 379)</strong> He computes: <strong>x = y^d mod n = 16,341³⁷⁹ mod 31,243</strong> The result: <strong>x = 13</strong> (the original message)</p><p><strong>Magic restored!</strong> The original message is recovered.</p><h4>Why RSA Works: The Mathematical Magic</h4><p>The security of RSA relies on <strong>Euler’s theorem</strong>, which states that for any integer m coprime to n: <strong>m^φ(n) ≡ 1 mod n</strong></p><p>In RSA, we ensure that: <strong>e × d ≡ 1 mod φ(n)</strong> [or mod λ(n)]</p><p>Therefore: <strong>(m^e)^d ≡ m^(e×d) ≡ m^(k×φ(n)+1) ≡ (m^φ(n))^k × m ≡ 1^k × m ≡ m mod n</strong></p><p>This mathematical guarantee ensures that encryption and decryption are <strong>inverse operations</strong>.</p><h3>Real-World RSA: From Theory to Practice</h3><h4>Key Sizes and Security</h4><p>In our example, we used small primes for demonstration. In practice:</p><ul><li><strong>1990s:</strong> 512-bit RSA (≈155 decimal digits)</li><li><strong>Early 2000s:</strong> 1024-bit RSA (≈308 decimal digits)</li><li><strong>Current Standard (2025):</strong> 2048-bit RSA (≈617 decimal digits), recommended by NIST until at least 2030</li><li><strong>Future-Proof:</strong> 3072-bit or 4096-bit RSA (≈1,234 decimal digits) for long-term security</li></ul><p>Each doubling of key size increases factorization difficulty <strong>exponentially</strong>. A 2048-bit RSA key would take <strong>billions of years</strong> to break with current technology.</p><h4>Why Both φ(n) and λ(n) Work</h4><p>While most textbooks teach RSA using <strong>Euler’s totient φ(n)</strong>, <strong>Carmichael’s function λ(n)</strong> is equally valid and often more efficient:</p><ul><li><strong>φ(n) = (p-1)(q-1)</strong> — counts numbers coprime to n</li><li><strong>λ(n) = lcm(p-1, q-1)</strong> — smallest universal exponent</li></ul><p>Both ensure that <strong>m^(e×d) ≡ m mod n</strong> for all messages m, but λ(n) typically gives a <strong>smaller d</strong>, speeding up decryption.</p><h3>RSA in CTF Challenges: Putting Theory into Practice</h3><p><strong>Capture the Flag (CTF)</strong> competitions frequently feature RSA challenges that test understanding of the algorithm and its <strong>vulnerabilities</strong>.</p><h4>Essential RSA Variables in CTFs</h4><ul><li><strong>p, q:</strong> Large prime numbers (the secret factors)</li><li><strong>n = p × q:</strong> Public modulus</li><li><strong>e:</strong> Public exponent (usually 65,537)</li><li><strong>d:</strong> Private exponent</li><li><strong>m:</strong> Plaintext message</li><li><strong>c:</strong> Ciphertext</li></ul><h4>Common CTF Challenge Types</h4><ul><li><strong>Factorable n:</strong> When n is small enough to factor</li><li><strong>Weak e:</strong> Small public exponent attacks</li><li><strong>Related primes:</strong> When p and q share a relationship</li><li><strong>Partial information:</strong> Known bits of p, q, or d</li><li><strong>Broadcast attacks:</strong> Same message encrypted with different n but same e</li></ul><h4>Essential Tools for RSA CTFs</h4><ul><li><strong>RsaCtfTool: The Swiss Army Knife for RSA Challenges</strong></li><li><strong>RsaCtfTool</strong> is a versatile Python tool that automatically applies numerous attacks:</li></ul><pre># Install and use RsaCtfTool<br>git clone https://github.com/RsaCtfTool/RsaCtfTool.git<br>cd RsaCtfTool<br>python RsaCtfTool.py - publickey key.pub - uncipherfile ciphertext.txt</pre><p><strong>The tool automatically tries:</strong></p><ul><li><strong>Wiener’s attack </strong>(small d)</li><li><strong>FactorDB lookup</strong></li><li><strong>Small q approximation</strong></li><li><strong>Fermat factorization</strong> And many more…</li></ul><h4>Other Valuable Tools</h4><ul><li><strong>rsatool</strong>: Specialized RSA key generation and analysis</li><li><strong>Factordb</strong>: Online database of known factorizations</li><li><strong>Python libraries:</strong> gmpy2, pycryptodome, sympy</li></ul><h4>Sample CTF Workflow</h4><p>When faced with an RSA challenge:</p><ol><li><strong>Gather information:</strong> Extract n, e, c from provided files</li><li><strong>Check for obvious weaknesses:</strong> Small n, small e, special relationships</li><li><strong>Try automated tools: Run RsaCtfTool first</strong></li><li><strong>Manual analysis:</strong> Look for mathematical relationships</li><li><strong>Compute the flag:</strong> Once d is found, decrypt c to get m</li></ol><h3>Conclusion: Mastering RSA</h3><p>Understanding RSA is <strong>essential</strong> for anyone in cybersecurity, from developers to penetration testers. Its elegant mathematical foundation demonstrates how theoretical number theory enables <strong>practical security solutions</strong>.</p><p>The journey from understanding the basic factorization problem to breaking RSA challenges in CTFs provides <strong>deep insight</strong> into cryptographic principles that extend far beyond RSA itself.</p><p>Whether you’re implementing secure systems, participating in CTF competitions, or simply satisfying intellectual curiosity, RSA offers a <strong>fascinating window</strong> into the world of cryptography — where ancient mathematics meets modern security challenges.</p><h4>Further Resources:</h4><ul><li><a href="https://people.csail.mit.edu/rivest/Rsapaper.pdf"><strong>Original RSA Paper</strong></a></li><li><a href="https://github.com/RsaCtfTool/RsaCtfTool"><strong>RsaCtfTool GitHub Repository</strong></a></li><li><a href="https://cryptohack.org/challenges/rsa/"><strong>Cryptohack RSA Challenges</strong></a></li></ul><h4>Connect with Me</h4><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f65b0a6fc883" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptography Basics: The Foundation of Our Digital World]]></title>
            <link>https://medium.com/@er.sumitsah/cryptography-basics-the-foundation-of-our-digital-world-3dae5d9f9f0e?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dae5d9f9f0e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[data-security]]></category>
            <category><![CDATA[cipher]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 08:05:48 GMT</pubDate>
            <atom:updated>2025-10-06T08:05:48.836Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0MaaVCHGyg-umfB-B9zJsg.png" /></figure><blockquote>Cryptography isn’t reserved for experts — it’s the unseen guardian of our digital existence.</blockquote><p>Have you ever stopped to think about what keeps your online conversations private? Or how your browser knows it’s really connecting to your bank’s website and not an imposter? The answer lies in cryptography — the invisible shield protecting our digital lives.</p><p>Cryptography isn’t just for security experts or tech giants. It’s the fundamental technology that enables trust in our connected world, ensuring that our messages, transactions, and data remain confidential and tamper-proof.</p><h3>Why Cryptography Matters More Than Ever</h3><p>At its core, cryptography ensures secure communication even in the presence of adversaries. “Secure” encompasses both <strong>confidentiality</strong> (keeping data private) and <strong>integrity</strong> (preventing unauthorized alterations). In everyday life, this translates to:</p><ul><li>When logging into online platforms, your credentials are encrypted, thwarting eavesdroppers on your connection.</li><li>SSH sessions create encrypted tunnels, shielding your activities from prying eyes.</li><li>Online banking verifies the server’s certificate, confirming you’re dealing with your legitimate bank — not an imposter.</li><li>File downloads use hash functions to verify integrity, ensuring the content is unaltered and matches the original.</li></ul><h3>The Language of Cryptography: Key Terms Explained</h3><p>To grasp cryptography, start with its core vocabulary:</p><ul><li><strong>Plaintext</strong>: The original, readable message or data before encryption.</li><li><strong>Ciphertext</strong>: The scrambled, unreadable output after encryption.</li><li><strong>Cipher</strong>: The algorithm that transforms plaintext into ciphertext (and vice versa).</li><li><strong>Key</strong>: A secret string of bits that drives the cipher’s encryption/decryption process.</li><li><strong>Encryption</strong>: Converting plaintext to ciphertext using a cipher and key.</li><li><strong>Decryption</strong>: The reverse — recovering plaintext from ciphertext.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pik73Y6MQlKdKU-ibdplDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l39lt2cGs4mEN3tkFm7b7Q.png" /></figure><h3>A Historical Perspective: The Caesar Cipher</h3><p>Cryptography’s roots trace back millennia, but the Caesar Cipher from the first century BCE remains a classic example of simplicity. It works by shifting each letter in the alphabet by a fixed number of positions.</p><p><strong>Try it yourself:</strong></p><ul><li><strong>Plaintext</strong>: TRYHACKME</li><li><strong>Key</strong>: 3 (right shift of 3 positions)</li><li><strong>Ciphertext</strong>: WUBKDFNPH</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7RzD-iERC10WweBV-EPxng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bVhZWUdsfdJ655m6eiyEbQ.png" /></figure><p>Decryption reverses the shift (left by 3). Ingenious for its era, but insecure today — with just 25 possible keys, brute-force attacks crack it instantly!</p><p><strong>See more in the example below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3Tudbe8bxvP9J9kvdUGvw.png" /></figure><h3>Modern Encryption: Symmetric vs. Asymmetric</h3><h4>Symmetric Encryption: One Key to Rule Them All</h4><p>Symmetric encryption employs a single key for both encryption and decryption, like a shared lock and key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2HTJlP1dzOKbDOD6hpC6vw.png" /></figure><p>Key examples:</p><ul><li><strong>DES (Data Encryption Standard)</strong>: 56-bit key; cracked in under 24 hours by 1999 due to advancing computing power.</li><li><strong>3DES (Triple DES)</strong>: DES applied three times; deprecated in 2019 — migrate to AES.</li><li><strong>AES (Advanced Encryption Standard)</strong>: The modern benchmark, supporting 128-, 192-, or 256-bit keys.</li></ul><p><strong><em>The hurdle? Securely distributing the key, known as the “key distribution problem,” especially across insecure channels.</em></strong></p><h4>Asymmetric Encryption: A Key Pair Solution</h4><p>Asymmetric encryption uses a duo: a public key (shared freely for encryption) and a private key (guarded for decryption).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ab1RL9oqilCMJXXWMjfHkw.png" /></figure><p>Prominent examples:</p><ul><li><strong>RSA</strong>: Relies on factoring large primes; minimum recommended key size is 2048 bits.</li><li><strong>Diffie-Hellman</strong>: Facilitates secure key exchanges.</li><li><strong>ECC (Elliptic Curve Cryptography)</strong>: Delivers comparable security with shorter keys (e.g., 256-bit ECC ≈ 3072-bit RSA).</li></ul><p><strong><em>Real-world analogy: Distribute open padlocks (public keys) — anyone can lock a message, but only you hold the key to unlock it.</em></strong></p><h3>The Mathematical Magic Behind Cryptography</h3><h4>XOR Operation: The Binary Workhorse</h4><p>XOR (exclusive OR) is a bitwise operation that outputs 1 only if the inputs differ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-igp4EMfG0ic8HgPDDpJbQ.png" /></figure><p>example: 1010 ⊕ 1100 = 0110</p><p>XOR’s cryptographic utility stems from properties like:</p><ul><li>A ⊕ A = 0</li><li>A ⊕ 0 = A</li><li>(A ⊕ B) ⊕ B = A</li></ul><p>This enables basic symmetric encryption: Ciphertext C = Plaintext P ⊕ Key K; recover with P = C ⊕ K.</p><h4>Modulo Operation: The Remainder Calculator</h4><p>Modulo (X % Y) yields the remainder of X divided by Y:</p><ul><li>25 % 5 = 0 (25 = 5 × 5 + 0)</li><li>23 % 6 = 5 (23 = 3 × 6 + 5)</li><li>23 % 7 = 2 (23 = 3 × 7 + 2)</li></ul><p>In cryptography, modulo creates cyclic behaviors (like alphabet wrapping in Caesar) and underpins complex algorithms by making operations irreversible in practice.</p><h3>Conclusion: Your First Step into a Larger World</h3><p>Understanding these fundamentals — from <strong>ancient ciphers</strong> to the <strong>mathematical principles of modern encryption</strong> — is the first step in demystifying how our digital world stays secure. <strong>Cryptography</strong> is not an obscure art for the few, but a <strong>critical technology</strong> that empowers everyone to communicate, transact, and live online with <strong>confidence</strong>.</p><p>The next time you see that lock icon in your browser, you’ll appreciate the sophisticated dance of <strong>algorithms and keys</strong> working to protect you. This knowledge is your <strong>foundation</strong>. From here, you can explore the fascinating realms of <strong>public key infrastructure</strong>, the magic of <strong>hash functions</strong>, and the <strong>protocols</strong> that keep the internet running.</p><h3>Connect with Me</h3><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dae5d9f9f0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Networking Core Protocols Explained: The Internet’s Hidden Conversations]]></title>
            <link>https://medium.com/@er.sumitsah/networking-core-protocols-explained-the-internets-hidden-conversations-3716333c6204?source=rss-1c65c5cdd655------2</link>
            <guid isPermaLink="false">https://medium.com/p/3716333c6204</guid>
            <category><![CDATA[email-security]]></category>
            <category><![CDATA[imap]]></category>
            <category><![CDATA[ftp]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Sumit Sah]]></dc:creator>
            <pubDate>Sat, 04 Oct 2025 13:50:33 GMT</pubDate>
            <atom:updated>2025-10-04T13:50:33.780Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Learn how DNS, HTTP, FTP, and email protocols power everything you do online — from loading web pages to sending emails.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*xbrcm9dVAzjP3uPF.png" /></figure><h3>DNS: Remembering Addresses</h3><p>Do you remember the IP addresses of your favourite websites? Unless it is a private IP address of a local device, no one needs to worry about memorizing IP addresses. This is in part due to the Domain Name System (DNS), which is responsible for properly mapping a domain name to an IP address.</p><p>DNS operates at the Application Layer, i.e., Layer 7 of the ISO OSI model. DNS traffic uses UDP port 53 by default and TCP port 53 as a default fallback. There are many types of DNS records; however, in this task, we will focus on the following four:</p><ul><li><strong>A record</strong>: The A (Address) record maps a hostname to one or more IPv4 addresses. For example, you can set example.com to resolve to 172.17.2.172.</li><li><strong>AAAA Record</strong>: The AAAA record is similar to the A Record, but it is for IPv6. Remember that it is AAAA (quad-A), as AA and AAA would refer to a battery size; furthermore, AAA refers to <em>Authentication, Authorization, and Accounting</em>; neither falls under DNS.</li><li><strong>CNAME Record</strong>: The CNAME (Canonical Name) record maps a domain name to another domain name. For example, www.example.com can be mapped to example.com or even to example.org.</li><li><strong>MX Record</strong>: The MX (Mail Exchange) record specifies the mail server responsible for handling emails for a domain.</li></ul><p>In other words, when you type example.com in your browser, your browser tries to resolve this domain name by querying the DNS server for the A record. However, when you try to send an email to test@example.com, the mail server would query the DNS server to find the MX record.</p><p>If you want to look up the IP address of a domain from the command line, you can use a tool such as nslookup. Consider the example in the terminal below where we look up example.com.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Em_fdmHcs9vSO07gj96tQ.png" /></figure><p>The query above led to four packets. In the terminal below, we can see that the first and third packets send DNS queries for the A and AAAA records, respectively. The second and fourth packets show the DNS query responses.</p><pre>user@TryHackMe$ tshark -r dns-query.pcapng -Nn<br>    1 0.000000000 192.168.66.89 → 192.168.66.1 DNS 86 Standard query 0x2e0f A www.example.com OPT<br>    2 0.059049584 192.168.66.1 → 192.168.66.89 DNS 102 Standard query response 0x2e0f A www.example.com A 93.184.215.14 OPT<br>    3 0.059721705 192.168.66.89 → 192.168.66.1 DNS 86 Standard query 0x96e1 AAAA www.example.com OPT<br>    4 0.101568276 192.168.66.1 → 192.168.66.89 DNS 114 Standard query response 0x96e1 AAAA www.example.com AAAA 2606:2800:21f:cb07:6820:80da:af6b:8b2c OPT</pre><h3>WHOIS</h3><p>In the previous task, we covered how a domain name is resolved into an IP address. However, for this to happen, someone needs to have the authority to set the A, AAAA, and MX records, among other DNS records for the domain. Whoever registers a domain name is granted this power. Therefore, if you register example.com, you can set any valid DNS records for example.com.</p><p>You can register any available domain name for one or more years. You need to pay the annual fee, and you are required to provide <a href="https://www.icann.org/resources/pages/whois-data-accuracy-2017-06-20-en">accurate contact information</a> as the registrant. This information is part of the data available via WHOIS records and is available publicly. (Although written in uppercase, WHOIS is not an acronym; it is pronounced <em>who is</em>.) However, don’t worry if you want to register a domain without revealing your contact information publicly; you can use one of the privacy services that hide all your information from the WHOIS records.</p><p>You can look up the WHOIS records of any registered domain name using one of the online services or via the command-line tool whois, available on Linux systems, among others. As expected, a WHOIS record provides information about the entity that registered a domain name, including name, phone number, email, and address. In the screenshot shown below, you can see when the record was first created and when it was last updated. Moreover, you can find the registrant’s name, address, phone, and email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rk269gHpDKwfoo_U.png" /></figure><p>In the terminal output below, we have used the whois command to look up a domain whose WHOIS record is protected by privacy protection.</p><pre>user@TryHackMe$ whois [REDACTED].com<br>[...]<br>Domain Name: [REDACTED].COM<br>Registry Domain ID: [REDACTED]<br>Registrar WHOIS Server: whois.godaddy.com<br>Registrar URL: https://www.godaddy.com<br>Updated Date: 2017-07-05T16:02:43Z<br>Creation Date: 1993-04-02T00:00:00Z<br>Registrar Registration Expiration Date: 2026-10-20T14:56:17Z<br>Registrar: GoDaddy.com, LLC<br>Registrar IANA ID: 146<br>Registrar Abuse Contact Email: abuse@godaddy.com<br>Registrar Abuse Contact Phone: +1.4806242505<br>[...]<br>Registrant Name: Registration Private<br>Registrant Organization: Domains By Proxy, LLC<br>Registrant Street: DomainsByProxy.com<br>[...]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1tjyc4oPFxvx7m9_.png" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*ZgXRFXbA3qUOII4O.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TzaUPBwxUtxaBWAV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sl5N44XP64v1YMtz.png" /></figure><h3>HTTP(S): Accessing the Web</h3><p>When you fire up your browser, you mainly use HTTP and HTTPS protocols. HTTP stands for Hypertext Transfer Protocol; the S in HTTPS stands for Secure. This protocol relies on TCP and defines how your web browser communicates with the web servers.</p><p>Some of the commands or methods that your web browser commonly issues to the web server are:</p><ul><li>GET retrieves data from a server, such as an HTML file or an image.</li><li>POST allows us to submit new data to the server, such as submitting a form or uploading a file.</li><li>PUT is used to create a new resource on the server and to update and overwrite existing information.</li><li>DELETE, as the name suggests, is used to delete a specified file or resource on the server.</li></ul><p>HTTP and HTTPS commonly use TCP ports 80 and 443, respectively, and less commonly other ports such as 8080 and 8443.</p><p>In the following example, we use our Firefox browser to access the web server on MACHINE_IP. Our browser fetches the web page and displays it perfectly; however, we are interested in what happens behind the scenes.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*MACVg-L2y7fnYBOe.png" /></figure><p>Using Wireshark, we can examine the exchange between the Firefox browser and the web server more closely. The screenshot below from Wireshark shows the text sent by our browser in <strong>red</strong> and the web server response in <strong>blue</strong>. As you can tell, a lot of information is exchanged between the client and the server that does not get rendered to the user. Examples include the web server version and when the page was last modified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CF8a-0j1zbNeFXjq.png" /></figure><p>As you remember from <a href="https://tryhackme.com/r/room/networkingconcepts">Networking Concepts</a>, we used the telnet client to connect to the web server running on MACHINE_IP at port 80. We had to send a couple of lines: GET / HTTP/1.1 and Host: anything to get the page we wanted. (On some servers, you might get the file without sending Host: anything.) You can use this method to access any page and not just the default page /. To get file.html, you would send GET /file.html HTTP/1.1, for instance (GET /file.html might work depending on the web server in use). This approach is efficient for troubleshooting as you would be “talking HTTP” with the server.</p><h3>FTP: Transferring Files</h3><p>Unlike HTTP, which is designed to retrieve web pages, File Transfer Protocol (FTP) is designed to transfer files. As a result, FTP is very efficient for file transfer, and when all conditions are equal, it can achieve higher speeds than HTTP.</p><p>Example commands defined by the FTP protocol are:</p><ul><li>USER is used to input the username</li><li>PASS is used to enter the password</li><li>RETR (retrieve) is used to download a file from the FTP server to the client.</li><li>STOR (store) is used to upload a file from the client to the FTP server.</li></ul><p>FTP server listens on TCP port 21 by default; data transfer is conducted via another connection from the client to the server.</p><p>In the terminal below we executed the command ftp MACHINE_IP to connect to the remote FTP server using the local ftp client. Then we went through the following steps:</p><ul><li>We used the username anonymous to log in</li><li>We didn’t need to provide any password</li><li>Issuing ls returned a list of files available for download</li><li>type ascii switched to ASCII mode as this is a text file</li><li>get coffee.txt allowed us to retrieve the file we want</li></ul><p>The command exchange via the FTP client is shown in the terminal below.</p><pre>user@TryHackMe$ ftp MACHINE_IP<br>Connected to MACHINE_IP (MACHINE_IP).<br>220 (vsFTPd 3.0.5)<br>Name (MACHINE_IP:strategos): anonymous<br>331 Please specify the password.<br>Password:<br>230 Login successful.<br>Remote system type is UNIX.<br>Using binary mode to transfer files.<br>ftp&gt; ls<br>227 Entering Passive Mode (10,10,41,192,134,10).<br>150 Here comes the directory listing.<br>-rw-r--r--    1 0        0            1480 Jun 27 08:03 coffee.txt<br>-rw-r--r--    1 0        0              14 Jun 27 08:04 flag.txt<br>-rw-r--r--    1 0        0            1595 Jun 27 08:05 tea.txt<br>226 Directory send OK.<br>ftp&gt; type ascii<br>200 Switching to ASCII mode.<br>ftp&gt; get coffee.txt<br>local: coffee.txt remote: coffee.txt<br>227 Entering Passive Mode (10,10,41,192,57,100).<br>150 Opening BINARY mode data connection for coffee.txt (1480 bytes).<br>WARNING! 47 bare linefeeds received in ASCII mode<br>File may not have transferred correctly.<br>226 Transfer complete.<br>1480 bytes received in 8e-05 secs (18500.00 Kbytes/sec)<br>ftp&gt; quit<br>221 Goodbye.</pre><p>We used Wireshark to examine the exchanged messages more closely. The client’s messages are in <strong>red</strong>, while the server’s responses are in <strong>blue</strong>. Notice how various commands differ between the client and the server. For example, when you type ls on the client, the client sends LIST to the server. One last thing to note is that the directory listing and the file we downloaded are sent over a separate connection each.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*nDenGk3ak3IYS0NI.png" /></figure><h3>SMTP: Sending Email</h3><p>As with browsing the web and downloading files, sending email needs its own protocol. Simple Mail Transfer Protocol (SMTP) defines how a mail client talks with a mail server and how a mail server talks with another.</p><p>The analogy for the SMTP protocol is when you go to the local post office to send a package. You greet the employee, tell them where you want to send your package, and provide the sender’s information before handing them the package. Depending on the country you are in, you might be asked to show your identity card. This process is not very different from an SMTP session.</p><p>Let’s present some of the commands used by your mail client when it transfers an email to an SMTP server:</p><ul><li>HELO or EHLO</li><li>MAIL FROM specifies the sender’s email address</li><li>RCPT TO specifies the recipient’s email address</li><li>DATA indicates that the client will begin sending the content of the email message.</li><li>. is sent on a line by itself to indicate the end of the</li></ul><p>The terminal below shows an example of an email sent via telnet. The SMTP server listens on TCP port 25 by default.</p><pre>user@TryHackMe$ telnet MACHINE_IP 25<br>Trying MACHINE_IP...<br>Connected to MACHINE_IP.<br>Escape character is &#39;^]&#39;.<br>220 example.thm ESMTP Exim 4.95 Ubuntu Thu, 27 Jun 2024 16:18:09 +0000<br>HELO client.thm<br>250 example.thm Hello client.thm [10.11.81.126]<br>MAIL FROM: &lt;user@client.thm&gt;<br>250 OK<br>RCPT TO: &lt;strategos@server.thm&gt;<br>250 Accepted<br>DATA<br>354 Enter message, ending with &quot;.&quot; on a line by itself<br>From: user@client.thm<br>To: strategos@server.thm<br>Subject: Telnet email</pre><pre>Hello. I am using telnet to send you an email!<br>.<br>250 OK id=1sMrpq-0001Ah-UT<br>QUIT<br>221 example.thm closing connection<br>Connection closed by foreign host.</pre><p>Obviously, sending an email using telnet is quite cumbersome; however, it helps you better understand the commands that your email client issues under the hood. The Wireshark capture shows the exchange in colours; the client’s messages are in red, while the server’s responses are in blue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*yy-5GRydYRQA9bID.png" /></figure><p>Now that we have covered some basic HTTP, FTP, and SMTP commands, you should have gained a solid understanding of how protocols are designed and used. It should be effortless to learn how other text-based protocols, such as POP3 and IMAP, work.</p><h3>POP3: Receiving Email</h3><p>You’ve received an email and want to download it to your local mail client. The Post Office Protocol version 3 (POP3) is designed to allow the client to communicate with a mail server and retrieve email messages.</p><p>Without going into in-depth technical details, an email client sends its messages by relying on SMTP and retrieves them using POP3. SMTP is similar to handing your envelope or package to the post office, and POP3 is similar to checking your local mailbox for new letters or packages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*1h2GKU7CV3WGzbTR.png" /></figure><p>Some common POP3 commands are:</p><ul><li>USER &lt;username&gt; identifies the user</li><li>PASS &lt;password&gt; provides the user’s password</li><li>STAT requests the number of messages and total size</li><li>LIST lists all messages and their sizes</li><li>RETR &lt;message_number&gt; retrieves the specified message</li><li>DELE &lt;message_number&gt; marks a message for deletion</li><li>QUIT ends the POP3 session applying changes, such as deletions</li></ul><p>In the terminal below, we can see a POP3 session over telnet. Since the POP3 server listens on TCP port 110 by default, the command to connect to the TELNET port is telnet MACHINE_IP 110. The exchange below retrieves the email message sent in the previous task.</p><pre>user@TryHackMe$ telnet MACHINE_IP 110<br>Trying MACHINE_IP...<br>Connected to MACHINE_IP.<br>Escape character is &#39;^]&#39;.<br>+OK [XCLIENT] Dovecot (Ubuntu) ready.<br>AUTH<br>+OK<br>PLAIN<br>.<br>USER strategos<br>+OK<br>PASS <br>+OK Logged in.<br>STAT<br>+OK 3 1264<br>LIST<br>+OK 3 messages:<br>1 407<br>2 412<br>3 445<br>.<br>RETR 3<br>+OK 445 octets<br>Return-path: &lt;user@client.thm&gt;<br>Envelope-to: strategos@server.thm<br>Delivery-date: Thu, 27 Jun 2024 16:19:35 +0000<br>Received: from [10.11.81.126] (helo=client.thm)<br>        by example.thm with smtp (Exim 4.95)<br>        (envelope-from &lt;user@client.thm&gt;)<br>        id 1sMrpq-0001Ah-UT<br>        for strategos@server.thm;<br>        Thu, 27 Jun 2024 16:19:35 +0000<br>From: user@client.thm<br>To: strategos@server.thm<br>Subject: Telnet email</pre><pre>Hello. I am using telnet to send you an email!<br>.<br>QUIT<br>+OK Logging out.<br>Connection closed by foreign host.</pre><p>Someone capturing the network packets would be able to intercept the exchanged traffic. As per previous Wireshark captures, the commands in red are sent by the client, and the lines in blue are the server’s. It is also clear that someone capturing the traffic can read the passwords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*0vIE_QKsdtLzjVOM.png" /></figure><p>Dovecot is often used as the backend for handling email retrieval in many mail servers. While it does not send emails (SMTP servers like Postfix or Exim handle that), it ensures that users can access their emails from different clients and devices.</p><p>Dovecot is a widely-used, reliable, and secure email server software for retrieving emails using the POP3 or IMAP protocols.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*DOtYnOJ7J2jUwxCT.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*WGE-NCsMuWEHoOZa.png" /></figure><h3>IMAP: Synchronizing Email</h3><p>POP3 is enough when working from one device, e.g., your favourite email client on your desktop computer. However, what if you want to check your email from your office desktop computer and from your laptop or smartphone? In this scenario, you need a protocol that allows synchronization of messages instead of deleting a message after retrieving it. One solution to maintaining a synchronized mailbox across multiple devices is Internet Message Access Protocol (IMAP).</p><p>IMAP allows synchronizing read, moved, and deleted messages. IMAP is quite convenient when you check your email via multiple clients. Unlike POP3, which tends to minimize server storage as email is downloaded and deleted from the remote server, IMAP tends to use more storage as email is kept on the server and synchronized across the email clients.</p><p>The IMAP protocol commands are more complicated than the POP3 protocol commands. We list a few examples below:</p><ul><li>LOGIN &lt;username&gt; &lt;password&gt; authenticates the user</li><li>SELECT &lt;mailbox&gt; selects the mailbox folder to work with</li><li>FETCH &lt;mail_number&gt; &lt;data_item_name&gt; Example fetch 3 body[] to fetch message number 3, header and body.</li><li>MOVE &lt;sequence_set&gt; &lt;mailbox&gt; moves the specified messages to another mailbox</li><li>COPY &lt;sequence_set&gt; &lt;data_item_name&gt; copies the specified messages to another mailbox</li><li>LOGOUT logs out</li></ul><p>Knowing that the IMAP server listens on TCP port 143 by default, we will use telnet to connect to MACHINE_IP’s port 143 and fetch the message we sent in an earlier task.</p><pre>user@TryHackMe$ telnet 10.10.41.192 143<br>Trying 10.10.41.192...<br>Connected to 10.10.41.192.<br>Escape character is &#39;^]&#39;.<br>* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN] Dovecot (Ubuntu) ready.<br>A LOGIN strategos<br>A OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY SPECIAL-USE] Logged in<br>B SELECT inbox<br>* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)<br>* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.<br>* 4 EXISTS<br>* 0 RECENT<br>* OK [UNSEEN 2] First unseen.<br>* OK [UIDVALIDITY 1719824692] UIDs valid<br>* OK [UIDNEXT 5] Predicted next UID<br>B OK [READ-WRITE] Select completed (0.001 + 0.000 secs).<br>C FETCH 3 body[]<br>* 3 FETCH (BODY[] {445}<br>Return-path: &lt;user@client.thm&gt;<br>Envelope-to: strategos@server.thm<br>Delivery-date: Thu, 27 Jun 2024 16:19:35 +0000<br>Received: from [10.11.81.126] (helo=client.thm)<br>        by example.thm with smtp (Exim 4.95)<br>        (envelope-from &lt;user@client.thm&gt;)<br>        id 1sMrpq-0001Ah-UT<br>        for strategos@server.thm;<br>        Thu, 27 Jun 2024 16:19:35 +0000<br>From: user@client.thm<br>To: strategos@server.thm<br>Subject: Telnet email</pre><pre>Hello. I am using telnet to send you an email!<br>)<br>C OK Fetch completed (0.001 + 0.000 secs).<br>D LOGOUT<br>* BYE Logging out<br>D OK Logout completed (0.001 + 0.000 secs).<br>Connection closed by foreign host.</pre><p>The screenshot below shows the exchanged messages between the client and the server as seen from Wireshark. The client only needed to send four commands, shown in red, and the “long” server responses are shown in blue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/0*Kri5zsGnFh5XLBCL.png" /></figure><h3>Conclusion</h3><p>This room dives into the foundational protocols powering the internet: DNS, HTTP, FTP, SMTP, POP3, and IMAP. Through these, you’ll gain a clearer view of how domain names translate to IPs, web pages load seamlessly, and emails flow from sender to inbox. Beyond the basics, the real payoff is demystifying what happens under the hood — peeling back the graphical layers to reveal the raw, text-based handshakes that make it all tick.</p><p>For quick reference, here’s a summary of their default ports:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xmdqx9iQ_F5wsN_8.png" /></figure><h3>Connect with Me</h3><ul><li><a href="https://sumit-jr.github.io/Portfolio/"><strong>Portfolio</strong></a><strong>.</strong></li><li><a href="https://x.com/sumitsah_jr"><strong>X(Twitter)</strong></a></li><li><a href="https://www.linkedin.com/in/sumit-prasad-sah/"><strong>Linkedin</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3716333c6204" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>