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 1 year has passed since last update.

CpawCTF writeup(2)

Last updated at Posted at 2022-11-02

0 まず

高校1年のもちもちといいます。セキュリティキャンプ2021やCODEBLUE2022に参加してモチベが爆上がりしてるのでCTFの勉強を久しぶりに再開しました。とりあえず2,3日目は初心者向けのCTFであるCpawCTFのLevel 2を進めていきます
前編はこちらからどうぞ

1 隠されたフラグ

左上と右下のモールス信号あるね

https://morse.ariafloat.com/en/
image.png

cpaw{hidden_message:)}

2 Redirect

http://q15.ctf.cpaw.site
にアクセスしたら別サイトにリダイレクトされてしまうので、Burpで挙動を見てみる。HTTP historyのhttp://q15.ctf.cpaw.site
のresponseのRawにフラグが書いてあった
image.png
cpaw{4re_y0u_1ook1ng_http_h3ader?}

3 HTTP Traffic

急に難易度上がった?
とりまpcapをWiresharkでしばく。httpでフィルタリングして全部ダウンロードしてきた。network100(1)に拡張子がついてなかったので調べたらhtmlだったので拡張子変更。ぽちーー

motimotipurinn:/mnt/c/CTFwork$ file 'network100(1)'
network100(1): HTML document, UTF-8 Unicode text

image.png
どうやらだめっぽい。これの通りにファイルの階層構造を変えてみる
image.png
image.png
image.png
cpaw{Y0u_r3st0r3d_7his_p4ge}

4 Can you login?

Wiresharkをしばく。StastisticsでFTPがあることを確認。こいつは暗号化されてないので見れる
「FLAG file exists in this directory.」なるほど
dummyも見てみると
image.png
とあるので、サーバーアドレスも書いてあることだしアクセスしていく。ftpではアクティブモードとパッシブモードの二種類があって今回ではパッシブモードにする必要があるっぽい

motimotipurinn:~$ ftp 118.27.110.77
Connected to 118.27.110.77.
220 Welcome to Cpaw CTF FTP service.
Name (118.27.110.77:motimotipurinn): cpaw_user
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
500 Illegal PORT command.
ftp: bind: Address already in use
ftp> passive
Passive mode on.
ftp> ls
227 Entering Passive Mode (118,27,110,77,234,100).
150 Here comes the directory listing.
-rw-r--r--    1 ftp      ftp            36 Sep 01  2017 dummy
226 Directory send OK.
ftp> get dummy -
remote: dummy
227 Entering Passive Mode (118,27,110,77,234,124).
150 Opening BINARY mode data connection for dummy (36 bytes).
FLAG file exists in this directory.
226 Transfer complete.
36 bytes received in 0.00 secs (1.9073 MB/s)
ftp> ls  -a
227 Entering Passive Mode (118,27,110,77,234,116).
150 Here comes the directory listing.
drwxr-xr-x    2 ftp      ftp            42 Mar 17  2021 .
drwxr-xr-x    2 ftp      ftp            42 Mar 17  2021 ..
-rw-r--r--    1 ftp      ftp            39 Sep 01  2017 .hidden_flag_file
-rw-r--r--    1 ftp      ftp            36 Sep 01  2017 dummy
226 Directory send OK.
ftp> get .hidden_flag_file -
remote: .hidden_flag_file
227 Entering Passive Mode (118,27,110,77,234,117).
150 Opening BINARY mode data connection for .hidden_flag_file (39 bytes).
cpaw{f4p_sh0u1d_b3_us3d_in_3ncryp4i0n}
226 Transfer complete.
39 bytes received in 0.00 secs (2.1878 MB/s)

cpaw{f4p_sh0u1d_b3_us3d_in_3ncryp4i0n}

5 leaf in forest

とりあえずfileコマンド叩いたらpcapファイルだったのでWiresharkに投げたけどエラー出た

motimotipurinn:/mnt/c/Users/user/Downloads$ file misc100
misc100: pcap capture file, microsecond ts (little-endian) - version 0.0 (linktype#1768711542, capture length 1869357413)

catやstringsコマンドで見てみたらオタクの叫び声が聞こえてきたので全部消していく。errors='ignore'入れないとうまく変換できなかった

f=open('/mnt/c/Users/user/Downloads/misc100.txt','r',errors='ignore')
data=f.read()
data=data.replace('love','')
data=data.replace('live!','')
print(data)
f.close()
motimotipurinn:/mnt/c/dev/pydev$ python3 pico.py 
òe!CCCelivPPPoveAAAe!lovWWWve!{{{eliMMMelGGG!livRRRovelEEEPPPe}}}

一応フラグ見えてるけど綺麗にしてみる

import re
f=open('/mnt/c/Users/user/Downloads/misc100.txt','r',errors='ignore')
data=f.read()
data=re.sub('[a-z,!]','',data)
print(data)
f.close()
motimotipurinn:/mnt/c/dev/pydev$ python3 pico.py 
òCCCPPPAAAWWW{{{MMMGGGRRREEEPPP}}}

cpaw{mgrep}

6 Block Cipher

なんとなくイメージ沸いたけど明瞭にするために疑似コード書いた

#include <bits/stdc++.h>
using namespace std;
signed main() {
    int flag_len = 10;
    int key = 3;
    for (int i = key - 1; i <= flag_len; i += key) {
        for (int j = i; j >= i - key + 1; j--) {
            cout << j;
        }
    }
}
motimotipurinn:/mnt/c/dev/cccdev$ ./main
210543876motimotipurinn:/mnt/c/dev/cccdev$ 

ruoYced_ehpigniriks_i_llrg_staeをぐっと睨むとYourでkey=4だとわかる

#include <bits/stdc++.h>
using namespace std;
signed main() {
    string s = "ruoYced_ehpigniriks_i_llrg_stae";
    int key = 4;
    for (int i = 0; i < s.size(); i += key) {
        for (int j = key - 1; j >= 0; j--) {
            if (i + j < s.size()) {
                cout << s[i + j];
            }
        }
    }
}
motimotipurinn:/mnt/c/dev/cccdev$ ./main
Your_deciphering_skill_is_great

cpaw{Your_deciphering_skill_is_great}

7 reversing easy!

motimotipurinn:~$ cd /mnt/c/Users/user/Downloads/
motimotipurinn:/mnt/c/Users/user/Downloads$  file rev100
rev100: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=f94360edd84a940de2b74007d4289705601d618d, not stripped
motimotipurinn:/mnt/c/Users/user/Downloads$ ./rev100
cpaw{}
motimotipurinn:/mnt/c/Users/user/Downloads$ strings rev100
//略
D$L1
D$Fcpawf
D$J{
D$ y
D$$a
D$(k
D$,i
D$0n
D$4i
D$8k
D$<u
D$@!

フラグ見えてもうてるけど一応IDAを見る

image.png
cpaw{yakiniku!}

8 Baby's SQLi - Stage 1-

select* from palloc_home

cpaw{palloc_escape_from_stage1;(}

8 Image!

motimotipurinn:/mnt/c/Users/user/Downloads/misc100$ file mimetype
mimetype: ASCII text, with no line terminators
motimotipurinn:/mnt/c/Users/user/Downloads/misc100$ strings mimetype
application/vnd.oasis.opendocument.graphics

らしいっすのでlibreoffice drawで開いてみる
image.png
実はwordでも開けたらしい
image.png
cpaw{It_is_fun__isn't_it?}

9 Who am I ?

cpaw{parock}

10 あとがき

レベル1と比べて急にCTFやってる!って感じがしてきて面白かったです。最後のレベル3まで一気に駆け抜けたいと思います。そういえばセキュリティキャンプミニキャンプ申し込みやってるので参加してみようかな

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?