<?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 Çağrı Topçu on Medium]]></title>
        <description><![CDATA[Stories by Çağrı Topçu on Medium]]></description>
        <link>https://medium.com/@cagritopcu?source=rss-f19a0df32edd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O7mbffJjnp82aLjwHli-jw.jpeg</url>
            <title>Stories by Çağrı Topçu on Medium</title>
            <link>https://medium.com/@cagritopcu?source=rss-f19a0df32edd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:18:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cagritopcu/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[Writing Safer Code: Key Principles of Secure Coding]]></title>
            <link>https://medium.com/@cagritopcu/writing-safer-code-key-principles-of-secure-coding-797f1df94555?source=rss-f19a0df32edd------2</link>
            <guid isPermaLink="false">https://medium.com/p/797f1df94555</guid>
            <dc:creator><![CDATA[Çağrı Topçu]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 14:05:28 GMT</pubDate>
            <atom:updated>2025-08-30T14:05:28.675Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz5Hnh6TFP8GvkDJ8Pg4mg.png" /></figure><h3>Introduction</h3><p>Imagine deploying a new feature, confident it works perfectly… until a hacker exploits a small bug and exposes thousands of users’ private data. <strong>Writing secure code isn’t just good practice — it’s your first line of defense.</strong></p><p>Secure coding is the practice of writing software in a way that <strong>prevents vulnerabilities from the start</strong>. It’s about thinking ahead, anticipating how your code might be misused, and building safeguards before anything goes wrong.</p><h3>Why Secure Coding Matters?</h3><p>Security breaches aren’t just headlines — they’re costly disasters waiting to happen. One small vulnerability can spiral into <strong>millions of compromised records, lost revenue, and irreparable damage to trust.</strong></p><p>Take the <a href="https://en.wikipedia.org/wiki/2017_Equifax_data_breach">Equifax breach</a> <strong>in 2017</strong>: a single unpatched vulnerability exposed sensitive personal information of over<strong> 140 million people</strong>. The aftermath?Billions in fines, lawsuits, and a long-lasting dent in public trust.</p><p>Fixing a security bug <strong>after deployment</strong> is exponentially more expensive than preventing it during development.</p><p>Every developer is part of the security chain. Even if you’re not on a dedicated security team, <strong>your code is a frontline defense</strong>. Writing secure code isn’t just about protecting your application — it’s about <strong>protecting the people who trust it.</strong></p><h3>Core Principles of Secure Coding</h3><h4><strong>Input Validation</strong></h4><p>Input validation is the practice of ensuring that any data coming from users, APIs, or external sources meets the expected format, type, and constraints before it is processed or stored. Proper input validation prevents injection attacks, data corruption, and unexpected behavior.</p><p><strong>Why it matters:</strong></p><p>Unvalidated or poorly validated input is one of the most common attack vectors. Attackers can exploit this to inject malicious code (e.g., SQL Injection, XSS), bypass authentication, or crash systems. By validating input, you ensure that only expected and safe data enters your application.</p><p>📌 <strong>Real World Breaches</strong></p><ul><li><a href="https://nvd.nist.gov/vuln/detail/cve-2014-0160">CVE-2014–0160 (Heartbleed)</a>, OpenSSL failed to properly validate the length of a heartbeat request, leading to a buffer over-read that leaked sensitive server memory (including private keys).</li><li><a href="https://nvd.nist.gov/vuln/detail/cve-2021-21705">CVE-2021–21705 (PHP URL Validation)</a>, PHP’s <strong>FILTER_VALIDATE_URL</strong> accepted malformed inputs, allowing attackers to smuggle malicious data through URLs.</li></ul><h4>Least Privilege</h4><p>The <em>Principle of Least Privilege (PoLP)</em> states that every user, service, or process should only have the minimum set of permissions necessary to perform its tasks; nothing more, nothing less.</p><p>This reduces the attack surface and limits the damage in case an account or system in compromised.</p><p><strong>Why it matters:</strong></p><p>If an attacker compromises a low-privileged account but that account has admin rights “just in case”, the entire system falls. By enforcing least privilege, we <strong>contain the blast radius</strong>; the attacker can only do as much damage as that account was legitimately allowed to do.</p><p>Real-world breaches (like cloud misconfigurations in AWS IAM or Kubernetes clusters) often happen because of <strong>overly permissive roles.</strong> Limiting permissions drastically lowers the chance of escalation.</p><p>❌ <strong>Bad Example</strong></p><ul><li>A web application gives the database user <strong>full </strong>root <strong>access</strong> (CREATE, DROP, ALTER on all schemas) when it only needs to read/write data in one table.</li><li>A developer runs the application in production with <strong>admin rights</strong> on the server “just in case”.</li></ul><p>✅ <strong>Good Example</strong></p><ul><li>The application uses a dedicated database user with <strong>restricted rights</strong> (e.g., only SELECT, INSERT, UPDATE on specific tables)</li><li>System services run as non-root users (e.g., www-data, nobody).</li><li>Developers use regular accounts for daily work and switched to privileged accounts only when needed, using audit-logged sudo.</li></ul><p><strong>📌 Real World Breaches</strong></p><ul><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2021-3156">CVE-2021–3156</a>, a heap-based buffer overflow in sudo allowed local users to escalate privileges to <strong>root </strong>without authentication.</li><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2020-1472">CVE-2020–1472 (Zerologon, Microsoft Netologon)</a>, a flaw in cryptographic authentication allowed attackers with network access to impersonate domain controllers and gain <strong>full domain admin privileges.</strong></li></ul><h4>Defense in Depth</h4><p>Defense in Depth is a <strong>security strategy</strong> that uses <strong>multiple layers of protection</strong> to secure systems and data. Instead of relying on a single safeguard, organizations implement several controls at different levels so that if one fails, others still provide security.</p><p><strong>Why it matters:</strong></p><ul><li><strong>Resilience: </strong>A single control (like a firewall) can fail or be bypassed. Layers ensure backup.</li><li><strong>Delay attackers:</strong> The more barriers, the harder and more time-consuming it is for attackers.</li><li><strong>Buy time for detection:</strong> While attackers struggle with multiple layers, defenders get alerts and can respond.</li></ul><p><strong>Real-world Examples</strong></p><ul><li><strong>Network Security:</strong> Firewalls, IDS/IPS, and segmentation working together.</li><li><strong>Application Security</strong>: Input validation, authentication, authorization, rate limiting, and logging all combined.</li><li><strong>Endpoint Security:</strong> Antivirus + EDR + OS hardening + least privilege access.</li></ul><h4>Fail Securely</h4><p>Security isn’t just about preventing attacks; it’s also about <strong>handling failure the right way.</strong> When something goes wrong (a crash, an error, an exception), your system should fail in a way that <strong>doesn’tt introduce vulnerabilities.</strong></p><p>🔑<strong> Key Ideas</strong></p><p><strong>Deny By Default</strong></p><ul><li>If a system component fails (e.g., authentication service times out), the safe option is to <strong>deny access</strong> instead of granting it.</li><li>“Better safe than sorry” should be the mindset.</li></ul><p><strong>Graceful Error Handling</strong></p><ul><li>Don’t expose stack traces, SQL queries, or sensitive details in error messages.</li><li>Show users a generic error message (“Something went wrong”) while logging the <strong>detailed error internally</strong> for developers.</li></ul><p><strong>Testing Failures</strong></p><p>Intentionally simulate failures (e.g., shutting down authentication server, breaking dependencies) to test if the system fails securely.</p><p><strong>📌 Real World Breaches</strong></p><ul><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2017-12149">CVE-2017–12149 (JBoss Application Server)</a>, improper error handling exposed a vulnerable interface, allowing <strong>unauthenticated remote attackers</strong> to execute arbitrary code.</li><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2020-14750">CVE-2020–14750 (Oracle WebLogic)</a>, an improper failure in input validation during error handling allowed <strong>remote code execution.</strong></li></ul><p><em>Applications should </em><strong><em>fail closed, log appropriately, and avoid revealing sensitive internals</em></strong><em>. A failure should </em><strong><em>not become a new attack vector</em></strong><em>.</em></p><h4>Keep Security Simple</h4><p>Security mechanisms are only effective if they are <strong>understandable, maintainable, and correctly implemented.</strong> Complexity is the enemy of security: the more complicated a system, the more likely developers will make mistakes, overlook controls, or misconfigure settings.</p><p>🔑 <strong>Key Ideas</strong></p><p><strong>Use Standard Libraries &amp; Protocols</strong></p><ul><li>Don’t reinvent cryptography, authentication, or input validation mechanisms.</li><li>Example: Use <strong>AES, libsodium, JWT libraries</strong>, or <strong>OAuth 2.0 / OpenID Connect</strong> instead of custom implementations.</li></ul><p><strong>Avoid Over-Engineering</strong></p><ul><li>Multiple intertwined mechanisms may introduce subtle vulnerabilities.</li><li>Example: Storing passwords with a custom, non-standard hash + salt + encryption layer can create hidden flaws.</li></ul><p><strong>Readable &amp; Maintainable Code</strong></p><ul><li>Clear code ensures security audits, peer reviews, and updates are easier.</li><li>Example: Instead of one 500-line function for validation, break it into small, reusable modules.</li></ul><p><strong>Minimize Dependencies</strong></p><ul><li>Every external library is potential vulnerability. Use only what is necessary and keep them updated.</li></ul><p><strong>📌 Real World Breaches</strong></p><ul><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2019-11043">CVE-2019–11043 (PHP-FPM)</a>, complex URI parsing in Nginx + PHP-FPM led to remote code execution. A simpler, clearly defined URI handling would have reduced attack surface.</li></ul><p><em>Security should be as </em><strong><em>simple as possible but no simpler</em></strong><em>. Complex, hard-to-understand systems increase human error and the likelihood of misconfigurations, while simple, standard, and well-audited designs are more robust.</em></p><h4>Authentication and Authorization</h4><p>Authentication is <em>“who you are” </em>verification (identify check). Authorization is <em>“what you can do”</em> after identity has been verified. Both are fundamental pillars of secure coding.</p><p><strong>Why it matters:</strong></p><ul><li>Mixing up authentication and authorization leads to some of the most critical vulnerabilities (e.g, IDOR — Insecure Direct Object Reference).</li><li>Even if a user is properly authenticated, without strict authorization checks they may access or manipulate resources they shouldn’t.</li><li>Attackers often try to bypass one of these layers, so both need to be implemented properly and independently.</li></ul><p>❌ <strong>Bad Practices</strong></p><ul><li>Treating authentication as enough:</li></ul><pre>// BAD: User is logged in, so we assume they can access any resource<br>if (User.Identity.IsAuthenticated) {<br>    return GetAllUsers(); <br>}</pre><p>Here, any authenticated user can fetch all users without role or permission checkcs.</p><ul><li>Relying solely on frontend checks:</li></ul><pre>// BAD: Hiding &quot;Admin&quot; button on frontend<br>if(user.role !== &quot;admin&quot;) {<br>   document.getElementById(&quot;adminButton&quot;).style.display = &quot;none&quot;;<br>}</pre><p>Attackers can bypass UI restrictions by calling backend APIs directly.</p><p>✅ <strong>Good Practices</strong></p><ul><li>Enforce role-based or attribute-based access control in the backend:</li></ul><pre>// GOOD: Explicitly checking authorization in backend<br>[Authorize(Roles = &quot;Admin&quot;)]<br>public IActionResult GetAllUsers() {<br>    return _userService.GetAll();<br>}</pre><ul><li>Use strong, standard authentication protocols (OAuth 2.0, OpenID Connect, SAML).</li><li>Apply <em>principle of least privilege</em>: users and services should only have permissions they need.</li><li>Implement <em>defense in depth</em>: session management, token expiration, and multi-factor authentication (MFA).</li></ul><p><strong>📌 Real World Breaches</strong></p><ul><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2021-21985">CVE-2021–21985 (VMWare vCenter)</a>, authentication bypass allowed remote attackers to execute arbitrary code.</li><li><a href="https://nvd.nist.gov/vuln/detail/CVE-2017-5638">CVE-2017–5638 (Apache Struts2)</a>, weak input validation combined with poor authentication checks led to the Equifax breach, exposing millions of records.</li></ul><p><em>Authentication proves who you are; authorization defines what you’re allowed to do. Both must be enforced server-side, independent of each other, and aligned with least privilege principles.</em></p><h3>Common Secure Coding Mistakes</h3><h4>Hardcoding Secrets</h4><p><strong>Issue:</strong> Storing API keys, passwords, or certificates directly in code or config files.<br><strong>Why it matters:</strong> If your code is ever leaked, stolen or pushed to a public repository, secrets are immediately compromised.</p><p>❌ <strong>Bad Example</strong></p><pre>string apiKey = &quot;1234567890abcdef&quot;;</pre><p>✅ <strong>Good Example</strong></p><ul><li>Use environment variables, secret managers (AWS Secrets Manager, HashiCorp Vault).</li><li>Never commit secrets to version control.</li></ul><h4>SQL Injection</h4><p><strong>Issue:</strong> Building SQL queries using unsanitized user input. <br><strong>Why it matters: </strong>Attackers can manipulate queries to <strong>read, modify, or delete database records.</strong></p><p>❌ <strong>Bad Example</strong></p><pre>string query = &quot;SELECT * FROM Users WHERE username = &#39;&quot; + userInput + &quot;&#39;&quot;;</pre><p>✅ <strong>Good Example</strong></p><pre>var user = dbContext.Users.Where(u =&gt; u.Username == userInput).FirstOrDefault();</pre><h4>Cross-Site Scripting</h4><p><strong>Issue:</strong> Allowing user input to be rendered in the browser without proper sanitization or encoding.<br><strong>Why it matters:</strong> Attackers can execute scripts in victims’ browsers, steal cookies, perform actions on behalf of users.</p><p>❌ <strong>Bad Example</strong></p><pre>&lt;div&gt;User comment: {{ userInput }}&lt;/div&gt;</pre><p>✅ <strong>Good Example</strong></p><ul><li>Escape output before rendering: @Html.Encode(userInput) or equivalent.</li><li>Use libraries like DOMPurify for sanitization.</li></ul><h4>Insecure Error Handling</h4><p><strong>Issue:</strong> Displaying stack traces, SQL errors, or sensitive system information to users.<br><strong>Why it matters:</strong> Provides attackers with clues the system, making it easier to craft attacks.</p><p>❌ <strong>Bad Example</strong></p><pre>SQL syntax error at line 12: SELECT * FROM Users WHERE username=&#39;...&#39;</pre><p>✅ <strong>Good Example</strong></p><ul><li>Show generic messages to users “An error occurred. Please try again.”</li><li>Log detailed errors securely on the server for developers.</li></ul><h4>Poor Logging Practices</h4><p><strong>Issue:</strong> Logging sensitive information such as passwords, tokens, or PII.<br><strong>Why it matters:</strong> Logs are often accessible to multiple staff, backups, or external services; exposed logs become a <strong>data leak risk</strong>.</p><p>❌ <strong>Bad Example</strong></p><pre>logger.info(&quot;User password: &quot; + password);</pre><p>✅ <strong>Good Example</strong></p><ul><li>Log events without sensitive data.</li><li>Mask or hash any necessary sensitive info in logs.</li></ul><p>These mistakes are common but <strong>entirely preventable</strong>. Following secure coding principles like <strong>input validation, least privilege, fail securely, and simplicity</strong> drastically reduces risk.</p><h3>Tools &amp; Resources for Secure Coding</h3><h4><strong>Static Analysis Tools (SAST)</strong></h4><p>Analyze source code for security flaws without running it. Detects issues like SQL injection, XSS, buffer overflows, and insecure configurations.</p><p><strong>Popular Tools</strong></p><ul><li><strong>SonarQube:</strong> Supports multiple languages, integrates with CI/CD.</li><li><strong>Checkmarx:</strong> Enterprise-grade, strong for complex apps.</li><li><strong>Bandit:</strong> Python-focused security linter.</li><li><strong>Semgrep: </strong>Fast, customizable pattern-based analysis.</li></ul><p><strong>Best Practice:</strong> Integrate into CI/CD pipelines to catch issues early.</p><h4>Dynamic Analysis Tools (DAST)</h4><p>Test running applications for vulnerabilities (e.g, SQLi, XSS, CSRF). Simulates real attacks.</p><p><strong>Popular Tools</strong></p><ul><li><strong>OWASP ZAP:</strong> Open source, automated scanning and fuzzing.</li><li><strong>Burp Suite:</strong> Powerful for manual and automated web app testing.</li><li><strong>Acunetix:</strong> Enterprise web vulnerability scanner.</li></ul><p><strong>Best Practice:</strong> Combine with SAST for full coverage.</p><h4>Dependency &amp; Package Scanners</h4><p>Detect known vulnerabilities in third-party libraries and frameworks.</p><p><strong>Popular Tools</strong></p><ul><li><strong>Snyk:</strong> Monitors NPM, Maven, Python, .NET dependencies.</li><li><strong>Dependabot:</strong> GitHub integration for automatic updates.</li><li><strong>OWASP Dependency-Check:</strong> Free tool for tracking CVEs in dependencies.</li></ul><p><strong>Best Practice:</strong> Regularly scan and update packages to prevent CVE exploitation.</p><h4>Secrets &amp; Configuration Management</h4><p>Safely store API keys, credentials, and config files.</p><p><strong>Popular Tools</strong></p><ul><li><strong>HashiCorp Vault:</strong> Secret storage and dynamic credentials</li><li><strong>AWS Secrets Manager:</strong> Managed secret storage with rotation</li><li><strong>Azure Key Vault:</strong> Centralized secure storage for cloud apps.</li></ul><p><strong>Best Practice:</strong> Never hardcode secrets in code.</p><h4>Fuzzing &amp; Penetration Testing Tools</h4><p>Identify unexpected behaviors and edge-case vulnerabilities.</p><p><strong>Popular Tools</strong></p><ul><li><strong>GoFuzz / Jazzer:</strong> Language-specific for Go or Java.</li><li><strong>Metasploit:</strong> Penetration testing framework for simulating attacks.</li></ul><p><strong>Best Pratice:</strong> Run against critical components, APIs, and authentication flows.</p><h4>Educational &amp; References Resources</h4><ul><li><em>OWASP Top 10</em> — Updated list of top web application risks.</li><li><em>Secure Coding in C/C++</em> by Robert C. Seacord.</li><li><em>The Web Application Hacker’s Handbook</em> — Deep dive into attack/defense patterns.</li></ul><h3>Conclusion</h3><p>Secure coding isn’t about being paranoid; it’s about building resilient, maintainable, and attack-resistant software. By following the core principles we discussed; Input Validation, Least Privilege, Defense in Depth, Fail Securely and Keep Security Simple; you reduce the risk of vulnerabilities while creating systems that are easier to manage and audit.</p><p>Remember: <strong>security is not an afterthought</strong>, it’s part of every design and development decision. Mistakes like SQL injection, XSS, privilege escalation, and insecure error handling often arise from ignoring these principles. CVEs in popular frameworks and platforms remind us that even well-known software is not immune when basic secure coding practices are skipped.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=797f1df94555" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Library Writeup]]></title>
            <link>https://medium.com/@cagritopcu/tryhackme-library-writeup-3aafbd2ec3f0?source=rss-f19a0df32edd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aafbd2ec3f0</guid>
            <dc:creator><![CDATA[Çağrı Topçu]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 23:14:28 GMT</pubDate>
            <atom:updated>2025-08-26T23:22:55.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*4ZXP4tZDBHOzOF1n.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*kz9ciPgrT9NtTHM6Rs8eKg.png" /></figure><h3><strong>Reconnaissance</strong></h3><p>Let’s start with a port scan.</p><pre>nmap -sS -sV &lt;MACHINE-IP&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*VTjtMkHzTMBb-YJjYVvPKw.png" /></figure><p>The scan results show that the <strong>HTTP (80)</strong> and <strong>SSH (22)</strong> ports are open.</p><h3><strong>Enumeration</strong></h3><p>I used the gobuster tool on the HTTP port to perform a directory enumeration.</p><pre>gobuster dir -u &lt;MACHINE-IP&gt; -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*wculiOGzaGi6kD0d308lVg.png" /></figure><p>Other than <strong>robots.txt</strong> and <strong>images</strong>, there is nothing interesting.</p><p>Upon checking <strong>robots.txt</strong>, I found that the User-Agent is set to ‘rockyou’. This could be a useful hint, so I noted it down and continued exploring the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*EF9CVump0G50umjaBUbYlw.png" /></figure><p>After a while, I noticed that a post was shared by a user named ‘meliodas’. This could potentially be the SSH username</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*abMEJ2qYMJA8q7v9LNeVDQ.png" /></figure><p>Based on the hint we found earlier, I attempted a brute-force attack on the user ‘meliodas’ with Hydra using the rockyou wordlist.</p><pre>hydra -l meliodas -P /usr/share/wordlists/rockyou.txt &lt;MACHINE-IP&gt; ssh</pre><p>We obtained the password for the user ‘meliodas’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*3Jh1M7TYIN6UCw3Lmn9rYQ.png" /></figure><p>Using this information, I established an SSH connection.</p><pre>ssh meliodas@&lt;MACHINE-IP&gt;</pre><p>After establishing the connection, I listed the files and obtained our first flag, the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*AU6vzK6FPTvzxkQXuMnI7g.png" /></figure><h3><strong>Privilege Escalation</strong></h3><p>Before attempting to switch to root, I checked the sudo permissions using sudo -l</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*czxvPPq5QjgBBnDFg77aCg.png" /></figure><p>I noticed that I have permission to run the bak.py python file. I checked the script to understand what it does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*8SY9BxIVavp92bP1FfyffA.png" /></figure><p>When I tried to unzip website.zip, I noticed that it was empty. I then checked the permissions of the bak.py file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*2wyAtmQM3oxlvwNwB_xUaQ.png" /></figure><p>I noticed that the file is owned by root. I deleted the file, recreated it, and added code to spawn a root shell.</p><pre>rm -f bak.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*ARmWvA86rNVuNrfx57zygw.png" /></figure><p>I then executed the script and obtained root access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*Gf2igOACySNlqvBl4ARUsA.png" /></figure><p>I navigated to the root directory, listed the files, and obtained the final flag, the root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*r1BcWlYn0Wn790duylP-zA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aafbd2ec3f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>