<?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: Shobhit saini</title>
    <description>The latest articles on DEV Community by Shobhit saini (@shobhit_saini_0057eac2ab4).</description>
    <link>https://dev.to/shobhit_saini_0057eac2ab4</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4208253%2F9e8927c8-7e53-40b3-bdff-275c2af2c3ae.jpg</url>
      <title>DEV Community: Shobhit saini</title>
      <link>https://dev.to/shobhit_saini_0057eac2ab4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shobhit_saini_0057eac2ab4"/>
    <language>en</language>
    <item>
      <title>Casino (Medium) — Hack Smarter World walkthrough</title>
      <dc:creator>Shobhit saini</dc:creator>
      <pubDate>Mon, 26 Oct 2026 09:24:16 +0000</pubDate>
      <link>https://dev.to/shobhit_saini_0057eac2ab4/casino-medium-hack-smarter-world-walkthrough-2p01</link>
      <guid>https://dev.to/shobhit_saini_0057eac2ab4/casino-medium-hack-smarter-world-walkthrough-2p01</guid>
      <description>&lt;h1&gt;
  
  
  Casino (Medium) — From Source Map to Root 🎰 | Hack Smarter World
&lt;/h1&gt;

&lt;p&gt;Sometimes you start testing a login page expecting SQL injection, and end up finding something completely different. 😂&lt;/p&gt;

&lt;p&gt;This is my walkthrough of &lt;strong&gt;Casino (Medium)&lt;/strong&gt;, a Web and Linux challenge on Hack Smarter World. The objective was to identify vulnerabilities in a resort's guest Wi-Fi portal and escalate privileges to root.&lt;/p&gt;

&lt;p&gt;The journey involved a forgotten JavaScript source map, an exposed API, Server-Side Template Injection (SSTI), SSH key exposure, credentials in Bash history, and finally, a root password sitting in a log file.&lt;/p&gt;

&lt;p&gt;Let's get into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Port Scanning with Nmap
&lt;/h2&gt;

&lt;p&gt;I started with an Nmap scan to identify the open ports and running services.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmap &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &amp;lt;TARGET_IP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The interesting results were:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.18
80/tcp   open  http    Werkzeug httpd 3.1.8 (Python 3.10.18)
2222/tcp open  ssh     OpenSSH 8.4p1 Debian 5+deb11u7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three open ports, two SSH services, and a Python-based web application. Port 80 looked like the obvious starting point, so I opened the website and started exploring.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. SQL Injection? Not Today.
&lt;/h2&gt;

&lt;p&gt;The website presented a guest Wi-Fi login page asking for a room number and last name.&lt;/p&gt;

&lt;p&gt;My first thought was SQL injection. I tried a few basic payloads against the &lt;code&gt;last_name&lt;/code&gt; parameter:&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 &lt;span class="s2"&gt;"http://&amp;lt;TARGET_IP&amp;gt;/login"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"room_number=101&amp;amp;last_name='"&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt;

curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="s2"&gt;"http://&amp;lt;TARGET_IP&amp;gt;/login"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"room_number=101&amp;amp;last_name=xyz' OR '1'='1"&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt;

curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="s2"&gt;"http://&amp;lt;TARGET_IP&amp;gt;/login"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"room_number=101&amp;amp;last_name=xyz' UNION SELECT 1,2,3-- -"&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every request returned the same authentication failure.&lt;/p&gt;

&lt;p&gt;I also tried an injection payload against the room number, but the application returned an invalid-format message.&lt;/p&gt;

&lt;p&gt;No useful behavior, no SQL errors, and no login bypass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Don't get emotionally attached to a vulnerability just because it looks promising. The login form wasn't cooperating, so I moved on.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Finding the JavaScript Source Map
&lt;/h2&gt;

&lt;p&gt;While inspecting the login page's source, I noticed this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/static/js/app.min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I opened the JavaScript file and found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;initPortal&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hack Smarter World WiFi Gateway Active&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;DOMContentLoaded&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;initPortal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//# sourceMappingURL=app.min.js.map&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last line caught my attention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//# sourceMappingURL=app.min.js.map
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A source map can reveal the original source code behind minified JavaScript. Naturally, I checked whether it was publicly accessible.&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;-s&lt;/span&gt; http://&amp;lt;TARGET_IP&amp;gt;/static/js/app.min.js.map
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response contained:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"app.min.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src/api/roomVerification.js"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sourcesContent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"// Front-Desk Kiosk API verification helper&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;async function checkRoomStatus(roomNum) {&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; const res = await fetch('/api/v1/rooms/status?status=occupied');&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; return await res.json();&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;}"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there it was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/api/v1/rooms/status?status=occupied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A previously undiscovered API endpoint. Time to investigate. 👀&lt;/p&gt;

&lt;h2&gt;
  
  
  4. An Unauthenticated API
&lt;/h2&gt;

&lt;p&gt;I visited the endpoint:&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;-s&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s2"&gt;"http://&amp;lt;TARGET_IP&amp;gt;/api/v1/rooms/status?status=occupied"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response contained multiple guest records, including room numbers, names, and checkout dates.&lt;/p&gt;

&lt;p&gt;The interesting part? The endpoint didn't require authentication.&lt;/p&gt;

&lt;p&gt;The login page was asking for guest details while another endpoint was exposing them. That's one way to make authentication unnecessarily difficult for legitimate users and unnecessarily easy for attackers. 😅&lt;/p&gt;

&lt;p&gt;I examined the checkout dates to identify active reservations and used a valid room-number-and-last-name combination from the lab to log in.&lt;/p&gt;

&lt;p&gt;The application issued a session cookie and redirected me to the dashboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login bypass achieved.&lt;/strong&gt; No SQL injection required.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. SSTI — The Profile Field Was the Next Clue
&lt;/h2&gt;

&lt;p&gt;Once inside the dashboard, I found an edit-profile option where I could change my preferred name.&lt;/p&gt;

&lt;p&gt;The application was running Flask and Werkzeug, so I decided to test the field for Server-Side Template Injection.&lt;/p&gt;

&lt;p&gt;I started with the classic payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{7*7}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application returned:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then I tried:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{7*'7'}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result was:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This behavior is consistent with Jinja2, which uses Python expression semantics for these operations.&lt;/p&gt;

&lt;p&gt;The field wasn't simply displaying my input—it was evaluating it as a template expression.&lt;/p&gt;

&lt;p&gt;A preferred-name field should display your name, not start doing your maths homework. 😂&lt;/p&gt;

&lt;h2&gt;
  
  
  6. From SSTI to a Shell
&lt;/h2&gt;

&lt;p&gt;The successful template-expression tests suggested SSTI. Further testing in the lab confirmed that the vulnerability could be escalated to operating-system command execution.&lt;/p&gt;

&lt;p&gt;I obtained a shell as:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This gave me an initial foothold on the system.&lt;/p&gt;

&lt;p&gt;The important point is that SSTI can become a serious vulnerability when untrusted input is interpreted as template code. In this case, the impact went beyond evaluating arithmetic expressions.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Finding George's SSH Private Key
&lt;/h2&gt;

&lt;p&gt;With access as &lt;code&gt;www-data&lt;/code&gt;, I began examining the filesystem and looking for files that the compromised account could read.&lt;/p&gt;

&lt;p&gt;Inside George's home directory, I found SSH key material:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/george/.ssh/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I checked the directory permissions and found that the private key, &lt;code&gt;id_rsa&lt;/code&gt;, was readable by other users.&lt;/p&gt;

&lt;p&gt;Its permissions were effectively &lt;code&gt;644&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw-r--r-- 1 george george ... id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A private key that everyone can read isn't very private anymore. 💀&lt;/p&gt;

&lt;p&gt;I copied the key, restricted its permissions locally, and used it to connect through SSH on port 2222:&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;chmod &lt;/span&gt;600 george_id_rsa

ssh &lt;span class="nt"&gt;-i&lt;/span&gt; george_id_rsa george@&amp;lt;TARGET_IP&amp;gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The connection succeeded, giving me access as George.&lt;/p&gt;

&lt;p&gt;One careless file-permission setting had turned a low-privileged web-server compromise into another user's shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. George to David — Bash History to the Rescue
&lt;/h2&gt;

&lt;p&gt;Next, I checked George's privileges:&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;sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No useful sudo access.&lt;/p&gt;

&lt;p&gt;So I moved on to shell history:&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; ~/.bash_history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Among the commands, I found a sequence involving a switch to the &lt;code&gt;david&lt;/code&gt; account and a database connection.&lt;/p&gt;

&lt;p&gt;The problem was that a password had been typed directly into the shell instead of being entered at the interactive password prompt.&lt;/p&gt;

&lt;p&gt;That meant the credential was sitting in Bash history in plaintext.&lt;/p&gt;

&lt;p&gt;There was also an attempt to clear the history:&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;history&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, clearing the current in-memory history doesn't guarantee that previously written history files or other session records are erased.&lt;/p&gt;

&lt;p&gt;I used the recovered credential in the lab to switch to David.&lt;/p&gt;

&lt;p&gt;Another account, another step forward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; Shell history is great for remembering commands, but terrible as a place to store passwords.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. David to Root — The Provisioning Log
&lt;/h2&gt;

&lt;p&gt;As David, I checked sudo privileges again:&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;sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No direct route to root.&lt;/p&gt;

&lt;p&gt;However, I noticed that David belonged to the &lt;code&gt;adm&lt;/code&gt; group. On many Linux systems, this group can read certain system logs.&lt;/p&gt;

&lt;p&gt;I inspected &lt;code&gt;/var/log&lt;/code&gt; and found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/log/provisioning.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file permissions showed that it was owned by &lt;code&gt;root:adm&lt;/code&gt; and readable by the group.&lt;/p&gt;

&lt;p&gt;I opened 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;cat&lt;/span&gt; /var/log/provisioning.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The log contained a root password in plaintext.&lt;/p&gt;

&lt;p&gt;At this point, the system had essentially left the final key in a file that my current user was allowed to read. Not exactly Fort Knox. 😂&lt;/p&gt;

&lt;p&gt;I used the recovered credential through the lab's local authentication mechanism and checked my privileges:&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;id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output confirmed root access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uid=0(root) gid=0(root) groups=0(root)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Root obtained!&lt;/strong&gt; 🎯&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Attack Chain Summary
&lt;/h2&gt;

&lt;p&gt;Here's the entire path in one place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nmap identified the available services.&lt;/li&gt;
&lt;li&gt;SQL injection attempts against the login form failed.&lt;/li&gt;
&lt;li&gt;The JavaScript source map revealed an undocumented API endpoint.&lt;/li&gt;
&lt;li&gt;The unauthenticated API exposed guest information.&lt;/li&gt;
&lt;li&gt;A valid guest record enabled login to the portal.&lt;/li&gt;
&lt;li&gt;SSTI in the profile field led to command execution as &lt;code&gt;www-data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A world-readable SSH private key enabled access as George.&lt;/li&gt;
&lt;li&gt;George's Bash history exposed David's credentials.&lt;/li&gt;
&lt;li&gt;David's &lt;code&gt;adm&lt;/code&gt; group membership allowed reading a provisioning log.&lt;/li&gt;
&lt;li&gt;The log exposed a root credential, leading to root access.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  11. What Could Have Prevented This?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source maps:&lt;/strong&gt; Avoid exposing sensitive implementation details in production source maps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API security:&lt;/strong&gt; Enforce authentication and authorization on every sensitive endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSTI:&lt;/strong&gt; Never treat user-controlled input as template source code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSH keys:&lt;/strong&gt; Restrict private keys to their intended owners.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bash history:&lt;/strong&gt; Avoid entering passwords directly into shell commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logs:&lt;/strong&gt; Never write reusable credentials into application or provisioning logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Least privilege:&lt;/strong&gt; Restrict access to user directories and sensitive log files.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Casino was a good reminder that penetration testing isn't just about running tools and firing payloads at a login form.&lt;/p&gt;

&lt;p&gt;My first instinct was SQL injection, but the real route started with a forgotten source map. That led to an exposed API, then SSTI, and eventually a chain of local privilege-escalation mistakes.&lt;/p&gt;

&lt;p&gt;The same problem kept appearing in different forms: sensitive information was accessible where it shouldn't have been.&lt;/p&gt;

&lt;p&gt;A source map exposed an API. A private key was readable by other users. A password survived in shell history. A root credential ended up in a log file.&lt;/p&gt;

&lt;p&gt;Different mistakes, same result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sometimes you don't need a fancy exploit when the target is already leaking the keys to the kingdom.&lt;/strong&gt; 😂&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/@vulnmachines/server-side-template-injection-write-up-vulnmachines-6e3eed2a44d1" rel="noopener noreferrer"&gt;SSTI Write-up — VulnMachines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hacktricks.wiki/en/pentesting-web/ssti-server-side-template-injection/index.html?highlight=SSTI#jinja2-python" rel="noopener noreferrer"&gt;HackTricks — Server-Side Template Injection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Server%20Side%20Template%20Injection/Python.md#mako---remote-command-execution" rel="noopener noreferrer"&gt;PayloadsAllTheThings — Server-Side Template Injection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kleiber.me/blog/2021/10/31/python-flask-jinja2-ssti-example/" rel="noopener noreferrer"&gt;Flask/Jinja2 SSTI Example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  CyberSecurity #CTF #HackSmarter #Writeup #PenetrationTesting #Linux #SSTI #Jinja2 #PrivilegeEscalation
&lt;/h1&gt;

</description>
      <category>cybersecurity</category>
      <category>python</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
