0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NITIC CTF 2 write up

Posted at

 始めにお礼から、茨城高専の有志の皆様今回はとても楽しいctfコンテストの開催ありがとうございました!。
 今大会はチームjyokenで参加し結果は66位でした。cryptoぐらいしかまともに解けなかったのですがせっかくなのでwrite upを書いてみようと思います(write up書くのは初めてなので見づらい所あったらすみませんm(__)m)。

pwn monster 1

pwn monsterが完成しました!ライバルのpwnchuは最強で、バグ技を使わない限りは勝てないでしょう。

nc 35.200.120.35 9001

たくさん文字を入力すると自分のHPとATKが改ざんされてflagが出ます。

pond@pond-virtualbox:~/ctf/nitic/tanitu_kanji$ nc 35.200.120.35 9001
 ____                 __  __                 _            
|  _ \__      ___ __ |  \/  | ___  _ __  ___| |_ ___ _ __ 
| |_) \ \ /\ / / '_ \| |\/| |/ _ \| '_ \/ __| __/ _ \ '__|
|  __/ \ V  V /| | | | |  | | (_) | | | \__ \ ||  __/ |   
|_|     \_/\_/ |_| |_|_|  |_|\___/|_| |_|___/\__\___|_|   
                        Press Any Key                            


Welcome to Pwn Monster World!
aa
I'll give your first monster!
Let's give your monster a name!
+--------+--------------------+----------------------+
|name    | 0x0000000000000000 |                      |
|        | 0x0000000000000000 |                      |
|HP      | 0x0000000000000064 |                  100 |
|ATK     | 0x000000000000000a |                   10 |
+--------+--------------------+----------------------+
Input name: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+--------+--------------------+----------------------+
|name    | 0x6161616161616161 |             aaaaaaaa |
|        | 0x6161616161616161 |             aaaaaaaa |
|HP      | 0x6161616161616161 |  7016996765293437281 |
|ATK     | 0x6161616161616161 |  7016996765293437281 |
+--------+--------------------+----------------------+
OK, Nice name.

Let's battle with Rival! If you win, give you FLAG.

[You] aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaapwnchu HP: 7016996765293437281
[Rival] pwnchu HP: 9999
Your Turn.

Rival monster took 7016996765293437281 damage!


[You] aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaapwnchu HP: 7016996765293437281
[Rival] pwnchu HP: -7016996765293427282
Win!

nitic_ctf{We1c0me_t0_pwn_w0r1d!}

*** stack smashing detected ***: terminated

nitic_ctf{We1c0me_t0_pwn_w0r1d!}

Excel

問題文Excelファイルのあるセルにフラグが書かれています!見つけて下さい!

U列869行目にflagがありましたCtrlと矢印キーを使いながら探すと探しやすいです。

nitic_ctf{plz_find_me}

image_conv

after_flag.pngというファイルが渡されました。flagがうっすら見えていてそれがそのまま答えです。(コントラストとかいじったら見やすくなるのかな?)
after_flag.png

nitic_ctf{high_contrast}

protected

問題文:パスワードでフラグを保護すれば安全!

challというバイナリファイルが配布されました。stringsしてみるとPASSWORDの後ろに怪しげな文字列があったのでそれを入力するとフラグが出てきました。

pond@pond-virtualbox:~/ctf/nitic/protected/protected$ strings chall 
/lib64/ld-linux-x86-64.so.2
libc.so.6
__isoc99_scanf
puts
__stack_chk_fail
printf
strlen
malloc
__cxa_finalize
strcmp
__libc_start_main
GLIBC_2.7
GLIBC_2.4
GLIBC_2.2.5
_ITM_deregisterTMCloneTable
__gmon_start__
_ITM_registerTMCloneTable
u+UH
ATSH
0[A\]
[]A\A]A^A_
PASSWORD: 
sUp3r_s3Cr37_P4s5w0Rd
Invalid password.
:*3$"
GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
crtstuff.c
deregister_tm_clones
__do_global_dtors_aux
completed.8060
__do_global_dtors_aux_fini_array_entry
frame_dummy
__frame_dummy_init_array_entry
main.c
__FRAME_END__
__init_array_end
_DYNAMIC
__init_array_start
__GNU_EH_FRAME_HDR
_GLOBAL_OFFSET_TABLE_
__libc_csu_fini
_ITM_deregisterTMCloneTable
puts@@GLIBC_2.2.5
_edata
strlen@@GLIBC_2.2.5
__stack_chk_fail@@GLIBC_2.4
printf@@GLIBC_2.2.5
__libc_start_main@@GLIBC_2.2.5
__data_start
strcmp@@GLIBC_2.2.5
__gmon_start__
__dso_handle
_IO_stdin_used
__libc_csu_init
malloc@@GLIBC_2.2.5
__bss_start
main
__isoc99_scanf@@GLIBC_2.7
__TMC_END__
_ITM_registerTMCloneTable
swap
__cxa_finalize@@GLIBC_2.2.5
.symtab
.strtab
.shstrtab
.interp
.note.gnu.property
.note.gnu.build-id
.note.ABI-tag
.gnu.hash
.dynsym
.dynstr
.gnu.version
.gnu.version_r
.rela.dyn
.rela.plt
.init
.plt.got
.plt.sec
.text
.fini
.rodata
.eh_frame_hdr
.eh_frame
.init_array
.fini_array
.dynamic
.data
.bss
.comment
pond@pond-virtualbox:~/ctf/nitic/protected/protected$ ./chall
PASSWORD: sUp3r_s3Cr37_P4s5w0Rd
nitic_ctf{hardcode_secret}

Caesar Cipher

問題文:フラグの中身がシーザー暗号で暗号化されています。 暗号化されたフラグの中身はfdhvduです。
nitic_ctf{復号したフラグの中身}
を提出してください

シーザー暗号ですね。CyberChefで23文字ずらしたら答えっぽい文になりました。

nitic_ctf{caesar}

ord_xor

flagを暗号化するときに使ったコードと暗号化されたflagが配布されました。

enc_sample.py
import os
flag = os.environ["FLAG"]


def xor(c: str, n: int) -> str:
    temp = ord(c)
    for _ in range(n):
        temp ^= n
    return chr(temp)


enc_flag = ""
for i in range(len(flag)):
    enc_flag += xor(flag[i], i)

with open("./flag", "w") as f:
    f.write(enc_flag)
flag
nhtjcZcsfroydRx`rl

flagの文字と添字をxorしているので同じようにenc_flagと添字をxorしてあげるとflagが復号されます。(a^b=c, b^c=aより)

solve.py
enc_flag = 'nhtjcZcsfroydRx`rl'

def xor(c: str, n: int) -> str:
    temp = ord(c)
    for _ in range(n):
        temp ^= n
    return chr(temp)


flag = ""
for i in range(len(enc_flag)):
    flag += xor(enc_flag[i], i)

print(flag)

nitic_ctf{ord_xor}

tanitu_kanji

 flagを暗号化するときに使ったコードと暗号化されたflagが配布されました。

enc_sample.py
import os
alphabets = "abcdefghijklmnopqrstuvwxyz0123456789{}_"
after1 = "fl38ztrx6q027k9e5su}dwp{o_bynhm14aicjgv"
after2 = "rho5b3k17pi_eytm2f94ujxsdvgcwl{}a086znq"

format = os.environ["FORMAT"]
flag = os.environ["FLAG"]

assert len(format) == 10


def conv(s: str, table: str) -> str:
    res = ""
    for c in s:
        i = alphabets.index(c)
        res += table[i]
    return res


for f in format:
    if f == "1":
        flag = conv(flag, after1)
    else:
        flag = conv(flag, after2)

with open("./flag", "w") as file:
    file.write(flag)
flag
l0d0pipdave0dia244im6fsp8x

 enc_sample.pyのconv()の中ではstrに入っている文字がalphabets文字列の中で何番目にあるのかを見てその番号をiに代入、返り値にtableのi番目に入っている文字を返します。最終的に暗号化されたflagはformatの形に依存します。
 formatの長さは10文字とわかっているので、formatには2進数で10桁の数値を2の10乗(1024)回総当たりで入れてあげるとどこかでflagが復号されます。

solve.py
alphabets = "abcdefghijklmnopqrstuvwxyz0123456789{}_"
after1 = "fl38ztrx6q027k9e5su}dwp{o_bynhm14aicjgv"
after2 = "rho5b3k17pi_eytm2f94ujxsdvgcwl{}a086znq"
enc = 'l0d0pipdave0dia244im6fsp8x'


def conv(s: str, table: str) -> str:
    res = ""
    for c in s:
        i = table.index(c)
        res += alphabets[i]
    return res


for i in range(1024):
    x = format(i, 'b')
    for f in x:
        if f  == "1":
            enc = conv(enc, after1)
        else:
            enc = conv(enc, after2)
    if(enc[0]=="n"):
        print(enc)
    enc = 'l0d0pipdave0dia244im6fsp8x'

nitic_ctf{bit_full_search}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?