見出し画像

AUCFT 2020 write-up

4/3(金) 22:00 〜4/6(月) 13:00(JST)に開催されたAUCTF 2020にソロで参加しました。2396pt取得して全1184チーム中424位でした。

学生向け?の簡単な問題が多くて、50ptの問題は結構解けたのでよかったです。Triviaが9問、Bashが4問、Welcome, Cryptography, Reversingが3問、Sequenceが2問、Forensics, Password Cracking, Pwn, Signalsが1問解けました。

画像2

以下、writeupです。

---------- Sequence ----------

* Pi Day [50pt]

Time to put your problem solving skills to work! Finish the sequence!

14, 15, 92, 65, 35, __, __, __, __, __

円周率の小数部分となっている。

Flag: 89, 79, 32, 38, 46

* Polar Bears [50pt]

Time to put your problem solving skills to work! Finish the sequence!

4, 8, 15, _, _, _

「polar bears 4 8 15」でGoogle検索するとAn Essay from Chuck Klosterman IVという本が検索にヒットした。

Flag: 16, 23, 42

---------- Pwn ----------

* Easy as Pie! [50pt]

My friend just spent hours making this custom shell! He's still working on it so it doesn't have much. But we can do some stuff! He even built a custom access control list for controlling if you can access files.

Check it out!

nc challenges.auctf.com 30010

netcatでアクセスするとPythonで作られたカスタムシェルにログインできる。cat, ls, writeコマンドが使えるようなので、それぞれ確認する。

$ nc challenges.auctf.com 30010
Welcome to my custom shell written in Python! To get started type `help`

user@pyshell$ help

Use help <command> for help on specific command.
================================================
cat  help  ls  write

user@pyshell$ help cat

       View contents of file

user@pyshell$ help ls

       List files in current directory.
       Can type `ls hidden` to view hidden files

user@pyshell$ help write

       write <content> <filename>
       adds content to the beginning of the file.

lsやls hiddenでflag.txtや.flag.txtが存在していることはわかるが、catを使用してもフラグは表示されない。acl.txtでアクセス権を管理しているようなので、writeコマンドを使って.acl.txtにuserのアクセス権を与えたらフラグが表示された。(flag.txtにuser権を与えるとaUctf_{h3y_th3_fl4g}が得られるが、答えではなかった)

user@pyshell$ cat acl.txt
user.txt:user:600
.acl.txt:root:600
.flag.txt:user:600
flag.txt:root:600
acl.txt:root:606


user@pyshell$ write .acl.txt:user:600 acl.txt
.acl.txt:user:600

user@pyshell$ cat .acl.txt
auctf{h4_y0u_g0t_tr0ll3d_welC0m#_t0_pWN_l@nd}

Flag: auctf{h4_y0u_g0t_tr0ll3d_welC0m#_t0_pWN_l@nd}

---------- Reversing ----------

* mobile0 [50pt]

Hey, look its an android file. Can you find the flag?

https://drive.google.com/open?id=1rX6W8xC5VCmzsFLO9r5yPCFKt4LMU5sc

ダウンロードしたバイナリーファイルに対し、stringsコマンドで可読部分を表示させればフラグが出てくる。

$ strings mobile0.apk | grep auctf
auctf{m0b1le_r3v3rs1ng!!}

Flag: auctf{m0b1le_r3v3rs1ng!!}

* mobile1 [50pt]

My friend sent this file to me and said that there was a flag in it. Can you help me?

https://drive.google.com/open?id=1iglx4cQ_iVi1RABBa1eF0OXcOGECjVLy

Googleドライブからmobile1.ipaをダウンロードする。IPAファイルはApple製品のために開発されたプログラムの実行可能ファイル形式のようである。

unzipで解凍して中身を確認するとフラグが書いてあった。

$ unzip mobile.ipa
Archive:  mobile1.ipa
   creating: Payload/
....

$ cd Payload

$ grep -r auctf *
Binary file Base.lproj/Main.storyboadc/BYZ-38-t0r0view-8bc-Xf-vdC.nib maches
Binary file Info.plist matches

$ strings Info.plist | grep auctf
 #auctf {i0s_r3v3rs1ng_1s_1nt3r3st1ng}

Flag: auctf{i0s_r3v3rs1ng_1s_1nt3r3st1ng}

* Cracker Barrel [50pt]

I found a USB drive under the checkers board at cracker barrel. My friends told me not to plug it in but surely nothing bad is on it?

I found this file, but I can't seem to unlock it's secrets. Can you help me out?

Also.. once you think you've got it I think you should try to connect to challenges.auctf.com at port 30000 not sure what that means, but it written on the flash drive..

Flag: auctf{w3lc0m3_to_R3_1021}

---------- Cryptography ----------

* Land Locked [50pt]

Eve found this in one of the packets she sniffed. What does it say?

YXVjdGZ7NExMX3kwVXJfQjQ1M19SX2IzbDBOZ18yX3VTXzEyNGRmMnNkYXN2fQ==

CyberChefでbase64デコードすればフラグとなる。

Flag: auctf{4LL_y0Ur_B453_R_b3l0Ng_2_uS_124df2sdasv}

* I'll Have The Salad [50pt]

Bob and Alice love to go to the local farmer's market to get their groceries. You could call them regulars. They know the farmers so well that they've started sharing secret messages with them. Here's one of the messages they wrote to one lettuce farmer.

vpxoa{eP5o_4_R4mH_pK_1_4421_9952}

CyberChefでシーザー暗号として5文字ずらすとフラグとなる。

Flag: auctf{jU5t_4_W4rM_uP_1_4421_9952}

* Pretty Ridiculous [50pt]

Eve discovered that a piece of paper had been shoved into her pocket.. what could it be? The message she found can be downloaded at the following link:

(n,e) = (627585038806247, 65537)

https://drive.google.com/file/d/17z7C5i_TOx_838QNPbZvNCKW4DcPCaEF/view?usp=sharin

Googleドライブにアクセスすると、暗号文が確認できる。

[145213650433152, 4562349440334, 24272724667960, 598242834066721, 89584939111364, 426756492371444, 511701778613016, 551732685650248, 296367799892003, 63113462897284, 198510931603899, 321201931522255, 401044612595398, 542697603423052, 213898535689643, 275839755798105, 185841409622217, 551732685650248, 121188708737752, 401044612595398, 512808963720303, 275839755798105, 198510931603899, 275839755798105, 401044612595398, 174484844253615, 551732685650248, 174486913717420, 575163265381617, 213898535689643, 401044612595398, 49103824223436, 551732685650248, 401044612595398, 598242834066721, 202722428784490, 306606077829794, 53801100921263, 401044612595398, 184805755675232, 405971446461049, 296367799892003, 275839755798105, 275839755798105, 401044612595398, 358054299396778, 4562349440334, 320837325468842, 401044612595398, 202722428784490, 551732685650248, 321201931522255, 228350651363859]

n, eが与えられているのでRSA暗号であることがわかる。通常はnが大きな数なので素因数分解ができないが、今回はnが627585038806247と小さいので簡単に分解可能である。例えば素因数分解計算機を使うとp×q は13458281×46631887であることがわかる。n, e, p, qがわかれば暗号文を解読できる。以下にPythonのプログラム例を示す。

def egcd(a, b):                                                                                                                                                                                      
   if a == 0:
       return (b, 0, 1)
   else:
       g, y, x = egcd(b % a, a)
       return (g, x - (b // a) * y, y)

def modinv(a, m):
   g, x, y = egcd(a, m)
   if g != 1:
       raise Exception('modular inverse does not exist')
   else:
       return x % m

c = [145213650433152, 4562349440334, 24272724667960, 598242834066721, 89584939111364, 426756492371444, 511701778613016, 551732685650248, 296367799892003, 63113462897284, 198510931603899, 321201931522255, 401044612595398, 542697603423052, 213898535689643, 275839755798105, 185841409622217, 551732685650248, 121188708737752, 401044612595398, 512808963720303, 275839755798105, 198510931603899, 275839755798105, 401044612595398, 174484844253615, 551732685650248, 174486913717420, 575163265381617, 213898535689643, 401044612595398, 49103824223436, 551732685650248, 401044612595398, 598242834066721, 202722428784490, 306606077829794, 53801100921263, 401044612595398, 184805755675232, 405971446461049, 296367799892003, 275839755798105, 275839755798105, 401044612595398, 358054299396778, 4562349440334, 320837325468842, 401044612595398, 202722428784490, 551732685650248, 321201931522255, 228350651363859]
e = 65537
n = 627585038806247
p = 13458281
q = 46631887

phi = (q-1) * (p-1)
d = modinv(e, phi)

flag = ""
for i in c:
   print(chr(pow(i, d, n)), end="")

Flag: auctf{R34lLy_Pr1M3s_w1L1_n3vEr_b3_thI5_Sm411_BuT_h3y}

---------- Forensics ----------

* Har Har Har [50pt]

Someone found this .har file. Can you see what's in it?

.harファイルについてはここを参照。JSON形式の中身を確認すると、画像を受け取った通信を確認できる。

base64でencodeしているとJSONファイル内に書いてあるので、cyberchefでdecodeした結果をダウンロードして、拡張子を.pngファイルにして開くとフラグをゲットできる。

画像2

Flag: auctf{har_har34}

---------- Password Cracking ----------

* Crack Me [50pt]

Here's an easy one.

Hash: 33f966f258879f252d582d45cef37e5e

Hash toolkitで検索するとハッシュを元に戻せる。

Flag: bad4ever

---------- Signals ----------

* FCC Hunter [50pt]

The flag is the frequency used by Auburn University's Tiger Transit system for their radios in each bus. This will also test your OSINT skills.

Flag format: auctf{xxx.xxx} where each "x" is a digit.

RadioReference.comでAubrun UniversityのあるLee County Alabamaで使用されている電波を探したら見つかった。

Flag: auctf{462.025}

---------- Bash ----------

* BASH 1 [50pt]

SSH into the server

ssh challenges.auctf.com -p 30040 -l level1
$ ssh challenges.auctf.com -p 30040 -l level1
$ ls
README
$ head README
auctf{W3lcoM3_2_da_C7F}

Flag: auctf{W3lcoM3_2_da_C7F}

* BASH 2 [50pt]

ssh challenges.auctf.com -p 30040 -l level2

password is the flag of the previous Bash challenge

sshでアクセスしてファイルを確認する。flag.txtがあるが、アクセス権がないため、読むことはできない。

$ ssh challenges.auctf.com -p 30040 -l level2

$ ls -l
total 8
-r--r----- 1 level3 level3  22 Apr  1 21:25 flag.txt
-r-xr-x--- 1 level3 level2 110 Apr  1 21:25 random_dirs.sh

random_dirs.shの中身は以下の通り。

#!/bin/bash

x=$RANDOM

base64 flag.txt > /tmp/$x
function finish {
       rm  /tmp/$x
}
trap finish EXIT

sleep 15

flag.txtを/tmp内にランダムなファイル名で保存するシェルスクリプトになっている。level3ユーザーで実行して、シェルスクリプトが終了する15秒以内に別窓から/tmp内のファイルを確認すれば、base64でエンコードされたフラグが手に入る。

$ sudo -u level3 /home/level2/random_dirs.sh

「YXVjdGZ7ZzB0dEBfbXV2X2Zhczd9Cg==」をデコードすればフラグとなる。

Flag: auctf{g0tt@_muv_fas7}

* BASH 3 [537pt]

ssh challenges.auctf.com -p 30040 -l level3

password is the flag to the previous Bash challenge

今回のファイル構成は以下の通りとなっている。

$ ls -l
total 8
-r--r----- 1 level4 level4  30 Apr  1 21:25 flag.txt
-r-xr-x--- 1 level4 level3 179 Apr  1 21:25 passcodes.sh

passcodes.shの中身は以下の通り。

#!/bin/bash
x=$RANDOM
echo "Input the random number."
read input
if [[ "$input" -eq "$x" ]]
then
       echo "AWESOME sauce"
       cat flag.txt
else
       echo "$input"
       echo "$x try again"
fi

入力を受け取って、その値とランダムに生成した数字が一致していればflag.txtが表示されるようになっている。RANDOMは0~32767を返すので、適当にやっても一致することはほぼない。

forループを利用して1000回試行し、RANDOMの値が12345となるまで繰り返し何度も試してみると、運が良かったのか数回目でフラグをゲットできた。

 $ for i in `seq 1 1000`; do echo "12345" | sudo -u level4 /home/level3/passcodes.sh; done

Flag: auctf{wut_r_d33z_RaNdom_numz}

* BASH 4 [561pt]

ssh challenges.auctf.com -p 30040 -l level4

ファイル構成は以下の通り。

$ ls -l
total 8
-r--r----- 1 level5 level5  25 Apr  1 21:25 flag.txt
-r-xr-x--- 1 level5 level4 209 Apr  1 21:25 print_file.sh

print_file.shは以下の通り。

#!/bin/bash
if [ ! -z "$@" ]
then
       cat $@ # 2>/dev/null
       # if [ ! $? -eq 0 ]
       # then
       #       echo "Printing error. Check file permissions"
       # fi
else
       echo "Please enter a file."
       echo "./print_file FILENAME"
fi

普通に実行したらフラグが表示された。

$ sudo -u level5 ./print_file.sh flag.txt
auctf{FunKy_P3rm1ssi0nZ}

Flag: auctf{FunKy_P3rm1ssi0nZ}

---------- Trivia ----------

* Password 1 [50pt]

A more secure way to hashing a password involves appending this to the password before the hashing is done.

Flag: salt

* Networking 1 [50pt]

What is Layer 7 of the OSI Model?

Flag: application

* Networking 2 [50pt]

What protocol dynamically allocates IP Addresses?

Flag: DHCP

* Networking 3 [50pt]

What type of packet does ping use?

Flag: ICMP

* Networking 4 [50pt]

What is the range of usable IP addresses with the following: 110.24.52.32/19

Flag: 110.24.32.1 - 110.24.63.254

* Pwn [50pt]

What is a countermeasure used to prevent return oriented programming?

Flag: ASLR

* Pwn 2 [50pt]

What are the pieces of a rop chain called?

Flag: gadgets

* Reversing 2 [50pt]

What is the deliberate act of trying to make code unreadable by a human in order to prevent tampering and to help ensure security?

Flag: Obfuscation

* Web 1 [50pt]

These properties are important to guarantee valid transactions within a database?

Flag: Atomicity, Consistency, Isolation, Durability

この記事が気に入ったらサポートをしてみませんか?