Skip to content

Instantly share code, notes, and snippets.

@okwrtdsh
Last active June 8, 2018 16:41
Show Gist options
  • Save okwrtdsh/ac58a3caf158ad3d6b8c4bd1cba31e8a to your computer and use it in GitHub Desktop.
Save okwrtdsh/ac58a3caf158ad3d6b8c4bd1cba31e8a to your computer and use it in GitHub Desktop.

ksnctf Programming write-up

http://ksnctf.sweetduet.info/problem/7

  1. 見るからにwhitespaceなので、以前作っていたwhitespaceのdebuggerで実行
  2. PIN:と聞かれる
  3. 1を答えたときのstackの様子を見てみる
$ runkotlin whitespace.kt program.cpp true
S-S-STSTSSSSL # stack push 80
TL-SS # io print char from 80: P
S-S-STSSTSSTL # stack push 73
TL-SS # io print char from 73: I
S-S-STSSTTTSL # stack push 78
TL-SS # io print char from 78: N
S-S-SSTTTSTSL # stack push 58
TL-SS # io print char from 58: :
S-S-SSTSSSSSL # stack push 32
TL-SS # io print char from 32:
S-S-SL # stack push 0
TL-TT # io read number to heap[0]
1
S-S-SL # stack push 0
TT-T # heap stack push from heap[0]
S-S-SSSSSSSTTTTTTTSSTTTTSTTTSSSSSTSSL # stack push 33355524
TS-ST # arithmetic 1 - 33355524
L-TS-TL # flow if stack pop (-33355523) == 0 then jump to label T
S-S-STSSTTTSL # stack push 78
TL-SS # io print char from 78: N
S-S-STSSTTTTL # stack push 79
TL-SS # io print char from 79: O
L-LL # flow exit
  1. 33355524ぽい
  2. flag
$ runkotlin whitespace.kt program.cpp
PIN: 33355524
OK
FLAG_XXXXXXXXXXX

追記

whitespaceのdebuggerをupしました。 whitespace.kt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment