[Web] Truth about Pi
lodash.get
の 4.4.2
では __proto__
にもアクセスできる。''.__proto__.length
は 0
。
curl 'http://chal.hakatashi.com:10043/' -H 'Content-Type: application/x-www-form-urlencoded' --data-raw 'index=__proto__.length'
[Rev] decompile me
Brainf*ckが実行ファイル(ELF)にコンパイルされてしまった。出力されたELFは objdump -d bf
ではなぜか逆アセンブルできないので objdump -D -b binary -m i386:x86-64 -M intel bf > bf.s
で無理やり逆アセンブルする。続いて雑にデコンパイル。
with open('bf.s') as f: s = f.read() s = s[s.index('d2:'):s.index('25f1:')] s = s.splitlines() s = iter(s) res = [] jmps = {} def find(dst): for i, x in enumerate(res): if x[0] == dst: return i return None line = next(s) try: while True: cur = line.split()[0][:-1] if 'rax,0x1' in line: next(s) next(s) next(s) next(s) res.append([cur, '.']) elif 'rax,0x0' in line: next(s) # mov rdi, ... next(s) # mov rsi, rbx next(s) # mov rdx, 1 next(s) # syscall res.append([cur, ',']) elif 'inc rbx' in line: res.append([cur, '>']) elif 'dec rbx' in line: res.append([cur, '<']) elif 'mov al,BYTE PTR [rbx]' in line: line = next(s) if 'inc al' in line: next(s) res.append([cur, '+']) elif 'dec al' in line: next(s) res.append([cur, '-']) else: res.append([cur, '']) jmp = next(s).split() cur = jmp[0][:-1] res.append([cur, '']) cmp = jmp[-2] dst = jmp[-1][2:] if cmp == 'je': pass elif cmp == 'jne': pass jmps[dst] = cmp line = next(s) except: pass code = '' for addr, inst in res: if addr in jmps: code += ']['[jmps[addr] == 'jne'] del jmps[addr] code += inst print(code)
出力されたBFコードをよく見ると、文字入力(,
)の前に [<->-]<[<+>[-]]<>
というコードがほぼ必ずくっついていることがわかる。よくわからないけど、これを削除した上で文字入力を文字出力に変えてやるとフラグが得られる。
console.log(a = `>>+++++++[<++++++++++++>-]<[<->-]<[<+>[-]]<>,>>+++++++[<++++++++++++>-]<-[<->-]<[<+>[-]]<>,>>+++++++[<++++++++++>-]<+[<->-]<[<+>[-]]<>,>>+++++++[<+++++++++++>-]<-[<->-]<[<+>[-]]<>,>>++++++++[<+++++++++>-]<+[<->-]<[<+>[-]]<>,>>+++++++[<++++++++++++>-]<++[<->-]<[<+>[-]]<>,>>+++++++[<++++++++++>-]<-[<->-]<[<+>[-]]<>,>>+++++++++++[<+++++++++++>-]<++[<->-]<[<+>[-]]<>,>>+++++++[<+++++++++>-]<-[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>+++++++[<+++++++++++++>-]<[<->-]<[<+>[-]]<>,>>++++++[<++++++++++>-]<[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>+++++++[<+++++++++>-]<-[<->-]<[<+>[-]]<>,>>+++++[<+++++++++>-]<[<->-]<[<+>[-]]<>,>>+++++++[<+++++++++++++>-]<++[<->-]<[<+>[-]]<>,>>++++++[<++++++++++>-]<[<->-]<[<+>[-]]<>,>>++++++[<+++++++>-]<+[<->-]<[<+>[-]]<>,>>+++++++++[<++++++++++++++>-]<-[<->-]<[<+>[-]]<>+<[>->>++++++[<+++++++++++++>-]<.>>+++++++[<++++++++++>-]<+.>>++[<+++++>-]<.<<<<[-]]>[->++++++++[<++++++++++>-]<-.>>+++++[<+++++++++++++++>-]<.>>++[<+++++>-]<.>]`.replaceAll('[<->-]<[<+>[-]]<>', '').replaceAll(',', '.'))