kanyewest CTF

勉強したことをメモしています。

Chujowy CTF 2020: Write up

beginner

Insanity1

指定されたIPアドレスとポートにncでつないでみると

$ nc insanity1.chujowyc.tf 4004
Welcome chCTF Sanity Check :D
What is 2+2: ^C
kali@kali:~/chujowyc_CTF_2020/insanity1$ nc insanity1.chujowyc.tf 4004
Welcome chCTF Sanity Check :D
What is 2+2: 4
What number between 0 and 100 am I thinking about right now?

「今、私が考えている0と100の間の数字はなんですか?」と聞かれるので総当りをして81と求めると

% nc insanity1.chujowyc.tf 4004
Welcome chCTF Sanity Check :D
What is 2+2: 4
What number between 0 and 100 am I thinking about right now?
81
xD xD The answer to the next one is in front of your eyes xD xD
What is 2+2:

次の答えは目の前にあると言われてこれもよくわからないので総当りでいこうとしました。

from pwn import *

for i in range(1000,100000):
    p = remote('insanity1.chujowyc.tf',4004)

    p.recvuntil(': ')
    p.sendline('4')
    p.recvuntil('now?')
    p.sendline('81')
    print p.recvuntil(': ')
    p.sendline(str(i))
    ret = p.recvline()
    print "ret[" + str(i) + "]: " + ret
    if not('Invalid answer Bye' in ret):
        break

p.interactive()
$ python solve.py 
[+] Opening connection to insanity1.chujowyc.tf on port 4004: Done

xD xD The answer to the next one is in front of your eyes xD xD
The answer is 42123 ;)                         What is 2+2: 
ret[1000]: Invalid answer Bye

1から1000くらいまで試してたら勝手に答えが出たのでよくわかりません。

$ nc insanity1.chujowyc.tf 4004
Welcome chCTF Sanity Check :D
What is 2+2: 4
What number between 0 and 100 am I thinking about right now?
81
xD xD The answer to the next one is in front of your eyes xD xD
What is 2+2: 42123       
Congratulations the flag is: chCTF{Ez3_cha113ng3}

beginner-web

The return of Insanity1

https://web4.chujowyc.tf/にアクセスします。

f:id:tekashi:20200718032447p:plain

f:id:tekashi:20200718032457p:plain

特になにもないので最初のリンクをよく確認するとflag.phpにアクセスした上でconstruct.phpにリダイレクトされていることがわかります。

f:id:tekashi:20200718032509p:plain

redirectされる前のflag.phpにレスポンスを確認します。

% curl https://web4.chujowyc.tf/flag.php
<html>
    <body>
        chCTF{4nd_Y0U_7H0u9H7_1n54N17y1_w45_4_U53l355_745k}    </body>
</html>

SHA256 Collision

ソースコードが示されていてsha256の衝突する文字列を求めればいいことがわかります。

<html>
    <body>
        <h1> Give me a SHA256 collision and I will give you the flag! </h1>

        <b>Here is the source!</b>

        <?php
            $source = show_source("index.php", true);
            echo("<div>");
            print $source;
            echo("</div>");

            if (isset($_GET['a']) && isset($_GET['b'])) {
                if ($_GET['a'] !== $_GET['b'] && hash("sha256", $_GET['a']) === hash("sha256", $_GET['b'])) {
                    include("flag.php");
                    echo("<h1>Flag: $flag</h1>");
                } else {
                    echo("<h1>Try harder!</h1>");
                }
            } else {
                echo("<h1>Give me your collision plox :P</h1>");
            }
        ?>
    </body>
</html>

適当にGETしてたらflagが出てきました。正直よくわかってません。

https://web5.chujowyc.tf/?a[]=a&b[]=b

f:id:tekashi:20200718032906p:plain

Deployment

f:id:tekashi:20200718033402p:plain

f:id:tekashi:20200718033412p:plain

一見なにもないようにみえますが、画像が置いてあるfilesディレクトリが存在することがわかります。/filesにアクセスするとflagがありました。

f:id:tekashi:20200718033426p:plain

Robot

名前のとおり、/robots.txtをみるだけです。

User-agent: *
Disallow: index.php
Disallow: CQy2Z1k3J7ku7uhQ8uNTagIeLvYg1noA2f4v