Rating: 5.0

## bookOfSecrets (472 pts) (Crypto)

```
Found this book on the street together with a strange note...
[[14, 7, 57],[21, 2, 32],[31, 9, 51],[39, 8, 42],[82, 1, 67],[21, 11, 26],[65, 2, 23,],[5, 25, 27],[50, 12, 16],[4, 0, 56],[13, 3, 6],[7, 15, 10],[65, 9, 31],[84, 27, 27],[2, 9, 55],[4, 10, 3],[86, 7, 15],[16, 6, 41],[82, 9, 21],[14, 5, 7],[79, 8, 24],[78, 14, 42],[26, 2, 21],[3, 19, 13],[47, 13, 46],[37, 4, 17],[72, 9, 45],[69, 21, 46],[47, 16, 22],[44, 27, 56],[63, 17, 34]]

Given: a .txt file named bookOfSecrets.txt
```

bookOfSecrets.txt contained 2025 lines of text in neat-looking chunks like this:

```
dvpwg30d2wny{rk8lsobbnc1p_b}{tq3yeq8diczjtk_nx-5ab26pfbo1gifpyq{yms{-k
64hvpr9w0hhnutfw5t3lkyuasmq4ea-ms3ifkbrvcw5uvlcow}srhzkj6lfecca-dnbak0
k2{2nkkz2-4khl1soqk6zhj9}5_k079ophilu5lpv23r4ie466xlkyu}2s2umqlvtnspv-
j19xvwbsd481m{8r{_a_pu4y19{9zjbtimky_dp{0dp77jp}m{qj2q0}msiia9g2b03g_{
98wuqg9l20-{-pntc{89{4d8m_ekbs20umj}i_fevgzg63nt6qhw5yrsqdd9txxelbwhbk
d5_r35pfmmtkcdfzebzzslotnz5ro54jnd62}73ddadsx52t3foel57pa370rczhhm{x2b
6c-fydb87vap3i_lnrvd5say8iu-{hqycy27pbsi_oqmm2xzk1}2ic8{2q}g952qc31_kb
o_hif4mki2awyoovcb8e11k3d8lrjekiyl0dl53shbcbka6}z5fiz1wee05ewg9plj27nm
i85_hcw64cud47e1j3rp0---pq{-fjdyrawxdzedof5-l9{4ul3walcymn785_c7la--69
14}dz7}defma1pkj}ist_a0p2{u4xscgadkwu-gz78i9qb9pfua2pjfb}kbamyadt4m0c9
fc363eufg1ltc6itpj8zn3_88}erc37qchl5l6e28l7l-x__uuvdg-t4728c2yjofq-7ip
4_uj8behfmoic0j9rbt1a5_ssnyc095xxow5i8c6r}b{ui9}08nl{lwnw4sp}v_oqdssl-
67xo1ujciexyfz4ju{ba3j{sa{vqaks}50_je0giiatmdrj5thf9uyu35ee74wegdfqwqu

73q2u9gij58kbkyd_l}bbrm5tjno31}0fih_dcr4j35enmdg05v0fmcov5fh_7tiz9f}x7
2zzl8qwp38s25953zfa3de251jlw-1av5z6h5ua_ko{kl{}ivgl70{x5pt8km}h1-yjr7r
87i_s{8zdi9tf6ks0ayuk{gdpqti2_3yos9sfnxpwg7zu2hjxhr{8fztmfd332cifac-hd
_c3w12twmo{r7cf6tkdqovodh7wr-ep1s}bbej}1u-wj_9dqxrxvc6_nwf2w-t{9gtyc94
p_okjlnbagph4bl7sh{b4vr4z{qmuy-4sik2_05midn67nufv7o4}_rzwl4m5um1q}hcj9
f-jip7nr8c}du}i-}}y0}ai6hi075467turset6lxke__r9vo}y57kgdf2_go2ktmuvpwv
0q2bjtoa}q9wgu{tehachn--6a{3463r{w1ttosjjflk4-h6r8qg_1pofup4{gh7xqbaje
{}omqwvpxcx_s7whjmx18{51p7{ryl{m8lu9qcznegc-6n4ip39hd69y15vcnqgrt4y1oc
6_dpiiblb4f7p}j{v3auj50qxhrhh6nh6j1{odh1pizxkgj2nuq-9pmnlw0qsu}klbvmfs
m1f8yayfvtyyn}hrq41pys3t188_ulm3bnvs8monm1pxwwz{4me}vqrc46owne}op1guib
r2pq{sr_g{1{esw6rh4ogier-jsou{a27nd_ndv{4aqy2c7wx7c2ge44ym9gmnlamy6kfu
b9jxchpo1k{jf}dn5md4q_65pfib4s-q97}9b7v0fkn55iop{kkbze0odwp0w6oy_8}lky
8y2ag83lp39}sexc5n01ms3j91-3_{vw9o-vt10z3yw8ul4047{1nox4gz4oepulebz3fq
-vm-q1qr0p7qc8nz9q12fbybv-p5_3u5x1dq}d299jv}wbi-yw6sbs7g3z62my-zp{xpje
6zsbr0de2uw1-_-mkt6fn__ch9zlvti9orimmur-2_ro10kx4zlb4m40ew4w7tn7sidasn
4j25r15ivl4nc0bmt-4}b5wmp2t3j9na0rfooqkg8-pu9e3j{ijh8w8wqm423w1f_9ycd-
s{nxedlqtou58v0bokrgox_q4njrts0m32gqiorj6d-38qw0e91oioms399g16i{h4{7}g
d-hyn3}3v6y5gsn8}4q47cje-a{xc1w5-cmchxj}uqa{21w7ibmx}p9dp6mxol2jr{lhcf
enksy0u19vo05l-}u7hw9_0dvpk-pa5u-g1c2vg}wutun_tnwobsmcm397a3j4m0cmrk{b

```

Because of the title of the challenge, we assumed that each block of text corresponded to a page in a book. The list given in the description was assumed to tell us where in the book we could find the next letter. For example, `[14, 7, 57]` would mean page #14, line #7, character #57. We could then proceed to write the following Python script:

```
import sys

code = [[14, 7, 57],[21, 2, 32],[31, 9, 51],[39, 8, 42],[82, 1, 67],[21, 11, 26],[65, 2, 23,],[5, 25, 27],[50, 12, 16],[4, 0, 56],[13, 3, 6],[7, 15, 10],[65, 9, 31],[84, 27, 27],[2, 9, 55],[4, 10, 3],[86, 7, 15],[16, 6, 41],[82, 9, 21],[14, 5, 7],[79, 8, 24],[78, 14, 42],[26, 2, 21],[3, 19, 13],[47, 13, 46],[37, 4, 17],[72, 9, 45],[69, 21, 46],[47, 16, 22],[44, 27, 56],[63, 17, 34]]

data =[]
current_page = []
for line in sys.stdin:
line = line.strip()
if line == "":
data.append(current_page)
current_page = []
else:
current_page.append(line)

for t in code:
page = t[0]
line = t[1]
letter = t[2]

print( data[page][line][letter], end="")
print()
```

Running `python3 script.py < bookOfSecrets.txt` printed the flag.

`bth_ctf{r34d_b37w33n_7h3_l1n35}`

Original writeup (https://github.com/liuhack/writeups/tree/master/2019/BTH_CTF/bookOfSecrets).