tkbctf3 Write-up
Misc 100 Real World TeX
こんな感じの謎のtexファイル。16進数を文字に直し、^^やKKを削除し、ZVHNをそれぞれ\スペース{}に置換とするとtexっぽくなるけど、IやGをどう処理して良いのか分からなかった。
^^5c^^66^^75^^74^^75^^72^^65^^6c^^65^^74^^7e ^^5c^^63^^61^^74^^63^^6f^^64^^65^^60K7 KK5cKK65KK6eKK64KK6cKK69KK6eKK65KK63KK68KK61KK72- KK5cKK73KK74KK72KK69KK6eKK67KK60 KK7eKK60I13KK7eKK60G10KK5cKK6cKK65KK74 IKK7eI86G10I83G7I72G1I90V0I78V2I80G6I82G5
Crypto 200 The Deal
520.421.926.48.56.914.402.585.81.824.826.115.515.472.522.397.116.789.415.525.…
こんな感じの暗号分と、暗号化するウェブサイトが与えられる。暗号化するウェブサイトで色々試すと、平文の各文字の文字コードに鍵から算出される値を足して、941 → 520.421のように2個の値に分ける暗号化だと分かる。
2個ずつ足し合わせて、
520.421.926.48.56.914.402.585.81.824.826.115.515.472.522.397.116.789.415.525.…
↓
941.974.970.987.905.941.987.919.905.940.…
あとは「鍵から算出される値」を全探索すれば良い。873だった。
↓
Dear Dr. C…
FreePizza!ComeAndGetIt
Binary 300 Penalty
ブートセクタ。ブートセクタのイメージは0x7c00に読み込まれる。またプログラムがINTnを実行したときは、4n番地の関数が、スタックにINTnの次のアドレスが積まれた状態で呼び出される。このプログラムは、0x000cを0x88に書き換え、INT3を使って難読化をしている。
00000088 5D pop bp 00000089 4D dec bp 0000008A 837600AA xor word [bp+0x0],byte -0x56 0000008E 55 push bp 0000008F CF iretw
INT3と次の命令をそれぞれ0xaaと0xffでxorしている。次の命令がxor 0xffされることに気が付かず、時間が掛かった。入力された文字列をecxに読み込み、チェックしているので、ecxを全探索する。
#include <stdio.h> unsigned int rol(unsigned int n, unsigned int s){return n<<s|n>>(32-s);} bool check(unsigned int ecx) { unsigned int esi, edi, edx, ebx, eax; esi=0xd76aa478; edi=0xfffa3942; edx=ecx; edx=rol(edx,16); // 11c edi^=esi; // 120 ebx=edi; ebx+=ecx; eax=ebx; ebx=rol(ebx,1); ebx+=eax; ebx-=1; eax=ebx; ebx=rol(ebx,4); ebx^=eax; esi^=ebx; // 141 ebx=esi; ebx+=edx; eax=ebx; ebx=rol(ebx,2); ebx+=eax; ebx+=1; eax=ebx; ebx=rol(ebx,8); ebx^=eax; ebx+=ecx; eax=ebx; ebx=rol(ebx,1); ebx-=eax; eax=ebx; eax|=esi; ebx=rol(ebx,16); ebx^=eax; edi^=ebx; // 17c ebx=edi; ebx+=edx; eax+=ebx; ebx=rol(ebx,2); ebx+=eax; ebx+=1; esi^=ebx; //return esi==0x639fd029 && edi==0x2a5891ff; return esi==0x639fd029 || edi==0x2a5891ff; } int main() { for (unsigned int i=0; i<0xffffffff; i++) if (check(i)) printf("%08x\n", i); }
checkの最後の条件はANDだが、どこかで写し間違えたのかesiが正しい値にならなかった。ORでも答えは1個しか出てこない。ecx=0x3108202dでチェックが通ることが分かる。0x31, 0x08, 0x20, 0x2dをキーボードのスキャンコードから探す。
N7DX
Web 103 From the Northern Country
指定されたページに北朝鮮からアクセスしろという問題。北朝鮮のプロキシなんて見つからなかったけど、逆で北朝鮮の人が私を経由してアクセスしていると装えば良い。X-Forwarded-Forヘッダ。
nc north.tkbctf.info 80 GET / HTTP/1.1 Host: north.tkbctf.info X-Forwarded-For: 175.45.176.0 HTTP/1.1 200 OK Server: nginx/1.6.0 Date: Sun, 04 May 2014 09:06:12 GMT Content-Type: text/plain Content-Length: 21 Last-Modified: Sat, 03 May 2014 22:13:55 GMT Connection: keep-alive ETag: "53656a23-15" Accept-Ranges: bytes KEY{공격전이다}
キーが実体参照になっているのは、はてなのスーパーpre記法のせい。北朝鮮の曲名らしい。
攻撃戦だ - Wikipedia
공격전이다
Misc 250 15-Puzzle
15パズルを解く。Stage nではn問出題される。真面目にソルバーを書こうとすると面倒なので、ここで公開されているプログラムをちょっと弄って、引数で盤面を受け取り、標準出力に答えを出すようにした。あとはPythonで。
import socket import subprocess import time s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("203.178.132.117", 3939)) print s.recv(0x10000) #15-Puzzle ~ for i in range(100): for j in range(i+1): time.sleep(1) B = s.recv(0x10000) print "<",B,">" if len(B.split()[-16:])!=16: print "Error" exit(-1) cmd = "solve.exe "+" ".join(B.split()[-16:]) print "cmd:",cmd p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) ans = p.stdout.read() print "ans:",ans s.send(ans+"\n") print s.recv(0x10000) # Stage n cleared.
何故か間違っていると言われることがあるけど、何回か試したらフラグが手に入った。
Welcome. We are the fafrotskies. Your answers must be terminated by an empty line, don't forget! ===== 15-Puzzle ===== Solve 15-Puzzle! The four lines make one set of input. Zero denotes the missing tile. If the input puzzle is solvable then print the number of the shortest steps to s olve the puzzle. If the puzzle is not solvable then print the line "NO". < Stage #1 Enjoy! #1 1 2 4 0 5 10 3 8 9 7 6 12 13 14 11 15 > cmd: solve.exe 1 2 4 0 5 10 3 8 9 7 6 12 13 14 11 15 ans: 9 Stage 1 cleared. < Stage #2 The 2nd stage! #1 1 2 7 3 : : 9 11 12 8 13 14 7 15 > cmd: solve.exe 5 0 3 10 2 1 4 6 9 11 12 8 13 14 7 15 ans: 29 Complete! Flag is FLAG{N0_R4M3N_N0_L1F3!!} < > Error
N0_R4M3N_N0_L1F3!!
Binary 500 game
SSHのIDとパスワードが与えられて、アクセスするとsuidされたゲームが置いてある。クイズと神経衰弱。クイズの最後にフラグがメモリ上に読み込まれる。神経衰弱は0<=x<13 && 0<=y<4とチェックすべきところ、0<=x<13 && 0<=y<13とチェックしているので、範囲外のメモリがちょっと読める。うまいことメモリのレイアウトを調節するらしいけど、解けなかった。
クイズの回答。
HAL sang this song Daisy Bell 'To be or not to be, that is the question' Hamlet Appolo 11 landed in this site ???????????????? Trinity set this as root password Z1ON0101 The name of this city is used as the codename of Windows 95 Chicago The first 10 digits of pi (X in 3.XXXXXXXXXX) 1415926535 The most accurate mass in the following for LD50 of caffeine in humans per kilogram of body mass; 50mg, 200mg, 300mg, 500mg and 700mg 200mg One definition of this is entering a private place with the intent of listeningsecretly to private conversation eavesdropping With much "Gravity", this young fellow of Trinity became the Lucasian Professorof Mathematics in 1669 Isaac Newton It's New Zealand's second-largest city Christchurch
アポロ11号の問題は答えが分からなかった。静かの海だと思うけど、Tranquillitatisでは1文字足りない。脆弱性で答えが盗めた問題もあるけど、アポロ11号は出てこなかった(´・ω・`)
Web 250 miocat
指定されたサイトにアクセスすると、URLを入力するフォームがあった。何かサーバーが外にアクセスできないような挙動をしていて、後回しにしていたら、皆解いていた。
http://../../../etc/passwd
で、/etc/passwdが読める。
: syslog:x:102:105::/home/syslog:/bin/false miocat:x:1001:1001:Miocat,,,Read /home/miocat/flag:/home/miocat:/bin/bash chris:x:1000:1000::/home/chris:/bin/bash
http://../flag
でフラグが出てくる。良く分からない。
ElizabethDoesntSayLazy